@hinkal/common 0.1.33 → 0.1.35
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/constants/chains.constants.cjs +1 -1
- package/constants/chains.constants.mjs +29 -29
- package/constants/fees.constants.cjs +1 -1
- package/constants/fees.constants.mjs +22 -22
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +1 -0
- package/data-structures/Hinkal/Hinkal.mjs +13 -10
- package/data-structures/Hinkal/IHinkal.d.ts +2 -1
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +48 -52
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -16
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +66 -74
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
- package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
- package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +42 -42
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +27 -27
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +27 -30
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +25 -25
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +37 -37
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +28 -28
- package/package.json +1 -1
- package/types/relayer.types.d.ts +22 -0
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./deploy-data/deploy-data-bnbMainnet.json.cjs"),l=require("./deploy-data/deploy-data-arbMainnet.json.cjs"),d=require("./deploy-data/deploy-data-ethMainnet.json.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./deploy-data/deploy-data-bnbMainnet.json.cjs"),l=require("./deploy-data/deploy-data-arbMainnet.json.cjs"),d=require("./deploy-data/deploy-data-ethMainnet.json.cjs"),h=require("./deploy-data/deploy-data-optimism.json.cjs"),u=require("./deploy-data/deploy-data-polygon.json.cjs"),m=require("./deploy-data/deploy-data-avalanche.json.cjs"),b=require("./deploy-data/deploy-data-base.json.cjs"),F=require("./deploy-data/deploy-data-localhost.json.cjs"),y=require("./deploy-data/deploy-data-axelar1.json.cjs"),g=require("./deploy-data/deploy-data-axelar2.json.cjs"),s=require("./vite.constants.cjs"),e={polygon:137,arbMainnet:42161,ethMainnet:1,avalanche:43114,bnbMainnet:56,optimism:10,base:8453,bnbTestnet:97,polygonMumbai:80001,mainnetSepolia:11155111,optimismSepolia:11155420,axelar1:2500,axelar2:2501,localhost:31337,hardhat:31337},n=e.ethMainnet,r=t=>!![e.axelar1,e.axelar2,e.localhost].includes(t),f=t=>t?r(t)?n:t:n,a={[e.ethMainnet]:{name:"Ethereum",chainId:e.ethMainnet,rpcUrl:"https://rpc.ankr.com/eth",fetchRpcUrl:"https://eth-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:d.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",accessTokenMintingFee:"0",priority:1,privateMempoolRpcUrl:"https://relay.flashbots.net"},[e.arbMainnet]:{name:"Arbitrum",chainId:e.arbMainnet,rpcUrl:"https://endpoints.omniatech.io/v1/arbitrum/one/public",fetchRpcUrl:"https://arb-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:l.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",accessTokenMintingFee:"0",priority:2},[e.optimism]:{name:"Optimism",chainId:e.optimism,rpcUrl:"https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903",fetchRpcUrl:"https://opt-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:h.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",accessTokenMintingFee:"0",priority:3},[e.polygon]:{name:"Polygon",chainId:e.polygon,rpcUrl:"https://polygon-rpc.com",fetchRpcUrl:"https://polygon-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:u.default,quoterV2Address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",uniswapV3FactoryAddress:"0x1F98431c8aD98523631AE4a59f267346ea31F984",accessTokenMintingFee:"0",priority:4},[e.avalanche]:{name:"Avalanche",chainId:e.avalanche,rpcUrl:"https://api.avax.network/ext/bc/C/rpc",fetchRpcUrl:"https://avax-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:m.default,quoterV2Address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",uniswapV3FactoryAddress:"0x740b1c1de25031C31FF4fC9A62f554A55cdC1baD",accessTokenMintingFee:"0",priority:5},[e.bnbMainnet]:{name:"BNB Chain",chainId:e.bnbMainnet,rpcUrl:"https://bsc-dataseed.binance.org",maxPageSize:1e3,fetchRpcUrl:"https://rpc.ankr.com/bsc/e2873adb3a38b045946aab68a342686642e27f1c4740d820075d438ad512f7ac",supported:!0,contractData:p.default,quoterV2Address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",uniswapV3FactoryAddress:"0xdB1d10011AD0Ff90774D0C6Bb92e5C5c8b4461F7",accessTokenMintingFee:"0",priority:6},[e.base]:{name:"Base",chainId:e.base,rpcUrl:"https://mainnet.base.org/",fetchRpcUrl:"https://base-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",supported:!0,contractData:b.default,quoterV2Address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",uniswapV3FactoryAddress:"0x33128a8fC17869897dcE68Ed026d694621f6FDfD",accessTokenMintingFee:"0",priority:7},...s.isDevelopment?{}:{}},A={name:"Localhost",chainId:e.localhost,rpcUrl:"http://localhost:8545",fetchRpcUrl:"http://localhost:8545",supported:!0,contractData:F.default,quoterV2Address:a[n].quoterV2Address,uniswapV3FactoryAddress:a[n].uniswapV3FactoryAddress,accessTokenMintingFee:a[n].accessTokenMintingFee,priority:7},k={name:"axelar1",chainId:e.axelar1,rpcUrl:"http://localhost:8600/0",fetchRpcUrl:"http://localhost:8600/0",supported:!0,contractData:y.default,quoterV2Address:a[n].quoterV2Address,uniswapV3FactoryAddress:a[n].uniswapV3FactoryAddress,accessTokenMintingFee:a[n].accessTokenMintingFee,priority:8},D={name:"axelar2",chainId:e.axelar2,rpcUrl:"http://localhost:8600/1",fetchRpcUrl:"http://localhost:8600/1",supported:!0,contractData:g.default,quoterV2Address:a[n].quoterV2Address,uniswapV3FactoryAddress:a[n].uniswapV3FactoryAddress,accessTokenMintingFee:a[n].accessTokenMintingFee,priority:9};s.isDevelopment&&(a[e.localhost]=A,a[e.axelar1]=k,a[e.axelar2]=D);const M=[e.ethMainnet,e.arbMainnet,e.avalanche,e.bnbMainnet,e.polygon,e.optimism,e.base];var o=(t=>(t.Mainnet="Mainnet",t.Testnet="Testnet",t.Local="Local",t))(o||{});const U={Mainnet:[e.polygon,e.arbMainnet,e.ethMainnet,e.bnbMainnet,e.optimism,e.avalanche,e.base],Testnet:[e.bnbTestnet,e.polygonMumbai],Local:[e.localhost,e.axelar1,e.axelar2]},c=t=>[e.optimism,e.base].includes(t),i=t=>!1,x=t=>c(t)||i();exports.EthereumNetworkType=o;exports.chainIds=e;exports.chainIdsByType=U;exports.crossChainAccessTokenNetworks=M;exports.getNonLocalhostChainId=f;exports.isLocalNetwork=r;exports.isOptimismBedrockLike=i;exports.isOptimismEcotoneLike=c;exports.isOptimismLike=x;exports.localhostNetwork=n;exports.networkRegistry=a;
|
|
@@ -4,10 +4,10 @@ import c from "./deploy-data/deploy-data-ethMainnet.json.mjs";
|
|
|
4
4
|
import i from "./deploy-data/deploy-data-optimism.json.mjs";
|
|
5
5
|
import p from "./deploy-data/deploy-data-polygon.json.mjs";
|
|
6
6
|
import l from "./deploy-data/deploy-data-avalanche.json.mjs";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
7
|
+
import d from "./deploy-data/deploy-data-base.json.mjs";
|
|
8
|
+
import m from "./deploy-data/deploy-data-localhost.json.mjs";
|
|
9
|
+
import h from "./deploy-data/deploy-data-axelar1.json.mjs";
|
|
10
|
+
import b from "./deploy-data/deploy-data-axelar2.json.mjs";
|
|
11
11
|
import { isDevelopment as r } from "./vite.constants.mjs";
|
|
12
12
|
const a = {
|
|
13
13
|
polygon: 137,
|
|
@@ -25,12 +25,12 @@ const a = {
|
|
|
25
25
|
axelar2: 2501,
|
|
26
26
|
localhost: 31337,
|
|
27
27
|
hardhat: 31337
|
|
28
|
-
}, n = a.ethMainnet,
|
|
28
|
+
}, n = a.ethMainnet, F = (t) => !![a.axelar1, a.axelar2, a.localhost].includes(t), q = (t) => t ? F(t) ? n : t : n, e = {
|
|
29
29
|
[a.ethMainnet]: {
|
|
30
30
|
name: "Ethereum",
|
|
31
31
|
chainId: a.ethMainnet,
|
|
32
32
|
rpcUrl: "https://rpc.ankr.com/eth",
|
|
33
|
-
fetchRpcUrl: "https://mainnet.
|
|
33
|
+
fetchRpcUrl: "https://eth-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
34
34
|
supported: !0,
|
|
35
35
|
contractData: c,
|
|
36
36
|
quoterV2Address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
@@ -43,7 +43,7 @@ const a = {
|
|
|
43
43
|
name: "Arbitrum",
|
|
44
44
|
chainId: a.arbMainnet,
|
|
45
45
|
rpcUrl: "https://endpoints.omniatech.io/v1/arbitrum/one/public",
|
|
46
|
-
fetchRpcUrl: "https://
|
|
46
|
+
fetchRpcUrl: "https://arb-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
47
47
|
supported: !0,
|
|
48
48
|
contractData: s,
|
|
49
49
|
quoterV2Address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
@@ -55,7 +55,7 @@ const a = {
|
|
|
55
55
|
name: "Optimism",
|
|
56
56
|
chainId: a.optimism,
|
|
57
57
|
rpcUrl: "https://optimism-mainnet.infura.io/v3/c26b99456bb6464bb498926ff5162903",
|
|
58
|
-
fetchRpcUrl: "https://
|
|
58
|
+
fetchRpcUrl: "https://opt-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
59
59
|
supported: !0,
|
|
60
60
|
contractData: i,
|
|
61
61
|
quoterV2Address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
@@ -67,7 +67,7 @@ const a = {
|
|
|
67
67
|
name: "Polygon",
|
|
68
68
|
chainId: a.polygon,
|
|
69
69
|
rpcUrl: "https://polygon-rpc.com",
|
|
70
|
-
fetchRpcUrl: "https://polygon-mainnet.
|
|
70
|
+
fetchRpcUrl: "https://polygon-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
71
71
|
supported: !0,
|
|
72
72
|
contractData: p,
|
|
73
73
|
quoterV2Address: "0x61fFE014bA17989E743c5F6cB21bF9697530B21e",
|
|
@@ -79,7 +79,7 @@ const a = {
|
|
|
79
79
|
name: "Avalanche",
|
|
80
80
|
chainId: a.avalanche,
|
|
81
81
|
rpcUrl: "https://api.avax.network/ext/bc/C/rpc",
|
|
82
|
-
fetchRpcUrl: "https://
|
|
82
|
+
fetchRpcUrl: "https://avax-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
83
83
|
supported: !0,
|
|
84
84
|
contractData: l,
|
|
85
85
|
quoterV2Address: "0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",
|
|
@@ -105,9 +105,9 @@ const a = {
|
|
|
105
105
|
chainId: a.base,
|
|
106
106
|
rpcUrl: "https://mainnet.base.org/",
|
|
107
107
|
// maxPageSize: 1000,
|
|
108
|
-
fetchRpcUrl: "https://base-mainnet.
|
|
108
|
+
fetchRpcUrl: "https://base-mainnet.g.alchemy.com/v2/XzUgeU8YiIIzkD7j2GWnTsFUck7wGgK9",
|
|
109
109
|
supported: !0,
|
|
110
|
-
contractData:
|
|
110
|
+
contractData: d,
|
|
111
111
|
quoterV2Address: "0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",
|
|
112
112
|
uniswapV3FactoryAddress: "0x33128a8fC17869897dcE68Ed026d694621f6FDfD",
|
|
113
113
|
accessTokenMintingFee: "0",
|
|
@@ -120,36 +120,36 @@ const a = {
|
|
|
120
120
|
rpcUrl: "http://localhost:8545",
|
|
121
121
|
fetchRpcUrl: "http://localhost:8545",
|
|
122
122
|
supported: !0,
|
|
123
|
-
contractData:
|
|
123
|
+
contractData: m,
|
|
124
124
|
quoterV2Address: e[n].quoterV2Address,
|
|
125
125
|
uniswapV3FactoryAddress: e[n].uniswapV3FactoryAddress,
|
|
126
126
|
accessTokenMintingFee: e[n].accessTokenMintingFee,
|
|
127
127
|
priority: 7
|
|
128
|
-
},
|
|
128
|
+
}, f = {
|
|
129
129
|
name: "axelar1",
|
|
130
130
|
chainId: a.axelar1,
|
|
131
131
|
rpcUrl: "http://localhost:8600/0",
|
|
132
132
|
fetchRpcUrl: "http://localhost:8600/0",
|
|
133
133
|
supported: !0,
|
|
134
|
-
contractData:
|
|
134
|
+
contractData: h,
|
|
135
135
|
quoterV2Address: e[n].quoterV2Address,
|
|
136
136
|
uniswapV3FactoryAddress: e[n].uniswapV3FactoryAddress,
|
|
137
137
|
accessTokenMintingFee: e[n].accessTokenMintingFee,
|
|
138
138
|
priority: 8
|
|
139
|
-
},
|
|
139
|
+
}, g = {
|
|
140
140
|
name: "axelar2",
|
|
141
141
|
chainId: a.axelar2,
|
|
142
142
|
rpcUrl: "http://localhost:8600/1",
|
|
143
143
|
fetchRpcUrl: "http://localhost:8600/1",
|
|
144
144
|
supported: !0,
|
|
145
|
-
contractData:
|
|
145
|
+
contractData: b,
|
|
146
146
|
quoterV2Address: e[n].quoterV2Address,
|
|
147
147
|
uniswapV3FactoryAddress: e[n].uniswapV3FactoryAddress,
|
|
148
148
|
accessTokenMintingFee: e[n].accessTokenMintingFee,
|
|
149
149
|
priority: 9
|
|
150
150
|
};
|
|
151
|
-
r && (e[a.localhost] = u, e[a.axelar1] =
|
|
152
|
-
const
|
|
151
|
+
r && (e[a.localhost] = u, e[a.axelar1] = f, e[a.axelar2] = g);
|
|
152
|
+
const z = [
|
|
153
153
|
a.ethMainnet,
|
|
154
154
|
a.arbMainnet,
|
|
155
155
|
a.avalanche,
|
|
@@ -158,8 +158,8 @@ const I = [
|
|
|
158
158
|
a.optimism,
|
|
159
159
|
a.base
|
|
160
160
|
];
|
|
161
|
-
var
|
|
162
|
-
const
|
|
161
|
+
var y = /* @__PURE__ */ ((t) => (t.Mainnet = "Mainnet", t.Testnet = "Testnet", t.Local = "Local", t))(y || {});
|
|
162
|
+
const C = {
|
|
163
163
|
Mainnet: [
|
|
164
164
|
a.polygon,
|
|
165
165
|
a.arbMainnet,
|
|
@@ -171,17 +171,17 @@ const R = {
|
|
|
171
171
|
],
|
|
172
172
|
Testnet: [a.bnbTestnet, a.polygonMumbai],
|
|
173
173
|
Local: [a.localhost, a.axelar1, a.axelar2]
|
|
174
|
-
},
|
|
174
|
+
}, A = (t) => [a.optimism, a.base].includes(t), D = (t) => !1, G = (t) => A(t) || D();
|
|
175
175
|
export {
|
|
176
|
-
|
|
176
|
+
y as EthereumNetworkType,
|
|
177
177
|
a as chainIds,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
C as chainIdsByType,
|
|
179
|
+
z as crossChainAccessTokenNetworks,
|
|
180
|
+
q as getNonLocalhostChainId,
|
|
181
|
+
F as isLocalNetwork,
|
|
182
182
|
D as isOptimismBedrockLike,
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
A as isOptimismEcotoneLike,
|
|
184
|
+
G as isOptimismLike,
|
|
185
185
|
n as localhostNetwork,
|
|
186
186
|
e as networkRegistry
|
|
187
187
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../functions/utils/amounts.utils.cjs"),I=require("../types/slippage.types.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../functions/utils/amounts.utils.cjs"),I=require("../types/slippage.types.cjs"),g=require("./vite.constants.cjs"),i=(g.isDevelopment,8n),r=(g.isDevelopment,3n),l=e=>e?i:r,u=(e,n=!1)=>{const t=a.absBigInt(e);return l(n)*t/10000n},p=(e,n)=>{const t=a.absBigInt(e),s=I.slippageLevels[n];return BigInt(Math.round(s*100))*t/10000n},c=(e,n=!1)=>{const t=a.absBigInt(e),s=u(t,n);return t-s},b=(e,n=!1)=>a.absBigInt(e)*10000n/(10000n-l(n)),F=(e,n,t=!1)=>{const s=a.absBigInt(e),o=a.absBigInt(n);return c(s,t)-o},m=(e,n)=>{const t=a.absBigInt(e),s=p(t,n);return t-s},R=(e,n,t,s=!1)=>{const o=a.absBigInt(e),A=a.absBigInt(n),f=m(o,t);return F(f,A,s)};exports.HINKAL_EXTERNAL_ACTION_FEE=r;exports.HINKAL_UNIVERSAL_FEE=i;exports.getAmountAfterRelayAndFlatFees=F;exports.getAmountAfterRelayAndFlatFeesAndSlippage=R;exports.getAmountAfterRelayFee=c;exports.getAmountAfterSlippage=m;exports.getAmountWithoutFee=b;exports.getHinkalFeeRateInBeeps=l;exports.getRelayFee=u;exports.getSlippageFee=p;
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { absBigInt as
|
|
2
|
-
import { slippageLevels as
|
|
3
|
-
import { isDevelopment as
|
|
4
|
-
const
|
|
5
|
-
const t =
|
|
1
|
+
import { absBigInt as o } from "../functions/utils/amounts.utils.mjs";
|
|
2
|
+
import { slippageLevels as c } from "../types/slippage.types.mjs";
|
|
3
|
+
import { isDevelopment as l } from "./vite.constants.mjs";
|
|
4
|
+
const u = 8n, m = 3n, p = (e) => e ? u : m, f = (e, n = !1) => {
|
|
5
|
+
const t = o(e);
|
|
6
6
|
return p(n) * t / 10000n;
|
|
7
|
-
},
|
|
8
|
-
const t =
|
|
9
|
-
return BigInt(Math.round(
|
|
7
|
+
}, g = (e, n) => {
|
|
8
|
+
const t = o(e), s = c[n];
|
|
9
|
+
return BigInt(Math.round(s * 100)) * t / 10000n;
|
|
10
10
|
}, i = (e, n = !1) => {
|
|
11
|
-
const t =
|
|
12
|
-
return t -
|
|
13
|
-
}, E = (e, n = !1) =>
|
|
14
|
-
const
|
|
15
|
-
return
|
|
11
|
+
const t = o(e), s = f(t, n);
|
|
12
|
+
return t - s;
|
|
13
|
+
}, E = (e, n = !1) => o(e) * 10000n / (10000n - p(n)), F = (e, n, t = !1) => {
|
|
14
|
+
const s = o(e), a = o(n);
|
|
15
|
+
return i(s, t) - a;
|
|
16
16
|
}, b = (e, n) => {
|
|
17
|
-
const t =
|
|
18
|
-
return t -
|
|
19
|
-
}, y = (e, n, t,
|
|
20
|
-
const a =
|
|
21
|
-
return F(
|
|
17
|
+
const t = o(e), s = g(t, n);
|
|
18
|
+
return t - s;
|
|
19
|
+
}, y = (e, n, t, s = !1) => {
|
|
20
|
+
const a = o(e), r = o(n), A = b(a, t);
|
|
21
|
+
return F(A, r, s);
|
|
22
22
|
};
|
|
23
23
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
m as HINKAL_EXTERNAL_ACTION_FEE,
|
|
25
|
+
u as HINKAL_UNIVERSAL_FEE,
|
|
26
26
|
F as getAmountAfterRelayAndFlatFees,
|
|
27
27
|
y as getAmountAfterRelayAndFlatFeesAndSlippage,
|
|
28
28
|
i as getAmountAfterRelayFee,
|
|
29
29
|
b as getAmountAfterSlippage,
|
|
30
30
|
E as getAmountWithoutFee,
|
|
31
31
|
p as getHinkalFeeRateInBeeps,
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
f as getRelayFee,
|
|
33
|
+
g as getSlippageFee
|
|
34
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),A=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),y=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),m=require("./hinkalSwap.cjs"),T=require("./hinkalWithdraw.cjs"),S=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("circomlibjs");const q=require("../../constants/chains.constants.cjs"),g=require("../../error-handling/error-codes.constants.cjs"),f=require("../../API/callMonitor.cjs"),E=require("./hinkalActionLidoEth.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const F=require("../../API/getAxelarGasEstimate.cjs"),p=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");require("../../constants/contracts.constants.cjs");const H=require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const I=require("../transactions-manager/TransactionsManager.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");const M=require("../../functions/utils/reloadPage.cjs"),R=require("./hinkalActionVolatile.cjs"),k=require("./hinkalActionPendleLP.cjs"),L=require("../../API/getConnextReceiveFee.cjs"),W=require("./hinkalActionStake.cjs"),K=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),N=require("./hinkalPrivateWallet.cjs");class x{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;transactionsManager;utxoUtils=K.multiThreadedUtxoUtils;constructor(){this.userKeys=new o.UserKeys(void 0),this.merkleTreeHinkal=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.merkleTreeAccessToken=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.transactionsManager=new I.TransactionsManager}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(){this.userKeys=new o.UserKeys(await this.getProviderAdapter().signMessage(this.signingMessage))}async initUserKeysWithPassword(e){this.userKeys=new o.UserKeys(e)}async resetMerkle(){this.isSelectedNetworkSupported()&&await S.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!q.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(g.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=c.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=c.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),M.reloadPage()}async monitorConnectedAddress(){f.monitor(await this.getEthereumAddress(),this.getCurrentChainId())}async getBalances(){return A.getShieldedBalance(this)}getSupportedPassportLinks(){return H.supportedPassportLinks}checkAccessToken(){return a.checkHinkalAccessToken(this)}async getAxelarEstimate(e,t,r,n){return F.getAxelarGasEstimate(e,t,r,n,this.userKeys.getAccessKey())}async getConnextReceiveFee(e,t){return L.getConnextReceiveFee(this.getCurrentChainId(),e,t)}async mintHinkalAccessToken(e){return a.mintAccessToken(this,e)}async mintHinkalAccessTokenCrossChain(e,t){return a.mintTokenCrossChain(this,e,t)}async getHinkalTreeRootHash(){return this.getContractWithFetcher(h.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){return this.getContractWithFetcher(h.ContractType.CrossChainAccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(g.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&await this.resetMerkle()}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(){return(await p.API.getIdleRelay(this.getCurrentChainId())).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return p.API}snapshotsClearInterval(){this.commitmentsSnapshotService?.intervalClear(),this.accessTokenSnapshotService?.intervalClear(),this.nullifierSnapshotService?.intervalClear()}async deposit(e,t){return d.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return d.hinkalDepositForOther(this,e,t,r)}async withdraw(e,t,r,n,i=!1){return T.hinkalWithdraw(this,e,t,r,n,i)}async swap(e,t,r,n,i=!1,s=!1){return m.hinkalSwap(this,e,t,r,n,i,s)}async actionCurve(e,t,r,n,i,s=!1){return P.hinkalActionCurve(this,e,t,r,n,i,s)}async actionConvex(e,t,r,n,i=!1){return C.hinkalActionConvex(this,e,t,r,n,i)}async actionBeefy(e,t,r,n,i,s,v=!1){return y.hinkalActionBeefy(this,e,t,r,n,i,s,v)}async actionLido(e,t,r,n,i,s=!1){return E.hinkalActionLido(this,e,t,r,n,i,s)}async actionPendle(e,t,r,n,i=!1){return w.hinkalActionPendle(this,e,t,r,n,i)}async actionPendleLP(e,t,r,n,i=!1){return k.hinkalActionPendleLP(this,e,t,r,n,i)}async actionVolatile(e,t,r,n=!1){return R.hinkalActionVolatile(this,e,t,r,n)}async actionStake(e,t,r,n){return W.hinkalActionStake(this,e,t,r,n)}async actionPrivateWallet(e,t,r,n=[],i,s=!1){return N.hinkalPrivateWallet(this,e,t,r,n,i,s)}async getPendleLPClaimableParams(e,t){return k.hinkalGetPendleLPClaimableParams(this,e,t)}}exports.Hinkal=x;
|
|
@@ -73,6 +73,7 @@ export declare class Hinkal<ConnectorType> implements IHinkal {
|
|
|
73
73
|
getRandomRelay(): Promise<string | undefined>;
|
|
74
74
|
getGasPrice(): Promise<bigint>;
|
|
75
75
|
getAPI(): IAPI;
|
|
76
|
+
snapshotsClearInterval(): void;
|
|
76
77
|
deposit(erc20Addresses: string[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
77
78
|
depositForOther(erc20Addresses: string[], amountChanges: bigint[], recipientInfo: string): Promise<ethers.ContractTransaction>;
|
|
78
79
|
withdraw(erc20Addresses: string[], amountChanges: bigint[], recipientAddress: string, isRelayerOff: boolean, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EventType as o } from "../../types/hinkal.types.mjs";
|
|
2
2
|
import { ContractType as c } from "../../types/ethereum-network.types.mjs";
|
|
3
|
-
import { checkHinkalAccessToken as g, mintAccessToken as u, mintTokenCrossChain as
|
|
4
|
-
import { getShieldedBalance as
|
|
3
|
+
import { checkHinkalAccessToken as g, mintAccessToken as u, mintTokenCrossChain as v } from "../../functions/web3/functionCalls/accessTokenCalls.mjs";
|
|
4
|
+
import { getShieldedBalance as k } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
5
5
|
import { UserKeys as s } from "../crypto-keys/keys.mjs";
|
|
6
|
-
import { hinkalActionBeefy as
|
|
6
|
+
import { hinkalActionBeefy as A } from "./hinkalActionBeefy.mjs";
|
|
7
7
|
import { hinkalActionConvex as y } from "./hinkalActionConvex.mjs";
|
|
8
|
-
import { hinkalActionCurve as
|
|
9
|
-
import { hinkalActionPendle as
|
|
8
|
+
import { hinkalActionCurve as C } from "./hinkalActionCurve.mjs";
|
|
9
|
+
import { hinkalActionPendle as f } from "./hinkalActionPendle.mjs";
|
|
10
10
|
import { hinkalDeposit as w, hinkalDepositForOther as P } from "./hinkalDeposit.mjs";
|
|
11
11
|
import { hinkalSwap as T } from "./hinkalSwap.mjs";
|
|
12
12
|
import { hinkalWithdraw as S } from "./hinkalWithdraw.mjs";
|
|
@@ -162,7 +162,7 @@ class Le {
|
|
|
162
162
|
F(await this.getEthereumAddress(), this.getCurrentChainId());
|
|
163
163
|
}
|
|
164
164
|
async getBalances() {
|
|
165
|
-
return
|
|
165
|
+
return k(this);
|
|
166
166
|
}
|
|
167
167
|
getSupportedPassportLinks() {
|
|
168
168
|
return L;
|
|
@@ -186,7 +186,7 @@ class Le {
|
|
|
186
186
|
return u(this, e);
|
|
187
187
|
}
|
|
188
188
|
async mintHinkalAccessTokenCrossChain(e, t) {
|
|
189
|
-
return
|
|
189
|
+
return v(this, e, t);
|
|
190
190
|
}
|
|
191
191
|
async getHinkalTreeRootHash() {
|
|
192
192
|
return this.getContractWithFetcher(c.HinkalContract).getRootHash();
|
|
@@ -224,6 +224,9 @@ class Le {
|
|
|
224
224
|
getAPI() {
|
|
225
225
|
return l;
|
|
226
226
|
}
|
|
227
|
+
snapshotsClearInterval() {
|
|
228
|
+
this.commitmentsSnapshotService?.intervalClear(), this.accessTokenSnapshotService?.intervalClear(), this.nullifierSnapshotService?.intervalClear();
|
|
229
|
+
}
|
|
227
230
|
async deposit(e, t) {
|
|
228
231
|
return w(this, e, t);
|
|
229
232
|
}
|
|
@@ -248,13 +251,13 @@ class Le {
|
|
|
248
251
|
);
|
|
249
252
|
}
|
|
250
253
|
async actionCurve(e, t, r, i, n, a = !1) {
|
|
251
|
-
return
|
|
254
|
+
return C(this, e, t, r, i, n, a);
|
|
252
255
|
}
|
|
253
256
|
async actionConvex(e, t, r, i, n = !1) {
|
|
254
257
|
return y(this, e, t, r, i, n);
|
|
255
258
|
}
|
|
256
259
|
async actionBeefy(e, t, r, i, n, a, m = !1) {
|
|
257
|
-
return
|
|
260
|
+
return A(
|
|
258
261
|
this,
|
|
259
262
|
e,
|
|
260
263
|
t,
|
|
@@ -269,7 +272,7 @@ class Le {
|
|
|
269
272
|
return I(this, e, t, r, i, n, a);
|
|
270
273
|
}
|
|
271
274
|
async actionPendle(e, t, r, i, n = !1) {
|
|
272
|
-
return
|
|
275
|
+
return f(this, e, t, r, i, n);
|
|
273
276
|
}
|
|
274
277
|
async actionPendleLP(e, t, r, i, n = !1) {
|
|
275
278
|
return K(
|
|
@@ -44,6 +44,7 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
44
44
|
getRandomRelay(): Promise<string | undefined>;
|
|
45
45
|
getGasPrice(): Promise<bigint>;
|
|
46
46
|
getAPI(): IAPI;
|
|
47
|
+
snapshotsClearInterval(): void;
|
|
47
48
|
deposit(erc20Addresses: string[], amountChanges: bigint[]): Promise<ethers.ContractTransaction>;
|
|
48
49
|
depositForOther(erc20Addresses: string[], amountChanges: bigint[], recepinetInfo: string): Promise<ethers.ContractTransaction>;
|
|
49
50
|
withdraw(erc20Addresses: string[], amountChanges: bigint[], recipientAddress: string, isRelayerOff: boolean, onlyGasEstimate?: boolean): Promise<ethers.ContractTransaction | RelayerTransaction | bigint>;
|
|
@@ -78,7 +79,7 @@ export interface IHinkal<ConnectorType = unknown> {
|
|
|
78
79
|
actionPendle(erc20Addresses: string[], amountChanges: bigint[], pendleMetadata: PendleMetadata, gasTokenAddress?: string, onlyGasEstimate?: boolean): Promise<RelayerTransaction | ContractTransaction | bigint>;
|
|
79
80
|
actionPendleLP(erc20Addresses: string[], amountChanges: bigint[], pendleLPMetadata: PendleLPMetadata, gasTokenAddress?: string, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
80
81
|
actionVolatile(erc20Addresses: string[], amountChanges: bigint[], volatileHelperData: VolatileHelperData, onlyGasEstimate?: boolean): Promise<RelayerTransaction | ContractTransaction | bigint>;
|
|
81
|
-
actionPrivateWallet(erc20Addresses: string[], amountChanges: bigint[], onChainCreation: boolean[], ops: string[], walletNonce
|
|
82
|
+
actionPrivateWallet(erc20Addresses: string[], amountChanges: bigint[], onChainCreation: boolean[], ops: string[], walletNonce?: bigint, onlyGasEstimate?: boolean): Promise<RelayerTransaction | bigint>;
|
|
82
83
|
getPendleLPClaimableParams(wlpTokenAddress: string, wlpTokenBalance: bigint): Promise<{
|
|
83
84
|
amount: bigint;
|
|
84
85
|
timestamp: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),S=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),k=require("../../functions/pre-transaction/getFlatFees.cjs"),M=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),P=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),_=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),F=require("../../types/hinkal.types.cjs"),i=require("../../types/external-action.types.cjs"),G=(e,r,t,n,l,d)=>{let a;return l===i.ExternalActionId.BeefyStake?(a=u.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256"],[Number(n),d,e[0][0].amount,e[0][0].timeStamp]),a):(r.length===1?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],"0x00",t]):r.length===2?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],r[1],t]):a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),"0x00","0x00",t]),a)},O=(e,r,t)=>r===i.ExternalActionId.BeefyStake?t===F.BeefyAction.GetRewards?[!1,!0]:[!1,!1,!0]:e.map(n=>n>0n),L=async(e,r,t,n,l,d,a,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),S=require("../../constants/chains.constants.cjs"),I=require("../../error-handling/error-codes.constants.cjs"),k=require("../../functions/pre-transaction/getFlatFees.cjs"),M=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),P=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),_=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),F=require("../../types/hinkal.types.cjs"),i=require("../../types/external-action.types.cjs"),G=(e,r,t,n,l,d)=>{let a;return l===i.ExternalActionId.BeefyStake?(a=u.utils.defaultAbiCoder.encode(["uint8","address","uint256","uint256"],[Number(n),d,e[0][0].amount,e[0][0].timeStamp]),a):(r.length===1?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],"0x00",t]):r.length===2?a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),r[0],r[1],t]):a=u.utils.defaultAbiCoder.encode(["uint8","bytes","bytes","address"],[Number(n),"0x00","0x00",t]),a)},O=(e,r,t)=>r===i.ExternalActionId.BeefyStake?t===F.BeefyAction.GetRewards?[!1,!0]:[!1,!1,!0]:e.map(n=>n>0n),L=async(e,r,t,n,l,d,a,E=!1)=>{const c=[...await T.addPaddingToUtxos(e,r,t)],p=`swapper${a?"MO":"M"}${t.length.toString()}x${c[0].length}x1`,s=a?i.ExternalActionId.BeefyStake:i.ExternalActionId.Beefy,{flatFees:f,feeUnit:q}=await k.getFlatFees(e.getCurrentChainId(),r,s,t,n);t=M.processAmountChanges({erc20Addresses:r,amountChanges:t,flatFees:f,feeUnit:q,externalActionId:s,action:n});const b=O(t,s,n),x=[];for(let o=0;o<r.length;o+=1){const{outputUtxos:R}=N.outputUtxoProcessing(e.userKeys,c[o],t[o]);x.push(R)}const{contractData:y}=S.networkRegistry[e.getCurrentChainId()],w=s===i.ExternalActionId.BeefyStake?y.beefyStakeExternalActionInstanceAddress:y.beefyExternalActionInstanceAddress,B=G(c,l,d,n,s,a),g=await e.getRandomRelay();if(!g)throw Error(I.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:A,circomData:C,dimData:m}=await P.constructZkProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,c,x,e.userKeys,p,s,w,B,g,e.getCurrentChainId(),b,f);return E?await U.estimateGasRelayer(e,A,m,C):await _.transactCallRelayer(e.getCurrentChainId(),A,m,C)};exports.hinkalActionBeefy=L;
|
|
@@ -10,11 +10,11 @@ import { estimateGasRelayer as L } from "../../functions/web3/functionCalls/esti
|
|
|
10
10
|
import { transactCallRelayer as O } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
11
11
|
import { BeefyAction as P } from "../../types/hinkal.types.mjs";
|
|
12
12
|
import { ExternalActionId as s } from "../../types/external-action.types.mjs";
|
|
13
|
-
const $ = (t, r, e, o,
|
|
13
|
+
const $ = (t, r, e, o, u, f) => {
|
|
14
14
|
let a;
|
|
15
|
-
return
|
|
15
|
+
return u === s.BeefyStake ? (a = m.defaultAbiCoder.encode(
|
|
16
16
|
["uint8", "address", "uint256", "uint256"],
|
|
17
|
-
[Number(o),
|
|
17
|
+
[Number(o), f, t[0][0].amount, t[0][0].timeStamp]
|
|
18
18
|
), a) : (r.length === 1 ? a = m.defaultAbiCoder.encode(
|
|
19
19
|
["uint8", "bytes", "bytes", "address"],
|
|
20
20
|
[Number(o), r[0], "0x00", e]
|
|
@@ -25,8 +25,8 @@ const $ = (t, r, e, o, f, u) => {
|
|
|
25
25
|
["uint8", "bytes", "bytes", "address"],
|
|
26
26
|
[Number(o), "0x00", "0x00", e]
|
|
27
27
|
), a);
|
|
28
|
-
}, G = (t, r, e) => r === s.BeefyStake ? e === P.GetRewards ? [!1, !0] : [!1, !1, !0] : t.map((o) => o > 0n), X = async (t, r, e, o,
|
|
29
|
-
const c = [...await F(t, r, e)],
|
|
28
|
+
}, G = (t, r, e) => r === s.BeefyStake ? e === P.GetRewards ? [!1, !0] : [!1, !1, !0] : t.map((o) => o > 0n), X = async (t, r, e, o, u, f, a, A = !1) => {
|
|
29
|
+
const c = [...await F(t, r, e)], E = `swapper${a ? "MO" : "M"}${e.length.toString()}x${c[0].length}x1`, n = a ? s.BeefyStake : s.Beefy, { flatFees: l, feeUnit: w } = await M(
|
|
30
30
|
t.getCurrentChainId(),
|
|
31
31
|
r,
|
|
32
32
|
n,
|
|
@@ -37,43 +37,41 @@ const $ = (t, r, e, o, f, u) => {
|
|
|
37
37
|
erc20Addresses: r,
|
|
38
38
|
amountChanges: e,
|
|
39
39
|
flatFees: l,
|
|
40
|
-
feeUnit:
|
|
40
|
+
feeUnit: w,
|
|
41
41
|
externalActionId: n,
|
|
42
42
|
action: o
|
|
43
43
|
});
|
|
44
|
-
const
|
|
45
|
-
console.log({ amountChanges: e, onChainCreation: d });
|
|
46
|
-
const p = [];
|
|
44
|
+
const b = G(e, n, o), d = [];
|
|
47
45
|
for (let i = 0; i < r.length; i += 1) {
|
|
48
46
|
const { outputUtxos: S } = U(t.userKeys, c[i], e[i]);
|
|
49
|
-
|
|
47
|
+
d.push(S);
|
|
50
48
|
}
|
|
51
|
-
const { contractData:
|
|
49
|
+
const { contractData: p } = N[t.getCurrentChainId()], B = n === s.BeefyStake ? p.beefyStakeExternalActionInstanceAddress : p.beefyExternalActionInstanceAddress, R = $(
|
|
52
50
|
c,
|
|
53
|
-
f,
|
|
54
51
|
u,
|
|
52
|
+
f,
|
|
55
53
|
o,
|
|
56
54
|
n,
|
|
57
55
|
a
|
|
58
|
-
),
|
|
59
|
-
if (!
|
|
56
|
+
), x = await t.getRandomRelay();
|
|
57
|
+
if (!x)
|
|
60
58
|
throw Error(I.RELAYER_NOT_AVAILABLE);
|
|
61
|
-
const { zkCallData:
|
|
59
|
+
const { zkCallData: y, circomData: g, dimData: C } = await k(
|
|
62
60
|
t.merkleTreeHinkal,
|
|
63
61
|
t.merkleTreeAccessToken,
|
|
64
62
|
c,
|
|
65
|
-
|
|
63
|
+
d,
|
|
66
64
|
t.userKeys,
|
|
67
|
-
|
|
65
|
+
E,
|
|
68
66
|
n,
|
|
69
67
|
B,
|
|
70
68
|
R,
|
|
71
|
-
|
|
69
|
+
x,
|
|
72
70
|
t.getCurrentChainId(),
|
|
73
|
-
|
|
71
|
+
b,
|
|
74
72
|
l
|
|
75
73
|
);
|
|
76
|
-
return
|
|
74
|
+
return A ? await L(t, y, C, g) : await O(t.getCurrentChainId(), y, C, g);
|
|
77
75
|
};
|
|
78
76
|
export {
|
|
79
77
|
X as hinkalActionBeefy
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("ethers"),s=require("../../constants/chains.constants.cjs"),R=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/processAmountChanges.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),S=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),_=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),y=require("../../types/hinkal.types.cjs"),M=require("../../types/external-action.types.cjs"),O=async(t,o,e,A,a,f=!1)=>{const n=[...await T.addPaddingToUtxos(t,o,e)],p=`swapperMO${e.length.toString()}x${n[0].length}x1`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("ethers"),s=require("../../constants/chains.constants.cjs"),R=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/pre-transaction/getFlatFees.cjs"),U=require("../../functions/pre-transaction/processAmountChanges.cjs"),L=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),S=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),T=require("../../functions/web3/events/getShieldedBalance.cjs"),_=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),F=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),y=require("../../types/hinkal.types.cjs"),M=require("../../types/external-action.types.cjs"),O=async(t,o,e,A,a,f=!1)=>{const n=[...await T.addPaddingToUtxos(t,o,e)],p=`swapperMO${e.length.toString()}x${n[0].length}x1`,c=s.getNonLocalhostChainId(t.getCurrentChainId()),i=M.ExternalActionId.Convex,{flatFees:u,feeUnit:I}=await P.getFlatFees(t.getCurrentChainId(),o,i,e,a);e=U.processAmountChanges({erc20Addresses:o,amountChanges:e,flatFees:u,feeUnit:I,externalActionId:i,action:a});const h=[y.ConvexAction.StakeLP,y.ConvexAction.UnStakeLP].includes(a)?[!1,!1,...c===s.chainIds.ethMainnet?[!0,!0]:[!0]]:[!1,...c===s.chainIds.ethMainnet?[!0,!0]:[!0]],l=[];for(let r=0;r<o.length;r+=1){const{outputUtxos:w}=L.outputUtxoProcessing(t.userKeys,n[r],e[r]);l.push(w)}const m=s.networkRegistry[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress,q=E.utils.defaultAbiCoder.encode(["uint8","uint256","uint256","uint256"],[Number(a),A,n[0][0].amount,n[0][0].timeStamp]),d=await t.getRandomRelay();if(!d)throw Error(R.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{zkCallData:C,circomData:g,dimData:x}=await S.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,n,l,t.userKeys,p,i,m,q,d,t.getCurrentChainId(),h,u);return f?await _.estimateGasRelayer(t,C,x,g):await F.transactCallRelayer(t.getCurrentChainId(),C,x,g)};exports.hinkalActionConvex=O;
|
|
@@ -8,12 +8,10 @@ import { constructZkProof as N } from "../../functions/snarkjs/constructGeneralZ
|
|
|
8
8
|
import { addPaddingToUtxos as O } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
9
9
|
import { estimateGasRelayer as S } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
10
10
|
import { transactCallRelayer as F } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
11
|
-
import { ConvexAction as
|
|
11
|
+
import { ConvexAction as C } from "../../types/hinkal.types.mjs";
|
|
12
12
|
import { ExternalActionId as b } from "../../types/external-action.types.mjs";
|
|
13
|
-
const Q = async (t, n, e,
|
|
14
|
-
const
|
|
15
|
-
console.log({ inputUtxosArray: o });
|
|
16
|
-
const i = b.Convex, { flatFees: m, feeUnit: I } = await T(
|
|
13
|
+
const Q = async (t, n, e, x, a, g = !1) => {
|
|
14
|
+
const r = [...await O(t, n, e)], A = `swapperMO${e.length.toString()}x${r[0].length}x1`, s = U(t.getCurrentChainId()), i = b.Convex, { flatFees: c, feeUnit: I } = await T(
|
|
17
15
|
t.getCurrentChainId(),
|
|
18
16
|
n,
|
|
19
17
|
i,
|
|
@@ -23,39 +21,38 @@ const Q = async (t, n, e, C, a, x = !1) => {
|
|
|
23
21
|
e = D({
|
|
24
22
|
erc20Addresses: n,
|
|
25
23
|
amountChanges: e,
|
|
26
|
-
flatFees:
|
|
24
|
+
flatFees: c,
|
|
27
25
|
feeUnit: I,
|
|
28
26
|
externalActionId: i,
|
|
29
27
|
action: a
|
|
30
|
-
})
|
|
31
|
-
const
|
|
32
|
-
for (let
|
|
33
|
-
const { outputUtxos: L } = M(t.userKeys, o
|
|
34
|
-
|
|
28
|
+
});
|
|
29
|
+
const y = [C.StakeLP, C.UnStakeLP].includes(a) ? [!1, !1, ...s === d.ethMainnet ? [!0, !0] : [!0]] : [!1, ...s === d.ethMainnet ? [!0, !0] : [!0]], m = [];
|
|
30
|
+
for (let o = 0; o < n.length; o += 1) {
|
|
31
|
+
const { outputUtxos: L } = M(t.userKeys, r[o], e[o]);
|
|
32
|
+
m.push(L);
|
|
35
33
|
}
|
|
36
|
-
|
|
37
|
-
const y = h[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress, E = R.defaultAbiCoder.encode(
|
|
34
|
+
const w = h[t.getCurrentChainId()].contractData.convexExternalActionInstanceAddress, E = R.defaultAbiCoder.encode(
|
|
38
35
|
["uint8", "uint256", "uint256", "uint256"],
|
|
39
|
-
[Number(a),
|
|
36
|
+
[Number(a), x, r[0][0].amount, r[0][0].timeStamp]
|
|
40
37
|
), u = await t.getRandomRelay();
|
|
41
38
|
if (!u)
|
|
42
39
|
throw Error(P.RELAYER_NOT_AVAILABLE);
|
|
43
|
-
const { zkCallData:
|
|
40
|
+
const { zkCallData: f, circomData: l, dimData: p } = await N(
|
|
44
41
|
t.merkleTreeHinkal,
|
|
45
42
|
t.merkleTreeAccessToken,
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
r,
|
|
44
|
+
m,
|
|
48
45
|
t.userKeys,
|
|
49
46
|
A,
|
|
50
47
|
i,
|
|
51
|
-
|
|
48
|
+
w,
|
|
52
49
|
E,
|
|
53
50
|
u,
|
|
54
51
|
t.getCurrentChainId(),
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
y,
|
|
53
|
+
c
|
|
57
54
|
);
|
|
58
|
-
return
|
|
55
|
+
return g ? await S(t, f, p, l) : await F(t.getCurrentChainId(), f, p, l);
|
|
59
56
|
};
|
|
60
57
|
export {
|
|
61
58
|
Q as hinkalActionConvex
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("ethers"),F=require("../../constants/chains.constants.cjs"),M=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),h=require("../../functions/pre-transaction/getFlatFees.cjs"),S=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),b=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("ethers"),F=require("../../constants/chains.constants.cjs"),M=require("../../error-handling/error-codes.constants.cjs"),P=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/snarkjs/constructGeneralZkProof.cjs"),h=require("../../functions/pre-transaction/getFlatFees.cjs"),S=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),_=require("../../functions/pre-transaction/processAmountChanges.cjs"),N=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),b=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),i=require("../../types/external-action.types.cjs"),o=require("../../types/hinkal.types.cjs"),D=(t,a)=>{if(t===o.LidoVariant.Ethereum)return a===o.LidoAction.Stake?i.ExternalActionId.LidoETH:i.ExternalActionId.LidoETHNFT;if(t===o.LidoVariant.Polygon)return a===o.LidoAction.Stake?i.ExternalActionId.LidoMATIC:i.ExternalActionId.LidoMATICNFT;throw new Error("Invalid LidoVariant used")},k=t=>R.ethers.utils.defaultAbiCoder.encode(["uint8"],[Number(t)]),v=async(t,a,n,s,r,d,p=!1)=>{const c=[...await P.addPaddingToUtxos(t,s,r,6,d)],g=c[0].length,C=`${n===o.LidoAction.Stake?"swapperM":"swapperToken"}2x${g}x1`,u=D(a,n),{flatFees:l,feeUnit:f}=await h.getFlatFees(t.getCurrentChainId(),s,u,r,n);r=_.processAmountChanges({erc20Addresses:s,amountChanges:r,flatFees:l,feeUnit:f,externalActionId:u,action:n});const w=n===o.LidoAction.Request?r.map(()=>!1):r.map(e=>e>0n),x=[];for(let e=0;e<s.length;e+=1){const{outputUtxos:T}=S.outputUtxoProcessing(t.userKeys,c[e],r[e],void 0,d[e]);x.push(T)}if(!await t.getRandomRelay())throw Error(M.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{lidoExternalActionEthAddress:m,lidoExternalActionMaticAddress:q}=F.networkRegistry[t.getCurrentChainId()].contractData,A=a===o.LidoVariant.Ethereum?m:q;if(!A)throw new Error("Can't find external action address");const I=k(n),{zkCallData:E,circomData:y,dimData:L}=await U.constructZkProof(t.merkleTreeHinkal,t.merkleTreeAccessToken,c,x,t.userKeys,C,u,A,I,await t.getRandomRelay(),t.getCurrentChainId(),w,l);return p?await N.estimateGasRelayer(t,E,L,y):await b.transactCallRelayer(t.getCurrentChainId(),E,L,y)};exports.hinkalActionLido=v;
|