{"id":21347113,"url":"https://github.com/kybernetwork/tradelogs","last_synced_at":"2025-08-04T01:34:58.206Z","repository":{"id":168177404,"uuid":"577228767","full_name":"KyberNetwork/tradelogs","owner":"KyberNetwork","description":null,"archived":false,"fork":false,"pushed_at":"2024-10-30T05:02:39.000Z","size":698,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2024-10-30T07:13:55.016Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KyberNetwork.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-12T09:15:43.000Z","updated_at":"2024-10-30T04:15:56.000Z","dependencies_parsed_at":"2023-10-17T11:43:07.870Z","dependency_job_id":"b0bafb4a-8d44-4a2f-8e8c-080048b12c56","html_url":"https://github.com/KyberNetwork/tradelogs","commit_stats":null,"previous_names":["kybernetwork/tradelogs"],"tags_count":63,"template":false,"template_full_name":"KyberNetwork/go-project-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyberNetwork%2Ftradelogs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyberNetwork%2Ftradelogs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyberNetwork%2Ftradelogs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KyberNetwork%2Ftradelogs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KyberNetwork","download_url":"https://codeload.github.com/KyberNetwork/tradelogs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225829064,"owners_count":17530666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-22T02:12:42.850Z","updated_at":"2024-11-22T02:12:43.379Z","avatar_url":"https://github.com/KyberNetwork.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tradelogs\n\nThis is service to indexing tradelogs from event\n\n# Tradelogs V2\n\n## Backfill Server API Documentation\n\nThis server serve the endpoints to manage backfill task: list, create, cancel, restart tasks\n### 1. **Backfill Task Creation**\n\n- **URL**: `/backfill`\n- **Method**: `POST`\n- **Description**: Creates a new backfill task.\n- **Request Body**:\n    - `from_block` (uint64, required): The starting block number.\n    - `to_block` (uint64, required): The ending block number.\n    - `exchange` (string, required): The exchange name.\n- **Response**:\n    - **200 OK**: On success.\n      ```json\n      {\n        \"success\": true,\n        \"id\": \"\u003ctask_id\u003e\",\n        \"message\": \"\u003cmessage\u003e\"\n      }\n      ```\n    - **400 Bad Request**: If there is a validation error (e.g., missing fields, invalid exchange).\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n    - **500 Internal Server Error**: If there is an error during task creation.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n\n### 2. **Get All Backfill Tasks**\n\n- **URL**: `/backfill`\n- **Method**: `GET`\n- **Description**: Retrieves all backfill tasks.\n- **Response**:\n    - **200 OK**: On success. The task with id -1 is the service's default backfill flow.\n      ```json\n      {\n        \"success\": true,\n        \"tasks\": [\n          {\n            \"id\": -1,\n            \"exchange\": \"\",\n            \"from_block\": 20926953,\n            \"to_block\": 20962657,\n            \"processed_block\": 20962657,\n            \"created_at\": \"0001-01-01T00:00:00Z\",\n            \"updated_at\": \"0001-01-01T00:00:00Z\",\n            \"status\": \"processing\"\n          },\n          {\n            \"id\": 1,\n            \"exchange\": \"zerox\",\n            \"from_block\": 20962657,\n            \"to_block\": 20962658,\n            \"processed_block\": 20962657,\n            \"created_at\": \"2024-10-14T09:07:01.059135Z\",\n            \"updated_at\": \"2024-10-14T17:18:32.814065Z\",\n            \"status\": \"done\"\n          }\n        ]\n      }\n      ```\n    - **500 Internal Server Error**: If there is an error retrieving the tasks.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n\n### 3. **Get Backfill Task By ID**\n\n- **URL**: `/backfill/:id`\n- **Method**: `GET`\n- **Description**: Retrieves a specific backfill task by its ID.\n- **URL Parameters**:\n    - `id` (int, required): The task ID.\n- **Response**:\n    - **200 OK**: On success.\n      ```json\n      {\n        \"success\": true,\n        \"task\": {\n            \"id\": 1,\n            \"exchange\": \"zerox\",\n            \"from_block\": 20962657,\n            \"to_block\": 20962658,\n            \"processed_block\": 20962657,\n            \"created_at\": \"2024-10-14T09:07:01.059135Z\",\n            \"updated_at\": \"2024-10-14T17:18:32.814065Z\",\n            \"status\": \"done\"\n          }\n      }\n      ```\n    - **400 Bad Request**: If the task ID is invalid.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"invalid task id: \u003cid\u003e\"\n      }\n      ```\n    - **500 Internal Server Error**: If there is an error retrieving the task.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n\n### 4. **Cancel Backfill Task**\n\n- **URL**: `/backfill/cancel/:id`\n- **Method**: `GET`\n- **Description**: Cancels a specific backfill task by its ID.\n- **URL Parameters**:\n    - `id` (int, required): The task ID.\n- **Response**:\n    - **200 OK**: On success.\n      ```json\n      {\n        \"success\": true\n      }\n      ```\n    - **400 Bad Request**: If the task ID is invalid.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"invalid task id: \u003cerror_message\u003e\"\n      }\n      ```\n    - **500 Internal Server Error**: If there is an error canceling the task.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n\n### 5. **Restart Backfill Task**\n\n- **URL**: `/backfill/restart/:id`\n- **Method**: `GET`\n- **Description**: Restarts a specific backfill task by its ID.\n- **URL Parameters**:\n    - `id` (int, required): The task ID.\n- **Response**:\n    - **200 OK**: On success.\n      ```json\n      {\n        \"success\": true\n      }\n      ```\n    - **400 Bad Request**: If the task ID is invalid.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"invalid task id: \u003cerror_message\u003e\"\n      }\n      ```\n    - **500 Internal Server Error**: If there is an error restarting the task.\n      ```json\n      {\n        \"success\": false,\n        \"error\": \"\u003cerror_message\u003e\"\n      }\n      ```\n\n## Broadcast Server API Documentation\n\nThis server serve the endpoints to subscribe trade logs\n### **WebSocket Connection Creation**\n\n- **URL**: `/eventlogws`\n- **Method**: `GET`\n- **Description**: Connect WebSocket.\n- **Request Params**:\n    - `id` (string, optional): The ID of websocket connection, also the consumer group ID. \n    Empty if you need to create new connection and subscribe from the newest offset. \n    Else, pass the ID to continue from the most recently event.\n    - `maker` (string, optional): The maker you want to subscribe.\n    - `taker` (string, optional): The taker you want to subscribe.\n    - `maker_token` (string, optional): The maker token you want to subscribe.\n    - `taker_token` (string, optional): The taker token you want to subscribe.\n    - `event_hash` (string, optional): The event hash you want to subscribe.\n\n  The filter will combine non-empty fields (AND). If no field are pass, all the trade logs will be sent.\n- **Response**:\n    - **ID Message**: With new connection, the first message will be the ID of session.\n      ```json\n      {\n        \"id\": \"\u003csession_id\u003e\"\n      }\n      ```\n    - **Trade log Message**: with type `trade_log` and the data containing trade log information\n      ```json\n      {\n        \"type\": \"trade_log\",\n        \"data\": {\n          \"order_hash\": \"0xcccf91f6cc3f636f0c7864ae8bcbc7cddbb54971997f90d81891a139c36c33e9\",\n          \"maker\": \"0x51C72848c68a965f66FA7a88855F9f7784502a7F\",\n          \"taker\": \"0x22F9dCF4647084d6C31b2765F6910cd85C178C18\",\n          \"maker_token\": \"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\",\n          \"taker_token\": \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\n          \"maker_token_amount\": \"20210895540598740\",\n          \"taker_token_amount\": \"50995428\",\n          \"contract_address\": \"0xDef1C0ded9bec7F1a1670819833240f027b25EfF\",\n          \"block_number\": 21034739,\n          \"tx_hash\": \"0x6926077a7cfdc78cd1649c43e85da918f10b4ee0c6e930d5107a50de0c9d0837\",\n          \"log_index\": 489,\n          \"timestamp\": 1729764251000,\n          \"event_hash\": \"0xac75f773e3a92f1a02b12134d65e1f47f8a14eabe4eaf1e24624918e6a8b269f\",\n          \"expiration_date\": 1729764301,\n          \"maker_token_price\": 0,\n          \"taker_token_price\": 0,\n          \"maker_usd_amount\": 0,\n          \"taker_usd_amount\": 0,\n          \"state\": \"\"\n        }\n      }\n      ```\n    - **Revert Message**: with type `revert` and data containing the block numbers of reverted blocks\n      ```json\n      {\n        \"type\": \"revert\",\n        \"data\": [11, 12, 13]\n      }\n      ```\n\n## Re-generate mock file\n\nFirst, you need to install `mockery`\n\n- https://vektra.github.io/mockery/latest/installation/\n- https://github.com/vektra/mockery\n\nThen you use the `mockery` to generate mock files from interface\n\n```\nmockery --dir=\u003cinterface directory\u003e --name=\u003cinterface name\u003e --output=\u003coutput dir\u003e --structname=\u003cname of output struct\u003e --filename=\u003coutput filename\u003e\n```\n\nExample: generate `Storage` interface to a struct name `MockStorage`\n\n```\nmockery --dir=v2/pkg/storage/state --name=Storage --output=v2/mocks/ --structname=MockState --filename=State.go\n```\n\nFor more information `mockery --help`","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkybernetwork%2Ftradelogs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkybernetwork%2Ftradelogs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkybernetwork%2Ftradelogs/lists"}