{
  "$schema": "https://schemas.pump.fun/deploy/v3/manifest.schema.json",
  "manifestVersion": "3.4.1",
  "kind": "OffchainCustomContractDeployment",
  "generatedBy": "amms-orchestrator",
  "buildProfile": "release-verifiable",
  "network": {
    "cluster": "mainnet-beta",
    "commitment": "confirmed",
    "identity": {
      "genesisHash": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
    },
    "rpc": {
      "primary": "${SOLANA_RPC_PRIMARY}",
      "fallback": "${SOLANA_RPC_FALLBACK}",
      "tertiary": "${SOLANA_RPC_TERTIARY}",
      "wsEndpoint": "${SOLANA_WS_ENDPOINT}",
      "maxRetries": 8,
      "confirmTransactionInitialTimeout": 90000,
      "rateLimit": { "requestsPerSecond": 40, "burst": 80 },
      "sendOptions": { "skipPreflight": false, "maxRetries": 5, "preflightCommitment": "processed" },
      "loadBalancing": { "strategy": "round-robin-with-health-check", "healthCheckIntervalMs": 5000, "ejectUnhealthyAfterFailures": 3 }
    },
    "priorityFees": {
      "strategy": "dynamic",
      "source": "helius-priority-fee-api",
      "percentile": 75,
      "minMicroLamports": 10000,
      "maxMicroLamports": 2500000,
      "computeUnitLimit": 600000,
      "computeUnitPriceBuffer": 1.2
    },
    "addressLookupTables": {
      "enabled": true,
      "tables": ["${ALT_JUPITER_ROUTE}", "${ALT_POOL_ACCOUNTS}", "${ALT_RESERVE_VAULT}"],
      "autoExtendOnDeploy": true
    }
  },
  "token": {
    "standard": "spl-token",
    "tokenProgram": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
    "name": "AMM-S",
    "symbol": "AMMS",
    "decimals": 6,
    "totalSupply": "1000000000000000",
    "mintAuthority": { "action": "revoke-post-launch" },
    "freezeAuthority": null,
    "description": "AMM-S is an SPL token whose liquidity is never denominated in SOL. The reserve side of its pool — the asset that defines price, the asset that leaves when a holder exits — is tokenized equity (xSPY). A routing layer sits in front of the market maker: an inbound buy in SOL or USDC is not forwarded, it is atomically cross-program-invoked into Jupiter, swapped across the deepest xSPY route, and delivered to the reserve vault as stock before it ever touches the pool. The user signs one transaction; inside it a two-leg sequence executes — currency in, stock down, position out.\n\nThe deployment is an offchain-orchestrated custom contract. An Anchor program owns the reserve vault through program-derived addresses and enforces a single invariant: no asset other than xSPY may enter the reserve. The program does not fork a market maker; it constrains what the market maker is permitted to hold. The build is compiled and verified against published source offchain, deployed through this manifest, and its upgrade authority is burned on finalization, leaving the routing invariant immutable. A stateless keeper monitors xSPY route depth across venues and posts refreshed slippage bounds on-chain as parameters — a crank, never a custodian; it holds no funds, touches no vault, and can only make the router more accurate.\n\nThe structural consequence is that the token's liquidity is a position in the S&P 500. When the index rises, the reserve appreciates on its own and the same quantity of xSPY supports a higher effective floor, with no buy of AMM-S required. Price is quoted in units of xSPY, so the chart is a ratio against the market rather than a dollar figure. AMM-S is not a share, confers no ownership, pays no dividend, and grants no redemption right against the reserve — it is a token whose liquidity architecture is denominated in stock.",
    "metadata": {
      "uri": "${IRYS_METADATA_URI}",
      "image": "${IRYS_IMAGE_URI}",
      "externalUrl": "https://amm-s.xyz",
      "creator": "${CREATOR_PUBKEY}",
      "mutable": false,
      "sellerFeeBasisPoints": 0,
      "collection": null,
      "uses": null,
      "attributes": [
        { "trait_type": "reserve_asset", "value": "xSPY" },
        { "trait_type": "quote_denomination", "value": "tokenized-equity" },
        { "trait_type": "launch_venue", "value": "pump.fun" },
        { "trait_type": "graduation_target", "value": "raydium-clmm" }
      ]
    }
  },
  "reserveAsset": {
    "symbol": "xSPY",
    "mint": "${XSPY_MINT}",
    "issuerModel": "fully-collateralized-tokenized-equity",
    "underlying": "S&P 500 ETF",
    "decimals": 8,
    "redeemable": "1:1 against underlying held by regulated custodian",
    "acceptedRoutingVenues": ["raydium", "meteora", "orca", "phoenix"],
    "depthOracle": { "provider": "jupiter", "refreshIntervalMs": 20000 }
  },
  "launch": {
    "platform": "pump.fun",
    "mode": "offchain-custom-contract",
    "bondingCurve": {
      "enabled": true,
      "type": "constant-product",
      "curveModel": "x*y=k",
      "quoteAsset": "xSPY",
      "quoteMint": "${XSPY_MINT}",
      "initialVirtualQuoteReserves": "30000000000",
      "initialVirtualBaseReserves": "1073000000000000",
      "initialRealQuoteReserves": "0",
      "graduationQuoteThreshold": "85000000000",
      "feeBasisPoints": 0,
      "creatorAllocationBps": 0,
      "presale": false,
      "teamAllocation": false,
      "antiSnipe": {
        "enabled": true,
        "maxBuyBpsOfSupplyPerWalletFirstBlock": 100,
        "blockWindow": 3,
        "penaltyRoute": "revert"
      }
    },
    "graduation": {
      "target": "raydium-clmm",
      "autoMigrate": true,
      "poolPair": ["AMMS", "xSPY"],
      "lpDisposition": "burn",
      "tickSpacing": 64,
      "feeTierBps": 25,
      "initialPriceFromCurve": true,
      "migrationGuard": {
        "requireCurveFilled": true,
        "requireKeeperBoundsFresh": true,
        "maxMigrationSlippageBps": 50
      }
    }
  },
  "program": {
    "framework": "anchor",
    "anchorVersion": "0.30.1",
    "solanaVersion": "1.18.26",
    "rustToolchain": "1.79.0",
    "programId": "${AMMS_PROGRAM_ID}",
    "programDataAccount": "${AMMS_PROGRAM_DATA}",
    "verifiedBuild": {
      "enabled": true,
      "dockerImage": "solanafoundation/solana-verifiable-build:1.18.26",
      "sourceRepo": "https://github.com/amm-s/amms-router",
      "commit": "${SOURCE_COMMIT_SHA}",
      "libName": "amms_router",
      "bpfName": "amms_router.so",
      "hashAlgorithm": "sha256",
      "expectedProgramHash": "${EXPECTED_PROGRAM_HASH}",
      "publishTo": "osec-verified-programs-registry"
    },
    "upgradeAuthority": {
      "action": "burn-on-finalize",
      "intermediateAuthority": "${DEPLOYER_MULTISIG}",
      "finalAuthority": null,
      "timelockSeconds": 0
    },
    "accounts": {
      "config": { "type": "pda", "seeds": ["config", "${AMMS_MINT}"], "space": 512 },
      "reserveVaultAuthority": { "type": "pda", "seeds": ["reserve", "${AMMS_MINT}"], "space": 0 },
      "reserveVault": { "type": "associated-token-account", "owner": "reserveVaultAuthority", "mint": "${XSPY_MINT}" },
      "slippageBounds": { "type": "pda", "seeds": ["bounds", "${AMMS_MINT}"], "space": 256 },
      "routeCache": { "type": "pda", "seeds": ["route", "${AMMS_MINT}"], "space": 1024 },
      "eventLog": { "type": "pda", "seeds": ["events", "${AMMS_MINT}"], "space": 4096 }
    },
    "instructions": [
      { "name": "initialize", "signers": ["creator"], "mutates": ["config"], "guards": ["only_creator", "config_uninitialized"] },
      { "name": "create_mint", "signers": ["creator"], "mutates": ["mint"], "guards": ["config_initialized"] },
      { "name": "launch_bonding_curve", "signers": ["creator"], "mutates": ["config", "reserveVault"], "guards": ["mint_created", "curve_not_launched"] },
      { "name": "route_buy", "signers": ["buyer"], "cpi": ["jupiter", "pool"], "atomic": true, "guards": ["reserve_mint_is_xspy", "within_slippage_bounds"] },
      { "name": "route_sell", "signers": ["seller"], "cpi": ["pool", "jupiter?"], "atomic": true, "guards": ["reserve_mint_is_xspy"] },
      { "name": "post_slippage_bounds", "signers": ["keeper"], "mutates": ["slippageBounds"], "guards": ["only_keeper", "bounds_monotonic_sanity"] },
      { "name": "graduate", "signers": ["permissionless"], "cpi": ["raydium"], "guards": ["curve_filled", "bounds_fresh"] },
      { "name": "finalize", "signers": ["creator"], "effects": ["revoke_mint_authority", "burn_upgrade_authority"], "guards": ["graduated"] }
    ],
    "invariants": [
      "reserve_vault.mint == XSPY_MINT",
      "no_instruction_may_transfer_non_xspy_into(reserve_vault)",
      "buy_route.legs == [JUPITER_SWAP_TO_XSPY, POOL_SWAP_TO_AMMS]",
      "sell_route.legs == [POOL_SWAP_TO_XSPY, OPTIONAL(JUPITER_SWAP_XSPY_TO_QUOTE)]",
      "transaction_is_atomic_or_reverts",
      "keeper_cannot_move_value_from(reserve_vault)",
      "post_finalize(upgrade_authority == null && mint_authority == null)"
    ],
    "errorCodes": {
      "6000": "ReserveMintMismatch",
      "6001": "SlippageExceeded",
      "6002": "RouteLegFailed",
      "6003": "Unauthorized",
      "6004": "CurveNotFilled",
      "6005": "BoundsStale",
      "6006": "AntiSnipeTriggered",
      "6007": "NonAtomicExecution"
    }
  },
  "routing": {
    "aggregator": "jupiter",
    "jupiterApi": "https://quote-api.jup.ag/v6",
    "jupiterProgram": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4",
    "reserveMint": "${XSPY_MINT}",
    "quoteMints": { "sol": "So11111111111111111111111111111111111111112", "usdc": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" },
    "buyRoute": {
      "steps": [
        { "leg": 1, "action": "cpi.jupiter.swap", "from": ["SOL", "USDC"], "to": "xSPY", "slippageBpsSource": "onchain.slippageBounds", "onlyDirectRoutes": false, "maxAccounts": 40 },
        { "leg": 2, "action": "cpi.pool.swap", "from": "xSPY", "to": "AMMS" }
      ],
      "atomic": true,
      "revertOnAnyLegFailure": true,
      "computeUnitEstimate": 480000
    },
    "sellRoute": {
      "steps": [
        { "leg": 1, "action": "cpi.pool.swap", "from": "AMMS", "to": "xSPY" },
        { "leg": 2, "action": "cpi.jupiter.swap", "from": "xSPY", "to": ["SOL", "USDC"], "optional": true }
      ],
      "atomic": true,
      "revertOnAnyLegFailure": true,
      "computeUnitEstimate": 420000
    },
    "slippage": {
      "defaultBps": 75,
      "maxBps": 300,
      "boundsRefreshedBy": "keeper",
      "boundsPostedOnchain": true,
      "stalenessThresholdSeconds": 120,
      "onStaleBounds": "reject-buys-allow-sells"
    },
    "mevProtection": {
      "enabled": true,
      "provider": "jito",
      "bundleTips": { "enabled": true, "tipLamports": 100000 },
      "sandwichGuard": "atomic-route-with-tight-bounds"
    }
  },
  "keeper": {
    "type": "stateless-crank",
    "custodiesFunds": false,
    "signsValueTransfers": false,
    "interval": "20s",
    "signer": "${KEEPER_PUBKEY}",
    "redundancy": { "instances": 2, "leaderElection": "onchain-slot-lease", "failoverSeconds": 40 },
    "responsibilities": [
      "poll xSPY route depth across Raydium, Meteora, Orca, Phoenix via Jupiter",
      "recompute acceptable slippage bounds from live depth and recent fills",
      "post bounds to slippageBounds PDA via post_slippage_bounds",
      "emit telemetry to monitoring pipeline"
    ],
    "constraints": [
      "may only write to slippageBounds PDA",
      "cannot sign transfers out of reserve_vault",
      "cannot alter config or program"
    ],
    "failureMode": "trades continue against last posted bounds until staleness threshold, then buys reject and sells continue"
  },
  "offchainOrchestration": {
    "pipeline": [
      { "stage": "preflight", "runner": "scripts/preflight_checks.ts", "asserts": ["rpc_reachable", "keypairs_present", "xspy_mint_valid", "alt_tables_exist"] },
      { "stage": "build", "cmd": "anchor build --verifiable", "artifact": "target/verifiable/amms_router.so" },
      { "stage": "hash", "cmd": "sha256sum target/verifiable/amms_router.so", "compareTo": "${EXPECTED_PROGRAM_HASH}" },
      { "stage": "verify", "cmd": "solana-verify verify-from-repo --library-name amms_router ${SOURCE_REPO}" },
      { "stage": "upload-metadata", "provider": "irys", "network": "mainnet", "pin": true },
      { "stage": "create-alts", "runner": "scripts/create_lookup_tables.ts" },
      { "stage": "deploy-program", "cmd": "solana program deploy --program-id ${AMMS_PROGRAM_ID} --with-compute-unit-price ${DEPLOY_CU_PRICE}" },
      { "stage": "init-config", "instruction": "initialize", "signer": "${CREATOR_PUBKEY}" },
      { "stage": "create-mint", "instruction": "create_mint" },
      { "stage": "launch-curve", "instruction": "launch_bonding_curve" },
      { "stage": "seed-bounds", "instruction": "post_slippage_bounds", "signer": "${KEEPER_PUBKEY}" },
      { "stage": "revoke-mint-authority", "instruction": "finalize.revoke_mint_authority" },
      { "stage": "burn-upgrade-authority", "cmd": "solana program set-upgrade-authority --final" },
      { "stage": "verify-invariants", "runner": "scripts/assert_invariants.ts", "asserts": ["reserve_mint_is_xspy", "upgrade_authority_null", "mint_authority_null"] },
      { "stage": "smoke-test", "runner": "scripts/smoke_buy_sell.ts", "amountSol": "0.05", "expectRevertOnStaleBounds": true }
    ],
    "secrets": [
      "CREATOR_KEYPAIR",
      "KEEPER_KEYPAIR",
      "DEPLOYER_MULTISIG_KEYPAIR",
      "SOLANA_RPC_PRIMARY",
      "IRYS_PRIVATE_KEY",
      "HELIUS_API_KEY",
      "JITO_AUTH_KEYPAIR"
    ],
    "dryRunFirst": true,
    "rollbackOnStageFailure": true,
    "idempotencyKey": "${DEPLOY_RUN_ID}",
    "concurrency": 1,
    "ci": {
      "provider": "github-actions",
      "workflow": ".github/workflows/deploy.yml",
      "requiredChecks": ["anchor-test", "verifiable-build-match", "invariant-suite"],
      "environmentProtection": "manual-approval"
    }
  },
  "security": {
    "audits": [
      { "firm": "${AUDIT_FIRM_1}", "status": "required-before-mainnet", "reportUri": "${AUDIT_REPORT_URI_1}" }
    ],
    "bugBounty": { "enabled": true, "platform": "immunefi", "maxPayoutUsd": 50000, "scope": ["amms_router program", "keeper signer authority"] },
    "accessControl": {
      "creator": "${CREATOR_PUBKEY}",
      "keeper": "${KEEPER_PUBKEY}",
      "deployerMultisig": { "address": "${DEPLOYER_MULTISIG}", "threshold": "2-of-3", "members": ["${SIGNER_1}", "${SIGNER_2}", "${SIGNER_3}"] }
    },
    "postDeployImmutability": ["upgrade_authority == null", "mint_authority == null", "freeze_authority == null"],
    "reentrancyModel": "solana-single-threaded-tx-atomicity",
    "oracleTrustAssumptions": ["jupiter route depth is advisory only", "keeper bounds bound slippage, never redirect funds"]
  },
  "monitoring": {
    "telemetry": { "provider": "grafana-cloud", "metrics": ["buy_revert_rate", "sell_revert_rate", "bounds_staleness_seconds", "reserve_xspy_balance", "effective_floor_ratio"] },
    "alerts": [
      { "name": "BoundsStale", "condition": "bounds_staleness_seconds > 120", "severity": "high", "notify": ["pagerduty"] },
      { "name": "HighRevertRate", "condition": "buy_revert_rate > 0.25 over 5m", "severity": "medium", "notify": ["discord-webhook"] },
      { "name": "ReserveMintDrift", "condition": "reserve_vault.mint != XSPY_MINT", "severity": "critical", "notify": ["pagerduty", "sms"] }
    ],
    "indexer": { "provider": "helius-webhooks", "trackedInstructions": ["route_buy", "route_sell", "graduate"], "sink": "${INDEXER_DB_URL}" }
  },
  "explorer": {
    "tx": "https://solscan.io/tx/{signature}",
    "account": "https://solscan.io/account/{address}",
    "token": "https://solscan.io/token/{mint}",
    "program": "https://solscan.io/account/{programId}"
  },
  "tracking": {
    "provider": "birdeye",
    "chain": "solana",
    "apiKeyEnv": "BIRDEYE_API_KEY",
    "pollIntervalSeconds": 30,
    "cacheSeconds": 25,
    "endpoints": {
      "overview": "/defi/token_overview?address={mint}",
      "trades": "/defi/txs/token?address={mint}&tx_type=swap&sort_type=desc&limit=10",
      "holders": "/defi/v3/token/holder?address={mint}&limit=1",
      "price": "/defi/price?address={mint}"
    },
    "displayFields": ["marketCap", "holders", "recentTrades"]
  }
}
