Leveraged tokens
How BTC3L, GOLD2S and the other leveraged tokens mint, redeem and rebalance, and the units their prices use.
Leveraged tokens are plain Sui coins (BTC3L, ETH2S, NVDA2L and others). Each one holds a single Aftermath perpetual position at a fixed target leverage and side. Buying opens exposure, selling closes the seller's share and pays its value in USDC, and a keeper rebalances the position back to its target whenever price moves push it out of its band.
In short: BTC3L holds a 3x long Bitcoin position, so if Bitcoin rises 1% it rises about 3%. BTC3S is the 3x short: it rises about 3% when Bitcoin falls 1%. There is no liquidation for you to manage and no margin to top up. You hold a coin, and you can sell it whenever its market trades.
| Fee | Amount |
|---|---|
| Buy | 0% |
| Sell | 0.3% |
| Management | 2% a year |
They run on the leveraged token package 0x294e0968e465d9e2e560b825c603a40d34a7ee72e5a9157ff796519d44f7df4a. Every token's object ids are at /api/lev/tokens.
The tokens#
32 tokens, each on one Aftermath market:
| Leverage | Tokens |
|---|---|
| 3x long and short | BTC3L, BTC3S |
| 2x long and short | HYPE2L, HYPE2S, GOLD2L, GOLD2S, NVDA2L, NVDA2S, GOOGL2L, GOOGL2S, TSLA2L, TSLA2S, ETH2L, ETH2S, SUI2L, SUI2S, META2L, META2S, SILVER2L, SILVER2S, SPCX2L, SPCX2S |
| 1x long and short | ZEC1L, ZEC1S, XMR1L, XMR1S |
| 1x short | NVDA1S, GOOGL1S, TSLA1S, META1S, AAPL1S, SPCX1S |
A 1x short holds a short position the size of its value: it gains about as much as the market falls.
Units#
| Field | Unit | Example |
|---|---|---|
tokens, supply | raw token units, 9 decimals | 2137313487 is 2.137313487 tokens |
deposit, payout, fee, nav | raw USDC units, 6 decimals | 2000000 is $2.00 |
price | raw USDC per 1e9 raw token units (one whole token) | 933584 is $0.933584 per token |
oracle | the base asset's oracle price, 18 decimals (Aftermath IFixed) | 83774733435430000000000 is $83,774.73 |
target_bps, leverage_bps | basis points of leverage | 30000 is 3x |
The contract computes the price as:
// lev_math::token_price: raw quote per whole token (1e9 units)
price = 1_000_000_000 * (assets + virtual_assets) / (supply + virtual_shares)So for a token with $74.597849 of value (nav = 74597849) and 79.9047937 tokens out (supply = 79904793700), the price is 1e9 * 74597849 / 79904793700 = 933584, which is $0.933584 per token. To convert:
const usdPerToken = Number(price) / 1e6; // 933584 -> 0.933584
const tokensFor = (usdc: bigint) => (usdc * 1_000_000_000n) / price; // raw tokens per raw USDCAn empty token restarts at $1 (price 1000000) on its next buy.
How it works#
- Value is the token's Aftermath account equity (free cash, position collateral, unrealized PnL and unsettled funding) at the oracle price, divided by supply. The oracle cannot be moved by trading; the venue's mark price can.
- Mint (buy). The deposit opens exposure at the token's current leverage, so every holder keeps the same exposure per token. The order is an immediate-or-cancel limit at most 1% from the oracle (
entry_slippage_bps) that must fill completely. It is refused while the position is above its band top, if the fill would leave it above the margin's leverage, and below the market's minimum order size. - Redeem (sell). Closes the seller's share of the position, rounded up to a whole lot, with a market order. The seller bears the closing cost. Works in every state after pending.
redeem_partialsells what the book can take now and returns the rest. - Rebalance. Only toward the target, only when leverage is outside the band. Routine rebalancing needs the keeper's cap (
rebalance_down,rebalance_up).rebalancestays open to anyone once leverage is past the emergency level. - Margin. The position keeps margin for the emergency leverage, so idle cash defends it from liquidation.
restore_marginis permissionless.
Fees#
| Fee | Current value | Ceiling |
|---|---|---|
| Buy | 0% | 1% |
| Sell | 0.3% of the payout | 1% |
| Streaming | 2% a year, minted to the fee balance | 5% a year |
A buy or sell fee goes 20% to the holder's referrer (if they have one). What is left, and all of the streaming fee, is split evenly between PPX holders and the treasury. No setting can raise a fee past its ceiling. Aftermath's trading fees and spread are paid by whoever causes the trade. Funding settles into the position and moves the token's value directly.
The streaming fee is taken as newly minted tokens and held by the token until collect_fees, which anyone can call, sells them and pays the recipients.
Mint and redeem in TypeScript#
Every entry point takes the same venue objects in the same order: the Config, the token, its vault, its Aftermath account, the market (ClearingHouse, taken by value and returned), the Aftermath registry and both oracles. Take them from /api/lev/tokens.
import { SuiGrpcClient } from "@mysten/sui/grpc";
import { Transaction, coinWithBalance } from "@mysten/sui/transactions";
const client = new SuiGrpcClient({ network: "mainnet", baseUrl: "https://fullnode.mainnet.sui.io:443" });
const LEV = "0x294e0968e465d9e2e560b825c603a40d34a7ee72e5a9157ff796519d44f7df4a";
const LEV_CONFIG = "0xfa003af67a3c948d1ebf9bbde1b08da54bee838d92ce577046fbc8fdc7d15cb4";
const AFTERMATH_PERPS = "0xe54757433d663835bda85cfc89c6c44bc8d952e941affa5ae57bba0baa226c1b"; // calls; types keep the original id 0x3ec740df8428aa9c93aaef7f8cc1542ac3194fd014826b51bfe245346d64efc7
const AFTERMATH_REGISTRY = "0xda0bd7a60182efd662b70e0de99218bbd2b6c4bbe9de23c0bb5a87ec52b37c37";
const USDC = "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC";
// BTC3L, as /api/lev/tokens lists it.
const BTC3L = {
coinType: "0x5f818c904f97f483ba3d80f35d004c69d9709a624b9ace19cf2f40283f128f58::btc3l::BTC3L",
token: "0x7e816bac3ff396dd2970c574bbac354c9cdcac2a047b377db93e39455b22da48",
vault: "0xe5934bdd7ed2f4d8844c8b5510c5b7b151cf5e4c41fb77adb398931a7997e133",
account: "0xa6117219eb52c03250f344c0e0a5a0d5360848dea762ef004e6cfd9ff93d415a",
market: "0x05b5c3bea84c4b8f33cf592d899008336dcbae8c9c6c75b2f8e7b8f7878744c1",
baseOracle: "0xc729d56d7de4e22ad6e21f379f79c68d277a49789ac5b52b8df51ed16bc4a9a0",
collateralOracle: "0x96ea92a33842446845c38992f5de53971471156e26b269c19a1f5864109ada03",
};
export function mintTx(t: typeof BTC3L, sender: string, usdc: bigint, minTokens: bigint) {
const tx = new Transaction();
tx.setSender(sender);
const [market, tokens] = tx.moveCall({
target: `${LEV}::token::mint`,
typeArguments: [t.coinType, USDC],
arguments: [
tx.object(LEV_CONFIG), tx.object(t.token), tx.object(t.vault), tx.object(t.account), tx.object(t.market),
tx.object(AFTERMATH_REGISTRY), tx.object(t.baseOracle), tx.object(t.collateralOracle),
coinWithBalance({ type: USDC, balance: usdc }),
tx.pure.u64(minTokens), // min_out, raw token units (9 decimals)
tx.pure.u64(0), // max_slippage_bps: 0 uses the Config's entry bound (1%)
tx.pure.address("0x0"), // referrer
tx.pure.u64(Date.now() + 100_000), // deadline: at most 120 s ahead
tx.object.clock(),
],
});
// The market was taken by value: share it back.
tx.moveCall({ target: `${AFTERMATH_PERPS}::clearing_house::share`, typeArguments: [USDC], arguments: [market] });
tx.transferObjects([tokens], sender);
return tx;
}
export function redeemTx(t: typeof BTC3L, sender: string, tokens: bigint, minUsdc: bigint) {
const tx = new Transaction();
tx.setSender(sender);
const [market, usdc] = tx.moveCall({
target: `${LEV}::token::redeem`,
typeArguments: [t.coinType, USDC],
arguments: [
tx.object(LEV_CONFIG), tx.object(t.token), tx.object(t.vault), tx.object(t.account), tx.object(t.market),
tx.object(AFTERMATH_REGISTRY), tx.object(t.baseOracle), tx.object(t.collateralOracle),
coinWithBalance({ type: t.coinType, balance: tokens }),
tx.pure.u64(minUsdc), // min_out, raw USDC (6 decimals)
tx.pure.address("0x0"), // referrer
tx.pure.u64(Date.now() + 100_000),
tx.object.clock(),
],
});
tx.moveCall({ target: `${AFTERMATH_PERPS}::clearing_house::share`, typeArguments: [USDC], arguments: [market] });
tx.transferObjects([usdc], sender);
return tx;
}Quoting#
Simulate the exact transaction and read the Minted or Redeemed event. Then set min_out a little under it and send.
const sim: any = await client.core.simulateTransaction({ transaction: mintTx(BTC3L, sender, 2_000_000n, 0n), include: { events: true } });
const minted = sim.Transaction.events.find((e: any) => e.eventType.endsWith("::token::Minted")).json;
// { deposit: "2000000", tokens: "2137313487", price: "933584", nav: "74597849", supply: "79904793700", fee: "0", ... }
const minOut = (BigInt(minted.tokens) * 995n) / 1000n; // 0.5% under the quoteTwo trades on one market#
Two tokens on the same market (BTC3L into BTC3S) in one transaction must pass the market along: the first call returns the ClearingHouse, the second takes that result instead of the shared object, and only the last one shares it back.
Reading a token#
token::status returns everything a front end needs in one simulation: state, side, target and band, NAV, supply, price, leverage, pending fees, margin shortfall, the oracles and any announced change.
const q = new Transaction();
q.setSender("0x0");
q.moveCall({
target: `${LEV}::token::status`,
typeArguments: [BTC3L.coinType, USDC],
arguments: [
q.object(LEV_CONFIG), q.object(BTC3L.token), q.object(BTC3L.vault), q.object(BTC3L.account), q.object(BTC3L.market),
q.object(AFTERMATH_REGISTRY), q.object(BTC3L.baseOracle), q.object(BTC3L.collateralOracle), q.object.clock(),
],
});Events#
| Event | Fields |
|---|---|
token::Minted | token, buyer, deposit, fee, referrer, tokens, nav, supply, price, oracle |
token::Redeemed | token, seller, tokens, payout, fee, referrer, nav, supply, price, oracle |
token::Rebalanced | token, increase, size, leverage_before, leverage_after, nav, oracle |
token::StateChanged | token, state |
token::FeesCollected | token, tokens, payout |
Event types use the package id 0x294e0968e465d9e2e560b825c603a40d34a7ee72e5a9157ff796519d44f7df4a.
Error codes#
| Code | Name | Meaning |
|---|---|---|
| 1 | EBinding | An object passed in is not this token's own (vault, account, market, registry or oracle). |
| 2 | EPolicy | The token's setup does not allow the step (for example an empty token still holding a position larger than a lot). |
| 3 | EAmount | Zero or too small an amount. |
| 4 | EDeadline | The deadline passed, or is more than 120 seconds ahead. |
| 5 | EFill | The order did not fill the exact size required. |
| 6 | ELiquidity | The payout is zero or more than the account's free cash. |
| 7 | EState | Not allowed in the token's current state. |
| 9 | EInBand | Rebalance refused: leverage is inside the band. |
| 10 | EProgress | A rebalance did not move leverage closer to the target. |
| 11 | EMinimum | The result is under your min_out. |
| 12 | ESlippage | The slippage asked for is over the Config's emergency ceiling. |
| 13 | EOverLevered | Buying is refused while leverage is above the band top, or the fill would pass the margin's leverage. |
| 14 | ENoFill | The venue filled nothing. |
From the Config (config module), the two a trader can see:
| Code | Name | Meaning |
|---|---|---|
| 1 | EVersion | The Config is halted, or the call went to another package version. |
| 4 | EPaused | Buying is paused. Sales still work. |
Risks#
- A 3x token loses about three times the market's move, and a single gap of about a third can zero it, like any 3x product.
- If the venue pauses or freezes a market, trading on it aborts until it clears.
- Pausing never blocks sells. The admin can pause buys on every token at once; sales keep working.
- A halt stops everything. To stop an exploit in progress, the admin can halt the Config. Every call on every token, sales included, is refused until the admin turns the Config back on, usually with fixed code.
- Winding down. The admin can wind a token down for good. Buying stops at once, the position closes in steps, and sales keep working throughout.
- If a market closes for good, anyone can settle the token at the venue's settlement prices and holders are paid from cash.
- Code upgrades are not timelocked: the UpgradeCap is held by the admin address so an exploit can be patched at once. See Security.