General Margin Operations

We provide a sketch to execute general margin operations here.

The Flow

In general, assuming the caller has existing balances with the lender, there aer two major steps, the flash loan itself and the inner call

  1. We execute the flashLoan call with currency X and amount x

    • Execute the Inner Calls
    • swap x to currency Y and amount y
    • put y into a lender to increase the credit line (e.g. deposit or repay)
    • pull x from the lender (e.g. withdraw or borrow)
  1. Repay the flash loan with funds x

Considerations

Lending operations that take funds need approvals (see Transfers section for that) and sometimes need to unwrap the flash loaned amount to native.

Lending operations that pull funds on the user's behalf need to be permissioned by the user.

© 1delta https://1delta.io/

Found an error in the docs? The source code can be found here. Please feel free to edit and contribute a merge request
Modified at: 2025-08-10 20:39:21

results matching ""

    No results matching ""