Alluo Explained
Search
⌃K
Comment on page
📈

Frax Convex Finance

Frax Convex pools: https://frax.convexfinance.com/

How to invest into a pool on FraxConvex Finance?

To enter most pools in Frax Convex Finance, one should first get LP tokens from a corresponding Curve Pool. The address of the underlying Curve Pool for each Frax Pool is shown under ‘Info’. Once tokens are staked in the Curve Pool, one gets LP tokens, and usually the address of that LP token is shown as Curve LP token address.
Next, those Curve LP tokens should be deposited in LP token address, which gives wrapped LP tokens in return in 1:1 ratio. Finally, wrapped LP tokens can be locked in the staking contract of the pool, shown as Staking address.
The funds are locked in Frax Pool for at least 7 days. For locking one gets rewards, and all the reward tokens can be seen if you click “?” as shown on Image 1. Usually, there are 3 reward tokens: FXS (Frax shares), CRV (Curve token) and CVX (Convex token).
One can also check the rewards in the Staking contract by calling getAllRewardsTokens(), which usually returns only FXS. CRV and CVX come from Curve pool.
​
​
Example of investing into FRAX/USDC pool:
​​1) Deposit poolToken (e.g. USDC) into Curve FRAX/USDC pool, get Curve LP tokens​
2) Stake Curve LP tokens to LP token address, get LP Tokens (same address)
3) Stake LP tokens to Staking address​
How do funds get allocated into a particular strategy?
We call VoteExecutor.sol contract which orchestrates the investment process. First, it fetches all the data needed to enter the pool from the StrategyHandler.sol and then calls invest() of CurveFraxConvexStrategy.sol.
The logic behind the execution of investment strategy.
When we call invest(), CurveFraxConvexStrategy.sol. first stakes pool token into Curve pool and receives crvLptokens. Next, crvLptokens are wrapped through the LP wrapper (the contract referred to as LP token address on Convex Frax), which is finally locked in the staking contract for at least 7 days.
Each lock is associated with a kek_id, so to avoid opening multiple positions, we first check if we already have a position in the pool. If yes, we call lockAdditional(), otherwise stakeLocked().
```solidity
// Deposit these crvLptokens into the convex wrapper to get staked fraxLP tokens
IConvexWrapper(address(stakeToken)).deposit(crvLpAmount, address(this));
uint256 fraxLpAmount = IERC20(stakeToken).balanceOf(address(this));
IERC20(stakeToken).safeIncreaseAllowance(fraxPool, fraxLpAmount);
​
// Now stake and lock these LP tokens into the frax farm.
//check if we have a position there already
IFraxFarmERC20.LockedStake[] memory lockedstakes = IFraxFarmERC20(
fraxPool
).lockedStakesOf(address(this));
​
if (lockedstakes.length == 1) {
bytes32 kek_id = lockedstakes[0].kek_id;
IFraxFarmERC20(fraxPool).lockAdditional(kek_id, fraxLpAmount);
} else {
bytes32 kek_id;
kek_id = IFraxFarmERC20(fraxPool).stakeLocked(
fraxLpAmount,
duration
);
kek_ids[fraxPool] = kek_id;
}
```
​