Skip to content

Commit 1919cc2

Browse files
committed
XRDao platform
1 parent 5d3c389 commit 1919cc2

File tree

3 files changed

+64
-33
lines changed

3 files changed

+64
-33
lines changed

5-DAO/xrdao/src/lib.rs

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,59 @@
11
/// **This submission does not need to be judged due to being incomplete***
22
///
33
/// XRDao protocol is built for medium to long term XRD holders and XRD altcoin
4-
/// investors. XRDao is the main component where most of the interactions
5-
/// take place. This blueprint allows users to mint XRDao which is pegged 1:1 to XRD. The
6-
/// XRDao token has a small tax taken for every trade, transfer, mint, or burn starting at .5%
7-
/// and can change from governance vote. Platform fees go towards buying protocol owned
8-
/// liquidity from the radiswap component and rewarding users
9-
///
10-
/// The basis of this platform is that as
11-
/// Users can add Radix altcoins to the investments available for the platform by
12-
/// governance proposal and vote. Users take their XRDao tokens and invest in these
13-
/// tokens in similar ways as doing it themselves. Users are incentivized to use the
14-
/// platform by earning repuataion (rep) tokens when making successful trades and/or earning
15-
/// fees for the protocol. The more rep a user earns, the higher rank the user can achieve.
16-
/// Higher ranks allow users to
17-
/// 1) Earn substantially higher shares of platform fees distributed
18-
/// 2) Increases Users base voting power curve
19-
/// 3)
20-
///
21-
///
22-
///
23-
/// the protocol takes a small fee on minting and burning
24-
///
25-
/// The
26-
///
27-
///
28-
///
29-
/// XRDaoUsers component organizes users information and stores this
30-
/// data on soul bound tokens (SBTs) given to each user. This component is responsible
31-
/// for keeping all data and balances up to date on these SBTs.
32-
///
33-
/// XRDaoProposal component allows users to create
4+
/// investors that are interested in a sustainable rewards structure. XRDao is the main
5+
/// component where most of the interactions take place. This blueprint allows users to mint
6+
/// XRDao which is pegged 1:1 to XRD. The XRDao token has a small tax taken for every trade,
7+
/// transfer, mint, or burn starting at .5% and can change from governance vote. A percent of platform
8+
/// fees (which also can change via governanve vote) go towards buying protocol owned liquidity from the
9+
/// radiswap component. The rest of platform fees collected are distributed to users of XRDao
10+
/// that make successful trades and strategies when investing through the platform. Future investment
11+
/// choices will be added along with altcoin investing such as staking to trustworthy validators, loaning
12+
/// funds to a lending platform for interest. In order to use XRDao, a user would send XRD
13+
/// to the platform and mint XRDao token. The exchange rate for minting and burning XRDao always remains
14+
/// 1:1 minus the buy/sell fee. The user would then use these XRDao tokens to pick investment options
15+
/// just as they would with XRD, but the platform would be making the actual trades/stakes for you.
16+
/// When a user makes a successful trade, Repuation (rep) tokens are awarded for the amount of xrd earned.
17+
///
18+
/// For example:
19+
/// User 1 has 100 xrd and mints 99.5 xrdao,
20+
/// User 1 invests 99.5 xrdao into oci,
21+
/// Oci goes 2x up in price relative to xrd,
22+
/// User 1 exits oci position
23+
/// User 1 sends xrdao to burn in return for xrd
24+
///
25+
/// User 1 now has 198.005 xrdao tokens that can be burned and exchanged for xrd minus the burn fee, as
26+
/// well as 1.495 Rep. Rep is a soulbound token created by the XRDao platform to signify who is most profitable
27+
/// for the platform. It can't be bought, sold, or traded, but it can be earned and minted for good behavior
28+
/// or removed and burned for bad behavior. Users are catagorized into Rank by the amount of rep they hold
29+
/// into the following ranks:
30+
///
31+
/// President, Highest rep, linear relationship between xrdao and voting power, top 1% of users, 3x reward multiplier
32+
/// VicePresident, x = y^1.1 voting power, top 10% of users, 1.67x reward multiplier
33+
/// Senator, x = y^1.2 voting power, top 30% of users, 1.25x reward multiplier
34+
/// Governor, x = y^1.3 voting power, top 50% of users, 1x reward multiplier
35+
/// Citizen, x = y^1.5 voting power, top 75% of users, .925x reward multiplier
36+
/// Pleb, Lowest rep, quadratic relationship, x = y^2 voting power, top 100% of users, 0x reward multiplier
37+
///
38+
/// As you can see, different ranks give different curves to determine voting power and different shares of the
39+
/// fees generated from the platform. The more money you make, the more rep you earn, the more fees you acrue.
40+
/// You might be asking yourself, why wouldnt these users just invest themselves and avoid platform fees
41+
/// alltogether? XRDao harneses sustainable revenues from market volatility. When the protocol buys liquidity
42+
/// from radiswap for XRDao-XRD, XRD volatility will generate price differences between the two tokens in the pool.
43+
/// When there is ever a price difference above the fee that is being charged (.5%) there will be a profitable
44+
/// arbitration opportunity within the pool. Whether an arbitrage bot or a user makes it, fees are then
45+
/// generated from that trade and go back to buying more liquidity and rewarding each user based on reputation.
46+
///
47+
/// The majority of my work here is to the xrdaouser and user components. Tokentax is a start of an attempt to
48+
/// design a component that a token must pass through in order to extract taxes from dex transactions. My
49+
/// understanding is this feature doesnt current work at the resource level, but hopefully it will be in the
50+
/// future. xrdaoproposal is mostly still copy paste from the Liquidity Dao scrypto examples. Radiswap is instantiated
51+
/// to trade and provide liquidity for XRDao-XRD token.
52+
///
53+
/// written by Austin
54+
/// @aus877 on twitter
55+
/// @aus87 on telegram
56+
3457

