Created
September 22, 2021 15:10
-
-
Save sembrestels/f6181e6d44d0ea05b9f67034704c4104 to your computer and use it in GitHub Desktop.
Deposit on Agave with EVMcrispr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ethers } from 'hardhat'; | |
import { EVMcripsr } from '@commonsswarm/evmcrispr' | |
const DAO_ADDR = '<your-dao>' | |
const agent = 0 // Agent index, 0 for the first Agent | |
const amount = 1.5 // Amount, example "1.50" USDC | |
const asset = 'WXDAI' // Token, example 1.50 "WETH" | |
// Agave addresses | |
const pool = '0x207E9def17B4bd1045F5Af2C651c081F9FDb0842' | |
const assets = { | |
WXDAI: ['0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', 1e18], | |
USDC: ['0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83', 1e6], | |
WBTC: ['0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', 1e8], | |
WETH: ['0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1', 1e18] | |
} | |
async function main() { | |
const signer = (await ethers.getSigners())[0] | |
const evm = await EVMcrispr.create(signer, DAO_ADDR) | |
const [assetAddr, decimals] = assets[asset] as [string, number] | |
const tx = await evm.forward( | |
[ | |
evm.act(`agent:${agent}`, assetAddr, 'approve(address,uint256)', [pool, String(amount * decimals)]), | |
evm.act(`agent:${agent}`, pool, 'deposit(address,uint256,address,uint16)', [assetAddr, String(amount * decimals), evm.app(`agent:${agent}`), 0]) | |
], | |
['voting'] | |
) | |
console.log(`Transaction sent: ${tx.transactionHash}`) | |
console.log(`Go to https://aragon.1hive.org/#/${DAO_ADDR}/${evm.app('voting')()} to find the recently created vote.`) | |
} | |
main() | |
.then(() => process.exit(0)) | |
.catch((error) => { | |
console.error(error); | |
process.exit(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment