Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contracts): create airdrop vesting contract with manager list #124

Merged
merged 24 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
fc5da15
feat: create airdrop vesting contract
matthiasmatt Feb 22, 2024
a69712e
fix: update cookbook
matthiasmatt Feb 22, 2024
182af7d
fix: remove airdrop contract
matthiasmatt Feb 22, 2024
6f2eb7a
feat: add more test coverage
matthiasmatt Feb 22, 2024
5e2cff4
fix: update schema
matthiasmatt Feb 22, 2024
182cea9
feat: add withdraw message
matthiasmatt Feb 22, 2024
5a41b55
fix: fix cookbook
matthiasmatt Feb 23, 2024
c869043
Merge branch 'mat/airdrop-vesting' of github.com:NibiruChain/cw-nibir…
jgimeno Feb 23, 2024
90987c1
fix: make check on instantiation earlier
matthiasmatt Feb 23, 2024
ec8fab9
add comment for some method
jgimeno Feb 23, 2024
248b47f
Merge branch 'mat/airdrop-vesting' of github.com:NibiruChain/cw-nibir…
jgimeno Feb 23, 2024
d84972c
add another comment for validate time
jgimeno Feb 23, 2024
f641efb
add more comments
jgimeno Feb 23, 2024
c3371ae
add refactor
jgimeno Feb 23, 2024
63b13a1
clarify vesting contract code
jgimeno Feb 23, 2024
502efdb
update README for airdrop-token-vesting
jgimeno Feb 23, 2024
1c0668a
fix: remove cw20
matthiasmatt Feb 23, 2024
e0474f2
feat: remove master_address and denom
matthiasmatt Feb 23, 2024
c1846cc
fix: fix readme
matthiasmatt Feb 23, 2024
a770c8f
update readme
jgimeno Feb 26, 2024
b5fb8a6
remove clone
jgimeno Feb 26, 2024
e7a8f52
chore(deps): Cargo.lock update
Unique-Divine Feb 26, 2024
f79a77a
docs(airdrop-token-vesting): add testing script to README
Unique-Divine Feb 26, 2024
5781f19
feat: undo changes to query interface
matthiasmatt Feb 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.

117 changes: 98 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
{}
{
}
Comment on lines +263 to +264
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The instantiation message for the core token vesting contract is mentioned as not existing, which might be intentional to indicate that no specific parameters are required for instantiation. However, it's crucial to ensure that this is clearly communicated to avoid confusion. If instantiation does not require parameters, consider adding a brief explanation to clarify this to users.

{
+  "Note": "This contract does not require any parameters for instantiation."
}

Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
{
}
{
"Note": "This contract does not require any parameters for instantiation."
}

```

### 3.2 Execute

- **Receive**
- **Receive**
matthiasmatt marked this conversation as resolved.
Show resolved Hide resolved

```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,80 @@ The owner is the only one who can execute messages in the contract
}
}
```

## 7. Airdrop token vesting

This contract implements vesting accounts for the CW20 and 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": {
"master_address": "cosmos1...",
"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...",
"denom": "uusd",
"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": {
"denom": "uusd",
"recipient": "cosmos1...",
}
}
```

### 7.3 Query

- **VestingAccount** returns the vesting account details for a given address.

```javascript
{
"vesting_account": {
"address": "cosmos1...",
}
}
```
matthiasmatt marked this conversation as resolved.
Show resolved Hide resolved
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.
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
Loading