Smart Contract Functions
Understand the contract calls behind SDK preparation, approvals and execution.
The Peach API builds swap calldata; the SDK validates it and submits the prepared transaction. This page explains the contract calls used by that workflow. For deployment addresses, see Contract Address.
Execute a swap
PeachExecutionRouter.executePlan() is the swap entry point for both Direct and Delegated execution. Its ABI is exported as PEACH_EXECUTION_ROUTER_ABI.
plan
Signed roles, tokens, amounts, minimum output, deadline, nonce, fees and hash bindings
params
Underlying swap parameters, route steps and intermediate tokens
logicalPoolIds
Logical pool identifiers bound to the route
amountModes
Amount handling modes for the route steps
payerSignature
Permit2 Witness authorization in Delegated mode; empty in Direct mode
aggregatorSignature
Aggregator signature authorizing the execution plan
Return values
executePlan() returns a receipt tuple containing planHash, payer, executor, recipient, tokenOut, requestedAmountIn, actualAmountIn and userAmountOut.
The SDK decodes this return value during simulateSwap(). It describes execution against the simulated RPC state. A submitted transaction instead returns an ethers transaction response; wait() returns the mined transaction receipt, not this tuple. See Transaction Safety.
Funding flows
The function is payable. For native BNB input, the prepared transaction's value equals the input amount; otherwise it is zero. Keep the service-built to, data and value unchanged.
Direct execution obtains the transaction through swapAllowance(). Delegated execution uses swapPermit2() followed by swapPermit2Build(). swap() selects the mode from whether payer and executor are equal. All three preparation methods accept from, target and the exact-input amount. Submit either ready transaction with executeSwap(). A display quote cannot be used to reconstruct executable calldata.
Supporting functions
Token approvals
ERC20 approvals call approve(address spender, uint256 amount) on the input token contract. allowance(address owner, address spender) reads the existing allowance.
Direct ERC20 input
Prepared Execution Router
buildDirectApprovalRequest() skips sufficient allowance or builds unlimited approval
Delegated ERC20 input
Canonical Permit2
checkPermit2BaseAllowance() checks the base allowance; the tutorial approves the prepared amount
Native BNB input
None
No ERC20 approval
Wait for a successful approval receipt before submitting the swap. The Permit2 Witness message signature is separate from this ERC20 approval and from the executor's transaction signature. See Direct Swaps and Delegated Swaps.
Router configuration
The SDK reads these functions from the underlying PeachRouter, not the Execution Router:
WETH(), owner(), pendingOwner(), paused(), maxCustomFeeBps(), maxProtocolCutBps(), protocolFeeReceiver(), protocolCutBps()
getRouterConfig(routerAddress)
protocolFeeReceiver(), protocolCutBps()
getProtocolFeeConfig(routerAddress)
These are current configuration snapshots and can change. They do not override a signed execution plan. See Fees for fee limits and Slippage for settlement, or SDK Reference for method signatures and return types.
getRouterConfig() performs the reads in parallel; it does not pin them to one block. In SDK 0.5.0, use getProtocolFeeConfig() and ProtocolFeeConfig; the older platform-named method and type have been removed.
Last updated
Was this helpful?