diff --git a/Cargo.lock b/Cargo.lock index b6f3a7d..adcdbd7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -37,22 +37,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "airdrop-token-vesting" -version = "0.2.0" -dependencies = [ - "anyhow", - "cosmwasm-schema", - "cosmwasm-std", - "cw-storage-plus", - "cw-utils", - "cw20", - "schemars", - "serde", - "serde_json", - "thiserror", -] - [[package]] name = "anstream" version = "0.6.13" @@ -248,9 +232,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.15.3" +version = "3.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ea184aa71bb362a1157c896979544cc23974e08fd265f29ea96b59f0b4a555b" +checksum = "7ff69b9dd49fd426c69a0db9fc04dd934cdb6645ff000864d98f7e2af8830eaa" [[package]] name = "bytecheck" @@ -288,9 +272,9 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cc" -version = "1.0.89" +version = "1.0.90" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0ba8f7aaa012f30d5b2861462f6708eccd49c3c39863fe083a308035f63d723" +checksum = "8cd6604a82acf3039f1144f54b8eb34e91ffba622051189e71b781822d5ee1f5" [[package]] name = "cfg-if" @@ -300,9 +284,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c918d541ef2913577a0f9566e9ce27cb35b6df072075769e0b26cb5a554520da" +checksum = "b230ab84b0ffdf890d5a10abdbc8b83ae1c4918275daea1ab8801f71536b2651" dependencies = [ "clap_builder", "clap_derive", @@ -310,9 +294,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.1" +version = "4.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f3e7391dad68afb0c2ede1bf619f579a3dc9c2ec67f089baa397123a2f3d1eb" +checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" dependencies = [ "anstream", "anstyle", @@ -385,6 +369,22 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" +[[package]] +name = "core-token-vesting-v2" +version = "2.0.0" +dependencies = [ + "anyhow", + "cosmwasm-schema", + "cosmwasm-std", + "cw-storage-plus", + "cw-utils", + "cw20", + "schemars", + "serde", + "serde_json", + "thiserror", +] + [[package]] name = "corosensei" version = "0.1.4" diff --git a/README.md b/README.md index 5c2bbd1..860fc14 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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) \ No newline at end of file +Ref: [github.com/casey/just](https://github.com/casey/just) diff --git a/artifacts/airdrop_token_vesting.wasm b/artifacts/airdrop_token_vesting.wasm deleted file mode 100644 index 9a25708..0000000 Binary files a/artifacts/airdrop_token_vesting.wasm and /dev/null differ diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 6cc9e4b..8e52fac 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1,4 +1,3 @@ -f684c6daf9e77d2f7cb14e70f87e6f10cd97cd02d163f71ab4e2f6f823abfc8a airdrop_token_vesting.wasm 382c05baf544f2886de849933ecf59e8bc3bcdcdd552d5a63537bd6d63f2ecf1 controller.wasm b56a880d4c67d9f353f549b502256f73159f89b50aa6dae683948e117efa4792 cw3_flex_multisig.wasm 1ecff403bbf3b5fcedccb5de76a0ef5f1fdbcc5f60890e3388f5425584899f0b incentives.wasm @@ -8,4 +7,3 @@ ef5b4de76526713e3531c3b9bbc4620b5d61599c4a0e8605365ebb0f1d7ee2ac nibi_stargate_ 0074489ff40c8ecbd766f7140b32d288dcaf7302ba630d452f79e7d292ea57ef nusd_valuator.wasm 955592d08017aa41f3c9ba3883153d6de024e8c7a3a79aa3b664a241ec1e7a19 pricefeed.wasm 354fdeff1386394d7aa829358323f89bde548d4aa782bae4a16dddfe33dad739 shifter.wasm -8d982ca2d679ea8d44f825fe91a3d4e0cb92150b12e4684497eee9e76991d247 token_vesting.wasm diff --git a/contracts/README.md b/contracts/README.md index 61e1fe3..5d75f50 100644 --- a/contracts/README.md +++ b/contracts/README.md @@ -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) \ No newline at end of file +- [**core-token-vesting-v2**](./core-token-vesting-v2/README.md) diff --git a/contracts/airdrop-token-vesting/.cargo/config b/contracts/core-token-vesting-v2/.cargo/config similarity index 100% rename from contracts/airdrop-token-vesting/.cargo/config rename to contracts/core-token-vesting-v2/.cargo/config diff --git a/contracts/airdrop-token-vesting/.gitignore b/contracts/core-token-vesting-v2/.gitignore similarity index 100% rename from contracts/airdrop-token-vesting/.gitignore rename to contracts/core-token-vesting-v2/.gitignore diff --git a/contracts/airdrop-token-vesting/Cargo.lock b/contracts/core-token-vesting-v2/Cargo.lock similarity index 100% rename from contracts/airdrop-token-vesting/Cargo.lock rename to contracts/core-token-vesting-v2/Cargo.lock diff --git a/contracts/airdrop-token-vesting/Cargo.toml b/contracts/core-token-vesting-v2/Cargo.toml similarity index 90% rename from contracts/airdrop-token-vesting/Cargo.toml rename to contracts/core-token-vesting-v2/Cargo.toml index 367f68a..02b11cb 100644 --- a/contracts/airdrop-token-vesting/Cargo.toml +++ b/contracts/core-token-vesting-v2/Cargo.toml @@ -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. diff --git a/contracts/airdrop-token-vesting/README.md b/contracts/core-token-vesting-v2/README.md similarity index 92% rename from contracts/airdrop-token-vesting/README.md rename to contracts/core-token-vesting-v2/README.md index 2a8030f..cb6bd3d 100644 --- a/contracts/airdrop-token-vesting/README.md +++ b/contracts/core-token-vesting-v2/README.md @@ -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 @@ -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 @@ -189,4 +191,4 @@ cat << EOF | jq '.' | tee withdraw.json EOF JSON_DATA="$( 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()?; diff --git a/contracts/airdrop-token-vesting/src/errors.rs b/contracts/core-token-vesting-v2/src/errors.rs similarity index 100% rename from contracts/airdrop-token-vesting/src/errors.rs rename to contracts/core-token-vesting-v2/src/errors.rs diff --git a/contracts/airdrop-token-vesting/src/lib.rs b/contracts/core-token-vesting-v2/src/lib.rs similarity index 100% rename from contracts/airdrop-token-vesting/src/lib.rs rename to contracts/core-token-vesting-v2/src/lib.rs diff --git a/contracts/airdrop-token-vesting/src/msg.rs b/contracts/core-token-vesting-v2/src/msg.rs similarity index 100% rename from contracts/airdrop-token-vesting/src/msg.rs rename to contracts/core-token-vesting-v2/src/msg.rs diff --git a/contracts/airdrop-token-vesting/src/state.rs b/contracts/core-token-vesting-v2/src/state.rs similarity index 100% rename from contracts/airdrop-token-vesting/src/state.rs rename to contracts/core-token-vesting-v2/src/state.rs diff --git a/contracts/airdrop-token-vesting/src/testing.rs b/contracts/core-token-vesting-v2/src/testing.rs similarity index 97% rename from contracts/airdrop-token-vesting/src/testing.rs rename to contracts/core-token-vesting-v2/src/testing.rs index 99dac73..64d27a7 100644 --- a/contracts/airdrop-token-vesting/src/testing.rs +++ b/contracts/core-token-vesting-v2/src/testing.rs @@ -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 @@ -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 @@ -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:?}"), } @@ -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:?}"), }