About Off-chain vs On-chain
The Nexera-FI Development Kit is structured around a combination of off-chain and on-chain components. This architecture ensures that off-chain and on-chain components work together to deliver a powerful yet easy-to-understand integration.
The SDK can be used in off-chain for handling complex decision-making and strategy formulation, while the on-chain components execute these strategies reliably and securely in the blockchain environment.
Off-Chain Components
Off-chain components refer to the elements that operate outside the blockchain. Generally speaking:
- The conceptual strategy itself (including triggers and the actions to be executed).
- The actual code implementing said strategy through Nexera-Fi SDK.
- The data input for the strategy (most likely a live data feed).
- The Executor or Transaction Relayer, in charge of sending the transactions to the Orchestrator contract, according to the strategy.
For example:
If at a given point in time t0
, your DeFi strategy needs to swap
a native token on Ethereum, and then a withdraw
, provided that you have properly configured your instance, you can make this call through the SDK:
On-Chain Components
The on-chain components are Smart Contracts deployed to the blockchain and are responsible for the execution of transactions, handling of assets, and interaction with various DeFi protocols. Smart contracts are the backbone of the on-chain architecture. They execute the actions decided by the off-chain components, manage assets, and ensure that transactions are completed according to the predefined rules and conditions.
On-chain the strategies are managed by primitive functions, interpreted by the Orchestrator with the use of Adapters. Some examples are:
Adapters are specialized on-chain components that translate the generic actions from the strategy into protocol-specific transactions. They enable the SDK to communicate and interact with different DeFi protocols.
For example, within ICompoundCErc20CEther
(an Adapter for Compound), you'll find the native Protocol interactions:
When the on-chain strategy Orchestrator receives the set of actions from the off-chain strategy and orchestrates their execution through the Adapters, it acts as a relayer from actions to protocols. You can check more examples here.