Last active
February 21, 2021 09:12
-
-
Save leckylao/261fe6094fb67e426c4113958e06f087 to your computer and use it in GitHub Desktop.
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
await dsa.setInstance(237); | |
let withdrawAmount = 1000; | |
let withdrawAmtInWei = dsa.tokens.fromDecimal(withdrawAmount, "bat"); | |
let slippage = 0.1; // 0.1% slippage. | |
let bat_address = dsa.tokens.info.bat.address | |
let usdc_address = dsa.tokens.info.usdc.address | |
let buyAmount = await dsa.kyber.getBuyAmount("USDC", "BAT", withdrawAmount, slippage); | |
let spells = dsa.Spell(); | |
spells.add({ | |
connector: "instapool", | |
method: "flashBorrow", | |
args: [usdc_address, buyAmount.buyAmtRaw, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "deposit", | |
args: [usdc_address, buyAmount.buyAmtRaw, 0, 0] | |
}); | |
spells.add({ | |
connector: "compound", | |
method: "withdraw", | |
args: [bat_address, withdrawAmtInWei, 0, 0] | |
}); | |
spells.add({ | |
connector: "kyber", | |
method: "sell", | |
args: [usdc_address, bat_address, withdrawAmtInWei, buyAmount.unitAmt, 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