Protocol-Side Workflow
Last updated
Last updated
The backend architecture of Lasagna Finance is entirely built on decentralized smart contracts using Solana's Anchor framework. Below is the detailed design of the protocol-side workflow:
Anchor Framework: Lasagna Finance is built using Solana's Anchor framework, which simplifies Solana smart contract development and ensures compatibility with DeFi standards.
Program Account: The protocol's main program account holds all the logic for staking, restaking, and withdrawing. It also manages user-specific data such as staked balances, reward rates, and timestamps.
User Accounts: Each user interacting with the protocol has a unique account on-chain that tracks their staking position, rewards, and transaction history. This ensures that user-specific data is stored securely and updated transparently.
PDA (Program Derived Accounts): Lasagna Finance uses Program Derived Accounts to ensure secure interaction between the user’s account and the protocol. PDAs allow for multi-signature authorization, ensuring only the intended user can modify their staking data.
On-Chain Storage: All staking data (user balances, rewards, etc.) is stored on-chain in the user’s account. This data is accessed and updated during each staking, restaking, or withdrawal transaction.
Off-Chain Data Indexing: For enhanced analytics and reporting, off-chain services (e.g., The Graph protocol) may be used to index and analyze on-chain data, providing users with insights such as historical APY and staking performance.
Security and Auditing: The smart contract is designed with security in mind, including regular audits and stress tests to ensure resistance to common DeFi exploits like reentrancy attacks.
User Initiated Transactions:
Users initiate transactions such as staking, restaking, and withdrawing by interacting with the frontend, which sends signed instructions to the smart contract on the Solana blockchain.
Processing and Validation:
The smart contract receives these instructions and processes the transactions in accordance with protocol rules. Each transaction undergoes validation (e.g., sufficient token balance, proper signatures) before being executed.
Reward Distribution:
Staking rewards are calculated continuously but distributed during restaking or withdrawal. This ensures rewards are fairly allocated based on the user’s staking duration and amount.
Scheduled Jobs: The protocol periodically runs automated jobs to handle the restaking logic for all users.
Batch Restaking: These jobs batch multiple restaking operations into a single transaction to optimize gas fees and reduce network congestion.
APY Monitoring: The protocol continuously monitors APY across multiple staking pools and dynamically reallocates funds if higher returns are available elsewhere.
DeFi Protocol Integration: Lasagna Finance integrates with popular liquid staking providers (e.g., Lido, Marinade) and decentralized exchanges (DEXs) to provide the best staking opportunities.
Yield Optimization: The protocol is designed to seamlessly switch between staking pools when better opportunities arise, ensuring users consistently receive the highest possible returns.