@hinkal/common 0.0.113 → 0.0.115
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/assets/{snarkjsWorkerLauncher-fuD5h_j0.js → snarkjsWorkerLauncher-CaBCnle3.js} +283 -257
- package/assets/snarkjsWorkerLogic-BAbiO5gj.js +17935 -0
- package/assets/snarkjsWorkerLogic-wHJfYCfg.js +15636 -0
- package/assets/{utxoWorkerLogic-CtFLQiAX.js → utxoWorkerLogic-BGFm-Zl2.js} +2 -2
- package/assets/{zkProofWorkerLauncher-J3Ts5_Ba.js → zkProofWorkerLauncher-BteYxRBn.js} +1 -1
- package/assets/{zkProofWorkerLogic-CPNuu61R.js → zkProofWorkerLogic-DiLbAhAo.js} +8354 -8298
- package/common.mjs +644 -0
- package/common10.mjs +30 -0
- package/common100.mjs +156 -0
- package/common101.mjs +568 -0
- package/common102.mjs +1603 -0
- package/common103.mjs +1764 -0
- package/common104.mjs +2030 -0
- package/common105.mjs +701 -0
- package/common106.mjs +480 -0
- package/common107.mjs +2082 -0
- package/common108.mjs +39 -0
- package/common109.mjs +24 -0
- package/common11.mjs +30 -0
- package/common110.mjs +41 -0
- package/common111.mjs +206 -0
- package/common112.mjs +48 -0
- package/common113.mjs +39 -0
- package/common114.mjs +70 -0
- package/common115.mjs +67 -0
- package/common116.mjs +5 -0
- package/common117.mjs +61 -0
- package/common118.mjs +20 -0
- package/common119.mjs +7 -0
- package/common12.mjs +58 -0
- package/common120.mjs +22 -0
- package/common121.mjs +16 -0
- package/common122.mjs +57 -0
- package/common123.mjs +45 -0
- package/common124.mjs +57 -0
- package/common125.mjs +229 -0
- package/common126.mjs +203 -0
- package/common127.mjs +29 -0
- package/common128.mjs +38 -0
- package/common129.mjs +15 -0
- package/common13.mjs +156 -0
- package/common130.mjs +105 -0
- package/common131.mjs +4 -0
- package/common132.mjs +14 -0
- package/common133.mjs +7 -0
- package/common134.mjs +6 -0
- package/common135.mjs +8 -0
- package/common136.mjs +40 -0
- package/common137.mjs +41 -0
- package/common138.mjs +72 -0
- package/common139.mjs +107 -0
- package/common14.mjs +32 -0
- package/common140.mjs +9 -0
- package/common141.mjs +10 -0
- package/common142.mjs +97 -0
- package/common143.mjs +65 -0
- package/common144.mjs +61 -0
- package/common145.mjs +95 -0
- package/common146.mjs +129 -0
- package/common147.mjs +105 -0
- package/common148.mjs +96 -0
- package/common149.mjs +18 -0
- package/common15.mjs +16 -0
- package/common150.mjs +45 -0
- package/common151.mjs +41 -0
- package/common152.mjs +108 -0
- package/common153.mjs +40 -0
- package/common154.mjs +19 -0
- package/common155.mjs +24 -0
- package/common156.mjs +21 -0
- package/common157.mjs +22 -0
- package/common158.mjs +4 -0
- package/common159.mjs +4 -0
- package/common16.mjs +6 -0
- package/common160.mjs +15 -0
- package/common161.mjs +13 -0
- package/common162.mjs +4 -0
- package/common163.mjs +15 -0
- package/common164.mjs +36 -0
- package/common165.mjs +58 -0
- package/common166.mjs +27 -0
- package/common167.mjs +15 -0
- package/common168.mjs +25 -0
- package/common169.mjs +4 -0
- package/common17.mjs +6877 -0
- package/common170.mjs +85 -0
- package/common171.mjs +2251 -0
- package/common172.mjs +856 -0
- package/common173.mjs +973 -0
- package/common174.mjs +1255 -0
- package/common175.mjs +591 -0
- package/common176.mjs +1392 -0
- package/common177.mjs +463 -0
- package/common178.mjs +137 -0
- package/common179.mjs +2700 -0
- package/common18.mjs +7415 -0
- package/common180.mjs +946 -0
- package/common181.mjs +973 -0
- package/common182.mjs +1327 -0
- package/common183.mjs +591 -0
- package/common184.mjs +1455 -0
- package/common185.mjs +490 -0
- package/common186.mjs +137 -0
- package/common187.mjs +2768 -0
- package/common188.mjs +8 -0
- package/common189.mjs +14 -0
- package/common19.mjs +11427 -0
- package/common190.mjs +115623 -0
- package/common191.mjs +42 -0
- package/common192.mjs +1022 -0
- package/common193.mjs +1423 -0
- package/common194.mjs +208 -0
- package/common195.mjs +340 -0
- package/common196.mjs +674 -0
- package/common197.mjs +1002 -0
- package/common198.mjs +883 -0
- package/common199.mjs +262 -0
- package/common2.mjs +67 -0
- package/common20.mjs +7417 -0
- package/common200.mjs +264 -0
- package/common201.mjs +173 -0
- package/common202.mjs +999 -0
- package/common203.mjs +80 -0
- package/common204.mjs +56 -0
- package/common205.mjs +42 -0
- package/common206.mjs +14 -0
- package/common207.mjs +4 -0
- package/common208.mjs +62 -0
- package/common209.mjs +4 -0
- package/common21.mjs +7439 -0
- package/common210.mjs +4 -0
- package/common211.mjs +58 -0
- package/common212.mjs +40 -0
- package/common213.mjs +45 -0
- package/common214.mjs +36 -0
- package/common215.mjs +32 -0
- package/common216.mjs +44 -0
- package/common217.mjs +32 -0
- package/common218.mjs +38 -0
- package/common219.mjs +9 -0
- package/common22.mjs +7411 -0
- package/common220.mjs +32 -0
- package/common221.mjs +47 -0
- package/common222.mjs +14 -0
- package/common223.mjs +30 -0
- package/common224.mjs +91 -0
- package/common225.mjs +112 -0
- package/common226.mjs +96 -0
- package/common227.mjs +30 -0
- package/common228.mjs +138 -0
- package/common229.mjs +18 -0
- package/common23.mjs +8425 -0
- package/common230.mjs +42 -0
- package/common231.mjs +60 -0
- package/common232.mjs +48 -0
- package/common233.mjs +47 -0
- package/common234.mjs +44 -0
- package/common235.mjs +74 -0
- package/common236.mjs +4 -0
- package/common237.mjs +60 -0
- package/common238.mjs +4 -0
- package/common239.mjs +30 -0
- package/common24.mjs +9600 -0
- package/common240.mjs +4 -0
- package/common241.mjs +153 -0
- package/common242.mjs +31 -0
- package/common243.mjs +30 -0
- package/common244.mjs +68 -0
- package/common245.mjs +57 -0
- package/common246.mjs +97 -0
- package/common247.mjs +36 -0
- package/common248.mjs +43 -0
- package/common249.mjs +44 -0
- package/common25.mjs +13283 -0
- package/common250.mjs +59 -0
- package/common251.mjs +75 -0
- package/{snarkjsWorkerLogic-CVna_BW9.mjs → common252.mjs} +1 -1
- package/common253.mjs +66 -0
- package/common254.mjs +70 -0
- package/common255.mjs +211 -0
- package/common256.mjs +8 -0
- package/{workerProxy-BDj498Ht.mjs → common257.mjs} +1 -1
- package/common26.mjs +4329 -0
- package/common27.mjs +4329 -0
- package/common28.mjs +204 -0
- package/common29.mjs +57 -0
- package/common3.mjs +27 -0
- package/common30.mjs +276 -0
- package/common31.mjs +118 -0
- package/common32.mjs +157 -0
- package/common33.mjs +29 -0
- package/common34.mjs +26 -0
- package/common35.mjs +53 -0
- package/common36.mjs +55 -0
- package/common37.mjs +18 -0
- package/common38.mjs +636 -0
- package/common39.mjs +24 -0
- package/common4.mjs +37 -0
- package/common40.mjs +13 -0
- package/common41.mjs +27 -0
- package/common42.mjs +15 -0
- package/common43.mjs +24 -0
- package/common44.mjs +253 -0
- package/common45.mjs +26 -0
- package/common46.mjs +15 -0
- package/common47.mjs +9 -0
- package/common48.mjs +25 -0
- package/common49.mjs +40 -0
- package/common5.mjs +37 -0
- package/common50.mjs +41 -0
- package/common51.mjs +90 -0
- package/common52.mjs +10 -0
- package/common53.mjs +299 -0
- package/common54.mjs +101 -0
- package/common55.mjs +83 -0
- package/common56.mjs +112 -0
- package/common57.mjs +140 -0
- package/common58.mjs +95 -0
- package/common59.mjs +98 -0
- package/common6.mjs +32 -0
- package/common60.mjs +5 -0
- package/common61.mjs +91 -0
- package/common62.mjs +66 -0
- package/common63.mjs +49 -0
- package/common64.mjs +177 -0
- package/common65.mjs +8 -0
- package/common66.mjs +131 -0
- package/common67.mjs +132 -0
- package/common68.mjs +59 -0
- package/common69.mjs +35 -0
- package/common7.mjs +37 -0
- package/common70.mjs +118 -0
- package/common71.mjs +134 -0
- package/common72.mjs +33 -0
- package/common73.mjs +29 -0
- package/common74.mjs +218 -0
- package/common75.mjs +194 -0
- package/common76.mjs +62 -0
- package/common77.mjs +181 -0
- package/common78.mjs +83 -0
- package/common79.mjs +9 -0
- package/common8.mjs +38 -0
- package/common80.mjs +21 -0
- package/common81.mjs +184 -0
- package/common82.mjs +53 -0
- package/common83.mjs +35 -0
- package/common84.mjs +7 -0
- package/common85.mjs +4 -0
- package/common86.mjs +350 -0
- package/common87.mjs +570 -0
- package/common88.mjs +519 -0
- package/common89.mjs +1422 -0
- package/common9.mjs +41 -0
- package/common90.mjs +1136 -0
- package/common91.mjs +334 -0
- package/common92.mjs +291 -0
- package/common93.mjs +205 -0
- package/common94.mjs +201 -0
- package/common95.mjs +89 -0
- package/common96.mjs +721 -0
- package/common97.mjs +346 -0
- package/common98.mjs +542 -0
- package/common99.mjs +393 -0
- package/package.json +4 -4
- package/assets/snarkjsWorkerLogic-B6N4z_eM.js +0 -12136
- package/assets/snarkjsWorkerLogic-Fv0M38Mc.js +0 -12087
- package/index-DXElTGy9.mjs +0 -254449
- package/index.js +0 -457
- package/utxoWorkerLogic-B1Hh-bq4.mjs +0 -64
- package/zkProofWorkerLogic-D9rxuuiK.mjs +0 -60
package/common71.mjs
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ethers as y } from "ethers";
|
|
2
|
+
import { CIRCOM_P as o } from "./common34.mjs";
|
|
3
|
+
import { poseidonHash as a } from "./common45.mjs";
|
|
4
|
+
import { randomBigInt as S } from "./common137.mjs";
|
|
5
|
+
import { UserKeys as d } from "./common51.mjs";
|
|
6
|
+
class h {
|
|
7
|
+
amount;
|
|
8
|
+
erc20TokenAddress;
|
|
9
|
+
timeStamp;
|
|
10
|
+
tokenId;
|
|
11
|
+
shieldedPrivateKey;
|
|
12
|
+
// 1) if it's own UTXO one provides private key and randomization -> computes stealth address and and eKey
|
|
13
|
+
randomization;
|
|
14
|
+
stealthAddress;
|
|
15
|
+
// 2) if it's other's utxo, stealth address and encryption key should be provided
|
|
16
|
+
encryptionKey;
|
|
17
|
+
commitment;
|
|
18
|
+
// computed
|
|
19
|
+
nullifier;
|
|
20
|
+
// computed
|
|
21
|
+
isStake;
|
|
22
|
+
isStakeOrUnstakeInput;
|
|
23
|
+
isUnstakeOutput;
|
|
24
|
+
/**
|
|
25
|
+
* creates new UTXO instance
|
|
26
|
+
* @param amount UTXO amount
|
|
27
|
+
* @param erc20TokenAddress contract address of ERC-20/ERC-721 token
|
|
28
|
+
* @param timeStamp timestamp
|
|
29
|
+
* @param tokenId tokenId
|
|
30
|
+
* @param randomization randomization parameter
|
|
31
|
+
* @param stealthAddress stealth address as a parameter(e.g. in case of transfers we will not know private key and randomization of payee
|
|
32
|
+
* @param encryptionKey encryption public key
|
|
33
|
+
* @param shieldedPrivateKey private key for nullification
|
|
34
|
+
* @param commitment [optional] commitment value if already computed
|
|
35
|
+
* @param nullifier [optional] nullifier value if already computed
|
|
36
|
+
*/
|
|
37
|
+
constructor({
|
|
38
|
+
amount: t,
|
|
39
|
+
erc20TokenAddress: e,
|
|
40
|
+
timeStamp: s,
|
|
41
|
+
tokenId: i,
|
|
42
|
+
shieldedPrivateKey: r,
|
|
43
|
+
randomization: n,
|
|
44
|
+
stealthAddress: m,
|
|
45
|
+
encryptionKey: l,
|
|
46
|
+
commitment: u = void 0,
|
|
47
|
+
nullifier: c = void 0,
|
|
48
|
+
isStake: p = !1,
|
|
49
|
+
isStakeOrUnstakeInput: k = !1,
|
|
50
|
+
isUnstakeOutput: f = !1
|
|
51
|
+
}) {
|
|
52
|
+
this.amount = t, this.erc20TokenAddress = e, this.timeStamp = s ?? Math.floor(Date.now() / 1e3).toString(), this.tokenId = i ?? 0, this.shieldedPrivateKey = r, this.randomization = n ?? h.findCorrectRandomization(S(31), r), this.stealthAddress = m, this.encryptionKey = l, this.commitment = u, this.nullifier = c, this.isStake = p, this.isStakeOrUnstakeInput = k, this.isUnstakeOutput = f;
|
|
53
|
+
}
|
|
54
|
+
static createFrom(t, e) {
|
|
55
|
+
return new h({
|
|
56
|
+
...t.getConstructableParams(),
|
|
57
|
+
nullifier: void 0,
|
|
58
|
+
commitment: void 0,
|
|
59
|
+
...e
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
getConstructableParams() {
|
|
63
|
+
return {
|
|
64
|
+
amount: this.amount,
|
|
65
|
+
erc20TokenAddress: this.erc20TokenAddress,
|
|
66
|
+
timeStamp: this.timeStamp,
|
|
67
|
+
shieldedPrivateKey: this.shieldedPrivateKey,
|
|
68
|
+
randomization: this.randomization,
|
|
69
|
+
stealthAddress: this.stealthAddress,
|
|
70
|
+
encryptionKey: this.encryptionKey,
|
|
71
|
+
tokenId: this.tokenId,
|
|
72
|
+
commitment: this.commitment,
|
|
73
|
+
nullifier: this.nullifier,
|
|
74
|
+
isStake: this.isStake,
|
|
75
|
+
isStakeOrUnstakeInput: this.isStakeOrUnstakeInput,
|
|
76
|
+
isUnstakeOutput: this.isUnstakeOutput
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @returns commitment hash of the UTXO instance
|
|
81
|
+
*/
|
|
82
|
+
getCommitment() {
|
|
83
|
+
if (!this.commitment) {
|
|
84
|
+
const t = [this.amount, this.erc20TokenAddress, BigInt(this.getStealthAddress()), this.timeStamp];
|
|
85
|
+
this.tokenId > 0 && t.push(this.tokenId.toString()), (this.isStake || this.isUnstakeOutput) && t.push(0n, 1n), this.commitment = a(...t);
|
|
86
|
+
}
|
|
87
|
+
return this.commitment;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @returns nullifier hash of the UTXO instance
|
|
91
|
+
*/
|
|
92
|
+
getNullifier() {
|
|
93
|
+
if (!this.nullifier) {
|
|
94
|
+
if (!this.shieldedPrivateKey)
|
|
95
|
+
throw new Error("No Nullifiers if private key is not provided");
|
|
96
|
+
const t = a(this.shieldedPrivateKey, this.getCommitment()), e = BigInt(a(this.commitment, t)), s = BigInt(this.isStakeOrUnstakeInput);
|
|
97
|
+
this.nullifier = y.BigNumber.from(e + s).toHexString();
|
|
98
|
+
}
|
|
99
|
+
return this.nullifier;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @returns stealth address from randomization and private shieldedPrivateKey
|
|
103
|
+
*/
|
|
104
|
+
getStealthAddress() {
|
|
105
|
+
if (!this.stealthAddress) {
|
|
106
|
+
if (!this.shieldedPrivateKey)
|
|
107
|
+
throw Error("No stealth address in UTXO if private key is not provided");
|
|
108
|
+
const t = d.getStealthAddress(this.randomization, this.shieldedPrivateKey);
|
|
109
|
+
this.stealthAddress = t;
|
|
110
|
+
}
|
|
111
|
+
return this.stealthAddress;
|
|
112
|
+
}
|
|
113
|
+
getEncryptionKey() {
|
|
114
|
+
if (!this.shieldedPrivateKey) {
|
|
115
|
+
if (!this.encryptionKey)
|
|
116
|
+
throw Error("No encryption key provided in UTXO");
|
|
117
|
+
return this.encryptionKey;
|
|
118
|
+
}
|
|
119
|
+
return d.getEncryptionKeyPair(this.shieldedPrivateKey).publicKey;
|
|
120
|
+
}
|
|
121
|
+
static findCorrectRandomization(t, e) {
|
|
122
|
+
if (!e)
|
|
123
|
+
throw Error("No Private Shielded Key Provided");
|
|
124
|
+
const s = BigInt(e) % o;
|
|
125
|
+
let i, r, n = 0n;
|
|
126
|
+
do
|
|
127
|
+
i = t * 10n ** n % o, r = i * s % o, n += 1n;
|
|
128
|
+
while (r >= 2n ** 253n || i >= 2n ** 253n);
|
|
129
|
+
return i;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export {
|
|
133
|
+
h as Utxo
|
|
134
|
+
};
|
package/common72.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
class o {
|
|
2
|
+
localStorageKey = "tokenRegistry";
|
|
3
|
+
tokenRegistry;
|
|
4
|
+
constructor() {
|
|
5
|
+
if (this.tokenRegistry = [], typeof localStorage < "u") {
|
|
6
|
+
const t = localStorage.getItem(this.localStorageKey);
|
|
7
|
+
t && (this.tokenRegistry = JSON.parse(t));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
persistRegistry() {
|
|
11
|
+
typeof localStorage < "u" && localStorage.setItem(this.localStorageKey, JSON.stringify(this.tokenRegistry));
|
|
12
|
+
}
|
|
13
|
+
getCustomTokens(t) {
|
|
14
|
+
return this.tokenRegistry.filter((s) => s.chainId === t);
|
|
15
|
+
}
|
|
16
|
+
tokenExists(t, s) {
|
|
17
|
+
return t.find(
|
|
18
|
+
(e) => e.erc20TokenAddress === s.erc20TokenAddress || e.symbol === s.symbol || e.name === s.name
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
addCustomToken(t) {
|
|
22
|
+
const { chainId: s } = t, e = this.getCustomTokens(s);
|
|
23
|
+
this.tokenExists(e, t) || this.tokenRegistry.push(t), this.persistRegistry();
|
|
24
|
+
}
|
|
25
|
+
removeCustomToken(t) {
|
|
26
|
+
const { chainId: s } = t, r = this.getCustomTokens(s).filter((i) => i.erc20TokenAddress !== t.erc20TokenAddress);
|
|
27
|
+
this.tokenRegistry = r, this.persistRegistry();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const g = new o();
|
|
31
|
+
export {
|
|
32
|
+
g as customTokenRegistry
|
|
33
|
+
};
|
package/common73.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { lowerCaseIncludes as a } from "./common134.mjs";
|
|
2
|
+
import { wstEthSymbol as r, stMaticSymbol as o } from "./common40.mjs";
|
|
3
|
+
import { chainIds as T } from "./common28.mjs";
|
|
4
|
+
class m {
|
|
5
|
+
static isCurveLPToken = (s, e) => a(e, s.erc20TokenAddress);
|
|
6
|
+
static isCurveStakeToken = (s) => s.name.includes("Gauge") && s.symbol.includes("-gauge");
|
|
7
|
+
static isConvexToken = (s) => s.name.includes("Convex") && s.symbol.includes("cvx");
|
|
8
|
+
static isBeefyLpToken = (s) => s.name.startsWith("moo") && s.symbol.startsWith("moo");
|
|
9
|
+
static isBeefyStakeToken = (s) => s.name.includes("-Boost") && s.symbol.includes("-Boost");
|
|
10
|
+
static isLidoToken = (s) => s.symbol === r || s.symbol === o;
|
|
11
|
+
static isCurveOrConvex = (s, e) => this.isCurveLPToken(s, e) || this.isCurveStakeToken(s) || this.isConvexToken(s);
|
|
12
|
+
static isBeefyToken = (s) => this.isBeefyLpToken(s) || this.isBeefyStakeToken(s);
|
|
13
|
+
static isStakeToken = (s) => this.isCurveStakeToken(s) || this.isConvexToken(s) || this.isBeefyStakeToken(s);
|
|
14
|
+
static isPendleYtToken = (s) => s.name.startsWith("Pendle-YT-") && s.symbol.startsWith("Pendle-YT-");
|
|
15
|
+
static isPendleLPToken = (s) => s.name.startsWith("Pendle-LP-") && s.symbol.startsWith("Pendle-LP-");
|
|
16
|
+
static isPendleSyToken = (s) => s.name.startsWith("SY ") && s.symbol.includes("SY-");
|
|
17
|
+
static isPendleNativeToken = (s) => {
|
|
18
|
+
const e = s.name.startsWith("YT ") && s.symbol.includes("YT-"), i = this.isPendleSyToken(s), t = s.name.startsWith("PT ") && s.symbol.includes("PT-"), n = s.name.startsWith("LP ") && s.symbol.includes("LP-");
|
|
19
|
+
return e || i || t || n;
|
|
20
|
+
};
|
|
21
|
+
static isPendleToken = (s) => this.isPendleYtToken(s) || this.isPendleLPToken(s) || this.isPendleNativeToken(s);
|
|
22
|
+
static isAaveToken = (s) => s.aaveToken;
|
|
23
|
+
static isNonRebasingBlastToken = (s) => s.chainId === T.blast && s.symbol.startsWith("nr");
|
|
24
|
+
static isKinzaToken = (s) => s.name.startsWith("Kinza");
|
|
25
|
+
static isProtocolToken = (s, e) => this.isCurveLPToken(s, e) || this.isCurveStakeToken(s) || this.isConvexToken(s) || this.isBeefyLpToken(s) || this.isBeefyStakeToken(s) || this.isLidoToken(s) || this.isPendleToken(s) || this.isAaveToken(s) || this.isNonRebasingBlastToken(s);
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
m as TokenChecker
|
|
29
|
+
};
|
package/common74.mjs
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import l from "axios";
|
|
2
|
+
import { ethers as u } from "ethers";
|
|
3
|
+
import { getCoingeckoPrice as g, getCoingeckoPrice2 as m } from "./common3.mjs";
|
|
4
|
+
import { getCurvePoolsforPriceFetching as y } from "./common13.mjs";
|
|
5
|
+
import { coingeckoRegistry as P } from "./common16.mjs";
|
|
6
|
+
import { getNonLocalhostChainId as h, chainIds as k, networkRegistry as T } from "./common28.mjs";
|
|
7
|
+
import "./common157.mjs";
|
|
8
|
+
import "./common164.mjs";
|
|
9
|
+
import "./common168.mjs";
|
|
10
|
+
import { zeroAddress as p, beefyChainIds as v } from "./common34.mjs";
|
|
11
|
+
import "circomlibjs";
|
|
12
|
+
import "./common51.mjs";
|
|
13
|
+
import "./common50.mjs";
|
|
14
|
+
import "./common139.mjs";
|
|
15
|
+
import "./common191.mjs";
|
|
16
|
+
import "./common117.mjs";
|
|
17
|
+
import { getERC20Token as I } from "./common118.mjs";
|
|
18
|
+
import "./common121.mjs";
|
|
19
|
+
import { getOdosPriceForToken as b } from "./common216.mjs";
|
|
20
|
+
import "./common129.mjs";
|
|
21
|
+
import { caseInsensitiveEqual as c } from "./common134.mjs";
|
|
22
|
+
import "./common42.mjs";
|
|
23
|
+
import "./common31.mjs";
|
|
24
|
+
import { TokenChecker as a } from "./common73.mjs";
|
|
25
|
+
import { abi as C } from "./common87.mjs";
|
|
26
|
+
import { urlForBeefyVaultTokens as A, urlForBeefyVaultTotalInUSD as w, urlForPendleAPI as B, urlForBeefyVaultLpTokens as D } from "./common188.mjs";
|
|
27
|
+
import "./common77.mjs";
|
|
28
|
+
import "./common72.mjs";
|
|
29
|
+
import "./common33.mjs";
|
|
30
|
+
import "libsodium-wrappers";
|
|
31
|
+
import "./common30.mjs";
|
|
32
|
+
import { CoinGeckoChainLabels as R, getCoingeckoIdForNativeTokens as E, getCoingeckoPlatform as S } from "./common35.mjs";
|
|
33
|
+
import "./common36.mjs";
|
|
34
|
+
import { getCrvCvxWithChainId as L } from "./common38.mjs";
|
|
35
|
+
import "./common41.mjs";
|
|
36
|
+
import { getERC20Registry as x } from "./common170.mjs";
|
|
37
|
+
class Pe extends a {
|
|
38
|
+
chainId;
|
|
39
|
+
provider;
|
|
40
|
+
erc20Registry = [];
|
|
41
|
+
// Curve state variables
|
|
42
|
+
crvCvxRegistry = [];
|
|
43
|
+
curvePools = [];
|
|
44
|
+
// Beefy state variables:
|
|
45
|
+
beefyVaults = [];
|
|
46
|
+
beefyTvlData = {};
|
|
47
|
+
usdcSymbol = "USDC";
|
|
48
|
+
supportsCurve = () => h(this.chainId) !== k.bnbMainnet;
|
|
49
|
+
constructor(r, t) {
|
|
50
|
+
super(), this.chainId = r, this.provider = t;
|
|
51
|
+
const e = h(this.chainId);
|
|
52
|
+
this.erc20Registry = x(this.chainId), this.crvCvxRegistry = L(e), this.supportsCurve() && y(this.chainId).then((i) => {
|
|
53
|
+
this.curvePools = i;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
async updateBeefyVault() {
|
|
57
|
+
this.beefyVaults.length === 0 && (this.beefyVaults = (await l.get(A)).data);
|
|
58
|
+
}
|
|
59
|
+
findTokenId(r) {
|
|
60
|
+
let t;
|
|
61
|
+
const e = R[this.chainId];
|
|
62
|
+
return r === p ? E[this.chainId] : (P.find((i) => Object.entries(i.platforms).find(
|
|
63
|
+
([s, n]) => s === e && (r ? c(r, n) : !1)
|
|
64
|
+
) ? (t = i.id, !0) : !1), t);
|
|
65
|
+
}
|
|
66
|
+
async fetchPriceById(r) {
|
|
67
|
+
const t = await g(r);
|
|
68
|
+
return { usd: t?.usd, eth: t.eth };
|
|
69
|
+
}
|
|
70
|
+
async fetchPriceByAddress(r) {
|
|
71
|
+
const t = S(this.chainId);
|
|
72
|
+
return (await m(r, t))?.usd;
|
|
73
|
+
}
|
|
74
|
+
async fetchHETHPrice(r) {
|
|
75
|
+
const t = I(r, this.chainId);
|
|
76
|
+
if (!t || t.underlyingErc20TokenAddress !== p || !t.isHToken || !this.provider)
|
|
77
|
+
return;
|
|
78
|
+
const { contractData: e } = T[this.chainId];
|
|
79
|
+
if (!e.hETHOracleAddress || !e.HTokenOracleABI)
|
|
80
|
+
return;
|
|
81
|
+
const o = await new u.Contract(
|
|
82
|
+
e.hETHOracleAddress,
|
|
83
|
+
e.HTokenOracleABI,
|
|
84
|
+
this.provider
|
|
85
|
+
).callStatic.exchangeRate(), s = Number(u.utils.formatEther(o)), n = await this.fetchPriceByTokenAddress(t.underlyingErc20TokenAddress);
|
|
86
|
+
if (n)
|
|
87
|
+
return s * n;
|
|
88
|
+
}
|
|
89
|
+
// This is general fetch price function: it has flexibility to fetch only with coingecko or also to try to find protocol specific price (use onlyMainRegistry parameter)
|
|
90
|
+
async fetchPriceByTokenAddress(r, t = !1) {
|
|
91
|
+
try {
|
|
92
|
+
console.log("fetchPriceByTokenAddress", { address: r });
|
|
93
|
+
const e = await this.fetchHETHPrice(r);
|
|
94
|
+
if (e)
|
|
95
|
+
return e;
|
|
96
|
+
const i = this.findTokenId(r);
|
|
97
|
+
if (i) {
|
|
98
|
+
const f = (await this.fetchPriceById(i)).usd;
|
|
99
|
+
if (f)
|
|
100
|
+
return f;
|
|
101
|
+
}
|
|
102
|
+
const o = await this.fetchPriceByAddress(r);
|
|
103
|
+
if (console.log({ coingecko: o }), o || t)
|
|
104
|
+
return o;
|
|
105
|
+
const s = await this.fetchProtocolPriceinUSD(r);
|
|
106
|
+
if (console.log({ protocolPrice: s }), s)
|
|
107
|
+
return s;
|
|
108
|
+
const n = await this.fetchOdosPriceinUSD(r);
|
|
109
|
+
if (console.log({ odosPrice: n }), n)
|
|
110
|
+
return n;
|
|
111
|
+
const d = await this.findBeefyLpPrice(r);
|
|
112
|
+
return console.log({ beefyLpPrice: d }), d || void 0;
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.log("fetchPriceByTokenAddress error ", e);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
async fetchOdosPriceinUSD(r) {
|
|
119
|
+
const t = h(this.chainId), e = await b(t, r);
|
|
120
|
+
if (e)
|
|
121
|
+
return e;
|
|
122
|
+
}
|
|
123
|
+
async fetchProtocolPriceinUSD(r) {
|
|
124
|
+
const t = this.erc20Registry.find(
|
|
125
|
+
(e) => c(e.erc20TokenAddress, r)
|
|
126
|
+
);
|
|
127
|
+
if (t) {
|
|
128
|
+
if (this.supportsCurve() && this.curvePools.length === 0 && (this.curvePools = await y(this.chainId)), a.isCurveOrConvex(
|
|
129
|
+
t,
|
|
130
|
+
this.curvePools.map((e) => e.lpTokenAddress)
|
|
131
|
+
)) {
|
|
132
|
+
const e = await this.fetchCurvePriceinUSD(t.underlyingErc20TokenAddress ?? r);
|
|
133
|
+
if (e)
|
|
134
|
+
return e;
|
|
135
|
+
}
|
|
136
|
+
if (a.isBeefyToken(t)) {
|
|
137
|
+
const e = await this.findBeefyPriceInUSD(t.underlyingErc20TokenAddress ?? r);
|
|
138
|
+
if (e)
|
|
139
|
+
return e;
|
|
140
|
+
}
|
|
141
|
+
if (a.isPendleToken(t)) {
|
|
142
|
+
const e = await this.fetchPendleTokenPriceInUSD(r);
|
|
143
|
+
if (e)
|
|
144
|
+
return e;
|
|
145
|
+
}
|
|
146
|
+
if (a.isAaveToken(t)) {
|
|
147
|
+
const { underlyingErc20TokenAddress: e } = t;
|
|
148
|
+
if (!e)
|
|
149
|
+
return console.log("missing underlying token for aave"), 0;
|
|
150
|
+
const i = await this.fetchPriceByTokenAddress(e);
|
|
151
|
+
if (i)
|
|
152
|
+
return i;
|
|
153
|
+
}
|
|
154
|
+
if (a.isNonRebasingBlastToken(t)) {
|
|
155
|
+
const e = this.erc20Registry.find((o) => o.symbol === t.symbol.slice(2));
|
|
156
|
+
if (!e)
|
|
157
|
+
return console.log("missing rebasing variant for non-rebasing token"), 0;
|
|
158
|
+
const i = await this.fetchPriceByTokenAddress(e.erc20TokenAddress);
|
|
159
|
+
if (i)
|
|
160
|
+
return i;
|
|
161
|
+
}
|
|
162
|
+
if (a.isKinzaToken(t)) {
|
|
163
|
+
const { underlyingErc20TokenAddress: e } = t;
|
|
164
|
+
if (!e)
|
|
165
|
+
return console.log("underlying token does not exists for Kinza token"), 0;
|
|
166
|
+
const i = await this.fetchPriceByTokenAddress(e);
|
|
167
|
+
if (i)
|
|
168
|
+
return i;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// this should work for Curve Pools, Curve Staking and Convex
|
|
173
|
+
async fetchCurvePriceinUSD(r) {
|
|
174
|
+
const t = this.crvCvxRegistry.find(
|
|
175
|
+
(i) => c(i.lpToken, r) || c(i.gauge, r) || c(i.cvxRewards, r)
|
|
176
|
+
), e = this.curvePools.find(
|
|
177
|
+
(i) => c(i.address, t?.pool) || c(i.lpTokenAddress, r) || c(i.gaugeAddress, r)
|
|
178
|
+
);
|
|
179
|
+
if (e?.lpPrice)
|
|
180
|
+
return e.lpPrice;
|
|
181
|
+
}
|
|
182
|
+
// this should work for Beefy Lp Provision and Beefy Staking
|
|
183
|
+
async findBeefyPriceInUSD(r) {
|
|
184
|
+
await this.updateBeefyVault();
|
|
185
|
+
const t = h(this.chainId), e = this.beefyVaults.find(
|
|
186
|
+
(i) => c(r, i.earnedTokenAddress) && v[t] === i.chain
|
|
187
|
+
);
|
|
188
|
+
if (e && this.provider) {
|
|
189
|
+
const { earnedTokenAddress: i, id: o } = e, n = (await new u.Contract(i, C, this.provider).totalSupply()).toBigInt(), d = Number(u.utils.formatUnits(n, 18));
|
|
190
|
+
Object.keys(this.beefyTvlData).length === 0 && (this.beefyTvlData = (await l.get(w)).data);
|
|
191
|
+
const f = this.beefyTvlData[t][o];
|
|
192
|
+
return !f || !d ? void 0 : f / d;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async fetchPendleTokenPriceInUSD(r) {
|
|
196
|
+
const t = h(this.chainId), i = this.erc20Registry.find(
|
|
197
|
+
(n) => c(n.erc20TokenAddress, r)
|
|
198
|
+
)?.underlyingErc20TokenAddress ?? r;
|
|
199
|
+
console.log({ searchToken: i });
|
|
200
|
+
const o = `${t}/assets/${i}`, s = (await l.get(`${B}${o}`)).data;
|
|
201
|
+
return s ? s?.price.usd : 0;
|
|
202
|
+
}
|
|
203
|
+
async findBeefyLpPrice(r) {
|
|
204
|
+
await this.updateBeefyVault();
|
|
205
|
+
const t = this.beefyVaults.find((e) => c(r, e.tokenAddress));
|
|
206
|
+
if (t)
|
|
207
|
+
try {
|
|
208
|
+
const { oracleId: e } = t;
|
|
209
|
+
return (await l.get(D)).data?.[e];
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.log("findBeefyLpPrice error:", e);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
Pe as TokenPriceFetcher
|
|
218
|
+
};
|
package/common75.mjs
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { getNonLocalhostChainId as T, chainIdsByType as y, EthereumNetworkType as S } from "./common28.mjs";
|
|
2
|
+
import "./common157.mjs";
|
|
3
|
+
import { emptyDecodedTx as k } from "./common164.mjs";
|
|
4
|
+
import { getCurrentWeek as A } from "./common165.mjs";
|
|
5
|
+
import "./common168.mjs";
|
|
6
|
+
import "ethers";
|
|
7
|
+
import { transactionErrorCodes as I } from "./common81.mjs";
|
|
8
|
+
import "circomlibjs";
|
|
9
|
+
import { UserKeys as x } from "./common51.mjs";
|
|
10
|
+
import { saveTxsCache as C, loadTxsCache as w } from "./common115.mjs";
|
|
11
|
+
import "./common139.mjs";
|
|
12
|
+
import "axios";
|
|
13
|
+
import { decryptUtxo as P } from "./common50.mjs";
|
|
14
|
+
import "./common191.mjs";
|
|
15
|
+
import "./common117.mjs";
|
|
16
|
+
import "./common72.mjs";
|
|
17
|
+
import "./common121.mjs";
|
|
18
|
+
import "./common129.mjs";
|
|
19
|
+
import { decodeTxInput as v, decodeTxLogs as H } from "./common130.mjs";
|
|
20
|
+
import { generateZkProof as z } from "./common149.mjs";
|
|
21
|
+
import "./common42.mjs";
|
|
22
|
+
import "./common31.mjs";
|
|
23
|
+
import { getTxDetails as E } from "./common235.mjs";
|
|
24
|
+
import "./common77.mjs";
|
|
25
|
+
import "./common35.mjs";
|
|
26
|
+
import "./common33.mjs";
|
|
27
|
+
import "libsodium-wrappers";
|
|
28
|
+
import { getHinkalParameters as b } from "./common30.mjs";
|
|
29
|
+
import "./common36.mjs";
|
|
30
|
+
import "./common41.mjs";
|
|
31
|
+
import { API as p } from "./common12.mjs";
|
|
32
|
+
class dt {
|
|
33
|
+
circuitSize = 50;
|
|
34
|
+
hinkalContract;
|
|
35
|
+
init(r) {
|
|
36
|
+
this.hinkalContract = r;
|
|
37
|
+
}
|
|
38
|
+
requireInit() {
|
|
39
|
+
if (!this.hinkalContract)
|
|
40
|
+
throw Error("TransactionsManager not initialized");
|
|
41
|
+
}
|
|
42
|
+
filterOwnTransactions = async (r, e, t, n) => {
|
|
43
|
+
const { transactMethodId: s, transactWithExternalActionMethodId: a, hinkalInterface: o } = b(
|
|
44
|
+
T(r)
|
|
45
|
+
), c = (i) => "decodedInput" in i, l = e.filter(
|
|
46
|
+
(i) => i.methodId === s || i.methodId === a
|
|
47
|
+
).map((i) => c(i) ? i : {
|
|
48
|
+
...i,
|
|
49
|
+
decodedInput: v(o, i.input),
|
|
50
|
+
status: i.isError === "0" ? "SUCCESS" : "FAILURE"
|
|
51
|
+
}), u = t.getShieldedPrivateKey();
|
|
52
|
+
return l.filter((i) => {
|
|
53
|
+
try {
|
|
54
|
+
if (c(i)) {
|
|
55
|
+
if (P(Buffer.from(i.decodedInput.encryptedOutputs[0].slice(2), "hex"), t), !n && i.methodId === s) {
|
|
56
|
+
const { extraRandomization: m, H0: f, H1: g } = i.decodedInput.stealthAddressStructure;
|
|
57
|
+
return x.checkSignature(m, f, g, u);
|
|
58
|
+
}
|
|
59
|
+
return !0;
|
|
60
|
+
}
|
|
61
|
+
return !1;
|
|
62
|
+
} catch {
|
|
63
|
+
return !1;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
saveTxsInStorage = (r, e, t, n) => {
|
|
68
|
+
const s = t.getShieldedPublicKey();
|
|
69
|
+
C(r, e, s, this.hinkalContract.address, n);
|
|
70
|
+
};
|
|
71
|
+
loadTxsFromStorage = (r, e) => {
|
|
72
|
+
const t = e.getShieldedPublicKey();
|
|
73
|
+
return w(r, t, this.hinkalContract.address);
|
|
74
|
+
};
|
|
75
|
+
getAllTransactions = async (r, e, t) => {
|
|
76
|
+
if (t) {
|
|
77
|
+
const { transactions: o } = await p.userGetTransactions(r, t);
|
|
78
|
+
return o;
|
|
79
|
+
}
|
|
80
|
+
const { decodedTxs: n, lastHash: s } = this.loadTxsFromStorage(r, e), { transactions: a } = await p.userGetTransactions(r, t, s);
|
|
81
|
+
return [...a, ...n];
|
|
82
|
+
};
|
|
83
|
+
getHinkalHistoryBase = async (r, e, t, n = !1) => {
|
|
84
|
+
this.requireInit();
|
|
85
|
+
const s = await this.getAllTransactions(r, e, t) ?? [];
|
|
86
|
+
s.sort((o, c) => c.timeStamp - o.timeStamp);
|
|
87
|
+
const a = await this.filterOwnTransactions(r, s, e, n);
|
|
88
|
+
return !t && s.length > 0 && this.saveTxsInStorage(a, r, e, s[0].hash), a;
|
|
89
|
+
};
|
|
90
|
+
getHinkalHistory = async (r, e) => {
|
|
91
|
+
const t = await this.getHinkalHistoryBase(r, e, void 0, !0), n = H(r, t);
|
|
92
|
+
return await Promise.all(
|
|
93
|
+
n.map(async (a) => ({
|
|
94
|
+
...a,
|
|
95
|
+
status: a.status,
|
|
96
|
+
details: await E(r, a.decodedInput, a.utxosArray)
|
|
97
|
+
}))
|
|
98
|
+
);
|
|
99
|
+
};
|
|
100
|
+
sortInBatches = (r) => {
|
|
101
|
+
const e = [];
|
|
102
|
+
let t = 0, n = 0;
|
|
103
|
+
r.forEach((o) => {
|
|
104
|
+
t === 0 && e.push([]), e[n].push(o), t += 1, t === this.circuitSize && (t = 0, n += 1);
|
|
105
|
+
});
|
|
106
|
+
const s = e[e.length - 1], a = s.length;
|
|
107
|
+
if (a < this.circuitSize) {
|
|
108
|
+
const o = this.circuitSize - a, c = new Array(o).fill(k);
|
|
109
|
+
e[e.length - 1] = s.concat(c);
|
|
110
|
+
}
|
|
111
|
+
return e;
|
|
112
|
+
};
|
|
113
|
+
generateTransactionsProof = async (r, e, t) => {
|
|
114
|
+
const n = this.sortInBatches(e), s = new Array(n.length).fill([]);
|
|
115
|
+
for (let a = 0; a < n.length; a += 1) {
|
|
116
|
+
const o = n[a].map(
|
|
117
|
+
(h) => h.decodedInput.stealthAddressStructure
|
|
118
|
+
), c = o.map((h) => h.extraRandomization), d = o.map((h) => h.stealthAddress);
|
|
119
|
+
console.log({ extraRandomizations: c, stealthAddresses: d });
|
|
120
|
+
const l = {
|
|
121
|
+
shieldedPrivateKey: t,
|
|
122
|
+
extraRandomizations: c,
|
|
123
|
+
stealthAddresses: d
|
|
124
|
+
};
|
|
125
|
+
console.log({ chainId: r, input: l });
|
|
126
|
+
const { zkCallData: u } = await z(r, "transactionsProver", l);
|
|
127
|
+
console.log({ zkCallData: u }), s[a] = u;
|
|
128
|
+
}
|
|
129
|
+
return { zkCallDataArray: s };
|
|
130
|
+
};
|
|
131
|
+
userVerifyTransactions = async (r, e, t, n, s, a) => await p.userVerifyTransactions(
|
|
132
|
+
r,
|
|
133
|
+
e,
|
|
134
|
+
t,
|
|
135
|
+
n,
|
|
136
|
+
s,
|
|
137
|
+
a
|
|
138
|
+
);
|
|
139
|
+
processAndSendTransactionsForVerification = async (r, e, t, n) => {
|
|
140
|
+
this.requireInit();
|
|
141
|
+
const s = A(), a = n ? s - 1 : s;
|
|
142
|
+
console.log("retrieving transactions in processAndSendTransactionsForVerification", { week: a });
|
|
143
|
+
const o = await this.getHinkalHistoryBase(r, e, a);
|
|
144
|
+
console.log("retrieved transactions", o);
|
|
145
|
+
let c = [], d = [];
|
|
146
|
+
o.length > 0 && ({ zkCallDataArray: d } = await this.generateTransactionsProof(
|
|
147
|
+
r,
|
|
148
|
+
o,
|
|
149
|
+
e.getShieldedPrivateKey()
|
|
150
|
+
), c = o.map((f) => f.hash));
|
|
151
|
+
const l = e.getBackendToken(), {
|
|
152
|
+
trade: u,
|
|
153
|
+
transactions: h,
|
|
154
|
+
lockedDeposit: i,
|
|
155
|
+
verification: m
|
|
156
|
+
} = await this.userVerifyTransactions(
|
|
157
|
+
r,
|
|
158
|
+
c,
|
|
159
|
+
d,
|
|
160
|
+
l,
|
|
161
|
+
t,
|
|
162
|
+
a
|
|
163
|
+
);
|
|
164
|
+
return { trade: u, transactions: h, lockedDeposit: i, verification: m };
|
|
165
|
+
};
|
|
166
|
+
multiProcessAndSendTransactionsForVerification = async (r, e) => {
|
|
167
|
+
console.log("Multi Certify Starts");
|
|
168
|
+
const t = y[S.Mainnet];
|
|
169
|
+
let n = !0;
|
|
170
|
+
for (let s = 0; s < t.length; s += 1)
|
|
171
|
+
try {
|
|
172
|
+
const { hasCertified: a } = await p.verificationStartDate(t[s], e);
|
|
173
|
+
if (console.log(`certification status for chain ${t[s]} is ${a}`), a)
|
|
174
|
+
continue;
|
|
175
|
+
const {
|
|
176
|
+
trade: o,
|
|
177
|
+
transactions: c,
|
|
178
|
+
lockedDeposit: d,
|
|
179
|
+
verification: l
|
|
180
|
+
} = await this.processAndSendTransactionsForVerification(t[s], r, e, !0);
|
|
181
|
+
if (console.log({ chainId: t[s], trade: o, totalTransactions: c, lockedDeposit: d, verification: l }), n = n && l, !n)
|
|
182
|
+
break;
|
|
183
|
+
} catch (a) {
|
|
184
|
+
console.log(`current chain ${t[s]} certification error`, { err: a }), n = !1;
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
if (!n)
|
|
188
|
+
throw Error(I.MULTI_VERIFICATION_FAILED);
|
|
189
|
+
return !0;
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
export {
|
|
193
|
+
dt as TransactionsManager
|
|
194
|
+
};
|
package/common76.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "./common28.mjs";
|
|
2
|
+
import "./common157.mjs";
|
|
3
|
+
import { ExternalActionId as t } from "./common159.mjs";
|
|
4
|
+
import "./common164.mjs";
|
|
5
|
+
import "./common168.mjs";
|
|
6
|
+
import "./common33.mjs";
|
|
7
|
+
import "./common30.mjs";
|
|
8
|
+
import "./common31.mjs";
|
|
9
|
+
import "./common35.mjs";
|
|
10
|
+
import "./common36.mjs";
|
|
11
|
+
import "./common41.mjs";
|
|
12
|
+
import "./common42.mjs";
|
|
13
|
+
import "ethers";
|
|
14
|
+
import "circomlibjs";
|
|
15
|
+
import "./common51.mjs";
|
|
16
|
+
import "axios";
|
|
17
|
+
import "./common50.mjs";
|
|
18
|
+
import "./common139.mjs";
|
|
19
|
+
import "./common191.mjs";
|
|
20
|
+
import { getExternalActionIdFromNumber as o } from "./common117.mjs";
|
|
21
|
+
import "./common72.mjs";
|
|
22
|
+
import "./common121.mjs";
|
|
23
|
+
import "./common129.mjs";
|
|
24
|
+
import "./common77.mjs";
|
|
25
|
+
import "libsodium-wrappers";
|
|
26
|
+
var m = /* @__PURE__ */ ((r) => (r[r.DEPOSIT = 0] = "DEPOSIT", r[r.WITHDRAW = 1] = "WITHDRAW", r[r.SWAP = 2] = "SWAP", r[r.BEEFY = 3] = "BEEFY", r[r.CURVE = 4] = "CURVE", r[r.CONVEX = 5] = "CONVEX", r[r.LIDO = 6] = "LIDO", r[r.PENDLE = 7] = "PENDLE", r[r.VOLATILE = 8] = "VOLATILE", r[r.UNKNOWN = 9] = "UNKNOWN", r))(m || {});
|
|
27
|
+
const p = (r) => {
|
|
28
|
+
const e = r.externalActionId.toBigInt();
|
|
29
|
+
switch (o(e)) {
|
|
30
|
+
case t.Transact:
|
|
31
|
+
return r.amountChanges[0].toBigInt() >= 0n ? 0 : 1;
|
|
32
|
+
case t.Uniswap:
|
|
33
|
+
case t.Odos:
|
|
34
|
+
case t.OneInch:
|
|
35
|
+
return 2;
|
|
36
|
+
case t.Beefy:
|
|
37
|
+
case t.BeefyStake:
|
|
38
|
+
return 3;
|
|
39
|
+
case t.Curve:
|
|
40
|
+
case t.CurveDynamic:
|
|
41
|
+
case t.CurveCRV:
|
|
42
|
+
case t.CurveCRVRewards:
|
|
43
|
+
return 4;
|
|
44
|
+
case t.Convex:
|
|
45
|
+
return 5;
|
|
46
|
+
case t.LidoETH:
|
|
47
|
+
case t.LidoMATIC:
|
|
48
|
+
case t.LidoETHNFT:
|
|
49
|
+
case t.LidoMATICNFT:
|
|
50
|
+
return 6;
|
|
51
|
+
case t.Pendle:
|
|
52
|
+
return 7;
|
|
53
|
+
case t.Volatile:
|
|
54
|
+
return r.amountChanges.length === 1 ? r.amountChanges[0].toBigInt() < 0n ? 1 : 0 : r.amountChanges.length === 2 ? 2 : 9;
|
|
55
|
+
default:
|
|
56
|
+
return 9;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export {
|
|
60
|
+
m as TransactionType,
|
|
61
|
+
p as externalActionToTransactionType
|
|
62
|
+
};
|