Transaction flow
Step by step explanation of on-chain and off-chain operations
Last updated
Step by step explanation of on-chain and off-chain operations
Last updated
The user accesses the Chainspot frontend (or via the API if they are a B2B partner) to select a desired yield vault and requests the most advantageous route for exchanging and transferring funds to the yield protocol's network (in this case, from BNB Chain to Base chain).
The user signs the callData
with the payload to execute a cross-chain deposit transaction of the token into the yield protocol on the Base network. After this, the asset along with the payload (instruction) is sent to the Chainspot managing contract.
The user’s tokens are transferred to the liquidity protocol contracts for exchange and transfer to the Base network. At this stage, the Chainspot on-chain and off-chain connector is utilized to various bridges and DEXs (e.g., Symbiosis, 1inch, etc.).
During the exchange/transfer, and subsequent allocation of funds in the yield protocol, several off-chain modules are involved:
The Liquidity Routing Module, which connects to liquidity protocols, ensures the most efficient and rapid process for exchanging and transferring tokens to the destination network.
The Yield Routing Module, which generates the payload for depositing the user’s tokens into the yield protocol, accounting for the final amount after all fees and slippage from the liquidity protocols.
The Gamification Module, which records the successful transaction and awards points, cashback, and other bonuses to the user's loyalty program.
At this point, the user’s funds have been successfully exchanged and transferred to the yield protocol network (Base), landing on the Chainspot liquidity management proxy smart contract.
The user’s funds are moved to the smart contract to execute the deposit into the yield protocol, emitting an event for the Yield Routing Module with the transaction status. Atomic transaction.
After receiving the event, the Yield Routing Module sends the payload with instructions to the Chainspot manager contract to execute the user’s deposit into the yield protocol, minus the blockchain fee for the transaction. Atomic transaction.
The user’s tokens are deposited into the yield protocol, resulting in the Chainspot manager smart contract receiving the LP tokens from the yield protocol. These tokens are immediately wrapped into a cross-chain native format (also known as omnichain) using the Asterizm smart contract abstraction. During this transaction, a key-value pair is recorded on the contract, marking the owner’s address, which prevents the withdrawal of funds from any other address, including that of the Chainspot manager contract owner (the Chainspot team). This transaction is atomic. Atomic transaction.
Utilizing the Asterizm infrastructure, the Chainspot manager contract initiates the transfer of the cross-chain native LP token from Base back to the BNB Chain.
At this stage, the cross-chain native LP token is moved from the Base network to the BNB Chain, using the mint/burn mechanism implemented within the Asterizm smart contract abstraction. To ensure the security of the cross-chain transaction, as per the protocol's architecture and business logic, the on-chain client computes a hash of the payload. This payload contains information indicating that the LP token was burned on the Base network and that an equivalent amount of LP tokens should be minted and transferred to the user’s address. Following the hash computation, the on-chain client contract emits an event that is monitored by Asterizm relay servers and the Chainspot client server, which operates on Asterizm. The Asterizm relays transfer the hash to the BNB Chain, while the Chainspot client server moves the payload.
In the BNB Chain, before executing the payload (token minting to the user’s address), the on-chain client Asterizm smart contracts validate the cross-chain transaction by recomputing the hash from the received payload and comparing it with the one received from the Asterizm relay servers. If the hashes match, the received payload is executed. This approach ensures the secure delivery of the payload (moving cross-chain native LP tokens between networks), even in the event of a compromise of Chainspot's servers, as the final verification relies on cryptographic hashing and is fully executed on the destination network smart contract (in this case, the BNB Chain).
Upon successful verification of the cross-chain transaction’s validity, the Asterizm on-chain client smart contract sends the payload to the Chainspot manager contract with instructions to mint the cross-chain native LP tokens from the position in the yield protocol on the Base network to the user’s address.
The Chainspot manager contract mints the cross-chain native LP tokens and sends them to the user’s address. At this stage, the business logic of the "cross-chain deposit" action concludes, whereby the user, having signed a single transaction on the BNB Chain, opens an on-chain DeFi position in the yield protocol on the Base network. Subsequently, the user can manage this position, also paying transaction fees in the BNB Chain: claiming rewards, withdrawing, and adding to the position.
The user signs the transaction to withdraw funds from the yield protocol (closing the position). This can be done by directly interacting with the smart contract or through the Chainspot website or its B2B partners.
After the transaction is signed, the LP tokens are burned, and a payload is created for sending to the Base network.
The proofs are calculated on the smart contract, and the payload is transmitted to the network.
Upon validation, the payload is sent for execution to the contract, which retrieves the original LP tokens and processes the withdrawal.
The user’s funds are withdrawn to the Chainspot smart contract, emitting an event for the Liquidity Routing Module and the Yield Routing Module.
After receiving the event indicating successful withdrawal from the yield protocol, the Yield Routing Module updates the status of the DeFi position for analytical purposes and to reflect it on the Chainspot interface or the partner frontend. The user's funds are then sent to the Chainspot liquidity smart contract for further transfer back to the original network, BNB Chain.
Utilizing the Liquidity Routing Module, an optimal route is established for transferring the funds back to the user’s original network (BNB Chain). Subsequently, the exchange and transfer of funds to the BNB Chain address are executed.
Error During Exchange/Transfer of Funds If there is an issue on the liquidity provider's side during the transaction, the funds are automatically returned to the user's address in the original network, minus the blockchain fee. If the funds are stuck on the bridge due to technical reasons, the bridge team can either manually process the return upon request or execute an automatic return via the bridge's website.
Deposit Issues in the Destination Network (Chain where is Yield Protocol deployed) If there is a failure at the yield protocol smart contract level, a gas spike, or any other reason:
For EVM Networks: The user can retrieve their funds within the same network by making a request to the smart contract from the same address used to initiate the DeFi position in the original network.
For Non-EVM Networks (e.g., Solana): The user can recover their funds using a special method called rescueDeposit
in the smart contract of the original network. This method sends a signed withdrawal instruction (payload) to the yield protocol network, leveraging the cross-chain messaging protocol Asterizm. Upon receiving this instruction, the yield protocol network will execute a method that requests the Liquidity Routing Module to transfer the user's funds back to their original network. Consequently, the funds will be returned at the best exchange rate, minus the non-EVM blockchain fees.
Inaccessibility of the Chainspot Frontend Even if the Chainspot website is unavailable, users can still withdraw their funds from the yield pools by utilizing smart contract methods. Detailed instructions on these methods will be provided in the project's GitHub repository.
Sudden Price Surge During Token Exchange (Slippage) The deposit transaction into the yield protocol will still be successful even if there is a sharp price spike during the user's exchange/transfer. Chainspot is designed to save users' time and funds, so in this scenario, the funds will be deposited based on the amount received from the exchange, ensuring the user does not incur additional costs for a repeat deposit transaction.
The scheme will be done soon....