The Spend Limit Authenticator is the first CosmWasm authenticator for Osmosis’s Smart Accounts functionality, offering enhanced security and control. As we continue to innovate, features like these will provide users with a seamless and secure trading experience.
The Spend Limit Authenticator lets users set a spend limit on their account.
When implemented in applications, spend limit authenticators should only be used as part of an AllOf authenticator with a SignatureVerification authenticator.
Overview
Each Spend Limit Authenticator utilizes specific parameters called SpendLimitParams. These parameters are stored in the module state and passed to hooks to enforce the spend limit.
Global configurations and states are maintained in the contract state.
Tokens that have high liquidity will not reduce the spend limit total. (e.g OSMO ≤≥ ATOM) These tokens are decided when the contract is instantiated.
Transaction Process
The authenticator checks if transaction amounts are within the spend limit. If the amount exceeds the limit, the transaction is rejected. Here’s how it works:
- Authentication: Always marked as
Authenticated
in theAuthenticate
hook, with spend limit checks in theConfirmExecution
hook. - Tracking Pre-Execution Balances: The
Track
hook records pre-execution balances. - Confirming Execution: The
ConfirmExecution
hook checks post-execution balances, determining the transaction amount by the difference. - Converting Spent Amount: Amounts spent are converted into quoted denominations using TWAP prices.
- Enforcing Limits: Transactions exceeding the spend limit are rejected; otherwise, they are accepted and spending is accumulated.
Upload path
The spend limit authenticator contract will be uploaded using the Osmosis foundation key approved in Proposal 775.
Github
For more details, visit our GitHub repository and join the discussion in this forum.
Feel free to ask any questions or provide feedback below!