{"_id":"@1delta/aggregators","_rev":"9-18bdadcf3a6f39808105782936d030ce","name":"@1delta/aggregators","dist-tags":{"latest":"0.1.8"},"versions":{"0.1.0":{"name":"@1delta/aggregators","version":"0.1.0","_id":"@1delta/aggregators@0.1.0","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"a42c9e2b49a3c0c4228ce087f108895b31964271","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.0.tgz","fileCount":110,"integrity":"sha512-VJlhSNhRiXQR1wma9vuRYOeW+FJpI+VreOep3zQMaISnJzCjbAN03PhqQTqnS0MVN/RYdZBXbem12DmeVw/w7A==","signatures":[{"sig":"MEYCIQDy2hv2prRQugoiHdC7fxehBNZFUrpWN3MuDjxZtuwLCAIhAKvPP8q8HD+VUR8tARAGAQvoYCunBz74BmZLq8qxmdwj","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":229046},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.0.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/cbc83ff28f78a3c6ae37dcdf96971a31/1delta-aggregators-0.1.0.tgz","_integrity":"sha512-VJlhSNhRiXQR1wma9vuRYOeW+FJpI+VreOep3zQMaISnJzCjbAN03PhqQTqnS0MVN/RYdZBXbem12DmeVw/w7A==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.33.0","axios":"^1.10.0","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.0","@1delta/calldatalib":"^0.0.42","@1delta/calldata-sdk":"^0.0.94"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.0_1762358645082_0.6992500232087857","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@1delta/aggregators","version":"0.1.1","_id":"@1delta/aggregators@0.1.1","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"fcb177b41279ac5c146ccf2e3fdee4aca88fc605","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.1.tgz","fileCount":110,"integrity":"sha512-0+gjQmKsA2JaSboiCjDBil5VeqojxIikVyQm0DcNVu9upgzOknpTNCAKuknGpeEI8hCF5jJauRxOu8AcW3TjzQ==","signatures":[{"sig":"MEUCIEJczaTPCX5yoX6b7cghL+nQb0AL7yX3ya6vWD3CnN0kAiEAoNiuWL5aXaSZ8Sa1HzzZBPCQFG0VHOqlpt1oczN4uoU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":229366},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.1.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/fdf7249ae42e89328451e3f5bac6be55/1delta-aggregators-0.1.1.tgz","_integrity":"sha512-0+gjQmKsA2JaSboiCjDBil5VeqojxIikVyQm0DcNVu9upgzOknpTNCAKuknGpeEI8hCF5jJauRxOu8AcW3TjzQ==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.33.0","axios":"^1.10.0","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.1","@1delta/calldatalib":"^0.0.42","@1delta/calldata-sdk":"^0.0.94"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.1_1762512710068_0.9050271054425363","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@1delta/aggregators","version":"0.1.2","_id":"@1delta/aggregators@0.1.2","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"47e0da4b7a652acbe32a4a70e85e6ee926888c96","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.2.tgz","fileCount":113,"integrity":"sha512-8FPZblhBA8swNDCoykoXVy70jkzUD6WjLhvIT+UjKy2JzG3E9OXzjXsfQT7tgNEjO4Op3fnMGpKFpUBm4OkBhQ==","signatures":[{"sig":"MEUCIEx4wZ8yuQWS/S0IjB5yEjWKvV8fNJitfWLxFbYhVZYdAiEAlZbcMferdbY9Tbj6cbLeWNBnP3UeQ6c1bWd5EZgvWq4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":232227},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.2.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/1d23476a29f84e2a0a4546cad1ae9d6e/1delta-aggregators-0.1.2.tgz","_integrity":"sha512-8FPZblhBA8swNDCoykoXVy70jkzUD6WjLhvIT+UjKy2JzG3E9OXzjXsfQT7tgNEjO4Op3fnMGpKFpUBm4OkBhQ==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.33.0","axios":"^1.10.0","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.3","@1delta/calldatalib":"^0.0.42","@1delta/calldata-sdk":"^0.0.94"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.0.0"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.2_1762699549274_0.19010489060168756","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@1delta/aggregators","version":"0.1.3","_id":"@1delta/aggregators@0.1.3","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"3374ac9948d88af1da036de2016baab48a8be9d3","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.3.tgz","fileCount":113,"integrity":"sha512-qnjtQ7ULNXle6K+e+7t9JziIe4GVjnupw3vHoH/XhoQ8CvgcSB+47SUBFW+xqqTmlm/7T/D2CLQ+Agd6FlziSg==","signatures":[{"sig":"MEUCIGWQ0TF4LFmUs2yB/w4QivX2uIgTYJmsCoDOKOcNqoUAAiEAwNFjRh4EjAi4PFnDTHiFbkZ7UY6txNEljLVy0aTjvYA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":232228},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.3.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/ffb40735cfde953aadf158da4ea01ded/1delta-aggregators-0.1.3.tgz","_integrity":"sha512-qnjtQ7ULNXle6K+e+7t9JziIe4GVjnupw3vHoH/XhoQ8CvgcSB+47SUBFW+xqqTmlm/7T/D2CLQ+Agd6FlziSg==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.38.6","axios":"^1.13.2","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.3","@1delta/calldatalib":"^0.0.45","@1delta/calldata-sdk":"^0.0.119"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.3_1762855620728_0.05617458088067129","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@1delta/aggregators","version":"0.1.4","_id":"@1delta/aggregators@0.1.4","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"d22405ba0bf59bbcc95152c7ac6a2008077d89df","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.4.tgz","fileCount":113,"integrity":"sha512-u/lwDcuzaw3Z6QhlSXcVt0jcPTH25J/LMimFoy4o/76HtHlg1PpgpskO2ceO1AtSRAuyiJ9gyAQgQW6u4G7Chg==","signatures":[{"sig":"MEYCIQCxGOA/8muwp1UX5+uU3yrA+jlxqmnUWgMvPq+Qjl7U2AIhAJZRWZ5xOnhfo2ok0xnrD9zLcQycq8KLQEAzRxdWmYUz","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":230826},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.4.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/f757779b5e95462af9c853439de2d8e8/1delta-aggregators-0.1.4.tgz","_integrity":"sha512-u/lwDcuzaw3Z6QhlSXcVt0jcPTH25J/LMimFoy4o/76HtHlg1PpgpskO2ceO1AtSRAuyiJ9gyAQgQW6u4G7Chg==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.39.3","axios":"^1.13.2","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.4","@1delta/calldatalib":"^0.0.46","@1delta/calldata-sdk":"^0.0.123"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.4_1763548676037_0.6341895944535259","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@1delta/aggregators","version":"0.1.5","_id":"@1delta/aggregators@0.1.5","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"034ae37450f062caef61241a89ac6d129b4becec","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.5.tgz","fileCount":119,"integrity":"sha512-N0CEPXDgOCMxR8ojZsPJtuNpl9ADixWHKXQMFO/gYKg319IsXJMnLSm3A0GR+w4VcczNYwJDNXRvBX9Ygj42fg==","signatures":[{"sig":"MEQCIHxaZkjgDY3gDRfTCreFGwfOv3V9kFIlnYBtNLC3lccGAiBG0TAfKK91vFJA0E2lmYBQuXnstHjzuW1lO5No0epaVA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":233025},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.5.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/ec0861b42a1ffa63e850dd1a9cc102a9/1delta-aggregators-0.1.5.tgz","_integrity":"sha512-N0CEPXDgOCMxR8ojZsPJtuNpl9ADixWHKXQMFO/gYKg319IsXJMnLSm3A0GR+w4VcczNYwJDNXRvBX9Ygj42fg==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.39.3","axios":"^1.13.2","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.5","@1delta/calldatalib":"^0.0.46","@1delta/calldata-sdk":"^0.0.123"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.5_1763655967697_0.7110054800847092","host":"s3://npm-registry-packages-npm-production"}},"0.1.6":{"name":"@1delta/aggregators","version":"0.1.6","_id":"@1delta/aggregators@0.1.6","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"f59842227d2ef01267ee52efaf37bb1b5c8a17b1","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.6.tgz","fileCount":119,"integrity":"sha512-aKR5fzMe1NW/xSt62lYKozaZt7f60+PdYXld50HNaPYZ26YzAOaJtZ8S3c0ay2KaUbR1R36mhHOF0wvpObagMQ==","signatures":[{"sig":"MEQCIDY2wwLMXrAM8o9uOkUaMExDkf4ZTYR9qv/+SiqH1M9BAiAYE/KeFHdYS9LLhu3YjiZouqqP+xvSHyDiyppfHVbOLg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":233025},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.6.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/9d8b68cb3b6034e1ac9d6a3f2e266e5c/1delta-aggregators-0.1.6.tgz","_integrity":"sha512-aKR5fzMe1NW/xSt62lYKozaZt7f60+PdYXld50HNaPYZ26YzAOaJtZ8S3c0ay2KaUbR1R36mhHOF0wvpObagMQ==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"viem":"^2.40.0","axios":"^1.13.2","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.6","@1delta/calldatalib":"^0.0.46","@1delta/calldata-sdk":"^0.0.125"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.6_1763991995260_0.40904468171767605","host":"s3://npm-registry-packages-npm-production"}},"0.1.7":{"name":"@1delta/aggregators","version":"0.1.7","_id":"@1delta/aggregators@0.1.7","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"dist":{"shasum":"4cfb6d733a1f93ba9c23f3b44f21a2ee3d45afd9","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.7.tgz","fileCount":162,"integrity":"sha512-MJ7KEs7TSmdp2dmbQZ4E67NVxaBX3jkUTFwht3S1arAuL1daKFa3gvRzM1gaKKgpkf3vI4WPjNx/ZUG0Up8SLA==","signatures":[{"sig":"MEQCIHG4ZwBtN1VkX2tOsj04ZDnAHI9fmGuIGhvbj3Ih4mQRAiBROiaYQORCNrKlbXo8OtpVuH+yPuT0Y7QEoyifn5eFQg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":364410},"main":"dist/index.js","_from":"file:1delta-aggregators-0.1.7.tgz","types":"dist/index.d.ts","scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"_resolved":"/tmp/63ca8740968ebce51f78d4669edb498b/1delta-aggregators-0.1.7.tgz","_integrity":"sha512-MJ7KEs7TSmdp2dmbQZ4E67NVxaBX3jkUTFwht3S1arAuL1daKFa3gvRzM1gaKKgpkf3vI4WPjNx/ZUG0Up8SLA==","_npmVersion":"10.9.3","description":"Aggregators for 1Delta","directories":{},"_nodeVersion":"22.19.0","dependencies":{"qs":"^6.14.0","viem":"~2.45.3","axios":"^1.13.2","lodash":"^4.17.21","async-retry":"^1.3.3","@1delta/lib-utils":"0.1.12","@1delta/calldatalib":"0.0.49","@1delta/calldata-sdk":"0.0.139"},"_hasShrinkwrap":false,"devDependencies":{"@types/qs":"^6.9.18","typescript":"^5.9.3"},"_npmOperationalInternal":{"tmp":"tmp/aggregators_0.1.7_1774789383498_0.8037300439021424","host":"s3://npm-registry-packages-npm-production"}},"0.1.8":{"name":"@1delta/aggregators","version":"0.1.8","description":"Aggregators for 1Delta","main":"dist/index.js","types":"dist/index.d.ts","devDependencies":{"@types/qs":"^6.9.18","typescript":"^5.9.3"},"dependencies":{"@1delta/calldatalib":"0.0.54","async-retry":"^1.3.3","lodash":"^4.17.21","qs":"^6.14.0","viem":"~2.45.3","@1delta/calldata-sdk":"0.0.147","@1delta/lib-utils":"0.1.12","@1delta/proxy-fetch":"0.0.1"},"scripts":{"build":"tsc --project tsconfig.json","clean":"rm -rf dist tsconfig.tsbuildinfo"},"_id":"@1delta/aggregators@0.1.8","_integrity":"sha512-G5FbGNm+I2ewGbH2XPtIdvbHSo3tmw5hLvOs1RvUDYwr2r6j0cnfTXv0N3G8fzu67FoqwPmLWarKjV4ISQRXeA==","_resolved":"/tmp/1601582764917120e400c987d05cfed3/1delta-aggregators-0.1.8.tgz","_from":"file:1delta-aggregators-0.1.8.tgz","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-G5FbGNm+I2ewGbH2XPtIdvbHSo3tmw5hLvOs1RvUDYwr2r6j0cnfTXv0N3G8fzu67FoqwPmLWarKjV4ISQRXeA==","shasum":"36aa4538e7408ee1814d581b3d1f78d289860028","tarball":"https://registry.npmjs.org/@1delta/aggregators/-/aggregators-0.1.8.tgz","fileCount":182,"unpackedSize":408405,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDvQ2o/Js7LB7TvSykb3EAFdF3Bzq3XZ+9y7vbITIkTjwIhAIFR4V+GT9j359cvTRfmS+IBNkpvajKMPixQ6CvJW0KL"}]},"_npmUser":{"name":"delta-achthar","email":"achim@1delta.io"},"directories":{},"maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/aggregators_0.1.8_1777895537176_0.5143980260033549"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-05T16:04:04.966Z","modified":"2026-05-04T11:52:17.474Z","0.1.0":"2025-11-05T16:04:05.287Z","0.1.1":"2025-11-07T10:51:50.249Z","0.1.2":"2025-11-09T14:45:49.487Z","0.1.3":"2025-11-11T10:07:00.944Z","0.1.4":"2025-11-19T10:37:56.253Z","0.1.5":"2025-11-20T16:26:07.887Z","0.1.6":"2025-11-24T13:46:35.447Z","0.1.7":"2026-03-29T13:03:03.670Z","0.1.8":"2026-05-04T11:52:17.349Z"},"description":"Aggregators for 1Delta","maintainers":[{"name":"delta-achthar","email":"achim@1delta.io"}],"readme":"# @1delta/aggregators\n\nUnified wrapper around 17+ DEX aggregator APIs. Provides a single entry point\n(`fetchAggregatorTrade`) that accepts a common set of parameters and returns a\nnormalized `GenericTrade` object, regardless of which underlying aggregator is\nused.\n\n## Quick Start\n\n```typescript\nimport { fetchAggregatorTrade, TradeAggregator } from '@1delta/aggregators'\nimport { TradeType } from '@1delta/lib-utils'\n\nconst trade = await fetchAggregatorTrade(TradeAggregator.Odos, {\n  chainId: '1',\n  fromCurrency: { address: '0xA0b8...', decimals: 18, symbol: 'WETH' },\n  toCurrency: { address: '0xA0b8...', decimals: 6, symbol: 'USDC' },\n  swapAmount: '1000000000000000000', // 1 WETH in wei\n  caller: '0xYourAddress',\n  receiver: '0xYourAddress',\n  slippage: 0.3, // 0.3%\n  tradeType: TradeType.EXACT_INPUT,\n})\n\n// Get calldata for on-chain execution\nconst callInfo = await trade?.assemble?.()\n\n// Re-quote with updated slippage\nconst refreshed = await trade?.refresh?.({ slippage: 0.5 })\n```\n\n## How It Works\n\n### Architecture\n\n```\nfetchAggregatorTrade(aggregator, input)\n        |\n        v\n  Fetcher Registry          <-- Map<TradeAggregator, FetcherFn>\n        |\n   +---------+---------+\n   |         |         |\nOneDelta  Wrapper  External (Odos, 1inch, Paraswap, ...)\n   |         |         |\n   v         v         v\n GenericTrade (unified output)\n```\n\n1. **Caller** picks an aggregator from the `TradeAggregator` enum and passes\n   unified `AggregatorApiInput`.\n2. **Router** (`aggregator.ts`) looks up the registered fetcher and dispatches\n   the call.\n3. **Fetcher** normalizes the input (token addresses, slippage format), calls\n   the aggregator API, and returns a `GenericTrade`.\n\n### Fetcher Categories\n\n| Category     | Aggregator      | Behavior                                                                            |\n| ------------ | --------------- | ----------------------------------------------------------------------------------- |\n| **Internal** | `OneDelta`      | Uses 1delta routing API. Accepts extended `OneDeltaInput`.                          |\n| **Wrapper**  | `NativeWrapper` | Synchronous wrap/unwrap of native token (ETH/MATIC/etc). No external API call.      |\n| **External** | All others      | Calls a third-party aggregator API, returns quote + lazy `assemble()` for calldata. |\n\n## Unified Input\n\nAll fetchers accept `AggregatorApiInput` (from `@1delta/lib-utils`):\n\n| Field                  | Type               | Description                                       |\n| ---------------------- | ------------------ | ------------------------------------------------- |\n| `chainId`              | `string`           | Target chain ID                                   |\n| `fromCurrency`         | `RawCurrency`      | Source token (address, decimals, symbol)          |\n| `toCurrency`           | `RawCurrency`      | Destination token                                 |\n| `swapAmount`           | `string`           | Amount in smallest unit (wei)                     |\n| `caller`               | `string`           | Transaction sender                                |\n| `receiver`             | `string`           | Token recipient                                   |\n| `slippage`             | `number`           | Slippage tolerance as percent (e.g. `0.3` = 0.3%) |\n| `tradeType`            | `TradeType`        | `EXACT_INPUT` or `EXACT_OUTPUT`                   |\n| `marginParams?`        | `MarginParameters` | Flash loan configuration for margin trades        |\n| `usePendleMintRedeem?` | `boolean`          | Enable Pendle PT/YT mint/redeem routing           |\n| `simpleRoute?`         | `boolean`          | Request simpler routing (Odos)                    |\n\n### Slippage Normalization\n\nSlippage is always provided as **percent** (e.g. `0.3` = 0.3%). Callers should\nnever convert slippage themselves -- pass the raw percent value and\n`convertSlippageForAggregator()` handles the rest.\n\nEach aggregator API expects slippage in a different format. The conversion is\nhandled automatically inside every fetcher via\n`convertSlippageForAggregator(slippage, aggregator)` (defined in\n`src/utils/misc.ts`):\n\n| Target format             | Example (0.3% in) | Example (out) | Aggregators                                 |\n| ------------------------- | ----------------- | ------------- | ------------------------------------------- |\n| **Decimal**               | `0.3`             | `0.003`       | SushiSwap, Fly, Pendle, OogaBooga, Eisen |\n| **Basis points**          | `0.3`             | `30`          | Kyberswap, Paraswap, 0x, Enso, Uniswap      |\n| **Percent** (passthrough) | `0.3`             | `0.3`         | OpenOcean, Odos, 1inch                      |\n\nWhen adding a new aggregator, check the API docs for the expected slippage\nformat and add a `case` to the `switch` in `convertSlippageForAggregator()`. If\nthe aggregator uses percent (the input format), no case is needed -- the\n`default` branch passes the value through.\n\n## Unified Output\n\nEvery fetcher returns `GenericTrade`:\n\n| Field              | Type                                    | Description                          |\n| ------------------ | --------------------------------------- | ------------------------------------ |\n| `tradeType`        | `TradeType`                             | `EXACT_INPUT` or `EXACT_OUTPUT`      |\n| `inputAmount`      | `CurrencyAmount`                        | Parsed input amount                  |\n| `outputAmount`     | `CurrencyAmount`                        | Parsed output amount                 |\n| `aggregator`       | `TradeAggregator`                       | Which aggregator produced this quote |\n| `target`           | `string`                                | Contract to send the transaction to  |\n| `approvalTarget`   | `string`                                | Contract to approve tokens against   |\n| `slippage`         | `number`                                | Applied slippage (percent)           |\n| `flashLoanSource?` | `FlashLoanProvider`                     | Flash loan provider (margin trades)  |\n| `assemble?`        | `() => Promise<GenericCallInfo>`        | Lazily builds calldata for execution |\n| `refresh?`         | `(overrides?) => Promise<GenericTrade>` | Re-fetches the quote                 |\n| `order?`           | `Order`                                 | Bebop-specific signing order         |\n\n### Two-Step Quote Flow\n\nMost aggregators use a **quote-then-assemble** pattern:\n\n1. **Quote** -- fetcher calls the aggregator API and returns a `GenericTrade`\n   with price/amount info.\n2. **Assemble** -- calling `trade.assemble()` makes a second API call to get the\n   actual transaction calldata (`to`, `calldata`, `value`).\n\nThis avoids building calldata until the user confirms the trade.\n\n## Supported Aggregators\n\n| Aggregator    | Enum Value  | Chains                                                                                                                                                                    |\n| ------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| NativeWrapper | `Wrapper`   | All                                                                                                                                                                       |\n| 1delta        | `1delta`    | Polygon, Base, Arbitrum, Optimism, Mantle, Taiko, Core, Hemi, Moonbeam, Metis, Fuel                                                                                       |\n| 1inch         | `1inch`     | Ethereum, Polygon, BNB, Arbitrum, Optimism, Avalanche, Linea, Fantom, Kaia, Unichain                                                                                      |\n| Paraswap      | `Paraswap`  | Ethereum, Polygon, BNB, Arbitrum, Optimism, Scroll, Sonic, Fantom, Gnosis                                                                                                 |\n| Odos          | `Odos`      | Ethereum, Polygon, BNB, Arbitrum, Optimism, Base, Avalanche, Mantle, Linea, Scroll, Sonic, Fantom, Mode, Unichain                                                         |\n| Kyberswap     | `Kyberswap` | Ethereum, Polygon, BNB, Arbitrum, Optimism, Base, Mantle, Linea, Scroll, Sonic, Fantom, Blast, Gnosis, Berachain, Metis, HyperEVM, Unichain, Plasma, Monad                |\n| Bebop         | `Bebop`     | Ethereum, Polygon, BNB, Arbitrum, Optimism, Base, Blast, Taiko, Mode, Berachain, HyperEVM, Unichain                                                                       |\n| Nordstern     | `Nordstern` | Most chains                                                                                                                                                               |\n| Fly (fly.trade) | `Fly`       | Ethereum, Polygon, BNB, Arbitrum, Optimism, Base, Avalanche, Blast, Scroll, Sonic, Fantom, Manta, Berachain, Metis                                                        |\n| 0x            | `0x`        | Ethereum, Polygon, BNB, Arbitrum, Base, Mantle, Linea, Blast, Mode, Scroll, Plasma, Monad                                                                                 |\n| SushiSwap     | `Sushiswap` | Most chains                                                                                                                                                               |\n| OpenOcean     | `OpenOcean` | Most chains                                                                                                                                                               |\n| Pendle        | `Pendle`    | Ethereum, BNB, Arbitrum, Optimism, Base, Mantle, Sonic, Berachain, HyperEVM, Plasma                                                                                       |\n| Wowmax        | `Wowmax`    | (currently disabled)                                                                                                                                                      |\n| Eisen         | `Eisen`     | BNB, Arbitrum, Base, Mantle, Linea, Taiko, Blast, Scroll, Morph, Hemi, Mode, Berachain, HyperEVM, Soneium, Katana, Zircuit, Abstract, Plume, Flow, Rootstock, Monad, Core |\n| Enso          | `Enso`      | Ethereum, Polygon, Arbitrum, Optimism, Base, Avalanche, Linea, Sonic, Gnosis, Berachain, Soneium, Katana, HyperEVM, Unichain, World Chain                                 |\n| OogaBooga     | `OogaBooga` | Berachain, HyperEVM, Monad                                                                                                                                                |\n| Uniswap       | `Uniswap`   | Ethereum, Polygon, BNB, Arbitrum, Base, Optimism, Avalanche, Blast, Linea, Unichain, Soneium, Monad, World Chain, Celo                                                    |\n\nUse `getAvailableAggregators(chainId)` to get the list for a specific chain at\nruntime.\n\n## Margin / Flash Loan Integration\n\nWhen `marginParams` is set on the input, the fetcher adjusts the swap amount to\naccount for flash loan fees before quoting. This enables margin trading where\nthe swap is funded by a flash loan.\n\n```typescript\nconst trade = await fetchAggregatorTrade(TradeAggregator.Odos, {\n  ...baseInput,\n  marginParams: {\n    flashSources: {\n      canUseMorpho: true,\n      canUseBalancerV3: false,\n      balancersAvailable: [],\n      aaveFee: 5n, // 5 bps\n      aaveFork: '0x...',\n    },\n    adjustForFlashFee: true,\n    maxInput: false,\n  },\n})\n```\n\n**Flash loan provider priority:** Morpho Blue > Balancer V3 > Balancer V2 > Aave\nfork.\n\nIf margin params are provided but no flash sources are available, the fetcher\nreturns `undefined` (no quote).\n\n## Proxy Configuration\n\nSome aggregator HTTP origins are blocked from certain runtimes; those use a\n**VPS relay**. Everything else uses **direct** HTTP.\n\n**Per-aggregator routing** is fixed in code:\n[`src/proxy/config.ts`](src/proxy/config.ts) exports `AGGREGATOR_PROXY_MODES`\n(`Record<TradeAggregator, ProxyMode>`). Only **Kyberswap** uses `Relay`; all\nother aggregators use `None`.\n\n| Mode    | Description                                            |\n| ------- | ------------------------------------------------------ |\n| `None`  | Direct fetch — no proxy                                |\n| `Relay` | Route through the VPS relay (`?url=` + `X-Relay-Auth`) |\n\n### Setup\n\nSet relay credentials once per process (required before any **Relay** fetcher\nruns, e.g. Kyberswap):\n\n```typescript\nimport { setProxyConfig } from '@1delta/aggregators'\n\nsetProxyConfig({\n  relay: {\n    baseUrl: process.env.RELAY_PROXY_URL!,\n    secret: process.env.RELAY_PROXY_SECRET!,\n  },\n})\n```\n\n### How It Works\n\nWhen a fetcher makes an HTTP call, it resolves its mode via\n`getAggregatorProxyMode()` and passes it to `proxyGet()` / `proxyPost()` /\n`proxyNativeFetch()`:\n\n- **None** — direct `axios` / `fetch` to the original URL (passthrough)\n- **Relay** — `GET/POST` to\n  `{relay.baseUrl}?url={encodeURIComponent(originalUrl)}` with an `X-Relay-Auth`\n  header\n\nBoth GET and POST are supported by the relay. The request body (for POST) is\nforwarded as-is.\n\n### Environment Variables\n\nFor worker deployments, set these in `wrangler.toml` or your env:\n\n| Variable             | Description                               |\n| -------------------- | ----------------------------------------- |\n| `RELAY_PROXY_URL`    | Base URL of the VPS relay proxy worker    |\n| `RELAY_PROXY_SECRET` | Auth secret for the `X-Relay-Auth` header |\n\n## Fetcher Registry\n\nFetchers are registered in a `Map` and can be replaced or extended at runtime:\n\n```typescript\nimport {\n  registerFetcher,\n  getFetcher,\n  getAllFetchers,\n} from '@1delta/aggregators'\n\n// Register a custom fetcher\nregisterFetcher('MyAggregator', myFetcherFn)\n\n// Retrieve a fetcher\nconst fetcher = getFetcher('Odos')\n```\n\nThe default fetchers are registered via `getAllAggregatorFetchers()` in\n`fetcher/index.ts`.\n\n## Adding a New Aggregator\n\n1. Create `src/fetcher/myAggregator.ts` implementing\n   `ExternalAggregatorFetcher`.\n2. Add an entry to the `TradeAggregator` enum in `src/types/tradeAggregator.ts`.\n3. Add the new enum member to `AGGREGATOR_PROXY_MODES` in `src/proxy/config.ts`\n   (almost always `ProxyMode.None`; use `Relay` only if the upstream blocks\n   direct calls from your runtime).\n4. Register it in the `fetchers` map in `src/fetcher/index.ts`.\n5. Add chain availability in `src/types/basics.ts`.\n6. Add the aggregator to `PENDLE_AGGREGATOR_CAPABILITIES` in\n   `src/utils/pendle/index.ts` (set to `undefined` unless it supports Pendle\n   tokens).\n7. If the aggregator expects slippage in **decimal** or **basis points** (not\n   percent), add a `case` to `convertSlippageForAggregator()` in\n   `src/utils/misc.ts`. See [Slippage Normalization](#slippage-normalization)\n   for the formats.\n\nA typical fetcher follows this pattern:\n\n```typescript\nexport const fetchMyTrade = async (\n  input: AggregatorApiInput,\n  controller?: AbortController,\n): Promise<GenericTrade | undefined> => {\n  // 1. Normalize token addresses (native → zero/wrapped)\n  // 2. Convert slippage via convertSlippageForAggregator()\n  // 3. Adjust amount for margin if marginParams present\n  // 4. Call aggregator quote API\n  // 5. Build GenericTrade with assemble() and refresh()\n  // 6. Return trade\n}\n```\n","readmeFilename":"README.md"}