Manage an Aave Simple Earn Vault
Manage your deployed vaults with fee configuration and revenue collection.
Identify the Vault
All actions below apply to a vault you own. Fetch the vault first; this page uses the following vault in its examples:
const vault: Vault = {
__typename: "Vault",
address: "0x1234567890abcdef1234567890abcdef12345678",
owner: "0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234", // Your address
shareName: "Aave USDC Vault Shares",
shareSymbol: "avUSDC",
chainId: 1,
usedReserve: {
__typename: "Reserve",
underlyingToken: {
__typename: "Currency",
symbol: "USDC",
name: "USD Coin",
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
// …
},
// …
},
fee: {
__typename: "PercentValue",
raw: "150000000000000000000000000",
decimals: 27,
value: "0.15",
formatted: "15", // 15% performance fee
},
totalFeeRevenue: {
__typename: "TokenAmount",
amount: {
__typename: "DecimalValue",
value: "1250.75", // Lifetime fees collected
// …
},
usd: "1250.75",
// …
},
feesBalance: {
__typename: "TokenAmount",
amount: {
__typename: "DecimalValue",
value: "100.00", // Fees currently available for withdrawal
// …
},
usd: "100.00",
// …
},
// …
};
Set Vault Fee
The fee can be 0% to 100%. Aave Labs automatically receives 50% of it.
Update the performance fee for your vault (vault owner only).
1. Prepare the Fee Update
Next, create the transaction request for updating the vault fee. Use the use hook in React, the vault action in TypeScript, or the vault query in GraphQL to create the transaction request for updating the vault fee.
import { useVaultSetFee, bigDecimal } from "@aave/react";
// …
const [setFee, settingFee] = useVaultSetFee();
const result = await setFee({
chainId: vault.chainId,
vault: vault.address,
newFee: bigDecimal(15), // 15% performance fee
});
// …
import { bigDecimal } from "@aave/client";
import { vaultSetFee } from "@aave/client/actions";
import { client } from "./client";
const result = await vaultSetFee(client, {
chainId: vault.chainId,
vault: vault.address,
newFee: bigDecimal(15), // 15% performance fee
});
// …
import { AaveClient } from "@aave/client";
export const client = AaveClient.create();
query {
vaultSetFee(
request: {
chainId: 1
vault: "0x1234567890abcdef1234567890abcdef12345678"
newFee: "15"
}
) {
to
from
data
value
chainId
}
}
2. Send the Fee Update
Finally, send the transaction.
- React: Use the
usehook for the wallet library of your choice to send the transaction.Send Transaction - TypeScript: Use
sendfor your chosen wallet library to initiate the transaction, and await indexing withWith client..wait For Transaction - GraphQL: The response is a
Transactionthat can be sent directly using the wallet associated with theRequest fromaddress.
import { useWalletClient } from "wagmi";
import { useVaultSetFee } from "@aave/react";
import { useSendTransaction } from "@aave/react/viem";
// …
const { data: walletClient } = useWalletClient();
const [setFee, settingFee] = useVaultSetFee();
const [sendTransaction, sending] = useSendTransaction(walletClient);
const loading = settingFee.loading || sending.loading;
const error = settingFee.error || sending.error;
// …
const result = await setFee({
// …
}).andThen(sendTransaction);
if (result.isErr()) {
console.error("Set fee failed:", result.error);
} else {
console.log("Set fee successful with hash:", result.value);
}
import { vaultSetFee } from "@aave/client/actions";
import { sendWith } from "@aave/client/viem";
import { client } from "./client";
import { wallet } from "./wallet";
const result = await vaultSetFee(client, {
// …
})
.andThen(sendWith(wallet))
.andThen(client.waitForTransaction);
if (result.isErr()) {
console.error("Set fee failed:", result.error);
} else {
console.log("Set fee successful:", result.value);
}
import { createWalletClient, http, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
export const wallet = createWalletClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as Hex),
chain: mainnet,
transport: http(),
});
{
"data": {
"vaultSetFee": {
"to": "0x1234567890abcdef1234567890abcdef12345678",
"from": "0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234",
"data": "0x69fe0e2d000000000000000000000000000000000000000000000000000000000000000f",
"value": "0",
"chainId": 1
}
}
}
Withdraw Fees
Withdraw accumulated fees from your vault (vault owner only).
Fees are withdrawn as the reserve’s aTokens.
1. Prepare the Fee Withdrawal
Next, create the transaction request for withdrawing fees. Use the use hook in React, the vault action in TypeScript, or the vault query in GraphQL to create the transaction request for withdrawing fees.
import { useVaultWithdrawFees, bigDecimal } from "@aave/react";
// …
const [withdrawFees, withdrawingFees] = useVaultWithdrawFees();
const result = await withdrawFees({
chainId: vault.chainId,
vault: vault.address,
amount: {
exact: bigDecimal(100), // 100 USDC of fees
},
// sendTo: evmAddress("0x1234…"), if different from vault owner
});
// …
import { useVaultWithdrawFees } from "@aave/react";
// …
const [withdrawFees, withdrawingFees] = useVaultWithdrawFees();
const result = await withdrawFees({
chainId: vault.chainId,
vault: vault.address,
amount: {
max: true,
},
// sendTo: evmAddress("0x1234…"), if different from vault owner
});
// …
import { bigDecimal } from "@aave/client";
import { vaultWithdrawFees } from "@aave/client/actions";
import { client } from "./client";
const result = await vaultWithdrawFees(client, {
chainId: vault.chainId,
vault: vault.address,
amount: {
exact: bigDecimal(100), // 100 USDC of fees
},
// sendTo: evmAddress("0x1234…"), if different from vault owner
});
// …
import { vaultWithdrawFees } from "@aave/client/actions";
import { client } from "./client";
const result = await vaultWithdrawFees(client, {
chainId: vault.chainId,
vault: vault.address,
amount: {
max: true,
},
// sendTo: evmAddress("0x1234…"), if different from vault owner
});
// …
import { AaveClient } from "@aave/client";
export const client = AaveClient.create();
query {
vaultWithdrawFees(
request: {
chainId: 1
vault: "0x1234567890abcdef1234567890abcdef12345678"
amount: {
exact: "100"
# OR
# max: true
}
# sendTo: "0x1234…", if different from vault owner
}
) {
to
from
data
value
chainId
}
}
2. Send the Fee Withdrawal
Finally, send the transaction.
- React: Use the
usehook for the wallet library of your choice to send the transaction.Send Transaction - TypeScript: Use
sendfor your chosen wallet library to initiate the transaction, and await indexing withWith client..wait For Transaction - GraphQL: The response is a
Transactionthat can be sent directly using the wallet associated with theRequest fromaddress.
import { useWalletClient } from "wagmi";
import { useVaultWithdrawFees } from "@aave/react";
import { useSendTransaction } from "@aave/react/viem";
// …
const { data: walletClient } = useWalletClient();
const [withdrawFees, withdrawingFees] = useVaultWithdrawFees();
const [sendTransaction, sending] = useSendTransaction(walletClient);
const loading = withdrawingFees.loading || sending.loading;
const error = withdrawingFees.error || sending.error;
// …
const result = await withdrawFees({
// …
}).andThen(sendTransaction);
if (result.isErr()) {
console.error("Withdraw fees failed:", result.error);
} else {
console.log("Withdraw fees successful with hash:", result.value);
}
import { vaultWithdrawFees } from "@aave/client/actions";
import { sendWith } from "@aave/client/viem";
import { client } from "./client";
import { wallet } from "./wallet";
const result = await vaultWithdrawFees(client, {
// …
})
.andThen(sendWith(wallet))
.andThen(client.waitForTransaction);
if (result.isErr()) {
console.error("Withdraw fees failed:", result.error);
} else {
console.log("Withdraw fees successful:", result.value);
}
import { createWalletClient, http, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
export const wallet = createWalletClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as Hex),
chain: mainnet,
transport: http(),
});
{
"data": {
"vaultWithdrawFees": {
"to": "0x1234567890abcdef1234567890abcdef12345678",
"from": "0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234",
"data": "0xad3b1b47000000000000000000000000742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b12340000000000000000000000000000000000000000000000000000000005f5e100",
"value": "0",
"chainId": 1
}
}
}
Transfer Vault Ownership
Transfer the ownership of a vault to a new address (vault owner only).
1. Prepare the Ownership Transfer
Next, create the transaction request for transferring the ownership of the vault. Use the use hook in React, the vault action in TypeScript, or the vault query in GraphQL to create the transaction request for transferring the ownership of the vault.
import { useVaultTransferOwnership, evmAddress } from "@aave/react";
// …
const [transferOwnership, transferring] = useVaultTransferOwnership();
const result = await transferOwnership({
chainId: vault.chainId,
vault: vault.address,
newOwner: evmAddress("0x9876543210fedcba9876543210fedcba98765432"),
});
// …
import { evmAddress } from "@aave/client";
import { vaultTransferOwnership } from "@aave/client/actions";
import { client } from "./client";
const result = await vaultTransferOwnership(client, {
chainId: vault.chainId,
vault: vault.address,
newOwner: evmAddress("0x9876543210fedcba9876543210fedcba98765432"),
});
// …
import { AaveClient } from "@aave/client";
export const client = AaveClient.create();
query {
vaultTransferOwnership(
request: {
chainId: 1
vault: "0x1234567890abcdef1234567890abcdef12345678"
newOwner: "0x9876543210fedcba9876543210fedcba98765432"
}
) {
to
from
data
value
chainId
}
}
2. Send the Ownership Transfer
Finally, send the transaction.
- React: Use the
usehook for the wallet library of your choice to send the transaction.Send Transaction - TypeScript: Use
sendfor your chosen wallet library to initiate the transaction, and await indexing withWith client..wait For Transaction - GraphQL: The response is a
Transactionthat can be sent directly using the wallet associated with theRequest fromaddress.
import { useWalletClient } from "wagmi";
import { useVaultTransferOwnership } from "@aave/react";
import { useSendTransaction } from "@aave/react/viem";
// …
const { data: walletClient } = useWalletClient();
const [transferOwnership, transferringOwnership] = useVaultTransferOwnership();
const [sendTransaction, sending] = useSendTransaction(walletClient);
const loading = transferringOwnership.loading || sending.loading;
const error = transferringOwnership.error || sending.error;
// …
const result = await transferOwnership({
// …
}).andThen(sendTransaction);
if (result.isErr()) {
console.error("Transfer ownership failed:", result.error);
} else {
console.log("Transfer ownership successful with hash:", result.value);
}
import { vaultTransferOwnership } from "@aave/client/actions";
import { sendWith } from "@aave/client/viem";
import { client } from "./client";
import { wallet } from "./wallet";
const result = await vaultTransferOwnership(client, {
// …
})
.andThen(sendWith(wallet))
.andThen(client.waitForTransaction);
if (result.isErr()) {
console.error("Transfer ownership failed:", result.error);
} else {
console.log("Transfer ownership successful:", result.value);
}
import { createWalletClient, http, type Hex } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
export const wallet = createWalletClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY as Hex),
chain: mainnet,
transport: http(),
});
{
"data": {
"vaultTransferOwnership": {
"to": "0x1234567890abcdef1234567890abcdef12345678",
"from": "0x742d35cc6e5c4ce3b69a2a8c7c8e5f7e9a0b1234",
"data": "0xf2fde38b0000000000000000000000009876543210fedcba9876543210fedcba98765432",
"value": "0",
"chainId": 1
}
}
}