Documentation
    Preparing search index...

    MarginTPSLContract class for managing Take Profit / Stop Loss operations.

    Index

    Constructors

    Methods

    • Parameters

      Returns (tx: Transaction) => void

      A function that takes a Transaction object

      Add a conditional order (take profit or stop loss)

    • Parameters

      • marginManagerKey: string

        The key to identify the margin manager

      Returns (tx: Transaction) => void

      A function that takes a Transaction object

      Cancel all conditional orders for a margin manager

    • Parameters

      • marginManagerKey: string

        The key to identify the margin manager

      • conditionalOrderId: string

        The ID of the conditional order to cancel

      Returns (tx: Transaction) => void

      A function that takes a Transaction object

      Cancel a specific conditional order

    • Parameters

      • poolKey: string

        The key to identify the pool

      • marginManagerId: string

        The ID of the margin manager

      • conditionalOrderId: string

        The ID of the conditional order

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Get a specific conditional order by ID

    • Parameters

      • poolKey: string

        The key to identify the pool

      • marginManagerId: string

        The ID of the margin manager

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Get all conditional order IDs for a margin manager

    • Parameters

      • managerAddress: string

        The address of the margin manager

      • poolKey: string

        The key to identify the pool (e.g., 'SUI_USDC')

      • maxOrdersToExecute: number

        Maximum number of orders to execute in this call

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Execute conditional orders that have been triggered. Permissionless — anyone can call this. After the inner fill loop, the manager's post-trade risk_ratio is checked against min_borrow_risk_ratio; if any triggered fill breaches that floor, the whole txn aborts (no partial-state landing).

    • Parameters

      • managerAddress: string

        The address of the margin manager

      • poolKey: string

        The key to identify the pool (e.g., 'SUI_USDC')

      • maxOrdersToExecute: number

        Maximum number of orders to execute in this call

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Execute conditional orders, deleveraging on each market-type fill. Permissionless, with the same trigger and cancellation handling as executeConditionalOrders, but the market proceeds are repaid into the loan before the risk check, and the gate is the net post-repay risk_ratio being at least the pre-fill ratio.

      This is what lets a stop-loss fire in the liquidation..min_borrow danger band: a swap alone only lowers the oracle-valued ratio (so the v2 borrow-floor gate rejects it), while repaying actually improves it. If a single triggered fill would worsen net solvency the whole txn aborts — no partial-state landing.

    • Parameters

      • poolKey: string

        The key to identify the pool

      • marginManagerId: string

        The ID of the margin manager

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Get the highest trigger price for trigger_below orders Returns 0 if there are no trigger_below orders

    • Parameters

      • poolKey: string

        The key to identify the pool

      • marginManagerId: string

        The ID of the margin manager

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Get the lowest trigger price for trigger_above orders Returns constants::max_u64() if there are no trigger_above orders

    • Parameters

      • poolKey: string

        The key to identify the pool

      • triggerBelowPrice: boolean

        Whether to trigger when price is below trigger price

      • triggerPrice: number | bigint

        The price at which to trigger the order

      Returns (tx: Transaction) => TransactionResult

      A function that takes a Transaction object

      Create a new condition for a conditional order