Skip to content

Commit

Permalink
Merge pull request #381 from curvefi/fix/fix-gauge
Browse files Browse the repository at this point in the history
test: fix gauge in tests
  • Loading branch information
Macket authored Aug 19, 2024
2 parents 89fdb86 + 24b8ac6 commit 6faa712
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@curvefi/api",
"version": "2.61.14",
"version": "2.61.15",
"description": "JavaScript library for curve.fi",
"main": "lib/index.js",
"author": "Macket",
Expand Down
4 changes: 2 additions & 2 deletions test/apy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const poolStatsTest = (name: string) => {


it('Token (CRV) APY', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) return;
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) return;

const apy = await pool.stats.tokenApy(false);
const apyFromApi = await pool.stats.tokenApy();
Expand All @@ -36,7 +36,7 @@ const poolStatsTest = (name: string) => {
});

it('Rewards APY', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) return;
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) return;

const rewardsApy = (await pool.stats.rewardsApy(false)).filter((r) => r.apy > 0);
const rewardsApyFromApi = (await pool.stats.rewardsApy()).filter((r) => r.apy > 0);
Expand Down
46 changes: 23 additions & 23 deletions test/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -67,7 +67,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -101,7 +101,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -164,7 +164,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -220,7 +220,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -249,7 +249,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -278,7 +278,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -307,7 +307,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -338,7 +338,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -367,7 +367,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -396,7 +396,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -425,7 +425,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -457,7 +457,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStakeWrapped([10, 10]);
const balances = await pool.stats.wrappedBalances();
Expand Down Expand Up @@ -487,7 +487,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStakeWrapped([10, 10]);
const balances = await pool.stats.wrappedBalances();
Expand Down Expand Up @@ -532,7 +532,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -562,7 +562,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -594,7 +594,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStakeWrapped([10, 10]);
const balances = await pool.stats.wrappedBalances();
Expand Down Expand Up @@ -624,7 +624,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStakeWrapped([10, 10]);
const balances = await pool.stats.wrappedBalances();
Expand Down Expand Up @@ -656,7 +656,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -686,7 +686,7 @@ describe('Factory deploy', function() {
const poolId = await curve.factory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

await pool.depositAndStake([10, 10, 10]);
const balances = await pool.stats.underlyingBalances();
Expand Down Expand Up @@ -728,7 +728,7 @@ describe('Factory deploy', function() {
const poolId = await curve.cryptoFactory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

const amounts = await pool.cryptoSeedAmounts(30);
await pool.depositAndStake(amounts);
Expand Down Expand Up @@ -774,7 +774,7 @@ describe('Factory deploy', function() {
const poolId = await curve.tricryptoFactory.fetchRecentlyDeployedPool(poolAddress);
const pool = curve.getPool(poolId);
assert.equal(poolAddress.toLowerCase(), pool.address);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge);
assert.equal(gaugeAddress.toLowerCase(), pool.gauge.address);

const amounts = await pool.cryptoSeedAmounts(30);
console.log(amounts);
Expand Down
26 changes: 13 additions & 13 deletions test/readme.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const poolFieldsTest = async () => {
console.log(pool.referenceAsset);
console.log(pool.address);
console.log(pool.lpToken);
console.log(pool.gauge);
console.log(pool.gauge.address);
console.log(pool.zap);
console.log(pool.rewardContract);
console.log(pool.isPlain);
Expand Down Expand Up @@ -962,23 +962,23 @@ const daoGaugeVoting = async () => {
console.log(await curve.dao.createCrvLock(10000, 365 * 2));

console.log(await curve.dao.getVotingGaugeList());
console.log(await curve.dao.voteForGaugeNextTime(pool1.gauge));
console.log(await curve.dao.voteForGaugeNextTime(pool2.gauge));
console.log(await curve.dao.estimateGas.voteForGauge(pool1.gauge, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool1.gauge, 50)); // 50%
console.log(await curve.dao.estimateGas.voteForGauge(pool2.gauge, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool2.gauge, 50)); // 50%
console.log(await curve.dao.voteForGaugeNextTime(pool1.gauge));
console.log(await curve.dao.voteForGaugeNextTime(pool2.gauge));
console.log(await curve.dao.voteForGaugeNextTime(pool1.gauge.address));
console.log(await curve.dao.voteForGaugeNextTime(pool2.gauge.address));
console.log(await curve.dao.estimateGas.voteForGauge(pool1.gauge.address, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool1.gauge.address, 50)); // 50%
console.log(await curve.dao.estimateGas.voteForGauge(pool2.gauge.address, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool2.gauge.address, 50)); // 50%
console.log(await curve.dao.voteForGaugeNextTime(pool1.gauge.address));
console.log(await curve.dao.voteForGaugeNextTime(pool2.gauge.address));
console.log(await curve.dao.userGaugeVotes());

console.log(await curve.dao.increaseCrvUnlockTime(365 * 2));
console.log(await curve.dao.userGaugeVotes());
// Adjust voting power. 10 days time travel is needed
console.log(await curve.dao.estimateGas.voteForGauge(pool1.gauge, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool1.gauge, 50)); // 50%
console.log(await curve.dao.estimateGas.voteForGauge(pool2.gauge, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool2.gauge, 50)); // 50%
console.log(await curve.dao.estimateGas.voteForGauge(pool1.gauge.address, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool1.gauge.address, 50)); // 50%
console.log(await curve.dao.estimateGas.voteForGauge(pool2.gauge.address, 50)); // 50%
console.log(await curve.dao.voteForGauge(pool2.gauge.address, 50)); // 50%
console.log(await curve.dao.userGaugeVotes());
}

Expand Down
2 changes: 1 addition & 1 deletion test/stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const poolStatsTest = (name: string) => {
});

it('Token APY', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS || pool.rewardsOnly()) {
console.log("Skip");
return
}
Expand Down
6 changes: 3 additions & 3 deletions test/underlying.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ const underlyingLiquidityTest = (id: string) => {
});

it('Stake', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return
}
Expand All @@ -121,7 +121,7 @@ const underlyingLiquidityTest = (id: string) => {
});

it('Deposit&stake', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return;
}
Expand All @@ -148,7 +148,7 @@ const underlyingLiquidityTest = (id: string) => {
});

it('Unstake', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return
}
Expand Down
6 changes: 3 additions & 3 deletions test/wrapped.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const wrappedLiquidityTest = (id: string) => {
});

it('Stake', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return
}
Expand All @@ -101,7 +101,7 @@ const wrappedLiquidityTest = (id: string) => {
});

it('Deposit&stake', async function () {
if (pool.isPlain || pool.isFake || pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.isPlain || pool.isFake || pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return;
}
Expand All @@ -128,7 +128,7 @@ const wrappedLiquidityTest = (id: string) => {
});

it('Unstake', async function () {
if (pool.gauge === _curve.constants.ZERO_ADDRESS) {
if (pool.gauge.address === _curve.constants.ZERO_ADDRESS) {
console.log('Skip');
return
}
Expand Down

0 comments on commit 6faa712

Please sign in to comment.