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