Skip to content

Commit

Permalink
feat: create airdrop vesting contract (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmatt authored Feb 27, 2024
1 parent aa5a824 commit 5436b53
Show file tree
Hide file tree
Showing 37 changed files with 3,031 additions and 1,077 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dist
node_modules/
yarn.lock
.vscode/
.idea/

contracts/*/.editorconfig
packages/*/.editorconfig
Expand Down
78 changes: 5 additions & 73 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 95 additions & 19 deletions Cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,13 @@ This contract implements vesting accounts for the CW20 and native tokens.
There's no instantiation message.

```javascript
{}
{
}
```

### 3.2 Execute

- **Receive**
- **Receive**

```javascript
{
Expand Down Expand Up @@ -340,7 +341,8 @@ This smart contract showcases usage examples for certain Nibiru-specific and Cos
There's no instantiation message.

```javascript
{}
{
}
```

### 4.2 Execute
Expand All @@ -356,33 +358,33 @@ There's no instantiation message.
- **Mint** mints tokens

```javascript
{
"mint": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"mint_to": "[mint-to-addr]"
}
{
"mint": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"mint_to": "[mint-to-addr]"
}
}
```

- **Burn** burns tokens

```javascript
{
"burn": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"burn_from": "[burn-from-addr]"
}
{
"burn": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"burn_from": "[burn-from-addr]"
}
}
```

- **ChangeAdmin** changes the admin of a denom

```javascript
{
"change_admin": {
"denom": "tf/[contract-addr]/[subdenom]",
"new_admin": "[ADDR]"
}
{
"change_admin": {
"denom": "tf/[contract-addr]/[subdenom]",
"new_admin": "[ADDR]"
}
}
```

Expand All @@ -399,6 +401,7 @@ The instantiation defines the owner of the contract, who will be able to add and
"admin": "cosmos1...",
}
```

### 5.2 Execute

- **MarketOrder** places a market order for a specified trading pair. `pair` indicates the trading pair, `is_long` determines if it's a long or short order, `quote_amount` is the amount in the quote currency, `leverage` specifies the leverage to apply, and `base_amount_limit` sets a limit for the amount in the base currency.
Expand Down Expand Up @@ -540,7 +543,6 @@ The owner is the only one who can execute messages in the contract
### 6.3 Query
- **Mintable** queries the amount of μNUSD that can be minted in exchange for the specified set of `from_coins`.
```javascript
Expand Down Expand Up @@ -579,3 +581,77 @@ The owner is the only one who can execute messages in the contract
}
}
```
## 7. Airdrop token vesting
This contract implements vesting accounts for the native tokens.
### 7.1 Instantiate
We need to specify admin and managers
```javascript
{
"admin": "cosmos1...",
"managers": ["cosmos1...", "cosmos1..."]
}
```
### 7.2 Execute
- **RewardUsers** registers several vesting contracts
```javascript
{
"reward_users": {
"rewards": [
{
"user_address": "cosmos1...",
"vesting_amount": "1000000",
"cliff_amount": "100000", // Only needed if vesting schedule is linear with cliff
}
],
"vesting_schedule": {
"linear_vesting": {
"start_time": "1703772805",
"end_time": "1703872805",
"vesting_amount": "0" // This amount does not matter
}
}
}
}
```
- **DeregisterVestingAccount** deregisters a vesting account
```javascript
{
"deregister_vesting_account": {
"address": "cosmos1...",
"vested_token_recipient": "cosmos1...", // address that will receive the vested tokens after deregistration. If None, tokens are received by the owner address.
"left_vested_token_recipient": "cosmos1...", // address that will receive the left vesting tokens after deregistration.
}
}
```
- **Claim** allows to claim vested tokens
```javascript
{
"claim": {
"recipient": "cosmos1...",
}
}
```
### 7.3 Query
- **VestingAccount** returns the vesting account details for a given address.
```javascript
{
"vesting_account": {
"address": "cosmos1...",
}
}
```
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Smart contract sandbox for Nibiru Chain.
└── 📂 core-shifter # Calls peg shift and depth shift in x/perp.
└── 📂 core-controller # Calls other admin calls from Nibiru foundation.
└── 📂 core-token-vesting # Token linear vesting contracts with optional cliffs.
└── 📂 airdrop-token-vesting # Token linear vesting contracts with optional cliffs but handled for airdrop.
├── 📂 nibiru-std # Nibiru Chain standard library for smart contracts
└── 📦 proto # Types and traits for QueryRequest::Stargate and CosmosMsg::Stargate
└── # Includes constructors for Cosmos, IBC, and Nibiru.
Expand Down
Binary file added artifacts/airdrop_token_vesting.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
6e43956a6ae41e032b611529bbbd0112699f96a8126fc32b879cfe14521ad85f airdrop.wasm
79f5056138d9d0e4b25131ffb02aa5679d5242fe5ef2d9ae64299280645034cd airdrop_token_vesting.wasm
382c05baf544f2886de849933ecf59e8bc3bcdcdd552d5a63537bd6d63f2ecf1 controller.wasm
0ee6293c7ab257139d6b10abb31cafe7a6c00f3fbf2c8be126363f3c1e4e6d80 cw3_flex_multisig.wasm
515a13e891e6bf6a95ab985f653a45668c24991931fc664b64d5a0e803e4ab33 incentives.wasm
Expand Down
4 changes: 3 additions & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@


- [**pricefeed**](./pricefeed): Legacy implementation of the Nibiru Oracle Module in pure
CosmWasm rather than the Cosmos-SDK.
CosmWasm rather than the Cosmos-SDK.

- [**airdrop-token-vesting**](./airdrop-token-vesting/README.md)
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example schema"

12 changes: 12 additions & 0 deletions contracts/airdrop-token-vesting/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Build results
/target

# Text file backups
**/*.rs.bk

# macOS
.DS_Store

# IDEs
*.iml
.idea
Loading

0 comments on commit 5436b53

Please sign in to comment.