How to take and payback flashloan on polygon chain?

const token = "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270" // wmatic token address on polygon 
const amount = web3.utils.toWei('100', 'ether') 
const amountWithFee = web3.utils.toWei('100.09', 'ether') 

let spells = new dsa.Spell()

      connector: 'INSTAPOOL-C',
      method: 'flashPayback',
      args: [token, amountWithFee, 0, 0],

const cd = dsa.instapool_v2.encodeFlashCastData(spells);
let flashloanWrappedSpells = new dsa.Spell();

      connector: 'INSTAPOOL-C',
      method: 'flashBorrowAndCast',
      args: [ token , amount, 1, cd, "0x"],


// keep adding spells across DeFi protocols to execute.

console.log("Transaction hash:",
            await dsa.cast({spells:flashloanWrappedSpells})
            .catch(err => {console.log(err)})

If you still can't find something you're looking for or have any questions, ask them at our developers community on Discord or simply send an Email.

Our team is excited about assisting you to build an application using Instadapp Developer Platform. Your questions and feedback help us make a better development environment for future developers.