hop.fun
hop.fun — documentation

Getting Started

Both contracts are permissionless on Sui. Anyone can call them directly — no API keys, no whitelist.

You can:


Example: Buy on Bonding Curve

const tx = new Transaction();
const [coin] = tx.splitCoins(tx.gas, [tx.pure.u64(amount)]);

tx.moveCall({
  target: `${HOPLAUNCH_PACKAGE}::curve::buy`,
  typeArguments: [coinType],
  arguments: [
    tx.object(HOPV4_CONFIG),
    tx.object(DYNAMIC_FEE),
    tx.object(curveId),
    tx.object(HOPLAUNCH_CONFIG),
    coin,
    tx.pure.u64(0), // min amount out
  ],
});

Example: Swap on HopV4

const tx = new Transaction();
const coinIn = tx.splitCoins(tx.gas, [tx.pure.u64(amount)]);
const coinZero = tx.moveCall({
  target: "0x2::coin::zero",
  typeArguments: [coinType],
});

tx.moveCall({
  target: `${HOPV4_PACKAGE}::trade::swap`,
  typeArguments: [coinType, "0x2::sui::SUI"],
  arguments: [
    tx.object(HOPV4_CONFIG),
    tx.object(DYNAMIC_FEE),
    tx.object(poolId),
    coinZero,   // coin_x (token) - zero for buy
    coinIn,     // coin_y (SUI)
    tx.pure.bool(false),  // x2y (false = buying token with SUI)
    tx.pure.bool(true),   // is_amount_in
    tx.pure.u128(MAX_SQRT_PRICE), // sqrt_price_limit
  ],
});

See contracts for all package IDs and object IDs.