LogoLogo
  • Overview
  • Learn
    • Lend
    • Borrow
    • Interest Rate
    • Liquidate
    • Flash Loans
    • NEPT Token
    • Risks
  • Develop
    • Contracts
      • Market
      • Interest Model
      • Token
      • Oracle
      • Querier
      • Flashloan Reciever
      • nToken
    • Token Addresses
  • User Guides
    • How to Lend on Neptune
    • How to Borrow on Neptune
    • How to Stake with the Neptune Validator
    • How to bridge TIA to Injective
  • Socials and Media
  • Audits
Powered by GitBook
On this page
  • Query Messages
  • 1. Get Params
  • 2. Get State
  • 3. Get User Token Unlocks
  • 4. Get User Staked
  • 5. Get Health Weighted Stake
  • 5. Get Gov Weighted Stake
  • 6. Get Flash Loan Weighted Stake
  • 7. Get Health Weighted Stake Range
  • 8. Get Cascade
  • Execute Messages
  • 1. Bond
  • 2. Unbond
  • 3. Rebond
  • 4. Claim Unbonded
  • 5. Claim Rewards
  • 6. Claim Token Unlock
  • 7. Reclaim Token Unlock
  • 8. Cascade
  • 9. Create Token Unlock
  • 10. Set Params
  1. Develop
  2. Contracts

Token

PreviousInterest ModelNextOracle

Last updated 2 months ago

Token Contract Address:

The Token Contract is a core component of the Neptune Protocol, responsible for managing the NEPT token. It handles token minting, bonding, unbonding, and various queries related to token state and user interactions.

Query Messages

The Token Contract supports several queries to retrieve information about the token state, user stakes, and unlock schedules.

1. Get Params

Query: get_params

Purpose: Returns the current state of the token contract variables

Query Input:

{
  "get_params": {}
}

Query Response:

{
  "emission_rate": "50000000000",
  "bond_duration_settings": [
    [
      604800000000000,
      {
        "reward_weight": "1",
        "gov_weight": "1",
        "health_weight": "0",
        "flash_loan_weight": "0"
      }
    ],
    [
      2592000000000000,
      {
        "reward_weight": "2",
        "gov_weight": "2",
        "health_weight": "1",
        "flash_loan_weight": "0"
      }
    ],
    [
      7776000000000000,
      {
        "reward_weight": "3",
        "gov_weight": "3",
        "health_weight": "1",
        "flash_loan_weight": "1"
      }
    ]
  ],
  "tokens_per_weight": 1000
}
Parameters
Type
Description

emission_rate

string (uint256)

The rate at which tokens are emitted and allocated to staking rewards

bond_duration_settings

array

Array contain staking pool parameters

bond_duration_settings.[].[]

integer (uint64)

The duration of the staking pool bonding period in nanoseconds

reward_weight

string (decimal256)

The weight assigned to rewards for the given bond duration

gov_weight

string (decimal256)

The weight assigned to governance power for the given bond duration

health_weight

string (decimal256)

The weight assigned to health calculations for the given bond duration

flash_loan_weight

string (decimal256)

The weight assigned to flashloan calculations for the given bond duration

tokens_per_weight

integer (uint64)

The number of tokens assigned per weight unit, used in staking calculations

This table provides a structured overview of the parameters found in the JSON, including their types and descriptions.

2. Get State

Query: get_state

Purpose: Returns the current state of the token contract variables

Query Input:

{
  "get_state": {}
}

Query Response:

{
  "bonded": [
    [
      604800000000000,
      "31290473171"
    ],
    [
      2592000000000000,
      "44644356919"
    ],
    [
      7776000000000000,
      "298450211419"
    ]
  ],
  "stake_acc": "0.220433595000408612",
  "time_last_distributed": "1740513832459201021",
  "total_issued": "19008699867843",
  "total_claimed": "19004686162561",
  "total_locked": "5737867114162",
  "total_supply": "20000000000000"
}
Parameters
Type
Description

bonded

array

Array of the available staking pools

bonded.[].[0]

integer (uint64)

Duration of bond for the staking pool in nanoseconds

bonded.[].[1]

string (uint256)

Amount of NEPT tokens staked to pool

stake_acc

string (decimal256)

The accumulated stake value

time_last_distributed

string (uint64)

The timestamp of the last emissions distribution event

total_issued

string (uint256)

The total number of NEPT tokens that have been issued

total_claimed

string (uint256)

The total number of tokens that have been claimed

total_locked

string (uint256)

The total number of NEPT tokens that are currently locked

total_supply

string (uint256)

The total supply of NEPT tokens

3. Get User Token Unlocks

Query: get_user_token_unlocks

Purpose: Retrieves token unlock schedules and their claimable amounts for a user, if any apply.

Query Input:

{
  "get_user_token_unlocks": {
    "account_addr": "inj142aemh62w2fpqjws0yre5936ts9x9e93fj8322"
  }
}

Query Response:

