X-LEND: A Comprehensive Staking and Reward Distribution System.Allows users to start a node with a small amount of funds.
Overview
X-LEND is a decentralized staking and reward distribution system that integrates Swan token staking and reward allocation. It operates on two sides: User and CP, ensuring both liquidity and security within the ecosystem. This document outlines the process flow, gas cost optimization strategies, and security design.
User
Staking
Users can stake Swan tokens into the Swan Staking Pool. In return, they receive Pswan tokens, where the exchange rate between Swan and Pswan is 1:1. The tokens are locked in the staking pool and are available for withdrawal based on user actions and pool conditions.
Withdrawal
The Swan Staking Pool is divided into two categories:
- Used Swan tokens
- Unused Swan tokens
Users can withdraw their staked Swan tokens in a 1:1 ratio by redeeming their Pswan tokens for the amount of Unused Swan in the staking pool.If Unused Swan < Amount of withdrawal ,Unable to withdraw successfully
Rebase Mechanism
Every day at a fixed time, the system deposits CP (Collateral Pool) earnings into the reward pool. Afterward, a Rebase event occurs where all Pswan holders receive additional Pswan tokens based on their holding amount.
- Rebase is triggered after rewards are distributed, and the first user to trigger the reward distribution will bear the Gas fees.
- The first user also receives an extra Lucky Pswan as a gas fee subsidy, which acts as a reward for triggering the rebase.
CP
All Miners Management - cp_all_manage.sol:
- Dynamic creation of miner addresses using
cp_owner_manage.sol.
- When a miner exits, they submit an exit request, and after 7 days, the contract is terminated, and the staked tokens are returned to the Swan Staking Pool.Margin return CP
- The yield distribution ratio is set
- The yield Base collateral daily rental value is set
- Each time the rebase mechanism is triggered, the contract sends the rewards to the rebase pool, miner's WorkerBeneficiary address, and the protocol.
Actual Miner Management - cp_owner_manage.sol:
Initialization
- Every time a miner applies for a node, the contract dynamically creates an
cp_owner_manage.sol contract through cp_manage.sol. This contract creates a Swan CPAccount, and both the CPAccount Owner and Beneficiary addresses are set to the dynamically created contract address, while the Worker And WorkerBeneficiary address is the one provided by the miner during application.
Native CPAccount Operations
- Supports calling all functions of the Swan official CPAccount.sol by
cp_owner_manage.sol. The write operation flow is as follows: cp_manage.sol -> cp_owner_manage.sol -> CPAccount.sol.
Margin Management
- The X-lend protocol allows users to start a node with a small amount of funds.
- The CP initially stakes 5% of the collateral to provide a guarantee, and the collateral is directly staked into the CPAccount.
- The Margin can only be returned to the miner after exit, and the miner can increase the Margin
Risk control
If no earnings are generated within 7 days or If the deposit is deducted due to task failure and (margin + borrowed collateral)/borrowed collateral is lower than 102%,
- The node's mult address will be set to an invalid value and forced to go offline.
- The node will be retained for 3-7 days. Once the miner increases the deposit to 105%, the node's mult address will be restored.Otherwise trigger liquidation(the node will not be recoverable)
- Apply to withdraw collateral (it takes 7 days)
- The collateral loaned to the CP node is withdraw to Swan Staking Pool.
- The margin is forfeited into the rebase pool.
Profit Distribution
Revenue Flow into Reward Pool:
- The revenue flows into the reward pool, with the proportions of x%, y%, and z% allocated to CP, users, and protocol fees respectively (adjusted dynamically based on Swan's dynamic pricing oracle).
Dynamic Allocation Rules
-
Base Collateral: 1cu=3533, 1 Swan = $0.1
-
Base Distribution: x = 20%, y = 20%, z = 5%.
-
If today's income is 100 Swan, and the daily rental value of the Base Collateral is $2 (as input externally), then the remaining 55% will be distributed as follows:
x = 20 + ($2 / 100 * $0.1 (max 1)) * 55
y = 20 + (1 - $2 / 100 * $0.1 (max 1)) * 55
z = 5
This results in the final distribution of:
Gas Cost Optimization
When staking amounts are large, the gas costs for operations like rebase and reward distribution can be quite high. The following strategies are used to mitigate these costs:
Indexer for Staker Records
Instead of maintaining a large list of all stakers in the contract, which would be gas-inefficient, an indexer is used to track staking events. Stakers are not directly stored within the contract but are instead recorded via events. This reduces the need for frequent contract reads and updates.
Event Logging for Staker Tracking
Each time a user stakes or unstakes Swan tokens, an event is emitted that logs their staking details. These events can be indexed off-chain, reducing the need to interact with the contract every time rewards are distributed or the rebase occurs.
Rebase Optimization
Rebase is triggered once a day, and only the first user who triggers the reward distribution will pay the gas fees. This minimizes the overall gas usage as the system doesn't require all users to trigger their rebase individually.
Security Design
On-chain Process
All processes are executed on-chain, ensuring that the entire staking, reward distribution, and collateral management system are transparent, auditable, and secure.
- Off-chain processes are only responsible for triggering the collateral clearing for CP nodes based on the time-based conditions.
Contract Audits
Before deployment, the entire smart contract system will undergo comprehensive security audits by a reputable third-party audit firm. This ensures that all potential vulnerabilities, such as reentrancy attacks or unexpected overflow, are mitigated before the system goes live.
Owner Address
The owner address involved in operations that can manage user pledges and withdrawals can be changed to the official multi-signature address of Swan Chain and X-Lend to protect user assets..
Conclusion
Pswan is designed to provide a fair, efficient, and secure staking system with a strong focus on gas cost reduction and scalability. By utilizing the rebase mechanism, dynamic reward distribution, and collateral management, Pswan offers users an attractive way to earn rewards while maintaining a robust and secure ecosystem for all participants.
Project Milestones and Timeline
Milestones and Timeline
| Milestone |
Description |
Timeline |
Funding Required |
| Milestone 1 |
Contract development and testing, staking website, and feature integration |
2-3 weeks |
5000 OP |
| Milestone 2 |
Establishing social media, building the official website, and contract auditing |
1-3 weeks |
$10K OP or Swan |
| Milestone 3 |
Start operations and complete contract audit |
After contract audit completed |
$30K OP or Swan |
Funding Requirements
Total funding requested: $50K, consisting of 5000 OP as initial capital, with the remainder to be settled in Swan or OP at different stages.
Fund Allocation
The $50K (5000 OP) funding will be allocated as follows:
- Initial development(Contracts, websites, documents): 5000 OP
- Contract auditing and promotional(social media) : $10,000
- Initial Swan Staking Pool,Activity reward pool and promotional expenses post-launch: $30,000
X-LEND: A Comprehensive Staking and Reward Distribution System.Allows users to start a node with a small amount of funds.
Overview
X-LEND is a decentralized staking and reward distribution system that integrates Swan token staking and reward allocation. It operates on two sides: User and CP, ensuring both liquidity and security within the ecosystem. This document outlines the process flow, gas cost optimization strategies, and security design.
User
Staking
Users can stake Swan tokens into the Swan Staking Pool. In return, they receive Pswan tokens, where the exchange rate between Swan and Pswan is 1:1. The tokens are locked in the staking pool and are available for withdrawal based on user actions and pool conditions.
Withdrawal
The Swan Staking Pool is divided into two categories:
Users can withdraw their staked Swan tokens in a 1:1 ratio by redeeming their Pswan tokens for the amount of Unused Swan in the staking pool.If Unused Swan < Amount of withdrawal ,Unable to withdraw successfully
Rebase Mechanism
Every day at a fixed time, the system deposits CP (Collateral Pool) earnings into the reward pool. Afterward, a Rebase event occurs where all Pswan holders receive additional Pswan tokens based on their holding amount.
CP
All Miners Management -
cp_all_manage.sol:cp_owner_manage.sol.Actual Miner Management -
cp_owner_manage.sol:Initialization
cp_owner_manage.solcontract throughcp_manage.sol. This contract creates a Swan CPAccount, and both the CPAccount Owner and Beneficiary addresses are set to the dynamically created contract address, while the Worker And WorkerBeneficiary address is the one provided by the miner during application.Native CPAccount Operations
cp_owner_manage.sol. The write operation flow is as follows:cp_manage.sol -> cp_owner_manage.sol -> CPAccount.sol.Margin Management
Risk control
If no earnings are generated within 7 days or If the deposit is deducted due to task failure and (margin + borrowed collateral)/borrowed collateral is lower than 102%,
Profit Distribution
Revenue Flow into Reward Pool:
Dynamic Allocation Rules
Base Collateral: 1cu=3533, 1 Swan = $0.1
Base Distribution: x = 20%, y = 20%, z = 5%.
If today's income is 100 Swan, and the daily rental value of the Base Collateral is $2 (as input externally), then the remaining 55% will be distributed as follows:
x = 20 + ($2 / 100 * $0.1 (max 1)) * 55y = 20 + (1 - $2 / 100 * $0.1 (max 1)) * 55z = 5This results in the final distribution of:
Gas Cost Optimization
When staking amounts are large, the gas costs for operations like rebase and reward distribution can be quite high. The following strategies are used to mitigate these costs:
Indexer for Staker Records
Instead of maintaining a large list of all stakers in the contract, which would be gas-inefficient, an indexer is used to track staking events. Stakers are not directly stored within the contract but are instead recorded via events. This reduces the need for frequent contract reads and updates.
Event Logging for Staker Tracking
Each time a user stakes or unstakes Swan tokens, an event is emitted that logs their staking details. These events can be indexed off-chain, reducing the need to interact with the contract every time rewards are distributed or the rebase occurs.
Rebase Optimization
Rebase is triggered once a day, and only the first user who triggers the reward distribution will pay the gas fees. This minimizes the overall gas usage as the system doesn't require all users to trigger their rebase individually.
Security Design
On-chain Process
All processes are executed on-chain, ensuring that the entire staking, reward distribution, and collateral management system are transparent, auditable, and secure.
Contract Audits
Before deployment, the entire smart contract system will undergo comprehensive security audits by a reputable third-party audit firm. This ensures that all potential vulnerabilities, such as reentrancy attacks or unexpected overflow, are mitigated before the system goes live.
Owner Address
The owner address involved in operations that can manage user pledges and withdrawals can be changed to the official multi-signature address of Swan Chain and X-Lend to protect user assets..
Conclusion
Pswan is designed to provide a fair, efficient, and secure staking system with a strong focus on gas cost reduction and scalability. By utilizing the rebase mechanism, dynamic reward distribution, and collateral management, Pswan offers users an attractive way to earn rewards while maintaining a robust and secure ecosystem for all participants.
Project Milestones and Timeline
Milestones and Timeline
Funding Requirements
Total funding requested: $50K, consisting of 5000 OP as initial capital, with the remainder to be settled in Swan or OP at different stages.
Fund Allocation
The $50K (5000 OP) funding will be allocated as follows: