Last active
September 6, 2020 05:56
-
-
Save leckylao/0859bef048ac366f8a3b7c7382f0db1a to your computer and use it in GitHub Desktop.
instadapp save
This file contains hidden or 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
let borrowAmount = 3880; | |
let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "usdc"); // borrow flash loan and swap via OasisDEX | |
console.log("borrowAmtInWei: ", borrowAmtInWei) | |
let position = await dsa.compound.getPosition(); | |
let wbtcDebtAmount = position.wbtc.borrow; | |
let wbtcDebtAmtInWei = dsa.tokens.fromDecimal(wbtcDebtAmount, "wbtc"); | |
console.log("wbtcDebtAmount: ", wbtcDebtAmount) | |
let daiDebtAmount = position.dai.borrow; | |
let daiDebtAmtInWei = dsa.tokens.fromDecimal(daiDebtAmount, "dai"); | |
console.log("daiDebtAmount: ", daiDebtAmount) | |
let slippage = 1; | |
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 wbtcBuyAmount = await dsa.kyber.getBuyAmount("WBTC", "USDC", 5, slippage); | |
// let wbtcSellAmount = await dsa.oasis.getSellAmount("WBTC", "USDC", wbtcDebtAmount, slippage); | |
let daiSellAmount = await dsa.oasis.getSellAmount("DAI", "USDC", daiDebtAmount, slippage); | |
console.log("wbtcBuyAmount: ", wbtcBuyAmount) | |
console.log("daiSellAmount: ", daiSellAmount) | |
let spells = dsa.Spell(); | |
spells.add({ | |
connector: "instapool", | |
method: "flashBorrow", | |
args: [usdc_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: [dai_address, usdc_address, daiDebtAmtInWei, daiSellAmount.unitAmt, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "payback", | |
args: [dai_address, dsa.maxValue, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "withdraw", | |
args: [usdc_address, dsa.maxValue, 0, 0] | |
}); | |
spells.add({ | |
connector: "instapool", | |
method: "flashPayback", | |
args: [usdc_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