Asset Managers
Overview
Arcadia Accounts offer users the flexibility to delegate control of their assets to third-party Asset Managers. Asset Managers are smart contracts that execute specific strategies on behalf of an account owner, such as rebalancing or compounding liquidity positions. By leveraging Asset Managers, users can optimize the performance of their accounts while maintaining control over the delegation process.
Key Features
Delegation: Users can authorize an Asset Manager to perform actions on their behalf.
Full Access: The Asset Manager has access to all assets within the assigned Arcadia Account.
Flexible Strategies: Asset Managers can perform complex operations, such as rebalancing or interacting with DeFi protocols.
Health Check for Margin Accounts: Asset Managers must ensure that a margin account remains in a healthy state after executing actions.
Spot Accounts: No health check is required for operations on spot accounts.
Workflow
1. Setting an Asset Manager
The account owner assigns an Asset Manager to their account by calling the setAssetManager()
function:
Parameters:
assetManager
: Address of the Asset Manager contract.true
: Enables the Asset Manager.
Once set, the Asset Manager can perform actions using the flashAction()
function.
2. Performing a Flash Action
The flashAction()
function enables Asset Managers to execute complex operations. It allows the chaining of multiple actions in a single transaction, with the following capabilities:
Withdraw Assets: Transfer assets from the Arcadia Account to the
actionTarget
.Direct Transfers: Transfer assets directly from the account owner to the
actionTarget
.Execute External Logic: Interact with DeFi protocols via the
actionTarget
(e.g., staking, swapping, or claiming rewards).Deposit Back: Deposit the resultant tokens back into the Arcadia Account.
At the end of the flash action, a health check ensures the margin account remains solvent (collateral value > liabilities). If the check fails, the transaction reverts.
Flash Action Parameters
actionTarget
: The contract address where external logic is executed.actionData
: Encoded data containing:withdrawData
: Asset withdrawal details from the Arcadia Account to the actionTarget.transferFromOwnerData
: Asset transfer details from the owner to the actionTarget.permit
: Permit for the Permit2 transfer.signature
: Signature for the Permit2 transfer.actionTargetData
: The encoded calldata required to perform the series of contract calls needed to execute a specific action or operation with the assets.
How Chaining of Calls Works
The flashAction()
function enables chaining by executing a series of tightly coupled operations in a single transaction. Here’s a step-by-step breakdown:
Decoding Input Data: The function decodes the
actionData
input into its respective components:Withdrawal details (
withdrawData
)Transfer details (
transferFromOwnerData
)Permit details for
Permit2
Action target logic (
actionTargetData
)
Asset Withdrawal: Using
_withdraw()
, assets are transferred from the Arcadia Account to theactionTarget
based on thewithdrawData
.Direct Transfers: If
transferFromOwnerData
specifies additional assets,_transferFromOwner()
transfers them from the owner’s wallet to theactionTarget
.Permit-Based Transfers: If a
signature
andpermit
are provided,_transferFromOwnerWithPermit()
is called to initiate aPermit2
-based asset transfer.External Logic Execution: The Asset Manager calls
executeAction()
on theactionTarget
, passing theactionTargetData
to interact with external protocols (e.g., swapping tokens, staking).Deposit Back to Account: After executing external logic,
_deposit()
transfers the resulting assets back into the Arcadia Account. The_deposit()
function usesdepositData
, which is returned from theexecuteAction()
call on theactionTarget
, to determine the assets and amounts to deposit.Health Check (Margin Accounts Only): The
isAccountUnhealthy()
function ensures the margin account remains solvent. If not, the transaction reverts.
Interfaces for Asset Managers
To interact with the flashAction()
function, developers must implement the following interfaces:
Requirements for Asset Managers
An Asset Manager should implement the following steps to function correctly:
Call
flashAction()
on the Account:The Asset Manager must call the
flashAction()
function on the Arcadia Account.The input to
flashAction()
includes:The address of the
actionTarget
contract.Encoded
actionData
, which must be formatted as follows:
Implement
executeAction()
in the ActionTarget Contract:The
actionTarget
contract must include anexecuteAction()
function that:Accepts
actionTargetData
as input.Executes all the required logic to perform the desired operation or strategy.
Returns an
ActionData
struct that contains the addresses and amounts of assets to be deposited back into the Arcadia Account.
Handle the Returned Data:
The
ActionData
struct returned byexecuteAction()
is used to call_deposit()
and finalize the process by returning the assets to the Arcadia Account.
Last updated