Rates

The Rates ADO is a smart contract that can be used to hold rates configurations for other ADOs. Instead of setting up the rate on the ADO itself, the ADO can reference this ADO to extract the rates set up and apply them on the ADO. These rates can be used to add a fee that is payed on a messages whether a tax or royalty.

We have seen in the AndromedaMsg section that rates can be applied on ADOs that have the rates feature enabled. This ADO can be referenced by those ADOs to apply the rates specified here.

ado_type: rates

Version: 2.0.1-beta.1

InstantiateMsg

By actions, we are referring to execute messages.

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

action

String

The message to apply the rates on.

rate

The rate configurations.

kernel_address

String

Contract address of the kernel contract to be used for AMP messaging. Kernel contract address can be found in our deployed contracts.

owner

Option<String>

Optional address to specify as the owner of the ADO being created. Defaults to the sender if not specified.

ExecuteMsg

SetRate

Only available to the ADO owner

Sets a rate on the specified action.

pub enum ExecuteMsg {
    SetRate { action: String, rate: LocalRate },
    }
NameTypeDescription

action

String

The execute message to add rates on.

rate

The rate configurations.

LocalRate

pub struct LocalRate {
    pub rate_type: LocalRateType,
    pub recipients: Vec<Recipient>,
    pub value: LocalRateValue,
    pub description: Option<String>,
}
NameTypeDescription

rate_type

The type of rate.

recipients

The addresses to recieve the rates. Each address specified will receive the full amount of rate. For example, having a rate of 5% and 2 recipients means each address will receive a 5% rate.

value

The amount of funds taken.

description

Option<String>

Optional description for the purpose of the rate.

LocalRateType

An enum specifying the type of the rate.

pub enum LocalRateType {
    Additive,
    Deductive,
}
  • Additive: The rate amount acts as a tax and is added to the price and payed by the buyer. For example a 10% additive rate (with one recipient) on a price of 1000 uandr means the buyer has to send 1100 uandr.

  • Deductive: The rate amount acts as a royalty and is deducted from the price. For example a 10% deductive rate on a price of 1000 uandr means the buyer needs to send 1000 uand and 100 will be taken to the recipient of the rate.

LocalRateValue

Percentage is specified as a decimal. This means a rate of 10% is specified as 0.1 and not 10.

pub enum LocalRateValue {
    Percent(PercentRate),
    Flat(Coin),
} 

pub struct PercentRate {
    pub percent: Decimal,
}
  • Percent: The rate is specified as a percentage of the price using decimal.

  • Flat: The rate is specified as a fixed amount of Coin.

RemoveRate

Only available to the ADO owner.

Removes the rate set on the specified action.

pub enum RatesMessage {
  RemoveRate {
    action: String 
  },
}
NameTypeDescription

action

String

The execute message to remove the rates from.

Base Executes

The rest of the execute messages can be found in the ADO Base section.

QueryMsg

Rate

Queries the rates applied for the specified action.

pub enum QueryMsg {
    #[returns(RateResponse)]
    Rate { action: String },
}

Returns a LocalRate struct containing the configurations of the rate.

Base Queries

The rest of the query messages can be found in the ADO Base section.

Additional Resources

GithubWebsite