mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
wip: Fix Curve tests to use underlying pool tokens instead of gauges
This commit is contained in:
parent
a693e0b767
commit
b5ba303e8f
|
@ -53,6 +53,7 @@ import {
|
||||||
RewardsATokenMockFactory,
|
RewardsATokenMockFactory,
|
||||||
CurveGaugeRewardsAwareATokenFactory,
|
CurveGaugeRewardsAwareATokenFactory,
|
||||||
CurveTreasuryFactory,
|
CurveTreasuryFactory,
|
||||||
|
CurveGaugeReserveInterestRateStrategyFactory,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import {
|
import {
|
||||||
withSaveAndVerify,
|
withSaveAndVerify,
|
||||||
|
@ -322,6 +323,17 @@ export const deployDefaultReserveInterestRateStrategy = async (
|
||||||
verify
|
verify
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const deployCurveGaugeReserveInterestRateStrategy = async (
|
||||||
|
args: [tEthereumAddress, string, string, string, string, string, string],
|
||||||
|
verify: boolean
|
||||||
|
) =>
|
||||||
|
withSaveAndVerify(
|
||||||
|
await new CurveGaugeReserveInterestRateStrategyFactory(await getFirstSigner()).deploy(...args),
|
||||||
|
eContractid.DefaultReserveInterestRateStrategy,
|
||||||
|
args,
|
||||||
|
verify
|
||||||
|
);
|
||||||
|
|
||||||
export const deployStableDebtToken = async (
|
export const deployStableDebtToken = async (
|
||||||
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
args: [tEthereumAddress, tEthereumAddress, tEthereumAddress, string, string],
|
||||||
verify: boolean
|
verify: boolean
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { ZERO_ADDRESS } from '../../../helpers/constants';
|
import { MAX_UINT_AMOUNT, ZERO_ADDRESS } from '../../../helpers/constants';
|
||||||
import { makeSuite, SignerWithAddress, TestEnv } from '../helpers/make-suite';
|
import { makeSuite, SignerWithAddress, TestEnv } from '../helpers/make-suite';
|
||||||
import {
|
import {
|
||||||
advanceTimeAndBlock,
|
advanceTimeAndBlock,
|
||||||
|
@ -15,7 +15,10 @@ import {
|
||||||
getLendingPoolAddressesProvider,
|
getLendingPoolAddressesProvider,
|
||||||
getLendingPoolConfiguratorProxy,
|
getLendingPoolConfiguratorProxy,
|
||||||
} from '../../../helpers/contracts-getters';
|
} from '../../../helpers/contracts-getters';
|
||||||
import { deployDefaultReserveInterestRateStrategy } from '../../../helpers/contracts-deployments';
|
import {
|
||||||
|
deployCurveGaugeReserveInterestRateStrategy,
|
||||||
|
deployDefaultReserveInterestRateStrategy,
|
||||||
|
} from '../../../helpers/contracts-deployments';
|
||||||
import { IERC20Factory } from '../../../types/IERC20Factory';
|
import { IERC20Factory } from '../../../types/IERC20Factory';
|
||||||
import BigNumberJs from 'bignumber.js';
|
import BigNumberJs from 'bignumber.js';
|
||||||
import { CurveGaugeRewardsAwareATokenFactory } from '../../../types';
|
import { CurveGaugeRewardsAwareATokenFactory } from '../../../types';
|
||||||
|
@ -25,35 +28,40 @@ import { checkRewards } from '../helpers/rewards-distribution/verify';
|
||||||
import { IRewardsAwareAToken } from '../../../types/IRewardsAwareAToken';
|
import { IRewardsAwareAToken } from '../../../types/IRewardsAwareAToken';
|
||||||
import { IRewardsAwareATokenFactory } from '../../../types/IRewardsAwareATokenFactory';
|
import { IRewardsAwareATokenFactory } from '../../../types/IRewardsAwareATokenFactory';
|
||||||
import { BigNumber } from 'ethers';
|
import { BigNumber } from 'ethers';
|
||||||
import { parseEther } from 'ethers/lib/utils';
|
import { AbiCoder, defaultAbiCoder, parseEther } from 'ethers/lib/utils';
|
||||||
import { IERC20 } from '../../../types/IERC20';
|
import { IERC20 } from '../../../types/IERC20';
|
||||||
import {
|
import {
|
||||||
getContractAddressWithJsonFallback,
|
getContractAddressWithJsonFallback,
|
||||||
getParamPerNetwork,
|
getParamPerNetwork,
|
||||||
} from '../../../helpers/contracts-helpers';
|
} from '../../../helpers/contracts-helpers';
|
||||||
import { ConfigNames, loadPoolConfig } from '../../../helpers/configuration';
|
import { ConfigNames, loadPoolConfig } from '../../../helpers/configuration';
|
||||||
|
import { ICurveGaugeFactory } from '../../../types/ICurveGaugeFactory';
|
||||||
const ONE_DAY = 86400;
|
const ONE_DAY = 86400;
|
||||||
const { expect } = require('chai');
|
const { expect } = require('chai');
|
||||||
|
|
||||||
interface GaugeInfo {
|
interface GaugeInfo {
|
||||||
|
underlying: tEthereumAddress;
|
||||||
address: tEthereumAddress;
|
address: tEthereumAddress;
|
||||||
name: string;
|
name: string;
|
||||||
symbol: string;
|
symbol: string;
|
||||||
rewardTokens: tEthereumAddress[];
|
rewardTokens: tEthereumAddress[];
|
||||||
}
|
}
|
||||||
|
const BLOCK_HEIGHT = '';
|
||||||
const USER_ADDRESS = '0x9c5083dd4838E120Dbeac44C052179692Aa5dAC5';
|
const USER_ADDRESS = '0x9c5083dd4838E120Dbeac44C052179692Aa5dAC5';
|
||||||
|
|
||||||
const CRV_TOKEN = '0xd533a949740bb3306d119cc777fa900ba034cd52';
|
const CRV_TOKEN = '0xd533a949740bb3306d119cc777fa900ba034cd52';
|
||||||
const SNX_TOKEN = '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f';
|
const SNX_TOKEN = '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f';
|
||||||
|
|
||||||
const GAUGE_3POOL: GaugeInfo = {
|
const GAUGE_3POOL: GaugeInfo = {
|
||||||
|
underlying: '0x6c3F90f043a72FA612cbac8115EE7e52BDe6E490',
|
||||||
address: '0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A',
|
address: '0xbFcF63294aD7105dEa65aA58F8AE5BE2D9d0952A',
|
||||||
name: 'aToken 3pool Gauge Deposit',
|
name: 'aToken 3pool Gauge Deposit',
|
||||||
|
symbol: 'a-3poolCRV-gauge',
|
||||||
rewardTokens: [],
|
rewardTokens: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
const GAUGE_AAVE3: GaugeInfo = {
|
const GAUGE_AAVE3: GaugeInfo = {
|
||||||
|
underlying: '0xFd2a8fA60Abd58Efe3EeE34dd494cD491dC14900',
|
||||||
address: '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d',
|
address: '0xd662908ADA2Ea1916B3318327A97eB18aD588b5d',
|
||||||
name: 'aToken a3CRV Gauge Deposit',
|
name: 'aToken a3CRV Gauge Deposit',
|
||||||
symbol: 'a-a3CRV-gauge',
|
symbol: 'a-a3CRV-gauge',
|
||||||
|
@ -61,6 +69,7 @@ const GAUGE_AAVE3: GaugeInfo = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GAUGE_EURS: GaugeInfo = {
|
const GAUGE_EURS: GaugeInfo = {
|
||||||
|
underlying: '0x194eBd173F6cDacE046C53eACcE9B953F28411d1',
|
||||||
address: '0x90Bb609649E0451E5aD952683D64BD2d1f245840',
|
address: '0x90Bb609649E0451E5aD952683D64BD2d1f245840',
|
||||||
name: 'aToken eursCRV Gauge Deposit',
|
name: 'aToken eursCRV Gauge Deposit',
|
||||||
symbol: 'a-eursCRV-gauge',
|
symbol: 'a-eursCRV-gauge',
|
||||||
|
@ -68,6 +77,7 @@ const GAUGE_EURS: GaugeInfo = {
|
||||||
};
|
};
|
||||||
|
|
||||||
const GAUGE_ANKR: GaugeInfo = {
|
const GAUGE_ANKR: GaugeInfo = {
|
||||||
|
underlying: '0xaA17A236F2bAdc98DDc0Cf999AbB47D47Fc0A6Cf',
|
||||||
address: '0x6d10ed2cf043e6fcf51a0e7b4c2af3fa06695707',
|
address: '0x6d10ed2cf043e6fcf51a0e7b4c2af3fa06695707',
|
||||||
name: 'aToken ankrCRV Gauge Deposit',
|
name: 'aToken ankrCRV Gauge Deposit',
|
||||||
symbol: 'a-ankrCRV-gauge',
|
symbol: 'a-ankrCRV-gauge',
|
||||||
|
@ -77,6 +87,14 @@ const GAUGE_ANKR: GaugeInfo = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const unstakeAllGauges = async (key: SignerWithAddress, gauges: tEthereumAddress[]) => {
|
||||||
|
for (let x = 0; x < gauges.length; x++) {
|
||||||
|
await waitForTx(
|
||||||
|
await ICurveGaugeFactory.connect(gauges[x], key.signer).withdraw(MAX_UINT_AMOUNT)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddress) => {
|
const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddress) => {
|
||||||
const { symbol } = gauge;
|
const { symbol } = gauge;
|
||||||
const poolConfig = loadPoolConfig(ConfigNames.Aave);
|
const poolConfig = loadPoolConfig(ConfigNames.Aave);
|
||||||
|
@ -109,7 +127,7 @@ const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddres
|
||||||
ConfigNames.Aave
|
ConfigNames.Aave
|
||||||
);
|
);
|
||||||
// WBTC Strategy used as a template for tests scenario
|
// WBTC Strategy used as a template for tests scenario
|
||||||
const interestStrategy = await deployDefaultReserveInterestRateStrategy(
|
const interestStrategy = await deployCurveGaugeReserveInterestRateStrategy(
|
||||||
[
|
[
|
||||||
addressProvider.address,
|
addressProvider.address,
|
||||||
strategyWBTC.strategy.optimalUtilizationRate,
|
strategyWBTC.strategy.optimalUtilizationRate,
|
||||||
|
@ -122,7 +140,7 @@ const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddres
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
const interestRateStrategyAddress = interestStrategy.address;
|
const interestRateStrategyAddress = interestStrategy.address;
|
||||||
|
const encodedParams = defaultAbiCoder.encode(['string'], [gauge.address]);
|
||||||
const curveReserveInitParams = [
|
const curveReserveInitParams = [
|
||||||
{
|
{
|
||||||
aTokenImpl,
|
aTokenImpl,
|
||||||
|
@ -130,7 +148,7 @@ const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddres
|
||||||
variableDebtTokenImpl,
|
variableDebtTokenImpl,
|
||||||
underlyingAssetDecimals: '18',
|
underlyingAssetDecimals: '18',
|
||||||
interestRateStrategyAddress,
|
interestRateStrategyAddress,
|
||||||
underlyingAsset: gauge.address,
|
underlyingAsset: gauge.underlying,
|
||||||
treasury,
|
treasury,
|
||||||
incentivesController: ZERO_ADDRESS,
|
incentivesController: ZERO_ADDRESS,
|
||||||
underlyingAssetName: gauge.symbol,
|
underlyingAssetName: gauge.symbol,
|
||||||
|
@ -140,60 +158,60 @@ const listCurveLPToken = async (gauge: GaugeInfo, curveTreasury: tEthereumAddres
|
||||||
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${symbol}`,
|
variableDebtTokenSymbol: `variableDebt${symbolPrefix}${symbol}`,
|
||||||
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${symbol}`,
|
stableDebtTokenName: `${stableDebtTokenNamePrefix} ${symbol}`,
|
||||||
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${symbol}`,
|
stableDebtTokenSymbol: `stableDebt${symbolPrefix}${symbol}`,
|
||||||
params: '0x10',
|
params: encodedParams,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
await waitForTx(await poolConfigurator.batchInitReserve(curveReserveInitParams));
|
await waitForTx(await poolConfigurator.batchInitReserve(curveReserveInitParams));
|
||||||
};
|
};
|
||||||
|
|
||||||
const depositGauge = async (
|
const depositPoolToken = async (
|
||||||
key: SignerWithAddress,
|
key: SignerWithAddress,
|
||||||
gauge: GaugeInfo,
|
gauge: GaugeInfo,
|
||||||
aGaugeAddress: tEthereumAddress,
|
aTokenAddress: tEthereumAddress,
|
||||||
amount: BigNumber,
|
amount: BigNumber,
|
||||||
shouldReward?: boolean
|
shouldReward?: boolean
|
||||||
) => {
|
) => {
|
||||||
const pool = await getLendingPool();
|
const pool = await getLendingPool();
|
||||||
const gaugeErc20 = IERC20Factory.connect(gauge.address, key.signer);
|
const curveReserveToken = IERC20Factory.connect(gauge.underlying, key.signer);
|
||||||
|
|
||||||
await gaugeErc20.connect(key.signer).approve(pool.address, amount);
|
await curveReserveToken.connect(key.signer).approve(pool.address, amount);
|
||||||
|
|
||||||
const txDeposit = await waitForTx(
|
const txDeposit = await waitForTx(
|
||||||
await pool.connect(key.signer).deposit(gauge.address, amount, key.address, '0')
|
await pool.connect(key.signer).deposit(gauge.underlying, amount, key.address, '0')
|
||||||
);
|
);
|
||||||
|
|
||||||
await checkRewards(key, aGaugeAddress, txDeposit.blockNumber, shouldReward);
|
await checkRewards(key, aTokenAddress, txDeposit.blockNumber, shouldReward);
|
||||||
};
|
};
|
||||||
|
|
||||||
const withdrawGauge = async (
|
const withdrawPoolToken = async (
|
||||||
key: SignerWithAddress,
|
key: SignerWithAddress,
|
||||||
gauge: GaugeInfo,
|
gauge: GaugeInfo,
|
||||||
aGaugeAddress: tEthereumAddress,
|
aTokenAddress: tEthereumAddress,
|
||||||
shouldReward = true
|
shouldReward = true
|
||||||
) => {
|
) => {
|
||||||
const pool = await getLendingPool();
|
const pool = await getLendingPool();
|
||||||
const aGauge = IRewardsAwareATokenFactory.connect(aGaugeAddress, key.signer);
|
const aGauge = IRewardsAwareATokenFactory.connect(aTokenAddress, key.signer);
|
||||||
|
|
||||||
const entireBalance = await aGauge.balanceOf(key.address);
|
const entireBalance = await aGauge.balanceOf(key.address);
|
||||||
|
|
||||||
await aGauge.connect(key.signer).approve(pool.address, entireBalance);
|
await aGauge.connect(key.signer).approve(pool.address, entireBalance);
|
||||||
|
|
||||||
const txWithdraw = await waitForTx(
|
const txWithdraw = await waitForTx(
|
||||||
await pool.connect(key.signer).withdraw(gauge.address, entireBalance, key.address)
|
await pool.connect(key.signer).withdraw(gauge.underlying, entireBalance, key.address)
|
||||||
);
|
);
|
||||||
|
|
||||||
await checkRewards(key, aGaugeAddress, txWithdraw.blockNumber, shouldReward);
|
await checkRewards(key, aTokenAddress, txWithdraw.blockNumber, shouldReward);
|
||||||
};
|
};
|
||||||
|
|
||||||
const claimFromGauge = async (
|
const claimFromGauge = async (
|
||||||
key: SignerWithAddress,
|
key: SignerWithAddress,
|
||||||
gauge: GaugeInfo,
|
gauge: GaugeInfo,
|
||||||
aGaugeAddress: tEthereumAddress,
|
aTokenAddress: tEthereumAddress,
|
||||||
shouldReward = true
|
shouldReward = true
|
||||||
) => {
|
) => {
|
||||||
const aGauge = IRewardsAwareATokenFactory.connect(aGaugeAddress, key.signer);
|
const aToken = IRewardsAwareATokenFactory.connect(aTokenAddress, key.signer);
|
||||||
const rewardTokens = await aGauge.getRewardsTokenAddressList();
|
const rewardTokens = await aToken.getRewardsTokenAddressList();
|
||||||
|
|
||||||
for (let x = 0; x < rewardTokens.length; x++) {
|
for (let x = 0; x < rewardTokens.length; x++) {
|
||||||
if (rewardTokens[x] == ZERO_ADDRESS) break;
|
if (rewardTokens[x] == ZERO_ADDRESS) break;
|
||||||
|
@ -201,11 +219,11 @@ const claimFromGauge = async (
|
||||||
const balanceBefore = await IERC20Factory.connect(rewardTokens[x], key.signer).balanceOf(
|
const balanceBefore = await IERC20Factory.connect(rewardTokens[x], key.signer).balanceOf(
|
||||||
key.address
|
key.address
|
||||||
);
|
);
|
||||||
const txClaim = await waitForTx(await aGauge.claim(rewardTokens[x]));
|
const txClaim = await waitForTx(await aToken.claim(rewardTokens[x]));
|
||||||
|
|
||||||
await checkRewards(
|
await checkRewards(
|
||||||
key,
|
key,
|
||||||
aGaugeAddress,
|
aTokenAddress,
|
||||||
txClaim.blockNumber,
|
txClaim.blockNumber,
|
||||||
shouldReward,
|
shouldReward,
|
||||||
rewardTokens[x],
|
rewardTokens[x],
|
||||||
|
@ -218,10 +236,12 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
let evmSnapshotId;
|
let evmSnapshotId;
|
||||||
let depositor: SignerWithAddress;
|
let depositor: SignerWithAddress;
|
||||||
|
|
||||||
let gaugeEursErc20: IERC20;
|
let curve3poolErc20: IERC20;
|
||||||
let gaugeAave3Erc20: IERC20;
|
let curveEursErc20: IERC20;
|
||||||
let gaugeAnkrErc20: IERC20;
|
let curveAave3Erc20: IERC20;
|
||||||
|
let curveAnkrErc20: IERC20;
|
||||||
|
|
||||||
|
let a3POOL: IRewardsAwareAToken;
|
||||||
let aEURS: IRewardsAwareAToken;
|
let aEURS: IRewardsAwareAToken;
|
||||||
let aAAVE3: IRewardsAwareAToken;
|
let aAAVE3: IRewardsAwareAToken;
|
||||||
let aANKR: IRewardsAwareAToken;
|
let aANKR: IRewardsAwareAToken;
|
||||||
|
@ -236,20 +256,34 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
// Set local vars
|
// Set local vars
|
||||||
depositor = await impersonateAddress(USER_ADDRESS);
|
depositor = await impersonateAddress(USER_ADDRESS);
|
||||||
|
|
||||||
gaugeEursErc20 = IERC20Factory.connect(GAUGE_EURS.address, depositor.signer);
|
curve3poolErc20 = IERC20Factory.connect(GAUGE_3POOL.underlying, depositor.signer);
|
||||||
gaugeAave3Erc20 = IERC20Factory.connect(GAUGE_AAVE3.address, depositor.signer);
|
curveEursErc20 = IERC20Factory.connect(GAUGE_EURS.underlying, depositor.signer);
|
||||||
gaugeAnkrErc20 = IERC20Factory.connect(GAUGE_ANKR.address, depositor.signer);
|
curveAave3Erc20 = IERC20Factory.connect(GAUGE_AAVE3.underlying, depositor.signer);
|
||||||
|
curveAnkrErc20 = IERC20Factory.connect(GAUGE_ANKR.underlying, depositor.signer);
|
||||||
crvToken = IERC20Factory.connect(CRV_TOKEN, depositor.signer);
|
crvToken = IERC20Factory.connect(CRV_TOKEN, depositor.signer);
|
||||||
snxToken = IERC20Factory.connect(SNX_TOKEN, depositor.signer);
|
snxToken = IERC20Factory.connect(SNX_TOKEN, depositor.signer);
|
||||||
|
// Unstake gauges to deposit into Aave
|
||||||
|
await unstakeAllGauges(depositor, [
|
||||||
|
GAUGE_3POOL.address,
|
||||||
|
GAUGE_AAVE3.address,
|
||||||
|
GAUGE_EURS.address,
|
||||||
|
GAUGE_ANKR.address,
|
||||||
|
]);
|
||||||
|
|
||||||
// Depositor should have EURS, AAVE3, and ANKR gauges balance
|
// Depositor should have 3pool, EURS, AAVE3, and ANKR balance
|
||||||
const gaugeEursBalance = await gaugeEursErc20.balanceOf(USER_ADDRESS);
|
const curve3poolBalance = await curve3poolErc20.balanceOf(USER_ADDRESS);
|
||||||
const gaugeAave3Balance = await gaugeAave3Erc20.balanceOf(USER_ADDRESS);
|
const gaugeCurve3poolBalance = await IERC20Factory.connect(
|
||||||
const gaugeAnkrBalance = await gaugeAnkrErc20.balanceOf(USER_ADDRESS);
|
GAUGE_3POOL.address,
|
||||||
|
depositor.signer
|
||||||
|
).balanceOf(USER_ADDRESS);
|
||||||
|
const curveEursBalance = await curveEursErc20.balanceOf(USER_ADDRESS);
|
||||||
|
const curveAave3Balance = await curveAave3Erc20.balanceOf(USER_ADDRESS);
|
||||||
|
const curveAnkrBalance = await curveAnkrErc20.balanceOf(USER_ADDRESS);
|
||||||
|
|
||||||
expect(gaugeEursBalance).to.be.gt('0');
|
expect(curve3poolBalance).to.be.gt('0', 'insufficient 3pool');
|
||||||
expect(gaugeAave3Balance).to.be.gt('0');
|
expect(curveEursBalance).to.be.gt('0', 'insufficient eurs');
|
||||||
expect(gaugeAnkrBalance).to.be.gt('0');
|
expect(curveAave3Balance).to.be.gt('0', 'insufficient aave3');
|
||||||
|
expect(curveAnkrBalance).to.be.gt('0', 'insufficient ankr');
|
||||||
|
|
||||||
// Deploy Curve Treasury
|
// Deploy Curve Treasury
|
||||||
const poolConfig = loadPoolConfig(ConfigNames.Aave);
|
const poolConfig = loadPoolConfig(ConfigNames.Aave);
|
||||||
|
@ -264,12 +298,17 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
collector,
|
collector,
|
||||||
});
|
});
|
||||||
// Gauge tokens should be listed at Aave test deployment
|
// Gauge tokens should be listed at Aave test deployment
|
||||||
|
await listCurveLPToken(GAUGE_3POOL, curveTreasury);
|
||||||
await listCurveLPToken(GAUGE_EURS, curveTreasury);
|
await listCurveLPToken(GAUGE_EURS, curveTreasury);
|
||||||
await listCurveLPToken(GAUGE_AAVE3, curveTreasury);
|
await listCurveLPToken(GAUGE_AAVE3, curveTreasury);
|
||||||
await listCurveLPToken(GAUGE_ANKR, curveTreasury);
|
await listCurveLPToken(GAUGE_ANKR, curveTreasury);
|
||||||
|
|
||||||
const allTokens = await testEnv.helpersContract.getAllATokens();
|
const allTokens = await testEnv.helpersContract.getAllATokens();
|
||||||
|
|
||||||
|
a3POOL = IRewardsAwareATokenFactory.connect(
|
||||||
|
allTokens.find((aToken) => aToken.symbol.includes('3pool'))?.tokenAddress || ZERO_ADDRESS,
|
||||||
|
await getFirstSigner()
|
||||||
|
);
|
||||||
aEURS = IRewardsAwareATokenFactory.connect(
|
aEURS = IRewardsAwareATokenFactory.connect(
|
||||||
allTokens.find((aToken) => aToken.symbol.includes('eurs'))?.tokenAddress || ZERO_ADDRESS,
|
allTokens.find((aToken) => aToken.symbol.includes('eurs'))?.tokenAddress || ZERO_ADDRESS,
|
||||||
await getFirstSigner()
|
await getFirstSigner()
|
||||||
|
@ -301,7 +340,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
it('Deposit and generate user reward checkpoints', async () => {
|
it('Deposit and generate user reward checkpoints', async () => {
|
||||||
// Deposits
|
// Deposits
|
||||||
await depositGauge(depositor, GAUGE_AAVE3, aAAVE3.address, parseEther('100000'));
|
await depositPoolToken(depositor, GAUGE_AAVE3, aAAVE3.address, parseEther('100000'));
|
||||||
const curveATokenBalance = await crvToken.balanceOf(aAAVE3.address);
|
const curveATokenBalance = await crvToken.balanceOf(aAAVE3.address);
|
||||||
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
||||||
});
|
});
|
||||||
|
@ -324,7 +363,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
await increaseTime(ONE_DAY);
|
await increaseTime(ONE_DAY);
|
||||||
|
|
||||||
// Withdraw
|
// Withdraw
|
||||||
await withdrawGauge(depositor, GAUGE_AAVE3, aAAVE3.address);
|
await withdrawPoolToken(depositor, GAUGE_AAVE3, aAAVE3.address);
|
||||||
const curveATokenBalance = await crvToken.balanceOf(aAAVE3.address);
|
const curveATokenBalance = await crvToken.balanceOf(aAAVE3.address);
|
||||||
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
||||||
});
|
});
|
||||||
|
@ -340,6 +379,55 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('AToken with only CRV rewards - 3pool Gauge', () => {
|
||||||
|
before(async () => {
|
||||||
|
evmSnapshotId = await evmSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
after(async () => {
|
||||||
|
await evmRevert(evmSnapshotId);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Deposit and generate user reward checkpoints', async () => {
|
||||||
|
// Deposits
|
||||||
|
await depositPoolToken(depositor, GAUGE_3POOL, a3POOL.address, parseEther('100000'));
|
||||||
|
const curveATokenBalance = await crvToken.balanceOf(a3POOL.address);
|
||||||
|
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Increase time and claim CRV', async () => {
|
||||||
|
// Pass time to generate rewards
|
||||||
|
await increaseTime(ONE_DAY);
|
||||||
|
|
||||||
|
// Claim
|
||||||
|
await claimFromGauge(depositor, GAUGE_3POOL, a3POOL.address);
|
||||||
|
const curveATokenBalance = await crvToken.balanceOf(a3POOL.address);
|
||||||
|
expect(curveATokenBalance).to.be.eq(
|
||||||
|
'0',
|
||||||
|
'CRV Balance should be zero as there is only one aToken holder'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Pass time and withdraw Staked AAVE3', async () => {
|
||||||
|
// Pass time to generate rewards
|
||||||
|
await increaseTime(ONE_DAY);
|
||||||
|
|
||||||
|
// Withdraw
|
||||||
|
await withdrawPoolToken(depositor, GAUGE_3POOL, a3POOL.address);
|
||||||
|
const curveATokenBalance = await crvToken.balanceOf(a3POOL.address);
|
||||||
|
expect(curveATokenBalance).to.be.eq('0', 'CRV rewards should be zero');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Claim the remaining CRV', async () => {
|
||||||
|
// Claim
|
||||||
|
await claimFromGauge(depositor, GAUGE_AAVE3, aAAVE3.address);
|
||||||
|
const curveATokenBalance = await crvToken.balanceOf(a3POOL.address);
|
||||||
|
expect(curveATokenBalance).to.be.eq(
|
||||||
|
'0',
|
||||||
|
'CRV Balance should be zero as there is only one aToken holder'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
describe('AToken with CRV and 1 extra rewards - EURS Gauge', () => {
|
describe('AToken with CRV and 1 extra rewards - EURS Gauge', () => {
|
||||||
before(async () => {
|
before(async () => {
|
||||||
evmSnapshotId = await evmSnapshot();
|
evmSnapshotId = await evmSnapshot();
|
||||||
|
@ -352,7 +440,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
it('Deposit and generate user reward checkpoints', async () => {
|
it('Deposit and generate user reward checkpoints', async () => {
|
||||||
// Deposits
|
// Deposits
|
||||||
|
|
||||||
await depositGauge(depositor, GAUGE_EURS, aEURS.address, parseEther('100000'));
|
await depositPoolToken(depositor, GAUGE_EURS, aEURS.address, parseEther('100000'));
|
||||||
const curveATokenBalance = await crvToken.balanceOf(aEURS.address);
|
const curveATokenBalance = await crvToken.balanceOf(aEURS.address);
|
||||||
expect(curveATokenBalance).to.be.eq('0', 'CRV should be zero');
|
expect(curveATokenBalance).to.be.eq('0', 'CRV should be zero');
|
||||||
});
|
});
|
||||||
|
@ -370,7 +458,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
await increaseTime(ONE_DAY);
|
await increaseTime(ONE_DAY);
|
||||||
|
|
||||||
// Withdraw
|
// Withdraw
|
||||||
await withdrawGauge(depositor, GAUGE_EURS, aEURS.address);
|
await withdrawPoolToken(depositor, GAUGE_EURS, aEURS.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Claim the remaining CRV and SNX', async () => {
|
it('Claim the remaining CRV and SNX', async () => {
|
||||||
|
@ -390,7 +478,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
|
|
||||||
it('Deposit and generate user reward checkpoints', async () => {
|
it('Deposit and generate user reward checkpoints', async () => {
|
||||||
// Deposits
|
// Deposits
|
||||||
await depositGauge(
|
await depositPoolToken(
|
||||||
depositor,
|
depositor,
|
||||||
GAUGE_ANKR,
|
GAUGE_ANKR,
|
||||||
aANKR.address,
|
aANKR.address,
|
||||||
|
@ -411,7 +499,7 @@ makeSuite('Curve Rewards Aware aToken', (testEnv: TestEnv) => {
|
||||||
await increaseTime(ONE_DAY * 30);
|
await increaseTime(ONE_DAY * 30);
|
||||||
|
|
||||||
// Withdraw
|
// Withdraw
|
||||||
await withdrawGauge(depositor, GAUGE_ANKR, aANKR.address);
|
await withdrawPoolToken(depositor, GAUGE_ANKR, aANKR.address);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Claim the CRV with extra rewards', async () => {
|
it('Claim the CRV with extra rewards', async () => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user