Skip to main content
POST
/
markets
/
creditbook
/
flash_borrow
Flash borrow
curl --request POST \
  --url https://tars.loopscale.com/v1/markets/creditbook/flash_borrow \
  --header 'Content-Type: application/json' \
  --header 'user-wallet: <user-wallet>' \
  --data '{
  "principalRequested": [],
  "depositCollateral": [],
  "cpiIxs": [
    {
      "programId": "<string>",
      "accounts": [
        {
          "pubkey": "<string>",
          "isSigner": true,
          "isWritable": true
        }
      ],
      "data": "<string>"
    }
  ],
  "cpiLuts": [
    "<string>"
  ],
  "cpiSigners": [
    "<string>"
  ],
  "loanAddress": "<string>",
  "setupIxs": [
    {
      "programId": "<string>",
      "accounts": [
        {
          "pubkey": "<string>",
          "isSigner": true,
          "isWritable": true
        }
      ],
      "data": "<string>"
    }
  ],
  "setupLuts": [
    "<string>"
  ],
  "setupSigners": [
    "<string>"
  ],
  "unifySetup": true
}'
{
  "transactions": [
    {
      "message": "<string>",
      "signatures": [
        {
          "publicKey": "<string>",
          "signature": "<string>"
        }
      ]
    }
  ],
  "loanAddress": "<string>"
}

Headers

user-wallet
string
required

Wallet address of the borrowing user

Body

application/json
principalRequested
object[]
required
depositCollateral
object[]
required
cpiIxs
object[]

Instructions to execute between borrow and deposit steps

cpiLuts
string[]

Optional Address Lookup Tables

cpiSigners
string[]

Optional signer keys, not including the user's own

loanAddress
string

If leveraging an existing loan, provide its address

setupIxs
object[]

Optional instructions to execute first

setupLuts
string[]

Optional Address Lookup Tables

setupSigners
string[]

Optional signer keys, not including the user's own

unifySetup
boolean

If true, this flag will prepend the setupIxs to the flash loan transaction, if false (default), this endpoint will return two transactions (Setup + Flash Loan w/ CPI)

Response

Serialized transaction and resulting loan address

transactions
object[]
loanAddress
string

Loan account address created (or used if pre-specified)