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._
automationRegistry
address automationRegistry
Chainlink Automation Registry address
config
contract IOrionConfig config
Orion Config contract address
internalStatesOrchestrator
contract IInternalStateOrchestrator internalStatesOrchestrator
Internal States Orchestrator contract address
underlyingAsset
address underlyingAsset
Underlying asset address
executionAdapterOf
mapping(address => contract IExecutionAdapter) executionAdapterOf
Execution adapters mapping for assets
lastProcessedEpoch
uint16 lastProcessedEpoch
Last processed epoch counter from Internal States Orchestrator
executionMinibatchSize
uint8 executionMinibatchSize
Execution minibatch size
currentPhase
enum ILiquidityOrchestrator.LiquidityUpkeepPhase currentPhase
Upkeep phase
currentMinibatchIndex
uint8 currentMinibatchIndex
Current minibatch index
targetBufferRatio
uint256 targetBufferRatio
Target buffer ratio
sellingTokens
address[] sellingTokens
Selling tokens for current epoch
sellingAmounts
uint256[] sellingAmounts
Selling amounts for current epoch
sellingEstimatedUnderlyingAmounts
uint256[] sellingEstimatedUnderlyingAmounts
Selling underlying amounts for current epoch
buyingTokens
address[] buyingTokens
Buying tokens for current epoch
buyingAmounts
uint256[] buyingAmounts
Buying amounts for current epoch
buyingEstimatedUnderlyingAmounts
uint256[] buyingEstimatedUnderlyingAmounts
Buying underlying amounts for current epoch
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
constructor
constructor(address initialOwner, address config_, address automationRegistry_) public
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
| initialOwner | address | The address of the initial owner |
| config_ | address | The address of the OrionConfig contract |
| automationRegistry_ | address | The address of the Chainlink Automation Registry |
updateExecutionMinibatchSize
function updateExecutionMinibatchSize(uint8 _executionMinibatchSize) external
Updates the execution minibatch size
Parameters
| Name | Type | Description |
|---|---|---|
| _executionMinibatchSize | uint8 | The new execution minibatch size |
updateAutomationRegistry
function updateAutomationRegistry(address newAutomationRegistry) external
Updates the Chainlink Automation Registry address
Parameters
| Name | Type | Description |
|---|---|---|
| newAutomationRegistry | address | The new automation registry address |
setInternalStatesOrchestrator
function setInternalStatesOrchestrator(address _internalStatesOrchestrator) external
Sets the internal states orchestrator address
Can only be called by the contract owner
Parameters
| Name | Type | Description |
|---|---|---|
| _internalStatesOrchestrator | address | The address of the internal states orchestrator |
setTargetBufferRatio
function setTargetBufferRatio(uint256 _targetBufferRatio) external
Sets the target buffer ratio
Parameters
| Name | Type | Description |
|---|---|---|
| _targetBufferRatio | uint256 | The new target buffer ratio |
depositLiquidity
function depositLiquidity(uint256 amount) external
Deposits underlying assets to the liquidity orchestrator buffer
Can only be called by the owner. Increases the buffer amount by the deposited amount.
Parameters
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| asset | address | The address of the asset. |
| adapter | contract IExecutionAdapter | The execution adapter for the asset. |
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
| Name | Type | Description |
|---|---|---|
| user | address | The user to return funds to |
| amount | uint256 | The amount to return |
transferCuratorFees
function transferCuratorFees(uint256 amount) external
Transfer pending curator fees to a vault owner
Called by vault contracts when vault owners claim their fees
Parameters
| Name | Type | Description |
|---|---|---|
| amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| user | address | The user to transfer funds to |
| amount | uint256 | The 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
| Name | Type | Description |
|---|---|---|
| assets | uint256 | The amount of underlying assets to withdraw |
| receiver | address | The 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
| Name | Type | Description |
|---|---|---|
| upkeepNeeded | bool | Whether the upkeep is needed |
| performData | bytes | The data to perform the upkeep |
performUpkeep
function performUpkeep(bytes performData) external
Performs the upkeep
Parameters
| Name | Type | Description |
|---|---|---|
| performData | bytes | The encoded data containing the action and minibatch index |
_handleStart
function _handleStart() internal
Handles the start action
_processMinibatchSell
function _processMinibatchSell(uint8 minibatchIndex) internal
Handles the sell action
Parameters
| Name | Type | Description |
|---|---|---|
| minibatchIndex | uint8 | The index of the minibatch to process |
_processMinibatchBuy
function _processMinibatchBuy(uint8 minibatchIndex) internal
Handles the buy action
Parameters
| Name | Type | Description |
|---|---|---|
| minibatchIndex | uint8 | The index of the minibatch to process |
_executeSell
function _executeSell(address asset, uint256 sharesAmount, uint256 estimatedUnderlyingAmount) internal
Executes a sell order
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The asset to sell |
| sharesAmount | uint256 | The amount of shares to sell |
| estimatedUnderlyingAmount | uint256 | The estimated underlying amount to receive |
_executeBuy
function _executeBuy(address asset, uint256 sharesAmount, uint256 estimatedUnderlyingAmount) internal
Executes a buy order
Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The asset to buy |
| sharesAmount | uint256 | The amount of shares to buy |
| estimatedUnderlyingAmount | uint256 | The estimated underlying amount to spend |
_processFulfillDepositAndRedeem
function _processFulfillDepositAndRedeem() internal
Handles the fulfill deposit and redeem actions
_processVaultDepositAndRedeem
function _processVaultDepositAndRedeem(address vault, uint256 totalAssetsForDeposit, uint256 totalAssetsForRedeem) internal
Processes deposit and redeem operations for a single vault
Parameters
| Name | Type | Description |
|---|---|---|
| vault | address | The vault address |
| totalAssetsForDeposit | uint256 | The total assets for deposit operations |
| totalAssetsForRedeem | uint256 | The total assets for redeem operations |