@hinkal/common 0.1.52 → 0.1.55

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.
Files changed (71) hide show
  1. package/constants/axelar.constants.cjs +1 -1
  2. package/constants/axelar.constants.mjs +27 -28
  3. package/constants/chains.constants.cjs +1 -1
  4. package/constants/chains.constants.mjs +49 -49
  5. package/constants/kyc.constants.cjs +1 -1
  6. package/constants/kyc.constants.mjs +27 -3
  7. package/crypto/babyJub.cjs +1 -1
  8. package/crypto/babyJub.mjs +4 -4
  9. package/crypto/poseidon.cjs +1 -1
  10. package/crypto/poseidon.mjs +12 -12
  11. package/crypto/preProcessing.cjs +1 -1
  12. package/crypto/preProcessing.mjs +7 -5
  13. package/data-structures/Hinkal/Hinkal.cjs +1 -1
  14. package/data-structures/Hinkal/Hinkal.mjs +6 -3
  15. package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
  16. package/data-structures/Hinkal/hinkalActionStake.mjs +1 -1
  17. package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
  18. package/data-structures/Hinkal/hinkalPrivateWallet.mjs +11 -8
  19. package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
  20. package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +8 -9
  21. package/data-structures/crypto-keys/keys.cjs +1 -1
  22. package/data-structures/crypto-keys/keys.mjs +6 -7
  23. package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
  24. package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +9 -6
  25. package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
  26. package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -8
  27. package/data-structures/event-service/AbstractEventService.cjs +1 -1
  28. package/data-structures/event-service/AbstractEventService.mjs +24 -21
  29. package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
  30. package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +6 -3
  31. package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
  32. package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +6 -3
  33. package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
  34. package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +7 -4
  35. package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
  36. package/data-structures/transactions-manager/TransactionsManager.mjs +1 -1
  37. package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
  38. package/functions/pre-transaction/outputUtxoProcessing.mjs +8 -5
  39. package/functions/pre-transaction/processAmountChanges.cjs +1 -1
  40. package/functions/pre-transaction/processAmountChanges.mjs +13 -10
  41. package/functions/protocols/pendle.helpers.cjs +1 -1
  42. package/functions/protocols/pendle.helpers.mjs +18 -16
  43. package/functions/staking/index.cjs +1 -1
  44. package/functions/staking/index.mjs +24 -22
  45. package/functions/utils/resolve-sync.utils.cjs +1 -1
  46. package/functions/utils/resolve-sync.utils.d.ts +1 -0
  47. package/functions/utils/resolve-sync.utils.mjs +12 -3
  48. package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
  49. package/functions/web3/functionCalls/transactCallRelayer.mjs +2 -2
  50. package/functions/web3/odosAPI.cjs +1 -1
  51. package/functions/web3/odosAPI.mjs +14 -11
  52. package/functions/web3/oneInchAPI.cjs +1 -1
  53. package/functions/web3/oneInchAPI.mjs +10 -7
  54. package/functions/web3/runContractFunction.cjs +1 -1
  55. package/functions/web3/runContractFunction.mjs +23 -20
  56. package/functions/web3/uniswapAPI.cjs +1 -1
  57. package/functions/web3/uniswapAPI.mjs +6 -3
  58. package/index.cjs +1 -1
  59. package/index.mjs +210 -209
  60. package/package.json +4 -3
  61. package/providers/prepareEthersHinkal.cjs +1 -1
  62. package/providers/prepareEthersHinkal.mjs +4 -5
  63. package/providers/prepareWagmiv1Hinkal.cjs +1 -1
  64. package/providers/prepareWagmiv1Hinkal.mjs +4 -5
  65. package/types/kyc.types.cjs +1 -1
  66. package/types/kyc.types.d.ts +3 -1
  67. package/types/kyc.types.mjs +3 -3
  68. package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
  69. package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
  70. package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
  71. package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
@@ -1,4 +1,4 @@
1
- import { getAmountAfterRelayAndFlatFees as I, getAmountAfterRelayAndFlatFeesAndSlippage as N, getAmountAfterSlippage as i } from "../../constants/fees.constants.mjs";
1
+ import { getAmountAfterRelayAndFlatFees as I, getAmountAfterRelayAndFlatFeesAndSlippage as N, getAmountAfterSlippage as L } from "../../constants/fees.constants.mjs";
2
2
  import { FeeOverTransactionValueError as S } from "../../error-handling/customErrors/FeeOverTransactionValueError.mjs";
3
3
  import { absBigInt as W } from "../utils/amounts.utils.mjs";
4
4
  import "ethers";
@@ -11,7 +11,10 @@ import { INTERACTION as c } from "../../types/hinkal.types.mjs";
11
11
  import { SlippageType as b } from "../../types/slippage.types.mjs";
12
12
  import "../../types/transactions.types.mjs";
13
13
  import "../../types/curve.types.mjs";
