Skip to main content

TenorRouterAdapterBase

Git Source - Generated with forge doc

Inherits: TenorRouter, CoreAdapter, ITenorRouterAdapter

Title: TenorRouterAdapterBase

Bundler3 adapter for TenorRouter batch execution. Overrides _initiator to return Bundler3.initiator() and adds sentinel resolution + executeAndConsume.

Functions

_initiator

function _initiator() internal view override returns (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);

Returns

NameTypeDescription
<none>uint256buyerAssets The total buyer-side asset flow (post-fee).
<none>uint256sellerAssets The total seller-side asset flow (post-fee).
<none>uint256units The 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.

function executeAndConsume(
ExecuteParams calldata params,
Action[] calldata actions,
bytes32 consumeGroup,
uint256 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.
maxConsumeduint256Final cap on consumed[initiator][consumeGroup] after the write; type(uint256).max disables.

Returns

NameTypeDescription
<none>uint256buyerAssets Total buyer-side asset flow across the batch (post-fee).
<none>uint256sellerAssets Total seller-side asset flow across the batch (post-fee).
<none>uint256units Total 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);

_resolveSentinel

FILL_UNITS resolves to the initiator's debt (buyer-side) or credit (seller-side); side-aware so the resolved cap matches the existing position the action would close, preventing overshoot. 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);