Skip to main content

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

GET 

/v1/actions/loop/refinance

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

Serves two lenders, each with its own mechanism (the response shape is the same: a transaction plus its permissions):

  • Lista DAO brokered markets — a flash-loan-backed 1delta composer bundle (repay the source loan, open the new fixed loan).

  • Exactly — the protocol's OWN periphery (DebtManager on Optimism, DebtRoller on Base): ONE direct transaction that flash-loans from Balancer, repays the source position and re-borrows into the target. Because it acts on msg.sender's own position it must be sent by the borrower, and it needs a Market borrow allowance (returned as a permission). Maps fromLoanId → source maturity and termId → target maturity, with termId=0 meaning "roll into the variable/floating position" and an absent fromLoanId meaning "roll FROM the floating position". Base ships only the fixed→fixed direction. The response adds an exactly block (direction, percentage, rolledAssets, projectedFaceValue).

  • 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.
Plain-text reference — GET /v1/actions/loop/refinance

Parameters

ParameterInTypeRequiredDescription
marketUidquerystringyesLoan-token market identifier of a Lista brokered market (lender:chainId:address).
amountquerystringnoFlash / repay / new-fixed amount (loan-token wei). Required only for a partial re-fix (provide amount, leave isAll unset). For a full close, omit it — the server sizes the flash itself; if present alongside a full close it is used only as a floor hint.
isAllquerybooleannoForce a full close even when amount is present. A full close is also the DEFAULT whenever amount is omitted. The server sizes the flash to the source loan's borrow balance — the max of the POST-body borrowBalance (+ earlyRepayPenalty) and a fresh on-chain read (dynamic = getUserTotalDebt minus each fixed position's current debt; fixed = that position's current debt + early-repay penalty) — plus a small (0.05%) margin. The repay clears the source to zero and the broker refunds the margin (swept back), so there is no sub-minLoan dust and no REMAIN_BORROW_TOO_LOW. Set amount (and leave this unset) only for a deliberate partial re-fix.
termIdqueryintegeryesFixed term to move the debt into, from the market's terms[] rate card (MarketTerm.termId).
fromLoanIdquerystringnoSource loan to roll FROM: a fixed loan's loanId (posId) to roll one fixed loan into another term, or omit (defaults to type(uint128).max) to refinance the dynamic/float position.
operatorquerystringyesThe borrower (and tx sender). Both the repaid source loan and the new fixed loan are this account.

Request body

FieldTypeRequiredDescription
borrowBalancestringnoSource loan's current borrow balance (loan-token wei).
earlyRepayPenaltystringnoSource loan's early-repay penalty (loan-token wei) — fixed, not-yet-matured source only.

Response 200

FieldTypeDescription
successTrue
dataobjectResponse from proxy-mode lending operations (via 1delta composer).
data.transactionobjectAn EVM transaction ready to sign and broadcast. Send to, data and value as-is; do not re-encode them.
data.transaction.tostringTarget contract address
data.transaction.datastringEncoded calldata
data.transaction.valuestringETH value to send with the transaction
data.transaction.descriptionstringHuman-readable label. For alternatives, this is the aggregator name (e.g. "Paraswap"). For transactions, describes the setup action (e.g. "Switch e-mode to 1").
data.permissionTxnsobject[]Approval transactions that must be executed before the main transaction. Empty when the user already has sufficient allowances.
data.permissionTxns[].tostringTarget contract address
data.permissionTxns[].datastringEncoded calldata
data.permissionTxns[].valuestringETH value
data.permissionTxns[].descriptionstringHuman-readable description of the approval (e.g. "Approve borrow for AAVE_V3", "Approve ERC20")
data.permissionTxns[].spenderstringERC-20 approve spender (x-chain permissions). Match it against the selected quote's approvalTarget — several bridges can share one spender, so do not match by description.
data.rateImpactobject[]Projected interest-rate impact per market. Single-market actions produce 1 entry; loop actions produce 2. Null if IRM data is unavailable.
data.rateImpact[].marketUidstringMarket identifier (format: lender:chainId:address)
data.rateImpact[].utilizationobjectA current/projected pair for a single rate metric.
data.rateImpact[].utilization.currentnumberCurrent value
data.rateImpact[].utilization.projectednumberProjected value after the action
data.rateImpact[].borrowRateobjectA current/projected pair for a single rate metric.
data.rateImpact[].borrowRate.currentnumberCurrent value
data.rateImpact[].borrowRate.projectednumberProjected value after the action
data.rateImpact[].depositRateobjectA current/projected pair for a single rate metric.
data.rateImpact[].depositRate.currentnumberCurrent value
data.rateImpact[].depositRate.projectednumberProjected value after the action
actionsobjectTransaction calldata and approvals. Null for quote-only responses (no account provided).
actions.transactionsobject[]Pre-trade setup transactions (e.g. e-mode switch, collateral enable). Execute these before the main swap. Empty when no setup is needed.
actions.transactions[].tostringTarget contract address
actions.transactions[].datastringEncoded calldata
actions.transactions[].valuestringETH value to send with the transaction
actions.transactions[].descriptionstringHuman-readable label. For alternatives, this is the aggregator name (e.g. "Paraswap"). For transactions, describes the setup action (e.g. "Switch e-mode to 1").
actions.alternativesobject[]DEX aggregator swap transactions sorted by best output (descending). Each entry's description is the aggregator name. The client should pick one to execute. Present on loop action endpoints.
actions.alternatives[].tostringTarget contract address
actions.alternatives[].datastringEncoded calldata
actions.alternatives[].valuestringETH value to send with the transaction
actions.alternatives[].descriptionstringHuman-readable label. For alternatives, this is the aggregator name (e.g. "Paraswap"). For transactions, describes the setup action (e.g. "Switch e-mode to 1").
actions.permissionsobject[]Approval/delegation transactions that must execute before both transactions and alternatives. Includes ERC20 allowances (targeting the composer contract) and lender borrow/withdrawal delegations (targeting the lending protocol contract directly). Filtered against on-chain state so only missing approvals are returned. Null when no approvals are needed.
actions.permissions[].tostringTarget contract address
actions.permissions[].datastringEncoded calldata
actions.permissions[].valuestringETH value
actions.permissions[].descriptionstringHuman-readable description of the approval (e.g. "Approve borrow for AAVE_V3", "Approve ERC20")

Example response

{
"success": true,
"data": {
"transaction": {
"to": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
"data": "0x617ba037000000000000000000000000c02aaa39b2",
"value": "0",
"description": "string"
},
"permissionTxns": [
{
"to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"data": "0x617ba037000000000000000000000000c02aaa39b2",
"value": "0",
"description": "string",
"spender": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
],
"rateImpact": [
{
"marketUid": "AAVE_V3:8453:0x4200000000000000000000000000000000000006",
"utilization": {
"current": 1.0,
"projected": 1.0
},
"borrowRate": {
"current": 1.0,
"projected": 1.0
},
"depositRate": {
"current": 1.0,
"projected": 1.0
}
}
]
},
"actions": {
"transactions": [
{
"to": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
"data": "0x617ba037000000000000000000000000c02aaa39b2",
"value": "0",
"description": "string"
}
],
"alternatives": [
{
"to": "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2",
"data": "0x617ba037000000000000000000000000c02aaa39b2",
"value": "0",
"description": "string"
}
],
"permissions": [
{
"to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"data": "0x617ba037000000000000000000000000c02aaa39b2",
"value": "0",
"description": "string",
"spender": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
]
}
}

Request

Responses

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