From a8eacc88a7b542408671f2a9a9e4e20c1db417ba Mon Sep 17 00:00:00 2001 From: Zaki Manian Date: Tue, 18 Jan 2022 11:21:10 +0100 Subject: [PATCH 1/2] Improved docs in the readme --- README.md | 59 ++++++- genesis.json | 489 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 544 insertions(+), 4 deletions(-) create mode 100644 genesis.json diff --git a/README.md b/README.md index a3f282c4..0d6059af 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,59 @@ The purpose of this repository is to develop and release a new set of staking, distrbution and slashing modules for the Cosmos Hub that are compatible with [cosmos-skd 0.43](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) and do not need to wait on cosmos-sdk 0.45 to included in a Gaia release and Cosmos hub Upgrade. -In scope are changes related to +## Liquid Staking design -- [liquid staking](https://liquidstaking.finance) -- key rotation for validators -- compounding rewards +This repo represents an opinated design for adding liquid staking to the Cosmos SDK. The + +There are a few core goals. + +1. Staked assets should be able to converted into liquid staked assets without unbonding. +2. The smallest change set possible on the existing staking, slashing and distrbution modules. +3. Assets are expected to be minimally fungible. Assets have a denom of "cosmosvaloperxxxx[recordId]". Record ID is a pointer to a non fungible asset that recieves the rewards from the tokenized stake. +4. Governance rights are bound to the validator. + + +## Typical user flow. + +1. Alice bonds 500 ATOM to iqlusion.io +2. Alice executes MsgTokenizeShares for the 500_000_000uatom and 500_000_000cosmosvaloper1xxxx42 in return. +3. Alice does an OTC deal with Bob for 250_000_000cosmosvaloper1xxxx42 assets. +4. Bob exectutes MsgRedeemTokensforShares for 250_000_000cosmosvaloper1xxxx42 which now becomes a delegation of 250atom to iqlusion. +5. While the shares were tokenized, TokenizedShareRecord 42 is recieving the full 500 atom of rewards minus iqlusion's commission. +6. Once Bob redeems his tokens for shares, now TokenizedShareRecord 42 will only recieve 250 atoms worth of rewards. +7. Alice can execute MsgWithdrawTokenizeShareRecordReward pass these rewards back to Alice's account. + +### Example Commands +```bash +liquidstakingd tx staking tokenize-share cosmosvaloper1qp49fdjtlsrv6jkx3gc8urp2ncg88s6mcversm 1000000stake cosmos1qp49fdjtlsrv6jkx3gc8urp2ncg88s6macdkug +liquidstakingd query distribution tokenize-share-record-rewards cosmos1qp49fdjtlsrv6jkx3gc8urp2ncg88s6macdkug +liquidstakingd tx distribution withdraw-tokenize-share-reward + +``` + + + +## Hypothetical user flow with refungiblization + +This flow requires an itegration with CosmWasm that is not part of this repo at this time. + +1. Alice bonds 500 ATOM to iqlusion.io +2. Alice executes MsgTokenizeShares for the 500_000_000uatom and 500_000_000cosmosvaloper1xxxx42 in return. +3. There is a staking DAO contract in cosmwasm that is will to accept tokenizedshares from iqlusion. +4. Alice excutes a multimsg sending 500_000_000cosmosvaloper1xxxx42 and MsgTransferTokenizeShareRecord to the address of the Staking DAO contract. +5. The Staking contract queries the state to see shares to atom ratio for iqlusion and the pending rewards in the share record. +6. Alice recieve 500_000_000ustatom from the staking dao contract. + + +### Testnet + + +Please join our testnet for Release 0.2. + + +[genesis.json](genesis.json) + + +``` +persistent_peers = "6aa0b269094af7e54fbfc1faa005845fe97269e4@34.124.241.85:26656,837a38ee4fdac1b0252f31eee9780ac74d685512@34.124.168.210:26656,dd0acaa93c4bae0be874cf52ae4487551756a1e0@35.240.151.206:26656" +``` \ No newline at end of file diff --git a/genesis.json b/genesis.json new file mode 100644 index 00000000..e86e37c5 --- /dev/null +++ b/genesis.json @@ -0,0 +1,489 @@ +{ + "genesis_time": "2022-01-17T09:52:53.910319Z", + "chain_id": "liquidstaking-2", + "initial_height": "1", + "consensus_params": { + "block": { + "max_bytes": "22020096", + "max_gas": "-1", + "time_iota_ms": "1000" + }, + "evidence": { + "max_age_num_blocks": "100000", + "max_age_duration": "172800000000000", + "max_bytes": "1048576" + }, + "validator": { + "pub_key_types": [ + "ed25519" + ] + }, + "version": {} + }, + "app_hash": "", + "app_state": { + "auth": { + "params": { + "max_memo_characters": "256", + "tx_sig_limit": "7", + "tx_size_cost_per_byte": "10", + "sig_verify_cost_ed25519": "590", + "sig_verify_cost_secp256k1": "1000" + }, + "accounts": [ + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "cosmos1yh60qk8lp0fz05zna43zjdmwj8y32wrh45nkwp", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "cosmos1sjq7jgd4r3al0875ysvpk3yw6c7250a73gzl0r", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "cosmos1jefsuvgwwt4pc0cntdwlzcjewckvdjrl6rp0k5", + "pub_key": null, + "account_number": "0", + "sequence": "0" + }, + { + "@type": "/cosmos.auth.v1beta1.BaseAccount", + "address": "cosmos186luay4vll7yv8w6z6amhxjczf4k5yzrl2lwym", + "pub_key": null, + "account_number": "0", + "sequence": "0" + } + ] + }, + "authz": { + "authorization": [] + }, + "bank": { + "params": { + "send_enabled": [], + "default_send_enabled": true + }, + "balances": [ + { + "address": "cosmos1yh60qk8lp0fz05zna43zjdmwj8y32wrh45nkwp", + "coins": [ + { + "denom": "stake", + "amount": "500000000" + }, + { + "denom": "testtoken", + "amount": "1000000000" + } + ] + }, + { + "address": "cosmos186luay4vll7yv8w6z6amhxjczf4k5yzrl2lwym", + "coins": [ + { + "denom": "stake", + "amount": "500000000" + }, + { + "denom": "testtoken", + "amount": "1000000000" + } + ] + }, + { + "address": "cosmos1sjq7jgd4r3al0875ysvpk3yw6c7250a73gzl0r", + "coins": [ + { + "denom": "stake", + "amount": "500000000" + }, + { + "denom": "testtoken", + "amount": "1000000000" + } + ] + }, + { + "address": "cosmos1jefsuvgwwt4pc0cntdwlzcjewckvdjrl6rp0k5", + "coins": [ + { + "denom": "stake", + "amount": "500000000" + }, + { + "denom": "testtoken", + "amount": "1000000000" + } + ] + } + ], + "supply": [ + { + "denom": "stake", + "amount": "2000000000" + }, + { + "denom": "testtoken", + "amount": "4000000000" + } + ], + "denom_metadata": [] + }, + "capability": { + "index": "1", + "owners": [] + }, + "crisis": { + "constant_fee": { + "denom": "stake", + "amount": "1000" + } + }, + "distribution": { + "params": { + "community_tax": "0.020000000000000000", + "base_proposer_reward": "0.010000000000000000", + "bonus_proposer_reward": "0.040000000000000000", + "withdraw_addr_enabled": true + }, + "fee_pool": { + "community_pool": [] + }, + "delegator_withdraw_infos": [], + "previous_proposer": "", + "outstanding_rewards": [], + "validator_accumulated_commissions": [], + "validator_historical_rewards": [], + "validator_current_rewards": [], + "delegator_starting_infos": [], + "validator_slash_events": [] + }, + "evidence": { + "evidence": [] + }, + "feegrant": { + "allowances": [] + }, + "genutil": { + "gen_txs": [ + { + "body": { + "messages": [ + { + "@type": "/liquidstaking.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "node0", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "1.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "1.000000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos1yh60qk8lp0fz05zna43zjdmwj8y32wrh45nkwp", + "validator_address": "cosmosvaloper1yh60qk8lp0fz05zna43zjdmwj8y32wrhsq8rzj", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "6miVuR8/SNIlp6TFmcZi2xCk6vgbZI/6G9GXEvax7GY=" + }, + "value": { + "denom": "stake", + "amount": "100000000" + } + } + ], + "memo": "7b64f5a07e4fc8122ab994be5a61663a1fbefe62@34.124.192.98:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "AvLdjrxVZMOyLcqo8E2ds5n7C5+mOOcNUrQR0p2vWZcH" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "0", + "payer": "", + "granter": "" + } + }, + "signatures": [ + "gnt5DZ1297T+6Uv1/ejlxemVT30wd8/cwj6s3UeJZalXUesoGeF+NEK1nkNAGfPFE/O/+yQ29TcQLgF7ewJ4yQ==" + ] + }, + { + "body": { + "messages": [ + { + "@type": "/liquidstaking.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "node1", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "1.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "1.000000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos1sjq7jgd4r3al0875ysvpk3yw6c7250a73gzl0r", + "validator_address": "cosmosvaloper1sjq7jgd4r3al0875ysvpk3yw6c7250a75uk2rs", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "E7g1tGNBj4QBvotPyJsrasf1F0w7tQ1irXo0L6IMZlM=" + }, + "value": { + "denom": "stake", + "amount": "100000000" + } + } + ], + "memo": "6aa0b269094af7e54fbfc1faa005845fe97269e4@34.124.241.85:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "A1AKeTAQsmfzJBXIBDZf6jBSOB5khHmoCM49/GhKG2cj" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "0", + "payer": "", + "granter": "" + } + }, + "signatures": [ + "UwVys3Tbf0wQmn5rnk3ZDIvRSQGFtBz98M2eQpQnRRpwbEtvC7uswMSDj9wR4QVUUS+FiBI+UmiTATJM0IpzlA==" + ] + }, + { + "body": { + "messages": [ + { + "@type": "/liquidstaking.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "node2", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "1.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "1.000000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos1jefsuvgwwt4pc0cntdwlzcjewckvdjrl6rp0k5", + "validator_address": "cosmosvaloper1jefsuvgwwt4pc0cntdwlzcjewckvdjrllh4668", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "uYMT+1iXe9SePknProQQ+ZuOfjEruG95LqmGSzxazps=" + }, + "value": { + "denom": "stake", + "amount": "100000000" + } + } + ], + "memo": "dd0acaa93c4bae0be874cf52ae4487551756a1e0@35.240.151.206:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "A5A72L8L6mnbx++ulQ+3EdLgsF8wCeg92oS6Ea7w7u8j" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "0", + "payer": "", + "granter": "" + } + }, + "signatures": [ + "UNcQVFlVe7e5zZWAZfD5pvkciSBNf1GHJhKIskwl3nQ0aOJlFlQ/QhfmEmBsvBLRd9zBGTl70pGJ0mdBB2jpiw==" + ] + }, + { + "body": { + "messages": [ + { + "@type": "/liquidstaking.staking.v1beta1.MsgCreateValidator", + "description": { + "moniker": "node3", + "identity": "", + "website": "", + "security_contact": "", + "details": "" + }, + "commission": { + "rate": "1.000000000000000000", + "max_rate": "1.000000000000000000", + "max_change_rate": "1.000000000000000000" + }, + "min_self_delegation": "1", + "delegator_address": "cosmos186luay4vll7yv8w6z6amhxjczf4k5yzrl2lwym", + "validator_address": "cosmosvaloper186luay4vll7yv8w6z6amhxjczf4k5yzr67tmgg", + "pubkey": { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "Pheho0Z/359h1LkJPBUzXI/MRBXMWXjUOoQnDWPuDRw=" + }, + "value": { + "denom": "stake", + "amount": "100000000" + } + } + ], + "memo": "837a38ee4fdac1b0252f31eee9780ac74d685512@34.124.168.210:26656", + "timeout_height": "0", + "extension_options": [], + "non_critical_extension_options": [] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Au0er3AECfwOCEwl4oy8jkOHFn6BkcByQ/TvRB6Kt2jv" + }, + "mode_info": { + "single": { + "mode": "SIGN_MODE_DIRECT" + } + }, + "sequence": "0" + } + ], + "fee": { + "amount": [], + "gas_limit": "0", + "payer": "", + "granter": "" + } + }, + "signatures": [ + "vHGioqhCTi4Dr6fLWeQmRemkAZwP84cOkWi0oW6gJ9gNCa1jH5NInV5GwXKFH25orX5hytfd2E4dkyLVnafXkg==" + ] + } + ] + }, + "gov": { + "starting_proposal_id": "1", + "deposits": [], + "votes": [], + "proposals": [], + "deposit_params": { + "min_deposit": [ + { + "denom": "stake", + "amount": "10000000" + } + ], + "max_deposit_period": "172800s" + }, + "voting_params": { + "voting_period": "172800s" + }, + "tally_params": { + "quorum": "0.334000000000000000", + "threshold": "0.500000000000000000", + "veto_threshold": "0.334000000000000000" + } + }, + "mint": { + "minter": { + "inflation": "0.130000000000000000", + "annual_provisions": "0.000000000000000000" + }, + "params": { + "mint_denom": "stake", + "inflation_rate_change": "0.130000000000000000", + "inflation_max": "0.200000000000000000", + "inflation_min": "0.070000000000000000", + "goal_bonded": "0.670000000000000000", + "blocks_per_year": "6311520" + } + }, + "params": null, + "slashing": { + "params": { + "signed_blocks_window": "100", + "min_signed_per_window": "0.500000000000000000", + "downtime_jail_duration": "600s", + "slash_fraction_double_sign": "0.050000000000000000", + "slash_fraction_downtime": "0.010000000000000000" + }, + "signing_infos": [], + "missed_blocks": [] + }, + "staking": { + "params": { + "unbonding_time": "1814400s", + "max_validators": 100, + "max_entries": 7, + "historical_entries": 10000, + "bond_denom": "stake" + }, + "last_total_power": "0", + "last_validator_powers": [], + "validators": [], + "delegations": [], + "unbonding_delegations": [], + "redelegations": [], + "exported": false + }, + "upgrade": {}, + "vesting": {} + } +} \ No newline at end of file From 41a33982d0f0d9cc8572f24abed2477e3df234a6 Mon Sep 17 00:00:00 2001 From: junkai121 Date: Tue, 18 Jan 2022 21:28:11 +1000 Subject: [PATCH 2/2] add redeem tokens command --- README.md | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 0d6059af..16dd2f02 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # liquidity-staking-module - -The purpose of this repository is to develop and release a new set of staking, distrbution and slashing modules for the Cosmos Hub that are compatible with [cosmos-skd 0.43](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) and do not need to wait on cosmos-sdk 0.45 to included in a Gaia release and Cosmos hub Upgrade. +The purpose of this repository is to develop and release a new set of staking, distrbution and slashing modules for the Cosmos Hub that are compatible with [cosmos-skd 0.43](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.43.0) and do not need to wait on cosmos-sdk 0.45 to included in a Gaia release and Cosmos hub Upgrade. ## Liquid Staking design @@ -14,48 +13,42 @@ There are a few core goals. 3. Assets are expected to be minimally fungible. Assets have a denom of "cosmosvaloperxxxx[recordId]". Record ID is a pointer to a non fungible asset that recieves the rewards from the tokenized stake. 4. Governance rights are bound to the validator. - ## Typical user flow. 1. Alice bonds 500 ATOM to iqlusion.io 2. Alice executes MsgTokenizeShares for the 500_000_000uatom and 500_000_000cosmosvaloper1xxxx42 in return. -3. Alice does an OTC deal with Bob for 250_000_000cosmosvaloper1xxxx42 assets. +3. Alice does an OTC deal with Bob for 250_000_000cosmosvaloper1xxxx42 assets. 4. Bob exectutes MsgRedeemTokensforShares for 250_000_000cosmosvaloper1xxxx42 which now becomes a delegation of 250atom to iqlusion. 5. While the shares were tokenized, TokenizedShareRecord 42 is recieving the full 500 atom of rewards minus iqlusion's commission. 6. Once Bob redeems his tokens for shares, now TokenizedShareRecord 42 will only recieve 250 atoms worth of rewards. 7. Alice can execute MsgWithdrawTokenizeShareRecordReward pass these rewards back to Alice's account. ### Example Commands + ```bash liquidstakingd tx staking tokenize-share cosmosvaloper1qp49fdjtlsrv6jkx3gc8urp2ncg88s6mcversm 1000000stake cosmos1qp49fdjtlsrv6jkx3gc8urp2ncg88s6macdkug liquidstakingd query distribution tokenize-share-record-rewards cosmos1qp49fdjtlsrv6jkx3gc8urp2ncg88s6macdkug liquidstakingd tx distribution withdraw-tokenize-share-reward - +liquidstakingd tx staking redeem-tokens 1000cosmosvaloper14tlxr8mcr3rg9mjp8d96f9na0v6mjtjlqnksqy1 ``` - - ## Hypothetical user flow with refungiblization This flow requires an itegration with CosmWasm that is not part of this repo at this time. -1. Alice bonds 500 ATOM to iqlusion.io +1. Alice bonds 500 ATOM to iqlusion.io 2. Alice executes MsgTokenizeShares for the 500_000_000uatom and 500_000_000cosmosvaloper1xxxx42 in return. 3. There is a staking DAO contract in cosmwasm that is will to accept tokenizedshares from iqlusion. 4. Alice excutes a multimsg sending 500_000_000cosmosvaloper1xxxx42 and MsgTransferTokenizeShareRecord to the address of the Staking DAO contract. 5. The Staking contract queries the state to see shares to atom ratio for iqlusion and the pending rewards in the share record. 6. Alice recieve 500_000_000ustatom from the staking dao contract. - -### Testnet - +### Testnet Please join our testnet for Release 0.2. - [genesis.json](genesis.json) - ``` persistent_peers = "6aa0b269094af7e54fbfc1faa005845fe97269e4@34.124.241.85:26656,837a38ee4fdac1b0252f31eee9780ac74d685512@34.124.168.210:26656,dd0acaa93c4bae0be874cf52ae4487551756a1e0@35.240.151.206:26656" -``` \ No newline at end of file +```