Skip to main content

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.

InstantiateMsg

Initializes the proxy contract with required addresses (generator, LP token to stake etc).

json
generator_proxy.rs
Copy

_7
{
_7
"generator_contract_addr": "...",
_7
"pair_addr": "...",
_7
"lp_token_addr": "...",
_7
"reward_contract_addr": "...",
_7
"reward_token_addr": "..."
_7
}

ParamsTypeDescription
generator_contract_addrStringThe generator contract address
pair_addrStringThe pair contract address used in this generator proxy
lp_token_addrStringThe LP contract address which can be staked in the reward_contract
reward_contract_addrStringThe 3rd party reward contract address
reward_token_addrStringThe 3rd party reward token contract address

ExecuteMsg

receive

CW20 receive msg.

json
generator_proxy.rs
Copy

_7
{
_7
"receive": {
_7
"sender": "...",
_7
"amount": "123",
_7
"msg": "<base64_encoded_json_string>"
_7
}
_7
}

ParamsTypeDescription
receiveCw20ReceiveMsgCW20 receive message

update_rewards

Updates 3rd party token proxy rewards and withdraws rewards from the 3rd party staking contract.

json
generator_proxy.rs
Copy

_3
{
_3
"update_rewards": {}
_3
}

send_rewards

Sends accrued token rewards to a specific account.

json
generator_proxy.rs
Copy

_6
{
_6
"send_rewards": {
_6
"account": "...",
_6
"amount": "1000000"
_6
}
_6
}

ParamsTypeDescription
accountStringThe address that will receive rewards
amountUint128The amount of tokens to send

withdraw

Withdraws LP tokens alongside any outstanding token rewards and sends them to the specified address.

json
generator_proxy.rs
Copy

_6
{
_6
"withdraw": {
_6
"account": "...",
_6
"amount": "1000000"
_6
}
_6
}

ParamsTypeDescription
accountStringThe address that will receive the withdrawn tokens and rewards
amountUint128The amount of LP tokens to withdraw

emergency_withdraw

Unstake LP tokens without caring about accrued rewards.

json
generator_proxy.rs
Copy

_6
{
_6
"emergency_withdraw": {
_6
"account": "...",
_6
"amount": "1000000"
_6
}
_6
}

ParamsTypeDescription
accountStringThe address that will receive the withdrawn tokens
amountUint128The 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.

json
generator_proxy.rs
Copy

_8
{
_8
"callback": {
_8
"transfer_lp_tokens_after_withdraw": {
_8
"account": "...",
_8
"prev_lp_balance": "1234"
_8
}
_8
}
_8
}

ParamsTypeDescription
callbackCallbackMsgCallback of type CallbackMsg

CallbackMsg

transfer_lp_tokens_after_withdraw

This structure describes the callback messages available in the contract.

json
generator_proxy.rs
Copy

_6
{
_6
"transfer_lp_tokens_after_withdraw": {
_6
"account": "...",
_6
"prev_lp_balance": "1234"
_6
}
_6
}

ParamsTypeDescription
accountAddrThe LP token recipient
prev_lp_balanceUint128The 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.

NOTE

You should execute this message inside the third-party LP token contract.

json
Copy

_7
{
_7
"send": {
_7
"contract": "ProxyContractAddress",
_7
"amount": "999",
_7
"msg": "base64-encodedStringOfWithdrawMsg"
_7
}
_7
}

In send.msg, you may encode this JSON string into base64 encoding.

json
generator_proxy.rs
Copy

_3
{
_3
"deposit": {}
_3
}

QueryMsg

config

Returns the contract's configuration.

json
generator_proxy.rs
Copy

_3
{
_3
"config": {}
_3
}

ConfigResponse

json
generator_proxy.rs
Copy

_7
{
_7
"generator_contract_addr": "...",
_7
"pair_addr": "...",
_7
"lp_token_addr": "...",
_7
"reward_contract_addr": "...",
_7
"reward_token_addr": "..."
_7
}

ParamsTypeDescription
generator_contract_addrStringThe generator contract address
pair_addrStringThe pair contract address used in this generator proxy
lp_token_addrStringThe LP contract address which can be staked in the reward_contract
reward_contract_addrStringThe 3rd party reward contract address
reward_token_addrStringThe 3rd party reward token contract address

deposit

Returns the deposited/staked token amount for a specific account.

json
generator_proxy.rs
Copy

_3
{
_3
"deposit": {}
_3
}

Returns Uint128

reward

Returns the total amount of 3rd party rewards.

json
generator_proxy.rs
Copy

_3
{
_3
"reward": {}
_3
}

Returns Uint128

pending_token

Returns the total amount of pending rewards for all stakers.

json
generator_proxy.rs
Copy

_3
{
_3
"pending_token": {}
_3
}

Returns Uint128

reward_info

Returns the reward (3rd party) token contract address.

json
generator_proxy.rs
Copy

_3
{
_3
"reward_info": {}
_3
}

Returns Addr