Skip to content

Commit

Permalink
feat: add core compounder contract (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasmatt authored Mar 22, 2024
1 parent 21dbc5c commit f546e89
Show file tree
Hide file tree
Showing 27 changed files with 1,965 additions and 185 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cosmwasm-std = { version = "1.5.0", features = ["stargate", "staking"] }
cosmwasm-schema = "1.5.0"
cw-storage-plus = { version = "1.2.0" }
cw-multi-test = { version = "0.20.0" }
cw-utils = { version = "1.0.2" }
cw-utils = { version = "1.0.3" }
# Macros for controlling ownership of CosmWasm smart contracts
cw-ownable = { version = "0.5.1"}

Expand All @@ -42,6 +42,7 @@ shifter = { path = "contracts/core-shifter" }
controller = { path = "contracts/core-controller" }
lockup = { path = "contracts/lockup", features = ["library"] }
incentives = { path = "contracts/incentives", features = ["library"] }
broker-bank = { path = "contracts/broker-bank", features = ["library"] }

# deps: else
anyhow = "1"
Expand Down
268 changes: 232 additions & 36 deletions Cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,35 @@
This file describes the different messages that can be sent as queries or transactions
to the contracts of this repository with a description of the expected behavior.

- [Core shifter](#core-shifter)
- [Instantiate](#instantiate)
- [Execute](#execute)
- [Query](#query)
- [Core token vesting](#core-token-vesting)
- [Instantiate](#instantiate-1)
- [Execute](#execute-1)
- [Query](#query-1)
- [4. Nibi Stargate](#4-nibi-stargate)
- [4.1 Instantiate](#41-instantiate)
- [4.2 Execute](#42-execute)
- [5. Nibi Stargate Perp](#5-nibi-stargate-perp)
- [5.1 Instantiate](#51-instantiate)
- [5.2 Execute](#52-execute)
- [6. Nusd Valuator](#6-nusd-valuator)
- [6.1 Instantiate](#61-instantiate)
- [6.2 Execute](#62-execute)
- [6.3 Query](#63-query)
- [Contracts Cookbook](#contracts-cookbook)
- [Core shifter](#core-shifter)
- [Instantiate](#instantiate)
- [Execute](#execute)
- [Query](#query)
- [Core token vesting](#core-token-vesting)
- [Instantiate](#instantiate-1)
- [Execute](#execute-1)
- [Query](#query-1)
- [4. Nibi Stargate](#4-nibi-stargate)
- [4.1 Instantiate](#41-instantiate)
- [4.2 Execute](#42-execute)
- [5. Nibi Stargate Perp](#5-nibi-stargate-perp)
- [5.1 Instantiate](#51-instantiate)
- [5.2 Execute](#52-execute)
- [6. Nusd Valuator](#6-nusd-valuator)
- [6.1 Instantiate](#61-instantiate)
- [6.2 Execute](#62-execute)
- [6.3 Query](#63-query)
- [7. Airdrop token vesting](#7-airdrop-token-vesting)
- [7.1 Instantiate](#71-instantiate)
- [7.2 Execute](#72-execute)
- [7.3 Query](#73-query)
- [8. Auto compounder](#8-auto-compounder)
- [8.1 Instantiate](#81-instantiate)
- [8.2 Execute](#82-execute)
- [Admin functions](#admin-functions)
- [Manager functions](#manager-functions)
- [8.3 Query](#83-query)

## Core shifter

Expand Down Expand Up @@ -101,7 +112,8 @@ This contract implements vesting accounts for the CW20 and native tokens.
There's no instantiation message.

```js
{}
{
}
```

### Execute
Expand Down Expand Up @@ -181,7 +193,8 @@ This smart contract showcases usage examples for certain Nibiru-specific and Cos
There's no instantiation message.

```js
{}
{
}
```

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

```js
{
"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

```js
{
"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

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

Expand Down Expand Up @@ -419,4 +432,187 @@ The owner is the only one who can execute messages in the contract
"redeem_amount": "1000000"
}
}
```
```
## 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...",
}
}
```
## 8. Auto compounder
This contract manages staking re-delegation processes securely, allowing for auto-compounding of staked funds.
### 8.1 Instantiate
We need to specify admin and managers
```javascript
{
"admin": "cosmos1...",
"managers": ["cosmos1...", "cosmos1..."]
}
```
### 8.2 Execute
#### Admin functions
- **SetAutoCompounderMode** sets the auto compounder mode
```javascript
{
"set_auto_compounder_mode": {
"mode": "true" // true or false
}
}
```
- **Withdraw** allows to withdraw the funds from the contract
```javascript
{
"withdraw": {
"amount": "1000000"
"recipient": "cosmos1..."
}
}
```
- **unstakes** allows to unstake the funds from the contract
```javascript
{
"unstake": {
"unstake_msgs": [
{
"validator": "cosmosvaloper1...",
"amount": "1000000"
},
{
"validator": "cosmosvaloper1...",
"amount": "1000000"
}
]
}
}
```
- **update managers** allows to update the managers of the contract
```javascript
{
"update_managers": {
"managers": ["cosmos1...", "cosmos1..."]
}
}
```
#### Manager functions
- **stake** allows to stake the funds from the contract. The shares are normalized
```javascript
{
"stake": {
"stake_msgs": [
{
"validator": "cosmosvaloper1...",
"share": "1000000"
},
{
"validator": "cosmosvaloper1...",
"share": "1000000"
}
]
},
"amount": "1000000"
}
```
### 8.3 Query
- **auto compounder mode** returns wether the auto compounder mode is enabled or not
```javascript
{
"auto_compounder_mode": {}
}
```
- **AdminAndManagers** returns the admin and managers of the contract
```javascript
{
"admin_and_managers": {}
}
```
Binary file added artifacts/broker_bank.wasm
Binary file not shown.
Binary file added artifacts/broker_staking.wasm
Binary file not shown.
7 changes: 5 additions & 2 deletions artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
3878c8fec84001d1260da6d8b7ea91af5bc3d3433d8cab293ae24de94a9fdda0 broker_bank.wasm
dfd48116b2181f477d42b7d0d697057e16814c0b703ef592a8757ca681c6e5ad broker_staking.wasm
382c05baf544f2886de849933ecf59e8bc3bcdcdd552d5a63537bd6d63f2ecf1 controller.wasm
6cf70cdf7ca010cbeff5fff2ca992ccb6d48fa669baf2b9ee26c8289a926413c core_token_vesting_v2.wasm
05948cad982935aa30a9c2011649ab40a38172ab50df5781a3e24f72b76dcc56 core_compounder.wasm
ed4a89ae4669b22863fcabd18e3bd7e40d039899f863a07eb0449eed059a898e core_token_vesting_v2.wasm
b56a880d4c67d9f353f549b502256f73159f89b50aa6dae683948e117efa4792 cw3_flex_multisig.wasm
1ecff403bbf3b5fcedccb5de76a0ef5f1fdbcc5f60890e3388f5425584899f0b incentives.wasm
dc89ed88f1c69bf63fc284492b7bf6935e3a85da2945067d70f71f08c01df60d lockup.wasm
222eac4e17c7ddffbecde0b196bc06ed1e458b8578ab25ed200a6fd7db4e5eda nibi_stargate.wasm
ef5b4de76526713e3531c3b9bbc4620b5d61599c4a0e8605365ebb0f1d7ee2ac nibi_stargate_perp.wasm
0074489ff40c8ecbd766f7140b32d288dcaf7302ba630d452f79e7d292ea57ef nusd_valuator.wasm
955592d08017aa41f3c9ba3883153d6de024e8c7a3a79aa3b664a241ec1e7a19 pricefeed.wasm
354fdeff1386394d7aa829358323f89bde548d4aa782bae4a16dddfe33dad739 shifter.wasm
89e3236c932a73575bf39da532bcb93f8e4a5f4a3a7f3836e43f8970993eb809 shifter.wasm
8d982ca2d679ea8d44f825fe91a3d4e0cb92150b12e4684497eee9e76991d247 token_vesting.wasm
Binary file modified artifacts/core_token_vesting_v2.wasm
Binary file not shown.
Binary file modified artifacts/shifter.wasm
Binary file not shown.
Loading

0 comments on commit f546e89

Please sign in to comment.