Skip to main content
POST
/
market
/
{marketId}
/
settle
curl -X POST http://localhost:3001/market/m1a2b3c4-d5e6-7890-abcd-ef1234567890/settle
{
  "success": true,
  "data": {
    "marketId": "m1a2b3c4-d5e6-7890-abcd-ef1234567890",
    "reportId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "companyName": "rippled",
    "consensusValuationM": 11.5,
    "valuationCapXRP": "23000000000000",
    "equityToken": {
      "mptIssuanceId": "00000001A1B2C3...",
      "founderAddress": "rXXX...",
      "companyName": "rippled",
      "totalShares": "10000000",
      "royaltyBps": 100,
      "transferable": true,
      "createdAt": 1710410000
    },
    "escrows": [
      {
        "userId": "alice",
        "xrplAddress": "rABC...",
        "sharesAllocated": "5555556",
        "condition": "A0258020...",
        "explorerLink": "https://testnet.xrpl.org/transactions/..."
      }
    ],
    "safe": {
      "contractAddress": "0xABC123...",
      "documentHash": "0xDEF456...",
      "deployTxHash": "0x789...",
      "linkTxHash": "0xAAA...",
      "settleTxHash": "0xBBB...",
      "baseSepoliaExplorerUrl": "https://sepolia.basescan.org/address/0xABC123...",
      "documentPreview": "SAFE Agreement for rippled..."
    },
    "rlusdFeeHash": null,
    "rlusdTrustLineHash": "ABC123...",
    "settledAt": "2026-03-14T10:15:00.000Z",
    "explorerLinks": [
      "https://testnet.xrpl.org/transactions/..."
    ]
  }
}
This is the main event. Settlement converts the market consensus into real on-chain equity tokens with vesting escrows.

Path Parameters

marketId
string
required
Market ID.

Prerequisites

  • Market must exist and have at least one bet (consensus valuation)
  • Associated report must be complete
  • FOUNDER_SEED and AGENT_SEED must be set in .env

Response

data
SettlementResult
curl -X POST http://localhost:3001/market/m1a2b3c4-d5e6-7890-abcd-ef1234567890/settle
{
  "success": true,
  "data": {
    "marketId": "m1a2b3c4-d5e6-7890-abcd-ef1234567890",
    "reportId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "companyName": "rippled",
    "consensusValuationM": 11.5,
    "valuationCapXRP": "23000000000000",
    "equityToken": {
      "mptIssuanceId": "00000001A1B2C3...",
      "founderAddress": "rXXX...",
      "companyName": "rippled",
      "totalShares": "10000000",
      "royaltyBps": 100,
      "transferable": true,
      "createdAt": 1710410000
    },
    "escrows": [
      {
        "userId": "alice",
        "xrplAddress": "rABC...",
        "sharesAllocated": "5555556",
        "condition": "A0258020...",
        "explorerLink": "https://testnet.xrpl.org/transactions/..."
      }
    ],
    "safe": {
      "contractAddress": "0xABC123...",
      "documentHash": "0xDEF456...",
      "deployTxHash": "0x789...",
      "linkTxHash": "0xAAA...",
      "settleTxHash": "0xBBB...",
      "baseSepoliaExplorerUrl": "https://sepolia.basescan.org/address/0xABC123...",
      "documentPreview": "SAFE Agreement for rippled..."
    },
    "rlusdFeeHash": null,
    "rlusdTrustLineHash": "ABC123...",
    "settledAt": "2026-03-14T10:15:00.000Z",
    "explorerLinks": [
      "https://testnet.xrpl.org/transactions/..."
    ]
  }
}

Settlement Steps

  1. Deploy SAFE (optional) — If BASE_PRIVATE_KEY is set, deploys a MetaLex SAFE agreement on Base Sepolia with company metadata and valuation cap
  2. Close market (if still open)
  3. Issue MPT equity tokenMPTokenIssuanceCreate with auth, escrow, and lock flags. If SAFE was deployed, embeds the contract address and document hash in MPT metadata
  4. Cross-chain link — Links the XRPL MPT issuance ID back to the Base contract and marks the SAFE as settled
  5. For each participant (max 5, serial for sequence safety):
    • Generate testnet wallet via faucet
    • Holder opt-in (MPTokenAuthorize)
    • Founder authorization (MPTokenAuthorize)
    • Create vesting escrow (EscrowCreate) with 90-day cliff and crypto-condition
  6. RLUSD trust line — Setup trust line for stablecoin
  7. Platform fee — Send 2.5% fee in RLUSD (non-critical, expected to fail on testnet)
This endpoint is idempotent. Calling it on an already-settled market returns the existing settlement result.
Settlement takes ~30 seconds on testnet due to sequential XRPL transactions with 3-5 second finality each.