Skip to main content

Overview

  • Allowed Assets (/v1/config/allowed-assets): Governs which assets can be used as Asset B when creating pools. Acts as an RPC‑level allowlist, useful at launch.
  • Minimum Amounts (/v1/config/min-amounts): Enforces minimum sizes for swaps and liquidity ops.
  • Feature Status (/v1/config/feature-status): Toggles features on/off across the stack (used during incidents with Spark/SSP/infra).
The FlashnetClient exposes helpers to read these configs and already enforces them automatically before executing sensitive operations. You can also read them to guide your UI.

Allowed Assets

Controls which assets are permitted as Asset B for pool creation.
  • Endpoint: /v1/config/allowed-assets
  • Behavior: If the list is empty, all assets are allowed (wildcard). Otherwise, only entries with enabled: true are allowed.
  • SDK behavior: createConstantProductPool and createSingleSidedPool will fail early if Asset B is not allowed.
Example: pre‑check in UI before enabling the “Create Pool” button.
// Fetch policy (cached ~60s internally)
const allowed = await client.getAllowedAssets();

// If empty => wildcard allowed; else enforce exact hex asset identifier match
function isAssetBAllowed(assetBHex: string): boolean {
  if (!allowed || allowed.length === 0) return true;
  return allowed.some(
    (it) => it.enabled && it.asset_identifier.toLowerCase() === assetBHex.toLowerCase()
  );
}

// Example usage
const canCreate = isAssetBAllowed("<assetBHex>");
Note: The client already enforces this. Use the pre‑check to provide better UX.

Minimum Amounts

Defines per‑asset minimums used to validate swaps and liquidity operations.
  • Endpoint: /v1/config/min-amounts
  • Rules:
    • If the input asset has a minimum → input_amount >= min_amount.
    • If the output asset has a minimum → min_amount_out >= min_amount with 50% slippage tolerance applied.
    • If both assets have minimums → input asset check takes priority.
    • Same rules apply to liquidity adds and removals (each asset checked; output sides use the 50% relaxed rule).
  • SDK behavior: executeSwap, executeRouteSwap, addLiquidity, and removeLiquidity all validate these rules before sending funds or intents.
You can read the policy to inform inputs and validations in your UI.
// Raw list (for display)
const list = await client.getMinAmounts();

// Map keyed by HEX asset identifier (lowercased) => bigint minimum (only enabled entries)
const minMap = await client.getMinAmountsMap();

function getMinFor(assetHex: string): bigint | undefined {
  return minMap.get(assetHex.toLowerCase());
}

// Example: validate a swap form
function validateSwap({ assetInHex, assetOutHex, amountIn, minAmountOut }: {
  assetInHex: string;
  assetOutHex: string;
  amountIn: bigint;
  minAmountOut: bigint;
}): string | undefined {
  const inMin = getMinFor(assetInHex);
  const outMin = getMinFor(assetOutHex);

  if (inMin && amountIn < inMin) {
    return `Minimum for input asset is ${inMin.toString()}`;
  }

  if (!inMin && outMin) {
    const relaxed = outMin / 2n; // 50% slippage tolerance
    if (minAmountOut < relaxed) {
      return `Minimum for output asset is ${relaxed.toString()} (50% relaxed)`;
    }
  }

  return undefined;
}
Note: The client enforces the same logic at execution time; the above helps you block invalid inputs early.

Feature Status

Global kill‑switches and per‑feature flags that gate AMM operations.
  • Endpoint: /v1/config/feature-status
  • Example flags: master_kill_switch, allow_swaps, allow_add_liquidity, allow_withdraw_liquidity, allow_pool_creation, allow_route_swaps, allow_withdraw_fees.
  • SDK behavior: All state‑changing methods call an internal guard that throws if the required feature is disabled or if the master kill switch is active.
Use the helpers to conditionally enable UI actions and to display maintenance notices.
// Map<FeatureName, boolean>, cached briefly
const flags = await client.getFeatureFlags();

const isServiceDown = flags.get("master_kill_switch") === true;
const canSwap = flags.get("allow_swaps") === true;
const canCreatePools = flags.get("allow_pool_creation") === true;

if (isServiceDown) {
  // Show site‑wide banner: read‑only mode
}

// Disable buttons based on flags
// swapButton.disabled = !canSwap
// createPoolButton.disabled = !canCreatePools

Notes on Caching

The SDK caches these reads briefly to reduce network load:
  • Feature flags: ~5s TTL
  • Min amounts: ~5s TTL (map of enabled entries only)
  • Allowed assets: ~60s TTL
Reads are refreshed automatically after the TTL expires.

TLDR;

  • Use getAllowedAssets() to pre‑screen Asset B for pool creation.
  • Use getMinAmounts() / getMinAmountsMap() to validate UI inputs for swaps and liquidity.
  • Use getFeatureFlags() to toggle UI actions and show maintenance states.
  • All execution methods in the SDK already enforce these policies server‑side and client‑side for safety.