{"id":26241607,"url":"https://github.com/a6b8/triangularpairs","last_synced_at":"2026-02-15T12:01:17.008Z","repository":{"id":211800717,"uuid":"729973676","full_name":"a6b8/triangularPairs","owner":"a6b8","description":"Triangular Pairs can be useful for executing composite transactions on a blockchain to efficiently carry out arbitrage opportunities. This module helps in identifying all possible pairs of pools, such as Uniswap V2 or V3, and subsequently conducts further analyses.","archived":false,"fork":false,"pushed_at":"2023-12-11T12:36:35.000Z","size":31,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-09T22:05:19.152Z","etag":null,"topics":["defi","triangular-arbitrage","uniswap"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/a6b8.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-12-10T22:50:33.000Z","updated_at":"2025-03-10T15:48:46.000Z","dependencies_parsed_at":"2023-12-11T00:22:59.503Z","dependency_job_id":"824cf6ce-ed92-4e71-9a9f-20b46fad9c98","html_url":"https://github.com/a6b8/triangularPairs","commit_stats":null,"previous_names":["a6b8/triangularpairs"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/a6b8/triangularPairs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a6b8%2FtriangularPairs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a6b8%2FtriangularPairs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a6b8%2FtriangularPairs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a6b8%2FtriangularPairs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a6b8","download_url":"https://codeload.github.com/a6b8/triangularPairs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a6b8%2FtriangularPairs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261012850,"owners_count":23096924,"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":["defi","triangular-arbitrage","uniswap"],"created_at":"2025-03-13T08:32:29.621Z","updated_at":"2026-02-03T17:06:46.244Z","avatar_url":"https://github.com/a6b8.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CircleCI](https://img.shields.io/circleci/build/github/a6b8/triangularPairs/main)]()\n\n\n# Triangular Pairs\n\nTriangular Pairs can be useful for executing composite transactions on a blockchain to efficiently carry out arbitrage opportunities. This module helps in identifying all possible pairs of pools, such as Uniswap V2 or V3, and subsequently conducts further analyses.\n\n```\n  -------------------------------------------------------------\n |                                                             |\n |      -----|-----        -----|-----        -----|-----      |\n  ---\u003e |  A     B  | ---\u003e |  B     Z  | ---\u003e |  Z     A  | ---\u003e \n        -----|-----        -----|-----        -----|-----\n           Pool n            Pool n             Pool n+2    \n         Contract A         Contract B         Contract A\n```\n\n\n\n## Quickstart\n\n```js\nimport { TriangularPairs } from './src/TriangularPairs.mjs'\nimport { selection } from './tests/data/pairs-selection.mjs'\n\nconst triangularPairs  = new TriangularPairs ()\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\nconst result = triangularPairs\n    .start( { pairsEncoded } )\n    .getTriangularPairs()\n```\n\n\n\n## Table of Contents\n\n- [Triangular Pairs](#triangular-pairs)\n  - [Quickstart](#quickstart)\n  - [Table of Contents](#table-of-contents)\n  - [Methods](#methods)\n    - [.start()](#start)\n    - [encodePairs()](#encodepairs)\n    - [.getTokens()](#gettokens)\n    - [.getPairs()](#getpairs)\n    - [.getTriangularPairs()](#gettriangularpairs)\n  - [License](#license)\n\n\n## Methods\n\nHere are all the public methods listed. `.start(...)` initiates the process. The results can be queried using the `get` methods. The main result can be found under `.getTriangularPairs()`.\n\n### .start()\n\nStarts the process and generates `this.#tokens`, `this.#pairs`, and `this.#triangularPairs`. The results are accessible through the methods listed below.\n\n`.start( { pairsEncoded } )`  \n\nreturns  \n`this`\n\n```js\nimport { TriangularPairs } from './src/TriangularPairs.mjs'\nconst triangularPairs  = new TriangularPairs ()\nconst selection = {\n    \"data\": [\n        {\n            \"contract_address\": \"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f\",\n            \"pair\": \"0x8c3b2e86aaceb1b7ad8cb96e63881c28f5cef29a\",\n            \"token1\": \"0x11a605d7e12b64d713e93c487277d819a1d14b99\",\n            \"token2\": \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n            \"total\": 5434,\n            \"tx_hash\": \"0x1e75b533f8aeda500c5d9837d40319d144c855ef7660679bd7a92368ff958fa7\"\n        }\n        ...\n    ]\n}\n\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\nconst tokens = triangularPairs\n    .start( { pairsEncoded } )\n    .getTokens()\nconsole.log( tokens )\n\n```\n\nYou can find a sample file here: [./tests/pairs-selection.mjs](https://github.com/a6b8/triangularPairs/blob/main/tests/pairs-selection.mjs)\n\n\n\n### encodePairs()\n\nAssists in encoding your data into the expected format for `.start()`. A pool pair needs to be encoded as a single string in the following order: `contractAddress_pairAddress_token1Address_token2Address`.\n\n`.encodePairs { items } )`  \n\nreturns  \n`this`\n\n\n```js\nconst selection = {\n    \"data\": [\n        {\n            \"contract_address\": \"0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f\",\n            \"pair\": \"0x8c3b2e86aaceb1b7ad8cb96e63881c28f5cef29a\",\n            \"token1\": \"0x11a605d7e12b64d713e93c487277d819a1d14b99\",\n            \"token2\": \"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2\",\n            \"total\": 5434,\n            \"tx_hash\": \"0x1e75b533f8aeda500c5d9837d40319d144c855ef7660679bd7a92368ff958fa7\"\n        }\n        ...\n    ]\n}\n\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\n\n```\n\n\n### .getTokens()\n\nFilters by tokens and provides references to individual pool pairs.\n\n`.getTokens()`\n\nreturns  \n`this.#tokens`\n\n```js\nimport { TriangularPairs } from './src/TriangularPairs.mjs'\nimport { selection } from './tests/data/pairs-selection.mjs'\n\nconst triangularPairs  = new TriangularPairs ()\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\nconst tokens = triangularPairs\n    .start( { pairsEncoded } )\n    .getTokens()\nconsole.log( tokens )\n```\n\n### .getPairs()\n\nFilters by pool pairs and lists the possible pools that provide this exchange opportunity under `contracts`. Additionally, the direction is indicated by specifying `tokenA` as the first and `tokenB` as the second position.\n\n`.getPairs()`\n\nreturns  \n`this.#pairs`\n\n```js\nimport { TriangularPairs } from './src/TriangularPairs.mjs'\nimport { selection } from './tests/data/pairs-selection.mjs'\n\nconst triangularPairs  = new TriangularPairs ()\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\nconst pairs = triangularPairs\n    .start( { pairsEncoded } )\n    .getPairs()\nconsole.log( pairs )\n```\n\n### .getTriangularPairs()\n\nGenerates all possible unique Triangular Pairs and provides references to further information in `this.#tokens` and `this.#pairs`.\n\n`.getTriangularPairs()`\n\nreturns  \n`this.#triangularPairs`\n\n```js\nimport { TriangularPairs } from './src/TriangularPairs.mjs'\nimport { selection } from './tests/data/pairs-selection.mjs'\n\nconst triangularPairs  = new TriangularPairs ()\nconst pairsEncoded = triangularPairs\n    .encodePairs( { 'items': selection['data'] } )\nconst triPairs = triangularPairs\n    .start( { pairsEncoded } )\n    .getTriangularPairs()\nconsole.log( triPairs )\n```\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa6b8%2Ftriangularpairs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa6b8%2Ftriangularpairs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa6b8%2Ftriangularpairs/lists"}