Executing Actions via Microservices
executeInMicroservice
Function
The executeInMicroservice
function facilitates the execution of a set of actions through an Orchestrator instance in a single on-chain transaction,
with transaction delegation to an external microservice.
Internally, the function prepares the appropriate transaction request object based on the input parameters (orchestratorAddress, actions, and gasLimit) and then dispatches it to the specified external microservice via a POST request. The microservice, acting as a transaction relayer, manages a designated wallet which sends the transaction object on the blockchain to be resolved.
Parameters
Name | Type | Description |
---|---|---|
orchestratorAddress | string | The address of the Orchestrator instance |
actions | Action[] | An array of actions to be executed by the Orchestrator. Each action specifies the Adapter, operation, token compositions, and any additional data required by the respective Adapter |
failedCaseTx | number | Number of attempts if the transaction fails |
microserviceUrl | string | The URL of the external microservice |
gasLimit | number | The gas limit for the transaction |
network | ChainId | The chain ID of the target blockchain network |
Action
Type
The Action type encapsulates the information required for executing a specific action. It includes the following:
- The address of the Adapter to be employed
- The operation code
- The token compositions to be sent to the Adapter
- The minimum expected token compositions to be received
- Any additional ABI encoded data specific to the Adapter's operation
TokenAmount
Type
This type represents a combination of a token address and a corresponding amount. It is used to define the token compositions involved in each action.
Example
The following example demonstrates how to use the executeInMicroservice
function to efficiently execute a set of actions on an Orchestrator
through an external microservice.
Specifically, the set of actions in this example is the following:
- Depositing DAI and WETH in Uniswap V3 (first action)
- Depositing WETH for aWETH shares in Aave V2 (second action)
Notes:
- Make sure you've appropriately initialized the NexeraFiSDK, covering configurations essential for further interactions.
- Ensure that the wallet managed by the microservice is configured as the designated executor for the target Orchestrator instance (see example).
- Ensure your
.env
file includes theMICROSERVICE_AUTH_KEY
, which should be set to the key provided by the microservice provider, for proper authorization.