Rate Limiting Withdrawals
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
Rust
JSON
pub struct InstantiateMsg {
pub allowed_coin: CoinAndLimit,
pub minimal_withdrawal_frequency: MinimumFrequency,
pub modules: Option<Vec<Module>>,
}
{
"allowed_coin":{
"coin":"uandr",
"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. |
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. |
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.
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. |
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":"andr1..."
}
}
Name | Type | Description |
---|---|---|
recipient | Option<String> | The owner of the deposited funds. If not set, defaults to the sender. |
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. |
Uses the modules feature.
Provides the allowed coin and limits for withdrawal size and frequency.
Rust
JSON
pub enum QueryMsg{
#[returns(CoinAllowance)]
CoinAllowanceDetails {}
}
{
"coin_allowed_details":{}
}
Returns a CoinAllowance struct.
Rust
JSON
pub struct CoinAllowance {
pub coin: String,
pub limit: Uint128,
pub minimal_withdrawal_frequency: Uint128,
}
{
"coin":"uandr",
"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. |
Shows the balance and latest withdrawal time.
Rust
JSON
pub enum QueryMsg{
#[returns(AccountDetails)]
AccountDetails {
account: String,
}
}
{
"account_details":{
"account":"andr1..."
}
}
Name | Type | Description |
---|---|---|
account | String | The address to check the account for. |
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. |
Last modified 3mo ago