3558
mod radiswap;
3659
mod xrdao;

5-DAO/xrdao/src/tokentax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ blueprint! {
4040
pub fn take_tax() {
4141
/// take in bucket of token
4242
/// assert token address matches token address from component
43-
/// take tax from bucket, put
43+
/// take tax from bucket, put in xrd_fees_collected vault in xrdao component
4444
/// pass remainder back to user
4545
/// present admin badge to allow the portion sent back to user to be used in trade/swap/transfer
4646
}

5-DAO/xrdao/src/xrdao.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,16 @@ blueprint! {
152152

153153
// take fee in put tokens in fee vault
154154
let total_fee: Decimal = xrd_deposit.amount() * self.buy_fee; // Calculate fees
155-
self.xrd_fees_collected.put(xrd_deposit.amount(total_fee)); // puts the collected fee in vault
155+
let fee_collected: Bucket = xrd_deposit.take(total_fee);
156+
self.xrd_fees_collected.put(fee_collected); // puts the collected fee in vault***********************
156157

157158
// Take remainder and send back to user
159+
160+
// test how much is actually in here? has fee been successfully taken?
161+
info!("amount to mint is {:?}", xrd_deposit.amount()) // ***should be 99.5
162+
158163
let xrdao_to_mint: Decimal = xrd_deposit.amount();
159-
self.collected_xrd.put(xrd_deposit.amount(xrdao_to_mint)); // puts xrd in vault
164+
self.collected_xrd.put(xrd_deposit); // puts xrd in vault *****************************************
160165

161166
// Mint xrdao according to how much xrd was deposited
162167
let xrdao_resource_manager: &mut Resourcemanager = borrow_resource_manager!(self.xrdao_address);
@@ -308,11 +313,14 @@ blueprint! {
308313
}
309314

310315
// Buy xrdao-xrd liquidity and deposit LP tokens to vault in this component
316+
317+
// make sure no dangeling resources or leftovers
311318
fn buy_xrdao_lp(&mut self, xrd_tokens: Bucket) -> () {
312319
let radiswap: Radiswap = self.xrdao_radiswap_component.into();
313320
let half = xrd_tokens.take(xrd_tokens.amount()/dec!("2"));
314321
let (xrdao_tokens, swap_remainder) = radiswap.swap(half);
315322
self.collected_xrd_fees.put(swap_remainder); // put any remainder back in vault
323+
//verify what resource remainder is to put in correct vault ******************************
316324
let (lp_tokens, lp_remainder) = radiswap.add_liquidity(xrd_tokens.empty(), xrdao_tokens);
317325
self.lp_token_vault.put(lp_tokens);
318326
self.collected_xrd_fees.put(lp_remainder); // put any remainder back in vault

0 commit comments

Comments
 (0)