@hinkal/common 0.1.6 → 0.1.7
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/coingecko.constants.cjs +1 -1
- package/constants/coingecko.constants.mjs +14 -13
- package/constants/vite.constants.cjs +1 -1
- package/constants/vite.constants.mjs +22 -21
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +71 -70
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +8 -7
- package/data-structures/crypto-keys/encryptDecryptUtxo.cjs +1 -1
- package/data-structures/crypto-keys/encryptDecryptUtxo.mjs +35 -34
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +28 -27
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +3 -2
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +3 -2
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +11 -10
- package/functions/snarkjs/common.snarkjs.cjs +1 -1
- package/functions/snarkjs/common.snarkjs.mjs +28 -27
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +25 -24
- package/functions/utils/process.utils.cjs +1 -1
- package/functions/utils/process.utils.mjs +3 -2
- package/functions/utils/requireEnv.cjs +1 -1
- package/functions/utils/requireEnv.mjs +5 -4
- package/functions/web3/events/balanceChangedHandler.cjs +1 -1
- package/functions/web3/events/balanceChangedHandler.mjs +4 -3
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +9 -8
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +3 -2
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +3 -2
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +3 -2
- package/package.json +1 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +4 -2
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +4 -2
- 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 +11 -10
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +2 -2
- package/webworker/utxoWorker/utxoWorkerLogic.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLogic.mjs +29 -28
- package/webworker/workerProxy.cjs +1 -1
- package/webworker/workerProxy.mjs +4 -3
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const f=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs"),T=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const f=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");const k=require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const q=require("../../functions/snarkjs/generateZkProof.cjs");require("../../types/circom-data.types.cjs");const I=require("../../types/transactions.types.cjs"),x=require("../../types/time.types.cjs"),P=require("./history/getTxDetails.cjs");require("circomlibjs");const C=require("../../error-handling/error-codes.constants.cjs"),w=require("../crypto-keys/keys.cjs"),v=require("../crypto-keys/encryptDecryptUtxo.cjs"),p=require("../../functions/utils/getDataFromTransaction.cjs"),S=require("../../functions/utils/cacheFunctions.cjs");class H{circuitSize=50;hinkalContract;init(e){this.hinkalContract=e}requireInit(){if(!this.hinkalContract)throw Error("TransactionsManager not initialized")}filterOwnTransactions=async(e,r,t,a)=>{const{transactMethodId:s,transactWithExternalActionMethodId:n,hinkalInterface:i}=k.getHinkalParameters(T.getNonLocalhostChainId(e)),c=o=>"decodedInput"in o,l=r.filter(o=>o.methodId===s||o.methodId===n).map(o=>c(o)?o:{...o,decodedInput:p.decodeTxInput(i,o.input),status:o.isError==="0"?"SUCCESS":"FAILURE"}),h=t.getShieldedPrivateKey();return l.filter(o=>{try{if(c(o)){if(v.decryptUtxo(A.from(o.decodedInput.encryptedOutputs[0].slice(2),"hex"),t),!a&&o.methodId===s){const{extraRandomization:g,H0:y,H1:m}=o.decodedInput.stealthAddressStructure;return w.UserKeys.checkSignature(g,y,m,h)}return!0}return!1}catch{return!1}})};saveTxsInStorage=(e,r,t,a)=>{const s=t.getShieldedPublicKey();return S.saveTxsCache(e,r,s,this.hinkalContract.address,a)};loadTxsFromStorage=async(e,r)=>{const t=r.getShieldedPublicKey();return await S.loadTxsCache(e,t,this.hinkalContract.address)};getAllTransactions=async(e,r,t)=>{if(t){const{transactions:i}=await f.API.userGetTransactions(e,t);return i}const{decodedTxs:a,lastHash:s}=await this.loadTxsFromStorage(e,r),{transactions:n}=await f.API.userGetTransactions(e,t,s);return[...n,...a]};getHinkalHistoryBase=async(e,r,t,a=!1)=>{this.requireInit();const s=await this.getAllTransactions(e,r,t)??[];s.sort((i,c)=>c.timeStamp-i.timeStamp);const n=await this.filterOwnTransactions(e,s,r,a);return!t&&s.length>0&&await this.saveTxsInStorage(n,e,r,s[0].hash),n};getHinkalHistory=async(e,r)=>{const t=await this.getHinkalHistoryBase(e,r,void 0,!0),a=p.decodeTxLogs(e,t);return await Promise.all(a.map(async n=>({...n,status:n.status,details:await P.getTxDetails(e,n.decodedInput,n.utxosArray)})))};sortInBatches=e=>{const r=[];let t=0,a=0;e.forEach(i=>{t===0&&r.push([]),r[a].push(i),t+=1,t===this.circuitSize&&(t=0,a+=1)});const s=r[r.length-1],n=s.length;if(n<this.circuitSize){const i=this.circuitSize-n,c=new Array(i).fill(I.emptyDecodedTx);r[r.length-1]=s.concat(c)}return r};generateTransactionsProof=async(e,r,t)=>{const a=this.sortInBatches(r),s=new Array(a.length).fill([]);for(let n=0;n<a.length;n+=1){const i=a[n].map(d=>d.decodedInput.stealthAddressStructure),c=i.map(d=>d.extraRandomization),u=i.map(d=>d.stealthAddress);console.log({extraRandomizations:c,stealthAddresses:u});const l={shieldedPrivateKey:t,extraRandomizations:c,stealthAddresses:u};console.log({chainId:e,input:l});const{zkCallData:h}=await q.generateZkProof(e,"transactionsProver",l);console.log({zkCallData:h}),s[n]=h}return{zkCallDataArray:s}};userVerifyTransactions=async(e,r,t,a,s,n)=>await f.API.userVerifyTransactions(e,r,t,a,s,n);processAndSendTransactionsForVerification=async(e,r,t,a)=>{this.requireInit();const s=x.getCurrentWeek(),n=a?s-1:s;console.log("retrieving transactions in processAndSendTransactionsForVerification",{week:n});const i=await this.getHinkalHistoryBase(e,r,n);console.log("retrieved transactions",i);let c=[],u=[];i.length>0&&({zkCallDataArray:u}=await this.generateTransactionsProof(e,i,r.getShieldedPrivateKey()),c=i.map(y=>y.hash));const l=r.getBackendToken(),{trade:h,transactions:d,lockedDeposit:o,verification:g}=await this.userVerifyTransactions(e,c,u,l,t,n);return{trade:h,transactions:d,lockedDeposit:o,verification:g}};multiProcessAndSendTransactionsForVerification=async(e,r)=>{console.log("Multi Certify Starts");const t=T.chainIdsByType[T.EthereumNetworkType.Mainnet];let a=!0;for(let s=0;s<t.length;s+=1)try{const{hasCertified:n}=await f.API.verificationStartDate(t[s],r);if(console.log(`certification status for chain ${t[s]} is ${n}`),n)continue;const{trade:i,transactions:c,lockedDeposit:u,verification:l}=await this.processAndSendTransactionsForVerification(t[s],e,r,!0);if(console.log({chainId:t[s],trade:i,totalTransactions:c,lockedDeposit:u,verification:l}),a=a&&l,!a)break}catch(n){console.log(`current chain ${t[s]} certification error`,{err:n}),a=!1;break}if(!a)throw Error(C.transactionErrorCodes.MULTI_VERIFICATION_FAILED);return!0}}exports.TransactionsManager=H;
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import T from "../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
|
|
2
|
+
import { getNonLocalhostChainId as y, chainIdsByType as S, EthereumNetworkType as k } from "../../constants/chains.constants.mjs";
|
|
2
3
|
import "../../constants/vite.constants.mjs";
|
|
3
4
|
import "axios";
|
|
4
5
|
import "../../constants/coingecko.constants.mjs";
|
|
5
6
|
import { API as m } from "../../API/API.mjs";
|
|
6
7
|
import "ethers";
|
|
7
8
|
import "../../types/curve.types.mjs";
|
|
8
|
-
import { getHinkalParameters as
|
|
9
|
+
import { getHinkalParameters as A } from "../../constants/contracts.constants.mjs";
|
|
9
10
|
import "../../constants/kyc.constants.mjs";
|
|
10
11
|
import "../../constants/axelar.constants.mjs";
|
|
11
12
|
import "../../constants/rewards.constants.mjs";
|
|
12
13
|
import "../../constants/reorg-depths.constants.mjs";
|
|
13
|
-
import { generateZkProof as
|
|
14
|
+
import { generateZkProof as I } from "../../functions/snarkjs/generateZkProof.mjs";
|
|
14
15
|
import "../../types/circom-data.types.mjs";
|
|
15
|
-
import { emptyDecodedTx as
|
|
16
|
-
import { getCurrentWeek as
|
|
17
|
-
import { getTxDetails as
|
|
16
|
+
import { emptyDecodedTx as x } from "../../types/transactions.types.mjs";
|
|
17
|
+
import { getCurrentWeek as w } from "../../types/time.types.mjs";
|
|
18
|
+
import { getTxDetails as C } from "./history/getTxDetails.mjs";
|
|
18
19
|
import "circomlibjs";
|
|
19
|
-
import { transactionErrorCodes as
|
|
20
|
-
import { UserKeys as
|
|
21
|
-
import { decryptUtxo as
|
|
22
|
-
import { decodeTxInput as
|
|
23
|
-
import { saveTxsCache as
|
|
24
|
-
class
|
|
20
|
+
import { transactionErrorCodes as P } from "../../error-handling/error-codes.constants.mjs";
|
|
21
|
+
import { UserKeys as v } from "../crypto-keys/keys.mjs";
|
|
22
|
+
import { decryptUtxo as H } from "../crypto-keys/encryptDecryptUtxo.mjs";
|
|
23
|
+
import { decodeTxInput as z, decodeTxLogs as E } from "../../functions/utils/getDataFromTransaction.mjs";
|
|
24
|
+
import { saveTxsCache as b, loadTxsCache as F } from "../../functions/utils/cacheFunctions.mjs";
|
|
25
|
+
class st {
|
|
25
26
|
circuitSize = 50;
|
|
26
27
|
hinkalContract;
|
|
27
28
|
init(r) {
|
|
@@ -32,21 +33,21 @@ class et {
|
|
|
32
33
|
throw Error("TransactionsManager not initialized");
|
|
33
34
|
}
|
|
34
35
|
filterOwnTransactions = async (r, e, t, n) => {
|
|
35
|
-
const { transactMethodId: a, transactWithExternalActionMethodId: s, hinkalInterface: i } =
|
|
36
|
-
|
|
36
|
+
const { transactMethodId: a, transactWithExternalActionMethodId: s, hinkalInterface: i } = A(
|
|
37
|
+
y(r)
|
|
37
38
|
), c = (o) => "decodedInput" in o, l = e.filter(
|
|
38
39
|
(o) => o.methodId === a || o.methodId === s
|
|
39
40
|
).map((o) => c(o) ? o : {
|
|
40
41
|
...o,
|
|
41
|
-
decodedInput:
|
|
42
|
+
decodedInput: z(i, o.input),
|
|
42
43
|
status: o.isError === "0" ? "SUCCESS" : "FAILURE"
|
|
43
44
|
}), u = t.getShieldedPrivateKey();
|
|
44
45
|
return l.filter((o) => {
|
|
45
46
|
try {
|
|
46
47
|
if (c(o)) {
|
|
47
|
-
if (
|
|
48
|
+
if (H(T.from(o.decodedInput.encryptedOutputs[0].slice(2), "hex"), t), !n && o.methodId === a) {
|
|
48
49
|
const { extraRandomization: f, H0: p, H1: g } = o.decodedInput.stealthAddressStructure;
|
|
49
|
-
return
|
|
50
|
+
return v.checkSignature(f, p, g, u);
|
|
50
51
|
}
|
|
51
52
|
return !0;
|
|
52
53
|
}
|
|
@@ -58,11 +59,11 @@ class et {
|
|
|
58
59
|
};
|
|
59
60
|
saveTxsInStorage = (r, e, t, n) => {
|
|
60
61
|
const a = t.getShieldedPublicKey();
|
|
61
|
-
return
|
|
62
|
+
return b(r, e, a, this.hinkalContract.address, n);
|
|
62
63
|
};
|
|
63
64
|
loadTxsFromStorage = async (r, e) => {
|
|
64
65
|
const t = e.getShieldedPublicKey();
|
|
65
|
-
return await
|
|
66
|
+
return await F(r, t, this.hinkalContract.address);
|
|
66
67
|
};
|
|
67
68
|
getAllTransactions = async (r, e, t) => {
|
|
68
69
|
if (t) {
|
|
@@ -80,12 +81,12 @@ class et {
|
|
|
80
81
|
return !t && a.length > 0 && await this.saveTxsInStorage(s, r, e, a[0].hash), s;
|
|
81
82
|
};
|
|
82
83
|
getHinkalHistory = async (r, e) => {
|
|
83
|
-
const t = await this.getHinkalHistoryBase(r, e, void 0, !0), n =
|
|
84
|
+
const t = await this.getHinkalHistoryBase(r, e, void 0, !0), n = E(r, t);
|
|
84
85
|
return await Promise.all(
|
|
85
86
|
n.map(async (s) => ({
|
|
86
87
|
...s,
|
|
87
88
|
status: s.status,
|
|
88
|
-
details: await
|
|
89
|
+
details: await C(r, s.decodedInput, s.utxosArray)
|
|
89
90
|
}))
|
|
90
91
|
);
|
|
91
92
|
};
|
|
@@ -97,7 +98,7 @@ class et {
|
|
|
97
98
|
});
|
|
98
99
|
const a = e[e.length - 1], s = a.length;
|
|
99
100
|
if (s < this.circuitSize) {
|
|
100
|
-
const i = this.circuitSize - s, c = new Array(i).fill(
|
|
101
|
+
const i = this.circuitSize - s, c = new Array(i).fill(x);
|
|
101
102
|
e[e.length - 1] = a.concat(c);
|
|
102
103
|
}
|
|
103
104
|
return e;
|
|
@@ -115,7 +116,7 @@ class et {
|
|
|
115
116
|
stealthAddresses: d
|
|
116
117
|
};
|
|
117
118
|
console.log({ chainId: r, input: l });
|
|
118
|
-
const { zkCallData: u } = await
|
|
119
|
+
const { zkCallData: u } = await I(r, "transactionsProver", l);
|
|
119
120
|
console.log({ zkCallData: u }), a[s] = u;
|
|
120
121
|
}
|
|
121
122
|
return { zkCallDataArray: a };
|
|
@@ -130,7 +131,7 @@ class et {
|
|
|
130
131
|
);
|
|
131
132
|
processAndSendTransactionsForVerification = async (r, e, t, n) => {
|
|
132
133
|
this.requireInit();
|
|
133
|
-
const a =
|
|
134
|
+
const a = w(), s = n ? a - 1 : a;
|
|
134
135
|
console.log("retrieving transactions in processAndSendTransactionsForVerification", { week: s });
|
|
135
136
|
const i = await this.getHinkalHistoryBase(r, e, s);
|
|
136
137
|
console.log("retrieved transactions", i);
|
|
@@ -157,7 +158,7 @@ class et {
|
|
|
157
158
|
};
|
|
158
159
|
multiProcessAndSendTransactionsForVerification = async (r, e) => {
|
|
159
160
|
console.log("Multi Certify Starts");
|
|
160
|
-
const t =
|
|
161
|
+
const t = S[k.Mainnet];
|
|
161
162
|
let n = !0;
|
|
162
163
|
for (let a = 0; a < t.length; a += 1)
|
|
163
164
|
try {
|
|
@@ -177,10 +178,10 @@ class et {
|
|
|
177
178
|
break;
|
|
178
179
|
}
|
|
179
180
|
if (!n)
|
|
180
|
-
throw Error(
|
|
181
|
+
throw Error(P.MULTI_VERIFICATION_FAILED);
|
|
181
182
|
return !0;
|
|
182
183
|
};
|
|
183
184
|
}
|
|
184
185
|
export {
|
|
185
|
-
|
|
186
|
+
st as TransactionsManager
|
|
186
187
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../data-structures/utxo/Utxo.cjs"),c=require("../../error-handling/error-codes.constants.cjs");require("ethers");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 d=(o,t,e,u,i)=>{let r=0n;if(t.forEach(s=>{r+=s.amount}),e<0n&&r+e<0n)throw Error(c.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{outputUtxos:[new n.Utxo({amount:r+e,erc20TokenAddress:t[0].erc20TokenAddress,shieldedPrivateKey:o.getShieldedPrivateKey(),timeStamp:u,tokenId:i})]}};exports.outputUtxoProcessing=d;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../data-structures/utxo/Utxo.cjs"),c=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.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 d=(o,t,e,u,i)=>{let r=0n;if(t.forEach(s=>{r+=s.amount}),e<0n&&r+e<0n)throw Error(c.transactionErrorCodes.INSUFFICIENT_FUNDS_TO_TRANSACT);return{outputUtxos:[new n.Utxo({amount:r+e,erc20TokenAddress:t[0].erc20TokenAddress,shieldedPrivateKey:o.getShieldedPrivateKey(),timeStamp:u,tokenId:i})]}};exports.outputUtxoProcessing=d;
|
|
@@ -4,12 +4,13 @@ import "ethers";
|
|
|
4
4
|
import "axios";
|
|
5
5
|
import "../../constants/chains.constants.mjs";
|
|
6
6
|
import "../../constants/vite.constants.mjs";
|
|
7
|
+
import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
7
8
|
import "../../types/circom-data.types.mjs";
|
|
8
9
|
import "../../types/transactions.types.mjs";
|
|
9
10
|
import "../../types/curve.types.mjs";
|
|
10
11
|
import "circomlibjs";
|
|
11
12
|
import "../../constants/reorg-depths.constants.mjs";
|
|
12
|
-
const
|
|
13
|
+
const F = (e, r, o, i, m) => {
|
|
13
14
|
let t = 0n;
|
|
14
15
|
if (r.forEach((p) => {
|
|
15
16
|
t += p.amount;
|
|
@@ -26,5 +27,5 @@ const S = (e, r, o, i, m) => {
|
|
|
26
27
|
] };
|
|
27
28
|
};
|
|
28
29
|
export {
|
|
29
|
-
|
|
30
|
+
F as outputUtxoProcessing
|
|
30
31
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("../../constants/fees.constants.cjs"),d=require("../../error-handling/customErrors/FeeOverTransactionValueError.cjs"),y=require("../utils/amounts.utils.cjs");require("ethers");require("axios");require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");const O=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const e=require("../../types/hinkal.types.cjs"),c=require("../../types/slippage.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("circomlibjs");require("../../constants/reorg-depths.constants.cjs");const _=require("./interaction-to-action.cjs"),N=(t,A,r)=>{const l=y.absBigInt(t)-A;if(A<0n)throw new d.FeeOverTransactionValueError({totalFeeWEI:l,feeUnit:r});return A},F=({erc20Addresses:t=[],amountChanges:A,flatFees:r,feeUnit:I,externalActionId:l,action:p,gasTokenAddress:b})=>{const i=_.getInteractionFromAction(l,p);if(i===e.INTERACTION.NONE)throw Error("No interaction was choosen");switch(i){case e.INTERACTION.WITHDRAW:{N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break}case e.INTERACTION.SWAP:{A[1]=N(A[1],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[1],r[1],c.SlippageType.Swap),I);break}case e.INTERACTION.CURVE_DEPOSIT:{const E=A.length-1;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.CurveDeposit),I);break}case e.INTERACTION.CURVE_WITHDRAW:r.forEach((E,R)=>{E>0n?A[R]=N(A[R],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[R],E,c.SlippageType.CurveWithdraw),I):E===0n&&A[R]>0n&&R!==r.length-1&&(A[R]=T.getAmountAfterSlippage(A[R],c.SlippageType.CurveWithdraw))});break;case e.INTERACTION.CURVE_WITHDRAW_INBALANCED:break;case e.INTERACTION.STAKING:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.UNSTAKING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.CLAIMING:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY:{const E=O.isBeefyDeposit(p)?1:0;A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Beefy),I);break}case e.INTERACTION.BEEFY_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.BEEFY_UNSTAKE:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.BEEFY_GET_REWARDS:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_STAKE:A[0]=N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0]),I);break;case e.INTERACTION.LIDO_REQUEST:N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.LIDO_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_TRANSACT:A[0]<0n&&N(A[0],T.getAmountAfterRelayAndFlatFees(A[0],r[0],!0),I);break;case e.INTERACTION.PENDLE_YT_IN_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_YT_OUT_SWAP:break;case e.INTERACTION.PENDLE_PT_SWAP:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_MINT:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_REDEEM:A[2]=N(A[2],T.getAmountAfterRelayAndFlatFees(A[2],r[2]),I);break;case e.INTERACTION.PENDLE_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break;case e.INTERACTION.PENDLE_LP:{const E=A.findIndex(R=>R>0n);A[E]=N(A[E],T.getAmountAfterRelayAndFlatFeesAndSlippage(A[E],r[E],c.SlippageType.Pendle));break}case e.INTERACTION.PENDLE_LP_CLAIM:A[1]=N(A[1],T.getAmountAfterRelayAndFlatFees(A[1],r[1]),I);break}return A};exports.processAmountChanges=F;
|
|
@@ -5,6 +5,7 @@ import "ethers";
|
|
|
5
5
|
import "axios";
|
|
6
6
|
import "../../constants/chains.constants.mjs";
|
|
7
7
|
import "../../constants/vite.constants.mjs";
|
|
8
|
+
import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
8
9
|
import { isBeefyDeposit as R } from "../../types/beefy.types.mjs";
|
|
9
10
|
import "../../types/circom-data.types.mjs";
|
|
10
11
|
import { INTERACTION as c } from "../../types/hinkal.types.mjs";
|
|
@@ -22,7 +23,7 @@ const p = (D, r, E) => {
|
|
|
22
23
|
feeUnit: E
|
|
23
24
|
});
|
|
24
25
|
return r;
|
|
25
|
-
},
|
|
26
|
+
}, $ = ({
|
|
26
27
|
erc20Addresses: D = [],
|
|
27
28
|
amountChanges: r,
|
|
28
29
|
flatFees: E,
|
|
@@ -210,5 +211,5 @@ const p = (D, r, E) => {
|
|
|
210
211
|
return r;
|
|
211
212
|
};
|
|
212
213
|
export {
|
|
213
|
-
|
|
214
|
+
$ as processAmountChanges
|
|
214
215
|
};
|
|
@@ -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?.symbol.toLowerCase()==="weth"&&console.log("token:",r),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},
|
|
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("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.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?.symbol.toLowerCase()==="weth"&&console.log("token:",r),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;
|
|
@@ -19,20 +19,21 @@ import "../../data-structures/crypto-keys/keys.mjs";
|
|
|
19
19
|
import "idb-keyval";
|
|
20
20
|
import "../utils/external-action.utils.mjs";
|
|
21
21
|
import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
|
|
22
|
+
import "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
22
23
|
import "../utils/convertIntegrationProviderToExternalActionId.mjs";
|
|
23
24
|
import "axios";
|
|
24
25
|
import "../utils/userAgent.mjs";
|
|
25
26
|
import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
26
27
|
import "../../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
27
28
|
import { isInEnum as w } from "../utils/enum.utils.mjs";
|
|
28
|
-
function
|
|
29
|
+
function j(e) {
|
|
29
30
|
if (!e)
|
|
30
31
|
return;
|
|
31
32
|
const r = T(e.address, e.chainId);
|
|
32
33
|
if (!r?.isVolatile)
|
|
33
34
|
return r?.symbol.toLowerCase() === "weth" && console.log("token:", r), r;
|
|
34
35
|
}
|
|
35
|
-
function
|
|
36
|
+
function z(e, r) {
|
|
36
37
|
if (!e || !r)
|
|
37
38
|
return;
|
|
38
39
|
let o;
|
|
@@ -55,7 +56,7 @@ function j(e, r) {
|
|
|
55
56
|
}
|
|
56
57
|
return o;
|
|
57
58
|
}
|
|
58
|
-
const
|
|
59
|
+
const H = (e, r, o) => {
|
|
59
60
|
if (i(e.yt.address, o.erc20TokenAddress))
|
|
60
61
|
return t.SwapExactTokenForYt;
|
|
61
62
|
if (i(e.pt.address, o.erc20TokenAddress))
|
|
@@ -64,7 +65,7 @@ const z = (e, r, o) => {
|
|
|
64
65
|
return t.SwapExactYtForToken;
|
|
65
66
|
if (i(e.pt.address, r.erc20TokenAddress))
|
|
66
67
|
return t.SwapExactPtForToken;
|
|
67
|
-
},
|
|
68
|
+
}, J = (e) => {
|
|
68
69
|
let r;
|
|
69
70
|
switch (e) {
|
|
70
71
|
case t.SwapExactTokenForYt:
|
|
@@ -83,7 +84,7 @@ const z = (e, r, o) => {
|
|
|
83
84
|
throw new Error("Cant determine Pendle Swap Type Api Route");
|
|
84
85
|
}
|
|
85
86
|
return r;
|
|
86
|
-
},
|
|
87
|
+
}, K = (e, r, o, s) => {
|
|
87
88
|
if (!w(p, e))
|
|
88
89
|
throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
|
|
89
90
|
if (s)
|
|
@@ -97,9 +98,9 @@ const z = (e, r, o) => {
|
|
|
97
98
|
return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (c = l), c;
|
|
98
99
|
};
|
|
99
100
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
H as determinePendleSwapType,
|
|
102
|
+
J as determinePendleSwapTypeApiRoute,
|
|
103
|
+
j as erc20TokenFromPendleAsset,
|
|
104
|
+
z as getAssetTypeFromPendleMarket,
|
|
105
|
+
K as getTokenIndexForPendleFlatFee
|
|
105
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("ethers"),u=require("../../constants/protocol.constants.cjs"),c=require("../../data-structures/crypto-keys/keys.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs"),o=require("ethers"),u=require("../../constants/protocol.constants.cjs"),c=require("../../data-structures/crypto-keys/keys.cjs"),S=require("../../data-structures/crypto-keys/encryptDecryptUtxo.cjs"),m=require("../../types/circom-data.types.cjs"),A=require("../utils/external-action.utils.cjs"),C=(t,e)=>t.map((r,n)=>r.map(s=>e[n]?"0":s.getNullifier())),p=(t,e)=>t.map((r,n)=>r.map(s=>e[n]?"0":s.getCommitment())),b=(t,e,r=!1)=>{const n=[];for(let s=0;s<t.length;s+=1){let i=0n,l=0n;for(let a=0;a<t[s].length;a+=1)i+=t[s][a].amount;for(let a=0;a<e[s].length;a+=1)l+=e[s][a].amount;l-i<0?r?n.push(l-i):n.push(u.CIRCOM_P+(l-i)):n.push(l-i)}return n},H=(t,e)=>{const r=[[""]];for(let n=0;n<t.length;n+=1)n>0&&r.push([""]),t[n].forEach((s,i)=>{r[n][i]=`0x${h.from(S.encryptUtxo(s,e)).toString("hex")}`});return r},f=(t,e)=>{const r=[];for(let s=0;s<t.length;s+=1){r.push([]);for(let i=0;i<t[s].length;i+=1)r[s][i]=e.getSiblingHashesForVerification(BigInt(t[s][i].getCommitment())).map(l=>l.toString())}const n=[];for(let s=0;s<t.length;s+=1){n.push([]);for(let i=0;i<t[s].length;i+=1)n[s][i]=e.getSiblingSides(BigInt(t[s][i].getCommitment())).map(l=>l.toString())}return{inCommitmentSiblings:r,inCommitmentSiblingSides:n}},y=(t,e)=>{const r=e.getSiblingHashesForVerification(BigInt(t.getAccessKey())).map(s=>s.toString()),n=e.getSiblingSides(BigInt(t.getAccessKey())).map(s=>s.toString());return{accessTokenSiblings:r,accessTokenSiblingSides:n}},I=t=>{const e={...t};return e.amountChanges=t.amountChanges.map(r=>r.toString()),e.calldataHash=t.calldataHash.toString(),e.rootHashAccessToken=t.rootHashAccessToken?.toString(),e.stealthAddressStructure.extraRandomization=t.stealthAddressStructure.extraRandomization.toString(),e.stealthAddressStructure.stealthAddress=t.stealthAddressStructure.stealthAddress.toString(),e.stealthAddressStructure.H0=t.stealthAddressStructure.H0.toString(),e.stealthAddressStructure.H1=t.stealthAddressStructure.H1.toString(),e.rootHashHinkal=t.rootHashHinkal?.toString(),e.externalActionId=t.externalActionId?.toString(),e.flatFees=t.flatFees.map(r=>r.toString()),e},k=t=>{const e={...t};return e.amountChanges=t.amountChanges.map(r=>BigInt(r)),e.calldataHash=BigInt(t.calldataHash),e.rootHashAccessToken=BigInt(t.rootHashAccessToken),e.rootHashHinkal=BigInt(t.rootHashHinkal),e.externalActionId=BigInt(t.externalActionId),e},B=(t,e,r,n,s,i,l,a)=>{const d=Object.values(a||m.defaultHookData),g=o.ethers.utils.defaultAbiCoder.encode(["uint16","address","address","uint256","bytes","tuple(address, address, bytes, bytes)","bytes[][]","uint256[]"],[t,e,r,typeof n=="bigint"?n:A.getExternalActionIdHash(n),s,d,i,l]);return BigInt(o.ethers.utils.keccak256(g))%u.CIRCOM_P},O=t=>t.startsWith("swapperMO")||t.startsWith("swapperME")?2:t.startsWith("swapperMW")?1:0,T=(t,e,r,n,s,i)=>{const l=O(t);return 9+e.length+r.length+n.flat().length+s.length+l+i},q=(t,e)=>{const{h0:r,h1:n}=c.UserKeys.getStealthAddressCompressedPoints(t,e),s=BigInt(c.UserKeys.getStealthAddress(t,e));return{extraRandomization:t,H0:r,H1:n,stealthAddress:s}};exports.buildInNullifiers=C;exports.buildOutCommitments=p;exports.calcAccessTokenSiblingsAndSides=y;exports.calcAmountChanges=b;exports.calcCommitmentsSiblingAndSides=f;exports.calcEncryptedOutputs=H;exports.calcPublicSignalCount=T;exports.calcStealthAddressStructure=q;exports.createCallDataHash=B;exports.deserializeCircomData=k;exports.serializeCircomData=I;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import h from "../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
|
|
1
2
|
import { ethers as i } from "ethers";
|
|
2
3
|
import { CIRCOM_P as u } from "../../constants/protocol.constants.mjs";
|
|
3
4
|
import { UserKeys as g } from "../../data-structures/crypto-keys/keys.mjs";
|
|
4
|
-
import { encryptUtxo as
|
|
5
|
-
import { defaultHookData as
|
|
6
|
-
import { getExternalActionIdHash as
|
|
7
|
-
const
|
|
5
|
+
import { encryptUtxo as S } from "../../data-structures/crypto-keys/encryptDecryptUtxo.mjs";
|
|
6
|
+
import { defaultHookData as m } from "../../types/circom-data.types.mjs";
|
|
7
|
+
import { getExternalActionIdHash as f } from "../utils/external-action.utils.mjs";
|
|
8
|
+
const y = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier())), O = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getCommitment())), T = (t, e, r = !1) => {
|
|
8
9
|
const n = [];
|
|
9
10
|
for (let s = 0; s < t.length; s += 1) {
|
|
10
11
|
let o = 0n, l = 0n;
|
|
@@ -15,14 +16,14 @@ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier()))
|
|
|
15
16
|
l - o < 0 ? r ? n.push(l - o) : n.push(u + (l - o)) : n.push(l - o);
|
|
16
17
|
}
|
|
17
18
|
return n;
|
|
18
|
-
},
|
|
19
|
+
}, j = (t, e) => {
|
|
19
20
|
const r = [[""]];
|
|
20
21
|
for (let n = 0; n < t.length; n += 1)
|
|
21
22
|
n > 0 && r.push([""]), t[n].forEach((s, o) => {
|
|
22
|
-
r[n][o] = `0x${
|
|
23
|
+
r[n][o] = `0x${h.from(S(s, e)).toString("hex")}`;
|
|
23
24
|
});
|
|
24
25
|
return r;
|
|
25
|
-
},
|
|
26
|
+
}, E = (t, e) => {
|
|
26
27
|
const r = [];
|
|
27
28
|
for (let s = 0; s < t.length; s += 1) {
|
|
28
29
|
r.push([]);
|
|
@@ -36,17 +37,17 @@ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier()))
|
|
|
36
37
|
n[s][o] = e.getSiblingSides(BigInt(t[s][o].getCommitment())).map((l) => l.toString());
|
|
37
38
|
}
|
|
38
39
|
return { inCommitmentSiblings: r, inCommitmentSiblingSides: n };
|
|
39
|
-
},
|
|
40
|
+
}, F = (t, e) => {
|
|
40
41
|
const r = e.getSiblingHashesForVerification(BigInt(t.getAccessKey())).map((s) => s.toString()), n = e.getSiblingSides(BigInt(t.getAccessKey())).map((s) => s.toString());
|
|
41
42
|
return { accessTokenSiblings: r, accessTokenSiblingSides: n };
|
|
42
|
-
},
|
|
43
|
+
}, M = (t) => {
|
|
43
44
|
const e = { ...t };
|
|
44
45
|
return e.amountChanges = t.amountChanges.map((r) => r.toString()), e.calldataHash = t.calldataHash.toString(), e.rootHashAccessToken = t.rootHashAccessToken?.toString(), e.stealthAddressStructure.extraRandomization = t.stealthAddressStructure.extraRandomization.toString(), e.stealthAddressStructure.stealthAddress = t.stealthAddressStructure.stealthAddress.toString(), e.stealthAddressStructure.H0 = t.stealthAddressStructure.H0.toString(), e.stealthAddressStructure.H1 = t.stealthAddressStructure.H1.toString(), e.rootHashHinkal = t.rootHashHinkal?.toString(), e.externalActionId = t.externalActionId?.toString(), e.flatFees = t.flatFees.map((r) => r.toString()), e;
|
|
45
|
-
},
|
|
46
|
+
}, W = (t) => {
|
|
46
47
|
const e = { ...t };
|
|
47
48
|
return e.amountChanges = t.amountChanges.map((r) => BigInt(r)), e.calldataHash = BigInt(t.calldataHash), e.rootHashAccessToken = BigInt(t.rootHashAccessToken), e.rootHashHinkal = BigInt(t.rootHashHinkal), e.externalActionId = BigInt(t.externalActionId), e;
|
|
48
|
-
},
|
|
49
|
-
const d = Object.values(a ||
|
|
49
|
+
}, w = (t, e, r, n, s, o, l, a) => {
|
|
50
|
+
const d = Object.values(a || m), c = i.utils.defaultAbiCoder.encode(
|
|
50
51
|
[
|
|
51
52
|
"uint16",
|
|
52
53
|
"address",
|
|
@@ -61,7 +62,7 @@ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier()))
|
|
|
61
62
|
t,
|
|
62
63
|
e,
|
|
63
64
|
r,
|
|
64
|
-
typeof n == "bigint" ? n :
|
|
65
|
+
typeof n == "bigint" ? n : f(n),
|
|
65
66
|
s,
|
|
66
67
|
d,
|
|
67
68
|
o,
|
|
@@ -69,10 +70,10 @@ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier()))
|
|
|
69
70
|
]
|
|
70
71
|
);
|
|
71
72
|
return BigInt(i.utils.keccak256(c)) % u;
|
|
72
|
-
},
|
|
73
|
-
const l =
|
|
73
|
+
}, p = (t) => t.startsWith("swapperMO") || t.startsWith("swapperME") ? 2 : t.startsWith("swapperMW") ? 1 : 0, z = (t, e, r, n, s, o) => {
|
|
74
|
+
const l = p(t);
|
|
74
75
|
return 9 + e.length + r.length + n.flat().length + s.length + l + o;
|
|
75
|
-
},
|
|
76
|
+
}, P = (t, e) => {
|
|
76
77
|
const { h0: r, h1: n } = g.getStealthAddressCompressedPoints(t, e), s = BigInt(g.getStealthAddress(t, e));
|
|
77
78
|
return {
|
|
78
79
|
extraRandomization: t,
|
|
@@ -82,15 +83,15 @@ const k = (t, e) => t.map((r, n) => r.map((s) => e[n] ? "0" : s.getNullifier()))
|
|
|
82
83
|
};
|
|
83
84
|
};
|
|
84
85
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
86
|
+
y as buildInNullifiers,
|
|
87
|
+
O as buildOutCommitments,
|
|
88
|
+
F as calcAccessTokenSiblingsAndSides,
|
|
89
|
+
T as calcAmountChanges,
|
|
90
|
+
E as calcCommitmentsSiblingAndSides,
|
|
91
|
+
j as calcEncryptedOutputs,
|
|
92
|
+
z as calcPublicSignalCount,
|
|
93
|
+
P as calcStealthAddressStructure,
|
|
94
|
+
w as createCallDataHash,
|
|
95
|
+
W as deserializeCircomData,
|
|
96
|
+
M as serializeCircomData
|
|
96
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.cjs"),i=require("ethers"),p=require("../../data-structures/crypto-keys/keys.cjs"),c=require("libsodium-wrappers"),d=require("../../crypto/poseidon.cjs");require("circomlibjs");const S=(e,t,r)=>{const n=i.ethers.utils.defaultAbiCoder.encode(["uint256","address"],[e,t]),a=c.crypto_box_seal(n,i.ethers.utils.arrayify(r));return`0x${s.from(a).toString("hex")}`},f=(e,t)=>{const r=s.from(e.slice(2),"hex"),{publicKey:n,privateKey:a}=p.UserKeys.getEncryptionKeyPair(t.getShieldedPrivateKey());try{const o=c.crypto_box_seal_open(r,i.ethers.utils.arrayify(n),i.ethers.utils.arrayify(a)),u=s.from(o).toString("utf-8"),[l,y]=i.ethers.utils.defaultAbiCoder.decode(["uint256","address"],u);return{stakeBlinding:l.toBigInt(),stakedTokenRecipient:y}}catch{console.log("failed to decrypt");return}},k=(e,t,r,n,a,o)=>BigInt(d.poseidonHash(...[e,t,r,n,a,o].map(BigInt))),g=(e,t)=>d.poseidonHash(e,t),h=(e,t,r,n,a)=>i.ethers.utils.defaultAbiCoder.encode(["uint8","uint256","address","bytes","bytes"],[e,t,r,n,a]);exports.calculateStakeNullifier=g;exports.createStakeCommitment=k;exports.decryptStake=f;exports.encodeHStakeMetadata=h;exports.encryptStake=S;
|
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import s from "../../node_modules/vite-plugin-node-polyfills/shims/buffer/dist/index.mjs";
|
|
2
|
+
import { ethers as n } from "ethers";
|
|
3
|
+
import { UserKeys as l } from "../../data-structures/crypto-keys/keys.mjs";
|
|
4
|
+
import c from "libsodium-wrappers";
|
|
5
|
+
import { poseidonHash as d } from "../../crypto/poseidon.mjs";
|
|
5
6
|
import "circomlibjs";
|
|
6
|
-
const
|
|
7
|
-
const o =
|
|
7
|
+
const h = (t, e, r) => {
|
|
8
|
+
const o = n.utils.defaultAbiCoder.encode(
|
|
8
9
|
["uint256", "address"],
|
|
9
10
|
[t, e]
|
|
10
|
-
),
|
|
11
|
-
return `0x${
|
|
12
|
-
},
|
|
13
|
-
const r =
|
|
11
|
+
), i = c.crypto_box_seal(o, n.utils.arrayify(r));
|
|
12
|
+
return `0x${s.from(i).toString("hex")}`;
|
|
13
|
+
}, x = (t, e) => {
|
|
14
|
+
const r = s.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } = l.getEncryptionKeyPair(e.getShieldedPrivateKey());
|
|
14
15
|
try {
|
|
15
|
-
const a =
|
|
16
|
+
const a = c.crypto_box_seal_open(
|
|
16
17
|
r,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
),
|
|
18
|
+
n.utils.arrayify(o),
|
|
19
|
+
n.utils.arrayify(i)
|
|
20
|
+
), u = s.from(a).toString("utf-8"), [y, p] = n.utils.defaultAbiCoder.decode(
|
|
20
21
|
["uint256", "address"],
|
|
21
|
-
|
|
22
|
+
u
|
|
22
23
|
);
|
|
23
|
-
return { stakeBlinding:
|
|
24
|
+
return { stakeBlinding: y.toBigInt(), stakedTokenRecipient: p };
|
|
24
25
|
} catch {
|
|
25
26
|
console.log("failed to decrypt");
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
|
-
}, B = (t, e, r, o,
|
|
29
|
-
|
|
30
|
-
),
|
|
29
|
+
}, B = (t, e, r, o, i, a) => BigInt(
|
|
30
|
+
d(...[t, e, r, o, i, a].map(BigInt))
|
|
31
|
+
), K = (t, e) => d(t, e), _ = (t, e, r, o, i) => n.utils.defaultAbiCoder.encode(
|
|
31
32
|
["uint8", "uint256", "address", "bytes", "bytes"],
|
|
32
|
-
[t, e, r, o,
|
|
33
|
+
[t, e, r, o, i]
|
|
33
34
|
);
|
|
34
35
|
export {
|
|
35
|
-
|
|
36
|
+
K as calculateStakeNullifier,
|
|
36
37
|
B as createStakeCommitment,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
x as decryptStake,
|
|
39
|
+
_ as encodeHStakeMetadata,
|
|
40
|
+
h as encryptStake
|
|
40
41
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=()=>typeof
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),r=()=>typeof e.default<"u"&&e.default?.release?.name==="node";exports.isOnServer=r;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import e from "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
2
|
+
const n = () => typeof e < "u" && e?.release?.name === "node";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
n as isOnServer
|
|
4
5
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs"),o=t=>{const r=e.default.env[t];return r===void 0&&(console.log(`Error: ${t} environment variable not set`),e.default.exitCode=1,e.default.exit()),r};exports.requireEnv=o;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import o from "../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
2
|
+
const n = (r) => {
|
|
3
|
+
const e = o.env[r];
|
|
4
|
+
return e === void 0 && (console.log(`Error: ${r} environment variable not set`), o.exitCode = 1, o.exit()), e;
|
|
4
5
|
};
|
|
5
6
|
export {
|
|
6
|
-
|
|
7
|
+
n as requireEnv
|
|
7
8
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../../types/circom-data.types.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");require("../../../types/circom-data.types.cjs");const t=require("../../../types/hinkal.types.cjs");require("../../../types/transactions.types.cjs");require("../../../types/curve.types.cjs");const a=()=>{const e=t.EventType.BalanceChange;typeof document<"u"?document.dispatchEvent(new Event(e)):n.default?.emit("message",e,void 0)};exports.balanceChangedHandler=a;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import t from "../../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.mjs";
|
|
1
2
|
import "../../../types/circom-data.types.mjs";
|
|
2
3
|
import { EventType as n } from "../../../types/hinkal.types.mjs";
|
|
3
4
|
import "../../../types/transactions.types.mjs";
|
|
4
5
|
import "../../../types/curve.types.mjs";
|
|
5
|
-
const
|
|
6
|
+
const a = () => {
|
|
6
7
|
const e = n.BalanceChange;
|
|
7
|
-
typeof document < "u" ? document.dispatchEvent(new Event(e)) :
|
|
8
|
+
typeof document < "u" ? document.dispatchEvent(new Event(e)) : t?.emit("message", e, void 0);
|
|
8
9
|
};
|
|
9
10
|
export {
|
|
10
|
-
|
|
11
|
+
a as balanceChangedHandler
|
|
11
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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("../../node_modules/vite-plugin-node-polyfills/shims/process/dist/index.cjs");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: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;
|