Skip to Content
General ConceptsPrice Adapters

Price Adapters

Price adapters provide on-chain price conversion, enabling the Roles Modifier to reason about values across different token denominations.

Use Cases

Denominated Allowances

Allowances track spending limits as raw token amounts. When a role needs a unified spending cap across multiple tokens (for example, a USD-denominated budget that applies to both USDC and WETH transfers), a price adapter converts each token amount into the shared denomination before checking and consuming the allowance.

This makes it possible to define a single allowance that covers transactions involving different assets, without requiring a separate allowance for each token.

Ratio Validation and Slippage Protection

Price adapters also support the WithinRatio condition operator. This operator compares two values (for example, the input and output amounts of a swap) and checks that their ratio falls within an acceptable range.

By consulting a price adapter, WithinRatio can normalize the two amounts to a common unit before comparing them. This enables slippage protection: a condition can enforce that the value received from a swap is within a specified percentage of the value sent.

How It Works

A price adapter is a contract that exposes a price conversion interface. When the Roles Modifier encounters a condition that requires price conversion, it calls the configured price adapter to translate the value in scope to the target denomination.

The adapter is responsible for sourcing the exchange rate — typically from an on-chain oracle — and returning the converted amount. Different adapter implementations can integrate with different oracle systems (e.g., Chainlink, Uniswap TWAP) depending on the requirements of the deployment.

Last updated on