Protocol Logic
Last updated
Last updated
The core logic of Lasagna Finance revolves around the smart contract deployed on the Solana blockchain. This smart contract defines the behavior of staking, restaking, and withdrawal operations, ensuring that all interactions are secure and follow DeFi best practices.
Stake Function:
Users can deposit LST tokens (e.g., stSOL or mSOL) into the contract using the stake function.
Upon staking, the tokens are transferred from the user's wallet to the protocol’s staking pool.
The user's account is updated to reflect the staked amount, and a timestamp is recorded to track when rewards begin accumulating.
Reward Calculation:
The protocol calculates rewards based on a time-weighted formula, factoring in the amount staked and the duration for which the tokens have been staked.
The smart contract updates the user’s balance of pending rewards at each restaking interval.
At predefined intervals (e.g., every 24 hours), the protocol automatically triggers the restake function for all users.
The accumulated staking rewards are compounded and re-staked to increase the user's overall position.
Restaking ensures that users' rewards continue to grow exponentially without manual intervention.
Batch Processing:
To reduce transaction fees and improve efficiency, the protocol batches multiple user restaking operations into a single transaction.
This allows for gas savings and prevents network congestion, ensuring smooth operations.
APY Optimization:
The restaking logic checks current APY rates from various staking pools. If a higher APY is available, the protocol can automatically migrate staked tokens to the more profitable pool, further optimizing returns for the user.
Withdraw Function:
Users can request to withdraw their staked tokens, including the compounded rewards, at any time.
Upon withdrawal, the smart contract transfers the user's tokens (including rewards) back to their wallet.
A small withdrawal fee (e.g., 0.1%) is collected to sustain the protocol’s operations.
Penalty for Early Withdrawal:
To discourage early withdrawals and maintain liquidity, the protocol applies a small penalty for users withdrawing before a certain minimum staking period (e.g., 7 days).
This penalty is redistributed among the remaining stakers to further incentivize long-term staking.
The protocol collects small performance and withdrawal fees from each transaction.
Collected fees are stored in a separate vault and can be redistributed to long-term stakers or used for protocol upgrades and maintenance.