apxUSD module
ERC-20 yield-bearing stablecoin that the apyUSD vault wraps. Available
as apyx.apxUSD after createApyxClient.
const balance = await apyx.apxUSD.balanceOf('0xabc…');
const tx = await apyx.apxUSD.approve({ spender, amount });
Address
apyx.apxUSD.address
// ^^^^^^^^ Address — the apxUSD contract on the configured chain
Always equals apyx.addresses.apxUSD. Pinned to the built-in registry
unless you passed addresses.apxUSD as an override.
Reads
All reads return Promise<T> and route through apyx.publicClient.readContract.
| Method | Returns | Notes |
|---|---|---|
balanceOf(owner: Address) | bigint | Raw token balance, 18-decimal scaled. |
allowance(owner, spender) | bigint | ERC-20 allowance. |
totalSupply() | bigint | Total minted apxUSD. |
supplyCap() | bigint | Max permitted supply (protocol guardrail). |
supplyCapRemaining() | bigint | Headroom = supplyCap - totalSupply. |
paused() | boolean | true if the contract is paused (writes will revert). |
decimals() | number | Always 6 today, but read it rather than hardcode. |
nonces(owner: Address) | bigint | EIP-2612 nonce. Used when signing permit. |
const [balance, allowance, supply, paused] = await Promise.all([
apyx.apxUSD.balanceOf(user),
apyx.apxUSD.allowance(user, apyx.addresses.apyUSD),
apyx.apxUSD.totalSupply(),
apyx.apxUSD.paused(),
]);
Writes
All writes require account to have been passed at createApyxClient
time. Without it, every write throws
WalletClientRequiredError before any RPC traffic.
Each write returns a TxHandle:
type TxHandle = {
hash: `0x${string}`;
wait: () => Promise<TransactionReceipt>;
};
wait() resolves the receipt via publicClient.waitForTransactionReceipt.
transfer({ to, amount })
ERC-20 transfer to to.
const tx = await apyx.apxUSD.transfer({ to: '0x…', amount: 1_000_000n });
const receipt = await tx.wait();
approve({ spender, amount })
ERC-20 approval. The most common spender is apyx.addresses.apyUSD —
required before apyUSD.deposit can pull funds.
const tx = await apyx.apxUSD.approve({
spender: apyx.addresses.apyUSD,
amount: 1_000_000n, // 1 apxUSD at 6 decimals
});
await tx.wait();
permit({ owner, spender, value, deadline, v, r, s })
EIP-2612 gasless approval. The signature comes from a separate
off-chain signing step (typically walletClient.signTypedData against
the permit domain). When you submit permit, you pay the gas to land
the approval; the holder pays nothing.
const tx = await apyx.apxUSD.permit({
owner, spender, value, deadline,
v, r, s, // returned by your typed-data signing step
});
await tx.wait();
For nonce + domain construction, see the approve recipe.
Source
src/contracts/apxUSD.ts is the implementation. The shape above
is generated ReturnType<typeof apxUSD> — if it ever drifts from this
page, the source is authoritative.