Generator Proxy
Overview
The generator proxy contract allows an external staking contract to be connected to the Generator. It gives Generator stakers the ability to claim both ASTRO emissions as well as 3rd party tokens at the same time. This is referred to as "dual rewards" in Astroport.
In order to build your Dual Rewards Proxy, you can use this template as a starting point. A working example for dual rewards can be be found here.
Links
- Template Contract Repo: https://github.com/astroport-fi/astroport-core/tree/main/templates/generator_proxy_template
- contract.rs: https://github.com/astroport-fi/astroport-core/blob/main/templates/generator_proxy_template/src/contract.rs
- generator_proxy.rs: https://github.com/astroport-fi/astroport-core/blob/main/packages/astroport/src/generator_proxy.rs
InstantiateMsg
Initializes the proxy contract with required addresses (generator, LP token to stake etc).
Params | Type | Description |
---|---|---|
generator_contract_addr | String | The generator contract address |
pair_addr | String | The pair contract address used in this generator proxy |
lp_token_addr | String | The LP contract address which can be staked in the reward_contract |
reward_contract_addr | String | The 3rd party reward contract address |
reward_token_addr | String | The 3rd party reward token contract address |
ExecuteMsg
receive
CW20 receive msg.
Params | Type | Description |
---|---|---|
receive | Cw20ReceiveMsg | CW20 receive message |
update_rewards
Updates 3rd party token proxy rewards and withdraws rewards from the 3rd party staking contract.
send_rewards
Sends accrued token rewards to a specific account.
Params | Type | Description |
---|---|---|
account | String | The address that will receive rewards |
amount | Uint128 | The amount of tokens to send |
withdraw
Withdraws LP tokens alongside any outstanding token rewards and sends them to the specified address.
Params | Type | Description |
---|---|---|
account | String | The address that will receive the withdrawn tokens and rewards |
amount | Uint128 | The amount of LP tokens to withdraw |
emergency_withdraw
Unstake LP tokens without caring about accrued rewards.
Params | Type | Description |
---|---|---|
account | String | The address that will receive the withdrawn tokens |
amount | Uint128 | The amount of LP tokens to withdraw |
callback
Handles callback mesasges.
One example is for transferring LP tokens after a withdrawal from the 3rd party staking contract.
Params | Type | Description |
---|---|---|
callback | CallbackMsg | Callback of type CallbackMsg |
CallbackMsg
transfer_lp_tokens_after_withdraw
This structure describes the callback messages available in the contract.
Params | Type | Description |
---|---|---|
account | Addr | The LP token recipient |
prev_lp_balance | Uint128 | The previous LP balance for the contract. This is used to calculate the amount of received LP tokens after withdrawing from a third party contract |
Cw20HookMsg
deposit
Deposit third-party LP tokens into the Generator Proxy contract.
You should execute this message inside the third-party LP token contract.
In send.msg
, you may encode this JSON string into base64 encoding.
QueryMsg
config
Returns the contract's configuration.
ConfigResponse
Params | Type | Description |
---|---|---|
generator_contract_addr | String | The generator contract address |
pair_addr | String | The pair contract address used in this generator proxy |
lp_token_addr | String | The LP contract address which can be staked in the reward_contract |
reward_contract_addr | String | The 3rd party reward contract address |
reward_token_addr | String | The 3rd party reward token contract address |
deposit
Returns the deposited/staked token amount for a specific account.
Returns Uint128
reward
Returns the total amount of 3rd party rewards.
Returns Uint128
pending_token
Returns the total amount of pending rewards for all stakers.
Returns Uint128
reward_info
Returns the reward (3rd party) token contract address.
Returns Addr