-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from studydefi/master
Updating master branch
- Loading branch information
Showing
16 changed files
with
1,739 additions
and
33 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,9 @@ | |
- DappSys | ||
- DyDx | ||
- ERC20 | ||
- Idle V3 | ||
- Kyber.Network | ||
- MakerDAO | ||
- OneSplit | ||
- UMA | ||
- Uniswap v1 | ||
- Kyber.Network |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Idle (V3) | ||
|
||
[Official Idle documentation](https://developers.idle.finance/) | ||
|
||
## Examples | ||
|
||
Import `@studydefi/money-legos/idle` package | ||
|
||
```js | ||
const idle = require("@studydefi/money-legos/idle"); | ||
``` | ||
|
||
List of all available contracts | ||
|
||
```js | ||
idle.maxYield.dai.address; | ||
idle.maxYield.usdc.address; | ||
idle.maxYield.usdt.address; | ||
|
||
idle.riskAdjusted.dai.address; | ||
idle.riskAdjusted.usdc.address; | ||
idle.riskAdjusted.usdt.address; | ||
|
||
idle.abi; // the same abi for each idle v3 contract | ||
|
||
idle.decimals; // idle mints ERC-20 tokens | ||
``` | ||
|
||
### JavaScript | ||
|
||
#### `mintIdleToken` | ||
|
||
```js | ||
const { ethers } = require("ethers"); | ||
const erc20 = require("@studydefi/money-legos/erc20"); | ||
const idle = require("@studydefi/money-legos/idle"); | ||
|
||
const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545"); | ||
const wallet = new ethers.Wallet(process.env.GANACHE_PRIV_KEY, provider); | ||
|
||
// init contracts | ||
const daiContract = new ethers.Contract(erc20.dai.address, erc20.abi, wallet); | ||
const idleContract = new ethers.Contract( | ||
idle.maxYield.dai.address, | ||
idle.abi, | ||
wallet, | ||
); | ||
|
||
// approve Idle to spend your DAI | ||
const daiBalanceWei = await daiContract.balanceOf(wallet.address); | ||
await daiContract.approve(idle.maxYield.dai.address, daiBalanceWei); | ||
|
||
// mint idleDAIYield | ||
await idleContract.mintIdleToken(daiBalanceWei, true, { | ||
gasLimit: 4000000, | ||
}); | ||
|
||
// check idleDAI balance | ||
const idleDaiBalance = await idleContract.balanceOf(wallet.address); | ||
console.log( | ||
`idleDAI: ${ethers.utils.formatUnits(idleDaiBalance, idle.decimals)}`, | ||
); | ||
``` |
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
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
Oops, something went wrong.