{
  "token_unlocks": [
    {
      "amount": "66340451",
      "start": "1736971200000000000",
      "last_claim": "1736971240955753058",
      "expiration": "1744747200000000000",
      "schedule": "lump_sum",
      "admin": {
        "addr": "inj196lzdc3cak5q4fqgtvmqs8vc42dym00frmwpsw",
        "reclaimed": false
      }
    }
  ],
  "claimable_unlocks": "0"
}
Parameters
Type
Description

token_unlocks

array

An array of objects, each representing a token unlock schedule with details

amount

string (uint256)

The amount of tokens scheduled to be unlocked

start

string (uint64)

The start time of the unlock schedule, unix epoch in nanoseconds

last_claim

string (uint64)

The timestamp of the last claim made, unix epoch in nanoseconds

expiration

string (uint64)

The expiration time of the unlock schedule, unix epoch in nanoseconds

schedule

UnlockSchedule

Either "lump_sum" or {"linear": {"duration": uint64}}

admin

object

An object containing administrative details related to the unlock schedule

admin.addr

string

The address of the admin responsible for the unlock schedule

admin.reclaimed

boolean

A flag indicating whether the unlock schedule has been reclaimed

claimable_unlocks

string (uint256)

The amount of tokens that are currently claimable from the unlock schedule

4. Get User Staked

Query: get_user_staked

Purpose: Retrieves staking data for a user, including bonded tokens, unbonding tokens, unclaimed rewards, and claimable rewards.

Query Input:

{
  "get_user_staked": {
    "account_addr": "inj1exampleaddress"
  }
}

Query Response:

{
  "bonded": [
    {
      "account_index": 0,
      "duration": 604800000000000,
      "bonded": []
    },
    {
      "account_index": 0,
      "duration": 7776000000000000,
      "bonded": [
        {
          "cooldown": null,
          "cascade": false,
          "last_stake_acc": "0.219795491591127008",
          "amount": "69922202"
        }
      ]
    },
    {
      "account_index": 2,
      "duration": 604800000000000,
      "bonded": []
    },
    {
      "account_index": 2,
      "duration": 7776000000000000,
      "bonded": []
    }
  ],
  "unbonding": [],
  "unclaimed": "1349271",
  "claimable_rewards": "1487805",
  "claimable_unbonding": "0"
}
Parameters
Type
Description

bonded

array

An array of objects, each representing a bond with details about account index, duration, and bonded tokens

bonded.[].

account_index

u64

The index of a users margin account associated with the token bond

bonded.[].

duration

u64 (nanoseconds)

The duration of the staking pool bond in nanoseconds

bonded.[].

bonded

array

An array of objects representing individual bond details

bonded.[].

bonded.

cooldown

null or string

The cooldown (unlock) period for the bond, null if not applicable

bonded.[].

bonded.

cascade

boolean

A flag indicating whether the cooldown is part of a cascade operation

bonded.[].

bonded.

last_stake_acc

string (u64)

The last recorded stake accumulator value for the bond.

bonded.[].

bonded.

amount

string (u64)

The amount of tokens bonded.

unbonding

array

An array representing tokens that are in the process of unbonding.

unclaimed

string (u64)

The amount of staking rewards that have been accumulated but not yet claimed

claimable_rewards

string (u64)

The amount of staking rewards that are currently claimable

claimable_unbonding

string (u64)

The amount of unbonding tokens that are currently claimable

5. Get Health Weighted Stake

Query: get_health_weighted_stake

Purpose: Calculates the health-weighted stake for a specific staking position, used by the market contract for account health calculations.

Query Input:

{
  "get_health_weighted_stake": {
    "account_addr": "inj1exampleaddress",
    "account_index": 0
  }
}

Query Response:

"69922202"
Parameters
Type
Description

response

string (uint256)

The health-weighted stake for the specified account address and index

5. Get Gov Weighted Stake

Query: get_gov_weighted_stake

Purpose: Calculates the governance-weighted stake for a user, determining voting power in protocol governance.

Query Input:

{
  "get_gov_weighted_stake": {
    "account_addr": "inj1exampleaddress"
  }
}

Query Response:

"209766606"
Parameters
Type
Description

response

string (uint256)

The governance weight for a given address

6. Get Flash Loan Weighted Stake

Query: get_flash_loan_weighted_stake

Purpose: Calculates the flashloan-weighted stake for a user, used in flashloan operations to determine the amount of assets a user can borrow in a flashloan.

Query Input:

{
  "get_flash_loan_weighted_stake": {
    "account_addr": "inj1exampleaddress"
  }
}

Query Response:

"209766606"
Parameters
Type
Description

response

string (uint256)

The flashloan weight staked used to calculate the amount a user can flashloan from the market

7. Get Health Weighted Stake Range

Query: get_health_weighted_stake_range

Purpose: Retrieves the health-weighted stake for a range of account positions.

Query Input:

{
  "get_health_weighted_stake_range": {
    "from": ["inj1exampleaddress", 0],
    "to": ["inj1exampleaddress", 1]
  }
}

Query Response:

[
  [
    ["inj1exampleaddress", 0],
    "1000000"
  ],
  [
    ["inj1exampleaddress", 1],
    "2000000"
  ]
]
Parameters
Type
Description

[]

array

