@aave/aave-v3-aptos-ts-sdk - v0.0.48
    Preparing search index...

    Class AptosConfigurator

    Index

    Constructors

    • Constructs an instance of the AptosConfigurator.

      Parameters

      • config: AptosProviderConfig

        The configuration for the Aptos provider.

      • poolPK: string

        The private key for the pool account.

      • oraclePK: string

        The private key for the oracle account.

      • ratePK: string
      • underlyingTokensPK: string

        The private key for the underlying tokens account.

      • Optionalmnemonic: string

        An optional mnemonic for the account.

      Returns AptosConfigurator

    Properties

    interestRateClient: InterestRateClient
    mnemonic?: string
    oracleClient: OracleClient
    poolClient: PoolClient
    provider: AptosProvider
    underlyingTokenClient: UnderlyingTokensClient

    Methods

    • Configures multiple reserves with the provided configuration settings.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each including the account address and various reserve parameters.

      Returns Promise<undefined>

      A promise that resolves to undefined when all reserves have been configured.

      This method sequentially configures each reserve by setting its collateral parameters, reserve factor, borrow cap, supply cap, borrowing enabled status, and flash loaning enabled status using the poolClient instance.

      const reservesConfig = [
      {
      address: '0x1',
      ltv: 75,
      liquidationThreshold: 80,
      liquidationBonus: 5,
      reserveFactor: 10,
      borrowCap: 1000,
      supplyCap: 2000,
      borrowingEnabled: true,
      flashloanEnabled: false,
      },
      // more reserve configurations
      ];
      await configReserves(reservesConfig);
    • Creates tokens based on the provided configuration and returns an array of tokens with their associated account addresses.

      Type Parameters

      • T extends TokenConfig

        The type of the token configuration.

      Parameters

      • tokens: T[]

        An array of token configurations.

      Returns Promise<WithAccountAddress<T>[]>

      A promise that resolves to an array of tokens with their associated account addresses.

    • Generates an Ed25519 account from a mnemonic and funds it with a specified amount.

      Parameters

      • index: number

        The index to derive the account from the mnemonic.

      Returns Promise<Ed25519Account>

      • A promise that resolves to the generated and funded Ed25519 account.
      • Throws an error if the mnemonic is not provided.
    • Sets the price of multiple assets using the oracle client.

      Parameters

      • assets: AssetPriceConfig[]

        An array of asset price configurations. Each configuration includes the asset's address, symbol, and price in the market reference currency.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses. Each response contains details about the transaction that set the asset's price.

    • Sets the EMode configuration for the pool.

      Parameters

      • eMode: EModeConfig

        The configuration object for EMode.

      Returns Promise<CommittedTransactionResponse>

      • A promise that resolves to the transaction response.
      const eModeConfig = {
      categoryId: 1,
      ltv: 75,
      liquidationThreshold: 80,
      liquidationBonus: 5,
      oracle: '0xOracleAddress',
      label: 'Stablecoins'
      };

      const receipt = await setEMode(eModeConfig);
      console.log(`Transaction hash: ${receipt.hash}`);
    • Sets multiple E-Modes by calling the setEMode method for each EModeConfig in the provided array.

      Parameters

      • eModes: EModeConfig[]

        An array of EModeConfig objects to be set.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of CommittedTransactionResponse objects, each representing the result of setting an E-Mode.

    • Sets the reserve interest rate strategy for a given asset.

      Parameters

      • strategy: ReserveStrategyConfig

        The configuration object for the reserve strategy.

      Returns Promise<CommittedTransactionResponse>

      A promise that resolves to the committed transaction response.

      const strategyConfig: ReserveStrategyConfig = {
      address: '0x...',
      optimalUsageRatio: 0.8,
      baseVariableBorrowRate: 0.02,
      variableRateSlope1: 0.04,
      variableRateSlope2: 0.75,
      symbol: 'DAI'
      };

      const receipt = await setReserveInterestRateStrategy(strategyConfig);
      console.log(`Transaction hash: ${receipt.hash}`);
    • Sets the active status of multiple reserves.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and reserve configuration details.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      const reservesConfig = [
      { address: '0x1', symbol: 'RESERVE1', active: true },
      { address: '0x2', symbol: 'RESERVE2', active: false },
      ];
      const receipts = await aptosConfigurator.setReservesActive(reservesConfig);
      console.log(receipts);
    • Sets the borrowable in isolation status for a list of reserves.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and the borrowable in isolation status.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      const reservesConfig = [
      { address: '0x...', borrowableInIsolation: true, symbol: 'USDC' },
      { address: '0x...', borrowableInIsolation: false, symbol: 'DAI' },
      ];
      const receipts = await setReservesBorrowableInIsolation(reservesConfig);
      console.log(receipts);
    • Sets the debt ceiling for a list of reserves if the current debt ceiling is different from the desired one.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and the desired debt ceiling.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      This method iterates over the provided reserve configurations and checks the current debt ceiling for each reserve. If the current debt ceiling is different from the desired debt ceiling, it updates the debt ceiling and logs the transaction.

      const reservesConfig = [
      { address: '0x1', debtCeiling: 1000, symbol: 'RESERVE1' },
      { address: '0x2', debtCeiling: 2000, symbol: 'RESERVE2' },
      ];
      const receipts = await aptosConfigurator.setReservesDebtCeiling(reservesConfig);
      console.log(receipts);
    • Sets the eMode category for a list of reserves.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and eMode category ID.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      const reservesConfig = [
      { address: '0x...', eModeCategoryId: 1, symbol: 'ETH' },
      { address: '0x...', eModeCategoryId: 2, symbol: 'DAI' },
      ];
      const receipts = await setReservesEModeCategory(reservesConfig);
      console.log(receipts);
    • Sets the freeze status for multiple reserves.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and reserve configuration details.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      const reservesConfig = [
      { address: '0x1', symbol: 'USDC', freezed: true },
      { address: '0x2', symbol: 'DAI', freezed: false },
      ];
      const receipts = await aptosConfigurator.setReservesFreezed(reservesConfig);
      console.log(receipts);
    • Sets the interest rate strategy for multiple reserves.

      Parameters

      • strategies: ReserveStrategyConfig[]

        An array of reserve strategy configurations.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

    • Pauses or unpauses a list of reserves.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing an account address and reserve configuration details.

      Returns Promise<CommittedTransactionResponse[]>

      A promise that resolves to an array of committed transaction responses.

      const reservesConfig = [
      { address: '0x...', symbol: 'USDC', paused: true },
      { address: '0x...', symbol: 'DAI', paused: false },
      ];
      const receipts = await setReservesPaused(reservesConfig);
      receipts.forEach(receipt => console.log(receipt.hash));
    • Sets up the protocol by performing a series of configuration steps.

      Parameters

      • reservesConfig: ReserveConfig[]

        An array of reserve configurations.

      • eModes: EModeConfig[]

        An array of eMode configurations.

      Returns Promise<void>

      A promise that resolves when the protocol setup is complete.

      This method performs the following steps:

      1. Creates tokens if they do not exist and retrieves their addresses.
      2. Sets the price of assets on the oracle.
      3. Configures eModes.
      4. Sets interest rate strategies for the reserves.
      5. Initializes reserves that are not yet initialized.
      6. Configures reserves.
      7. Sets the eMode category for reserves.
      8. Sets reserves as borrowable in isolation.
      9. Activates reserves.
      10. Pauses reserves.
      11. Freezes reserves.
      12. Sets the debt ceiling for reserves.
    • Attempts to create tokens based on the provided token configurations.

      Type Parameters

      • T extends TokenConfig

        The type of the token configuration.

      Parameters

      • tokens: T[]

        An array of token configurations.

      Returns Promise<WithAccountAddress<T>[]>

      • A promise that resolves to an array of tokens with their associated account addresses.

      This method first checks if a token with the given symbol already exists by fetching its metadata. If the token does not exist, it creates a new token with the provided configuration and retrieves its address. If the token already exists, it fetches additional metadata such as the maximum supply, name, and decimals.

      const tokens = [
      { symbol: 'TOKEN1', maxSupply: 1000, name: 'Token One', decimals: 18, iconUri: 'http://example.com/icon1.png', projectUri: 'http://example.com/project1' },
      { symbol: 'TOKEN2', maxSupply: 2000, name: 'Token Two', decimals: 18, iconUri: 'http://example.com/icon2.png', projectUri: 'http://example.com/project2' }
      ];
      const result = await tryCreateTokens(tokens);
      console.log(result);
    • Attempts to initialize reserves that are not already initialized.

      Parameters

      • reservesConfig: WithAccountAddress<ReserveConfig>[]

        An array of reserve configurations, each containing account address and reserve details.

      Returns Promise<CommittedTransactionResponse>

      A promise that resolves to a CommittedTransactionResponse if reserves were initialized, or undefined if no reserves needed initialization.

      The function performs the following steps:

      1. Creates an object to hold the reserves that need to be initialized.
      2. Retrieves the current list of reserves from the pool client.
      3. Iterates over the provided reserve configurations and checks if each reserve is already initialized.
        • If a reserve is not initialized, it adds the reserve details to the reservesToInit object.
        • If a reserve is already initialized, it logs a message indicating that the reserve was already initialized.
      4. If there are any reserves to initialize, it calls the initReserves method on the pool client with the collected reserve details.
        • Logs a message indicating the reserves that were initialized and the transaction hash.
        • Returns the transaction receipt.
      5. If no reserves needed initialization, it returns undefined.