xGov-197 - CompX - xUSD -> COMPX Staking - Governance Discussions / xGov Proposals Pilot - Algorand
xGov-197 - CompX - xUSD -> COMPX Staking
post by Xxiled on Apr 24, 2024
id: 197 period: 4 title: CompX - xUSD → COMPX Staking author: Kieran Nelson (@xxiled-plastic-cat) discussions-to: xGov-197 - CompX - xUSD -> COMPX Staking company_name: CompX Labs category: dApps focus_area: DeFi funding_type: Proactive open_source: Yes amount_requested: 60000 delivery_date: 2024-06-30 status: Draft
Abstract
Creation of an xUSD → COMPX staking contract which will allow xbacked users to gain a position within CompX and accumulate what will become the governance token for the CompX platform - that xBacked is now part of.
Secondly, this staking contract would give users additional reasons to use and hold their xUSD which will ultimately help toward maintaining the soft USD peg for xUSD.
Team
Kieran Nelson - CEO/Founder at CompXLabs
Akingbesote Jesulonimi (Nimi) - Founder / Lead smart contract developer
Experience with Algorand
Kieran - 2.5 years working in the Algorand ecosystem across Algogator and CompX. Extensive experience with Algorand SDK and ecosystem APIs.
Nimi - 2 years experience working with xBacked creating smart contracts, front end, and backend for the platform.
Proposal
The staking contracts for xUSD were previously made and audited however these were written in Reach.sh and are not upgradable and the limited experience of Reach in the ecosystem makes them difficult to maintain. We will be re-writing these contracts in Tealish as this is Nimi’s preferred SC language to use.
See the video below for more info:
Technical specifications
The technical specifications for this contract and associated front end UI are presently below in pseudo-code/plain language - actual contract/code variables may differ in name.
Global State variables: totalStake, totalRewards, state, numberOfStakers, lockPeriod, rewardTokenId, rewardsPerBlock, stakeTokenId, accessTokenId, accessTokenBalanceRequired, minimumStake, maximumStake
Local State variables: currentStake, claimedRewards, unclaimedRewards, totalRewards, lockPeriodStart, lockPeriodEnd
There are a number of variables that can be set at contract deployment to allow for different styles of staking, these are:
accessTokenId: The token ID of an ASA that the user must have in their wallet to be able to use the staking contract. If accessTokenId == 1, this setting will be ignored (As the ALGO ASA token has an id of 0)
accessTokenBalanceRequired: The balance needed in the users wallet to access the staking contract. If accessTokenBalanceRequired == 0, this setting will be ignored. Balance required is in lowest denominator units i.e microAlgo.
minimumStake: The minimum stake amount in the chosen ASA that must be placed into the contract to participate in rewards. If minimumStake == 0, this setting is ignored.
maximumStake: The maximum stake amount in the chosen ASA that can be placed in the contract. If maximumStake == 0, this setting is ignored.
Functions:
Manager functions - only usable by the contract deployer
addRewards: adds rewards to the staking contract
setRewardsPerBlock: sets the rewardsPerBlock
removeRewards: removes a set number of rewards from the contract
closeStakingPool: sets state to closed, returns all rewards that have been unspent to the manager, stops reward payouts and disabled stakeTokens method - users can only unstake and claim rewards.
deployStakingPool: initial deployment, sets state to deployed
beginRewardPayouts: starts reward payouts to stakers based on rewardsPerBlock and sets state to running
User functions:
stakeTokens
unstakeTokens
claimRewards
User rewards are calculated based on the rewardsPerBlock variable which is set at deployment but can be updated by the contract manager. The variable, rewardsPerBlock, is the total rewards available to all stakers for that block. Rewards in that block are then split among stakers depending on their percentage of the total stake their stake represents.
Rewards will continue to pay out until the totalRewards variable is exhausted where in the contract is set into the closed state.
Future Blueprint
As the contract is being built generically we hope to use it for other tokens within CompX or in future applications. We believe that making this open source will allow other platforms to take advantage of the contract also.
Maintenance: While deployed on CompX this contract will be maintained as production-ready code. If the contract is removed from CompX and no longer in use by ourselves, 3 months maintenance will be provided on the repository.
Benefits for the community
- This is one of many tools being brought out to add further utility to xUSD which will have an effect on holding the Peg as users don’t sell their xUSD as readily as now. The community can take advantage of the rewards and having a native stablecoin that is more stable.
- We hope that making this open source encourages the community to use the contract and build on it but also shows that CompX is open to community development and feedback.
Additional information
653 views
25 likes
3 links
post by dashawn.algo on Apr 24, 2024
Wow I this is great getting a plan together to help Algorand have its own native stable coin and give the community power to push Algorand to be a stronger ecosystem
post by TheHolyGoat on Apr 25, 2024
The consequences of TDR passing for certain protocols are unfolding. CompX/xBacked vaults have been gaining a lot of attention, new users, ASA options, etc. All great, but when xUSD is minted it is hard to compete with USDt/USDC farming and pool options. I do think incentivizing xUSD→CompX staking is beneficial for the reasons you stated (longer hold times/less sell pressure, and then of course rewarding users). The open-source is a huge plus, and upgradeable contracts seem important. Does this centralize things in any way? I imagine this is something the gov token seeks to involve itself with. Regardless, you have my vote!
A couple additional opinions:
Would be great if APY is greater than minting xUSD, selling for USDC, and then lending it/lending pools/any other farming options around the ecosystem. With that said, given the recent depegs, I could still see some opt for the instant USDC swapping. Confidence will build.
xUSD staking is needed, and excited to see it pass and grow alongside the serious pegging I heard you guys are doing over there at CompX … had to. Cheers guys really hope this passes
post by Xxiled on Apr 25, 2024
Haha, someone had to make that joke - I’m surprised it took this long!
Great suggestions - we do want to start with a high APY so we can discourage the sell for USDC behavior but it will have to balances against other rewards.
If our TDR proposals pass then that’s easier but if not we’ll work it out.
post by Xxiled on Jul 11, 2024
Contracts are set up and can be verified. UI is on its way which will allow standard testing.
post by Xxiled on Aug 5, 2024
Contract is now live on mainnet for use.
I believe we’ve satisfied our deliverables - @Adri
post by 565dsi on Aug 6, 2024
Deposited yesterday and its humming along. Thanks for all the hard work, great to see it up and running.
post by Xxiled on Aug 6, 2024
Work and deliverables complete: GitHub - compx-labs/staking-contracts
Staking pools available at CompX
post by Adri on Aug 6, 2024
Thanks @Xxiled - It’s queued up with the team for deliverables review.
post by TheHolyGoat on Aug 6, 2024
I’m staking on CompX right now, everything is working great
Thanks for this, and I’m excited to see what’s next
post by dashawn.algo on Aug 6, 2024
Wow staking is working great just deposited some xUSD the other day CompX is moving right along