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;AAClB,UAAA;AACF,YAAA;AACqB,YAAA;AACJ,YAAA;AACtB,UAAA;AACF,QAAA;AACS,QAAA;AAC0D,UAAA;AACnE,QAAA;AACF,MAAA;AACF,IAAA;AAEW,IAAA;AACb,EAAA;AAE0E,EAAA;AAC5E;AAkBE;AACwC,EAAA;AAED,EAAA;AACzC;ADpC4E;AACA;AACA;AACA;AACA","file":"/Users/paul-n/git/ston-fi/public/sdk-contracts/packages/sdk/dist/chunk-RZRWJECQ.cjs","sourcesContent":[null,"import type { RouterInfo } from \"@ston-fi/api\";\n\nimport { DEX, DEX_TYPE } from \"./contracts/dex\";\n\n/**\n * Returns a set of DEX contracts for the given version and type of the router.\n * Useful for defining the set of contracts based on the API information about the router.\n * Throws if the version or type is not supported.\n *\n * @param {number} routerInfo.majorVersion - The major version of the router.\n * @param {number} routerInfo.minorVersion - The minor version of the router.\n * @param {string | undefined} routerInfo.routerType - The type of router.\n *\n * @returns The set of contracts for the given version.\n */\nexport function dexFactory(\n  routerInfo: Pick<RouterInfo, \"majorVersion\" | \"minorVersion\"> & {\n    routerType?: RouterInfo[\"routerType\"] | DEX_TYPE;\n  },\n) {\n  const { majorVersion, minorVersion } = routerInfo;\n\n  if (majorVersion === 1 && minorVersion === 0) {\n    return DEX.v1;\n  }\n\n  if (majorVersion === 2 && minorVersion === 1) {\n    if (routerInfo.routerType) {\n      const contracts = {\n        ...DEX.v2_1,\n        /**\n         * @deprecated. `dexFactory` will return the correct router class to work with, not a generic one\n         * Left for backward compatibility for those, who use `dexFactory().Router.*` syntax\n         */\n        _Router: DEX.v2_1.Router,\n        /**\n         * @deprecated. `dexFactory` will return the correct router class to work with, not a generic one\n         * Left for backward compatibility for those, who use `dexFactory().Pool.*` syntax\n         */\n        _Pool: DEX.v2_1.Pool,\n      } as const;\n\n      switch (routerInfo.routerType) {\n        case DEX_TYPE.CPI:\n        case \"ConstantProduct\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_1.Router.CPI,\n            Pool: DEX.v2_1.Pool.CPI,\n          };\n        }\n        case DEX_TYPE.Stable:\n        case \"StableSwap\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_1.Router.Stable,\n            Pool: DEX.v2_1.Pool.Stable,\n          };\n        }\n        case DEX_TYPE.WCPI:\n        case \"WeightedConstProduct\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_1.Router.WCPI,\n            Pool: DEX.v2_1.Pool.WCPI,\n          };\n        }\n        case DEX_TYPE.WStable:\n        case \"WeightedStableSwap\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_1.Router.WStable,\n            Pool: DEX.v2_1.Pool.WStable,\n          };\n        }\n        default: {\n          throw new Error(`Unsupported router type: ${routerInfo.routerType}`);\n        }\n      }\n    }\n\n    return DEX.v2_1;\n  }\n\n  if (majorVersion === 2 && minorVersion === 2) {\n    if (routerInfo.routerType) {\n      const contracts = {\n        ...DEX.v2_2,\n        /**\n         * @deprecated. `dexFactory` will return the correct router class to work with, not a generic one\n         * Left for backward compatibility for those, who use `dexFactory().Router.*` syntax\n         */\n        _Router: DEX.v2_2.Router,\n        /**\n         * @deprecated. `dexFactory` will return the correct router class to work with, not a generic one\n         * Left for backward compatibility for those, who use `dexFactory().Pool.*` syntax\n         */\n        _Pool: DEX.v2_2.Pool,\n      } as const;\n\n      switch (routerInfo.routerType) {\n        case DEX_TYPE.CPI:\n        case \"ConstantProduct\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_2.Router.CPI,\n            Pool: DEX.v2_2.Pool.CPI,\n          };\n        }\n        case DEX_TYPE.Stable:\n        case \"StableSwap\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_2.Router.Stable,\n            Pool: DEX.v2_2.Pool.Stable,\n          };\n        }\n        case DEX_TYPE.WCPI:\n        case \"WeightedConstProduct\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_2.Router.WCPI,\n            Pool: DEX.v2_2.Pool.WCPI,\n          };\n        }\n        case DEX_TYPE.WStable:\n        case \"WeightedStableSwap\": {\n          return {\n            ...contracts,\n            Router: DEX.v2_2.Router.WStable,\n            Pool: DEX.v2_2.Pool.WStable,\n          };\n        }\n        default: {\n          throw new Error(`Unsupported router type: ${routerInfo.routerType}`);\n        }\n      }\n    }\n\n    return DEX.v2_2;\n  }\n\n  throw new Error(`Unsupported dex version: ${majorVersion}.${minorVersion}`);\n}\n\n/**\n * Returns an instance of the router contract for the given version, address and type.\n * Useful for creating a router based on the API information about the router.\n * Throws if the version or type is not supported.\n *\n * @param {Address | string} routerInfo.address - The address of the router.\n * @param {number} routerInfo.majorVersion - The major version of the router.\n * @param {number} routerInfo.minorVersion - The minorVersion version of the router.\n * @param {string | undefined} routerInfo.routerType - The type of router.\n *\n * @returns {Router} The instance of the router contract.\n */\nexport function routerFactory(\n  routerInfo: Pick<RouterInfo, \"address\" | \"majorVersion\" | \"minorVersion\"> & {\n    routerType?: RouterInfo[\"routerType\"] | DEX_TYPE;\n  },\n) {\n  const { Router } = dexFactory(routerInfo);\n\n  return Router.create(routerInfo.address);\n}\n"]}