/**
 * This file was auto-generated by openapi-typescript.
 * Do not make direct changes to the file.
 */

export interface paths {
  "/v1/bids": {
    /**
     * Returns at most 20 bids which were submitted after a specific time.
     * @description If no time is provided, the server will return the first bids.
     */
    get: operations["get_bids_by_time"];
    /**
     * Bid on a specific permission key for a specific chain.
     * @description Your bid will be verified by the server. Depending on the outcome of the auction, a transaction
     * containing your bid will be sent to the blockchain expecting the bid amount to be paid in the transaction.
     */
    post: operations["bid"];
  };
  "/v1/bids/{bid_id}": {
    /** Query the status of a specific bid. */
    get: operations["bid_status"];
  };
  "/v1/opportunities": {
    /**
     * Fetch opportunities ready for execution or historical opportunities
     * @description depending on the mode. You need to provide `chain_id` for historical mode.
     * Opportunities are sorted by creation time in ascending order in historical mode.
     */
    get: operations["get_opportunities"];
    /**
     * Submit an opportunity ready to be executed.
     * @description The opportunity will be verified by the server. If the opportunity is valid, it will be stored in the database
     * and will be available for bidding.
     */
    post: operations["post_opportunity"];
  };
  "/v1/opportunities/{opportunity_id}/bids": {
    /** Bid on opportunity */
    post: operations["opportunity_bid"];
  };
  "/v1/profiles/access_tokens": {
    /**
     * Revoke the authenticated profile access token.
     * @description Returns empty response.
     */
    delete: operations["delete_profile_access_token"];
  };
}

export type webhooks = Record<string, never>;

