Skip to main content

LiquidityOrchestrator

LiquidityOrchestrator

Contract that orchestrates liquidity operations

_This contract is responsible for:

  • Executing actual buy and sell orders on investment universe;
  • Processing withdrawal requests from LPs;
  • Handling slippage and market execution differences from adapter price estimates via liquidity buffer._

BASIS_POINTS_FACTOR

uint16 BASIS_POINTS_FACTOR

Basis points factor

automationRegistry

address automationRegistry

Chainlink Automation Registry address

config

contract IOrionConfig config

Orion Config contract address

internalStateOrchestrator

contract IInternalStateOrchestrator internalStateOrchestrator

Internal State Orchestrator contract address

underlyingAsset

address underlyingAsset

Underlying asset address

executionAdapterOf

mapping(address => contract IExecutionAdapter) executionAdapterOf

Execution adapters mapping for assets

minibatchSize

uint8 minibatchSize

Minibatch size for fulfill deposit and redeem processing

currentPhase

enum ILiquidityOrchestrator.LiquidityUpkeepPhase currentPhase

Upkeep phase

currentMinibatchIndex

uint8 currentMinibatchIndex

Current minibatch index

targetBufferRatio

uint256 targetBufferRatio

Target buffer ratio

slippageTolerance

uint256 slippageTolerance

Slippage tolerance

MAX_MINIBATCH_SIZE

uint8 MAX_MINIBATCH_SIZE

Maximum minibatch size

epochCounter

uint256 epochCounter

Epoch counter

deltaBufferAmount

int256 deltaBufferAmount

Delta buffer amount for current epoch

onlyAuthorizedTrigger

modifier onlyAuthorizedTrigger()

Restricts function to only owner or Chainlink Automation Registry

onlyConfig

modifier onlyConfig()

Restricts function to only Orion Config contract

onlyInternalStateOrchestrator

modifier onlyInternalStateOrchestrator()

Restricts function to only Internal State Orchestrator contract

onlyOwnerOrGuardian

modifier onlyOwnerOrGuardian()

Restricts function to only owner or guardian

constructor

constructor() public

Constructor that disables initializers for the implementation contract

initialize

function initialize(address initialOwner, address config_, address automationRegistry_) public

Initializes the contract

Parameters

NameTypeDescription
initialOwneraddressThe address of the initial owner
config_addressThe address of the OrionConfig contract
automationRegistry_addressThe address of the Chainlink Automation Registry

updateMinibatchSize

function updateMinibatchSize(uint8 _minibatchSize) external

Updates the minibatch size for fulfill deposit and redeem processing

Parameters

NameTypeDescription
_minibatchSizeuint8The new minibatch size

updateAutomationRegistry

function updateAutomationRegistry(address newAutomationRegistry) external

Updates the Chainlink Automation Registry address

Parameters

NameTypeDescription
newAutomationRegistryaddressThe new automation registry address

setInternalStateOrchestrator

function setInternalStateOrchestrator(address _internalStateOrchestrator) external

Sets the internal state orchestrator address

Can only be called by the contract owner

Parameters

NameTypeDescription
_internalStateOrchestratoraddress

setTargetBufferRatio

function setTargetBufferRatio(uint256 _targetBufferRatio) external

Sets the target buffer ratio

Slippage tolerance is set to 50% of targetBufferRatio to support worst-case scenario prices and full NAV rebalancing. This ensures ALL trades pass even with maximum price impact.

Parameters

NameTypeDescription
_targetBufferRatiouint256The new target buffer ratio

depositLiquidity

function depositLiquidity(uint256 amount) external

Deposits underlying assets to the liquidity orchestrator buffer

Increases the buffer amount by the deposited amount.

Parameters

NameTypeDescription
amountuint256The amount of underlying assets to deposit

withdrawLiquidity

function withdrawLiquidity(uint256 amount) external

Withdraws underlying assets from the liquidity orchestrator buffer

Can only be called by the owner. Decreases the buffer amount by the withdrawn amount. Includes safety checks to prevent predatory withdrawals that could break protocol operations.

Parameters

