Vault Transactions
The Vault Transactions module provides methods for interacting with Mirage Protocol vaults, including creating vaults, managing collateral, borrowing, and handling liquidations.
All methods return an InputEntryFunctionData object that can be used with an Aptos wallet for transaction submission.
Basic Vault Operations
getCreateVaultPayload
Creates a new vault with initial collateral.
getCreateVaultPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
collateralAmount: number // Amount of collateral to add
): InputEntryFunctionDataExample:
const txPayload = mirageClient.vault.transactions.getCreateVaultPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
100 // Add 100 APT as collateral
)
await wallet.signAndSubmitTransaction(txPayload)getCreateVaultAndBorrowPayload
Creates a new vault, adds collateral, and borrows in a single transaction.
async getCreateVaultAndBorrowPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
collateralAmount: number, // Amount of collateral to add
borrowAmount: number // Amount to borrow
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getCreateVaultAndBorrowPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
100, // Add 100 APT as collateral
500 // Borrow 500 USD
)
await wallet.signAndSubmitTransaction(txPayload)Collateral Management
getAddCollateralPayload
Adds collateral to an existing vault.
getAddCollateralPayload(
collateralSymbol: string, // Symbol of collateral asset
vaultObjectAddress: MoveObjectType, // Vault address
collateralAmount: number // Amount to add
): InputEntryFunctionDataExample:
const txPayload = mirageClient.vault.transactions.getAddCollateralPayload(
"APT", // Collateral symbol
"0x123...", // Vault address
50 // Add 50 APT
)
await wallet.signAndSubmitTransaction(txPayload)getRemoveCollateralPayload
Removes collateral from an existing vault.
async getRemoveCollateralPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
removeAmount: number // Amount to remove
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getRemoveCollateralPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
25 // Remove 25 APT
)
await wallet.signAndSubmitTransaction(txPayload)Borrowing Operations
getBorrowPayload
Borrows additional assets from an existing vault.
async getBorrowPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
borrowAmount: number // Amount to borrow
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getBorrowPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
200 // Borrow 200 USD
)
await wallet.signAndSubmitTransaction(txPayload)getRepayDebtPartPayload
Repays a portion of borrowed assets.
getRepayDebtPartPayload(
vaultObjectAddress: MoveObjectType, // Vault address
repayPartAmount: number // Amount to repay in rebase parts
): InputEntryFunctionDataExample:
const txPayload = mirageClient.vault.transactions.getRepayDebtPartPayload(
"0x123...", // Vault address
100 // Repay 100 parts of debt
)
await wallet.signAndSubmitTransaction(txPayload)Combined Operations
getAddCollateralAndBorrowPayload
Adds collateral and borrows additional assets in a single transaction.
async getAddCollateralAndBorrowPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
addAmount: number, // Amount of collateral to add
borrowAmount: number // Amount to borrow
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getAddCollateralAndBorrowPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
50, // Add 50 APT
250 // Borrow 250 USD
)
await wallet.signAndSubmitTransaction(txPayload)getRemoveCollateralAndBorrowPayload
Removes collateral and borrows additional assets in a single transaction.
async getRemoveCollateralAndBorrowPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
removeAmount: number, // Amount of collateral to remove
borrowAmount: number // Amount to borrow
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getRemoveCollateralAndBorrowPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
25, // Remove 25 APT
200 // Borrow 200 USD
)
await wallet.signAndSubmitTransaction(txPayload)getRepayDebtAndRemoveCollateralPayload
Repays debt and removes collateral in a single transaction.
async getRepayDebtAndRemoveCollateralPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
removeAmount: number, // Amount of collateral to remove
repayPartAmount: number // Amount to repay in rebase parts
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getRepayDebtAndRemoveCollateralPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
25, // Remove 25 APT
100 // Repay 100 parts of debt
)
await wallet.signAndSubmitTransaction(txPayload)getAddCollateralAndRepayDebtPayload
Adds collateral and repays debt in a single transaction.
async getAddCollateralAndRepayDebtPayload(
collateralSymbol: string, // Symbol of collateral asset
vaultObjectAddress: MoveObjectType, // Vault address
increaseAmount: number, // Amount of collateral to add
repayPartAmount: number // Amount to repay in rebase parts
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getAddCollateralAndRepayDebtPayload(
"APT", // Collateral symbol
"0x123...", // Vault address
50, // Add 50 APT
100 // Repay 100 parts of debt
)
await wallet.signAndSubmitTransaction(txPayload)Liquidation Operations
getLiquidateVaultWithPartPayload
Liquidates a portion of a vault that has fallen below maintenance requirements.
async getLiquidateVaultWithPartPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
partToLiquidate: number // Amount to liquidate in parts
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getLiquidateVaultWithPartPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
50 // Liquidate 50 parts
)
await wallet.signAndSubmitTransaction(txPayload)getLiquidateVaultBankruptPayload
Liquidates a bankrupt vault.
async getLiquidateVaultBankruptPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
vaultObjectAddress: MoveObjectType, // Vault address
debtAmountToLiquidate: number // Amount of debt to liquidate
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getLiquidateVaultBankruptPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Vault address
1000 // Liquidate 1000 USD worth of debt
)
await wallet.signAndSubmitTransaction(txPayload)Maintenance Operations
getAccrueInterestPayload
Updates the interest accrual for a vault collection.
getAccrueInterestPayload(
collectionObjectAddress: MoveObjectType // Vault collection address
): InputEntryFunctionDataExample:
const txPayload = mirageClient.vault.transactions.getAccrueInterestPayload(
"0x123..." // Vault collection address
)
await wallet.signAndSubmitTransaction(txPayload)getMergeVaultsPayload
Merges two vaults owned by the same user.
async getMergeVaultsPayload(
collateralSymbol: string, // Symbol of collateral asset
borrowSymbol: string, // Symbol of borrow asset
dstVaultObjectAddress: MoveObjectType, // Destination vault address
srcVaultObjectAddress: MoveObjectType // Source vault address
): Promise<InputEntryFunctionData>Example:
const txPayload = await mirageClient.vault.transactions.getMergeVaultsPayload(
"APT", // Collateral symbol
"USD", // Borrow symbol
"0x123...", // Destination vault address
"0x456..." // Source vault address
)
await wallet.signAndSubmitTransaction(txPayload)