{"id":15824754,"url":"https://github.com/sambacha/twist","last_synced_at":"2026-04-27T23:32:28.377Z","repository":{"id":53718465,"uuid":"349015259","full_name":"sambacha/twist","owner":"sambacha","description":"twist: transactional aggregation library for EIP-2718","archived":false,"fork":false,"pushed_at":"2021-10-20T12:05:45.000Z","size":3127,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-11T01:57:36.265Z","etag":null,"topics":["dex","eip-2718","ethereum","library","trading","transactions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/sambacha.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}},"created_at":"2021-03-18T09:35:32.000Z","updated_at":"2021-10-23T03:39:53.000Z","dependencies_parsed_at":"2022-09-10T13:40:34.013Z","dependency_job_id":null,"html_url":"https://github.com/sambacha/twist","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sambacha/twist","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Ftwist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Ftwist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Ftwist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Ftwist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sambacha","download_url":"https://codeload.github.com/sambacha/twist/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sambacha%2Ftwist/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32360110,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["dex","eip-2718","ethereum","library","trading","transactions"],"created_at":"2024-10-05T09:01:03.788Z","updated_at":"2026-04-27T23:32:28.362Z","avatar_url":"https://github.com/sambacha.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [twist](#)\n\n\u003e `twist-lib`\n\n### Overview \n\n\u003e twist: a transactional aggregator library \n\n### usage \n\n\u003e Instance is created by passing in the network id to the constructor.\n\n```javascript\nimport { Twist } from \"./index\";\nconst twist = new Twist(1);\n```\nEach twist has it's own class in this directory, and each twistor\nfetches its own token metadata and returns it to the main class.\nOnce all token metadata has been loaded the  `twist.tokens` Ready\npromise resolves and the library is ready to be interacted with.\n\nThere are two ways the lib can be used, to fetch quotes, and to fetch\ntrades. \n- Quotes are just prices. They don't require a web3 instance, or a\nwallet address, and they can be used for price discovery for arbitrarily\nlarge amounts.\n- Trades are executable. They require a web3 provider and slippage\nparameters to be set. \n\n### Fetching Quotes\n\n\u003e syntax for fetching quotes:\n\n```javascript\ntwist.fetchQuotes({\n    sourceAmount,\n    sourceToken,\n    destinationToken\n});\n```\n\n### Fetching Trades \n\n\u003e syntax for fetching trades\n\n```javascript\ntwist.fetchTrades({\n        sourceAmount,\n        sourceToken,\n        destinationToken,\n        userAddress,\n        slippage\n    },\n    web3\n);\n```\n\nWhen a trade is fetched, the appropriate approvals are also checked for\nthe `userAddress` address provided.\nIf approvals are missing, they are added as an `approvalNeeded` param to\neach individual trade returned.\n\n#### approval transaction \n\n\u003e execute an approval transaction \n\n```javascript\nconst approvalTx = await trade.approvalNeeded({ gasPrice });\nconst approvalReceipt = await approvalTx.wait();\n                  \n```\n\n#### trade transaction\n\n\u003e execute a trade transaction \n\n```javascript\nconst txObject = {\n    from: walletAddress,\n    to: trade.to,\n    value: trade.value,\n    data: trade.data,\n    gas,\n    gasPrice\n};\nweb3.eth.sendTransaction(txObject);\n```\n\n`0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE` is used for ETH\n\n- Each twist has a different method of approving the end user's ERC20\nbalance. Many utilize an ERC20 proxy that handles the authorizations.\nThat's why it's important to use the libraries built-in approval checks\ninstead of manually checking the `trade.to` address for the spender\napproval.\n\n## License\n\nGPL-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Ftwist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsambacha%2Ftwist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsambacha%2Ftwist/lists"}