Andromeda
Search…
Rate Limiting Withdrawals

Introduction

The Rate Limiting Withdrawals ADO acts as a bank account that limits the frequency and size of an account holder's withdrawals. Only one type of coin can be used.
Ado_type: rate-limiting-withdrawals

InstantiateMsg

Either the minimal_withdrawal_frequency or contract_key should be set and not both.
Rust
JSON
pub struct InstantiateMsg {
pub allowed_coin: CoinAndLimit,
pub minimal_withdrawal_frequency: MinimumFrequency,
pub modules: Option<Vec<Module>>,
}
{
"allowed_coin":{
"coin":"ujunox",
"limit":"500"
},
"minimal_withdrawal_frequency":{
"time":{
"time":"3600"
}
}
}
Name
Type
Description
allowed_coin
Set the allowed coin denom and the maximum amount allowed to withdraw.
minimal_withdrawal_frequency
The time required between withdrawals. Specified in seconds. Cannot be 0.
modules
Option<Vec<Module>>
An optional vector of Andromeda Modules that can be attached to the contract. "address-list" module can be added.

CoinAndLimit

pub struct CoinAndLimit {
pub coin: String,
pub limit: Uint128,
}
Name
Type
Description
coin
String
Sets the accepted coin denom.
limit
Uint128
Sets the withdrawal limit in terms of amount.

MinimumFrequency

pub enum MinimumFrequency {
Time { time: Uint128 },
AddressAndKey { address_and_key: ContractAndKey },
The minimum withdrawal frequency can be set in two ways:
  • Time: A time in seconds. For example 3600 would specify that each the user needs to wait 3600 seconds between withdrawals.
  • AddressAndKey: Takes the value from a primitive. Need to specify the contract address of the primitive and the key associated to the value we want.

ContractAndKey

pub struct ContractAndKey {
pub contract_address: String,
pub key: Option<String>,
}
Name
Type
Description
contract_address
String
The contract address of the primitive to get the value from.
key
Option<String>
The key of the saved value we want to use. Uses the default key if not specified.

ExecuteMsg

Deposit

Deposit funds for the specified recipient.
Only the allowed coin in instantiation can be deposited.
Rust
JSON
pub enum ExecuteMsg {
Deposit {
recipient: Option<String>,
}
}
{
"deposit":{
"recipient":"juno1..."
}
}
Name
Type
Description
recipient
Option<String>
The owner of the deposited funds. If not set default to the sender.

Withdraw

Enough time should pass since the last withdrawal.
Rust
JSON
pub enum ExecuteMsg{
Withdraw {
amount: Uint128,
}
}
{
"withdraw":{
"amount":"100"
}
}
Name
Type
Description
amount
Uint128
The amount of coins to withdraw.

AndrReceive

Uses the modules feature.

QueryMsg

CoinAllowanceDetails

Provides the allowed coin and limits for withdrawal size and frequency.
Rust
JSON
pub enum QueryMsg{
CoinAllowanceDetails {}
}
{
"coin_allowed_details":{}
}

Response

Returns a CoinAllowance struct.
Rust
JSON
pub struct CoinAllowance {
pub coin: String,
pub limit: Uint128,
pub minimal_withdrawal_frequency: Uint128,
}
{
"coin":"ujuox",
"limit":"50000",
"minimal_withdrawal_frequency":"3600"
}
Name
Type
Description
coin
string
The coin denom.
limit
Uint128
The amount allowed to withdraw per withdrawal.
minimal_withdrawal_frequency
Uint128
The time required between withdrawals. Specified in seconds.

AccountDetails

Shows the balance and latest withdrawal time.
Rust
JSON
pub enum QueryMsg{
AccountDetails {
account: String,
}
}
{
"account_details":{
"account":"juno1..."
}
}
Name
Type
Description
account
String
The address to check the account for.

Response

Returns an AccountDetails struct.
Rust
JSON
pub struct AccountDetails {
pub balance: Uint128,
pub latest_withdrawal: Option<Timestamp>,
}
{
"balance":"100000",
"latest_withdrawal":"1658744585559151746"
}
Name
Type
Description
balance
Uint128
The balance of the specified address.
latest_withdrawal
Option<Timestamp>
The time of the last withdrawal of the specified address.

AndrQuery

Check AndrQuery.
Copy link
Outline
Introduction
InstantiateMsg
ExecuteMsg
Deposit
Withdraw
AndrReceive
QueryMsg
CoinAllowanceDetails
AccountDetails
AndrQuery