14
- import "circomlibjs";
14
+ import "circomlibjs-hinkal-fork";
15
+ import "libsodium-wrappers";
16
+ import "process";
17
+ import "buffer";
15
18
  import "../../constants/reorg-depths.constants.mjs";
16
19
  import { getInteractionFromAction as d } from "./interaction-to-action.mjs";
17
20
  const p = (D, r, E) => {
@@ -22,19 +25,19 @@ const p = (D, r, E) => {
22
25
  feeUnit: E
23
26
  });
24
27
  return r;
25
- }, Z = ({
28
+ }, l = ({
26
29
  erc20Addresses: D = [],
27
30
  amountChanges: r,
28
31
  flatFees: E,
29
32
  feeUnit: A,
30
33
  externalActionId: T,
31
- action: P,
34
+ action: i,
32
35
  gasTokenAddress: w
33
36
  }) => {
34
- const L = d(T, P);
35
- if (L === c.NONE)
37
+ const P = d(T, i);
38
+ if (P === c.NONE)
36
39
  throw Error("No interaction was choosen");
37
- switch (L) {
40
+ switch (P) {
38
41
  case c.WITHDRAW: {
39
42
  p(
40
43
  r[0],
@@ -66,7 +69,7 @@ const p = (D, r, E) => {
66
69
  r[_],
67
70
  N(r[_], k, b.CurveWithdraw),
68
71
  A
69
- ) : k === 0n && r[_] > 0n && _ !== E.length - 1 && (r[_] = i(r[_], b.CurveWithdraw));
72
+ ) : k === 0n && r[_] > 0n && _ !== E.length - 1 && (r[_] = L(r[_], b.CurveWithdraw));
70
73
  });
71
74
  break;
72
75
  case c.CURVE_WITHDRAW_INBALANCED:
@@ -93,7 +96,7 @@ const p = (D, r, E) => {
93
96
  );
94
97
  break;
95
98
  case c.BEEFY: {
96
- const k = R(P) ? 1 : 0;
99
+ const k = R(i) ? 1 : 0;
97
100
  r[k] = p(
98
101
  r[k],
99
102
  N(
@@ -210,5 +213,5 @@ const p = (D, r, E) => {
210
213
  return r;
211
214
  };
212
215
  export {
213
- Z as processAmountChanges
216
+ l as processAmountChanges
214
217
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("../../data-structures/crypto-keys/keys.cjs");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}function w(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const F=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},q=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=F;exports.determinePendleSwapTypeApiRoute=q;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=w;exports.getTokenIndexForPendleFlatFee=k;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("process");require("buffer");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}function w(e,r){if(!e||!r)return;let t;switch(r){case n.PendleAssetType.YT:t=e?.yt;break;case n.PendleAssetType.PT:t=e?.pt;break;case n.PendleAssetType.PENDLE_LP:t=e?.lp;break;case n.PendleAssetType.SY:t=e?.sy;break;default:t=void 0;break}return t}const q=(e,r,t)=>{if(i.caseInsensitiveEqual(e.yt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForYt;if(i.caseInsensitiveEqual(e.pt.address,t.erc20TokenAddress))return n.PendleSwapType.SwapExactTokenForPt;if(i.caseInsensitiveEqual(e.yt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactYtForToken;if(i.caseInsensitiveEqual(e.pt.address,r.erc20TokenAddress))return n.PendleSwapType.SwapExactPtForToken},F=e=>{let r;switch(e){case n.PendleSwapType.SwapExactTokenForYt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForYT;break;case n.PendleSwapType.SwapExactTokenForPt:r=o.API_CONFIG.ROUTES.pendleSwapExactTokenForPt;break;case n.PendleSwapType.SwapExactYtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactYtForToken;break;case n.PendleSwapType.SwapExactPtForToken:r=o.API_CONFIG.ROUTES.pendleSwapExactPtForToken;break;default:throw new Error("Cant determine Pendle Swap Type Api Route")}return r},k=(e,r,t,a)=>{if(!T.isInEnum(s.PendleAction,e))throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");if(a)return t.findIndex(d=>d.toLowerCase()===a?.toLowerCase());const l=r.findIndex(d=>d>0n),p=r.length-1;if(r[p]<=0n)throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");let u=l;return(e===s.PendleAction.Mint||e===s.PendleAction.Redeem||e===s.PendleAction.PoolRemove)&&(u=l),u};exports.determinePendleSwapType=q;exports.determinePendleSwapTypeApiRoute=F;exports.erc20TokenFromPendleAsset=P;exports.getAssetTypeFromPendleMarket=w;exports.getTokenIndexForPendleFlatFee=k;
@@ -14,25 +14,27 @@ import "../../types/transactions.types.mjs";
14
14
  import { PendleAssetType as d, PendleSwapType as o } from "../../types/pendle.types.mjs";
15
15
  import "../../types/curve.types.mjs";
16
16
  import "ethers";
17
- import "circomlibjs";
18
- import "../../data-structures/crypto-keys/keys.mjs";
17
+ import "circomlibjs-hinkal-fork";
18
+ import "libsodium-wrappers";
19
19
  import "idb-keyval";
20
20
  import "../utils/external-action.utils.mjs";
21
21
  import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
22
22
  import "../utils/convertIntegrationProviderToExternalActionId.mjs";
23
23
  import "axios";
24
+ import "process";
25
+ import "buffer";
24
26
  import "../utils/userAgent.mjs";
25
27
  import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
26
28
  import "../../data-structures/volatile-helper/VolatileHelper.mjs";
27
29
  import { isInEnum as k } from "../utils/enum.utils.mjs";
28
- function V(e) {
30
+ function z(e) {
29
31
  if (!e)
30
32
  return;
31
33
  const r = T(e.address, e.chainId);
32
34
  if (!r?.isVolatile)
33
35
  return r;
34
36
  }
35
- function j(e, r) {
37
+ function H(e, r) {
36
38
  if (!e || !r)
37
39
  return;
38
40
  let t;
@@ -55,7 +57,7 @@ function j(e, r) {
55
57
  }
56
58
  return t;
57
59
  }
58
- const z = (e, r, t) => {
60
+ const J = (e, r, t) => {
59
61
  if (i(e.yt.address, t.erc20TokenAddress))
60
62
  return o.SwapExactTokenForYt;
61
63
  if (i(e.pt.address, t.erc20TokenAddress))
@@ -64,7 +66,7 @@ const z = (e, r, t) => {
64
66
  return o.SwapExactYtForToken;
65
67
  if (i(e.pt.address, r.erc20TokenAddress))
66
68
  return o.SwapExactPtForToken;
67
- }, H = (e) => {
69
+ }, K = (e) => {
68
70
  let r;
69
71
  switch (e) {
70
72
  case o.SwapExactTokenForYt:
@@ -83,23 +85,23 @@ const z = (e, r, t) => {
83
85
  throw new Error("Cant determine Pendle Swap Type Api Route");
84
86
  }
85
87
  return r;
86
- }, J = (e, r, t, s) => {
88
+ }, Q = (e, r, t, s) => {
87
89
  if (!k(p, e))
88
90
  throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
89
91
  if (s)
90
92
  return t.findIndex(
91
93
  (a) => a.toLowerCase() === s?.toLowerCase()
92
94
  );
93
- const c = r.findIndex((a) => a > 0n), m = r.length - 1;
94
- if (r[m] <= 0n)
95
+ const c = r.findIndex((a) => a > 0n), l = r.length - 1;
96
+ if (r[l] <= 0n)
95
97
  throw new Error("getTokenIndexForPendleFlatFee: Last token in amountChange is not > 0");
96
- let l = c;
97
- return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (l = c), l;
98
+ let m = c;
99
+ return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (m = c), m;
98
100
  };
99
101
  export {
100
- z as determinePendleSwapType,
101
- H as determinePendleSwapTypeApiRoute,
102
- V as erc20TokenFromPendleAsset,
103
- j as getAssetTypeFromPendleMarket,
104
- J as getTokenIndexForPendleFlatFee
102
+ J as determinePendleSwapType,
103
+ K as determinePendleSwapTypeApiRoute,
104
+ z as erc20TokenFromPendleAsset,
105
+ H as getAssetTypeFromPendleMarket,
106
+ Q as getTokenIndexForPendleFlatFee
105
107
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),y=require("../../data-structures/crypto-keys/keys.cjs"),s=require("libsodium-wrappers"),c=require("../../crypto/poseidon.cjs");require("circomlibjs");const f=(e,t,r)=>{const n=o.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=s.crypto_box_seal(n,o.ethers.utils.arrayify(r));return`0x${Buffer.from(a).toString("hex")}`},p=(e,t)=>{const r=Buffer.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=y.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const i=s.crypto_box_seal_open(r,o.ethers.utils.arrayify(n),o.ethers.utils.arrayify(a)),d=Buffer.from(i).toString("utf-8"),[u,l]=o.ethers.utils.defaultAbiCoder.decode(["uint256","address"],d);return{stakeBlinding:u.toBigInt(),stakedTokenRecipient:l}}catch{console.log("failed to decrypt");return}},S=(e,t,r,n,a,i)=>BigInt(c.poseidonHash(...[e,t,r,n,a,i].map(BigInt))),k=(e,t)=>c.poseidonHash(e,t),g=(e,t,r,n,a)=>o.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=k;exports.createStakeCommitment=S;exports.decryptStake=p;exports.encodeHStakeMetadata=g;exports.encryptStake=f;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("ethers"),y=require("../../data-structures/crypto-keys/keys.cjs"),s=require("libsodium-wrappers"),c=require("../../crypto/poseidon.cjs");require("circomlibjs-hinkal-fork");require("process");require("buffer");const f=(e,t,r)=>{const n=i.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=s.crypto_box_seal(n,i.ethers.utils.arrayify(r));return`0x${Buffer.from(a).toString("hex")}`},p=(e,t)=>{const r=Buffer.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=y.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const o=s.crypto_box_seal_open(r,i.ethers.utils.arrayify(n),i.ethers.utils.arrayify(a)),d=Buffer.from(o).toString("utf-8"),[u,l]=i.ethers.utils.defaultAbiCoder.decode(["uint256","address"],d);return{stakeBlinding:u.toBigInt(),stakedTokenRecipient:l}}catch{console.log("failed to decrypt");return}},S=(e,t,r,n,a,o)=>BigInt(c.poseidonHash(...[e,t,r,n,a,o].map(BigInt))),k=(e,t)=>c.poseidonHash(e,t),g=(e,t,r,n,a)=>i.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=k;exports.createStakeCommitment=S;exports.decryptStake=p;exports.encodeHStakeMetadata=g;exports.encryptStake=f;
@@ -1,40 +1,42 @@
1
- import { ethers as i } from "ethers";
2
- import { UserKeys as f } from "../../data-structures/crypto-keys/keys.mjs";
1
+ import { ethers as n } from "ethers";
2
+ import { UserKeys as y } from "../../data-structures/crypto-keys/keys.mjs";
3
3
  import s from "libsodium-wrappers";
4
4
  import { poseidonHash as c } from "../../crypto/poseidon.mjs";
5
- import "circomlibjs";
6
- const S = (t, e, r) => {
7
- const o = i.utils.defaultAbiCoder.encode(
5
+ import "circomlibjs-hinkal-fork";
6
+ import "process";
7
+ import "buffer";
8
+ const B = (t, e, r) => {
9
+ const o = n.utils.defaultAbiCoder.encode(
8
10
  ["uint256", "address"],
9
11
  [t, e]
10
- ), n = s.crypto_box_seal(o, i.utils.arrayify(r));
11
- return `0x${Buffer.from(n).toString("hex")}`;
12
- }, k = (t, e) => {
13
- const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey: n } = f.getEncryptionKeyPair(e.getShieldedPrivateKey());
12
+ ), i = s.crypto_box_seal(o, n.utils.arrayify(r));
13
+ return `0x${Buffer.from(i).toString("hex")}`;
14
+ }, h = (t, e) => {
15
+ const r = Buffer.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } = y.getEncryptionKeyPair(e.getShieldedPrivateKey());
14
16
  try {
15
17
  const a = s.crypto_box_seal_open(
16
18
  r,
17
- i.utils.arrayify(o),
18
- i.utils.arrayify(n)
19
- ), d = Buffer.from(a).toString("utf-8"), [u, y] = i.utils.defaultAbiCoder.decode(
19
+ n.utils.arrayify(o),
20
+ n.utils.arrayify(i)
21
+ ), d = Buffer.from(a).toString("utf-8"), [u, p] = n.utils.defaultAbiCoder.decode(
20
22
  ["uint256", "address"],
21
23
  d
22
24
  );
23
- return { stakeBlinding: u.toBigInt(), stakedTokenRecipient: y };
25
+ return { stakeBlinding: u.toBigInt(), stakedTokenRecipient: p };
24
26
  } catch {
25
27
  console.log("failed to decrypt");
26
28
  return;
27
29
  }
28
- }, B = (t, e, r, o, n, a) => BigInt(
29
- c(...[t, e, r, o, n, a].map(BigInt))
30
- ), h = (t, e) => c(t, e), x = (t, e, r, o, n) => i.utils.defaultAbiCoder.encode(
30
+ }, x = (t, e, r, o, i, a) => BigInt(
31
+ c(...[t, e, r, o, i, a].map(BigInt))
32
+ ), K = (t, e) => c(t, e), _ = (t, e, r, o, i) => n.utils.defaultAbiCoder.encode(
31
33
  ["uint8", "uint256", "address", "bytes", "bytes"],
32
- [t, e, r, o, n]
34
+ [t, e, r, o, i]
33
35
  );
34
36
  export {
35
- h as calculateStakeNullifier,
36
- B as createStakeCommitment,
37
- k as decryptStake,
38
- x as encodeHStakeMetadata,
39
- S as encryptStake
37
+ K as calculateStakeNullifier,
38
+ x as createStakeCommitment,
39
+ h as decryptStake,
40
+ _ as encodeHStakeMetadata,
41
+ B as encryptStake
40
42
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=t=>t.reduce((e,n)=>e.then(()=>n()),Promise.resolve()),u=(t,e,n)=>{const r=[];if(n){let o=t;for(;o<=e;){const s=Math.min(o+n-1,e);r.push({from:o,to:s}),o=s+1}}else r.push({from:t,to:e});return r};exports.getSequence=u;exports.resolveSync=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=t=>t.reduce((e,o)=>e.then(()=>o()),Promise.resolve()),i=(t,e,o)=>{const r=[];if(o){let n=t;for(;n<=e;){const s=Math.min(n+o-1,e);r.push({from:n,to:s}),n=s+1}}else r.push({from:t,to:e});return r},u=(t,e=100)=>new Promise((o,r)=>{setTimeout(async()=>{try{await t(),o(0)}catch(n){r(n)}},e)});exports.getSequence=i;exports.promisify=u;exports.resolveSync=c;
@@ -3,3 +3,4 @@ export declare const getSequence: (fromBlockNumber: number, lastBlockNumber: num
3
3
  from: number;
4
4
  to: number;
5
5
  }[];
6
+ export declare const promisify: (callback: () => Promise<any>, timeout?: number) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), h = (t, e, n) => {
1
+ const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), i = (t, e, n) => {
2
2
  const s = [];
3
3
  if (n) {
4
4
  let o = t;
@@ -15,8 +15,17 @@ const c = (t) => t.reduce((e, n) => e.then(() => n()), Promise.resolve()), h = (
15
15
  to: e
16
16
  });
17
17
  return s;
18
- };
18
+ }, h = (t, e = 100) => new Promise((n, s) => {
19
+ setTimeout(async () => {
20
+ try {
21
+ await t(), n(0);
22
+ } catch (o) {
23
+ s(o);
24
+ }
25
+ }, e);
26
+ });
19
27
  export {
20
- h as getSequence,
28
+ i as getSequence,
29
+ h as promisify,
21
30
  c as resolveSync
22
31
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs");require("../../../data-structures/crypto-keys/keys.cjs");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const i=n.serializeCircomData(c),e=await o.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:i,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
@@ -1,8 +1,8 @@
1
1
  import { callRelayerTransactAPI as e } from "../../../API/callRelayer.mjs";
2
2
  import "../../../constants/chains.constants.mjs";
3
3
  import "ethers";
4
- import "circomlibjs";
5
- import "../../../data-structures/crypto-keys/keys.mjs";
4
+ import "circomlibjs-hinkal-fork";
5
+ import "libsodium-wrappers";
6
6
  import "../../../constants/vite.constants.mjs";
7
7
  import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
8
8
  import "../../../types/circom-data.types.mjs";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:c}=await i.callOdosAPI(r.getCurrentChainId(),t);if(c!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../API/callOdosAPI.cjs"),n=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const d=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const a=require("../../error-handling/error-codes.constants.cjs"),q=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const A=async(r,e,o,u)=>{try{const t={chainId:r.getCurrentChainId()!==31337?r.getCurrentChainId():n.localhostNetwork,inputTokens:[{tokenAddress:e?.wrappedErc20TokenAddress??e.erc20TokenAddress,amount:q.getAmountInWei(e,u).toString()}],outputTokens:[{tokenAddress:o?.wrappedErc20TokenAddress??o.erc20TokenAddress,proportion:1}],userAddr:n.networkRegistry[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress||d.zeroAddress,slippageLimitPercent:10,disableRFQs:!0},{odosResponse:s,status:i}=await c.callOdosAPI(r.getCurrentChainId(),t);if(i!=="success")throw Error("Odos API Fetch Error");return{outSwapAmountValue:BigInt(s.outputTokens[0].amount),odosDataValue:s.transaction.data}}catch(t){throw console.log({error:t}),Error(a.transactionErrorCodes.NO_ODOS_PRICE)}};exports.getOdosPrice=A;
@@ -1,9 +1,9 @@
1
- import { callOdosAPI as i } from "../../API/callOdosAPI.mjs";
2
- import { localhostNetwork as a, networkRegistry as p } from "../../constants/chains.constants.mjs";
1
+ import { callOdosAPI as d } from "../../API/callOdosAPI.mjs";
2
+ import { localhostNetwork as p, networkRegistry as m } from "../../constants/chains.constants.mjs";
3
3
  import "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
- import { zeroAddress as m } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as a } from "../../constants/protocol.constants.mjs";
7
7
  import "../../constants/coingecko.constants.mjs";
8
8
  import "../../constants/axelar.constants.mjs";
9
9
  import "../../constants/rewards.constants.mjs";
@@ -14,16 +14,19 @@ import "axios";
14
14
  import "../../types/circom-data.types.mjs";
15
15
  import "../../types/transactions.types.mjs";
16
16
  import "../../types/curve.types.mjs";
17
- import "circomlibjs";
18
17
  import "ethers";
19
- const N = async (r, t, e, n) => {
18
+ import "circomlibjs-hinkal-fork";
19
+ import "libsodium-wrappers";
20
+ import "process";
21
+ import "buffer";
22
+ const b = async (r, t, e, i) => {
20
23
  try {
21
24
  const o = {
22
- chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : a,
25
+ chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
23
26
  inputTokens: [
24
27
  {
25
28
  tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
26
- amount: u(t, n).toString()
29
+ amount: u(t, i).toString()
27
30
  }
28
31
  ],
29
32
  outputTokens: [
@@ -32,15 +35,15 @@ const N = async (r, t, e, n) => {
32
35
  proportion: 1
33
36
  }
34
37
  ],
35
- userAddr: p[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || m,
38
+ userAddr: m[r.getCurrentChainId()].contractData.odosExternalActionInstanceAddress || a,
36
39
  slippageLimitPercent: 10,
37
40
  disableRFQs: !0
38
41
  // sometimes swap fails because of RFQs
39
- }, { odosResponse: s, status: d } = await i(
42
+ }, { odosResponse: s, status: n } = await d(
40
43
  r.getCurrentChainId(),
41
44
  o
42
45
  );
43
- if (d !== "success")
46
+ if (n !== "success")
44
47
  throw Error("Odos API Fetch Error");
45
48
  return {
46
49
  outSwapAmountValue: BigInt(s.outputTokens[0].amount),
@@ -51,5 +54,5 @@ const N = async (r, t, e, n) => {
51
54
  }
52
55
  };
53
56
  export {
54
- N as getOdosPrice
57
+ b as getOdosPrice
55
58
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const d=require("../../error-handling/error-codes.constants.cjs"),u=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("ethers");const l=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:u.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(d.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=l;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../API/callOneInchAPI.cjs");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const e=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const u=require("../../error-handling/error-codes.constants.cjs"),d=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const a=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const q=async(s,t,n,c)=>{try{const o={fromTokenAddress:t.erc20TokenAddress!==e.zeroAddress?t.erc20TokenAddress:e.oneInchZeroAddress,toTokenAddress:n.erc20TokenAddress!==e.zeroAddress?n.erc20TokenAddress:e.oneInchZeroAddress,fromAddress:e.zeroAddress,destReceiver:s.getContractMetadata(a.ContractType.OneInchExternalActionContract).address,amount:d.getAmountInWei(t,c),slippage:10,disableEstimate:!0,allowPartialFill:!1},r=await i.callOneInchAPI(s.getCurrentChainId(),o);if(!r||!r.tx)throw Error("OneInch API price fetch error");return{outSwapAmountValue:BigInt(r.toAmount),oneInchDataValue:r.tx.data}}catch(o){throw console.log({error:o}),Error(u.transactionErrorCodes.NO_ONEINCH_PRICE)}};exports.getOneInchPrice=q;
@@ -3,7 +3,7 @@ import "../../constants/chains.constants.mjs";
3
3
  import "../../constants/vite.constants.mjs";
4
4
  import "../../constants/contracts.constants.mjs";
5
5
  import "../../constants/kyc.constants.mjs";
6
- import { zeroAddress as e, oneInchZeroAddress as i } from "../../constants/protocol.constants.mjs";
6
+ import { zeroAddress as e, oneInchZeroAddress as m } from "../../constants/protocol.constants.mjs";
7
7
  import "../../constants/coingecko.constants.mjs";
8
8
  import "../../constants/axelar.constants.mjs";
9
9
  import "../../constants/rewards.constants.mjs";
@@ -15,17 +15,20 @@ import "../../types/circom-data.types.mjs";
15
15
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
16
16
  import "../../types/transactions.types.mjs";
17
17
  import "../../types/curve.types.mjs";
18
- import "circomlibjs";
19
18
  import "ethers";
20
- const _ = async (s, t, n, m) => {
19
+ import "circomlibjs-hinkal-fork";
20
+ import "libsodium-wrappers";
21
+ import "process";
22
+ import "buffer";
23
+ const v = async (s, t, i, n) => {
21
24
  try {
22
25
  const o = {
23
- fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : i,
24
- toTokenAddress: n.erc20TokenAddress !== e ? n.erc20TokenAddress : i,
26
+ fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : m,
27
+ toTokenAddress: i.erc20TokenAddress !== e ? i.erc20TokenAddress : m,
25
28
  fromAddress: e,
26
29
  // we user zero address here because this paramater is not relevant to us, only destReceiver is
27
30
  destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
28
- amount: d(t, m),
31
+ amount: d(t, n),
29
32
  slippage: 10,
30
33
  disableEstimate: !0,
31
34
  // disable gas estimation, we don't need it
@@ -47,5 +50,5 @@ const _ = async (s, t, n, m) => {
47
50
  }
48
51
  };
49
52
  export {
50
- _ as getOneInchPrice
53
+ v as getOneInchPrice
51
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const m=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const l=5e4,d=1,w=11,P=15,g=async(t,s)=>{try{const r=await t.getFeeData(),a=s===0?w:P;return r.gasPrice?.mul(a).div(10)??void 0}catch(r){console.log("getGasPrice error: ",{err:r});return}},q=(t,s,r)=>new Promise((a,o)=>{const n=setTimeout(()=>{o(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);t.wait(s).then(e=>{clearTimeout(n),a(e)}).catch(e=>{clearTimeout(n),o(e)})}),T=async({contractFunction:t,args:s,gasPrice:r,gasLimit:a,nonce:o,confirmations:n,waitTime:e})=>{const i=await t(...s,{type:0,gasLimit:a,gasPrice:r,nonce:o});return await q(i,n??d,e??l)},E=async({provider:t,contractFunction:s,args:r,gasLimit:a,nonce:o,confirmations:n})=>{try{const e=await g(t,0);return await T({contractFunction:s,args:r,gasPrice:e,gasLimit:a,nonce:o,confirmations:n})}catch(e){const i=m.getErrorMessage(e);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(t,1);return await T({contractFunction:s,args:r,gasPrice:u,gasLimit:a,nonce:o,confirmations:n})}throw e}};exports.runContractFunction=E;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../error-handling/error-codes.constants.cjs");require("ethers");const m=require("../../error-handling/get-error.message.cjs");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const l=5e4,q=1,d=11,w=15,g=async(t,s)=>{try{const r=await t.getFeeData(),a=s===0?d:w;return r.gasPrice?.mul(a).div(10)??void 0}catch(r){console.log("getGasPrice error: ",{err:r});return}},P=(t,s,r)=>new Promise((a,o)=>{const n=setTimeout(()=>{o(new Error(c.transactionErrorCodes.TRANSACTION_TIMEOUT))},r);t.wait(s).then(e=>{clearTimeout(n),a(e)}).catch(e=>{clearTimeout(n),o(e)})}),T=async({contractFunction:t,args:s,gasPrice:r,gasLimit:a,nonce:o,confirmations:n,waitTime:e})=>{const i=await t(...s,{type:0,gasLimit:a,gasPrice:r,nonce:o});return await P(i,n??q,e??l)},E=async({provider:t,contractFunction:s,args:r,gasLimit:a,nonce:o,confirmations:n})=>{try{const e=await g(t,0);return await T({contractFunction:s,args:r,gasPrice:e,gasLimit:a,nonce:o,confirmations:n})}catch(e){const i=m.getErrorMessage(e);if(i===c.UserFriendlyErrorCodes.MAX_FEE_GAS_ERROR||i===c.transactionErrorCodes.TRANSACTION_TIMEOUT){console.log("Timeout Hit: Increase gas");const u=await g(t,1);return await T({contractFunction:s,args:r,gasPrice:u,gasLimit:a,nonce:o,confirmations:n})}throw e}};exports.runContractFunction=E;
@@ -1,13 +1,16 @@
1
- import { UserFriendlyErrorCodes as g, transactionErrorCodes as T } from "../../error-handling/error-codes.constants.mjs";
1
+ import { UserFriendlyErrorCodes as T, transactionErrorCodes as p } from "../../error-handling/error-codes.constants.mjs";
2
2
  import "ethers";
3
- import { getErrorMessage as p } from "../../error-handling/get-error.message.mjs";
3
+ import { getErrorMessage as g } from "../../error-handling/get-error.message.mjs";
4
4
  import "axios";
5
5
  import "../../constants/chains.constants.mjs";
6
6
  import "../../constants/vite.constants.mjs";
7
7
  import "../../types/circom-data.types.mjs";
8
8
  import "../../types/transactions.types.mjs";
9
9
  import "../../types/curve.types.mjs";
10
- import "circomlibjs";
10
+ import "circomlibjs-hinkal-fork";
11
+ import "libsodium-wrappers";
12
+ import "process";
13
+ import "buffer";
11
14
  import "../../constants/reorg-depths.constants.mjs";
12
15
  const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
13
16
  try {
@@ -17,42 +20,42 @@ const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
17
20
  console.log("getGasPrice error: ", { err: t });
18
21
  return;
19
22
  }
20
- }, E = (o, e, t) => new Promise((a, s) => {
21
- const i = setTimeout(() => {
22
- s(new Error(T.TRANSACTION_TIMEOUT));
23
+ }, E = (o, e, t) => new Promise((a, i) => {
24
+ const s = setTimeout(() => {
25
+ i(new Error(p.TRANSACTION_TIMEOUT));
23
26
  }, t);
24
27
  o.wait(e).then((r) => {
25
- clearTimeout(i), a(r);
28
+ clearTimeout(s), a(r);
26
29
  }).catch((r) => {
27
- clearTimeout(i), s(r);
30
+ clearTimeout(s), i(r);
28
31
  });
29
32
  }), u = async ({
30
33
  contractFunction: o,
31
34
  args: e,
32
35
  gasPrice: t,
33
36
  gasLimit: a,
34
- nonce: s,
35
- confirmations: i,
37
+ nonce: i,
38
+ confirmations: s,
36
39
  waitTime: r
37
40
  }) => {
38
41
  const n = await o(...e, {
39
42
  type: 0,
40
43
  gasLimit: a,
41
44
  gasPrice: t,
42
- nonce: s
45
+ nonce: i
43
46
  });
44
47
  return await E(
45
48
  n,
46
- i ?? l,
49
+ s ?? l,
47
50
  r ?? w
48
51
  );
49
- }, N = async ({
52
+ }, U = async ({
50
53
  provider: o,
51
54
  contractFunction: e,
52
55
  args: t,
53
56
  gasLimit: a,
54
- nonce: s,
55
- confirmations: i
57
+ nonce: i,
58
+ confirmations: s
56
59
  }) => {
57
60
  try {
58
61
  const r = await m(
@@ -60,21 +63,21 @@ const w = 5e4, l = 1, P = 11, d = 15, m = async (o, e) => {
60
63
  0
61
64
  /* Initial */
62
65
  );
63
- return await u({ contractFunction: e, args: t, gasPrice: r, gasLimit: a, nonce: s, confirmations: i });
66
+ return await u({ contractFunction: e, args: t, gasPrice: r, gasLimit: a, nonce: i, confirmations: s });
64
67
  } catch (r) {
65
- const n = p(r);
66
- if (n === g.MAX_FEE_GAS_ERROR || n === T.TRANSACTION_TIMEOUT) {
68
+ const n = g(r);
69
+ if (n === T.MAX_FEE_GAS_ERROR || n === p.TRANSACTION_TIMEOUT) {
67
70
  console.log("Timeout Hit: Increase gas");
68
71
  const c = await m(
69
72
  o,
70
73
  1
71
74
  /* Secondary */
72
75
  );
73
- return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: a, nonce: s, confirmations: i });
76
+ return await u({ contractFunction: e, args: t, gasPrice: c, gasLimit: a, nonce: i, confirmations: s });
74
77
  }
75
78
  throw r;
76
79
  }
77
80
  };
78
81
  export {
79
- N as runContractFunction
82
+ U as runContractFunction
80
83
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");const h=require("../../error-handling/logError.cjs"),w=async(t,s,r,o)=>{const c=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await s.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(c.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},g=async(t,s,r,o,c)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:s.wrappedErc20TokenAddress??s.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:c,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(n){throw h.logError(n),n}},A=async(t,s,r)=>{try{const o=t.getCurrentChainId(),c=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),n=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,c,s.wrappedErc20TokenAddress??s.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,s,r,o)=>{try{const c=await A(t,r,o),n=q.utils.defaultAbiCoder.encode(["uint24"],[c]),a=y.getAmountInWei(r,s);return{tokenPrice:await g(t,r,o,c,a),poolFee:n}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=A;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=g;exports.searchPoolAndFee=w;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs-hinkal-fork");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../error-handling/logError.cjs"),w=async(t,s,r,o)=>{const c=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await s.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),n=await Promise.all(c.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=n.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return n.find(e=>e.token1Balance===i)},q=async(t,s,r,o,c)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:s.wrappedErc20TokenAddress??s.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:c,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(n){throw h.logError(n),n}},g=async(t,s,r)=>{try{const o=t.getCurrentChainId(),c=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),n=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(n,c,s.wrappedErc20TokenAddress??s.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,s,r,o)=>{try{const c=await g(t,r,o),n=A.utils.defaultAbiCoder.encode(["uint24"],[c]),a=y.getAmountInWei(r,s);return{tokenPrice:await q(t,r,o,c,a),poolFee:n}}catch{throw Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=g;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=q;exports.searchPoolAndFee=w;
@@ -15,7 +15,10 @@ import "../../types/circom-data.types.mjs";
15
15
  import { ContractType as p } from "../../types/ethereum-network.types.mjs";
16
16
  import "../../types/transactions.types.mjs";
17
17
  import "../../types/curve.types.mjs";
18
- import "circomlibjs";
18
+ import "circomlibjs-hinkal-fork";
19
+ import "libsodium-wrappers";
20
+ import "process";
21
+ import "buffer";
19
22
  import { logError as C } from "../../error-handling/logError.mjs";
20
23
  const f = async (e, s, t, o) => {
21
24
  const c = (await Promise.all(
@@ -68,7 +71,7 @@ const f = async (e, s, t, o) => {
68
71
  } catch (o) {
69
72
  throw console.log("Error in getUniswapFee", o), o;
70
73
  }
71
- }, L = async (e, s, t, o) => {
74
+ }, D = async (e, s, t, o) => {
72
75
  try {
73
76
  const c = await I(e, t, o), n = w.defaultAbiCoder.encode(["uint24"], [c]), a = l(t, s);
74
77
  return { tokenPrice: await g(e, t, o, c, a), poolFee: n };
@@ -78,7 +81,7 @@ const f = async (e, s, t, o) => {
78
81
  };
79
82
  export {
80
83
  I as getUniswapFee,
81
- L as getUniswapPrice,
84
+ D as getUniswapPrice,
82
85
  g as getUniswapPriceHelper,
83
86
  f as searchPoolAndFee
84
87
  };