Borrow Fixed Rate

Supply collateral and borrow at a fixed rate in a single transaction, receiving USDC via the BT→FW→token path.

Also available: borrowSingleToken — same flow but skips the collateral supply step (assumes collateral already supplied).

Key references: src/fira_bonding/router/ActionBorrow.sol::supplyAndBorrowSingleToken, borrowSingleToken.

Details

  • Goal: Supply collateral and receive a target token in one transaction (via BT→FW→token path).

  • Preconditions:

    • User approved collateralToken to the router.

    • tokensToBorrow > 0, collateralAmount > 0, receiver != 0x0.

    • Market is initialized; firaMarket and lendingMarket set.

    • User must have authorized the router on the LendingMarket (setAuthorization(router, true)).

  • Parameters (high level):

    • marketParams (Fira Lending), collateralAmount, tokensToBorrow (BT),

    • output (TokenOutput: tokenOut, tokenRedeemFw, minTokenOut, firaSwap, swapData),

    • limitOrderData (kept for interface compatibility, orderbook not used in current version).

Views and events

Views

  • Lending: getUserPosition(marketParams, user)supplyAssets, supplyShares, borrowAssets, borrowShares, collateralAssets.

  • Lending: position(id, user), market(id).

  • Market (fixed-rate): readTokens(), isExpired().

Events

  • Lending: EventsLib.SupplyCollateral, EventsLib.Borrow.

  • Market: Swap (BT→FW), UpdateImpliedRate.

  • FW: Deposit (tokenIn→FW), Redeem (FW→tokenOut).

Reward share (fixed-rate borrow)

  • Suggested formula: userBorrowBT / totalBorrowBT over the epoch (TWAP).

  • Functions to call:

    • LendingMarket.getUserPosition(marketParamsBT, user)borrowAssets (userBorrowBT)

    • LendingMarket.market(idBT).totalBorrowAssetstotalBorrowBT (consider accrueInterest(marketParamsBT) before reading)

    • FiraMarket.readTokens() → BT address; FiraMarket.isExpired()

  • Events to index: EventsLib.Borrow, FiraMarket.Swap (BT→FW), IFiraWrappedStandardized.Redeem

Last updated