-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from comdex-official/remove-t34
Remove t3-4
- Loading branch information
Showing
17 changed files
with
1,177 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cosmywasmy.chainConfigName": "comdex" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,27 @@ | ||
# CosmWasm Starter Pack | ||
# Locking Contract | ||
|
||
This is a template to build smart contracts in Rust to run inside a | ||
[Cosmos SDK](https://github.com/cosmos/cosmos-sdk) module on all chains that enable it. | ||
To understand the framework better, please read the overview in the | ||
[cosmwasm repo](https://github.com/CosmWasm/cosmwasm/blob/master/README.md), | ||
and dig into the [cosmwasm docs](https://www.cosmwasm.com). | ||
This assumes you understand the theory and just want to get coding. | ||
The locking-contract encloses the core functionality for locking governance tokens | ||
for a different locking period generating ve representation of locked tokens in an nft. | ||
The contract also holds the key logic to handle token emission and its distribution. | ||
|
||
## Creating a new repo from template | ||
## Documentation | ||
|
||
Assuming you have a recent version of rust and cargo (v1.58.1+) installed | ||
(via [rustup](https://rustup.rs/)), | ||
then the following should get you a new repo to start a contract: | ||
For an overview of the locking contract, click [here](/docs/OVERVIEW.md). | ||
Documentation of the [instantiate](/docs/INSTANTIATE.md), [execute](/docs/EXECUTE.md) and | ||
[query](/docs/QUERY.md) messages are available in `docs/` folder. | ||
|
||
Install [cargo-generate](https://github.com/ashleygwilliams/cargo-generate) and cargo-run-script. | ||
Unless you did that before, run this line now: | ||
## Compilation | ||
|
||
```sh | ||
cargo install cargo-generate --features vendored-openssl | ||
cargo install cargo-run-script | ||
``` | ||
|
||
Now, use it to create your new contract. | ||
Go to the folder in which you want to place it and run: | ||
|
||
|
||
**Latest: 1.0.0** | ||
|
||
```sh | ||
cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME | ||
```` | ||
|
||
For cloning minimal code repo: | ||
For compiling, you may use the following commands, with the latter | ||
generating a much more optimized wasm file (though it does require docker). | ||
|
||
```sh | ||
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 1.0-minimal --name PROJECT_NAME | ||
RUSTFLAGS='-C link-arg=-s' cargo wasm | ||
``` | ||
|
||
**Older Version** | ||
|
||
Pass version as branch flag: | ||
|
||
```sh | ||
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch <version> --name PROJECT_NAME | ||
```` | ||
Example: | ||
```sh | ||
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 0.16 --name PROJECT_NAME | ||
``` | ||
|
||
You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else) | ||
containing a simple working contract and build system that you can customize. | ||
|
||
## Create a Repo | ||
|
||
After generating, you have a initialized local git repo, but no commits, and no remote. | ||
Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below). | ||
Then run the following: | ||
|
||
```sh | ||
# this is needed to create a valid Cargo.lock file (see below) | ||
cargo check | ||
git branch -M main | ||
git add . | ||
git commit -m 'Initial Commit' | ||
git remote add origin YOUR-GIT-URL | ||
git push -u origin main | ||
``` | ||
|
||
## CI Support | ||
|
||
We have template configurations for both [GitHub Actions](.github/workflows/Basic.yml) | ||
and [Circle CI](.circleci/config.yml) in the generated project, so you can | ||
get up and running with CI right away. | ||
|
||
One note is that the CI runs all `cargo` commands | ||
with `--locked` to ensure it uses the exact same versions as you have locally. This also means | ||
you must have an up-to-date `Cargo.lock` file, which is not auto-generated. | ||
The first time you set up the project (or after adding any dep), you should ensure the | ||
`Cargo.lock` file is updated, so the CI will test properly. This can be done simply by | ||
running `cargo check` or `cargo unit-test`. | ||
|
||
## Using your project | ||
|
||
Once you have your custom repo, you should check out [Developing](./Developing.md) to explain | ||
more on how to run tests and develop code. Or go through the | ||
[online tutorial](https://docs.cosmwasm.com/) to get a better feel | ||
of how to develop. | ||
|
||
[Publishing](./Publishing.md) contains useful information on how to publish your contract | ||
to the world, once you are ready to deploy it on a running blockchain. And | ||
[Importing](./Importing.md) contains information about pulling in other contracts or crates | ||
that have been published. | ||
|
||
Please replace this README file with information about your specific project. You can keep | ||
the `Developing.md` and `Publishing.md` files as useful referenced, but please set some | ||
proper description in the README. | ||
docker run --rm -v "$(pwd)":/code \ | ||
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \ | ||
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \ | ||
cosmwasm/rust-optimizer:0.12.6 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
# Execute Operations | ||
|
||
The following execute operations are available: | ||
|
||
1. Lock | ||
2. Withdraw | ||
3. Transfer | ||
4. VoteProposal | ||
5. RaiseProposal | ||
6. ClaimReward | ||
7. Bribe | ||
8. Emission | ||
9. Rebase | ||
10. FoundationRewards | ||
|
||
## Lock | ||
|
||
```rust | ||
Lock { | ||
app_id: u64, | ||
locking_period: LockingPeriod, | ||
recipient: Option<Addr>, | ||
} | ||
``` | ||
|
||
Allows locking funds sent along with the execute message. The funds will be | ||
locked for the specified locking period and optionally for the specified user. | ||
|
||
* `app_id` - Unique application ID. | ||
* `locking_period` - Choice of locking period for locking funds. | ||
* `recipient` - Optionally set the owner of the locked funds. If not specified, | ||
then the tokens will be locked for the user that initiated the transaction. | ||
|
||
## Withdraw | ||
|
||
```rust | ||
Withdraw { | ||
denom: String, | ||
} | ||
``` | ||
|
||
Any tokens for the specified denomination may be withdrawn, if the tokens | ||
have unlocked, i.e. competed their locking period. | ||
|
||
* `denom` - Token denomination that is to be withdrawn. | ||
|
||
## Transfer | ||
|
||
```rust | ||
Transfer { | ||
recipient: String, | ||
locking_period: LockingPeriod, | ||
denom: String, | ||
} | ||
``` | ||
|
||
Any locked/unlocked (unlocked tokens that haven't been withdrawn) tokens may be | ||
transferred to another user. Transferring locked tokens will only be withdrawable | ||
when the locking period for the tokens has been completed. | ||
|
||
* `recipient` - Address of the recipient. | ||
* `locking_period` - Tokens with the specified locking period will be transferred. | ||
* `denom` - Token denomination that needs to be transferred. | ||
|
||
## Vote Proposal | ||
|
||
```rust | ||
VoteProposal { | ||
app_id: u64, | ||
proposal_id: u64, | ||
extended_pair: u64, | ||
} | ||
``` | ||
|
||
Any user with vtokens may vote on an active proposal for a specific extended pair. | ||
|
||
* `app_id` - Unique application ID. | ||
* `proposal_id` - Unique proposal ID of an active proposal. | ||
* `extended_pair` - Unique ID of the extended pair to vote. | ||
|
||
## Bribe | ||
|
||
```rust | ||
Bribe { | ||
proposal_id: u64, | ||
extended_pair: u64, | ||
} | ||
``` | ||
|
||
Incentivise users to vote for a specific extended pair, by providing them external incentives the said pair. | ||
|
||
* `proposal_id` - Unique proposal ID of an active proposal. | ||
* `extended_pair` - Unique ID of the extended pair to bribe. | ||
|
||
## Claim Rewards | ||
|
||
```rust | ||
ClaimReward { | ||
app_id: u64, | ||
} | ||
``` | ||
|
||
vtoken holders are eligible for surplus funds received from the protocol. Whereas, | ||
voters receive proportional bribe for the extended pair they voted upon. | ||
ClaimReward facilitates a user to claim rewards for previous proposals as well, if they have not been claimed. | ||
|
||
* `app_id` - Unique application ID. | ||
|
||
## Rebase | ||
|
||
```rust | ||
Rebase { | ||
proposal_id: u64, | ||
}, | ||
``` | ||
|
||
vtoken holders are incentivised with more vtoken to avoid their voting power dilution. Each vtoken holder is rebased to their proportional individual vtoken holding. | ||
|
||
* `proposal_id` - Unique proposal ID for which to rebase. | ||
|
||
## Raise Proposal | ||
|
||
```rust | ||
RaiseProposal { | ||
app_id: u64, | ||
} | ||
``` | ||
|
||
An admin is allowed to raise a new proposal for the specific application. Furthermore, only a single proposal may be active at any given moment. Any new | ||
proposal will not be raised until the previously active proposal has been | ||
completed. | ||
|
||
* `app_id` - Unique application ID. | ||
|
||
## Emission | ||
|
||
```rust | ||
Emission { | ||
proposal_id: u64, | ||
} | ||
``` | ||
|
||
It is a process in which a certain amount of the token (governance token for the app) will be minted after every proposal (epoch). The Emission distribution is computed as: | ||
|
||
* **Emission distribution:** They are distributed to vault owners based on the share of votes received for their respective vault pair id. | ||
|
||
rewards_pending*(emission_rate)*(1-total_vtoken/circulating_supply)*(1-foundation_percentage) | ||
|
||
* **Foundation distribution:** They are distributed to foundation_addr equally. | ||
|
||
Rebase distribution: rewards_pending*(emission_rate)*(total_vtoken/circulating_supply) | ||
|
||
**NOTE:** Only the admin is allowed to execute this transaction. | ||
|
||
* `proposal_id` - Unique proposal ID for which to calculate the emission. | ||
|
||
## Foundation Rewards | ||
|
||
```rust | ||
FoundationRewards { | ||
proposal_id: u64, | ||
}, | ||
``` | ||
|
||
This triggers the foundation reward disbursal once the Emission calculation has completed. | ||
|
||
**NOTE:** Only the admin is allowed to execute this transaction. | ||
|
||
* `proposal_id` - Unique proposal ID for which to distribute the emission. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Instantiate Operation | ||
|
||
```rust | ||
InstantiateMsg { | ||
pub t1: PeriodWeight, | ||
pub t2: PeriodWeight, | ||
pub voting_period: u64, | ||
pub vesting_contract: Addr, | ||
pub foundation_addr: Vec<String>, | ||
pub foundation_percentage: Decimal, | ||
pub surplus_asset_id: u64, | ||
pub emission: Emission, | ||
pub admin: Addr, | ||
pub min_lock_amount: Uint128, | ||
} | ||
``` | ||
|
||
Instatiates a new instance of this contract with the following details. Here, | ||
t1 and t2 represent two locking periods that may be used to lock sent tokens | ||
in return for *vtokens*. | ||
|
||
* `t1`--`t2` - specifies the duration (in seconds) and weight (in decimals) of each time period. | ||
* `voting_period` - Proposal voting period. | ||
* `vesting_contract` - Address of the vesting contract on chain. | ||
* `foundation_addr` - An array of addresses of foundation wallets. | ||
* `foundation_percentage` - Percentage of emission transferred to foundation. | ||
* `surplus_asset_id` - | ||
* `emission` - | ||
* `admin` - Address of the admin. | ||
* `min_lock_amount` - Minimum amount of tokens that need to be locked. | ||
|
||
```json | ||
{ | ||
"t1": { | ||
"period":0, | ||
"weight":0, | ||
}, | ||
"t2": { | ||
"period":0, | ||
"weight":0, | ||
}, | ||
"voting_period":0, | ||
"vesting_contract":"", | ||
"foundation_addr":[], | ||
"foundation_percentage":0, | ||
"surplus_asset_id":0, | ||
"emission": { | ||
"app_id":0, | ||
"distributed_rewards":0, | ||
"emission_rate":0, | ||
"rewards_pending":0, | ||
"total_rewards":0 | ||
}, | ||
"admin":"", | ||
"min_lock_amount":0 | ||
} | ||
``` |
Oops, something went wrong.