🇺🇲
Protocolink
  • 🔮Overview
  • 🌟Why Protocolink?
  • 💡Use Cases
    • Flash Loans
    • Permit2 Amplifier
    • Zap-in & Zap-out
    • Position Management
    • Multi-Action Bundling
  • 📋Networks & Protocols
  • 🛡️Security & Audits
  • 💎Fees
  • ❓FAQ
  • Protocolink API
    • 🔮Overview
      • Swap & Supply (Example)
    • 📗Swagger
      • Request Protocols
      • Request Tokens
      • Request Quote
      • Estimate Logics Result
      • Request Transaction Data
  • Protocolink SDK
    • 🔮Overview
    • 1️⃣Install SDK
    • 2️⃣Build Logics
    • 3️⃣Estimate Router Data
    • 4️⃣Send Router Transaction
    • ⚒️API SDK Interfaces
      • Global Types
      • FlashLoan Logic
      • Aave V2
      • Aave V3
      • Balancer V2
      • Compound V3
      • Iolend
      • Magicsea
      • Morphoblue
      • OpenOcean V2
      • ParaSwap V5
      • Permit2
      • Spark
      • Stargate
      • Stargate V2
      • SyncSwap
      • Uniswap V3
      • Utility
      • Wagmi
      • ZeroEx V4
    • ⚒️Common SDK Interfaces
      • Constants
      • Network
      • Token
      • Web3Toolkit
      • Utility Functions
  • Lending SDK
    • 🔮Overview
    • ✳️SDK
      • Open By Collateral
      • Open By Debt
      • Close
      • Leverage By Collateral
      • Leverage By Debt
      • Deleverage
      • Collateral swap
      • Debt swap
      • Zap supply
      • Zap withdraw
      • Zap repay
      • Zap borrow
  • Smart Contract
    • 🔮Overview
      • Router
      • Agent
      • Callback
      • Fees
      • Utility
      • Data Type
      • ERC721/ERC1155 Support
    • 📑Deployment Addresses
    • 🧑‍💻Security Review Details
  • COMPOUND KIT
    • 🔮Overview
    • ✳️SDK
      • Leverage
      • Deleverage
      • Collateral Swap
      • Zap Supply
      • Zap Withdraw
      • Zap Repay
      • Zap Borrow
    • 📗API
  • Video Tutorials
    • 1. Introducing Protocolink
    • 2. Lending SDK
    • 3. Protocolink Q&A
  • Social medias
    • Twitter
  • Support
Powered by GitBook
On this page
  1. Protocolink SDK
  2. API SDK Interfaces

FlashLoan Logic

In this section, we will introduce four main types that are essential for implementing Flash Loan via our SDK, which can be accessed using the api. prefix:

  • FlashLoanLogicParams: This type represents the params used to configure the parameters required for making Flash Loan quote requests. By using the loans or repays parameter, you can specify the desired loan or repayment amounts.

import * as common from '@protocolink/common';

type FlashLoanLoanParams<T = object> = {
  loans: common.TokenAmounts;
};

type FlashLoanRepayParams<T = object> = {
  repays: common.TokenAmounts;
};

type FlashLoanLogicParams = FlashLoanLoanParams | FlashLoanRepayParams;
  • FlashLoanLogicFields: This type represents the fields required for FlashLoanLogic, including the unique id, loans and a boolean isLoan field.

import * as common from '@protocolink/common';

interface FlashLoanLogicFields {
  id: string;
  loans: common.TokenAmounts;
  isLoan: boolean;
}
  • FlashLoanFields: A type that represents the fields required for the flash loan logic.

interface FlashLoanFields {
  id: string;
  loans: {
    token: {
      chainId: number;
      address: string;
      decimals: number;
      symbol: string;
      name: string;
    };
    amount: string;
  }[];
  isLoan: boolean;
}
  • FlashLoanLogic: An interface that extends the Logic interface and represents the flash loan logic. It includes the rid, and fields properties.

interface FlashLoanLogic {
  rid: string;
  fields: FlashLoanFields;
}

For any FlashLoan-like logic, you will need to create two FlashLoan logics data with a unique ID (such as a UUID):

  • one with isLoan = true, representing the loan taken out from the protocol

  • one with isLoan = false, representing the loan repayment

Any additional logics that need to be executed during the FlashLoan process should be wrapped within these two FlashLoan logics.

Remember, the FlashLoan logic with isLoan = true should be the first one, and the FlashLoan logic with isLoan = false should be the last one.

PreviousGlobal TypesNextAave V2

Last updated 1 year ago

⚒️