@contractjs/aave-v3
Version:
A TypeScript utility library for Aave V3 contracts.
107 lines • 4.88 kB
TypeScript
import { Address } from "ox";
import { PublicClient, TransactionReceipt, WalletClient } from "viem";
export type ReserveData = {
/**
* A bit-packed configuration map for the reserve (e.g., active/frozen status, borrowing enabled, LTV, liquidation threshold).
* Encoded as a ReserveConfigurationMap (uint256).
*/
configuration: bigint;
/**
* The cumulative liquidity index, used to calculate accrued interest for suppliers.
* Expressed in ray (divide by 1e27 for a human-readable value).
*/
liquidityIndex: bigint;
/**
* The current supply rate (APR) for liquidity providers.
* Expressed in ray (divide by 1e27 for a human-readable value).
*/
liquidityRate: bigint;
/**
* The cumulative variable borrow index, used to calculate accrued interest for variable-rate borrowers.
* Expressed in ray (divide by 1e27 for a human-readable value).
*/
variableBorrowIndex: bigint;
/**
* The current variable borrow rate (APR).
* Expressed in ray (divide by 1e27 for a human-readable value).
*/
currentVariableBorrowRate: bigint;
/**
* The current stable borrow rate (APR).
* Deprecated in Aave V3 (stable borrowing no longer supported); in V3.3+, this field is repurposed for tracking liquidity deficits (e.g., temporary negative liquidity).
* Expressed in ray (divide by 1e27 for a human-readable value).
*/
currentStableBorrowRate: bigint;
/**
* The timestamp of the last reserve update (e.g., when interest was last accrued).
* Expressed as a Unix timestamp (uint40).
*/
lastUpdateTimestamp: bigint;
/**
* The unique ID of the reserve within the pool (its position in the active reserves list).
* Note: This is uint16 in the contract ABI (not uint8 as in your current poolAbi—recommend fixing that to avoid parsing errors on chains with >255 reserves).
*/
id: number;
/**
* The address of the aToken (yield-bearing token minted to suppliers).
*/
aTokenAddress: Address.Address;
/**
* The address of the stable debt token (tracks stable-rate borrows).
* Deprecated in Aave V3; still present for backward compatibility.
*/
stableDebtTokenAddress: Address.Address;
/**
* The address of the variable debt token (tracks variable-rate borrows).
*/
variableDebtTokenAddress: Address.Address;
/**
* The address of the contract implementing the interest rate strategy for this reserve.
*/
interestRateStrategyAddress: Address.Address;
/**
* The scaled amount of interest accrued to the Aave treasury from this reserve.
* Expressed in ray (uint128; divide by 1e27 for a human-readable value).
*/
accruedToTreasury: bigint;
};
export type TransactionResult = {
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
};
export declare const getReserveData: (tokenAddress: Address.Address, publicClient: PublicClient) => Promise<ReserveData>;
export declare const getSupplyAprRate: (tokenAddress: Address.Address, publicClient: PublicClient) => Promise<number>;
export declare const getSupplyAprPercentage: (tokenAddress: Address.Address, publicClient: PublicClient) => Promise<number>;
export declare const getSupplyApyRate: (tokenAddress: Address.Address, publicClient: PublicClient) => Promise<number>;
export declare const getSupplyApyPercentage: (tokenAddress: Address.Address, publicClient: PublicClient) => Promise<number>;
export declare const supplyERC20: (tokenAddress: Address.Address, amount: bigint, walletClient: WalletClient, options?: {
onBehalfOf?: Address.Address;
referralCode?: number;
}) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
export declare const supplyETH: (amount: bigint, walletClient: WalletClient, options?: {
onBehalfOf?: Address.Address;
referralCode?: number;
}) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
export declare const withdrawERC20: (tokenAddress: Address.Address, amount: bigint, to: Address.Address, walletClient: WalletClient) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
export declare const withdrawAllERC20: (tokenAddress: Address.Address, walletClient: WalletClient) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
export declare const withdrawETH: (amount: bigint, to: Address.Address, walletClient: WalletClient) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
export declare const withdrawAllETH: (walletClient: WalletClient) => Promise<{
hash: `0x${string}`;
waitForReceipt: () => Promise<TransactionReceipt>;
}>;
//# sourceMappingURL=pool.d.ts.map