Settlement and lifecycle examples
Settlement is an operator action. Check permissions, read the relevant preview, verify the valuation and prepare required curator funding before requesting a transaction confirmation. Never use unsafe to work around an unexplained failure.
Inspect named previews
import { FeeClaimType, type T3trisWalletClient } from "@t3tris-labs/sdk";
import type { Address } from "viem";
export async function settlementQuotes(client: T3trisWalletClient, chainId: number, vault: Address) {
const [combined, deposits, redemptions] = await Promise.all([
client.vaults.read.previewSettleAll({ chainId, address: vault, feeClaimType: FeeClaimType.None }),
client.vaults.read.previewSettleDeposits({ chainId, address: vault, feeClaimType: FeeClaimType.None }),
client.vaults.read.previewSettleRedemptions({ chainId, address: vault, fullClaim: false }),
]);
return {
combinedFunding: combined.assetsFromCurator,
depositFunding: deposits.assetsFromCurator,
redemptionFunding: redemptions.assetsFromCurator,
depositShares: deposits.netDepositFlowData.netDepositShares,
redemptionAssets: redemptions.netRedeemFlowData.netRedeemAssets,
managementFeeAssets: combined.lastPeriodData.managementFeeAssets,
};
}
Each quote describes a different possible transaction against the current state. Do not add the three funding values together or execute all paths in sequence from one quote. Re-read before the chosen action, especially after an approval or another settlement changes state.
Named models include bigint asset/share amounts and WAD price fields. lastPeriodData.pnl is a magnitude with direction in isProfit. grossTvlData describes pre-settlement state, while netTvlData reflects the previewed update.
Prepare curator funding
assetsFromCurator is the raw underlying amount the action needs from the curator. Verify the curator balance and the expected allowance or Permit2 payload using the funding examples. The transaction signer and the funding wallet may differ; approving from the wrong account will not fund the curator's transfer.
Approvals are separate transactions and must execute before settlement. An approval proposal is not sufficient. Re-read the preview and stop if the required funding has changed beyond the amount the user approved.
Settle deposits
import { FeeClaimType, type T3trisWalletClient } from "@t3tris-labs/sdk";
import type { Address, Hex } from "viem";
export function settleDeposits(
client: T3trisWalletClient, chainId: number, vault: Address,
feeClaimType: FeeClaimType, permit2Data?: Hex,
) {
return client.vaults.settle({
chainId, address: vault, kind: "deposits", feeClaimType, permit2Data, unsafe: false,
});
}
Use the same feeClaimType as the reviewed preview. None claims no fees, Soft claims fee shares and Full claims shares plus assets. These options can change the funding and payout requirements.
Settle redemptions
import type { T3trisWalletClient } from "@t3tris-labs/sdk";
import type { Address, Hex } from "viem";
export function settleRedemptions(
client: T3trisWalletClient, chainId: number, vault: Address,
fullClaim: boolean, permit2Data?: Hex,
) {
return client.vaults.settle({
chainId, address: vault, kind: "redemptions", fullClaim, permit2Data, unsafe: false,
});
}
The redemption path accepts fullClaim, not feeClaimType. Review currentRequestId, sharesToRedeem, assetsFromCurator and assetsToSilo from SettleRedemptionsPreview before executing.
Settle both paths
import { FeeClaimType, type T3trisWalletClient } from "@t3tris-labs/sdk";
import type { Address, Hex } from "viem";
export function settleBoth(
client: T3trisWalletClient, chainId: number, vault: Address,
feeClaimType: FeeClaimType, permit2Data?: Hex,
) {
return client.vaults.settle({ chainId, address: vault, kind: "both", feeClaimType, permit2Data, unsafe: false });
}
Confirm the transaction receipt, then refresh requests and positions. Depositors still need to submit their own eligible claims after settlement.
Enter and leave end-of-fund mode
import { FeeClaimType, type T3trisWalletClient } from "@t3tris-labs/sdk";
import type { Address, Hex } from "viem";
export function quoteEndOfFund(client: T3trisWalletClient, chainId: number, vault: Address, feeClaimType: FeeClaimType) {
return client.vaults.read.previewEnableEndOfFund({ chainId, address: vault, feeClaimType });
}
export function enableEndOfFund(
client: T3trisWalletClient, chainId: number, vault: Address,
feeClaimType: FeeClaimType, permit2Data?: Hex,
) {
return client.vaults.enableEndOfFund({ chainId, address: vault, feeClaimType, permit2Data, unsafe: false });
}
export function disableEndOfFund(
client: T3trisWalletClient, chainId: number, vault: Address,
closeVault: boolean, minAssetsOut: bigint,
) {
return client.vaults.disableEndOfFund({ chainId, address: vault, closeVault, minAssetsOut, unsafe: false });
}
Entering end-of-fund mode uses an OpenPreview. Leaving it may close the vault when explicitly requested through closeVault. Review lifecycle and withdrawal implications with the operator before either action.