apyUSD module
ERC-4626 vault wrapping apxUSD. Shares (apyUSD) are 18-decimal,
underlying assets (apxUSD) are 6-decimal. Available as apyx.apyUSD
after createApyxClient.
const rate = await apyx.apyUSD.exchangeRate(); // 1 share -> assets, 1e18 scaled
const shares = await apyx.apyUSD.convertToShares(1_000_000n);
Address
apyx.apyUSD.address
Equals apyx.addresses.apyUSD.
Reads
Conversion views
| Method | Returns | Notes |
|---|---|---|
asset() | Address | Underlying asset (always apxUSD). |
totalAssets() | bigint | Vault TVL in apxUSD (6-decimal). |
convertToShares(assets: bigint) | bigint | apxUSD → apyUSD at the current ratio. |
convertToAssets(shares: bigint) | bigint | apyUSD → apxUSD. |
exchangeRate() | bigint | Convenience: convertToAssets(1e18). 18-decimal scaled. The single most-read number on this contract — the value displayed by every UI / dashboard. |
Preview views
Pre-flight quotes for the four ERC-4626 mutations. These match exactly what would happen on-chain at the current block, including any rounding.
| Method | Returns |
|---|---|
previewDeposit(assets) | shares minted for assets |
previewMint(shares) | assets pulled to mint shares |
previewWithdraw(assets) | shares burned for assets |
previewRedeem(shares) | assets returned for shares |
Capacity views
| Method | Returns |
|---|---|
maxDeposit(receiver) | max apxUSD receiver can deposit |
maxMint(receiver) | max apyUSD shares receiver can mint |
maxRedeem(owner) | max apyUSD owner can redeem |
maxWithdraw(owner) | max apxUSD owner can withdraw |
Holder views
| Method | Returns | Notes |
|---|---|---|
balanceOf(owner) | bigint | apyUSD share balance, 18-decimal. |
decimals() | number | Always 18, but read it rather than hardcode. |
Writes
All writes require account; without it they throw
WalletClientRequiredError. Each write returns a
TxHandle = { hash, wait }.
Approval first.
depositandmintpullapxUSDfrom the sender viatransferFrom. You mustapprovethe apyUSD address first — see the approve and deposit recipe.
deposit({ assets, receiver })
Pull assets apxUSD from the sender, mint shares to receiver.
const tx = await apyx.apyUSD.deposit({
assets: 1_000_000n, // 1 apxUSD (6-dec)
receiver: apyx.walletClient!.account!.address,
});
await tx.wait();
mint({ shares, receiver })
Mint exactly shares apyUSD to receiver, pulling whatever apxUSD is
required (previewMint(shares)).
withdraw({ assets, receiver, owner })
Burn shares from owner to deliver assets apxUSD to receiver.
Requires that owner === wallet.account or that the wallet has been
approved by owner (approve is for the share token in this case).
redeem({ shares, receiver, owner })
Burn exactly shares apyUSD from owner, deliver
previewRedeem(shares) apxUSD to receiver. The most common exit
path — see the redeem recipe.
const tx = await apyx.apyUSD.redeem({
shares: apyx.walletClient!.account!.address, // your share balance
receiver: apyx.walletClient!.account!.address,
owner: apyx.walletClient!.account!.address,
});
Source
src/contracts/apyUSD.ts. The exposed shape is
ReturnType<typeof apyUSD>; this page mirrors that and the source
wins on conflict.