The Aave Ability enables Vincent Apps to interact with the Aave V3 lending protocol on behalf of Vincent Users. This allows Vincent Apps to provide comprehensive DeFi functionality including supplying assets as collateral, borrowing against collateral, repaying debt, and withdrawing assets.
The Aave Ability is built using the Vincent Ability SDK and operates in two phases:
Precheck Phase: Validates all prerequisites for the Aave operation
Execution Phase: Executes the Aave protocol operation
Depending on your role in the Vincent Ecosystem, you'll be interacting with this Ability in different ways. Click on the link below that matches your role to see how to get started:
If you want to enable your App Delegatees to perform Aave operations on behalf of your Vincent App Users, you can add this Ability to your App.
Adding Abilities to your Vincent App is done using the Vincent App Dashboard. Visit the Create Vincent App guide to learn more about how to add Abilities to your App during creation, or check out the Upgrading Your App guide to learn how to add Abilities to an existing App.
Note
To learn more about executing Vincent Abilities, see the Executing Abilities guide.
Before executing Aave operations, the following conditions must be met. You can use the Ability's precheck
function to check if these conditions are met, or you can check them manually.
The Vincent App User's Vincent Wallet must have enough native tokens (ETH, MATIC, etc.) to cover the transaction gas fees for the Aave operation.
For supply and repay operations, the Vincent App User's Vincent Wallet must have approved the Aave Pool contract to spend the tokens.
If your Vincent App has enabled the ERC20 Approval Ability, you can use it to handle submitting the approval transaction using the Vincent Wallet.
Each Aave operation has specific validation requirements that are checked during the precheck phase:
Supply Operation:
Withdraw Operation:
aToken
balance (Aave deposit receipts) to cover the withdrawalBorrow Operation:
1
for Stable Rate, 2
for Variable Rate)Repay Operation:
precheck
FunctionThis Ability's precheck
function validates all prerequisites for executing the specified Aave operation and provides detailed account information.
Before executing the precheck
function, you'll need to provide the following parameters for the Aave operation:
{
/**
* The AAVE operation to perform (supply, withdraw, borrow, repay)
*/
operation: 'supply' | 'withdraw' | 'borrow' | 'repay';
/**
* The token contract address for the operation
*/
asset: string;
/**
* The amount of tokens to use in the operation, as a string
*/
amount: string;
/**
* The blockchain network to perform the operation on
*/
chain: string;
/**
* Interest rate mode: 1 for Stable, 2 for Variable
* (required for borrow operations, optional for repay)
*/
interestRateMode?: 1 | 2;
/**
* Custom RPC URL (optional, uses default if not provided)
*/
rpcUrl?: string;
}
To execute precheck
, you'll need to:
VincentAbilityClient
using the getVincentAbilityClient
function (imported from @lit-protocol/vincent-app-sdk/abilityClient
)
bundledVincentAbility
object (imported from @lit-protocol/vincent-ability-aave
)ethersSigner
you'll be using to sign the request to Lit with your Delegatee private keyprecheck
functionVincentAbilityClient
instance to call the precheck
functionimport { getVincentAbilityClient } from '@lit-protocol/vincent-app-sdk/abilityClient';
import { bundledVincentAbility } from '@lit-protocol/vincent-ability-aave';
// Create ability client
const abilityClient = getVincentAbilityClient({
bundledVincentAbility: bundledVincentAbility,
ethersSigner: yourEthersSigner,
});
// Example: Supply WETH as collateral on Sepolia
const aaveParams = {
operation: 'supply' as const,
asset: '0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c', // WETH on Sepolia
amount: '0.01', // 0.01 WETH
chain: 'sepolia',
rpcUrl: 'https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY', // Optional for precheck
};
const precheckResult = await abilityClient.precheck(aaveParams, {
delegatorPkpEthAddress: '0x...', // The Vincent App User's Vincent Wallet address
});
if (precheckResult.success) {
const result = precheckResult.result;
console.log('Operation valid:', result.operationValid);
console.log('User balance:', result.userBalance);
console.log('Current allowance:', result.allowance);
console.log('Borrow capacity:', result.borrowCapacity);
console.log('Estimated gas:', result.estimatedGas);
} else {
// Handle different types of failures
if (precheckResult.runtimeError) {
console.error('Runtime error:', precheckResult.runtimeError);
}
if (precheckResult.schemaValidationError) {
console.error('Schema validation error:', precheckResult.schemaValidationError);
}
if (precheckResult.result) {
console.error('Aave precheck failed:', precheckResult.result.error);
}
}
A successful precheck
response will contain detailed validation information:
{
/**
* Whether the requested operation is valid
*/
operationValid: boolean;
/**
* Whether the specified asset is valid for the operation
*/
assetValid: boolean;
/**
* Whether the specified amount is valid
*/
amountValid: boolean;
/**
* The user's current balance of the specified asset
*/
userBalance?: string;
/**
* The current allowance approved for the AAVE contract
*/
allowance?: string;
/**
* The user's current borrow capacity in USD
*/
borrowCapacity?: string;
/**
* Estimated gas cost for the operation
*/
estimatedGas?: number;
/**
* Available markets and their addresses
*/
availableMarkets?: Record<string, string>;
/**
* List of supported blockchain networks
*/
supportedChains?: string[];
}
A failure precheck
response will contain:
{
/**
* A string containing the error message if the precheck failed
*/
error: string;
}
execute
FunctionThis Ability's execute
function performs the actual Aave protocol operation.
The execute
function expects the same parameters as the precheck
function (except rpcUrl
which is not allowed), and can be executed using the same VincentAbilityClient
instance:
// Remove rpcUrl for execute - chain parameter is used instead
const executeParams = {
operation: 'supply' as const,
asset: '0xC558DBdd856501FCd9aaF1E62eae57A9F0629a3c', // WETH on Sepolia
amount: '0.01', // 0.01 WETH
chain: 'sepolia',
};
const executeResult = await abilityClient.execute(executeParams, {
delegatorPkpEthAddress: '0x...', // The Vincent App User's Vincent Wallet address
});
if (executeResult.success) {
const result = executeResult.result;
console.log('Transaction hash:', result.txHash);
console.log('Operation:', result.operation);
console.log('Asset:', result.asset);
console.log('Amount:', result.amount);
console.log('Timestamp:', result.timestamp);
} else {
// Handle different types of failures
if (executeResult.runtimeError) {
console.error('Runtime error:', executeResult.runtimeError);
}
if (executeResult.schemaValidationError) {
console.error('Schema validation error:', executeResult.schemaValidationError);
}
if (executeResult.result) {
console.error('Aave execution failed:', executeResult.result.error);
}
}
A successful execute
response will contain:
{
/**
* The transaction hash of the executed operation
*/
txHash: string;
/**
* The type of AAVE operation that was executed
*/
operation: 'supply' | 'withdraw' | 'borrow' | 'repay';
/**
* The token address involved in the operation
*/
asset: string;
/**
* The amount of tokens involved in the operation
*/
amount: string;
/**
* The Unix timestamp when the operation was executed
*/
timestamp: number;
/**
* The interest rate mode used (1 for Stable, 2 for Variable)
*/
interestRateMode?: number;
}
A failure execute
response will contain:
{
/**
* A string containing the error message if the execution failed
*/
error: string;
}
The Aave Ability supports operations on the following networks where Aave V3 is deployed:
ethereum
polygon
avalanche
arbitrum
optimism
base
fantom
bnb
gnosis
scroll
metis
linea
zksync
sepolia
basesepolia
arbitrumsepolia
optimismsepolia
avalanchefuji
scrollsepolia
The amount
parameter should be specified in human-readable format (e.g., "1.5" for 1.5 tokens), not in wei or smallest units.
precheck
: You can provide either chain
or rpcUrl
execute
: Only chain
is allowed, rpcUrl
will cause an errorThis is a security feature to prevent RPC URL injection attacks.
The precheck function provides gas estimation, but actual gas usage may vary depending on network conditions.
Monitor your health factor when borrowing. A health factor below 1.0 triggers liquidation.
Important: The Vincent Aave Ability does not validate health factor during the precheck phase. While the ability fetches the Vincent App User's Vincent Wallet's account data (including health factor), it only validates borrowing capacity and does not proactively check if a borrow operation would result in an unhealthy position. Health factor validation occurs at the Aave protocol level during transaction execution, and may result in failed transactions.
Common failure scenarios include: