Generator
The Generator contract allocates token rewards (ASTRO) for various LP tokens and distributes them pro-rata to LP stakers. The Generator supports proxy staking via 3rd party contracts that offer a second reward besides ASTRO token emissions.
Links
- Contract Address: terra1ksvlfex49desf4c452j6dewdjs6c48nafemetuwjyj6yexd7x3wqvwa7j9
- Testnet Address: terra1gc4d4v82vjgkz0ag28lrmlxx3tf6sq69tmaujjpe7jwmnqakkx0qm28j2l
- Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/contracts/tokenomics/generator
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/contracts/tokenomics/generator/src/contract.rs
- generator.rs: https://github.com/astroport-fi/astroport-core/blob/main/packages/astroport/src/generator.rs
- Tests: https://github.com/astroport-fi/astroport-core/tree/main/contracts/tokenomics/generator/tests
InstantiateMsg
Initializes the contract with required addresses and contracts used for reward distributions.
Params | Type | Description |
---|---|---|
owner | String | Address that can change contract settings |
astro_token | String | ASTRO token contract address |
tokens_per_block | Uint128 | Amount of ASTRO distributed per block among all pairs |
start_block | Uint64 | Start block for distributing ASTRO |
vesting_contract | String | The ASTRO vesting contract that drips ASTRO rewards |
ExecuteMsg
update_config
Update the vesting contract address, generator controller contract address or generator guardian address. Only the contract owner can execute this.
Params | Type | Description |
---|---|---|
vesting_contract | Option<String> | The new vesting contract address |
generator_controller | Option<String> | The new generator controller contract address |
guardian | Option<String> | The new generator guardian |
voting_escrow_delegation | Option<String> | The new voting escrow delegation contract address |
voting_escrow | Option<String> | The new voting escrow contract address |
checkpoint_generator_limit | Option<u32> | The amount of generators |
setup_pools
Set up a new list of pools with allocation points.
Params | Type | Description |
---|---|---|
pools | Vec<(String, Uint128)> | The list of pools with allocation point |
update_pool
Update has_asset_rewards
parameter for the given pool.
Params | Type | Description |
---|---|---|
lp_token | String | The address of the LP token contract address whose allocation we change |
has_asset_rewards | bool | This flag determines whether the pool gets 3rd party token rewards |
claim_rewards
Updates rewards and returns it to user.
Params | Type | Description |
---|---|---|
lp_tokens | Vec<String> | The LP token contract address |
deposit
Stakes LP tokens in a specific generator (inside the Generator contract).
In order to stake in the Generator contract, you should execute this message inside the contract of the LP token you want to stake.
Params | Type | Description |
---|---|---|
send | Cw20ReceiveMsg | CW20 receive message |
Inside send.msg
, you may encode this JSON string into base64 encoding:
deposit_for
Stakes LP tokens in the Generator on behalf of another address.
In order to stake in the Generator contract, you should execute this message inside the LP token you want to stake.
Params | Type | Description |
---|---|---|
send | Cw20ReceiveMsg | CW20 receive message |
Inside send.msg
, you may encode this JSON string into base64 encoding:
withdraw
Unstakes LP tokens from the Generator contract and claims outstanding token emissions.
Params | Type | Description |
---|---|---|
lp_token | String | The address of the LP token to withdraw |
amount | Uint128 | The amount to withdraw |
emergency_withdraw
Unstakes LP tokens without caring about rewards. To be used only in emergencies such as a critical bug found in the Generator contract.
Params | Type | Description |
---|---|---|
lp_token | String | The address of the LP token to withdraw |
send_orphan_proxy_reward
Sends orphaned rewards (left behind by emergency withdraws) to another address. Only the contract owner can transfer orphan rewards.
Params | Type | Description |
---|---|---|
recipient | String | The transfer recipient |
lp_token | String | The address of the LP token contract for which we send orphaned rewards |
receive
CW20 receive msg.
Params | Type | Description |
---|---|---|
receive | Cw20ReceiveMsg | CW20 receive message |
set_tokens_per_block
Sets the total amount of ASTRO distributed per block among all active generators. Only the owner can execute this.
Params | Type | Description |
---|---|---|
amount | Uint128 | The new amount of ASTRO to distro per block |
propose_new_owner
Creates a request to change contract ownership. The validity period of the offer is set by the expires_in variable. Only the current owner can execute this.
Params | Type | Description |
---|---|---|
owner | String | The newly proposed owner |
expires_in | u64 | The validity period of the proposal to change the contract owner |
drop_ownership_proposal
Removes the existing offer to change contract ownership. Only the contract owner can execute this.
claim_ownership
Used by the newly proposed contract owner to claim contract ownership.
move_to_proxy
Change the current dual rewards proxy for a specific LP token. Only the contract owner can execute this.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
proxy | String | Proxy address |
migrate_proxy
Migrates LP tokens and collected rewards to new proxy.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
new_proxy | String | New proxy address |
update_blocked_tokens_list
Add or remove tokens to and from the tokens blocked list. Only the owner contract or generator guardian can execute this.
Params | Type | Description |
---|---|---|
add | Option<Vec<AssetInfo>> | LP token address |
remove | Option<Vec<AssetInfo>> | New proxy address |
deactivate_pool
Sets the allocation point to zero for specified pool. Only the factory contract can execute this.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
deactivate_pools
Sets the allocation point to zero for each pool by the pair type.
Params | Type | Description |
---|---|---|
pair_types | Vec<PairType> | Pair types to deactivate |
checkpoint_user_boost
Updates emissions boost for specified generators.
Params | Type | Description |
---|---|---|
generators | Vec<String> | Vector of generator addresses |
user | Option<String> | User address |
callback
Process action after the callback
Params | Type | Description |
---|---|---|
action | ExecuteOnReply | Action to process callback for stored in an ExecuteOnReply enum |
ExecuteOnReply
Variants | Description |
---|---|
ClaimRewards | Updates reward and returns it to user |
Deposit | Stake LP tokens in the Generator to receive token emissions |
Withdraw | Withdraw LP tokens from the Generator |
SetTokensPerBlock | Sets a new amount of ASTRO to distribute per block between all active generators |
MigrateProxy | Migrate LP tokens and collected rewards to new proxy |
MigrateProxyDepositLP | Stake LP tokens into new reward proxy |
QueryMsg
active_pool_length
Queries the total amount of active generators.
Returns usize
pool_length
Queries the total amount of generators that have been created until now.
Returns usize
deposit
Queries the amount of a specific LP token that a user currently has staked in the Generator.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
user | String | User address |
Returns Uint128
user_virtual_amount
Queries the current virtual amount in a specific generator.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
user | String | User address |
Returns Uint128
total_virtual_supply
Queries the total virtual supply of generator.
Params | Type | Description |
---|---|---|
generator | String | Generator address |
Returns Uint128
pending_token
Queries the amount of pending ASTRO and 3rd party token rewards that can be claimed by a user that staked a specific LP token.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
user | String | User address |
PendingTokenResponse
Params | Type | Description |
---|---|---|
pending | String | The amount of pending ASTRO |
pending_on_proxy | Option<Vec<Asset>> | The amount of pending 3rd party reward tokens |
config
Queries the main Generator contract configuration.
Config
(response)
Params | Type | Description |
---|---|---|
owner | Addr | Address allowed to change contract parameters |
factory | Addr | The Factory address |
generator_controller | Option<Addr> | Contract address which can only set active generators and their alloc points |
voting_escrow | Option<Addr> | The voting escrow contract address |
astro_token | Addr | The ASTRO token address |
tokens_per_block | Uint128 | Total amount of ASTRO rewards per block |
total_alloc_point | Uint128 | Total allocation points. Must be the sum of all allocation points in all active generators |
vesting_contract | Addr | The vesting contract from which rewards are distributed |
active_pools | Vec<(Addr, Uint128)> | The list of active pools with allocation points |
blocked_tokens_list | Vec<AssetInfo> | The list of blocked tokens |
guardian | Option<Addr> | The guardian address which can add or remove tokens from blacklist |
checkpoint_generator_limit | Option<u32> | The amount of generators |
reward_info
Queries information about token emissions for the specified LP token.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
RewardInfoResponse
This structure holds the response returned when querying for the token addresses used to reward a specific generator.
Params | Type | Description |
---|---|---|
base_reward_token | String | The address of the base reward token |
proxy_reward_token | String | The address of the 3rd party reward token |
orphan_proxy_rewards
Queries the amount of orphaned proxy rewards left behind by emergency withdrawals.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
Returns a vector that contains objects of type (AssetInfo
, Uint128
)
pool_info
Queries pool information for the specified LP token.
Params | Type | Description |
---|---|---|
lp_token | String | LP token address |
PoolInfoResponse
This structure holds the response returned when querying for a pool's information.
Params | Type | Description |
---|---|---|
alloc_point | Uint128 | The slice of ASTRO that this pool's generator gets per block |
astro_tokens_per_block | Uint128 | Amount of ASTRO tokens being distributed per block to this LP pool |
last_reward_block | u64 | The last block when token emissions were snapshotted (distributed) |
current_block | u64 | Current block number. Useful for computing APRs off-chain |
global_reward_index | Decimal | Total amount of ASTRO rewards already accumulated per LP token staked |
pending_astro_rewards | Uint128 | Pending amount of total ASTRO rewards which are claimable by stakers right now |
reward_proxy | Option<Addr> | The address of the 3rd party reward proxy contract |
pending_proxy_rewards | Option<Uint128> | Pending amount of total proxy rewards which are claimable by stakers right now |
accumulated_proxy_rewards_per_share | Vec<(Addr, Decimal)> | Total amount of 3rd party token rewards already accumulated per LP token staked per proxy |
proxy_reward_balance_before_update | Uint128 | Reward balance for the dual rewards proxy before updating accrued rewards |
orphan_proxy_rewards | Vec<(Addr, Uint128)> | The amount of orphan proxy rewards which are left behind by emergency withdrawals and not yet transferred out |
lp_supply | Uint128 | Total amount of lp tokens staked in the pool's generator |
simulate_future_reward
Queries the amount of ASTRO that will be distributed up to a future block and for a specific LP token.
Params | Type | Description |
---|---|---|
lp_token | String | LP token addres |
future_block | u64 | Future block |
Returns Uint128
pool_stakers
Queries a list of stakers that currently have funds in a specific generator.
Params | Type | Description |
---|---|---|
lp_token | String | LP token addres |
start_after | Option<String> | Staker address to start after |
limit | Option<u32> | Amount of stakers to list |
Returns a vector that contains objects of type StakerResponse
StakerResponse
This structure holds the parameters used to return information about a staked in a specific generator.
Params | Type | Description |
---|---|---|
account | String | The staker's address |
amount | Uint128 | The amount that the staker currently has in the generator |
blocked_tokens_list
Queries the list of blocked tokens.
Returns a vector that contains objects of type AssetInfo
reward_proxies_list
Queries a list of reward proxy contracts which have been ever used.
Returns a vector that contains objects of type Addr