Andromeda
Search…
Rates
A smart contract to implement rates on ADOs.

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. 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":"juno1..."
},
{
"addr":"juno1..."
}
]
},
...
]
}
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.)
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":"juno1..."
},
{
"addr":"juno1..."
},
...
]
},
...
]
}
}
Name
Type
Description
rates
A vector containing the new RateInfo to be used by the contract.

AndrReceive

QueryMsg

Payments

Returns the rates used by the contract in a vector of RateInfo.
Rust
JSON
pub enum QueryMsg{
Payments {}
}
{
"payments":{}
}

PaymentsResponse

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

AndrQuery

Copy link
Outline
Introduction
InstantiateMsg
RateInfo
ExecuteMsg
UpdateRates
AndrReceive
QueryMsg
Payments
PaymentsResponse
AndrQuery