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. ADO: First, the ADO requesting the fees is checked for funds and if available will use these funds to pay the fee.

  2. App: The App contract of the ADO requesting the fees.

  3. Payee: The address that sent the message to the ADO that is requesting the fees.

Ado_type: economics

InstantiateMsg

pub struct InstantiateMsg {
    pub kernel_address: String,
    pub owner: Option<String>,
}
NameTypeDescription

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.

pub enum ExecuteMsg{
     Deposit {
        address: Option<AndrAddr>,
    }
}
Name TypeDescription

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. Called by sending CW20 tokens from the CW20 ADO using the Send execute message.

This is not called directly by the user, but called when the user sends CW20 tokens to this ADO.

The msg field of the Send execute should be a base64 encoded Cw20HookMsg.

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 Cw20HookMsg 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> },
}
NameTypeDescription

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.

pub enum ExecuteMsg {
    PayFee {
        payee: Addr,
        action: String,
    },
}
NameTypeDescription

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.

pub enum ExecuteMsg {
     Withdraw {
        amount: Option<Uint128>,
        asset: String,
    }
}
Name TypeDescription

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.

 pub enum ExecuteMsg {
 #[serde(rename = "withdraw_cw20")]
 WithdrawCW20 {
        amount: Option<Uint128>,
        asset: String,
    }
}
Name TypeDescription

amount

Option<Uint128>

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.

Ownership

The set of ownerhsip messages. These messages are the same as the ones found in the ADO base section.

QueryMsg

Balance

Queries the amount of the specified asset for the specified address.

pub enum QueryMsg {
    #[returns(Uint128)]
    Balance { asset: String, address: AndrAddr },
}
NameTypeDescription

asset

String

The asset to get the balance for. Can be either a native token or a CW20 contract address.

address

The address to get the balance for.

Returns a Uint128 representing the current balance.

Version

Queries the version of the ADO.

pub enum AndromedaQuery {
     #[returns(VersionResponse)]
     Version {}
     }

VersionResponse

pub struct VersionResponse {
    pub version: String,
}
NameTypeDescripton

version

String

The version of the ADO.

Owner

Queries the owner of the contract.

pub enum AndromedaQuery{
    #[returns(ContractOwnerResponse)]
    Owner{}
}

ContractOwnerResponse

pub struct ContractOwnerResponse {
    pub owner: String
}

Type

Queries the ADO type.

pub enum AndromedaQuery {
    #[returns(TypeResponse)]
    Type {}
}

TypeResponse

pub struct TypeResponse {
    pub ado_type: String,
    }
NameTypeDescription

ado_type

String

The type of the ado.

KernelAddress

Queries the kernel address of the chain the ADO is deployed on.

pub enum AndromedaQuery {
    #[returns(KernelAddressResponse)]
    KernelAddress {},
    }

Returns a String containing the contract address of the Kernel.

Additional Resources

GithubWebsite