export interface components {
  schemas: {
    APIResponse: components["schemas"]["BidResult"];
    Bid: components["schemas"]["BidEvm"] | components["schemas"]["BidSvm"];
    BidEvm: {
      /**
       * @description Amount of bid in wei.
       * @example 10
       */
      amount: string;
      /**
       * @description The chain id to bid on.
       * @example op_sepolia
       */
      chain_id: string;
      /**
       * @description The permission key to bid on.
       * @example 0xdeadbeef
       */
      permission_key: string;
      /**
       * @description Calldata for the contract call.
       * @example 0xdeadbeef
       */
      target_calldata: string;
      /**
       * @description The contract address to call.
       * @example 0xcA11bde05977b3631167028862bE2a173976CA11
       */
      target_contract: string;
    };
    BidResult: {
      /**
       * @description The unique id created to identify the bid. This id can be used to query the status of the bid.
       * @example beedbeed-58cc-4372-a567-0e02b2c3d479
       */
      id: string;
      status: string;
    };
    BidStatus:
      | components["schemas"]["BidStatusEvm"]
      | components["schemas"]["BidStatusSvm"];
    BidStatusEvm:
      | {
          /** @enum {string} */
          type: "pending";
        }
      | {
          /**
           * Format: int32
           * @example 1
           */
          index: number;
          /** @example 0x103d4fbd777a36311b5161f2062490f761f25b67406badb2bace62bb170aa4e3 */
          result: string;
          /** @enum {string} */
          type: "submitted";
        }
      | {
          /**
           * Format: int32
           * @example 1
           */
          index?: number | null;
          /** @example 0x103d4fbd777a36311b5161f2062490f761f25b67406badb2bace62bb170aa4e3 */
          result?: string | null;
          /** @enum {string} */
          type: "lost";
        }
      | {
          /**
           * Format: int32
           * @example 1
           */
          index: number;
          /** @example 0x103d4fbd777a36311b5161f2062490f761f25b67406badb2bace62bb170aa4e3 */
          result: string;
          /** @enum {string} */
          type: "won";
        };
    BidStatusSvm:
      | {
          /** @enum {string} */
          type: "pending";
        }
      | {
          /** @example Jb2urXPyEh4xiBgzYvwEFe4q1iMxG1DNxWGGQg94AmKgqFTwLAiTiHrYiYxwHUB4DV8u5ahNEVtMMDm3sNSRdTg */
          result: string;
          /** @enum {string} */
          type: "submitted";
        }
      | {
          /** @example Jb2urXPyEh4xiBgzYvwEFe4q1iMxG1DNxWGGQg94AmKgqFTwLAiTiHrYiYxwHUB4DV8u5ahNEVtMMDm3sNSRdTg */
          result?: string | null;
          /** @enum {string} */
          type: "lost";
        }
      | {
          /** @example Jb2urXPyEh4xiBgzYvwEFe4q1iMxG1DNxWGGQg94AmKgqFTwLAiTiHrYiYxwHUB4DV8u5ahNEVtMMDm3sNSRdTg */
          result: string;
          /** @enum {string} */
          type: "won";
        };
    BidStatusWithId: {
      bid_status: components["schemas"]["BidStatus"];
      id: string;
    };
    BidSvm: {
      /**
       * @description The chain id to bid on.
       * @example solana
       */
      chain_id: string;
      /**
       * @description The transaction for bid.
       * @example SGVsbG8sIFdvcmxkIQ==
       */
      transaction: string;
    };
    ClientMessage:
      | {
          /** @enum {string} */
          method: "subscribe";
          params: {
            chain_ids: string[];
          };
        }
      | {
          /** @enum {string} */
          method: "unsubscribe";
          params: {
            chain_ids: string[];
          };
        }
      | {
          /** @enum {string} */
          method: "post_bid";
          params: {
            bid: components["schemas"]["Bid"];
          };
        }
      | {
          /** @enum {string} */
          method: "post_opportunity_bid";
          params: {
            opportunity_bid: components["schemas"]["OpportunityBid"];
            opportunity_id: string;
          };
        };
    ClientRequest: components["schemas"]["ClientMessage"] & {
      id: string;
    };
    ErrorBodyResponse: {
      error: string;
    };
    OpportunityBid: {
      /**
       * @description The bid amount in wei.
       * @example 1000000000000000000
       */
      amount: string;
      /**
       * @description The latest unix timestamp in seconds until which the bid is valid
       * @example 1000000000000000000
       */
      deadline: string;
      /**
       * @description Executor address
       * @example 0x5FbDB2315678afecb367f032d93F642f64180aa2
       */
      executor: string;
      /**
       * @description The nonce of the bid permit signature
       * @example 123
       */
      nonce: string;
      /**
       * @description The opportunity permission key
       * @example 0xdeadbeefcafe
       */
      permission_key: string;
      /** @example 0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12 */
      signature: string;
    };
    /** @enum {string} */
    OpportunityMode: "live" | "historical";
    OpportunityParams: components["schemas"]["OpportunityParamsV1"] & {
      /** @enum {string} */
      version: "v1";
    };
    /**
     * @description Opportunity parameters needed for on-chain execution
     * If a searcher signs the opportunity and have approved enough tokens to opportunity adapter,
     * by calling this target contract with the given target calldata and structures, they will
     * send the tokens specified in the sell_tokens field and receive the tokens specified in the buy_tokens field.
     */
    OpportunityParamsV1: {
      buy_tokens: components["schemas"]["TokenAmount"][];
      /**
       * @description The chain id where the opportunity will be executed.
       * @example op_sepolia
       */
      chain_id: string;
      /**
       * @description The permission key required for successful execution of the opportunity.
       * @example 0xdeadbeefcafe
       */
      permission_key: string;
      sell_tokens: components["schemas"]["TokenAmount"][];
      /**
       * @description The value to send with the contract call.
       * @example 1
       */
      target_call_value: string;
      /**
       * @description Calldata for the target contract call.
       * @example 0xdeadbeef
       */
      target_calldata: string;
      /**
       * @description The contract address to call for execution of the opportunity.
       * @example 0xcA11bde05977b3631167028862bE2a173976CA11
       */
      target_contract: string;
    };
    /** @description Similar to OpportunityParams, but with the opportunity id included. */
    OpportunityParamsWithMetadata: (components["schemas"]["OpportunityParamsV1"] & {
      /** @enum {string} */
      version: "v1";
    }) & {
      /**
       * @description Creation time of the opportunity (in microseconds since the Unix epoch)
       * @example 1700000000000000
       */
      creation_time: number;
      /**
       * @description The opportunity unique id
       * @example obo3ee3e-58cc-4372-a567-0e02b2c3d479
       */
      opportunity_id: string;
    };
    ServerResultMessage:
      | {
          result: components["schemas"]["APIResponse"] | null;
          /** @enum {string} */
          status: "success";
        }
      | {
          result: string;
          /** @enum {string} */
          status: "error";
        };
    /**
     * @description This enum is used to send the result for a specific client request with the same id
     * id is only None when the client message is invalid
     */
    ServerResultResponse: components["schemas"]["ServerResultMessage"] & {
      id?: string | null;
    };
    /** @description This enum is used to send an update to the client for any subscriptions made */
    ServerUpdateResponse:
      | {
          opportunity: components["schemas"]["OpportunityParamsWithMetadata"];
          /** @enum {string} */
          type: "new_opportunity";
        }
      | {
          status: components["schemas"]["BidStatusWithId"];
          /** @enum {string} */
          type: "bid_status_update";
        };
    SimulatedBid:
      | components["schemas"]["SimulatedBidEvm"]
      | components["schemas"]["SimulatedBidSvm"];
    /** BidResponseEvm */
    SimulatedBidEvm: {
      /**
       * @description Amount of bid in wei.
       * @example 10
       */
      bid_amount: string;
      /**
       * @description The chain id for bid.
       * @example op_sepolia
       */
      chain_id: string;
      /**
       * @description The unique id for bid.
       * @example obo3ee3e-58cc-4372-a567-0e02b2c3d479
       */
      id: string;
      /**
       * @description The time server received the bid formatted in rfc3339.
       * @example 2024-05-23T21:26:57.329954Z
       */
      initiation_time: string;
      /**
       * @description The permission key for bid.
       * @example 0xdeadbeef
       */
      permission_key: string;
      /**
       * @description The profile id for the bid owner.
       * @example
       */
      profile_id: string;
      status: components["schemas"]["BidStatus"];
    } & {
      /**
       * @description The gas limit for the contract call.
       * @example 2000000
       */
      gas_limit: string;
      /**
       * @description Calldata for the contract call.
       * @example 0xdeadbeef
       */
      target_calldata: string;
      /**
       * @description The contract address to call.
       * @example 0xcA11bde05977b3631167028862bE2a173976CA11
       */
      target_contract: string;
    };
    /** BidResponseSvm */
    SimulatedBidSvm: {
      /**
       * @description Amount of bid in wei.
       * @example 10
       */
      bid_amount: string;
      /**
       * @description The chain id for bid.
       * @example op_sepolia
       */
      chain_id: string;
      /**
       * @description The unique id for bid.
       * @example obo3ee3e-58cc-4372-a567-0e02b2c3d479
       */
      id: string;
      /**
       * @description The time server received the bid formatted in rfc3339.
       * @example 2024-05-23T21:26:57.329954Z
       */
      initiation_time: string;
      /**
       * @description The permission key for bid.
       * @example 0xdeadbeef
       */
      permission_key: string;
      /**
       * @description The profile id for the bid owner.
       * @example
       */
      profile_id: string;
      status: components["schemas"]["BidStatus"];
    } & {
      /**
       * @description The transaction of the bid.
       * @example SGVsbG8sIFdvcmxkIQ==
       */
      transaction: string;
    };
    /** BidsResponse */
    SimulatedBids: {
      items: components["schemas"]["SimulatedBid"][];
    };
    TokenAmount: {
      /**
       * @description Token amount
       * @example 1000
       */
      amount: string;
      /**
       * @description Token contract address
       * @example 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2
       */
      token: string;
    };
  };
  responses: {
    BidResult: {
      content: {
        "application/json": {
          /**
           * @description The unique id created to identify the bid. This id can be used to query the status of the bid.
           * @example beedbeed-58cc-4372-a567-0e02b2c3d479
           */
          id: string;
          status: string;
        };
      };
    };
    /** @description An error occurred processing the request */
    ErrorBodyResponse: {
      content: {
        "application/json": {
          error: string;
        };
      };
    };
    /** @description Similar to OpportunityParams, but with the opportunity id included. */
    OpportunityParamsWithMetadata: {
      content: {
        "application/json": (components["schemas"]["OpportunityParamsV1"] & {
          /** @enum {string} */
          version: "v1";
        }) & {
          /**
           * @description Creation time of the opportunity (in microseconds since the Unix epoch)
           * @example 1700000000000000
           */
          creation_time: number;
          /**
           * @description The opportunity unique id
           * @example obo3ee3e-58cc-4372-a567-0e02b2c3d479
           */
          opportunity_id: string;
        };
      };
    };
    SimulatedBids: {
      content: {
        "application/json": {
          items: components["schemas"]["SimulatedBid"][];
        };
      };
    };
  };
  parameters: never;
  requestBodies: never;
  headers: never;
  pathItems: never;
}

