@kaspacom/swap-sdk 1.1.7 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -146,6 +146,14 @@ declare class SwapService {
146
146
  protected rejectPartnerFeeLoaded: ((error: any) => void) | null;
147
147
  protected partnerFee: bigint;
148
148
  constructor(provider: BrowserProvider | JsonRpcProvider, config: SwapSdkNetworkConfig, swapOptions: SwapSdkOptions);
149
+ protected get routerContractFunctionNames(): {
150
+ swapExactTokensForTokens: string;
151
+ swapTokensForExactTokens: string;
152
+ swapExactETHForTokens: string;
153
+ swapETHForExactTokens: string;
154
+ swapExactTokensForETH: string;
155
+ swapTokensForExactETH: string;
156
+ };
149
157
  protected get routerAbi(): string[];
150
158
  protected get factoryAbi(): string[];
151
159
  protected get proxyAbi(): string[];
package/dist/index.d.ts CHANGED
@@ -146,6 +146,14 @@ declare class SwapService {
146
146
  protected rejectPartnerFeeLoaded: ((error: any) => void) | null;
147
147
  protected partnerFee: bigint;
148
148
  constructor(provider: BrowserProvider | JsonRpcProvider, config: SwapSdkNetworkConfig, swapOptions: SwapSdkOptions);
149
+ protected get routerContractFunctionNames(): {
150
+ swapExactTokensForTokens: string;
151
+ swapTokensForExactTokens: string;
152
+ swapExactETHForTokens: string;
153
+ swapETHForExactTokens: string;
154
+ swapExactTokensForETH: string;
155
+ swapTokensForExactETH: string;
156
+ };
149
157
  protected get routerAbi(): string[];
150
158
  protected get factoryAbi(): string[];
151
159
  protected get proxyAbi(): string[];
@@ -32237,23 +32237,33 @@ var KaspaComSwapSdk = (() => {
32237
32237
  this.loadAllPairs();
32238
32238
  this.loadPartnerFee();
32239
32239
  }
32240
+ get routerContractFunctionNames() {
32241
+ return {
32242
+ swapExactTokensForTokens: "swapExactTokensForTokens",
32243
+ swapTokensForExactTokens: "swapTokensForExactTokens",
32244
+ swapExactETHForTokens: "swapExactETHForTokens",
32245
+ swapETHForExactTokens: "swapETHForExactTokens",
32246
+ swapExactTokensForETH: "swapExactTokensForETH",
32247
+ swapTokensForExactETH: "swapTokensForExactETH"
32248
+ };
32249
+ }
32240
32250
  get routerAbi() {
32241
32251
  return [
32242
32252
  // Swaps (ERC20 <-> ERC20)
32243
- "function swapExactTokensForTokens(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)",
32244
- "function swapTokensForExactTokens(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)",
32253
+ `function ${this.routerContractFunctionNames.swapExactTokensForTokens}(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)`,
32254
+ `function ${this.routerContractFunctionNames.swapTokensForExactTokens}(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)`,
32245
32255
  // Swaps (ETH <-> ERC20)
32246
- "function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)",
32247
- "function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)",
32248
- "function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)",
32249
- "function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)",
32256
+ `function ${this.routerContractFunctionNames.swapExactETHForTokens}(uint amountOutMin, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)`,
32257
+ `function ${this.routerContractFunctionNames.swapETHForExactTokens}(uint amountOut, address[] calldata path, address to, uint deadline) external payable returns (uint[] memory amounts)`,
32258
+ `function ${this.routerContractFunctionNames.swapExactTokensForETH}(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)`,
32259
+ `function ${this.routerContractFunctionNames.swapTokensForExactETH}(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline) external returns (uint[] memory amounts)`,
32250
32260
  // Get Amounts
32251
- "function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)",
32252
- "function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut)",
32253
- "function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn)",
32254
- "function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts)",
32261
+ `function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts)`,
32262
+ `function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut)`,
32263
+ `function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn)`,
32264
+ `function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts)`,
32255
32265
  // Get WETH
32256
- "function WETH() external pure returns (address)"
32266
+ `function WETH() external pure returns (address)`
32257
32267
  ];
32258
32268
  }
32259
32269
  get factoryAbi() {
@@ -32614,6 +32624,7 @@ var KaspaComSwapSdk = (() => {
32614
32624
  if (!this.signer) {
32615
32625
  throw new Error("Please connect wallet first");
32616
32626
  }
32627
+ console.log("from the insiddeee", this.routerContractFunctionNames);
32617
32628
  try {
32618
32629
  const deadlineTimestamp = Math.floor(Date.now() / 1e3) + deadline * 60;
32619
32630
  let tx;
@@ -32623,14 +32634,14 @@ var KaspaComSwapSdk = (() => {
32623
32634
  const to = this.config.proxyAddress ? this.config.proxyAddress : signerAddress;
32624
32635
  if (isOutputAmount) {
32625
32636
  if (fromToken.address === ethers_exports.ZeroAddress) {
32626
- swapData = iface.encodeFunctionData("swapETHForExactTokens", [
32637
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapETHForExactTokens, [
32627
32638
  amountOutWei,
32628
32639
  path,
32629
32640
  to,
32630
32641
  deadlineTimestamp
32631
32642
  ]);
32632
32643
  } else if (toToken.address === ethers_exports.ZeroAddress) {
32633
- swapData = iface.encodeFunctionData("swapTokensForExactETH", [
32644
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapTokensForExactETH, [
32634
32645
  amountOutWei,
32635
32646
  amountInWei,
32636
32647
  path,
@@ -32638,7 +32649,7 @@ var KaspaComSwapSdk = (() => {
32638
32649
  deadlineTimestamp
32639
32650
  ]);
32640
32651
  } else {
32641
- swapData = iface.encodeFunctionData("swapTokensForExactTokens", [
32652
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapTokensForExactTokens, [
32642
32653
  amountOutWei,
32643
32654
  amountInWei,
32644
32655
  path,
@@ -32648,14 +32659,14 @@ var KaspaComSwapSdk = (() => {
32648
32659
  }
32649
32660
  } else {
32650
32661
  if (fromToken.address === ethers_exports.ZeroAddress) {
32651
- swapData = iface.encodeFunctionData("swapExactETHForTokens", [
32662
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapExactETHForTokens, [
32652
32663
  amountOutWei,
32653
32664
  path,
32654
32665
  to,
32655
32666
  deadlineTimestamp
32656
32667
  ]);
32657
32668
  } else if (toToken.address === ethers_exports.ZeroAddress) {
32658
- swapData = iface.encodeFunctionData("swapExactTokensForETH", [
32669
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapExactTokensForETH, [
32659
32670
  amountInWei,
32660
32671
  amountOutWei,
32661
32672
  path,
@@ -32663,7 +32674,7 @@ var KaspaComSwapSdk = (() => {
32663
32674
  deadlineTimestamp
32664
32675
  ]);
32665
32676
  } else {
32666
- swapData = iface.encodeFunctionData("swapExactTokensForTokens", [
32677
+ swapData = iface.encodeFunctionData(this.routerContractFunctionNames.swapExactTokensForTokens, [
32667
32678
  amountInWei,
32668
32679
  amountOutWei,
32669
32680
  path,