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.

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
// 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
);

The AptosProvider instance used to interact with the Aptos blockchain.

Optional Ed25519Account signer for transaction signing.

Hierarchy (View Summary)

Constructors

Properties

peripheryContract: PeripheryContract

Methods

  • Builds a transaction for the specified user, function, and arguments.

    Parameters

    • user: AccountAddress

      The account address of the user initiating the transaction.

    • functionId: `${string}::${string}::${string}`

      The identifier of the Move function to be called.

    • funcArgs: (EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes)[]

      An array of arguments for the entry function.

    • typeArgs: string[] = []

    Returns Promise<SimpleTransaction>

    A promise that resolves to a SimpleTransaction object.

  • Calls a view method on the Aptos blockchain.

    Type Parameters

    • T extends MoveValue[]

      The type of the return value, which extends an array of MoveValue.

    Parameters

    • functionId: `${string}::${string}::${string}`

      The identifier of the function to call.

    • funcArgs: (EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes)[]

      The arguments to pass to the function.

    • typeArgs: string[] = []

      Optional generic type arguments for the function (e.g. ["0x1::aptos_coin::AptosCoin"]).

    Returns Promise<T>

    • A promise that resolves to the result of the view method call.
  • Claims all rewards for a user

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • to: AccountAddress

      The address to which rewards are transferred

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing a tuple of reward addresses and their corresponding amounts

  • Claims all rewards on behalf of a user

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • user: AccountAddress

      The address of the user

    • to: AccountAddress

      The address to which rewards are transferred

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing a tuple of reward addresses and their corresponding amounts

  • Claims all rewards and transfers them to the caller

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing a tuple of reward addresses and their corresponding amounts

  • Claims rewards for a user

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • amount: bigint

      The amount of rewards to claim

    • to: AccountAddress

      The address to which rewards are transferred

    • reward: AccountAddress

      The address of the reward

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing the amount of rewards claimed

  • Claims rewards on behalf of a user

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • amount: bigint

      The amount of rewards to claim

    • user: AccountAddress

      The address of the user

    • to: AccountAddress

      The address to which rewards are transferred

    • reward: AccountAddress

      The address of the reward

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing the amount of rewards claimed

  • Claims rewards and transfers them to the caller

    Parameters

    • assets: AccountAddress[]

      Vector of asset addresses

    • amount: bigint

      The amount of rewards to claim

    • reward: AccountAddress

      The address of the reward

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<CommittedTransactionResponse>

    The transaction response containing the amount of rewards claimed

  • Funds an account with a specified amount.

    Parameters

    • account: AccountAddress

      The address of the account to be funded.

    • amount: bigint

      The amount to fund the account with, in bigint.

    Returns Promise<UserTransactionResponse>

    A promise that resolves to a UserTransactionResponse.

  • Retrieves the Aptos balance of a specified account.

    Parameters

    • account: Ed25519Account

      The Ed25519 account object.

    • accountAddress: AccountAddress

      The address of the account to retrieve the balance for.

    • OptionalversionToWaitFor: bigint

      (Optional) The specific version to wait for before retrieving the balance.

    Returns Promise<bigint>

    A promise that resolves to the balance of the account in bigint.

  • Gets all rewards for a user across multiple assets.

    Parameters

    • assets: AccountAddress[]

      Array of asset addresses to check rewards for.

    • user: AccountAddress

      The address of the user.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<[AccountAddress[], bigint[]]>

    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 [[], []].

  • Gets the number of decimals for a specific asset.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<number>

    A promise that resolves to the number of decimals as a number.

  • Gets the asset index for a specific asset and reward.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<[bigint, bigint]>

    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].

  • Gets the claimer for a user

    Parameters

    • user: AccountAddress

      The user address

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<AccountAddress>

    The claimer address if one exists

  • Gets the distribution end timestamp for a specific asset and reward.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<bigint>

    A promise that resolves to the distribution end timestamp as a u256 value.

  • Retrieves events associated with a specific account.

    Parameters

    • account: AccountAddress

      The address of the account to retrieve events for.

    • limit: number

      The maximum number of events to retrieve.

    Returns Promise<
        {
            account_address: string;
            creation_number: any;
            data: any;
            event_index: any;
            indexed_type: string;
            sequence_number: any;
            transaction_block_height: any;
            transaction_version: any;
            type: string;
        }[],
    >

    A promise that resolves to an array of event objects, each containing:

    • account_address: The address of the account.
    • creation_number: The creation number of the event.
    • data: The data associated with the event.
    • event_index: The index of the event.
    • sequence_number: The sequence number of the event.
    • transaction_block_height: The block height of the transaction.
    • transaction_version: The version of the transaction.
    • type: The type of the event.
    • indexed_type: The indexed type of the event.
  • Gets the pull rewards transfer strategy for a reward

    Parameters

    • reward: AccountAddress

      The reward address

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<PullRewardsTransferStrategy>

    The pull rewards transfer strategy if one exists

  • Gets all rewards for a specific asset.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<AccountAddress[]>

    A promise that resolves to an array of reward token addresses. If no rewards data exists for the asset, returns an empty array.

  • Retrieves the global reward data for a given asset and reward token from the Rewards Controller contract.

    Parameters

    • asset: AccountAddress

      The address of the asset for which to fetch reward data.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<RewardData>

    A promise that resolves to a RewardData object containing the global reward data. The usersData field will be an empty map.

  • Gets all available rewards from the rewards controller.

    Parameters

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<AccountAddress[]>

    A promise that resolves to an array of reward token addresses. If no rewards controller data exists, returns an empty array.

  • Retrieves the events associated with a given transaction hash.

    Parameters

    • txHash: HexInput

      The hash of the transaction to retrieve events for.

    Returns Promise<{ data: unknown }[]>

    A promise that resolves to an array of objects containing the event data.

    This method fetches the transaction details using the provided Aptos provider. It then checks if the transaction response is of type BlockMetadataTransactionResponse or UserTransactionResponse to extract the events. The event data is parsed from JSON and returned in an array.

  • Gets the total accrued rewards for a specific user and reward across all assets.

    Parameters

    • user: AccountAddress

      The address of the user.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<bigint>

    A promise that resolves to the total accrued rewards as a u256 value. If no rewards controller data exists, returns 0.

  • Gets the user asset index for a specific user, asset, and reward.

    Parameters

    • user: AccountAddress

      The address of the user.

    • asset: AccountAddress

      The address of the asset.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<bigint>

    A promise that resolves to the user's asset index as a u256 value.

  • Gets user data for a specific asset, reward, and user.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • reward: AccountAddress

      The address of the reward token.

    • user: AccountAddress

      The address of the user.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<UserData>

    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}.

  • Gets the total rewards for a user across multiple assets for a specific reward token.

    Parameters

    • assets: AccountAddress[]

      Array of asset addresses to check rewards for.

    • user: AccountAddress

      The address of the user.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<bigint>

    A promise that resolves to the total rewards as a u256 value.

  • Looks up asset data for a specific asset

    Parameters

    • reward: AccountAddress
    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller

    Returns Promise<PullRewardsTransferStrategy>

    The asset data if it exists

  • Looks up rewards data for a specific asset and reward.

    Parameters

    • asset: AccountAddress

      The address of the asset.

    • reward: AccountAddress

      The address of the reward token.

    • rewardsControllerAddress: AccountAddress

      The address of the rewards controller.

    Returns Promise<{ assetData?: AssetData; rewardData?: RewardData }>

    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.

  • Gets the address of the rewards controller

    Returns Promise<AccountAddress>

    The address of the rewards controller

  • Gets the rewards controller object

    Returns Promise<AccountAddress>

    The rewards controller object

  • Sends a transaction and awaits the response.

    Parameters

    • functionId: `${string}::${string}::${string}`

      The ID of the Move function to be called.

    • funcArgs: (EntryFunctionArgumentTypes | SimpleEntryFunctionArgumentTypes)[]

      An array of arguments for the entry function.

    • typeArgs: string[] = []

    Returns Promise<CommittedTransactionResponse>

    A promise that resolves to the committed transaction response.