export type $defs = Record<string, never>;

export type external = Record<string, never>;

export interface operations {
  /**
   * Returns at most 20 bids which were submitted after a specific time.
   * @description If no time is provided, the server will return the first bids.
   */
  get_bids_by_time: {
    parameters: {
      query?: {
        /** @example 2024-05-23T21:26:57.329954Z */
        from_time?: string | null;
      };
    };
    responses: {
      /** @description Paginated list of bids for the specified query */
      200: {
        content: {
          "application/json": components["schemas"]["SimulatedBids"];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
    };
  };
  /**
   * Bid on a specific permission key for a specific chain.
   * @description Your bid will be verified by the server. Depending on the outcome of the auction, a transaction
   * containing your bid will be sent to the blockchain expecting the bid amount to be paid in the transaction.
   */
  bid: {
    requestBody: {
      content: {
        "application/json": components["schemas"]["Bid"];
      };
    };
    responses: {
      /** @description Bid was placed successfully */
      200: {
        content: {
          "application/json": components["schemas"]["BidResult"];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
      /** @description Chain id was not found */
      404: {
        content: {
          "application/json": components["schemas"]["ErrorBodyResponse"];
        };
      };
    };
  };
  /** Query the status of a specific bid. */
  bid_status: {
    parameters: {
      path: {
        /** @description Bid id to query for */
        bid_id: string;
      };
    };
    responses: {
      /** @description Latest status of the bid */
      200: {
        content: {
          "application/json": components["schemas"]["BidStatus"];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
      /** @description Bid was not found */
      404: {
        content: {
          "application/json": components["schemas"]["ErrorBodyResponse"];
        };
      };
    };
  };
  /**
   * Fetch opportunities ready for execution or historical opportunities
   * @description depending on the mode. You need to provide `chain_id` for historical mode.
   * Opportunities are sorted by creation time in ascending order in historical mode.
   */
  get_opportunities: {
    parameters: {
      query?: {
        /** @example op_sepolia */
        chain_id?: string | null;
        /** @description Get opportunities in live or historical mode */
        mode?: components["schemas"]["OpportunityMode"];
        /**
         * @description The permission key to filter the opportunities by. Used only in historical mode.
         * @example 0xdeadbeef
         */
        permission_key?: string | null;
        /**
         * @description The time to get the opportunities from. Used only in historical mode.
         * @example 2024-05-23T21:26:57.329954Z
         */
        from_time?: string | null;
      };
    };
    responses: {
      /** @description Array of opportunities ready for bidding */
      200: {
        content: {
          "application/json": components["schemas"]["OpportunityParamsWithMetadata"][];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
      /** @description Chain id was not found */
      404: {
        content: {
          "application/json": components["schemas"]["ErrorBodyResponse"];
        };
      };
    };
  };
  /**
   * Submit an opportunity ready to be executed.
   * @description The opportunity will be verified by the server. If the opportunity is valid, it will be stored in the database
   * and will be available for bidding.
   */
  post_opportunity: {
    requestBody: {
      content: {
        "application/json": components["schemas"]["OpportunityParams"];
      };
    };
    responses: {
      /** @description The created opportunity */
      200: {
        content: {
          "application/json": components["schemas"]["OpportunityParamsWithMetadata"];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
      /** @description Chain id was not found */
      404: {
        content: {
          "application/json": components["schemas"]["ErrorBodyResponse"];
        };
      };
    };
  };
  /** Bid on opportunity */
  opportunity_bid: {
    parameters: {
      path: {
        /** @description Opportunity id to bid on */
        opportunity_id: string;
      };
    };
    requestBody: {
      content: {
        "application/json": components["schemas"]["OpportunityBid"];
      };
    };
    responses: {
      /** @description Bid Result */
      200: {
        content: {
          "application/json": components["schemas"]["BidResult"];
        };
      };
      400: components["responses"]["ErrorBodyResponse"];
      /** @description Opportunity or chain id was not found */
      404: {
        content: {
          "application/json": components["schemas"]["ErrorBodyResponse"];
        };
      };
    };
  };
  /**
   * Revoke the authenticated profile access token.
   * @description Returns empty response.
   */
  delete_profile_access_token: {
    responses: {
      /** @description The token successfully revoked */
      200: {
        content: never;
      };
      400: components["responses"]["ErrorBodyResponse"];
    };
  };
}
