@tokemak/auto
v0.1.2
Published
Headless TypeScript SDK for the **AUTO** token: **sAUTO staking** (lock/unlock/rewards), **cross-chain bridging** (LayerZero V2 OFT), and the **ETH/AUTO Uniswap V4 LP pool** (reads + Merkl reward claims). The TOKE-side products (legacy accTOKE exits, TOKE
Readme
@tokemak/auto
Headless TypeScript SDK for the AUTO token: sAUTO staking
(lock/unlock/rewards), cross-chain bridging (LayerZero V2 OFT), and the
ETH/AUTO Uniswap V4 LP pool (reads + Merkl reward claims). The TOKE-side
products (legacy accTOKE exits, TOKE→AUTO migration, TOKE bridging) live in
@tokemak/toke.
Runtime dependencies: viem + fetch. No React, no wagmi, no GraphQL client.
Reads return data or throw typed TokemakSdkErrors; builders return unsigned
transactions — nothing executes on its own.
Quickstart
import { createTokemakClient, sendTransaction } from "@tokemak/sdk-core";
import {
getStaking,
getUserStaking,
getBridgeQuote
} from "@tokemak/auto/queries";
import { prepareLock, prepareBridge } from "@tokemak/auto/transactions";
const client = createTokemakClient({ chainId: 1, rpcUrl: RPC_URL });
const staking = await getStaking(client); // sAUTO supply/TVL/APR/cycle/status
const position = await getUserStaking(client, { owner }); // null = no position
// Lock 100 AUTO (16 cycles). Plan includes an `approval` tx iff allowance is short.
const plan = await prepareLock(client, { owner, amount: 100n * 10n ** 18n });
if (plan.approval) await sendTransaction(walletClient, plan.approval);
await sendTransaction(walletClient, plan.transaction);Surface
- Queries:
getStaking,getUserStaking,getStakingRewardsHistory,getUserStakingRewards,getBridgeQuote,getLpPool,getUserLpPositions,getUserLpRewards,getTokenPrices(re-export). - Transactions:
prepareLock(gated),prepareRequestUnlock,prepareUnlock,prepareCancelUnlockRequest,prepareClaimStakingRewards,prepareBridge,prepareClaimLpRewards,prepareApprove. - Registry data in
@tokemak/config:AUTO_STAKING_REGISTRY,AUTO_BRIDGE_REGISTRY,AUTO_LP_POOL_REGISTRY— every address/symbol/eid verified on-chain 2026-07-07 (the V4 pool key is verified by recomputing the poolId hash). - Shared machinery in
@tokemak/sdk-core, reused by@tokemak/toke: AccToke reads, rewardsV1 payloads, and the full LayerZero bridge surface (getBridgeQuote/prepareBridge/prepareApprove) — this package binds it toAUTO_BRIDGE_REGISTRY.
Quirks agents should know
- The sAUTO ABI uses legacy "toke" naming.
lockToke()locks AUTO;toke()returns the AUTO address (verified on-chain). Don't let the names mislead tooling. - Locks are sender-bound.
lockTokedebits and creditsmsg.sender; the receiver-creditinglockTokeForis role-gated on-chain (LOCK_FOR_ROLE), soprepareLockhas no receiver param. To stake for another account, use@tokemak/toke'sprepareMigrateAndStake(its receiver param goes through the role-holding conversion contract). - The lock duration is currently fixed:
minLockCycles == maxLockCycles == 16. - Two-phase exit:
requestWithdrawal(amount)→ wait until the request'sminCycle→withdraw(amount); requests are only accepted in cycles where(currentCycle − lockCycle) % lockDuration == 0. Exits are never gated by the SDK, but the contract'swithdrawiswhenNotPausedon-chain. - Staking reward claims are strictly sender-bound and payload amounts are
cumulative (claimable = amount − alreadyClaimed). Payloads come from
the keyless IPFS mirror (
endpoints.rewardsIpfs), current cycle falling back one cycle while the new file publishes. Rewards pay in AUTO. - Staking APR is subgraph-derived:
currentAprPerCreditis wei-scaled (1e18) per cycle × 16 cycles, returned as a fraction (0.56 = 56%). - Bridging: mainnet uses the OFTAdapter lockbox (approval in the plan);
satellites burn from the sender. Recipient is a real parameter (defaults
to sender); excess native fee refunds to the sender. Amounts below
10^12raw are dust;minAmountReceivedis the exact truncation. No AUTO OFT on Sonic. Track deliveries athttps://layerzeroscan.com/tx/{hash}. - LP is read + claim only. Position entry/exit happens on the Uniswap UI;
no LP tx builders exist by design.
getLpPoolTVL prefers the V4 subgraph and falls back to a labeled on-chain full-range approximation (tvlSource). TheGraph's gateway requires a key even on the "public" URL — keyless callers get the approximation, andgetUserLpPositionsneeds eithergraphApiKey/endpoints.uniV4SubgraphorknownTokenIds. - Merkl proofs rotate (~4 h): build
prepareClaimLpRewardsand send promptly; refetch if stale. Merkl amounts are cumulative — the distributor no-ops already-claimed portions. LP rewards currently pay in TOKE.
Verification
pnpm --filter @tokemak/auto test # pure-logic unit tests (V4 math/decoding)
pnpm --filter @tokemak/auto smoke # live mainnet + Base checks with real actorsSMOKE_SKIP_TOKEMAK_SUBGRAPH=1 skips the two Tokemak-subgraph checks during
backend outages (loudly; not a full verification).
