Andromeda
Search…
⌃K

Rates

Introduction

The Rates ADO is a smart contract used to impose some kind of fees on funds transactions.
This contract is implemented as a module and attached to other contracts which would apply the specified rates on any fund transfers. The contract owner can specify specific addresses to be exempt from these rates. A small example on this would be putting rates on an NFT Collectible, sending a percentage as royalty to the original owner.
There are two main types of rates:
  • Taxes: Funds are added to the price and paid by the buyer
  • Royalties: Funds are deducted from the price and are paid by the seller.
More information on how the module works can be found in the Rates Module section.
Ado_type: rates

InstantiateMsg

Rust
JSON
pub struct InstantiateMsg {
pub rates: Vec<RateInfo>,
}
{
"rates":
[
{
"rate":{
"percent":{
"percent":"0.1"
},
"is_additive": false,
"recipients":[{
"addr":"andr1..."
},
{
"addr":"andr1..."
}
]
},
...
]
}
Name
Type
Description
rates
A vector containing the different RateInfo of the contract.

RateInfo

The information about the rates is stored in a RateInfo struct.
Each of the recipients will receive the rate imposed. ( The rate is 3% and we have 5 recipients then 15 % would go to them in total.)
Taxes are added to the selling price (Paid by buyer) while royalties are deducted from the price (Paid by seller).
pub struct RateInfo {
pub rate: Rate,
pub is_additive: bool,
pub description: Option<String>,
pub recipients: Vec<Recipient>,
}
Name
Type
Description
rate
Rate
The type of rate being taken.
is_additive
bool
An indicator to whether the rate being taken is tax. If tax is_additive is set to true.
description
Option<String>
Optional description for the rate.
recipients
The addresses to receive the rate specified.

Rate

An enum used to define various types of fees which is used in the RateInfo.
pub enum Rate {
Flat(Coin),
Percent(PercentRate),
External(PrimitivePointer),
}
The Rate can be one of the three option seen above:
  • Flat: A fixed amount to be taken (Coin). Needs to have an amount and denomination specified.
  • Percent: A percentage based rate. Needs to have the percent to take specified.
  • External: This refers to a rate that we want to use which is saved in a primitive contract. Needs the address of the primitive and the key of the stored Rate primitive to be specified.

PercentRate

pub struct PercentRate {
pub percent: Decimal,
}
Name
Type
Description
percent
Decimal
The percentage to take as rate.
PrimitivePointer
pub struct PrimitivePointer {
pub address: AndrAddress,
pub key: Option<String>,
}
Name
Type
Description
address
The address of the primitive contract.
key
Option<String>
The optional key for the stored data.

ExecuteMsg

UpdateRates

Only the contract owner can execute UpdateRates.
Rust
JSON
pub enum ExecuteMsg{
UpdateRates{
rates: Vec<RateInfo>
}
}
{
"update_rates":{
"rates":
[
{
"rate":{
"percent":{
"percent":"0.1"
},
"is_additive": false,
"recipients":[
{
"addr":"andr1..."
},
{
"addr":"andr1..."
},
...
]
},
...
]
}
}
Name
Type
Description
rates
A vector containing the new RateInfo to be used by the contract.

AddExemption

Specifies an address to be exempt from any rates set by this contract.
Only available to the contract owner.
Rust
JSON
pub enum ExecuteMsg {
AddExemption {
address: String
}
}
{
"add_exemption":{
"address":"andr1..."
}
}
Name
Type
Description
address
String
The address that will not have the rates applied.

RemoveExemption

Removes an address from the list of exempt addresses.
Rust
JSON
pub enum ExecuteMsg {
RemoveExemption {
address: String
}
}
{
"remove_exemption":{
"address":"andr1..."
}
}
Name
Type
Description
address
String
The address to remove the exemption from.

AndrReceive

The rest of the executes can be found in the AndrReceive section.

Payments

Returns the rates used by the contract in a vector of RateInfo.
Rust
JSON
pub enum QueryMsg{
#[returns(PaymentsResponse)]
Payments {}
}
{
"payments":{}
}

PaymentsResponse

Rust
JSON
pub struct PaymentsResponse {
pub payments: Vec<RateInfo>,
}
{
"payments":
[
{
"rate":{
"percent":{
"percent":"0.3"
}
},
"is_additive": false,
"recipients":[
{
"addr":"andr1..."
},
{
"addr":"andr1..."
},
...
]
},
...
]
}
Name
Type
Description
payments
A vector of the RatInfo currently used by the contract.

IsExempt

Checks if the specified address is exempt from rates.
Rust
JSON
pub enum QueryMsg {
#[returns(bool)]
IsExempt {address: String }
}
{
"is_exempt":{
"address":"andr1..."
}
}
Name
Type
Description
address
String
The address to check if exempt from rates.
Returns true if included and false otherwise.

Exemptions

Queries the list of addresses exempt from rates.
Rust
JSON
pub enum QueryMsg {
#[returns(ExemptionsResponse)]
Exemptions {
limit: Option<u32>,
start_after: Option<String>,
}
}
{
"exemptions":{
"limit": 80
}
}
Name
Type
Description
limit
Option<u32>
An optional limit on how many are returned. Default limit is 50 and the maximum limit that can be set is 100.
start_after
Option<String>
An optional Id for which to start after, used for pagination.

ExemptionsResponse

Rust
JSON
pub struct ExemptionsResponse {
pub exemptions: Vec<String>,
}
{
"exemptions":["andr1...","andr1...",...]
}

AndrQuery

A set of base queries common to all Andromeda ADOs. Check AndrQuery.