Array of account indexes and their health weighted stakes

[].[].[1]

string (uint256)

Health weighted stake value

8. Get Cascade

Query: get_cascade

Purpose: Checks if there are any pending cascade operations. Cascading is used to transition bonds from one duration phase to another.

Query Input:

{
  "get_cascade": {}
}

Query Response:

true
Parameters
Type
Description

response

boolean

Returns true if at least one cascade entry exists, false otherwise

Execute Messages

The Token Contract supports several execute messages for managing token bonding, unbonding, rewards, and token unlocks.

1. Bond

Execute: bond

Purpose: Bonds (stakes) NEPT tokens to a specified staking pool for a specified duration, enabling participation in protocol governance and earning staking rewards.

Execute Input:

{
  "bond": {
    "account_index": 0,
    "duration": 604800000000000
  }
}
Parameters
Type
Description

account_index

integer (uint8)

The index of the margin account to associate with the bond

duration

integer (uint64)

The duration to bond tokens for, must match one of the durations in bond_duration_settings

Note: This message must be sent with exactly one non-zero amount of NEPT tokens to bond.

2. Unbond

Execute: unbond

Purpose: Initiates the unbonding of staked NEPT tokens, starting the cooldown period before tokens can be claimed.

Execute Input:

{
  "unbond": {
    "account_index": 0,
    "amount": "1000000",
    "duration": 604800000000000
  }
}
Parameters
Type
Description

account_index

integer (uint8)

The index of the margin account to unbond from

amount

string (uint256)

The amount of NEPT tokens to unbond

duration

integer (uint64)

The duration pool to unbond from

3. Rebond

Execute: rebond

Purpose: Rebonds tokens that are currently unbonding back into a staking position, optionally enabling cascading.

Execute Input:

{
  "rebond": {
    "account_index": 0,
    "amount": "1000000",
    "duration": 604800000000000,
    "cascade": true
  }
}
Parameters
Type
Description

account_index

integer (uint8)

The index of the margin account to rebond to

amount

string (uint256)

The amount of NEPT tokens to rebond

duration

integer (uint64)

The duration to rebond for

cascade

boolean

Whether to enable cascading for this bond

4. Claim Unbonded

Execute: claim_unbonded

Purpose: Claims NEPT tokens that have completed their unbonding period.

Execute Input:

{
  "claim_unbonded": {}
}

5. Claim Rewards

Execute: claim_rewards

Purpose: Claims accumulated staking rewards from all bonded positions.

Execute Input:

{
  "claim_rewards": {}
}

6. Claim Token Unlock

Execute: claim_token_unlock

Purpose: Claims tokens that have been unlocked according to the unlock schedule.

Execute Input:

{
  "claim_token_unlock": {}
}

7. Reclaim Token Unlock

Execute: reclaim_token_unlock

Purpose: Allows an admin to reclaim tokens from an unlock schedule they control.

Execute Input:

{
  "reclaim_token_unlock": {
    "addr": "inj1...",
    "index": 0,
    "recipient": "inj1..."
  }
}
Parameters
Type
Description

addr

string

The address that owns the unlock schedule

index

integer (uint64)

The index of the unlock schedule to reclaim

recipient

string

Optional recipient address for the reclaimed tokens

8. Cascade

Execute: cascade

Purpose: Processes bonds that are ready to cascade to lower duration pools.

Execute Input:

{
  "cascade": {
    "limit": 10
  }
}
Parameters
Type
Description

limit

integer (uint16)

Maximum number of cascade entries to process

9. Create Token Unlock

Execute: create_token_unlock

Purpose: Creates a new token unlock schedule for gradual or lump-sum token distribution.

Execute Input:

{
  "create_token_unlock": {
    "addr": "inj1...",
    "start": "1736971200000000000",
    "expiration": "1744747200000000000",
    "schedule": {
      "linear": {
        "duration": 7776000000000000
      }
    },
    "admin": "inj1..."
  }
}
Parameters
Type
Description

addr

string

The address that will receive the unlocked tokens

start

string (uint64)

The timestamp when the unlock schedule begins

expiration

string (uint64)

Optional timestamp when the unlock schedule expires

schedule

UnlockSchedule

Either "lump_sum" or {"linear": {"duration": uint64}}

admin

string

Optional admin address that can reclaim tokens

Note: This message must be sent with the NEPT tokens to be unlocked.

10. Set Params

Execute: set_params

Purpose: Updates the contract parameters, including emission rate and bond duration settings.

Execute Input:

{
  "set_params": {
    "params": {
      "emission_rate": "50000000000",
      "bond_duration_settings": [
        [
          604800000000000,
          {
            "reward_weight": "1",
            "gov_weight": "1",
            "health_weight": "0",
            "flash_loan_weight": "0"
          }
        ]
      ]
    }
  }
}
Parameters
Type
Description

emission_rate

string (uint256)

The new emission rate of NEPT tokens per year

bond_duration_settings

array

Array of duration and weight settings

Note: Cannot modify governance or reward weights for existing durations.

inj1v3a4zznudwpukpr8y987pu5gnh4xuf7v36jhva