{
  "openapi": "3.0.0",
  "info": {
    "title": "Circle Gateway Fast Deposits API",
    "version": "2.0.0",
    "description": "REST API for creating quoted Circle Gateway deposit vaults, queueing gasless funding via ERC-3009, polling vault and job status."
  },
  "servers": [
    {
      "url": "https://api.eco.com",
      "description": "Mainnet"
    }
  ],
  "tags": [
    {
      "name": "Circle Gateway"
    },
    {
      "name": "Gasless funding"
    }
  ],
  "paths": {
    "/circle-gateway/v2/depositAddresses": {
      "post": {
        "tags": [
          "Circle Gateway"
        ],
        "summary": "Create a quoted Circle Gateway deposit vault",
        "description": "Returns a source-chain vault address plus the requested amount and quote deadline. Fund the vault with at least `amount` USDC before `deadline` and Eco publishes the deposit intent. Repeating the same request while the quote is still pending and unexpired returns the same vault.",
        "operationId": "createCircleGatewayDepositVault",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CircleGatewayDepositAddressDTO"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quoted vault created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CircleGatewayDepositAddressResponseDTO"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid input"
          }
        }
      }
    },
    "/circle-gateway/v2/depositAddresses/{vaultAddress}": {
      "get": {
        "tags": [
          "Circle Gateway"
        ],
        "summary": "Get Circle Gateway deposit vault status",
        "description": "Returns the persisted quoted gateway intent state and metadata for a vault address.",
        "operationId": "getCircleGatewayDepositVaultStatus",
        "parameters": [
          {
            "name": "vaultAddress",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/EvmAddress"
            }
          },
          {
            "name": "sourceChainId",
            "in": "query",
            "required": true,
            "description": "Source chain ID where the vault is funded.",
            "schema": {
              "type": "number",
              "example": 8453
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Quoted vault record retrieved successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "data"
                  ],
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CircleGatewayDepositAddressStatusResponseDTO"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid vaultAddress or sourceChainId"
          },
          "404": {
            "description": "Vault not found"
          }
        }
      }
    },
    "/circle-gateway/v1/gasless/transferWithAuthorization": {
      "post": {
        "tags": [
          "Gasless funding"
        ],
        "summary": "Queue ERC-3009 gasless transfer",
        "description": "Submit a signed `TransferWithAuthorization` for the operator wallet to broadcast. Single onchain tx, USDC-native. For a quoted vault, `value` must cover the quoted `amount` and the quote must not be expired.",
        "operationId": "queueGaslessTransferWithAuthorization",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferWithAuthorizationDTO"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GaslessJobResponse"
                }
              }
            }
          }
        }
      }
    },
    "/circle-gateway/v1/gasless/permit": {
      "post": {
        "tags": [
          "Gasless funding"
        ],
        "summary": "Queue EIP-2612 Permit transfer",
        "description": "Fallback for tokens that support `permit()` but not ERC-3009. The user signs a Permit with the vault as spender; the operator wallet submits the transactions that pull the tokens into the vault.",
        "operationId": "queueGaslessPermit",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PermitDTO"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job queued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GaslessJobResponse"
                }
              }
            }
          }
        }
      }
    },
    "/circle-gateway/v1/gasless/jobs/{id}": {
      "get": {
        "tags": [
          "Gasless funding"
        ],
        "summary": "Poll gasless job status",
        "operationId": "getGaslessJob",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Job status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/GaslessJob"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Job not found"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "EvmAddress": {
        "type": "string",
        "pattern": "^0x[a-fA-F0-9]{40}$",
        "description": "EIP-55 / lowercase hex 20-byte address",
        "example": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
      },
      "Hex32": {
        "type": "string",
        "pattern": "^0x[a-fA-F0-9]{64}$",
        "description": "0x-prefixed 32-byte hex (64 hex chars)"
      },
      "Hex65": {
        "type": "string",
        "pattern": "^0x[a-fA-F0-9]{130}$",
        "description": "0x-prefixed 65-byte hex (130 hex chars)"
      },
      "GaslessJobStatus": {
        "type": "string",
        "enum": [
          "PENDING",
          "PERMIT_SENT",
          "COMPLETED",
          "FAILED"
        ]
      },
      "QuotedGatewayIntentState": {
        "type": "string",
        "description": "Current quoted gateway intent state. `PENDING`: vault created, waiting for funds. `FUNDING_DETECTED`: vault balance reached the quoted amount. `PUBLISHED`: deposit intent published onchain. `EXPIRED_UNFUNDED`: quote deadline passed without funding. `FAILED`, `REFUNDED_BY_USER`, `RECOVERY_PUBLISHED`: terminal recovery outcomes.",
        "enum": [
          "PENDING",
          "FUNDING_DETECTED",
          "PUBLISHED",
          "FAILED",
          "REFUNDED_BY_USER",
          "RECOVERY_PUBLISHED",
          "EXPIRED_UNFUNDED"
        ]
      },
      "CircleGatewayDepositAddressDTO": {
        "type": "object",
        "required": [
          "sourceChainId",
          "amount",
          "recipient",
          "depositor"
        ],
        "properties": {
          "sourceChainId": {
            "type": "number",
            "description": "Source chain ID for the USDC transfer. Mainnet: 8453 (Base), 10 (Optimism), 42161 (Arbitrum).",
            "example": 8453
          },
          "amount": {
            "type": "string",
            "description": "Required positive integer source-chain USDC amount in base units.",
            "example": "1000000"
          },
          "recipient": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Gateway depositFor target on the destination chain."
          },
          "depositor": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Address that will fund the vault."
          },
          "refundRecipient": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Address that receives expiry refunds. Defaults to depositor."
          }
        }
      },
      "CircleGatewayDepositAddressResponseDTO": {
        "type": "object",
        "required": [
          "vaultAddress",
          "amount",
          "deadline"
        ],
        "properties": {
          "vaultAddress": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Vault address on the source chain."
          },
          "amount": {
            "type": "string",
            "description": "Requested source-chain USDC amount in base units.",
            "example": "1000000"
          },
          "deadline": {
            "type": "number",
            "description": "Unix seconds quote deadline.",
            "example": 1798915200
          }
        }
      },
      "CircleGatewayDepositAddressStatusResponseDTO": {
        "type": "object",
        "required": [
          "vaultAddress",
          "amount",
          "deadline",
          "state",
          "intentHash",
          "sourceChainId"
        ],
        "properties": {
          "vaultAddress": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Vault address on the source chain."
          },
          "amount": {
            "type": "string",
            "description": "Requested source-chain USDC amount in base units.",
            "example": "1000000"
          },
          "deadline": {
            "type": "number",
            "description": "Unix seconds quote deadline.",
            "example": 1798915200
          },
          "state": {
            "$ref": "#/components/schemas/QuotedGatewayIntentState"
          },
          "intentHash": {
            "$ref": "#/components/schemas/Hex32",
            "description": "Intent hash for this quoted vault, assigned at quote creation and preserved through publish."
          },
          "sourceChainId": {
            "type": "number",
            "description": "Source chain ID where the vault is funded.",
            "example": 8453
          }
        }
      },
      "TransferWithAuthorizationDTO": {
        "type": "object",
        "required": [
          "chainId",
          "from",
          "to",
          "value",
          "validAfter",
          "validBefore",
          "nonce",
          "signature"
        ],
        "properties": {
          "chainId": {
            "type": "integer",
            "minimum": 1
          },
          "from": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Token owner (signer)"
          },
          "to": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Quoted vault address that will receive the tokens"
          },
          "value": {
            "type": "string",
            "description": "Raw token units. For a quoted vault, must be at least the quoted amount."
          },
          "validAfter": {
            "type": "string",
            "description": "Unix seconds"
          },
          "validBefore": {
            "type": "string",
            "description": "Unix seconds"
          },
          "nonce": {
            "$ref": "#/components/schemas/Hex32"
          },
          "signature": {
            "$ref": "#/components/schemas/Hex65",
            "description": "ERC-3009 signature"
          }
        }
      },
      "PermitDTO": {
        "type": "object",
        "required": [
          "chainId",
          "owner",
          "depositAddress",
          "value",
          "deadline",
          "signature"
        ],
        "properties": {
          "chainId": {
            "type": "integer",
            "minimum": 1
          },
          "owner": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Token owner (signer)"
          },
          "depositAddress": {
            "$ref": "#/components/schemas/EvmAddress",
            "description": "Quoted vault address (permit spender)"
          },
          "value": {
            "type": "string",
            "description": "Raw token units"
          },
          "deadline": {
            "type": "string",
            "description": "Unix seconds"
          },
          "signature": {
            "$ref": "#/components/schemas/Hex65",
            "description": "EIP-2612 signature"
          }
        }
      },
      "GaslessJob": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "status": {
            "$ref": "#/components/schemas/GaslessJobStatus"
          },
          "permitTxHash": {
            "type": "string",
            "nullable": true
          },
          "transferTxHash": {
            "type": "string",
            "nullable": true
          },
          "intentHash": {
            "type": "string",
            "nullable": true
          },
          "amount": {
            "type": "string",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "GaslessJobResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/GaslessJob"
          }
        }
      }
    }
  }
}