Skip to main content
The Spending Limit Policy enables Vincent App Users to set daily USD spending limits that restrict how much value Vincent Apps can spend on their behalf. This policy provides financial controls and risk management for DeFi operations by tracking and enforcing spending limits across all supported Vincent Abilities.

Key Features

  • Daily USD Limits: Set maximum daily spending amounts in USD, with rolling 24-hour windows
  • Real-time USD Conversion: Automatically converts token amounts to USD using Uniswap quotes and Chainlink price feeds
  • Multi-Chain Support: Works across any EVM-compatible network supported by Uniswap
  • Blockchain-Enforced Tracking: Records all spending to an on-chain contract for transparent, tamper-proof tracking
  • Per-App Isolation: Spending limits are tracked separately for each Vincent App to prevent cross-app interference

How It Works

The Spending Limit Policy is built using the Vincent Policy SDK and operates through a three-phase validation and tracking system:
1

Precheck Phase

Validates proposed spending against current limits:
  • Calculates the USD value of the token transaction using Uniswap to quote the token amount in ETH, and then uses Chainlink price feeds to convert the ETH amount to USD
  • Checks the calculated USD spend amount against the Vincent App User’s configured daily spending limit
  • Returns allow/deny decision with spending details for validation
2

Evaluate Phase

Re-validates spending during ability execution:
  • Performs the same USD calculation and Spending Limit validation as precheck
  • Ensures spending limits are still valid at execution time
3

Commit Phase

Records the actual spend to the blockchain:
  • Submits a transaction to the Lit Chronicle Yellowstone blockchain to record the spent amount of USD in the Spending Limit contract
  • Returns the transaction hash of the spending update transaction

Getting Started

Depending on your role in the Vincent Ecosystem, you’ll be interacting with this Policy in different ways. Click on the link below that matches your role to see how to get started with this Policy:
  • Vincent App Managers: If you’ve created or are creating a Vincent App and you want to enable this Policy for your users to govern the execution of Vincent Abilities, go here.
  • Vincent App Delegatees: If you are a delegatee of a Vincent App that has a Vincent Ability enabled that supports this Policy, go here.
  • Vincent Ability Developers: If you’ve created or are creating a Vincent Ability and you want to support this Policy, go here.

Adding the Policy to your Vincent App

Your Vincent App can only enable this Policy for Abilities that have been specifically configured to support it. Each Ability must be individually configured—having one compatible Ability doesn’t automatically enable this Policy for all Abilities in your App. If the Abilities your App uses have not been configured to support this Policy, you can contact the developers of those Abilities to request that they do so, or you can fork their code and enable the Policy yourself (also see the Ability Quickstart Guide to learn more about how to create your own Vincent Ability).

Executing a Vincent Ability that Supports this Policy

If you are a Delegatee to a Vincent App that has a Vincent Ability enabled that supports this Policy, there are several important considerations for executing Vincent Abilities on behalf of your users.

What’s the Spending Limit

Vincent App Users set the daily spending limit for each Vincent App that has this Policy enabled for a Vincent Ability. If multiple Vincent Abilities that support this are enabled for a Vincent App, the spending limit is shared across all of them. Additionally, the App User can update the spending limit at any time, so you cannot rely on what the spending limit is when you execute an Ability on behalf of your users, and you should call the Vincent Ability’s precheck function to check the spending limit before executing any Ability.

Checking the Spending Limit

When you execute an Ability’s precheck function, and the Vincent User has enabled this Policy for the Ability, the precheck function of this Policy will also execute. This Policy’s precheck function will perform the same validation as the actual execution of the Policy, which will convert the token buy amount to ETH, then use Chainlink to convert the ETH amount to USD, and then check the calculated USD spend amount against the Vincent App User’s daily spending limit for the Vincent App you’re a Delegatee of.
  • Allow Response
  • Deny Response
If the proposed token buy amount is within the Vincent App User’s daily spending limit, the precheck function will return an Allow Response with the structure:
{
  /**
   * The user's maximum daily spending limit in USD
   */
  maxSpendingLimitInUsd: number;
  /**
   * The calculated USD value of the proposed token buy amount
   */
  buyAmountInUsd: number;
}

The Policy’s evaluate Function

When you execute an Ability’s execute function, and the Vincent User has enabled this Policy for the Ability, the evaluate function of this Policy will also execute. This Policy’s evaluate function will perform the same validation as precheck function, returning the same Allow and Deny responses. If a Deny response is returned, the Ability’s execute function will cease execution and return a Failure response.

Supporting this Policy in your Vincent Ability

If you’d like to provide the users of your Vincent Ability with spending limit controls, you can integrate this Policy into your Ability.
  • Installation
  • Configuration
  • Integration
Start by installing the @lit-protocol/vincent-policy-spending-limit package:
npm install --save @lit-protocol/vincent-policy-spending-limit

The Spending Limit Contract

Deployed to the Lit Chronicle Yellowstone blockchain blockchain at the address: 0x756fa449de893446b26e10c6c66e62ccabee908c, the Spending Limit contract tracks spending for each Vincent App User using a sliding window mechanism.

Contract Interface

The contract provides the following functions and events:
  • View Functions
  • State-Changing Functions
  • Events
  • Custom Errors
checkLimit
function checkLimit(address user, uint256 appId, uint256 amountToSpend, uint256 userMaxSpendLimit, uint256 duration) returns (bool)
  • Validates if a proposed spend would remain within the user’s spending limit
  • Returns true if the spend is allowed, false otherwise
getAppSpendHistory
function getAppSpendHistory(address user, uint256 appId, uint256 duration) returns (Spend[] memory history)
  • Retrieves detailed spending history for a specific Vincent App within a time window
  • Returns array of Spend structs with timestamp and runningSpend fields
getAppsSpentInDuration
function getAppsSpentInDuration(address user, uint256[] appIds, uint256 duration) returns (uint256)
  • Calculates total spent across multiple specified Vincent Apps within a time window
  • Returns the total amount in USD (8 decimal precision)
getTotalSpent
function getTotalSpent(address user, uint256 duration) returns (uint256)
  • Calculates total spent across ALL Vincent Apps for a user within a time window
  • Returns the total amount in USD (8 decimal precision)

Important Considerations

The Policy supports the networks supported by the @uniswap/sdk-core package where Uniswap V3 is deployed. Ensure the chainIdForUniswap corresponds to one of the supported networks.
Spending limits are enforced over a continuous 24-hour lookback window from the current time. As time moves forward, older transactions automatically fall outside the window and no longer count against the spending limit.
The Policy commit phase requires a transaction on the Lit Chronicle Yellowstone blockchain to record the spent amount of USD in the Spending Limit contract. The Vincent App User’s Vincent Wallet must have sufficient Lit test tokens to pay for the gas fee of the spending update transaction.Lit test tokens can be obtained from the Lit Testnet Faucet.
Common scenarios where spending limits may be exceeded or validation may fail:
  • Limit Exceeded: Transaction amount pushes daily spending over the configured limit
  • Uniswap Quote Failures: Unable to get token price quotes from Uniswap, this could be caused by the token not being supported by Uniswap, or there not being enough liquidity for a quote for the tokenInAddress / ETH pair
I