Skip to content

Commit

Permalink
refactor(token-vesting): rename airdrop-token-vesting to core-token-v…
Browse files Browse the repository at this point in the history
…esting-v2 (#133)

* refactor(token-vesting): rename airdrop-token-vesting to core-token-vesting-v2

* refactor: run tidy-update
  • Loading branch information
k-yang authored Mar 8, 2024
1 parent 753f118 commit 74450b0
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 56 deletions.
48 changes: 24 additions & 24 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +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.
└── 📂 core-token-vesting-v2 # Improved version of core-token-vesting-v2.
├── 📂 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 All @@ -38,4 +38,4 @@ cargo install just

You can view the list of available development commands with `just -ls`.

Ref: [github.com/casey/just](https://github.com/casey/just)
Ref: [github.com/casey/just](https://github.com/casey/just)
Binary file removed artifacts/airdrop_token_vesting.wasm
Binary file not shown.
2 changes: 0 additions & 2 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
f684c6daf9e77d2f7cb14e70f87e6f10cd97cd02d163f71ab4e2f6f823abfc8a airdrop_token_vesting.wasm
382c05baf544f2886de849933ecf59e8bc3bcdcdd552d5a63537bd6d63f2ecf1 controller.wasm
b56a880d4c67d9f353f549b502256f73159f89b50aa6dae683948e117efa4792 cw3_flex_multisig.wasm
1ecff403bbf3b5fcedccb5de76a0ef5f1fdbcc5f60890e3388f5425584899f0b incentives.wasm
Expand All @@ -8,4 +7,3 @@ ef5b4de76526713e3531c3b9bbc4620b5d61599c4a0e8605365ebb0f1d7ee2ac nibi_stargate_
0074489ff40c8ecbd766f7140b32d288dcaf7302ba630d452f79e7d292ea57ef nusd_valuator.wasm
955592d08017aa41f3c9ba3883153d6de024e8c7a3a79aa3b664a241ec1e7a19 pricefeed.wasm
354fdeff1386394d7aa829358323f89bde548d4aa782bae4a16dddfe33dad739 shifter.wasm
8d982ca2d679ea8d44f825fe91a3d4e0cb92150b12e4684497eee9e76991d247 token_vesting.wasm
7 changes: 3 additions & 4 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
- [**core-controller**](./core-controller): Admin calls for things like creating
perp markets or changing oracle parameters.

## Example Contracts
## Example Contracts

- [**nibi-stargate**](./nibi-stargate/README.md): Example smart contract that showcases how to use the Nibiru standard (nibiru-std) library to execute `CosmosMsg::Stargate` transactions for the token factory module.

## Utility Contracts

- **lockup**: Smart contract that enables users to lock or bond tokens for arbitrary durations. This contract can be used as a building block in combination with a contract like `incentives` to implement liquidity mining incentives or other yield mechanisms.
- **lockup**: Smart contract that enables users to lock or bond tokens for arbitrary durations. This contract can be used as a building block in combination with a contract like `incentives` to implement liquidity mining incentives or other yield mechanisms.

- **incentives**: Smart contract for funding lockups based with tokens.


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

- [**airdrop-token-vesting**](./airdrop-token-vesting/README.md)
- [**core-token-vesting-v2**](./core-token-vesting-v2/README.md)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "airdrop-token-vesting"
version = "0.2.0"
name = "core-token-vesting-v2"
version = "2.0.0"
edition = "2021"
description = "Airdrop token vesting contract"
description = "Token vesting contract v2"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ Admin and managers are defined at the instantiation of the contracts. Both can
reward users and de-register vesting accounts, but only the admin can withdraw
the unallocated amount from the contract.

- [Master Operations](#master-operations)
- [By admin and managers](#by-admin-and-managers)
- [By admin only](#by-admin-only)
- [Vesting Account Operations](#vesting-account-operations)
- [Deployed Contract Info](#deployed-contract-info)
- [Token Vesting](#token-vesting)
- [Master Operations](#master-operations)
- [By admin and managers](#by-admin-and-managers)
- [By admin only](#by-admin-only)
- [Vesting Account Operations](#vesting-account-operations)
- [Deployed Contract Info](#deployed-contract-info)
- [Testing Against a Live Chain](#testing-against-a-live-chain)

### Master Operations

Expand Down Expand Up @@ -83,7 +85,7 @@ TODO for mainnet/testnet
### Testing Against a Live Chain

You can test this smart contract on a live chain with the following script. It
requires `nibid` version 1 or 2.
requires `nibid` version 1 or 2.

```bash
WALLET=devnet_wallet
Expand Down Expand Up @@ -189,4 +191,4 @@ cat << EOF | jq '.' | tee withdraw.json
EOF
JSON_DATA="$(<withdraw.json)"
nibid tx wasm execute $CONTRACT_ADDRESS "$JSON_DATA" --from $MANAGER_WALLET "${TX_FLAG[@]}"
```
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::env::current_dir;
use std::fs::create_dir_all;

use airdrop_token_vesting::msg::{
use core_token_vesting_v2::msg::{
ExecuteMsg, InstantiateMsg, QueryMsg, VestingAccountResponse,
};
use cosmwasm_schema::{export_schema, remove_schemas, schema_for};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,11 @@ fn reward_users(
let total_requested: Uint128 =
rewards.iter().map(|req| req.vesting_amount).sum();
if total_requested > unallocated_amount {
return Err(
StdError::generic_err("Insufficient funds for all rewards").into()
);
return Err(StdError::generic_err(format!(
"Insufficient funds for all rewards. Have {} but want {}",
unallocated_amount, total_requested
))
.into());
}
vesting_schedule.validate()?;

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,10 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult {
&env,
mock_info("addr0000", &[Coin::new(1000u128, "uusd")]),
msg,
ContractError::Vesting(
VestingError::ExcessiveAmount {
cliff_amount,
vesting_amount,
}
.into(),
),
ContractError::Vesting(VestingError::ExcessiveAmount {
cliff_amount,
vesting_amount,
}),
);

// deposit amount higher than unallocated
Expand All @@ -337,7 +334,10 @@ fn register_cliff_vesting_account_with_native_token() -> TestResult {
&env,
mock_info("addr0000", &[Coin::new(999u128, "uusd")]),
msg,
StdError::generic_err("Insufficient funds for all rewards").into(),
StdError::generic_err(
"Insufficient funds for all rewards. Have 2000 but want 10000",
)
.into(),
);

// valid amount
Expand Down Expand Up @@ -597,7 +597,10 @@ fn register_vesting_account_with_native_token() -> TestResult {
let res = execute(deps.as_mut(), env.clone(), info, msg.clone());
match res {
Err(ContractError::Std(StdError::GenericErr { msg, .. })) => {
assert_eq!(msg, "Insufficient funds for all rewards")
assert_eq!(
msg,
"Insufficient funds for all rewards. Have 1000 but want 1000001"
)
}
_ => panic!("should not enter. got result: {res:?}"),
}
Expand Down Expand Up @@ -626,7 +629,10 @@ fn register_vesting_account_with_native_token() -> TestResult {
let res = execute(deps.as_mut(), env.clone(), info, msg.clone());
match res {
Err(ContractError::Std(StdError::GenericErr { msg, .. })) => {
assert_eq!(msg, "Insufficient funds for all rewards")
assert_eq!(
msg,
"Insufficient funds for all rewards. Have 1000 but want 1001"
)
}
_ => panic!("should not enter. got result: {res:?}"),
}
Expand Down

0 comments on commit 74450b0

Please sign in to comment.