NameTypeDescription
amountuint256The amount of underlying assets to withdraw

claimProtocolFees

function claimProtocolFees(uint256 amount) external

Claim protocol fees with specified amount

Called by the Owner to claim a specific amount of protocol fees

Parameters

NameTypeDescription
amountuint256The amount of protocol fees to claim

setExecutionAdapter

function setExecutionAdapter(address asset, contract IExecutionAdapter adapter) external

Register or replace the execution adapter for an asset.

Can only be called by the Orion Config contract.

Parameters

NameTypeDescription
assetaddressThe address of the asset.
adaptercontract IExecutionAdapterThe execution adapter for the asset.

advanceIdlePhase

function advanceIdlePhase() external

Advances the idle phase

Called by the internal state orchestrator to advance the idle phase

returnDepositFunds

function returnDepositFunds(address user, uint256 amount) external

Return deposit funds to a user who cancelled their deposit request

Called by vault contracts when users cancel deposit requests

Parameters

NameTypeDescription
useraddressThe user to return funds to
amountuint256The amount to return

transferVaultFees

function transferVaultFees(uint256 amount) external

Transfer pending fees to manager

Called by vault contracts when managers claim their fees

Parameters

NameTypeDescription
amountuint256The amount of fees to transfer

transferRedemptionFunds

function transferRedemptionFunds(address user, uint256 amount) external

Transfer redemption funds to a user after shares are burned

Called by vault contracts when processing redemption requests

Parameters

NameTypeDescription
useraddressThe user to transfer funds to
amountuint256The amount of underlying assets to transfer

withdraw

function withdraw(uint256 assets, address receiver) external

Synchronous redemption for decommissioned vaults

Called by vault contracts to process synchronous redemptions for LPs with share tokens

Parameters

NameTypeDescription
assetsuint256The amount of underlying assets to withdraw
receiveraddressThe address to receive the underlying assets

checkUpkeep

function checkUpkeep(bytes) external view returns (bool upkeepNeeded, bytes performData)

Checks if the upkeep is needed

Return Values

NameTypeDescription
upkeepNeededboolWhether the upkeep is needed
performDatabytesEmpty bytes

performUpkeep

function performUpkeep(bytes) external

Performs the upkeep

_processSellLeg

function _processSellLeg() internal

Handles the sell action

_processBuyLeg

function _processBuyLeg() internal

Handles the buy action

_executeSell

function _executeSell(address asset, uint256 sharesAmount, uint256 estimatedUnderlyingAmount) internal

Executes a sell order

Parameters

NameTypeDescription
assetaddressThe asset to sell
sharesAmountuint256The amount of shares to sell
estimatedUnderlyingAmountuint256The estimated underlying amount to receive

_executeBuy

function _executeBuy(address asset, uint256 sharesAmount, uint256 estimatedUnderlyingAmount) internal

Executes a buy order

The adapter handles slippage tolerance internally.

Parameters

NameTypeDescription
assetaddressThe asset to buy
sharesAmountuint256The amount of shares to buy
estimatedUnderlyingAmountuint256The estimated underlying amount to spend

_processVaultOperations

function _processVaultOperations() internal

Handles the vault operations

_processSingleVaultOperations

function _processSingleVaultOperations(address vault, uint256 totalAssetsForDeposit, uint256 totalAssetsForRedeem, uint256 finalTotalAssets) internal

Processes deposit and redeem operations for a single vault

Parameters

NameTypeDescription
vaultaddressThe vault address
totalAssetsForDeposituint256The total assets for deposit operations
totalAssetsForRedeemuint256The total assets for redeem operations
finalTotalAssetsuint256The final total assets for the vault

pause

function pause() external

Pauses the contract

Can only be called by OrionConfig for emergency situations

unpause

function unpause() external

Unpauses the contract

Can only be called by OrionConfig after resolving emergency

_authorizeUpgrade

function _authorizeUpgrade(address newImplementation) internal

Authorizes an upgrade to a new implementation

This function is required by UUPS and can only be called by the owner

Parameters

NameTypeDescription
newImplementationaddressThe address of the new implementation contract