Sigil ships a constant-product AMM as a native primitive. Pools, liquidity positions, and swaps are all transaction types — there is no contract to call. Fees are configured per-pool (in basis points) at create time.

When to use this

  • Bootstrap liquidity for a token you issued.
  • Execute an exact-input swap with a minimum-out guard.
  • Withdraw your share of pool reserves after collecting fees.

Prerequisites

  • Two assets to pair. Each is identified as either MINT (the native currency) or a token id like tok:demo:points.
  • The pool may not yet exist — if so, you’ll create it in step 1.

Recipe

1

Create a pool (or skip if it exists)

fee_bps is the per-swap fee in basis points (30 = 0.30%). min_lp_shares is your slippage guard.
await signAndSend({
  DexCreatePool: {
    asset_a: { Native: null },                       // MINT
    asset_b: { Token: { token_id: 'tok:demo:points' } },
    amount_a_desired: 1_000_000_000,                 // 1,000 MINT
    amount_b_desired: '50000',                       // 50,000 PTS
    fee_bps: 30,
    min_lp_shares: 1,
    expiration_height: null,
  },
});
On success the chain emits a pool_id you’ll use for all subsequent operations. Resolve it from the receipt’s event log or via sigil_listDexPools.
2

Quote a swap (no transaction)

Before submitting, get a deterministic quote.
curl -s "$SIGIL_RPC_URL" \
  -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"sigil_quoteDexSwapExactIn",
       "params":{
         "pool_id":"pool:mint:tok-demo-points",
         "asset_in":{"Native":null},
         "amount_in": 10000000
       }}'
Use the returned amount_out to set min_amount_out with your slippage tolerance — typically 50 bps below the quote.
3

Swap exact-in

await signAndSend({
  DexSwapExactIn: {
    pool_id: 'pool:mint:tok-demo-points',
    asset_in: { Native: null },
    amount_in: 10_000_000,           // 10 MINT
    min_amount_out: '480',           // protect against >0.5% slippage
    recipient_did: process.env.SIGIL_SENDER_DID,
    expiration_height: null,
  },
});
4

Remove liquidity

Burn your LP shares to redeem the underlying assets.
await signAndSend({
  DexRemoveLiquidity: {
    pool_id: 'pool:mint:tok-demo-points',
    lp_shares: 1_000_000,
    amount_a_min: 950_000_000,       // slippage floor for asset A
    amount_b_min: '47500',           // slippage floor for asset B
    recipient_did: process.env.SIGIL_SENDER_DID,
    expiration_height: null,
  },
});

Reading state

# Pool metadata, reserves, and fee tier
curl -s "$SIGIL_RPC_URL" -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"sigil_getDexPool",
       "params":{"pool_id":"pool:mint:tok-demo-points"}}'

# Your LP position
curl -s "$SIGIL_RPC_URL" -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"sigil_getDexPosition",
       "params":{"pool_id":"pool:mint:tok-demo-points","owner_did":"did:oas:sigil:agent:..."}}'

# Swap and liquidity events
curl -s "$SIGIL_RPC_URL" -H 'content-type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"sigil_getDexEvents",
       "params":{"pool_id":"pool:mint:tok-demo-points","limit":50}}'

Common errors

SymptomCauseFix
pool already existsPair already pooledUse DexAddLiquidity instead
slippage exceededPrice moved past min_amount_outRe-quote and resubmit
expiration height passedTx waited too long in mempoolResubmit with a later expiration_height or null
insufficient lp_sharesTried to remove more than you holdQuery sigil_getDexPosition first

See also