Flash Loans SDK
A flash loan is one where the borrowing and returning of loans from pools is performed within a single programmable transaction block. The SDK exposes functions that allow you to implement this functionality. See Flash Loans for more details on the API.
Flash loan functions
The DeepBookV3 SDK provides the following flash loan related functions.
borrowBaseAsset
Use borrowBaseAsset to borrow a base asset from the pool identified by the poolKey value you provide. The call returns a function that takes a Transaction object
Parameters
poolKey: String that identifies the pool from which to borrow.borrowAmount: Number that represents the amount to borrow from the pool.
borrowBaseAsset(poolKey: string, borrowAmount: number);
returnBaseAsset
Use returnBaseAsset to return the base asset to the pool identified by the poolKey value you provide. The call returns a function that takes a Transaction object.
Parameters
poolKey: String that identifies the pool from which to borrow.borrowAmount: Number that represents the amount to borrow from the pool.baseCoinInput: Coin object representing the base asset to be returned.flashLoan: Flash loan object representing the loan to be settled.
returnBaseAsset(
{
poolKey: string,
borrowAmount: number,
baseCoinInput: TransactionObjectArgument,
flashLoan: TransactionObjectArgument,
}
)
borrowQuoteAsset
Use borrowQuoteAsset to borrow a quote asset from the pool identified by the poolKey value you provide. The call returns a function that takes a Transaction object.
Parameters
poolKey: String that identifies the pool from which to borrow.borrowAmount: Number that represents the amount to borrow from the pool.
borrowQuoteAsset(poolKey: string, borrowAmount: number);
returnQuoteAsset
Use returnQuoteAsset to return a quote asset to the pool identified by the poolKey you provide. The call returns a function that takes a Transaction object.
Parameters
poolKey: String that identifies the pool from which to borrow.borrowAmount: Number that represents the amount to borrow from the pool.baseCoinInput: Coin object representing the quote asset to be returned.flashLoan: Flash loan object representing the loan to be settled.
returnQuoteAsset(
poolKey: string,
borrowAmount: number,
quoteCoinInput: TransactionObjectArgument,
flashLoan: TransactionObjectArgument,
);