Skip to content

Commit

Permalink
fix: convex fixes for Aura support
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Oct 10, 2023
1 parent 254a4b0 commit bc816c7
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 11 deletions.
44 changes: 42 additions & 2 deletions config/usdcLevconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export const config: PoolV3DeployConfig = {
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
rETH: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
WBTC: {
minRate: 1,
maxRate: 3000,
Expand Down Expand Up @@ -119,7 +125,12 @@ export const config: PoolV3DeployConfig = {
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},

rETH_f: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
steCRV: {
minRate: 1,
maxRate: 3000,
Expand Down Expand Up @@ -252,7 +263,24 @@ export const config: PoolV3DeployConfig = {
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},

B_rETH_STABLE: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
auraB_rETH_STABLE: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
auraB_rETH_STABLE_vault: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
yvDAI: {
minRate: 1,
maxRate: 3000,
Expand Down Expand Up @@ -326,6 +354,18 @@ export const config: PoolV3DeployConfig = {
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
BAL: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
AURA: {
minRate: 1,
maxRate: 3000,
quotaIncreaseFee: 0,
limit: (BigInt(1e7) * POOL_DECIMALS) / POOL_DIVIDER,
},
},
creditManagers: [
{
Expand Down
12 changes: 10 additions & 2 deletions contracts/adapters/convex/ConvexV1_BaseRewardPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,23 @@ contract ConvexV1BaseRewardPoolAdapter is AbstractAdapter, IConvexV1BaseRewardPo

try ICreditManagerV3(creditManager).getTokenMaskOrRevert(_extraReward1) returns (uint256) {}
catch {
_extraReward1 = IExtraRewardWrapper(_extraReward1).token();
try IExtraRewardWrapper(_extraReward1).token() returns (address baseToken) {
_extraReward1 = baseToken;
} catch {
_extraReward1 = IExtraRewardWrapper(_extraReward1).baseToken();
}
}

if (extraRewardLength >= 2) {
_extraReward2 = IRewards(IBaseRewardPool(_baseRewardPool).extraRewards(1)).rewardToken();

try ICreditManagerV3(creditManager).getTokenMaskOrRevert(_extraReward2) returns (uint256) {}
catch {
_extraReward2 = IExtraRewardWrapper(_extraReward2).token();
try IExtraRewardWrapper(_extraReward2).token() returns (address baseToken) {
_extraReward2 = baseToken;
} catch {
_extraReward2 = IExtraRewardWrapper(_extraReward2).baseToken();
}
}
}
}
Expand Down
9 changes: 6 additions & 3 deletions contracts/adapters/convex/ConvexV1_Booster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,14 @@ contract ConvexV1BoosterAdapter is AbstractAdapter, IConvexV1BoosterAdapter {
unchecked {
for (uint256 i = 0; i < len; ++i) {
address adapter = allowedAdapters[i];
address targetContract = IAdapter(adapter).targetContract();
address poolTargetContract = IAdapter(adapter).targetContract();
AdapterType aType = IAdapter(adapter)._gearboxAdapterType();

if (aType == AdapterType.CONVEX_V1_BASE_REWARD_POOL) {
uint256 pid = IBaseRewardPool(targetContract).pid();
if (
aType == AdapterType.CONVEX_V1_BASE_REWARD_POOL
&& IBaseRewardPool(poolTargetContract).operator() == targetContract
) {
uint256 pid = IBaseRewardPool(poolTargetContract).pid();
address phantomToken = IConvexV1BaseRewardPoolAdapter(adapter).stakedPhantomToken();
pidToPhantomToken[pid] = phantomToken;
emit SetPidToPhantomToken(pid, phantomToken);
Expand Down
2 changes: 2 additions & 0 deletions contracts/integrations/convex/Interfaces.sol
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,6 @@ interface IExtraRewardWrapper {
function booster() external view returns (address);

function token() external view returns (address);

function baseToken() external view returns (address);
}
20 changes: 19 additions & 1 deletion contracts/test/config/USDC_Lev_config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
// POOL

string public constant symbol = "dUSDC-lev-V3";
string public constant name = "Diesel USDC V3 leverage pool";
string public constant name = "USDC v3 farm";

PoolV3DeployParams _poolParams = PoolV3DeployParams({withdrawalFee: 0, expectedLiquidityLimit: 10_000_000_000_000});

Expand All @@ -52,6 +52,7 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_gaugeRates.push(GaugeRate({token: Tokens.WETH, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.STETH, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.wstETH, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.rETH, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.WBTC, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.LINK, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.aDAI, minRate: 1, maxRate: 30_00}));
Expand All @@ -64,6 +65,7 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_gaugeRates.push(GaugeRate({token: Tokens.FRAX, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.GUSD, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.LUSD, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.rETH_f, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.steCRV, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.cvxsteCRV, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.stkcvxsteCRV, minRate: 1, maxRate: 30_00}));
Expand All @@ -85,6 +87,9 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_gaugeRates.push(GaugeRate({token: Tokens.crvFRAX, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.cvxcrvFRAX, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.stkcvxcrvFRAX, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.B_rETH_STABLE, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.auraB_rETH_STABLE, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.auraB_rETH_STABLE_vault, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.yvDAI, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.yvUSDC, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.yvWETH, minRate: 1, maxRate: 30_00}));
Expand All @@ -97,9 +102,12 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_gaugeRates.push(GaugeRate({token: Tokens.CRV, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.LDO, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.SNX, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.BAL, minRate: 1, maxRate: 30_00}));
_gaugeRates.push(GaugeRate({token: Tokens.AURA, minRate: 1, maxRate: 30_00}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.WETH, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.STETH, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.wstETH, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.rETH, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.WBTC, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.LINK, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.aDAI, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
Expand All @@ -112,6 +120,7 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_quotaLimits.push(PoolQuotaLimit({token: Tokens.FRAX, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.GUSD, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.LUSD, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.rETH_f, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.steCRV, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.cvxsteCRV, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.stkcvxsteCRV, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
Expand Down Expand Up @@ -145,6 +154,13 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_quotaLimits.push(PoolQuotaLimit({token: Tokens.crvFRAX, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.cvxcrvFRAX, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.stkcvxcrvFRAX, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.B_rETH_STABLE, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(
PoolQuotaLimit({token: Tokens.auraB_rETH_STABLE, quotaIncreaseFee: 0, limit: 10_000_000_000_000})
);
_quotaLimits.push(
PoolQuotaLimit({token: Tokens.auraB_rETH_STABLE_vault, quotaIncreaseFee: 0, limit: 10_000_000_000_000})
);
_quotaLimits.push(PoolQuotaLimit({token: Tokens.yvDAI, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.yvUSDC, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.yvWETH, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
Expand All @@ -157,6 +173,8 @@ contract CONFIG_MAINNET_USDC_LEV_V3 is IPoolV3DeployConfig {
_quotaLimits.push(PoolQuotaLimit({token: Tokens.CRV, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.LDO, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.SNX, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.BAL, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));
_quotaLimits.push(PoolQuotaLimit({token: Tokens.AURA, quotaIncreaseFee: 0, limit: 10_000_000_000_000}));

/// CREDIT_MANAGER_0
CreditManagerV3DeployParams storage cp = _creditManagers.push();
Expand Down
15 changes: 12 additions & 3 deletions contracts/test/suites/LiveTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,20 @@ contract LiveTestHelper is IntegrationTestHelper {
function _configureAdapters(address creditManager, CreditManagerV3DeployParams memory creditManagerParams)
internal
{
// CONVEX BOOSTER
// CONVEX AND AURA BOOSTER
address boosterAdapter = getAdapter(creditManager, Contracts.CONVEX_BOOSTER);

vm.prank(CONFIGURATOR);
IConvexV1BoosterAdapter(boosterAdapter).updateStakedPhantomTokensMap();
if (boosterAdapter != address(0)) {
vm.prank(CONFIGURATOR);
IConvexV1BoosterAdapter(boosterAdapter).updateStakedPhantomTokensMap();
}

boosterAdapter = getAdapter(creditManager, Contracts.AURA_BOOSTER);

if (boosterAdapter != address(0)) {
vm.prank(CONFIGURATOR);
IConvexV1BoosterAdapter(boosterAdapter).updateStakedPhantomTokensMap();
}

// BALANCER VAULT
BalancerPool[] memory bPools = creditManagerParams.balancerPools;
Expand Down

0 comments on commit bc816c7

Please sign in to comment.