Pure-ledger PANDASTR with transfer tax (default 15%, owner up to 25%) and a built-in DIESEL ↔ PANDASTR AMM.
Any wallet, site, or bot can call SwapBuy / SwapSell — no authorized swap contract.
SellPanda lets users attach Alkane Pandas (2:614) and receive DIESEL at the owner-set price. The contract converts accumulated fee PANDASTR through the internal AMM at sell time (no pre-funded vault).
| Op | Name | Notes |
|---|---|---|
| 0 | Initialize | owner, fee_bps, pool_panda, founder, name, symbol + optional seed DIESEL |
| 1 | Transfer | signed; fee on amount |
| 2 | SwapBuy | attach DIESEL → PANDASTR ledger (permissionless) |
| 3 | SwapSell | signed; PANDASTR → DIESEL out (permissionless) |
| 4 | SellPanda | attach Panda 2:614 → DIESEL out (converts /fee_p on the fly) |
| 6 | SetPaused | owner |
| 7 | SetFeeBps | owner |
| 8 | SetPandaPrice | owner — DIESEL per Panda (0 = buyback off) |
| 9 | WithdrawFees | owner — /fee_p → owner ledger |
| Op | Returns |
|---|---|
| 20 | GetBalance(pk) |
| 21 | GetPoolPanda |
| 22 | GetFeeState — fee_bal(16) ‖ fee_bps(4) |
| 23 | GetPoolState — diesel(16) ‖ panda(16) |
| 24 | GetBuybackState — price(16) ‖ fee_p(16) ‖ panda_bought(16) ‖ pool_d(16) ‖ pool_p(16) |
| 25 | GetPandaPrice — diesel per Panda (u128) |
| 26 | GetAdminNonce — owner nonce (u64) |
| 101–103 | name, symbol, total supply |
| Offset | Field |
|---|---|
| 0 | owner (32 B) |
| 32 | fee_bps (4) — 1500 = 15% |
| 36 | pool_pandrastr (16) — AMM inventory (ledger) |
| 52 | founder_amount (16) — credit owner ledger |
| 68+ | name, symbol |
Attach optional seed DIESEL 2:0 in the same tx for initial pool_diesel.
Panda buyback price starts at 0 (disabled) until owner calls SetPandaPrice.
x = pool_diesel (attached alkanes on this contract)
y = pool_pandrastr (ledger)
out = (y × Δx) / (x + Δx)
15% tax applies on the PANDASTR leg (buy and sell), same as Transfer.
Calldata: min_diesel(16)
Attach: one or more Alkane Panda 2:614 (amount = count; typically 1 per NFT).
Flow:
diesel_pay = panda_count × /panda_price- Contract sells enough PANDASTR from
/fee_pthrough the AMM (no second tax) to free ≥diesel_payDIESEL from/pool_d - User receives
diesel_payDIESEL; Pandas stay on the contract UTXO - Fails if
/fee_ptoo low, pool too thin, or price is0
Example: price = 100000000 (1 DIESEL in 8-decimal base units), attach 1 Panda → user gets 1 DIESEL if fees + pool can support conversion.
Calldata: owner(32) ‖ sig(64) ‖ nonce(8) ‖ price_u128(16)
Domain PSTR_PANDAPRICE, action = price(16).
Set 0 to disable buyback.
# Read current price (DIESEL base units)
TOKEN=2:N node get-panda-price.mjs
TOKEN=2:N FULL=1 node get-panda-price.mjs # + full buyback state
# Owner update price (1 DIESEL = 100000000 base units if 8 decimals)
MNEMONIC="..." TOKEN=2:N PANDA_PRICE_DIESEL=100000000 CONFIRM=yes node set-panda-price.mjs
# Disable buyback
MNEMONIC="..." TOKEN=2:N PANDA_PRICE_DIESEL=0 CONFIRM=yes node set-panda-price.mjsOn-chain views: opcode 25 GetPandaPrice, opcode 8 SetPandaPrice (owner-signed).
Calldata: min_pandrastr_out(16) ‖ buyer_pk(32)
Attach: DIESEL to token contract.
Calldata: user_pk(32) ‖ amount(16) ‖ min_diesel(16) ‖ nonce(8) ‖ sig(64)
Domain PSTR_SWAPSELL, action = amount(16) ‖ min_diesel(16), per-user nonce /u/{pk}.
Outgoing: DIESEL to tx pointer.
Domain PSTR_TRANSFER, action = to(32) ‖ amount(16), per-user nonce /u/{pk}.
cd contracts/panda_strategy_token
cargo build --release --target wasm32-unknown-unknown
MNEMONIC="..." FEE_BPS=1500 POOL_PANDA=... FOUNDER=... \
TOKEN_NAME="Panda Strategy" TOKEN_SYMBOL=PANDASTR \
CONFIRM=yes node deploy-token.mjsAfter deploy: SetPandaPrice to enable NFT buyback (e.g. 1 DIESEL per Panda in base units).
Attach seed DIESEL in the Initialize reveal tx (protostone edict).