DeFi strategy to invest USDC in Venus in a loop in order to earn XVS rewards for approx x7 of the initial investment.
Run on a mainnet fork with Hardhat:
npm install
npm run build
npm run test
To see all event logs pass --logs
to the test command.
- Clone and initialize the repo:
git clone
npm install
npm run build
- Enter your infura/alchemy endpoint in
hardhat.config.ts
undernetworks.eth.url
- Create a new temporary address with a mnemonic generator and import the private key to metamask.
- Send 0.3ETH (enough for deployment) to the temp address (preferably from a cefi origin like Binance, so that it will be a "clean" account with no history)
npm run deploy eth
and follow the prompts.- The deploy script will take care of everything, after deployment send any leftover funds back and BURN THE MNEMONIC!
- A backup is created under
./deployments
just in case. - The contract is ready to be used by the owner.
- To add custom abi to etherscan, use the ABI in
deployments/*/artifacts/contracts/VenusLoop.sol/VenusLoop.json
- Owner owns the contract and the funds inside. Can enter, exit and withdraw.
It's recommended to take the ABI created during deployment and upload it as private custom ABI to Etherscan and this way we can easily use Etherscan's read/write interface (with Trezor) without publishing the contract source. (pass false at contract deployment to skip source upload).
- Call
getPositionData
to see that the liquidity is not dropping to1
(approaching liquidation).
If exitPosition
fails, exit can be done manually:
- Using a lower number in maxIterations. Partial exits are supported, will deleverage but stay in position.
- Using multiple manual rollback transactions
- The owner of the contract can also execute an arbitrary transaction using
emergencyFunctionCall
oremergencyFunctionDelegateCall
. Check the tests. - By sending more USDC to the contract before running
exitPosition
again, this will reduce the numebr of exit iterations