[OLD] Instadapp Docs
  • Introduction
  • DeFi Smart Account (DSA)
  • DSA SDK
    • Running Instadapp SDK
  • πŸ’»Instadapp GUI
    • Integrated Protocols
      • Aave
      • Compound Finance
      • MakerDAO
    • Strategies
    • Multi-Protocol Refinancing
    • Authorities
    • Debt Collateral Ratio
  • πŸ‘©β€πŸ’» DSA SDK
    • Casting Spells
    • Build a Connector
    • Connectors
      • Basic
      • Authority
      • Instapool
      • MakerDAO
      • Compound
      • Comp
      • Aave
      • dYdX
      • 1Inch
      • Uniswap
      • OasisDEX
      • Kyber
      • Curve sBTC
      • Curve sUSD
      • Curve yUSD
    • Resolvers
      • Accounts
      • Balances
      • Instapool
      • MakerDAO
      • Compound
      • Aave
      • dYdX
      • 1inch
      • Uniswap
      • OasisDex
      • Kyber
      • Curve sBTC
      • Curve sUSD
      • Curve yUSD
    • getId/setId
    • Example Use Cases
      • Long ETH
      • Short DAI
      • Debt Swap
      • Lending Bridge
      • Lending Swap
      • Debt Bridge
  • πŸ‘©β€πŸ« Tutorials
    • Getting Started
    • Moving Assets into DSA
    • In-App Swaps
  • Additional Info
    • Contract Infomation
    • FAQs
    • Security Audits
    • Release History
  • 🌏Links
    • Homepage
    • DApp
    • Discord
    • Contact Us
Powered by GitBook
On this page
  1. πŸ‘©β€πŸ’» DSA SDK
  2. Example Use Cases

Long ETH

Sample code for longing Ethereum

Step 1

Installation or just use your browser console.

Step 2

Setup Account

Step 3

Trigger the following uniquely designed spells to fulfill this use case. Check this section for generic details around casting spells.

The DSA will cast the spells across the Compound, OasisDEX and Instapool connectors in the following sequence.

Benefits

  • Bullish on ETH? Get benefit whenever ETH goes up.

Recipe

  1. Instapool: borrow DAI

  2. OasisDEX: swap DAI with ETH

  3. Compound: deposit ETH

  4. Compound: borrow DAI

  5. Instapool: return DAI

Requirements

  • User should have base amount of ETH to perform the leverage. Liquidation on Compound is 75% which means for $1 borrowed amount, user needs to have the balance of $0.33 worth ETH for collateral to perform this spell.

let borrowAmount = 20; // 20 DAI
let borrowAmtInWei = dsa.tokens.fromDecimal(borrowAmount, "dai"); // borrow flash loan and swap via OasisDEX

let slippage = 2; // 2% slippage.
let dai_address = dsa.tokens.info.dai.address;
let eth_address = dsa.tokens.info.eth.address;

let buyDetail = await dsa.oasis.getBuyAmount("ETH", "DAI", borrowAmount, slippage);

let spells = dsa.Spell();

spells.add({
  connector: "instapool",
  method: "flashBorrow",
  args: [dai_address, borrowAmtInWei, 0, 0]
});

spells.add({
  connector: "oasis",
  method: "sell",
  args: [eth_address, dai_address, borrowAmtInWei, buyDetail.unitAmt, 0, 0]
});

spells.add({
  connector: "compound",
  method: "deposit",
  args: [eth_address, "-1", 0, 0]
});

spells.add({
  connector: "compound",
  method: "borrow",
  args: [dai_address, borrowAmtInWei, 0, 0]
});

spells.add({
  connector: "instapool",
  method: "flashPayback",
  args: [dai_address, 0, 0]
});

dsa.cast(spells).then(console.log)
PreviousExample Use CasesNextShort DAI

Last updated 4 years ago