For the complete documentation index, see llms.txt. This page is also available as Markdown.

TurbineSettler

Git Source

Inherits: ITurbineSettler, AccessControl, Pausable, IUnlockCallback

State Variables

PERMIT2_CONTRACT

IPermit2 public constant PERMIT2_CONTRACT = IPermit2(PERMIT2)

UNIV4_POOL_MANAGER_CONTRACT

IPoolManager public constant UNIV4_POOL_MANAGER_CONTRACT = IPoolManager(UNIV4_POOL_MANAGER)

PAUSER_ROLE

bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE")

UNPAUSER_ROLE

bytes32 public constant UNPAUSER_ROLE = keccak256("UNPAUSER_ROLE")

CALL_DATA_EXECUTION_GAS_LIMIT

uint256 private constant CALL_DATA_EXECUTION_GAS_LIMIT = 200000

turbineSigner

Address that signs the settlement solutions

feeWithdrawer

Address authorized to withdraw accumulated fees

turbineLiquidityRouter

Contract that handles liquidity provisions and removals

executedSellAmounts

Executed settled sell amounts of orders

Functions

constructor

---------------------------- 🛠️ CONSTRUCTOR ----------------------------- ///

onlyTurbineSigner

Restricts function access to the turbine signer only

_onlyTurbineSigner

onlyFeeWithdrawer

Restricts function access to the fee withdrawer only

_onlyFeeWithdrawer

pause

------------------------ 🌐 EXTERNAL METHODS ------------------------- ///

Pauses the contract

unpause

Unpauses the contract

renounceAdmin

Renounces the caller's admin role

Can only be called by an admin. If multiple admins exist, other admins retain their roles.

updateFeeWithdrawer

Updates the fee withdrawer address

Only callable by the admin

Parameters

Name
Type
Description

newFeeWithdrawer

address

The new fee withdrawer address

sweepFees

Sweeps all available balance of specified tokens to a specified recipient

Only callable by the fee withdrawer

Parameters

Name
Type
Description

tokens

address[]

The addresses of the tokens to sweep

to

address

The address to send the swept fees to

executeLiquidityActionsAndSettlement

Executes liquidity actions and a batch settlement

Parameters

Name
Type
Description

addLiquidityActions

AddLiquidityAppliedAction[]

The liquidity actions to add liquidity

removeLiquidityOffchainActions

RemoveLiquidityAppliedAction[]

The offchain-applied liquidity actions to remove liquidity

removeLiquidityOnchainActions

RemoveLiquidityIntentHash[]

Intent hashes for onchain liquidity removals

settlement

BatchSettlement

The settlement to execute

targetBlockNumber

uint256

The block number at which the settlement is valid

batchId

uint256

The unique identifier for this settlement batch

unlockCallback

Take loans, fill orders, repay the loans

This function is called by the UniV4PoolManager contract.

batchExecutedSellAmounts

Returns the cumulative executed sell amount for a batch of orders over all settlements

Parameters

Name
Type
Description

orderHashes

bytes32[]

The hashes of the orders

Returns

Name
Type
Description

<none>

uint256[]

The executed sell amounts

getTurbineLiquidityRouter

Returns the address of the TurbineLiquidityRouter

Return type is address to avoid unnecessary imports

Returns

Name
Type
Description

<none>

address

The address of the TurbineLiquidityRouter

getTurbineHook

Returns the address of the TurbineHook (via the TurbineLiquidityRouter)

Return type is address to avoid unnecessary imports

Returns

Name
Type
Description

<none>

address

The address of the TurbineHook

_executeBatchSettlement

------------------------- 🛠️ INTERNAL METHODS ------------------------- ///

Execute a settlement, potentially taking flashloans

_executeSmartOrderSwaps

Executes smart orders

_executeDEXSwaps

Executes DEX pool swaps

_executeTurbinePoolExecutions

Execute Turbine pool executions

_receiveSellTokens

_sendBuyTokens

_computeReceivedTokenAmounts

_executeSmartOrderSwap

Execute swaps on external contracts

This is used both to execute smart orders and to execute swaps on liquidity pools. These two cases are almost identical, but they might diverge in the future. We may decide later to merge them.

Parameters

Name
Type
Description

swap

SmartOrderExecution

The swap to execute.

Returns

Name
Type
Description

<none>

uint256

Returns the received sell amount from this smart order execution.

_executeDEXSwap

Execute a swap on a DEX pool

We don't check for amounts transferred because we do these checks at a token level

Parameters

Name
Type
Description

swap

DEXSwap

The swap to execute.

Last updated

Was this helpful?