> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ana.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Values

> Amounts, percentages, trigger.value, arithmetic, value ranges, rounding, tokens per network, and the address and time forms of the rule language.

After you read this page, you can write every amount, range, address and instant that a rule needs, and you know how the engine computes the result.

## Where values occur

| Position | Form | Example |
| - | - | - |
| `send_one.value`, `send_batch` item `value`, `exchange.in`, `off_ramp.value` | [value expression](#value-expressions) | `"min(trigger.value * 20%, 100 USDC)"` |
| `incoming_tx.value`, `outgoing_tx.value` | [value range](#value-ranges) | `"100..1000 USDC"` |
| `exchange.out`, `price_crossed.token`, `fees_method.token`, allowlists | [token symbol](#token-symbols) | `WETH` |
| `price_crossed.price_usd` | number | `80000` |
| `agent_envelope.balance_floor`, `agent_envelope.per_tx_max` | `"<N> <TOKEN>"` | `"500 USDC"` |
| addresses | [address](#addresses) | `"0x1111111111111111111111111111111111111111"` |
| `off_ramp.to.iban`, `global.iban_allowlist` | [IBAN](#ibans) | `"DE89370400440532013000"` |
| `start`, `expiry`, `timestamps` | [instant](#instants) | `"2027-01-01T00:00:00Z"` |

## Value expressions

A value expression computes one amount of one token each time the action fires. Put it in double quotes.

### Atoms

| Atom | Form | Example | Unit |
| - | - | - | - |
| Amount | `<N> <TOKEN>` | `"100 USDC"`, `"0.5 WETH"` | an amount of that token |
| Percent | `<N>%`, no space before `%` | `"50%"`, `"0.5%"` | a percentage: `50%` is the ratio 0.5 |
| Number | `<N>` | `"2"`, `"1.5"` | a bare number |
| Trigger value | `trigger.value` | `"trigger.value"` | the amount of the transfer that fired the rule |
| Minimum | `min(<expr>, <expr>)` | `"min(trigger.value, 100 USDC)"` | the unit of its two arguments |
| Maximum | `max(<expr>, <expr>)` | `"max(trigger.value * 1%, 1 USDC)"` | the unit of its two arguments |
| Group | `(<expr>)` | `"(trigger.value - 1 USDC) * 50%"` | the unit of the inner expression |

`<N>` is a non-negative integer of at most 19 digits, or a decimal with at most 19 digits before the point and at most 18 after it. There is no sign: a negative literal is not valid.

`min` and `max` take exactly two arguments. Nest them for more: `"min(min(a, b), c)"`.

### Operators

| Operator | Meaning | Precedence | Associativity |
| - | - | - | - |
| `+` | sum | lowest | left |
| `-` | difference | lowest | left |
| `*` | product | higher | left |

Atoms bind tighter than `*`. So `"10 USDC + 100 USDC * 10%"` is 10 + 10 = 20 USDC.

The language has no division, no unary minus, no comparison and no condition. Use `* 50%` for "half", and `min` or `max` for a limit.

### Unit rules

Each expression has a unit. The engine checks the units before it stages the document. A percentage and a bare number are two different units.

| Expression | Rule | Result |
| - | - | - |
| `a + b`, `a - b`, `min(a, b)`, `max(a, b)` | Both sides must have the same unit. `"50% + 0.5"` is refused. | that unit |
| amount `*` percentage or bare number | Order does not matter. | the amount, scaled |
| percentage `*` percentage, percentage `*` bare number | Order does not matter. | a percentage |
| bare number `*` bare number | | a bare number |
| amount `*` amount | Refused. | none |

`trigger.value` without a range has an open unit. It joins any unit in `+`, `-`, `min` and `max`. Times a percentage, a bare number or another open value, it stays open. Times an amount, it is that amount. See [trigger.value](#triggervalue).

Examples of refusals:

| Expression | Refusal text |
| - | - |
| `"100 USDC + 50 USDT0"` | ``rule '<rule>': `+` operands must agree: left is amount of USDC, right is amount of USDT0`` |
| `"min(trigger.value, 100 USDT0)"` under a USDC range | ``rule '<rule>': `min` arms must agree: first is amount of USDC, second is amount of USDT0`` |
| `"100 USDC * 2 USDC"` | ``rule '<rule>': `*` cannot multiply two token-typed values (amount of USDC and amount of USDC)`` |
| `"50%"` as a `send_one` value | `rule '<rule>': send_one value must be a token amount; got percentage` |
| `"100"` as an `exchange` input | `rule '<rule>': exchange in value must be a token amount; got bare number` |

The result of an action value must be an amount. The same rule applies to `send_batch` items (`send_batch recipient value must be a token amount`) and to `exchange.in`. An `off_ramp.value` must be an amount of `EURe`. See [off\_ramp](https://docs.ana.fi/rules/actions.md#off_ramp).

### trigger.value

`trigger.value` is the amount and the token of the transfer that fired the rule.

| Rule | Detail |
| - | - |
| Triggers | Only `incoming_tx` and `outgoing_tx` supply it. In another rule it is refused with `'trigger.value' reads the amount of a matched transfer, so only an incoming_tx or outgoing_tx rule can use it`. |
| Field name | `value` is the only field. `trigger.amount` is refused with `unknown trigger field 'trigger.amount'; the only field is 'trigger.value'`. |
| With a range | The token of `trigger.value` is the token of the range. The engine checks each expression before staging. |
| Without a range | The token is not known until a transfer fires the rule. See below. |

Without a range, the token of `trigger.value` is the token of each transfer:

* `"trigger.value"` and `"trigger.value * 90%"` pay in whichever token arrived. These forms are safe.
* `"min(trigger.value, 100 USDC)"` validates. It runs only when the transfer is in `USDC`. For a transfer in another token, the engine records the fire and skips the action.
* `"trigger.value * 100 USDC"`, `"trigger.value * trigger.value"` and `"min(trigger.value, 50%) * 100 USDC"` validate, but every fire refuses them. The action always skips.

Give the trigger a range to decide each form before staging. With `value: "0.. USDC"`, the engine accepts `"min(trigger.value, 100 USDC)"` and refuses the other forms.

> [!TIP]
>
> Add a range to each transfer trigger whose actions mix `trigger.value` with a literal amount. `"0.. USDC"` watches every USDC transfer and fixes the token.

### What a value cannot contain

| Text | Refusal text |
| - | - |
| A variable: `"$budget"` or `"1 $token"` | `rule '<rule>': value expression names variable '$budget', but a variable stands only at an address or IBAN position: write the amount itself` |
| A bare token: `"USDC"` | `rule '<rule>': value expression: a bare token name is not a value: write an amount ("25 USDT") or trigger.value` |
| An unknown symbol: `"1 EUR"`, `"1 usdc"` | `rule '<rule>': unknown token 'EUR'` |
| An unknown operator: `"100 USDC / 2"` | `rule '<rule>': value expression: Invalid token at 9` |
| A negative literal: `"-1 USDC"` | A text that starts with `rule '<rule>': value expression: Unrecognized token` and names the `-` |
| More than 256 bytes | `rule '<rule>': value expression: value expression is <n> bytes, over the 256-byte limit` |

### How the engine computes a value

* Every number is a fixed-point value with 18 decimals.
* A product is exact, then the engine cuts the result to 18 decimals toward zero.
* A sum and a difference are exact. A result outside the range of the format stops at the largest value.
* The engine converts the result to the decimals of the token, toward zero. `USDC` has 6 decimals, so `"1 USDC * 33.3333333%"` pays 0.333333 USDC.
* A result below zero is refused at the fire. `"1 USDC - 5 USDC"` validates, and every fire refuses it.
* A zero `exchange` input is refused at the fire. Keep every amount above zero.
* An `off_ramp` amount computed at the fire is rounded down to whole cents.

### Fee floor for literal amounts

When an action value is only a literal amount, such as `value: "0.1 USDC"`, the stage compares it with the minimum Anafi fee. An amount at or below the fee floor is refused:

```text theme={null}
An amount of <amount> <TOKEN> or less is refused: the Anafi fee is at least $0.20
```

For a token that is not a dollar stablecoin, the stage converts \$0.20 with a current price. If no price is known, the stage refuses with `No price is known for <TOKEN>, so the Anafi fee cannot be computed`. An expression, such as `"trigger.value * 10%"`, is not checked at staging. See [Fees](https://docs.ana.fi/concepts/fees.md).

## Value ranges

A value range filters a transfer trigger by token and amount. It has exactly two parts, separated by a space: the bounds, then the token.

| Form | Example | Matches an amount `x` with |
| - | - | - |
| `<N> <TOKEN>` | `"100 USDC"` | `x = 100` |
| `<N>..<M> <TOKEN>` | `"100..1000 USDC"` | `100 ≤ x ≤ 1000` |
| `<N>.. <TOKEN>` | `"100.. USDC"` | `x ≥ 100` |
| `..<M> <TOKEN>` | `"..50 USDC"` | `x ≤ 50` |

Rules:

* Both bounds are inclusive.
* There is no space inside the bounds. `"1 .. 5 USDC"` is refused with `bad value range (expected '<N> <TOKEN>' or '<N>..<M> <TOKEN>') '1 .. 5 USDC'`.
* The lower bound must not be above the upper bound: `value range lower bound must be <= upper bound`.
* A bound is a number with at most 18 decimals. It is not an expression.
* `"0.. USDC"` means "any amount of USDC". It also fixes the token of `trigger.value`.
* Each network has a minimum transfer that can fire a rule, worth a fraction of a dollar. An amount below it never fires, whatever the range says.

## Token symbols

A token symbol is case-sensitive and names one asset. The language knows these 26 symbols:

`AAVE`, `ETH`, `EURC`, `EURe`, `frxUSD`, `LINK`, `OKB`, `PAXGy`, `POL`, `PYUSD`, `rsETH`, `sUSDe`, `uniBTC`, `USDC`, `USDC.e`, `USDe`, `USDG`, `USDT`, `USDT0`, `WBTC`, `WETH`, `wNVDAx`, `wSPYx`, `xBTC`, `xETH`, `xSOL`

Another symbol, or another letter case such as `usdc` or `XETH`, is refused with `unknown token '<symbol>'`. The fiat names `EUR`, `USD` and `GBP` are not tokens.

Some symbols are easy to confuse:

| Symbol | Meaning |
| - | - |
| `USDC` | The natively issued USDC of the network. |
| `USDC.e` | The USDC bridged from Ethereum on `polygon`. A different contract. It never stands in for `USDC`. |
| `USDT0` | Tether's omnichain USDT. Its contract calls itself `USD₮0`. |
| `EURe` | Monerium's euro. Not Circle's `EURC`. |
| `WETH` | Bridged ether on `polygon`. |
| `xETH`, `xBTC`, `xSOL` | The OKX xAssets on `xlayer`. |
| `wSPYx`, `wNVDAx` | The wrapped S\&P 500 and NVIDIA xStocks on `xlayer`. |
| `PAXGy` | A gold receipt on `xlayer`. |

### Tokens per network

A known symbol passes the parser on every network. The stage then refuses each symbol that the network does not have. The text is `<TOKEN> is not a token on <network name>.`, after `rule '<rule>': ` or `global.token_allowlist: `. On `polygon`, `USDT` gets the hint ` Did you mean USDT0?`.

These are the tokens that the engine moves on each network, with the decimals of each contract:

> [tab] polygon
>
> | Symbol | Kind | Decimals |
> | - | - | - |
> | `POL` | native coin | 18 |
> | `AAVE` | ERC-20 | 18 |
> | `EURe` | ERC-20 | 18 |
> | `LINK` | ERC-20 | 18 |
> | `USDC` | ERC-20 | 6 |
> | `USDC.e` | ERC-20 | 6 |
> | `USDT0` | ERC-20 | 6 |
> | `WBTC` | ERC-20 | 8 |
> | `WETH` | ERC-20 | 18 |

> [tab] xlayer
>
> | Symbol | Kind | Decimals |
> | - | - | - |
> | `OKB` | native coin | 18 |
> | `frxUSD` | ERC-20 | 18 |
> | `LINK` | ERC-20 | 18 |
> | `PAXGy` | ERC-20 | 18 |
> | `PYUSD` | ERC-20 | 6 |
> | `rsETH` | ERC-20 | 18 |
> | `sUSDe` | ERC-20 | 18 |
> | `uniBTC` | ERC-20 | 8 |
> | `USDC` | ERC-20 | 6 |
> | `USDe` | ERC-20 | 18 |
> | `USDG` | ERC-20 | 6 |
> | `USDT0` | ERC-20 | 6 |
> | `wNVDAx` | ERC-20 | 18 |
> | `wSPYx` | ERC-20 | 18 |
> | `xBTC` | ERC-20 | 8 |
> | `xETH` | ERC-20 | 18 |
> | `xSOL` | ERC-20 | 9 |

> [tab] polygon-amoy
>
> | Symbol | Kind | Decimals |
> | - | - | - |
> | `POL` | native coin | 18 |
> | `EURe` | ERC-20 | 18 |
> | `USDC` | ERC-20 | 6 |

`ETH` and `USDT` have no contract on any of the three networks. `WBTC` has a contract only on `polygon`. The contract addresses are on [Networks](https://docs.ana.fi/networks.md).

Write amounts in whole tokens, not in base units. `"1.5 USDC"` is 1500000 base units of USDC. A literal with more decimals than the token has is cut toward zero when the engine converts it.

## Addresses

An address position accepts two forms:

| Form | Example |
| - | - |
| `0x` and exactly 40 hex characters | `"0x1111111111111111111111111111111111111111"` |
| `$` and a variable name | `"$landlord"` |

Rules:

* Letter case is free. The language does not check the EIP-55 checksum.
* Comparisons for the zero address, the account itself, and `account` against `from` or `to` ignore letter case.
* The comparison with `global.recipient_allowlist` uses the exact text after the engine replaces each `$name`. Write each address in the same letter case in the allowlist and in the actions, or use one variable for both.
* Another text is refused with `bad address (expected 0x + 40 hex chars or $variable reference) '<value>'`.
* A `$name` must exist in `variables` (`undefined variable '$<name>'`) and hold an address (`variable '$<name>' is used as an address but its value '<value>' is not a 0x + 40-hex address`).

Put every address in double quotes. See [YAML scalar rules](https://docs.ana.fi/rules/document.md#yaml-scalar-rules).

## IBANs

An IBAN position accepts a canonical IBAN or a `$name` that holds one.

* Canonical means uppercase letters and digits, no spaces, 15 to 34 characters, two letters, two check digits, and correct check digits.
* `"DE89370400440532013000"` is valid. `"de89 3704 0044 0532 0130 00"` is not.
* A `$name` that holds another text is refused with `variable '$<name>' is used as an IBAN but its value '<value>' is not a canonical IBAN (uppercase, no spaces, valid check digits)`.

## Instants

`start`, `expiry`, `at_fixed_time.timestamps` and `agent_envelope.expiry` use RFC 3339:

| Example | Valid |
| - | - |
| `"2027-01-01T00:00:00Z"` | yes |
| `"2027-01-01T09:00:00+01:00"` | yes |
| `"2027-01-01T09:00:00.500Z"` | yes |
| `"2027-01-01"` | no: `bad ISO-8601 timestamp '2027-01-01'` |
| `"2027-01-01T09:00:00"` | no: it has no offset |

The `calendar` trigger uses `time_of_day` and an IANA `timezone` instead. See [calendar](https://docs.ana.fi/rules/triggers.md#calendar).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.