import { AccountAddress, CommittedTransactionResponse, Ed25519Account } from "@aptos-labs/ts-sdk"; import { AptosContractWrapperBaseClass } from "./baseClass"; import { AptosProvider } from "./aptosProvider"; import { PeripheryContract } from "../contracts/periphery"; /** * Represents the configuration for pulling rewards transfer strategy. * * @property {AccountAddress} rewardsAdmin - The address of the rewards admin. * @property {AccountAddress} incentivesController - The address of the incentives controller. * @property {AccountAddress} rewardsVault - The address of the rewards vault. */ export type PullRewardsTransferStrategy = { rewardsAdmin: AccountAddress; incentivesController: AccountAddress; rewardsVault: AccountAddress; }; /** * Represents the data for a reward configuration. * * @property {bigint} index - The current index of the reward. * @property {bigint} emissionPerSecond - The emission rate per second. * @property {bigint} lastUpdateTimestamp - The timestamp of the last update. * @property {bigint} distributionEnd - The timestamp when distribution ends. * @property {Map} usersData - Map of user addresses to their reward data. */ export type RewardData = { index: bigint; emissionPerSecond: bigint; lastUpdateTimestamp: bigint; distributionEnd: bigint; usersData: Map; }; /** * Represents the data for a user's rewards. * * @property {bigint} index - The user's current index. * @property {bigint} accrued - The amount of rewards accrued by the user. */ export type UserData = { index: bigint; accrued: bigint; }; /** * Represents the balance information for a user's asset. * * @property {AccountAddress} asset - The address of the asset. * @property {bigint} userBalance - The user's balance of the asset. * @property {bigint} totalSupply - The total supply of the asset. */ export type UserAssetBalance = { asset: AccountAddress; userBalance: bigint; totalSupply: bigint; }; /** * Represents the data for an asset's rewards configuration. * * @property {Map} rewards - Map of reward addresses to their data. * @property {Map} availableRewards - Map of reward indices to their addresses. * @property {bigint} availableRewardsCount - The number of available rewards. * @property {number} decimals - The number of decimals for the asset. */ export type AssetData = { rewards: Map; availableRewards: Map; availableRewardsCount: bigint; decimals: number; }; /** * The `RewardsControllerClient` class provides methods to interact with the Rewards Controller contract on the Aptos blockchain. * It extends the `AptosContractWrapperBaseClass` and includes functionalities for managing rewards, claiming rewards, * and retrieving reward-related data within the AAVE protocol. * * @remarks * This client is designed to work with the Rewards Controller contract and provides a high-level API for reward operations. * The client can be instantiated in two ways: * 1. Using the constructor directly with a provider and optional signer * 2. Using the static buildWithDefaultSigner method which automatically configures the client with the provider's pool profile account * * @example * ```typescript * // Using buildWithDefaultSigner * const provider = new AptosProvider(); * const client = RewardsControllerClient.buildWithDefaultSigner(provider); * * // Using constructor directly * const provider = new AptosProvider(); * const signer = provider.getPoolProfileAccount(); * const client = new RewardsControllerClient(provider, signer); * * // Claim rewards for specific assets * const tx = await client.claimRewards( * [assetAddress], * 1000n, * recipientAddress, * rewardAddress, * rewardsControllerAddress * ); * ``` * * @param provider - The AptosProvider instance used to interact with the Aptos blockchain. * @param signer - Optional Ed25519Account signer for transaction signing. */ export declare class RewardsControllerClient extends AptosContractWrapperBaseClass { peripheryContract: PeripheryContract; /** * Creates an instance of RewardsControllerClient. * * @param provider - The Aptos blockchain provider. * @param signer - Optional Ed25519 account signer. */ constructor(provider: AptosProvider, signer?: Ed25519Account); /** * Creates an instance of RewardsControllerClient using the default signer from the provided AptosProvider. * * @param provider - The AptosProvider instance to use for creating the RewardsControllerClient. * @returns A new instance of RewardsControllerClient. */ static buildWithDefaultSigner(provider: AptosProvider): RewardsControllerClient; /** * Gets the address of the rewards controller * * @returns The address of the rewards controller */ rewardsControllerAddress(): Promise; /** * Gets the rewards controller object * * @returns The rewards controller object */ rewardsControllerObject(): Promise; /** * Gets the claimer for a user * * @param user - The user address * @param rewardsControllerAddress - The address of the rewards controller * @returns The claimer address if one exists */ getClaimer(user: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; getRewardOracle(): Promise; /** * Gets the pull rewards transfer strategy for a reward * * @param reward - The reward address * @param rewardsControllerAddress - The address of the rewards controller * @returns The pull rewards transfer strategy if one exists */ getPullRewardsTransferStrategy(reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims rewards for a user * @param assets Vector of asset addresses * @param amount The amount of rewards to claim * @param to The address to which rewards are transferred * @param reward The address of the reward * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing the amount of rewards claimed */ claimRewards(assets: Array, amount: bigint, to: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims rewards on behalf of a user * @param assets Vector of asset addresses * @param amount The amount of rewards to claim * @param user The address of the user * @param to The address to which rewards are transferred * @param reward The address of the reward * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing the amount of rewards claimed */ claimRewardsOnBehalf(assets: Array, amount: bigint, user: AccountAddress, to: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims rewards and transfers them to the caller * @param assets Vector of asset addresses * @param amount The amount of rewards to claim * @param reward The address of the reward * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing the amount of rewards claimed */ claimRewardsToSelf(assets: Array, amount: bigint, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims all rewards for a user * @param assets Vector of asset addresses * @param to The address to which rewards are transferred * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing a tuple of reward addresses and their corresponding amounts */ claimAllRewards(assets: Array, to: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims all rewards on behalf of a user * @param assets Vector of asset addresses * @param user The address of the user * @param to The address to which rewards are transferred * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing a tuple of reward addresses and their corresponding amounts */ claimAllRewardsOnBehalf(assets: Array, user: AccountAddress, to: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Claims all rewards and transfers them to the caller * @param assets Vector of asset addresses * @param rewardsControllerAddress The address of the rewards controller * @returns The transaction response containing a tuple of reward addresses and their corresponding amounts */ claimAllRewardsToSelf(assets: Array, rewardsControllerAddress: AccountAddress): Promise; /** * Looks up asset data for a specific asset * * @param asset - The asset address * @param rewardsControllerAddress - The address of the rewards controller * @returns The asset data if it exists */ lookupAssetData(reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Looks up rewards data for a specific asset and reward. * * @param asset - The address of the asset. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to an object containing: * - assetData: Asset configuration data * - rewardData: Reward configuration data * Both fields will be undefined if their respective data doesn't exist. */ lookupRewardsData(asset: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise<{ assetData?: AssetData; rewardData?: RewardData; }>; /** * Retrieves the global reward data for a given asset and reward token from the Rewards Controller contract. * * @param asset - The address of the asset for which to fetch reward data. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to a `RewardData` object containing the global reward data. The `usersData` field will be an empty map. */ getRewardsData(asset: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets user data for a specific asset, reward, and user. * * @param asset - The address of the asset. * @param reward - The address of the reward token. * @param user - The address of the user. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to a UserData object containing the user's index and accrued rewards as u256 values. * If no user data exists, returns {index: 0n, accrued: 0n}. */ getUserData(asset: AccountAddress, reward: AccountAddress, user: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets the asset index for a specific asset and reward. * * @param asset - The address of the asset. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to a tuple containing the current asset index and new asset index as u256 values. * If no rewards data exists, returns [0, 0]. */ getAssetIndex(asset: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise<[bigint, bigint]>; /** * Gets the distribution end timestamp for a specific asset and reward. * * @param asset - The address of the asset. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to the distribution end timestamp as a u256 value. */ getDistributionEnd(asset: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets all rewards for a specific asset. * * @param asset - The address of the asset. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to an array of reward token addresses. * If no rewards data exists for the asset, returns an empty array. */ getRewardsByAsset(asset: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets all available rewards from the rewards controller. * * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to an array of reward token addresses. * If no rewards controller data exists, returns an empty array. */ getRewardsList(rewardsControllerAddress: AccountAddress): Promise; /** * Gets the user asset index for a specific user, asset, and reward. * * @param user - The address of the user. * @param asset - The address of the asset. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to the user's asset index as a u256 value. */ getUserAssetIndex(user: AccountAddress, asset: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets the total accrued rewards for a specific user and reward across all assets. * * @param user - The address of the user. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to the total accrued rewards as a u256 value. * If no rewards controller data exists, returns 0. */ getUserAccruedRewards(user: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets the total rewards for a user across multiple assets for a specific reward token. * * @param assets - Array of asset addresses to check rewards for. * @param user - The address of the user. * @param reward - The address of the reward token. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to the total rewards as a u256 value. */ getUserRewards(assets: AccountAddress[], user: AccountAddress, reward: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; /** * Gets all rewards for a user across multiple assets. * * @param assets - Array of asset addresses to check rewards for. * @param user - The address of the user. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to a tuple containing: * - Array of reward token addresses * - Array of corresponding reward amounts as u256 values * If no rewards controller data exists, returns [[], []]. */ getAllUserRewards(assets: AccountAddress[], user: AccountAddress, rewardsControllerAddress: AccountAddress): Promise<[AccountAddress[], bigint[]]>; /** * Gets the number of decimals for a specific asset. * * @param asset - The address of the asset. * @param rewardsControllerAddress - The address of the rewards controller. * @returns A promise that resolves to the number of decimals as a number. */ getAssetDecimals(asset: AccountAddress, rewardsControllerAddress: AccountAddress): Promise; }