config.rs
this
: the address of this pool contract.owner
: the owner address of this pool contract.beneficiary
: the address of which all interest collected from principal deposits are sent to. could be a single address, or a contract address that oversees additional distribution logic.moneymarket
: the address of the Anchor money market contract to accept deposits.atoken
: the address of the aUST token contract.stable_denom
: base Terra stablecoin denomination of this pool to be deposited to Anchor, i.e. uusd
.dp_token
: the address of the DP token contract minted by this pool.contract.rs
InitMsg
, HandleMsg
and QueryMsg
calls.config.rs
, and initializes a new DP token contract linked to this pool contract.HandleMsg
endpoints. Calls the following functions per HandleMsg
:Receive(msg)
: calls receive(deps, env, msg)
defined under handler_exec.rs
.Deposit {}
: calls deposit(deps, env)
defined under handler_exec.rs
.ClaimReward {}
: calls claim_reward(deps, env)
defined under handler_exec.rs
.RegisterDPToken {}
: calls register_dp_token(deps, env)
defined under handler_exec.rs
.QueryMsg
endpoints. Calls the following functions per QueryMsg
:DepositAmountOf { owner }
: calls deposit_amount(deps, owner)
defined under handler_query.rs
; returns the current DP token balance of the sender of this message.TotalDepositAmount {}
: calls total_deposit_amount(deps)
defined under handler_query.rs
; returns the total DP token balanced linked to this pool contract.Config {}
: calls config(deps)
defined under handler/query.rs
; returns the following:beneficiary
: returns the current beneficiary address set for this pool contract.moneymarket
: returns the Anchor money market contract set for this pool contract to call for deposit_stable
and redeem_stable
messages. For further information regarding logic of the Anchor money market, please refer to Anchor Protocol's official documentation.stable_denom
: returns the current Terra stablecoin denomination that the underlying Anchor money market contract accepts.anchor_token
: returns the aToken contract address that the underlying Anchor money market contract returns on deposits.dp_token
: returns the DP token contract address minted by this pool contract on new deposits.GetClaimableReward {}
: calls claimable_reward(deps)
defined under handler_query.rs
; returns all claimable UST rewards for all UST deposits held by this pool.handler/core.rs
receive
: defines a CW-20 token contract receive hook, which is executed when a Pylon DP token is sent to this Pylon pool.deposit
: deposits UST to this Pylon pool, deposits them to Anchor, and mints Pylon DP tokens back to the depositor.redeem
: consecutively called on a CW-20 receive
call. Burns received DP tokens, retrieves equivalent amounts of UST from Anchor, and returns principal UST deposits excluding any interest generated.claim_reward
: claims any remaining interest remaining in the pool, and sends them over to the beneficiary address. Interest is calculated as (total_aust_amount * exchange_rate) - (total_dp_balance)
register_dp_token
: registers a DP token contract controlled by this Pylon deposit pool for new DP token mints/burns on deposits/redemptions.Redeem {}
Cw20HookMsg
:HookMsg
is the registered DP token address (i.e. not any other token contract address being sent to this pool) - return unauthorized()
error if not, else continueredeem(deps, _env, cw20_msg.sender, cw20_msg.amount)
Redeem {}
message is not included with this function call, return an invalid_request
error.MsgExecuteContract
call:stable_denom
.generic_err
.HandleResponse
issuing the following messages:deposit_stable
from the Anchor money market contract for deposit_amount
units of stable_denom
(e.g. 100 UST). aUST will be returned from the Anchor money market contract to this pool contract.MsgExecuteContract
call that mints deposit_amount
units of Pylon DP tokens for this particular pool to the caller.Redeem {}
Cw20HookMsg
is called:epoch_state
from the Anchor money market.dp_token_balance / epoch_state.exchange_rate
MsgSend
s on the Terra blockchain, deduct_tax
should be called twice, as there are two cases when Terra tax is charged for UST transfers during redemptions:HandleResponse
containing the following messages:amount
units of DP tokens for this Pylon pool.market_redeem_amount
aUST (calculated as dp_token_balance / epoch_state.exchange_rate
) for pool_redeem_amount
UST.MsgSend
s pool_redeem_amount
back to the caller of this contractClaimReward {}
HandleMsg
call:(total_aust_amount * exchange_rate) - (total_dp_balance)
market_redeem_amount
: amount of aUST for redemptions before Terra blockchain tax for both beneficiary
and collector
. returns Uint256
.beneficiary_redeem_amount
: amount of aUST for redemptions after Terra blockchain tax for beneficiary
. returns a Coin
object.collector_redeem_amount
: amount of aUST for redemptions after Terra blockchain tax for collector
, sent to the Collector contract for buybacks. returns a Coin
object.HandleResponse
that includes the following messages:market_redeem_amount
aUST from Anchorbeneficiary_redeem_amount
to beneficiary accountcollector_redeem_amount
to Collector contract