Skip to main content

TenorRouterAdapterBase

Git Source - Generated with forge doc

Inherits: TenorRouter, CoreAdapter, ITenorRouterAdapter

Title: TenorRouterAdapterBase

Bundler3 adapter for TenorRouter batch execution.

_initiator returns Bundler3.initiator(): the bundle initiator is the Midnight taker.

Functions​

_initiator​

function _initiator() internal view override returns (address);

Returns

NameTypeDescription
<none>address

execute​

Executes a batch of direct midnight.take actions, accumulating buyer/seller/units totals and enforcing per-batch fill bounds and price slippage. The initiator is the Midnight taker for every action.

Adapter override: callable only by Bundler3, and resolves type(uint256).max maxFill/minFill sentinels against onchain state before executing.

function execute(ExecuteParams calldata params, Action[] calldata actions)
external
override(TenorRouter, ITenorRouter)
onlyBundler3
returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
paramsExecuteParams
actionsAction[]

Returns

NameTypeDescription
<none>uint256The total buyer-side asset flow (post-fee).
<none>uint256The total seller-side asset flow (post-fee).
<none>uint256The total market units filled.

executeAndConsume​

Executes a batch then increments the caller's consumed counter for consumeGroup by the filled amount in the params.fillAxis dimension; enables mixed-execution limit orders in one tx.

consumeGroup is the caller's self-limit group, independent of each offer's own group. Midnight's auth on setConsumed enforces that the caller has authorized this adapter to write into their namespace.

consumeGroup and params.fillAxis must match the group and dimension (units vs assets) the caller's resting offers consume against, or the shared counter is corrupted.

Only taker-side fills advance the counter; maker-side fills are already tracked by Midnight under the offer's own group.

Only top-level taker fills are counted; taker fills settled inside a callback are excluded, so the self-limit is not atomic against nested fills.

function executeAndConsume(
ExecuteParams calldata params,
Action[] calldata actions,
bytes32 consumeGroup,
uint128 maxConsumed
) external override onlyBundler3 returns (uint256, uint256, uint256);

Parameters

NameTypeDescription
paramsExecuteParamsBatch execution parameters (fill index, max/min fill, deadline, slippage).
actionsAction[]Per-action payloads (MidnightTakeData).
consumeGroupbytes32Caller's self-limit group to increment.
maxConsumeduint128Final cap on consumed[initiator][consumeGroup] after the write;
type(uint128).max disables.

Returns

NameTypeDescription
<none>uint256Total buyer-side asset flow across the batch (post-fee).
<none>uint256Total seller-side asset flow across the batch (post-fee).
<none>uint256Total market units filled across the batch.

_executeResolvingSentinels​

function _executeResolvingSentinels(ExecuteParams calldata params, Action[] calldata actions)
internal
returns (uint256[3] memory totals, uint256[3] memory rawTotals);

Parameters

NameTypeDescription
paramsExecuteParams
actionsAction[]

Returns

NameTypeDescription
totalsuint256[3]
rawTotalsuint256[3]

_resolveSentinel​

FILL_UNITS resolves to the initiator's debt (buyer-side) or credit (seller-side); side-aware so the resolved cap matches the position the batch would close. Sentinels are resolved once at batch start; state changes occurring mid-execution are not accounted for. FILL_BUYER_ASSETS resolves to loanToken.balanceOf(adapter). FILL_SELLER_ASSETS is unsupported; it would cap borrower output by the adapter loan balance.

function _resolveSentinel(uint8 fillIndex, address initiator, Action[] calldata actions)
internal
view
returns (uint256);

Parameters

NameTypeDescription
fillIndexuint8
initiatoraddress
actionsAction[]

Returns

NameTypeDescription
<none>uint256