diff --git a/.changeset/khaki-experts-smoke.md b/.changeset/khaki-experts-smoke.md new file mode 100644 index 00000000..66145e3a --- /dev/null +++ b/.changeset/khaki-experts-smoke.md @@ -0,0 +1,5 @@ +--- +"@balancer/sdk": patch +--- + +Add support for Sonic chain diff --git a/package.json b/package.json index d0dc0835..74d82786 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dependencies": { "decimal.js-light": "^2.5.1", "lodash.clonedeep": "^4.5.0", - "viem": "^2.12.1" + "viem": "^2.21.55" }, "devDependencies": { "@biomejs/biome": "^1.5.2", @@ -44,7 +44,7 @@ "pino-pretty": "^10.3.1", "ts-node": "^10.9.2", "tsup": "^8.0.1", - "typescript": "^5.3.3", + "typescript": "^5.7.2", "vite": "^5.2.10", "vite-tsconfig-paths": "^4.2.3", "vitest": "^1.2.0" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33f5b054..3422518d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.0' +lockfileVersion: '6.1' settings: autoInstallPeers: true @@ -12,8 +12,8 @@ dependencies: specifier: ^4.5.0 version: 4.5.0 viem: - specifier: ^2.12.1 - version: 2.12.1(typescript@5.3.3) + specifier: ^2.21.55 + version: 2.21.55(typescript@5.7.2) devDependencies: '@biomejs/biome': @@ -45,27 +45,27 @@ devDependencies: version: 10.3.1 ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@18.19.7)(typescript@5.3.3) + version: 10.9.2(@types/node@18.19.7)(typescript@5.7.2) tsup: specifier: ^8.0.1 - version: 8.0.1(ts-node@10.9.2)(typescript@5.3.3) + version: 8.0.1(ts-node@10.9.2)(typescript@5.7.2) typescript: - specifier: ^5.3.3 - version: 5.3.3 + specifier: ^5.7.2 + version: 5.7.2 vite: specifier: ^5.2.10 version: 5.2.10(@types/node@18.19.7) vite-tsconfig-paths: specifier: ^4.2.3 - version: 4.2.3(typescript@5.3.3)(vite@5.2.10) + version: 4.2.3(typescript@5.7.2)(vite@5.2.10) vitest: specifier: ^1.2.0 version: 1.2.0(@types/node@18.19.7) packages: - /@adraffy/ens-normalize@1.10.0: - resolution: {integrity: sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==} + /@adraffy/ens-normalize@1.11.0: + resolution: {integrity: sha512-/3DDPKHqqIqxUULp8yP4zODUY1i+2xvVWsv8A79xGWdCAG+8sb0hRh0Rk2QyOJUnnbyPUAZYcpBuRe3nS2OIUg==} dev: false /@babel/code-frame@7.23.5: @@ -865,15 +865,21 @@ packages: read-yaml-file: 1.1.0 dev: true - /@noble/curves@1.2.0: - resolution: {integrity: sha512-oYclrNgRaM9SsBUBVbb8M6DTV7ZHRTKugureoYEncY5c65HOmRzvSiTE3y5CYaPYJA/GVkrhXEoF0M3Ya9PMnw==} + /@noble/curves@1.7.0: + resolution: {integrity: sha512-UTMhXK9SeDhFJVrHeUJ5uZlI6ajXg10O6Ddocf9S6GjbSBVZsJo88HzKwXznNfGpMTRDyJkqMjNDPYgf0qFWnw==} + engines: {node: ^14.21.3 || >=16} dependencies: - '@noble/hashes': 1.3.2 + '@noble/hashes': 1.6.0 dev: false - /@noble/hashes@1.3.2: - resolution: {integrity: sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==} - engines: {node: '>= 16'} + /@noble/hashes@1.6.0: + resolution: {integrity: sha512-YUULf0Uk4/mAA89w+k3+yUYh6NrEvxZa5T6SY3wlMvE2chHkxFUUIDI8/XW1QSC357iA5pSnqt7XEhvFOqmDyQ==} + engines: {node: ^14.21.3 || >=16} + dev: false + + /@noble/hashes@1.6.1: + resolution: {integrity: sha512-pq5D8h10hHBjyqX+cfBm0i8JUXJ0UhczFc4r74zbuT9XgewFo2E3J1cOaGtdZynILNmQ685YWGzGE1Zv6io50w==} + engines: {node: ^14.21.3 || >=16} dev: false /@nodelib/fs.scandir@2.1.5: @@ -1136,23 +1142,23 @@ packages: dev: true optional: true - /@scure/base@1.1.5: - resolution: {integrity: sha512-Brj9FiG2W1MRQSTB212YVPRrcbjkv48FoZi/u4l/zds/ieRrqsh7aUf6CLwkAq61oKXr/ZlTzlY66gLIj3TFTQ==} + /@scure/base@1.2.1: + resolution: {integrity: sha512-DGmGtC8Tt63J5GfHgfl5CuAXh96VF/LD8K9Hr/Gv0J2lAoRGlPOMpqMpMbCTOoOJMZCk2Xt+DskdDyn6dEFdzQ==} dev: false - /@scure/bip32@1.3.2: - resolution: {integrity: sha512-N1ZhksgwD3OBlwTv3R6KFEcPojl/W4ElJOeCZdi+vuI5QmTFwLq3OFf2zd2ROpKvxFdgZ6hUpb0dx9bVNEwYCA==} + /@scure/bip32@1.6.0: + resolution: {integrity: sha512-82q1QfklrUUdXJzjuRU7iG7D7XiFx5PHYVS0+oeNKhyDLT7WPqs6pBcM2W5ZdwOwKCwoE1Vy1se+DHjcXwCYnA==} dependencies: - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@scure/base': 1.1.5 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + '@scure/base': 1.2.1 dev: false - /@scure/bip39@1.2.1: - resolution: {integrity: sha512-Z3/Fsz1yr904dduJD0NpiyRHhRYHdcnyh73FZWiV+/qhWi83wNJ3NWolYqCEN+ZWsUz2TWwajJggcRE9r1zUYg==} + /@scure/bip39@1.5.0: + resolution: {integrity: sha512-Dop+ASYhnrwm9+HA/HwXg7j2ZqM6yk2fyLWb5znexjctFY3+E+eU8cIWI0Pql0Qx4hPZCijlGq4OL71g+Uz30A==} dependencies: - '@noble/hashes': 1.3.2 - '@scure/base': 1.1.5 + '@noble/hashes': 1.6.1 + '@scure/base': 1.2.1 dev: false /@sinclair/typebox@0.27.8: @@ -1273,8 +1279,8 @@ packages: pretty-format: 29.7.0 dev: true - /abitype@1.0.0(typescript@5.3.3): - resolution: {integrity: sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ==} + /abitype@1.0.7(typescript@5.7.2): + resolution: {integrity: sha512-ZfYYSktDQUwc2eduYu8C4wOs+RDPmnRYMh7zNfzeMtGGgb0U+6tLGjixUic6mXf5xKKCcgT5Qp6cv39tOARVFw==} peerDependencies: typescript: '>=5.0.4' zod: ^3 >=3.22.0 @@ -1284,7 +1290,7 @@ packages: zod: optional: true dependencies: - typescript: 5.3.3 + typescript: 5.7.2 dev: false /abort-controller@3.0.0: @@ -1785,7 +1791,7 @@ packages: glob: 10.3.10 ora: 5.4.1 tslib: 2.6.2 - typescript: 5.3.3 + typescript: 5.7.2 yargs: 17.7.2 dev: true @@ -1983,6 +1989,10 @@ packages: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: true + /eventemitter3@5.0.1: + resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==} + dev: false + /events@3.3.0: resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} engines: {node: '>=0.8.x'} @@ -2567,12 +2577,12 @@ packages: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} dev: true - /isows@1.0.4(ws@8.13.0): - resolution: {integrity: sha512-hEzjY+x9u9hPmBom9IIAqdJCwNLax+xrPb51vEPpERoFlIxgmZcHzsT5jKG06nvInKOBGvReAVz80Umed5CczQ==} + /isows@1.0.6(ws@8.18.0): + resolution: {integrity: sha512-lPHCayd40oW98/I0uvgaHKWCSvkzY27LjWLbtzOm64yQ+G3Q5npjjbdppU65iZXkK1Zt+kH9pfegli0AYfwYYw==} peerDependencies: ws: '*' dependencies: - ws: 8.13.0 + ws: 8.18.0 dev: false /jackspeak@2.3.6: @@ -2952,6 +2962,26 @@ packages: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} dev: true + /ox@0.1.2(typescript@5.7.2): + resolution: {integrity: sha512-ak/8K0Rtphg9vnRJlbOdaX9R7cmxD2MiSthjWGaQdMk3D7hrAlDoM+6Lxn7hN52Za3vrXfZ7enfke/5WjolDww==} + peerDependencies: + typescript: '>=5.4.0' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@adraffy/ens-normalize': 1.11.0 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + '@scure/bip32': 1.6.0 + '@scure/bip39': 1.5.0 + abitype: 1.0.7(typescript@5.7.2) + eventemitter3: 5.0.1 + typescript: 5.7.2 + transitivePeerDependencies: + - zod + dev: false + /p-filter@2.1.0: resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} engines: {node: '>=8'} @@ -3128,7 +3158,7 @@ packages: optional: true dependencies: lilconfig: 3.0.0 - ts-node: 10.9.2(@types/node@18.19.7)(typescript@5.3.3) + ts-node: 10.9.2(@types/node@18.19.7)(typescript@5.7.2) yaml: 2.3.4 dev: true @@ -3768,7 +3798,7 @@ packages: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} dev: true - /ts-node@10.9.2(@types/node@18.19.7)(typescript@5.3.3): + /ts-node@10.9.2(@types/node@18.19.7)(typescript@5.7.2): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true peerDependencies: @@ -3794,12 +3824,12 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 5.3.3 + typescript: 5.7.2 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true - /tsconfck@2.1.2(typescript@5.3.3): + /tsconfck@2.1.2(typescript@5.7.2): resolution: {integrity: sha512-ghqN1b0puy3MhhviwO2kGF8SeMDNhEbnKxjK7h6+fvY9JAxqvXi8y5NAHSQv687OVboS2uZIByzGd45/YxrRHg==} engines: {node: ^14.13.1 || ^16 || >=18} hasBin: true @@ -3809,14 +3839,14 @@ packages: typescript: optional: true dependencies: - typescript: 5.3.3 + typescript: 5.7.2 dev: true /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} dev: true - /tsup@8.0.1(ts-node@10.9.2)(typescript@5.3.3): + /tsup@8.0.1(ts-node@10.9.2)(typescript@5.7.2): resolution: {integrity: sha512-hvW7gUSG96j53ZTSlT4j/KL0q1Q2l6TqGBFc6/mu/L46IoNWqLLUzLRLP1R8Q7xrJTmkDxxDoojV5uCVs1sVOg==} engines: {node: '>=18'} hasBin: true @@ -3849,7 +3879,7 @@ packages: source-map: 0.8.0-beta.0 sucrase: 3.35.0 tree-kill: 1.2.2 - typescript: 5.3.3 + typescript: 5.7.2 transitivePeerDependencies: - supports-color - ts-node @@ -3927,8 +3957,8 @@ packages: is-typed-array: 1.1.12 dev: true - /typescript@5.3.3: - resolution: {integrity: sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==} + /typescript@5.7.2: + resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} engines: {node: '>=14.17'} hasBin: true @@ -3974,23 +4004,24 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /viem@2.12.1(typescript@5.3.3): - resolution: {integrity: sha512-71gxcGCXdNXQuBhpqXblVRH1F3hP/wONCptVOCW4r6VrCEXL/9vfNyCdQKtK/0WGyXm04Zs9Jf/AOAxKqf6FmQ==} + /viem@2.21.55(typescript@5.7.2): + resolution: {integrity: sha512-PgXew7C11cAuEtOSgRyQx2kJxEOPUwIwZA9dMglRByqJuFVA7wSGZZOOo/93iylAA8E15bEdqy9xulU3oKZ70Q==} peerDependencies: typescript: '>=5.0.4' peerDependenciesMeta: typescript: optional: true dependencies: - '@adraffy/ens-normalize': 1.10.0 - '@noble/curves': 1.2.0 - '@noble/hashes': 1.3.2 - '@scure/bip32': 1.3.2 - '@scure/bip39': 1.2.1 - abitype: 1.0.0(typescript@5.3.3) - isows: 1.0.4(ws@8.13.0) - typescript: 5.3.3 - ws: 8.13.0 + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + '@scure/bip32': 1.6.0 + '@scure/bip39': 1.5.0 + abitype: 1.0.7(typescript@5.7.2) + isows: 1.0.6(ws@8.18.0) + ox: 0.1.2(typescript@5.7.2) + typescript: 5.7.2 + webauthn-p256: 0.0.10 + ws: 8.18.0 transitivePeerDependencies: - bufferutil - utf-8-validate @@ -4018,7 +4049,7 @@ packages: - terser dev: true - /vite-tsconfig-paths@4.2.3(typescript@5.3.3)(vite@5.2.10): + /vite-tsconfig-paths@4.2.3(typescript@5.7.2)(vite@5.2.10): resolution: {integrity: sha512-xVsA2xe6QSlzBujtWF8q2NYexh7PAUYfzJ4C8Axpe/7d2pcERYxuxGgph9F4f0iQO36g5tyGq6eBUYIssdUrVw==} peerDependencies: vite: '*' @@ -4028,7 +4059,7 @@ packages: dependencies: debug: 4.3.4 globrex: 0.1.2 - tsconfck: 2.1.2(typescript@5.3.3) + tsconfck: 2.1.2(typescript@5.7.2) vite: 5.2.10(@types/node@18.19.7) transitivePeerDependencies: - supports-color @@ -4134,6 +4165,13 @@ packages: defaults: 1.0.4 dev: true + /webauthn-p256@0.0.10: + resolution: {integrity: sha512-EeYD+gmIT80YkSIDb2iWq0lq2zbHo1CxHlQTeJ+KkCILWpVy3zASH3ByD4bopzfk0uCwXxLqKGLqp2W4O28VFA==} + dependencies: + '@noble/curves': 1.7.0 + '@noble/hashes': 1.6.1 + dev: false + /webidl-conversions@4.0.2: resolution: {integrity: sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==} dev: true @@ -4234,8 +4272,8 @@ packages: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} dev: true - /ws@8.13.0: - resolution: {integrity: sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==} + /ws@8.16.0: + resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -4245,10 +4283,10 @@ packages: optional: true utf-8-validate: optional: true - dev: false + dev: true - /ws@8.16.0: - resolution: {integrity: sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==} + /ws@8.18.0: + resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -4258,7 +4296,7 @@ packages: optional: true utf-8-validate: optional: true - dev: true + dev: false /y18n@4.0.3: resolution: {integrity: sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==} diff --git a/src/data/providers/balancer-api/modules/sorSwapPaths/index.ts b/src/data/providers/balancer-api/modules/sorSwapPaths/index.ts index 692bb0e6..a96500c8 100644 --- a/src/data/providers/balancer-api/modules/sorSwapPaths/index.ts +++ b/src/data/providers/balancer-api/modules/sorSwapPaths/index.ts @@ -129,6 +129,8 @@ export class SorSwapPaths { return 'SEPOLIA'; case ChainId.BASE: return 'BASE'; + case ChainId.SONIC: + return 'SONIC'; default: throw Error(`Unsupported API chain: ${chainId}`); } diff --git a/src/utils/constants.ts b/src/utils/constants.ts index f4d55e8e..f077227b 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -17,6 +17,7 @@ import { sepolia, mode, fraxtal, + sonic } from 'viem/chains'; export const ZERO_ADDRESS: Address = @@ -65,6 +66,7 @@ export enum ChainId { BSC = 56, GNOSIS_CHAIN = 100, POLYGON = 137, + SONIC = 146, ZKSYNC_TESTNET = 280, FANTOM = 250, FRAXTAL = 252, @@ -92,6 +94,7 @@ export const API_CHAIN_NAMES: Record = { [ChainId.ARBITRUM_ONE]: 'ARBITRUM', [ChainId.AVALANCHE]: 'AVALANCHE', [ChainId.SEPOLIA]: 'SEPOLIA', + [ChainId.SONIC]: 'SONIC', }; export const CHAINS: Record = { @@ -111,6 +114,7 @@ export const CHAINS: Record = { [ChainId.AVALANCHE]: avalanche, [ChainId.BASE_GOERLI]: baseGoerli, [ChainId.SEPOLIA]: sepolia, + [ChainId.SONIC]: sonic, }; /** @@ -147,6 +151,7 @@ export const VAULT: Record = { [ChainId.POLYGON]: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', [ChainId.ZKEVM]: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', [ChainId.SEPOLIA]: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', + [ChainId.SONIC]: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', }; export const VAULT_V3: Record = { @@ -174,6 +179,7 @@ export const BALANCER_QUERIES: Record = { [ChainId.POLYGON]: '0xE39B5e3B6D74016b2F6A9673D7d7493B6DF549d5', [ChainId.ZKEVM]: '0x809b79b53f18e9bc08a961ed4678b901ac93213a', [ChainId.SEPOLIA]: '0x1802953277FD955f9a254B80Aa0582f193cF1d77', + [ChainId.SONIC]: '0x4B29DB997Ec0efDFEF13bAeE2a2D7783bCf67f17', }; export const WEIGHTED_POOL_FACTORY_BALANCER_V2: Record = { @@ -360,6 +366,14 @@ export const NATIVE_ASSETS = { 'Matic', '0xa2036f0538221a77a3937f1379699f44945018d0', ), + [ChainId.SONIC]: new Token( + ChainId.SONIC, + NATIVE_ADDRESS, + 18, + 'S', + 'Sonic', + '0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38', + ), }; export const ETH = NATIVE_ASSETS[ChainId.MAINNET];