[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

Casting Spells

Spells denotes a sequence of connector functions that will achieve a given use case. Spells can comprise of any number of functions across any number of connectors.

With this SDK, performing DeFi operations on your dapp consists of creating a spells instance to add transactions. Here is where you can initiate complex transactions amongst different protocols.

Create an instance.

let spells = dsa.Spell();

Add spells that you want to execute. Think of any actions, and by just adding new SPELLS, you can wonderfully CAST transactions across protocols. Let's try to execute the following actions:

  1. Lend 1 ETH on Compound

  2. Borrow 50 DAI on Compound

spells.add({
  connector: "compound",
  method: "deposit",
  args: [dsa.tokens.info.eth.address, dsa.tokens.fromDecimal(1, "eth"), 0, 0]
});

spells.add({
  connector: "compound",
  method: "borrow",
  args: [dsa.tokens.info.dai.address, dsa.tokens.fromDecimal(50, "dai"), 0, 0]
});

Note: Make sure, your smart account have the equivalent ETH balance before executing the above actions. Check this section for more details.

At last, cast your spell using cast() method.

dsa.cast(spells).then(console.log) // returns transaction hash

You can also pass an object to send optional parameters like sending ETH along with the transaction.

dsa.cast({
  spells: spells,
  gasPrice: web3.utils.toWei(gasPrice, 'gwei'), // in gwei, used in node implementation.
  value: dsa.tokens.fromDecimal(1,"eth"), // sending 1 Eth along the transaction.
  nonce: nonce
})
PreviousDebt Collateral RatioNextBuild a Connector

Last updated 4 years ago