How to apply limits to a wallet
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
Or using the ledger sdk
Limit evaluation and atomicity
Keeping in mind that an intent (set of claims) is atomic - checks like balance limits (by default balance cannot go under 0) are applied having taken the cumulative claims of an intent in mind.
Because of this, even if one claim brings a wallet below or above their limit, if there's another claim in the same intent that brings it back within normal range, the intent will not break the limit and will succeed.
Available metrics for limiting
This is a list of available metrics for use in limit claims. Some of them might not be enabled by default and require a change of specific ledger config entries to enable for a ledger. Some configs might not be enabled server-wide, depending on which environment (shared, dedicated, test) you use.
Name | Description | Default | Config to enable | Enabled by default |
---|---|---|---|---|
minBalance | Lowest balance this wallet can hold | 0 | N/A | Yes |
maxBalance | Highest balance this wallet can hold | N/A | N/A | Yes |
dailyCount | Maximal number of transfers this wallet can do in a 24 hours timeframe | N/A | limits.aggregated.enabled | No |
dailyAmount | Maximal cumulative amount this wallet can transfer in a 24 hours timeframe. This includes both receiving and sending. | N/A | limits.aggregated.enabled | No |