Skip to content

Latest commit

 

History

History
1171 lines (860 loc) · 89.7 KB

File metadata and controls

1171 lines (860 loc) · 89.7 KB

AaveV3

(aaveV3)

Overview

Available Operations

aaveAaveSupportedTokens

Returns the list of supported tokens on Aave for the specified network, along with key metadata.

For each token, the response includes:

  • The symbol and contract address.
  • Whether the token is currently enabled for supplying (depositing).
  • Whether it is enabled for borrowing.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveAaveSupportedTokens({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveAaveSupportedTokens } from "@compass-labs/api-sdk/funcs/aaveV3AaveAaveSupportedTokens.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveAaveSupportedTokens(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveAaveSupportedTokens failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveAaveSupportedTokensRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveSupportedTokensResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveRate

Returns the latest APY and APR rates for a specified token on Aave, for both deposits and loans.

Annual percentage yield (APY) is the yearly return/cost after continuous compounding of the per-second rate stored on-chain. This value is the same value as seen the on app.aave.com but more up-to-date as it is taken directly from the blockchain every time this endpoint is called.

Annual percentage rate (APR) is the yearly simple interest rate (no compounding).

For APY/APR on loans Aave offers both stable and fixed rates on certain tokens.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveRate({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveRate } from "@compass-labs/api-sdk/funcs/aaveV3AaveRate.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveRate(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveRate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveRateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveRateResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveAvgRate

Provides time-weighted averages of deposit and borrow rates for Aave reserves.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveAvgRate({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveAvgRate } from "@compass-labs/api-sdk/funcs/aaveV3AaveAvgRate.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveAvgRate(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveAvgRate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveAvgRateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveAvgRateResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveStdRate

Returns the historical standard deviation of lending and borrowing rates for Aave reserves, illustrating market volatility.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveStdRate({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveStdRate } from "@compass-labs/api-sdk/funcs/aaveV3AaveStdRate.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveStdRate(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveStdRate failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveStdRateRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveSTDRateResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveReserveOverview

Returns key metrics for Aave Reserves:

  • Total Supplied (TVL) in USD
  • Total Borrowed in USD
  • Utilization Ratio

See below for more info:

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveReserveOverview({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveReserveOverview } from "@compass-labs/api-sdk/funcs/aaveV3AaveReserveOverview.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveReserveOverview(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveReserveOverview failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveReserveOverviewRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveReserveOverviewResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveTokenPrice

This endpoint retrieves the current price of a specified token in USD as determined by the Aave protocol.

It utilizes the Aave V3 Oracle to fetch the token price, ensuring accurate and up- to-date information. The request requires the token identifier and the blockchain network (chain) on which the token resides. The response provides the token price in a standardized format, converted from Wei to the base currency decimals defined by Aave.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveTokenPrice({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveTokenPrice } from "@compass-labs/api-sdk/funcs/aaveV3AaveTokenPrice.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveTokenPrice(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveTokenPrice failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveTokenPriceRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveTokenPriceResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveLiquidityChange

This endpoint retrieves the change in the reserve liquidity index between two provided blocks.

This is then converted to a percentage change. The liquidity index represents the change in debt and interest accrual over each block. Aave does not store individual user balances directly. Instead, it keeps a scaled balance and uses the liquidity index to compute real balances dynamically. If a user was to have deposited tokens at the start block, a positive liquidity index change will represent accrued interest and a profit. If tokens were borrowed at the start block, this debt will increase, compound on itself and represent large debt. The reverse in both cases is true if the liquidity index is negative.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveLiquidityChange({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveLiquidityChange } from "@compass-labs/api-sdk/funcs/aaveV3AaveLiquidityChange.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveLiquidityChange(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveLiquidityChange failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveLiquidityChangeRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveLiquidityChangeResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveUserPositionSummary

This endpoint retrieves a comprehensive summary of a user's position on the AAVE platform.

It provides key financial metrics including the total collateral deposited, total debt accrued, available borrowing capacity, liquidation threshold, maximum loan-to- value ratio, and the health factor of the user's account. These metrics are calculated by aggregating data across all open positions held by the user, offering a holistic view of their financial standing within the AAVE ecosystem.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveUserPositionSummary({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveUserPositionSummary } from "@compass-labs/api-sdk/funcs/aaveV3AaveUserPositionSummary.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveUserPositionSummary(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveUserPositionSummary failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveUserPositionSummaryRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveUserPositionSummaryResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveUserPositionPerToken

This endpoint retrieves the user's position for a specific token on the AAVE platform.

It provides key financial metrics including the current aToken balance, current stable debt, current variable debt, principal stable debt, principal variable debt, stable borrow rate, stable borrow rate for new loans, variable borrow rate, and liquidity rate. These metrics are calculated by aggregating data across all open positions held by the user for the specified token, offering a detailed view of their financial standing within the AAVE ecosystem.

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveUserPositionPerToken({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveUserPositionPerToken } from "@compass-labs/api-sdk/funcs/aaveV3AaveUserPositionPerToken.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveUserPositionPerToken(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveUserPositionPerToken failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveUserPositionPerTokenRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveUserPositionPerTokenResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveHistoricalTransactions

This endpoint retrieves historical transactions for a user on the AAVE platform.

It returns a list of transactions including deposits, withdrawals, borrows, and repayments. Each transaction includes details such as the token, amount, timestamp, and transaction type. This provides a comprehensive view of the user's historical activity within the AAVE protocol.

⚠️ Data comes from the official Aave subgraph ( https://github.com/aave/protocol-subgraphs) and thus this particular endpoint may be less reliable than our other endpoints. ⚠️

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveHistoricalTransactions({});

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveHistoricalTransactions } from "@compass-labs/api-sdk/funcs/aaveV3AaveHistoricalTransactions.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveHistoricalTransactions(compassApiSDK, {});
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveHistoricalTransactions failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request operations.V1AaveHistoricalTransactionsRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.AaveHistoricalTransactionsResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveSupply

By supplying assets, users can earn interest on their deposits.

The supplied collateral can be used as a basis for borrowing other assets, allowing users to leverage their positions. In combination with a trading protocol, this can create leverage.

Overall, this endpoint is a critical component for users looking to maximize their asset utility within the AAVEv3 ecosystem, providing both earning potential and borrowing flexibility. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `AaveV3Pool`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveSupply({
    token: "WETH",
    amount: 1.5,
    chain: "base",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveSupply } from "@compass-labs/api-sdk/funcs/aaveV3AaveSupply.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveSupply(compassApiSDK, {
    token: "WETH",
    amount: 1.5,
    chain: "base",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveSupply failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.AaveSupplyRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveBorrow

You will pay interest for your borrows.

Price changes in the assets may lead to some or all of your collateral being liquidated, if the borrow position becomes unhealthy. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `AaveV3Pool`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveBorrow({
    token: "WETH",
    amount: 150.5,
    interestRateMode: "stable",
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveBorrow } from "@compass-labs/api-sdk/funcs/aaveV3AaveBorrow.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveBorrow(compassApiSDK, {
    token: "WETH",
    amount: 150.5,
    interestRateMode: "stable",
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveBorrow failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.AaveBorrowRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveRepay

This endpoint allows users to repay a portion or the entirety of their borrowed tokens on the Aave platform.

By repaying borrowed amounts, users can improve their health factor, which is a measure of the safety of their loan position. A higher health factor reduces the risk of liquidation, ensuring a more secure borrowing experience. The endpoint requires specifying the chain and the details of the repayment transaction, including the amount and the asset to be repaid. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `AaveV3Pool`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveRepay({
    token: "WETH",
    amount: 150.5,
    interestRateMode: "stable",
    chain: "arbitrum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveRepay } from "@compass-labs/api-sdk/funcs/aaveV3AaveRepay.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveRepay(compassApiSDK, {
    token: "WETH",
    amount: 150.5,
    interestRateMode: "stable",
    chain: "arbitrum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveRepay failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.AaveRepayRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*

aaveWithdraw

This endpoint facilitates the withdrawal of collateral from the Aave protocol.

Users can withdraw a portion or all of their collateral, which may increase the risk of liquidation if there are outstanding borrows. The withdrawal process also includes the collection of any interest earned on the collateral. It is important for users to carefully consider their outstanding debts and the potential impact on their liquidation threshold before proceeding with a withdrawal. This endpoint is designed to provide a seamless and efficient way to manage your collateral within the Aave ecosystem. Required Allowances

                    In order to make this transaction, token allowances need to be set for the following contracts.

                 - `AaveV3Pool`
                </Info>

Example Usage

import { CompassApiSDK } from "@compass-labs/api-sdk";

const compassApiSDK = new CompassApiSDK({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const result = await compassApiSDK.aaveV3.aaveWithdraw({
    token: "WETH",
    amount: 1.5,
    recipient: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CompassApiSDKCore } from "@compass-labs/api-sdk/core.js";
import { aaveV3AaveWithdraw } from "@compass-labs/api-sdk/funcs/aaveV3AaveWithdraw.js";

// Use `CompassApiSDKCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const compassApiSDK = new CompassApiSDKCore({
  apiKeyAuth: "<YOUR_API_KEY_HERE>",
});

async function run() {
  const res = await aaveV3AaveWithdraw(compassApiSDK, {
    token: "WETH",
    amount: 1.5,
    recipient: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
    chain: "ethereum",
    sender: "0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B",
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("aaveV3AaveWithdraw failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
request components.AaveWithdrawRequest ✔️ The request object to use for the request.
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TransactionResponse>

Errors

Error Type Status Code Content Type
errors.HTTPValidationError 422 application/json
errors.APIError 4XX, 5XX */*