The Cetus CLMM (Concentrated Liquidity Market Maker) provides a flash loan mechanism, allowing users to borrow assets from a liquidity pool without requiring upfront collateral, as long as the borrowed amount is repaid within the same transaction. This feature is particularly useful for arbitrage, liquidations, and high-frequency trading strategies.
The module includes the following functions:
1. Flash loan from pool
/// Flash loan from pool
/// Params
/// - `config` The global config of clmm package.
/// - `pool` The clmm pool object.
/// - `loan_a` A flag indicating whether to loan coin A (true) or coin B (false).
/// - `amount` The amount to loan.
/// Returns
/// - `Balance<CoinTypeA>` The balance of coin A to loan.
/// - `Balance<CoinTypeB>` The balance of coin B to loan.
/// - `FlashLoanReceipt` The receipt for repaying the flash loan.
public fun flash_loan<CoinTypeA, CoinTypeB>(
_config: &GlobalConfig,
_pool: &mut Pool<CoinTypeA, CoinTypeB>,
_loan_a: bool,
_amount: u64
): (Balance<CoinTypeA>, Balance<CoinTypeB>, FlashLoanReceipt) {}
2. Flash loan from pool with partner
/// Flash loan with partner, like flash loan but there has a partner object for receive ref fee.
/// Params
/// - `config` The global config of clmm package.
/// - `pool` The clmm pool object.
/// - `partner` The partner object for receiving ref fee.
/// - `loan_a` A flag indicating whether to loan coin A (true) or coin B (false).
/// - `amount` The amount to loan.
/// - `clock` The CLOCK of sui framework, used to get current timestamp.
/// Returns
/// - `Balance<CoinTypeA>` The balance of coin A to loan.
/// - `Balance<CoinTypeB>` The balance of coin B to loan.
/// - `FlashLoanReceipt` The receipt for repaying the flash loan.
public fun flash_loan_with_partner<CoinTypeA, CoinTypeB>(
_config: &GlobalConfig,
_pool: &mut Pool<CoinTypeA, CoinTypeB>,
_partner: &Partner,
_loan_a: bool,
_amount: u64,
_clock: &Clock
): (Balance<CoinTypeA>, Balance<CoinTypeB>, FlashLoanReceipt) {}
3. Repay flash loan
/// Repay for flash loan
/// Params
/// - `config` The global config of clmm package.
/// - `pool` The clmm pool object.
/// - `balance_a` The balance of `CoinTypeA` will pay for flash loan,
/// if `loan_a` is true the value need equal `amount + fee_amount` else it need with zero value.
/// - `balance_b` The balance of `CoinTypeB` will pay for flash loan,
/// if `loan_a` is false the value need equal `amount + fee_amount` else it need with zero value.
/// - `receipt` The receipt which will be destroyed.
/// Returns
/// Null
public fun repay_flash_loan<CoinTypeA, CoinTypeB>(
_config: &GlobalConfig,
_pool: &mut Pool<CoinTypeA, CoinTypeB>,
_balance_a: Balance<CoinTypeA>,
_balance_b: Balance<CoinTypeB>,
_receipt: FlashLoanReceipt,
) {}
4. Repay flash loan with partner id
/// Repay flash loan with partner id to receive ref fee.
/// Params
/// - `config` The global config of clmm package.
/// - `pool` The clmm pool object.
/// - `partner` The partner object which will receive ref fee.
/// - `balance_a` The balance of `CoinTypeA` will pay for flash loan,
/// if `loan_a` is true the value need equal `amount + fee_amount` else it need with zero value.
/// - `balance_b` The balance of `CoinTypeB` will pay for flash loan,
/// if `loan_a` is false the value need equal `amount + fee_amount` else it need with zero value.
/// - `receipt` The receipt which will be destroyed.
/// Returns
/// Null
public fun repay_flash_loan_with_partner<CoinTypeA, CoinTypeB>(
_config: &GlobalConfig,
_pool: &mut Pool<CoinTypeA, CoinTypeB>,
_partner: &mut Partner,
_balance_a: Balance<CoinTypeA>,
_balance_b: Balance<CoinTypeB>,
_receipt: FlashLoanReceipt,
) {}
In addition to Swap with Partner, the Cetus protocol also enables the sharing of protocol fees with a designated partner. Partner can collect ref fee by partner cap. Details can refer to .