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.
- Contracts Cookbook
Shifter is a simple contract that can execute peg and depth shift to any markets in the x/perp module of Nibiru. The contract holds a whitelist of addressses that are allowed to execute the shift.
The instantiation defines just the onwer of the contract, who wil be able to add and remove addresses from the whitelist, and execute the shifts.
{"owner": "cosmos1..."}
- ShiftSwapInvariant executes a depth shift in a market.
{
"shift_swap_invariant": {
"pair": "uusd:usdr",
"new_swap_invariant": "1000000"
}
}
- ShiftPegMultiplier executes a depth shift on a market. It can be executed by anyone.
{
"shift_peg_multiplier": {
"pair": "ubtc:unusd",
"new_peg_mult": "20420.69"
}
}
- EditOpers adds or removes addresses from the whitelist. It can be executed by the owner.
{
"edit_opers": {
"add_oper": {"addr": "cosmos1..."},
"remove_oper": {"addr": "cosmos1..."},
}
}
The queries have to do with checking permissions of addresses.
- HasPerms checks if an address has permissions to execute shifts.
{
"has_perms": {
"address": "cosmos1..."
}
}
- Perms query the contract owner and set of operators.
{
"perms": {},
}
This contract implements vesting accounts for the CW20 and native tokens.
There's no instantiation message.
{
}
- Receive
{
"receive": {
"sender": "cosmos1...",
"amount": "1000000",
"msg": "eyJ2ZXN0X2lkIjoxLCJ2ZXN0X3R5cGUiOiJ2ZXN0In0=",
}
}
- RegisterVestingAccount registers a vesting account
{
"register_vesting_account": {
"address": "cosmos1...",
"master_address": "cosmos1...",
"vesting_schedule": {
"linear_vesting": {
"start_time": "1703772805",
"end_time": "1703872805",
"vesting_amount": "1000000"
}
}
}
}
- DeregisterVestingAccount deregisters a vesting account
{
"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
{
"claim": {
"denom": "uusd",
"recipient": "cosmos1...",
}
}
- VestingAccount returns the vesting account details for a given address.
{
"vesting_account": {
"address": "cosmos1...",
}
}
This smart contract showcases usage examples for certain Nibiru-specific and Cosmos-SDK-specific.
There's no instantiation message.
{
}
- CreateDenom creates a new denom
{
"create_denom": { "subdenom": "zzz" }
}
- Mint mints tokens
{
"mint": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"mint_to": "[mint-to-addr]"
}
}
- Burn burns tokens
{
"burn": {
"coin": { "amount": "[amount]", "denom": "tf/[contract-addr]/[subdenom]" },
"burn_from": "[burn-from-addr]"
}
}
- ChangeAdmin changes the admin of a denom
{
"change_admin": {
"denom": "tf/[contract-addr]/[subdenom]",
"new_admin": "[ADDR]"
}
}
This smart contract showcases usage examples for certain Nibiru-specific for the perp market.
The instantiation defines the owner of the contract, who will be able to add and remove addresses from the whitelist, and execute the shifts.
{
"admin": "cosmos1...",
}
- 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, andbase_amount_limit
sets a limit for the amount in the base currency.
{
"market_order": {
"pair": "BTC/USDT",
"is_long": true,
"quote_amount": "1000000",
"leverage": "2.0",
"base_amount_limit": "5000000"
}
}
- ClosePosition closes an open position for a specified trading pair.
{
"close_position": {
"pair": "BTC/USDT"
}
}
- AddMargin adds margin to an existing position for a specified trading pair.
margin
is the amount of additional margin to add.
{
"add_margin": {
"pair": "BTC/USDT",
"margin": {"denom": "usdt", "amount": "100000"}
}
}
- RemoveMargin removes margin from an existing position for a specified trading pair.
margin
is the amount of margin to remove.
{
"remove_margin": {
"pair": "BTC/USDT",
"margin": {"denom": "usdt", "amount": "50000"}
}
}
- MultiLiquidate triggers multiple liquidations based on the provided arguments.
liquidations
is a list of liquidation arguments specifying the details for each liquidation.
{
"multi_liquidate": {
"liquidations": [
{
"pair": "BTC/USDT",
"trader": "cosmos1...",
},
{
"pair": "BTC/USDT",
"trader": "cosmos1...",
}
]
}
}
- DonateToInsuranceFund allows donation to the insurance fund.
donation
is the coin and amount to donate.
{
"donate_to_insurance_fund": {
"donation": {"denom": "usdt", "amount": "100000"}
}
}
- Claim facilitates the claiming of funds.
funds
is an optional field specifying a particular coin and amount to claim,claim_all
is an optional flag to claim all funds, andto
is the address to which the funds will be sent.
{
"claim": {
"funds": {"denom": "usdt", "amount": "100000"},
"claim_all": true,
"to": "cosmos1..."
}
}
This format aligns with the style of your previous documentation, ensuring consistency and clarity in the explanation of each function and its parameters.
This smart contract is a simple valuator for the nusd token, which takes one collateral.
The owner is the only one who can execute messages in the contract
{
"owner": "cosmos1...",
"accepted_denoms": "uusdc",
}
- ChangeDenom updates the accepted denoms
{
"change_denom": {
"from: "uusdc",
"to": "uusd",
}
}
- AddDenom adds a new accepted denom
{
"add_denom": {
"denom": "uusd",
}
}
- RemoveDenom removes an accepted denom
{
"remove_denom": {
"denom": "uusd",
}
}
- Mintable queries the amount of μNUSD that can be minted in exchange for the specified set of
from_coins
.
{
"mintable": {
"from_coins": ["BTC", "ETH"]
}
}
- Redeemable calculates the amount of a specified
to_denom
currency that is redeemable for a givenredeem_amount
of μNUSD.
{
"redeemable": {
"redeem_amount": "1000000",
"to_denom": "usdt"
}
}
- AcceptedDenoms retrieves the set of token denominations that are accepted as collateral.
{
"accepted_denoms": {}
}
- RedeemableChoices provides a set of possible redeemable coin options that could be received when redeeming a specified
redeem_amount
of μNUSD.
{
"redeemable_choices": {
"redeem_amount": "1000000"
}
}
This contract implements vesting accounts for the native tokens.
We need to specify admin and managers
{
"admin": "cosmos1...",
"managers": ["cosmos1...", "cosmos1..."]
}
- RewardUsers registers several vesting contracts
{
"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
{
"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
{
"claim": {
"recipient": "cosmos1...",
}
}
- VestingAccount returns the vesting account details for a given address.
{
"vesting_account": {
"address": "cosmos1...",
}
}
This contract manages staking re-delegation processes securely, allowing for auto-compounding of staked funds.
We need to specify admin and managers
{
"admin": "cosmos1...",
"managers": ["cosmos1...", "cosmos1..."]
}
- SetAutoCompounderMode sets the auto compounder mode
{
"set_auto_compounder_mode": {
"mode": "true" // true or false
}
}
-
Withdraw allows to withdraw the funds from the contract
{ "withdraw": { "amount": "1000000" "recipient": "cosmos1..." } }
-
unstakes allows to unstake the funds from the contract
{ "unstake": { "unstake_msgs": [ { "validator": "cosmosvaloper1...", "amount": "1000000" }, { "validator": "cosmosvaloper1...", "amount": "1000000" } ] } }
-
update managers allows to update the managers of the contract
{
"update_managers": {
"managers": ["cosmos1...", "cosmos1..."]
}
}
- stake allows to stake the funds from the contract. The shares are normalized
{
"stake": {
"stake_msgs": [
{
"validator": "cosmosvaloper1...",
"share": "1000000"
},
{
"validator": "cosmosvaloper1...",
"share": "1000000"
}
]
},
"amount": "1000000"
}
- auto compounder mode returns wether the auto compounder mode is enabled or not
{
"auto_compounder_mode": {}
}
- AdminAndManagers returns the admin and managers of the contract
{
"admin_and_managers": {}
}