short dai
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
await dsa.setInstance(dsa.instance.id); | |
let borrowAmount = 10000; // 10000 DAI | |
let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "dai"); // borrow flash loan and swap via OasisDEX | |
let position = await dsa.compound.getPosition(); | |
let debtAmount = position.wbtc.borrow; | |
let debtAmtInWei = dsa.tokens.fromDecimal(debtAmount, "wbtc"); // borrow flash loan and swap via OasisDEX | |
let slippage = 0.5; // 0.5% slippage. | |
let dai_address = dsa.tokens.info.dai.address | |
let usdc_address = dsa.tokens.info.usdc.address | |
let wbtc_address = dsa.tokens.info.wbtc.address | |
let buyAmount = await dsa.curve.getBuyAmount("USDC", "DAI", borrowAmount, slippage); | |
let sellAmount = await dsa.oasis.getSellAmount("WBTC", "DAI", debtAmount, slippage); | |
let spells = dsa.Spell(); | |
spells.add({ | |
connector: "instapool", | |
method: "flashBorrow", | |
args: [dai_address, borrowAmtInWei, 0, 0] | |
}); | |
spells.add({ | |
connector: "curve", | |
method: "sell", | |
args: [usdc_address, dai_address, borrowAmtInWei, buyAmount.unitAmt, 0, 0] | |
}); | |
spells.add({ | |
connector: "oasis", | |
method: "buy", | |
args: [wbtc_address, dai_address, debtAmtInWei, sellAmount.unitAmt, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "payback", | |
args: [usdc_address, dsa.maxValue, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "payback", | |
args: [wbtc_address, dsa.maxValue, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "withdraw", | |
args: [usdc_address, dsa.maxValue, 0, 0] | |
}); | |
spells.add({ | |
connector: "maker", | |
method: "open", | |
args: ["USDC-A"] | |
}); | |
spells.add({ | |
connector: "maker", | |
method: "deposit", | |
args: [0, dsa.maxValue, 0, 0] // deposit all USDC | |
}); | |
spells.add({ | |
connector: "maker", | |
method: "borrow", | |
args: [0, borrowAmtInWei, 0, 0] | |
}); | |
spells.add({ | |
connector: "instapool", | |
method: "flashPayback", | |
args: [dai_address, 0, 0] | |
}); | |
dsa.cast(spells).then(console.log) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment