Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFP Application<X-LEND> #27

Open
harleyLuke opened this issue Dec 3, 2024 · 3 comments
Open

RFP Application<X-LEND> #27

harleyLuke opened this issue Dec 3, 2024 · 3 comments
Labels
RFP Request for Proposal Wave2

Comments

@harleyLuke
Copy link

harleyLuke commented Dec 3, 2024

X-LEND: A Comprehensive Staking and Reward Distribution System

Overview

Pswan 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.

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

Collateral Guarantee

The CP (Collateral Provider) is required to pledge a small amount of collateral. If there is no return within X days or if the collateral decreases by X% within Y days, the staked assets lent to the CP node will be automatically withdrawn, and the collateral will be returned to the CP.

  • The CP's collateral amount can be increased at any time based on the protocol's rules.

Miner Creation

Miners can create new nodes by interacting with the X-LEND smart contract. Upon node creation:

  • The smart contract address becomes the CP's Owner Address for easy management and the Owner permissions are managed by X-LEND.
  • The CP's Worker Address is set to the address provided by the CP.

Revenue Distribution

Revenue generated within the ecosystem will flow into the reward pool. The revenue distribution is split as follows:

  • x% directly goes to the CP
  • y% is allocated to the users who have staked tokens (Pswan holders)
  • z% is used for protocol fees

The percentages (x%, y%, z%) could be dynamically adjusted, possibly using a dynamic price oracle mechanism that adjusts based on the price of Swan.

Miner Exit

Miners can request to exit the system. After X days, the miner's contract will be terminated, and their staked tokens will be returned to the Swan Staking Pool.


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.

@harleyLuke harleyLuke added the documentation Improvements or additions to documentation label Dec 3, 2024
@flyworker flyworker added RFP Request for Proposal Wave2 and removed documentation Improvements or additions to documentation labels Dec 3, 2024
@harleyLuke
Copy link
Author

If possible, I would like to discuss pre-development details as soon as possible, since TGE is launching soon.

@flyworker
Copy link
Member

@harleyLuke please send an email to [email protected] for planing a call

@harleyLuke
Copy link
Author

@harleyLuke please send an email to [email protected] for planing a call

Email has been sent, looking forward to your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFP Request for Proposal Wave2
Projects
None yet
Development

No branches or pull requests

2 participants