init383838

This commit is contained in:
ZOMBIIIIIII
2026-05-13 23:59:32 +03:00
parent 9fe5311bbf
commit 0661fffb88
8 changed files with 1155 additions and 71 deletions

View File

@@ -318,8 +318,8 @@
},
"/wallets/{chain}/sign-raw-evm-tx": {
"post": {
"summary": "Custodial sign + broadcast arbitrary EVM tx (Relay/Swap unsigned tx)",
"description": "Подписывает произвольную EVM tx (например `steps[0].items[0].data` из `/relay/execute/swap`). Сервер расшифровывает mnemonic, деривит privkey, ставит nonce, подписывает type-2 EIP-1559 tx, broadcast'ит. Если задан `feeTier` → переопределяет maxFeePerGas/maxPriority из тела актуальным из eth_feeHistory. ⚠️ Security: подписывает arbitrary `to`+`data` — в production надо whitelist'ить `to` (Relay routers) или требовать Relay attestation. Только ETH(1)/BSC(56).",
"summary": "Custodial sign + broadcast arbitrary EVM tx (Relay bridge)",
"description": "Подписывает unsigned EVM tx из Relay /execute response. Policy: `to` ДОЛЖЕН быть в Relay router allowlist; selector blacklist (approve/permit/setApprovalForAll). Для DEX swap'ов используй `/wallets/{chain}/swap` — там chained custodial без этих ограничений.",
"tags": ["Wallet Ops"],
"parameters": [{ "name": "chain", "in": "path", "required": true, "schema": { "type": "string", "enum": ["ETH", "BSC"] } }],
"requestBody": {
@@ -328,13 +328,115 @@
},
"responses": {
"200": { "description": "Broadcast successful", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TxBroadcastResponse" } } } },
"400": { "description": "Invalid input (bad to/data/value, chainId mismatch, invalid feeTier)" },
"400": { "description": "Policy violation: to not in allowlist OR forbidden selector OR cap exceeded" },
"404": { "description": "Wallet/mnemonic not found" },
"502": { "description": "Broadcast failed" },
"503": { "description": "Crypto service not ready" }
}
}
},
"/wallets/{chain}/swap": {
"post": {
"summary": "Custodial chained swap (BSC PancakeSwap / TRX SunSwap / SOL Jupiter)",
"description": "Полностью custodial swap в один HTTP-вызов. Никакого client-side signing. BSC: approve+swap chained (PancakeSwap V2, поддерживает BNB/USDT/USDC/DOGE/WBNB/BUSD). TRX: SunSwap TRX↔USDT. SOL: Jupiter aggregator (любые mints из registry). Slippage protection — server computes amountOutMin от actual quote с default 50 bps tolerance. Optional Idempotency-Key header для anti double-spend.",
"tags": ["Wallet Ops"],
"parameters": [{ "name": "chain", "in": "path", "required": true, "schema": { "type": "string", "enum": ["BSC", "TRX", "SOL"] } }],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"type": "object",
"title": "BSC/TRX swap (symbols)",
"required": ["from", "to", "amount"],
"properties": {
"from": { "type": "string", "description": "BSC: BNB|USDT|USDC|DOGE|WBNB|BUSD; TRX: TRX|USDT" },
"to": { "type": "string" },
"amount": { "type": "string", "description": "Smallest units (wei для 18-dec, sun для TRX 6-dec)" },
"slippageBps": { "type": "integer", "minimum": 1, "maximum": 1000, "description": "0.01%-10%. Default 50 (0.5%)." },
"feeTier": { "type": "string", "enum": ["slow", "normal", "fast"] }
}
},
{
"type": "object",
"title": "SOL swap (mints)",
"required": ["inputMint", "outputMint", "amount"],
"properties": {
"inputMint": { "type": "string", "description": "SPL mint address (base58)" },
"outputMint": { "type": "string" },
"amount": { "type": "string", "description": "Smallest units (lamports = 9-dec для SOL native)" },
"slippageBps": { "type": "integer", "minimum": 1, "maximum": 1000 }
}
}
]
}
}
}
},
"responses": {
"200": {
"description": "BSC: { approveTxid?, swapTxid }. TRX/SOL: { txid | signature }",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": { "type": "boolean" },
"data": {
"type": "object",
"properties": {
"chain": { "type": "string" },
"approveTxid": { "type": "string", "nullable": true, "description": "BSC only, если token-to-X swap требовал approve" },
"swapTxid": { "type": "string", "description": "BSC swap txid" },
"txid": { "type": "string", "description": "TRX txid" },
"signature": { "type": "string", "description": "SOL tx signature" }
}
}
}
}
}
}
},
"400": { "description": "Invalid pair / slippage / amount / unsupported chain" },
"404": { "description": "Wallet not found" },
"409": { "description": "Idempotency-Key reuse with different body, or operation in-flight" },
"502": { "description": "Swap failed (no liquidity / network error / contract revert)" },
"503": { "description": "Crypto service not ready" }
}
}
},
"/wallets/SOL/sign-and-broadcast-tx": {
"post": {
"summary": "Custodial sign + broadcast arbitrary Solana VersionedTransaction",
"description": "Подписывает unsigned serialized Solana tx (от Relay /execute SOL-side, или любого aggregator'а). Server verify feePayer === user's pubkey, partial-sign keypair'ом, broadcast, confirm.",
"tags": ["Wallet Ops"],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": ["transaction"],
"properties": {
"transaction": { "type": "string", "description": "Base64-encoded VersionedTransaction (max ~1500 bytes raw)" }
}
}
}
}
},
"responses": {
"200": {
"description": "Signed and broadcast",
"content": { "application/json": { "schema": { "type": "object", "properties": { "success": { "type": "boolean" }, "data": { "type": "object", "properties": { "signature": { "type": "string" }, "chain": { "type": "string" } } } } } } }
},
"400": { "description": "Invalid base64 / tx size / feePayer mismatch" },
"404": { "description": "SOL wallet/mnemonic not found" },
"502": { "description": "Sign or broadcast failed" }
}
}
},
"/btc/utxos/{address}": {
"get": {