Minka Ledger Docs
How To Guides

How to apply limits to a wallet

DateResponsibleChanges
March 11, 2024@Omar MonterreyInitial version

Applying limits

A wallet can hold balance in multiple symbols. By default this balance is only limited to be at least 0. Limits allow wallets to have negative balance up to an specified amount or to have an upper limit, for example.

In order to apply limits to a wallet an intent with valid limit claims needs to be executed. For example, in order to allow wallet bank to have negative balance up to -200, for the symbol usd, the metric minBalance should be limited to -200 with an intent that looks like this:

For -200 usd the amount is -20000 because of a factor of 100

{
    "handle": "limiting-usd-in-bank-wallet",
    "claims": [
    {
        "action": "limit",
        "metric": "minBalance",
        "wallet": {
            "handle": "bank"
        },
        "symbol": {
            "handle": "usd"
        },
        "amount": -20000
    }
    ],
    "access": []
}

Or using the ledger sdk

import { AccessAction, ClaimAction, LedgerIntent } from "@minka/ledger-sdk/types";
 
const sdk = new LedgerSdk({
	server: "<server-url>",
	ledger: "<ledger-handle>",
});
 
const limitIntent: LedgerIntent = {
    handle: 'limiting-usd-in-bank-wallet',
    claims: [
    {
        action: ClaimAction.Limit,
        metric: LimitClaimMetric.MinBalance,
        wallet: {
            handle: 'bank',
        },
            symbol: {
            handle: 'usd',
        },
        amount: -20000,
    },
    ],
    access: [
    {
        action: AccessAction.Any,
    },
    ],
}
 
await sdk.intent
    .init()
    .data(limitIntent)
    .hash()
    .sign([{keyPair}])
    .send()

Available metrics for limiting

NameDescriptionDefault
minBalanceLowest balance this wallet can hold0
maxBalanceHighest balance this wallet can holdN/A
dailyCountMaximal number of transfers this wallet can do in a 24 hours timeframeN/A
dailyAmountMaximal cumulative amount this wallet can transfer in a 24 hours timeframe. This includes both receiving and sending.N/A

On this page