Andromeda
Ask or search…
K

Economics Engine

The Economics ADO allows users to deposit funds to be used to pay fees implemented on ADO actions by the ADODB. Deposited funds can be either native funds such as "uandr" or CW20 tokens where the contract address is used. The fees are automatically called by the ADO that implements them.
Fees are charged in the following order:
A fee can be paid by a combination of the below. For example if a 1000 uandr fee is required and the balance of the ADO is 800 uandr, then 800 will be deducted from the 1000, and the remainder is paid by App contract. If the App does not have sufficient funds to cover the rest, then the funds are deducted from the payee next.
  1. 1.
    ADO: First, the ADO requesting the fees is checked for funds and if available will use these funds to pay the fee.
  2. 2.
    App: The App contract of the ADO requesting the fees.
  3. 3.
    Payee: The address that sent the message to the ADO that is requesting the fees.
Ado_type: economics

InstantiateMsg

Rust
JSON
pub struct InstantiateMsg {
pub kernel_address: String,
pub owner: Option<String>,
}
{
"kernel_address":"andr1...",
"owner":"andr1..."
}
Name
Type
Description
kernel_address
String
The address of the kernel contract on chain. This can be found in our deployed contracts section.
owner
Option<String>
Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

ExecuteMsg

Deposit

Deposit funds to be used by the Andromeda economics module to pay for ADO fees.
Rust
JSON
pub enum ExecuteMsg{
Deposit {
address: Option<AndrAddr>,
}
}
{
"deposit":{
"address":"andr1..."
}
}
Name
Type
Description
address
Option<AndrAddr>
If specified, then your deposit would be on the behalf of the AndrAddr. If not specified, then the deposit will be for the sender.

Receive

Handles receiving CW20 tokens to be deposited as funds to pay fees with.
This is not called directly by the user, but called when the user sends CW20 tokens to this ADO.
Rust
pub enum ExecuteMsg {
Receive(Cw20ReceiveMsg),
}

Cw20ReceiveMsg

pub struct Cw20ReceiveMsg {
pub sender: String,
pub amount: Uint128,
pub msg: Binary,
}
The msg field needs to be a CwHookMsg of type Deposit. The message is attached as a bsae64 encoded binary of the JSON representation of the Deposit message.

Cw20HookMsg

Deposits CW20 tokens to be used as funds to pay fees.
#[cw_serde]
pub enum Cw20HookMsg {
Deposit { address: Option<AndrAddr> },
}
Name
Type
Description
address
Option<AndrAddr>
If specified, then your deposit would be on the behalf of the AndrAddr. If not specified, then the deposit will be for the sender.

PayFee

Pay a fee for the given action. The sender must be a valid ADO contract.
This message is never called by the user directly, but by an ADO when the user calls a message that requires fees to be payed.
Rust
pub enum ExecuteMsg {
PayFee {
payee: Addr,
action: String,
},
}
Name
Type
Description
payee
Addr
The address that will pay in case the ADO and App did not have enough funds to cover the fee.
action
String
The action we are paying a fee for.

Withdraw

Withdraw native funds from the Andromeda economics module. If no amount is provided, all funds are withdrawn for the given asset.
Rust
JSON
pub enum ExecuteMsg {
Withdraw {
amount: Option<Uint128>,
asset: String,
}
}
{
"withdraw":{
"amount":"500000",
"asset":"uandr"
}
}
Name
Type
Description
amount
Option<AndrAddr>
The amount of the specified asset to withdraw. If not specified then the total amount is withdrawn.
asset
String
The native asset to withdraw.

WithdrawCW20

Withdraw CW20 funds from the Andromeda economics module. If no amount is provided all funds are withdrawn for the given asset.
Rust
JSON
pub enum ExecuteMsg {
#[serde(rename = "withdraw_cw20")]
WithdrawCW20 {
amount: Option<Uint128>,
asset: String,
}
}
{
"withdraw_cw20":{
"amount":"800",
"asset":"andr1..."
}
}
Name
Type
Description
amount
Option<AndrAddr>
The amount of the specified asset to withdraw. If not specified then the total amount is withdrawn.
asset
String
The contract address of the CW20 token to withdraw.

QueryMsg

Balance

Queries the amount of the specified asset for the specified address.
Rust
JSON
pub enum QueryMsg {
#[returns(Uint128)]
Balance { asset: String, address: AndrAddr },
}
{
"balance":{
"asset":"uandr",
"address":"andr1..."
}
}
Name
Type
Description
asset
String
The asset to get the balance for. Can be either a native token or a CW20 contract address.
address
AndrAddr
The address to get the balance for.
Returns a Uint128 representing the current balance.