Skip to main content

Refinance / roll-over (move debt to a fixed term)

GET 

/v1/actions/loop/refinance

Move a Lista DAO broker user's debt into a fresh fixed term — "refinance" / "roll-over".

  • Refinance (default, omit fromLoanId): roll the dynamic/float position into a fixed term — e.g. an expired fixed loan the keeper rolled into the dynamic bracket. Lista's own refinanceMaturedFixedPositions (matured fixed → dynamic) is keeper-only; this is the user-driven inverse.
  • Roll-over (fromLoanId = a fixed loan's posId): roll one fixed loan into a different term (rate/duration). Rolling a not-yet-matured fixed loan repays it early, so amount must also cover its accrued interest + early-repayment penalty.

Same collateral, same principal, different rate bracket.

Flash-loan backed (robust at any LTV). The flash comes free from the market's own Moolah singleton, and the new fixed loan repays it. The returned transaction is a single composer bundle:

flashLoan(loanToken, amount) from Moolah:
approve loanToken → Moolah # so Moolah can pull the flash repayment
broker.repay(amount, DYNAMIC, user) # repay the float position with the flashed funds
broker.borrow(amount, termId, user, receiver=composer) # open the new fixed loan; repays the flash
→ sweep residual loanToken back to user

Because the dynamic is repaid before the fixed borrow, the borrow's health check sees the original (net) debt — no 2× peak — so it works regardless of LTV.

Net debt is unchanged. A setAuthorization(composer) permission (on Moolah) is returned only when the composer isn't already authorized — the broker's on-behalf borrow requires it, but setAuthorization reverts AlreadySet() if re-applied, so the server reads isAuthorized(user, composer) on-chain and omits the permission when it's already set. actions.permissions is empty in that case.

Notes:

  • Single-market, debt-side only — pass the loan-token marketUid of a brokered market.
  • Full close (default — omit amount): the server sizes the flash to the source loan's borrow balance + a small (0.05%) margin, clearing it to zero (the broker refunds the margin, swept back). The balance is the max of (a) the borrowBalance you POST in the body and (b) a fresh on-chain read — robust whether or not the worker's live RPC is current. Avoids the REMAIN_BORROW_TOO_LOW revert from a stale client snapshot amount. Prefer POST with borrowBalance (+ earlyRepayPenalty for a not-yet-matured fixed source) from /v1/data/lending/user-positions; a plain GET also works (on-chain read only). Never make the user hand-pick an over-funded amount.
  • Partial re-fix: pass an explicit amount (leave isAll unset) < the source outstanding. Both the new fixed (amount) and the remaining source must clear minLoan.

Request

Responses

Flash-loan composer transaction (repay source loan + borrow new fixed term) and the borrow-authorization permission