@hinkal/common 0.1.26 → 0.1.27
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/babyJub.cjs +1 -1
- package/crypto/babyJub.mjs +5 -5
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.mjs +2 -3
- package/data-structures/Hinkal/hinkalPrivateWallet.cjs +1 -1
- package/data-structures/Hinkal/hinkalPrivateWallet.mjs +2 -3
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractAccessTokenSnapshotService.mjs +2 -3
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +10 -11
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientAccessTokenSnapshotService.mjs +2 -3
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientCommitmentsSnapshotService.mjs +2 -3
- package/data-structures/snapshot/ClientNullifierSnapshotService.cjs +1 -1
- package/data-structures/snapshot/ClientNullifierSnapshotService.mjs +2 -3
- package/functions/pre-transaction/outputUtxoProcessing.cjs +1 -1
- package/functions/pre-transaction/outputUtxoProcessing.mjs +2 -3
- package/functions/pre-transaction/processAmountChanges.cjs +1 -1
- package/functions/pre-transaction/processAmountChanges.mjs +7 -8
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +10 -11
- package/functions/staking/index.cjs +1 -1
- package/functions/staking/index.mjs +13 -14
- package/functions/web3/functionCalls/transactCallRelayer.cjs +1 -1
- package/functions/web3/functionCalls/transactCallRelayer.mjs +6 -7
- package/functions/web3/odosAPI.cjs +1 -1
- package/functions/web3/odosAPI.mjs +5 -6
- package/functions/web3/oneInchAPI.cjs +1 -1
- package/functions/web3/oneInchAPI.mjs +6 -7
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +6 -7
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +2 -3
- package/package.json +1 -1
- package/providers/prepareEthersHinkal.cjs +1 -1
- package/providers/prepareEthersHinkal.mjs +2 -3
- package/providers/prepareWagmiv1Hinkal.cjs +1 -1
- package/providers/prepareWagmiv1Hinkal.mjs +2 -3
- package/webworker/utxoWorker/utxoWorkerLauncher.cjs +1 -1
- package/webworker/utxoWorker/utxoWorkerLauncher.mjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.cjs +1 -1
- package/webworker/zkProofWorker/zkProofWorkerLauncher.mjs +1 -1
package/crypto/babyJub.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(
|
|
1
|
+
"use strict";var o=Object.create;var i=Object.defineProperty;var r=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty;var y=(b,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of s(t))!l.call(b,u)&&u!==e&&i(b,u,{get:()=>t[u],enumerable:!(a=r(t,u))||a.enumerable});return b};var j=(b,t,e)=>(e=b!=null?o(c(b)):{},y(t||!b||!b.__esModule?i(e,"default",{value:b,enumerable:!0}):e,b));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class d{babyjub=void 0;async init(){const t=await import("circomlibjs");this.babyjub=await t.buildBabyjub()}getJub(){return this.babyjub}}const n=new d,J=()=>n.getJub();exports.babyJubInstance=J;exports.jubHolder=n;
|
package/crypto/babyJub.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { buildBabyjub as b } from "circomlibjs";
|
|
2
1
|
class t {
|
|
3
2
|
babyjub = void 0;
|
|
4
3
|
async init() {
|
|
5
|
-
|
|
4
|
+
const b = await import("circomlibjs");
|
|
5
|
+
this.babyjub = await b.buildBabyjub();
|
|
6
6
|
}
|
|
7
7
|
getJub() {
|
|
8
8
|
return this.babyjub;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
const
|
|
11
|
+
const a = new t(), i = () => a.getJub();
|
|
12
12
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
i as babyJubInstance,
|
|
14
|
+
a as jubHolder
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),y=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),v=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),T=require("./hinkalSwap.cjs"),m=require("./hinkalWithdraw.cjs"),q=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../../types/hinkal.types.cjs"),h=require("../../types/ethereum-network.types.cjs"),a=require("../../functions/web3/functionCalls/accessTokenCalls.cjs"),y=require("../../functions/web3/events/getShieldedBalance.cjs"),o=require("../crypto-keys/keys.cjs"),v=require("./hinkalActionBeefy.cjs"),C=require("./hinkalActionConvex.cjs"),P=require("./hinkalActionCurve.cjs"),w=require("./hinkalActionPendle.cjs"),d=require("./hinkalDeposit.cjs"),T=require("./hinkalSwap.cjs"),m=require("./hinkalWithdraw.cjs"),q=require("./resetMerkleTrees.cjs"),l=require("../merkle-tree/MerkleTree.cjs"),u=require("../../crypto/poseidon.cjs");require("libsodium-wrappers");require("process");require("buffer");const S=require("../../constants/chains.constants.cjs"),g=require("../../error-handling/error-codes.constants.cjs"),f=require("../../API/callMonitor.cjs"),E=require("./hinkalActionLidoEth.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const F=require("../../API/getAxelarGasEstimate.cjs"),p=require("../../API/API.cjs");require("ethers");require("../../types/curve.types.cjs");require("../../constants/contracts.constants.cjs");const H=require("../../constants/kyc.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const I=require("../transactions-manager/TransactionsManager.cjs");require("../../functions/utils/external-action.utils.cjs");require("../../types/circom-data.types.cjs");require("../../types/transactions.types.cjs");const M=require("../../functions/utils/reloadPage.cjs"),R=require("./hinkalActionVolatile.cjs"),k=require("./hinkalActionPendleLP.cjs"),L=require("../../API/getConnextReceiveFee.cjs"),W=require("./hinkalActionStake.cjs"),K=require("../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.cjs"),N=require("./hinkalPrivateWallet.cjs");class x{providerAdapter;userKeys;signingMessage="Login to Hinkal Protocol";merkleTreeHinkal;merkleTreeAccessToken;nullifiers;encryptedOutputs;commitmentsSnapshotService;nullifierSnapshotService;accessTokenSnapshotService;transactionsManager;utxoUtils=K.multiThreadedUtxoUtils;constructor(){this.userKeys=new o.UserKeys(void 0),this.merkleTreeHinkal=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.merkleTreeAccessToken=l.MerkleTree.create(u.poseidonFunction,25n,0n),this.nullifiers=new Set,this.encryptedOutputs=[],this.transactionsManager=new I.TransactionsManager}async initProviderAdapter(e,t){await this.updateProviderAdapter(t),this.providerAdapter?.initConnector(e);const r=await this.connectAndPatchProvider(e);await t.init(r),await this.setListeners()}async initUserKeys(){this.userKeys=new o.UserKeys(await this.getProviderAdapter().signMessage(this.signingMessage))}async initUserKeysWithPassword(e){this.userKeys=new o.UserKeys(e)}async resetMerkle(){this.isSelectedNetworkSupported()&&await q.resetMerkleTrees(this)}getProviderAdapter(){if(!this.providerAdapter)throw new Error("ProviderAdapter is not initialized");return this.providerAdapter}async waitForTransaction(e,t=1){return!!await this.providerAdapter?.waitForTransaction(e,t)}getContractMetadata(e,t){return this.getProviderAdapter().getContractMetadata(e,t)}getContract(e,t=void 0,r){return this.getProviderAdapter().getContract(e,t,r)}async signMessage(e){return await this.getProviderAdapter().signMessage(e)}async signTypedData(e,t,r){return await this.getProviderAdapter().signTypedData(e,t,r)}getContractWithSigner(e,t=""){return this.getProviderAdapter().getContractWithSigner(e,t)}getContractWithFetcher(e,t=""){return this.getProviderAdapter().getContractWithFetcher(e,t)}getContractWithFetcherForEthereum(e,t){return this.getProviderAdapter().getContractWithFetcherForEthereum(e,t)}isSelectedNetworkSupported(){return!!S.networkRegistry[this.getCurrentChainId()]}async switchNetwork(e){try{await this.getProviderAdapter().switchNetwork(e)}catch{throw new Error(g.transactionErrorCodes.FAILED_TO_SWITCH_NETWORKS)}}getCurrentChainId(){const{chainId:e}=this.getProviderAdapter();if(!e)throw new Error("Illegal State: no chainId");return e}getSelectedNetwork(){return this.providerAdapter?.getSelectedNetwork()}isPermitterAvailable(){return this.getProviderAdapter().isPermitterAvailable()}async connectAndPatchProvider(e){return await this.getProviderAdapter().connectAndPatchProvider(e)}async disconnectFromConnector(){await this.getProviderAdapter().disconnectFromConnector()}async updateProviderAdapter(e){try{this.providerAdapter&&this.providerAdapter.release(),this.providerAdapter=e}catch(t){throw console.error(t),Error("updateProviderAdapter failed, please try again.")}}async setListeners(){this.providerAdapter?.setChainEventListener({onAccountChanged:()=>{this.onAccountChanged()},onChainChanged:e=>{this.onChainChanged(e)}})}async onAccountChanged(){await this.getProviderAdapter().onAccountChanged();const e=c.EventType.AccountChanged;typeof document<"u"?document?.dispatchEvent(new Event(e)):process?.emit("message",e,void 0)}async onChainChanged(e){if(e){await this.getProviderAdapter().onChainChanged(e);const t=c.EventType.NetworkChange;typeof document<"u"?document.dispatchEvent(new Event(t)):process?.emit("message",t,void 0)}else await this.disconnectFromConnector(),M.reloadPage()}async monitorConnectedAddress(){f.monitor(await this.getEthereumAddress(),this.getCurrentChainId())}async getBalances(){return y.getShieldedBalance(this)}getSupportedPassportLinks(){return H.supportedPassportLinks}checkAccessToken(){return a.checkHinkalAccessToken(this)}async getAxelarEstimate(e,t,r,n){return F.getAxelarGasEstimate(e,t,r,n,this.userKeys.getAccessKey())}async getConnextReceiveFee(e,t){return L.getConnextReceiveFee(this.getCurrentChainId(),e,t)}async mintHinkalAccessToken(e){return a.mintAccessToken(this,e)}async mintHinkalAccessTokenCrossChain(e,t){return a.mintTokenCrossChain(this,e,t)}async getHinkalTreeRootHash(){return this.getContractWithFetcher(h.ContractType.HinkalContract).getRootHash()}async getAccessTokenTreeRootHash(){return this.getContractWithFetcher(h.ContractType.CrossChainAccessTokenContract).getRootHash()}async resetMerkleTreesIfNecessary(){if(!this.isSelectedNetworkSupported())throw new Error(g.transactionErrorCodes.UNSUPPORTED_NETWORK);const[e,t]=await Promise.all([this.getHinkalTreeRootHash(),this.getAccessTokenTreeRootHash()]);(e.toBigInt()!==this.merkleTreeHinkal.getRootHash()||t.toBigInt()!==this.merkleTreeAccessToken.getRootHash())&&await this.resetMerkle()}async getEventsFromHinkal(){await Promise.all([this.accessTokenSnapshotService?.retrieveEventsFromLatestBlock(),this.commitmentsSnapshotService?.retrieveEventsFromLatestBlock(),this.nullifierSnapshotService?.retrieveEventsFromLatestBlock()])}getEthereumAddress(){return this.getProviderAdapter().getAddress()}async getRandomRelay(){return(await p.API.getIdleRelay(this.getCurrentChainId())).relay}getGasPrice(){if(!this.providerAdapter?.chainId)throw new Error("Illegal State of providerAdapter in Hinkal: no chainId");return this.providerAdapter.getGasPrice()}getAPI(){return p.API}async deposit(e,t){return d.hinkalDeposit(this,e,t)}async depositForOther(e,t,r){return d.hinkalDepositForOther(this,e,t,r)}async withdraw(e,t,r,n,i=!1){return m.hinkalWithdraw(this,e,t,r,n,i)}async swap(e,t,r,n,i=!1,s=!1){return T.hinkalSwap(this,e,t,r,n,i,s)}async actionCurve(e,t,r,n,i,s=!1){return P.hinkalActionCurve(this,e,t,r,n,i,s)}async actionConvex(e,t,r,n,i=!1){return C.hinkalActionConvex(this,e,t,r,n,i)}async actionBeefy(e,t,r,n,i,s,A=!1){return v.hinkalActionBeefy(this,e,t,r,n,i,s,A)}async actionLido(e,t,r,n,i,s=!1){return E.hinkalActionLido(this,e,t,r,n,i,s)}async actionPendle(e,t,r,n,i=!1){return w.hinkalActionPendle(this,e,t,r,n,i)}async actionPendleLP(e,t,r,n,i=!1){return k.hinkalActionPendleLP(this,e,t,r,n,i)}async actionVolatile(e,t,r,n=!1){return R.hinkalActionVolatile(this,e,t,r,n)}async actionStake(e,t,r,n){return W.hinkalActionStake(this,e,t,r,n)}async actionPrivateWallet(e,t,r,n=[],i,s=!1){return N.hinkalPrivateWallet(this,e,t,r,n,i,s)}async getPendleLPClaimableParams(e,t){return k.hinkalGetPendleLPClaimableParams(this,e,t)}}exports.Hinkal=x;
|
|
@@ -13,7 +13,6 @@ import { hinkalWithdraw as S } from "./hinkalWithdraw.mjs";
|
|
|
13
13
|
import { resetMerkleTrees as E } from "./resetMerkleTrees.mjs";
|
|
14
14
|
import { MerkleTree as h } from "../merkle-tree/MerkleTree.mjs";
|
|
15
15
|
import { poseidonFunction as d } from "../../crypto/poseidon.mjs";
|
|
16
|
-
import "circomlibjs";
|
|
17
16
|
import "libsodium-wrappers";
|
|
18
17
|
import "process";
|
|
19
18
|
import "buffer";
|
|
@@ -44,7 +43,7 @@ import { getConnextReceiveFee as x } from "../../API/getConnextReceiveFee.mjs";
|
|
|
44
43
|
import { hinkalActionStake as B } from "./hinkalActionStake.mjs";
|
|
45
44
|
import { multiThreadedUtxoUtils as U } from "../MultiThreadedUtxoUtils/MultiThreadedUtxoUtils.mjs";
|
|
46
45
|
import { hinkalPrivateWallet as b } from "./hinkalPrivateWallet.mjs";
|
|
47
|
-
class
|
|
46
|
+
class We {
|
|
48
47
|
providerAdapter;
|
|
49
48
|
userKeys;
|
|
50
49
|
signingMessage = "Login to Hinkal Protocol";
|
|
@@ -298,5 +297,5 @@ class Ne {
|
|
|
298
297
|
}
|
|
299
298
|
}
|
|
300
299
|
export {
|
|
301
|
-
|
|
300
|
+
We as Hinkal
|
|
302
301
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("../../constants/chains.constants.cjs"),x=require("../../error-handling/error-codes.constants.cjs");require("ethers");require("axios");require("../../constants/vite.constants.cjs");require("../../types/circom-data.types.cjs");const A=require("../../types/external-action.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const C=require("../../functions/snarkjs/constructEmporiumProof.cjs"),P=require("../../functions/pre-transaction/processAmountChanges.cjs"),R=require("../../functions/pre-transaction/outputUtxoProcessing.cjs"),w=require("../../functions/web3/events/getShieldedBalance.cjs"),U=require("../../functions/web3/functionCalls/estimateGasRelayer.cjs"),I=require("../../functions/web3/functionCalls/transactCallRelayer.cjs"),T=async(e,o,r,q,d=[],p,y=!1)=>{const a=o.map(t=>0n);r=P.processAmountChanges({erc20Addresses:o,amountChanges:r,flatFees:a,feeUnit:void 0,externalActionId:A.ExternalActionId.Emporium});const s=[...await w.addPaddingToUtxos(e,o,r)],i=[];for(let t=0;t<o.length;t+=1){const{outputUtxos:E}=R.outputUtxoProcessing(e.userKeys,s[t],r[t]);i.push(E)}const n=await e.getRandomRelay();if(!n)throw Error(x.transactionErrorCodes.RELAYER_NOT_AVAILABLE);const{contractData:g}=f.networkRegistry[e.getCurrentChainId()],{emporiumAddress:c}=g;if(!c)throw Error("No Emporium Address Provided");const{zkCallData:u,circomData:l,dimData:m}=await C.constructEmporiumProof(e.merkleTreeHinkal,e.merkleTreeAccessToken,s,i,e.userKeys,r.length,s[0].length,c,d,n,e.getCurrentChainId(),q,a,p);return y?await U.estimateGasRelayer(e,u,m,l):await I.transactCallRelayer(e.getCurrentChainId(),u,m,l)};exports.hinkalPrivateWallet=T;
|
|
@@ -7,7 +7,6 @@ import "../../types/circom-data.types.mjs";
|
|
|
7
7
|
import { ExternalActionId as w } from "../../types/external-action.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
-
import "circomlibjs";
|
|
11
10
|
import "libsodium-wrappers";
|
|
12
11
|
import "process";
|
|
13
12
|
import "buffer";
|
|
@@ -18,7 +17,7 @@ import { outputUtxoProcessing as C } from "../../functions/pre-transaction/outpu
|
|
|
18
17
|
import { addPaddingToUtxos as I } from "../../functions/web3/events/getShieldedBalance.mjs";
|
|
19
18
|
import { estimateGasRelayer as P } from "../../functions/web3/functionCalls/estimateGasRelayer.mjs";
|
|
20
19
|
import { transactCallRelayer as T } from "../../functions/web3/functionCalls/transactCallRelayer.mjs";
|
|
21
|
-
const
|
|
20
|
+
const S = async (t, e, o, u, d = [], l, E = !1) => {
|
|
22
21
|
const m = e.map((r) => 0n);
|
|
23
22
|
o = U({
|
|
24
23
|
erc20Addresses: e,
|
|
@@ -57,5 +56,5 @@ const X = async (t, e, o, u, d = [], l, E = !1) => {
|
|
|
57
56
|
return E ? await P(t, n, f, c) : await T(t.getCurrentChainId(), n, f, c);
|
|
58
57
|
};
|
|
59
58
|
export {
|
|
60
|
-
|
|
59
|
+
S as hinkalPrivateWallet
|
|
61
60
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../../constants/protocol.constants.cjs"),c=require("../../crypto/poseidon.cjs");require("libsodium-wrappers");require("process");require("buffer");const n=require("../../functions/utils/amounts.utils.cjs"),o=require("../merkle-tree/MerkleTree.cjs"),u=require("./AbstractSnapshotService.cjs");class A extends u.AbstractSnapshotService{constructor(e,s,r,d){super(e,{name:"NewAccessKeyAdded",args:["accessKey","index","senderAddress"]},s,r,d)}_merkleTree;_senderAddresses;_senderAddressIndexMap;get merkleTree(){return this._merkleTree}get senderAddresses(){return this._senderAddresses}get senderAddressIndexMap(){return this._senderAddressIndexMap}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),senderAddresses:Array.from(e.payload.senderAddresses),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,senderAddressIndexMap:Array.from(e.payload.senderAddressIndexMap).map(([s,r])=>({address:s,index:r}))}}deserializeSnapshot(e){let s,r;if(e.latestBlockNumber&&e.merkleTree){const d=new Map(Object.entries(e.merkleTree.tree).map(([t,a])=>[BigInt(t),BigInt(a)]));s=o.MerkleTree.createWithData(d,n.toBigInt(e.merkleTree.index),n.toBigInt(e.merkleTree.count),c.poseidonFunction,25n,0n)}else s=o.MerkleTree.create(c.poseidonFunction,25n,0n);return e.latestBlockNumber&&e.senderAddressIndexMap?r=new Map(e.senderAddressIndexMap.map(({address:d,index:t})=>[d,t])):r=new Map,{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:s,senderAddresses:e.senderAddresses??[],senderAddressIndexMap:r}}}acceptEvent(e,s){try{return this._merkleTree.insert(e.accessKey,e.index),this._senderAddressIndexMap.set(e.senderAddress,Math.max(Number(e.index),this._senderAddressIndexMap.get(e.senderAddress)??0)),this._senderAddresses.includes(e.senderAddress)||this._senderAddresses.push(e.senderAddress),e.accessKey===0n&&e.senderAddress===l.zeroAddress&&this._merkleTree.remove(e.index),!0}catch(r){return console.error(r),!1}}mapEvent(e){const{accessKey:s,index:r,senderAddress:d}=e;return{accessKey:n.toBigInt(s),index:n.toBigInt(r),senderAddress:d}}getSnapshotPayload(){return{merkleTree:this._merkleTree,senderAddresses:this._senderAddresses,senderAddressIndexMap:this._senderAddressIndexMap}}populateSnapshot({payload:{merkleTree:e,senderAddresses:s,senderAddressIndexMap:r}}){this._merkleTree=e,this._senderAddresses=s,this._senderAddressIndexMap=r}}exports.AbstractAccessTokenSnapshotService=A;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { zeroAddress as o } from "../../constants/protocol.constants.mjs";
|
|
2
2
|
import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
|
|
3
|
-
import "circomlibjs";
|
|
4
3
|
import "libsodium-wrappers";
|
|
5
4
|
import "process";
|
|
6
5
|
import "buffer";
|
|
7
6
|
import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
|
|
8
7
|
import { MerkleTree as c } from "../merkle-tree/MerkleTree.mjs";
|
|
9
8
|
import { AbstractSnapshotService as l } from "./AbstractSnapshotService.mjs";
|
|
10
|
-
class
|
|
9
|
+
class b extends l {
|
|
11
10
|
constructor(e, s, r, d) {
|
|
12
11
|
super(
|
|
13
12
|
e,
|
|
@@ -107,5 +106,5 @@ class I extends l {
|
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
export {
|
|
110
|
-
|
|
109
|
+
b as AbstractAccessTokenSnapshotService
|
|
111
110
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../crypto/poseidon.cjs");require("libsodium-wrappers");require("process");require("buffer");const s=require("../merkle-tree/MerkleTree.cjs"),u=require("../../functions/utils/amounts.utils.cjs"),m=require("./AbstractSnapshotService.cjs");class p extends m.AbstractSnapshotService{constructor(e,t,n,r){super(e,{name:"NewCommitment",args:["commitment","index","encryptedOutput"]},t,n,r)}_merkleTree;_encryptedOutputs;get merkleTree(){return this._merkleTree}get encryptedOutputs(){return this._encryptedOutputs}serializeSnapshot(e){return{merkleTree:e.payload.merkleTree.toJSON(),latestBlockNumber:e.latestBlockNumber,reserveBlockNumber:e.reserveBlockNumber,encryptedOutputs:e.payload.encryptedOutputs.map(t=>({value:t.value,isPositive:String(t.isPositive)}))}}deserializeSnapshot(e){let t;if(e.latestBlockNumber&&e.merkleTree){const r=new Map(Object.entries(e.merkleTree.tree).map(([c,o])=>[BigInt(c),BigInt(o)]));t=s.MerkleTree.createWithData(r,u.toBigInt(e.merkleTree.index),u.toBigInt(e.merkleTree.count),i.poseidonFunction,25n,0n)}else t=s.MerkleTree.create(i.poseidonFunction,25n,0n);const n=e.encryptedOutputs?.map(r=>({value:r.value,isPositive:JSON.parse(r.isPositive)}));return{latestBlockNumber:e.latestBlockNumber??0,reserveBlockNumber:e.reserveBlockNumber??0,payload:{merkleTree:t,encryptedOutputs:n||[]}}}getSnapshotPayload(){return{merkleTree:this._merkleTree,encryptedOutputs:this._encryptedOutputs}}populateSnapshot({payload:{merkleTree:e,encryptedOutputs:t}}){this._merkleTree=e,this._encryptedOutputs=t}mapEvent(e){const{commitment:t,index:n,encryptedOutput:r}=e;return{commitment:u.toBigInt(t),index:u.toBigInt(n),encryptedOutput:r}}acceptEvent(e,t){if(!this.encryptedOutputs.map(n=>n.value).includes(e.encryptedOutput)){if(this.isServer&&console.log(`Adding commitment to file ${e.commitment} at index ${e.index} for encrypted output ${e.encryptedOutput}. Block Number: ${t}
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
`),!this._merkleTree.insert(e.commitment,e.index>=0?e.index:-1n*e.index))return console.log(`Could not add ${e.commitment} at index ${e.index} `),!1;const r={value:e.encryptedOutput,isPositive:e.index>=0n};return this._encryptedOutputs.push(r),!0}return!1}}exports.AbstractCommitmentsSnapshotService=p;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { poseidonFunction as
|
|
2
|
-
import "circomlibjs";
|
|
1
|
+
import { poseidonFunction as m } from "../../crypto/poseidon.mjs";
|
|
3
2
|
import "libsodium-wrappers";
|
|
4
3
|
import "process";
|
|
5
4
|
import "buffer";
|
|
6
5
|
import { MerkleTree as i } from "../merkle-tree/MerkleTree.mjs";
|
|
7
|
-
import { toBigInt as
|
|
6
|
+
import { toBigInt as n } from "../../functions/utils/amounts.utils.mjs";
|
|
8
7
|
import { AbstractSnapshotService as o } from "./AbstractSnapshotService.mjs";
|
|
9
|
-
class
|
|
8
|
+
class x extends o {
|
|
10
9
|
constructor(e, t, u, r) {
|
|
11
10
|
super(
|
|
12
11
|
e,
|
|
@@ -49,14 +48,14 @@ class b extends o {
|
|
|
49
48
|
);
|
|
50
49
|
t = i.createWithData(
|
|
51
50
|
r,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
n(e.merkleTree.index),
|
|
52
|
+
n(e.merkleTree.count),
|
|
53
|
+
m,
|
|
55
54
|
25n,
|
|
56
55
|
0n
|
|
57
56
|
);
|
|
58
57
|
} else
|
|
59
|
-
t = i.create(
|
|
58
|
+
t = i.create(m, 25n, 0n);
|
|
60
59
|
const u = e.encryptedOutputs?.map((r) => ({
|
|
61
60
|
value: r.value,
|
|
62
61
|
isPositive: JSON.parse(r.isPositive)
|
|
@@ -84,8 +83,8 @@ class b extends o {
|
|
|
84
83
|
mapEvent(e) {
|
|
85
84
|
const { commitment: t, index: u, encryptedOutput: r } = e;
|
|
86
85
|
return {
|
|
87
|
-
commitment:
|
|
88
|
-
index:
|
|
86
|
+
commitment: n(t),
|
|
87
|
+
index: n(u),
|
|
89
88
|
encryptedOutput: r
|
|
90
89
|
};
|
|
91
90
|
}
|
|
@@ -108,5 +107,5 @@ class b extends o {
|
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
109
|
export {
|
|
111
|
-
|
|
110
|
+
x as AbstractCommitmentsSnapshotService
|
|
112
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("../event-service/AbstractAccessTokenSnapshotService.cjs");require("ethers");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../../API/fetchCommitmentsCache.cjs");class c extends s.AbstractAccessTokenSnapshotService{constructor(r,e){super(r,0,!1,e)}async fetchSnapshot(){const{chainId:r}=await this.contract.provider.getNetwork(),e=await t.fetchAccessTokenSnapshot(r);if(e.accessTokenContractAddress!==this.contract.address||e.chainId!==r)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,senderAddresses:e.senderAddresses,senderAddressIndexMap:e.senderAddressIndexMap}}persistSnapshot(r){return Promise.resolve()}}exports.ClientAccessTokenSnapshotService=c;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { AbstractAccessTokenSnapshotService as s } from "../event-service/AbstractAccessTokenSnapshotService.mjs";
|
|
2
2
|
import "ethers";
|
|
3
|
-
import "circomlibjs";
|
|
4
3
|
import "libsodium-wrappers";
|
|
5
4
|
import "process";
|
|
6
5
|
import "buffer";
|
|
7
6
|
import "../../constants/vite.constants.mjs";
|
|
8
7
|
import "../../constants/reorg-depths.constants.mjs";
|
|
9
8
|
import { fetchAccessTokenSnapshot as t } from "../../API/fetchCommitmentsCache.mjs";
|
|
10
|
-
class
|
|
9
|
+
class l extends s {
|
|
11
10
|
constructor(r, e) {
|
|
12
11
|
super(r, 0, !1, e);
|
|
13
12
|
}
|
|
@@ -27,5 +26,5 @@ class k extends s {
|
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
28
|
export {
|
|
30
|
-
|
|
29
|
+
l as ClientAccessTokenSnapshotService
|
|
31
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const r=require("../event-service/AbstractCommitmentsSnapshotService.cjs"),s=require("../../API/fetchCommitmentsCache.cjs");class i extends r.AbstractCommitmentsSnapshotService{constructor(t,e){super(t,0,!1,e)}async fetchSnapshot(){const{chainId:t}=await this.contract.provider.getNetwork(),e=await s.fetchCommitmentsSnapshot(t);if(e.hinkalAddress!==this.contract.address||e.chainId!==t)throw Error("Commitment Snapshot: incorrect contract or chain id");return{latestBlockNumber:e.latestBlockNumber,merkleTree:e.merkleTree,encryptedOutputs:e.encryptedOutputs}}persistSnapshot(t){return Promise.resolve()}}exports.ClientCommitmentsSnapshotService=i;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "ethers";
|
|
2
|
-
import "circomlibjs";
|
|
3
2
|
import "libsodium-wrappers";
|
|
4
3
|
import "process";
|
|
5
4
|
import "buffer";
|
|
@@ -7,7 +6,7 @@ import "../../constants/vite.constants.mjs";
|
|
|
7
6
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
7
|
import { AbstractCommitmentsSnapshotService as e } from "../event-service/AbstractCommitmentsSnapshotService.mjs";
|
|
9
8
|
import { fetchCommitmentsSnapshot as o } from "../../API/fetchCommitmentsCache.mjs";
|
|
10
|
-
class
|
|
9
|
+
class l extends e {
|
|
11
10
|
constructor(r, t) {
|
|
12
11
|
super(r, 0, !1, t);
|
|
13
12
|
}
|
|
@@ -26,5 +25,5 @@ class u extends e {
|
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
27
|
export {
|
|
29
|
-
|
|
28
|
+
l as ClientCommitmentsSnapshotService
|
|
30
29
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");require("process");require("buffer");require("../../constants/vite.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const t=require("../event-service/AbstractNullifierSnapshotService.cjs"),i=require("../../API/fetchNullifiers.cjs");class s extends t.AbstractNullifierSnapshotService{constructor(e,r){super(e,0,!1,r)}async fetchSnapshot(){const{chainId:e}=await this.contract.provider.getNetwork(),r=await i.fetchNullifiers(e);return{latestBlockNumber:r.latestBlockNumber,nullifiers:r.nullifiers}}persistSnapshot(e){return Promise.resolve()}}exports.ClientNullifierSnapshotService=s;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "ethers";
|
|
2
|
-
import "circomlibjs";
|
|
3
2
|
import "libsodium-wrappers";
|
|
4
3
|
import "process";
|
|
5
4
|
import "buffer";
|
|
@@ -7,7 +6,7 @@ import "../../constants/vite.constants.mjs";
|
|
|
7
6
|
import "../../constants/reorg-depths.constants.mjs";
|
|
8
7
|
import { AbstractNullifierSnapshotService as e } from "../event-service/AbstractNullifierSnapshotService.mjs";
|
|
9
8
|
import { fetchNullifiers as i } from "../../API/fetchNullifiers.mjs";
|
|
10
|
-
class
|
|
9
|
+
class f extends e {
|
|
11
10
|
constructor(t, r) {
|
|
12
11
|
super(t, 0, !1, r);
|
|
13
12
|
}
|
|
@@ -23,5 +22,5 @@ class h extends e {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
export {
|
|
26
|
-
|
|
25
|
+
f as ClientNullifierSnapshotService
|
|
27
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("../../data-structures/utxo/Utxo.cjs"),
|
|
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("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const q=(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=q;
|
|
@@ -7,12 +7,11 @@ import "../../constants/vite.constants.mjs";
|
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
-
import "circomlibjs";
|
|
11
10
|
import "libsodium-wrappers";
|
|
12
11
|
import "process";
|
|
13
12
|
import "buffer";
|
|
14
13
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
|
-
const
|
|
14
|
+
const I = (i, r, o, e, m) => {
|
|
16
15
|
let t = 0n;
|
|
17
16
|
if (r.forEach((p) => {
|
|
18
17
|
t += p.amount;
|
|
@@ -29,5 +28,5 @@ const P = (i, r, o, e, m) => {
|
|
|
29
28
|
] };
|
|
30
29
|
};
|
|
31
30
|
export {
|
|
32
|
-
|
|
31
|
+
I as outputUtxoProcessing
|
|
33
32
|
};
|
|
@@ -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("
|
|
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("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;
|
|
@@ -11,7 +11,6 @@ import { INTERACTION as c } from "../../types/hinkal.types.mjs";
|
|
|
11
11
|
import { SlippageType as b } from "../../types/slippage.types.mjs";
|
|
12
12
|
import "../../types/transactions.types.mjs";
|
|
13
13
|
import "../../types/curve.types.mjs";
|
|
14
|
-
import "circomlibjs";
|
|
15
14
|
import "libsodium-wrappers";
|
|
16
15
|
import "process";
|
|
17
16
|
import "buffer";
|
|
@@ -25,19 +24,19 @@ const p = (D, r, E) => {
|
|
|
25
24
|
feeUnit: E
|
|
26
25
|
});
|
|
27
26
|
return r;
|
|
28
|
-
},
|
|
27
|
+
}, x = ({
|
|
29
28
|
erc20Addresses: D = [],
|
|
30
29
|
amountChanges: r,
|
|
31
30
|
flatFees: E,
|
|
32
31
|
feeUnit: A,
|
|
33
32
|
externalActionId: T,
|
|
34
|
-
action:
|
|
33
|
+
action: P,
|
|
35
34
|
gasTokenAddress: w
|
|
36
35
|
}) => {
|
|
37
|
-
const
|
|
38
|
-
if (
|
|
36
|
+
const i = d(T, P);
|
|
37
|
+
if (i === c.NONE)
|
|
39
38
|
throw Error("No interaction was choosen");
|
|
40
|
-
switch (
|
|
39
|
+
switch (i) {
|
|
41
40
|
case c.WITHDRAW: {
|
|
42
41
|
p(
|
|
43
42
|
r[0],
|
|
@@ -96,7 +95,7 @@ const p = (D, r, E) => {
|
|
|
96
95
|
);
|
|
97
96
|
break;
|
|
98
97
|
case c.BEEFY: {
|
|
99
|
-
const k = R(
|
|
98
|
+
const k = R(P) ? 1 : 0;
|
|
100
99
|
r[k] = p(
|
|
101
100
|
r[k],
|
|
102
101
|
N(
|
|
@@ -213,5 +212,5 @@ const p = (D, r, E) => {
|
|
|
213
212
|
return r;
|
|
214
213
|
};
|
|
215
214
|
export {
|
|
216
|
-
|
|
215
|
+
x as processAmountChanges
|
|
217
216
|
};
|
|
@@ -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("libsodium-wrappers");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("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 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;
|
|
@@ -15,7 +15,6 @@ import { PendleAssetType as d, PendleSwapType as t } from "../../types/pendle.ty
|
|
|
15
15
|
import "../../types/curve.types.mjs";
|
|
16
16
|
import "ethers";
|
|
17
17
|
import "libsodium-wrappers";
|
|
18
|
-
import "circomlibjs";
|
|
19
18
|
import "idb-keyval";
|
|
20
19
|
import "../utils/external-action.utils.mjs";
|
|
21
20
|
import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
|
|
@@ -27,14 +26,14 @@ import "../utils/userAgent.mjs";
|
|
|
27
26
|
import "../../data-structures/custom-token-registry/CustomTokenRegistry.mjs";
|
|
28
27
|
import "../../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
29
28
|
import { isInEnum as w } from "../utils/enum.utils.mjs";
|
|
30
|
-
function
|
|
29
|
+
function j(e) {
|
|
31
30
|
if (!e)
|
|
32
31
|
return;
|
|
33
32
|
const r = T(e.address, e.chainId);
|
|
34
33
|
if (!r?.isVolatile)
|
|
35
34
|
return r?.symbol.toLowerCase() === "weth" && console.log("token:", r), r;
|
|
36
35
|
}
|
|
37
|
-
function
|
|
36
|
+
function z(e, r) {
|
|
38
37
|
if (!e || !r)
|
|
39
38
|
return;
|
|
40
39
|
let o;
|
|
@@ -57,7 +56,7 @@ function H(e, r) {
|
|
|
57
56
|
}
|
|
58
57
|
return o;
|
|
59
58
|
}
|
|
60
|
-
const
|
|
59
|
+
const H = (e, r, o) => {
|
|
61
60
|
if (i(e.yt.address, o.erc20TokenAddress))
|
|
62
61
|
return t.SwapExactTokenForYt;
|
|
63
62
|
if (i(e.pt.address, o.erc20TokenAddress))
|
|
@@ -66,7 +65,7 @@ const J = (e, r, o) => {
|
|
|
66
65
|
return t.SwapExactYtForToken;
|
|
67
66
|
if (i(e.pt.address, r.erc20TokenAddress))
|
|
68
67
|
return t.SwapExactPtForToken;
|
|
69
|
-
},
|
|
68
|
+
}, J = (e) => {
|
|
70
69
|
let r;
|
|
71
70
|
switch (e) {
|
|
72
71
|
case t.SwapExactTokenForYt:
|
|
@@ -85,7 +84,7 @@ const J = (e, r, o) => {
|
|
|
85
84
|
throw new Error("Cant determine Pendle Swap Type Api Route");
|
|
86
85
|
}
|
|
87
86
|
return r;
|
|
88
|
-
},
|
|
87
|
+
}, K = (e, r, o, s) => {
|
|
89
88
|
if (!w(p, e))
|
|
90
89
|
throw new Error("getTokenIndexForPendleFlatFee: Invalid Pendle Action");
|
|
91
90
|
if (s)
|
|
@@ -99,9 +98,9 @@ const J = (e, r, o) => {
|
|
|
99
98
|
return (e === p.Mint || e === p.Redeem || e === p.PoolRemove) && (c = l), c;
|
|
100
99
|
};
|
|
101
100
|
export {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
H as determinePendleSwapType,
|
|
102
|
+
J as determinePendleSwapTypeApiRoute,
|
|
103
|
+
j as erc20TokenFromPendleAsset,
|
|
104
|
+
z as getAssetTypeFromPendleMarket,
|
|
105
|
+
K as getTokenIndexForPendleFlatFee
|
|
107
106
|
};
|
|
@@ -1 +1 @@
|
|
|
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("
|
|
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("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,43 +1,42 @@
|
|
|
1
1
|
import { ethers as n } from "ethers";
|
|
2
|
-
import { UserKeys as
|
|
2
|
+
import { UserKeys as p } from "../../data-structures/crypto-keys/keys.mjs";
|
|
3
3
|
import d from "libsodium-wrappers";
|
|
4
4
|
import { poseidonHash as c } from "../../crypto/poseidon.mjs";
|
|
5
|
-
import "circomlibjs";
|
|
6
5
|
import "process";
|
|
7
6
|
import "buffer";
|
|
8
7
|
var s = {};
|
|
9
|
-
const
|
|
8
|
+
const _ = (t, e, r) => {
|
|
10
9
|
const o = n.utils.defaultAbiCoder.encode(
|
|
11
10
|
["uint256", "address"],
|
|
12
11
|
[t, e]
|
|
13
12
|
), i = d.crypto_box_seal(o, n.utils.arrayify(r));
|
|
14
13
|
return `0x${s.from(i).toString("hex")}`;
|
|
15
|
-
},
|
|
16
|
-
const r = s.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } =
|
|
14
|
+
}, h = (t, e) => {
|
|
15
|
+
const r = s.from(t.slice(2), "hex"), { publicKey: o, privateKey: i } = p.getEncryptionKeyPair(e.getShieldedPrivateKey());
|
|
17
16
|
try {
|
|
18
17
|
const a = d.crypto_box_seal_open(
|
|
19
18
|
r,
|
|
20
19
|
n.utils.arrayify(o),
|
|
21
20
|
n.utils.arrayify(i)
|
|
22
|
-
), u = s.from(a).toString("utf-8"), [
|
|
21
|
+
), u = s.from(a).toString("utf-8"), [y, l] = n.utils.defaultAbiCoder.decode(
|
|
23
22
|
["uint256", "address"],
|
|
24
23
|
u
|
|
25
24
|
);
|
|
26
|
-
return { stakeBlinding:
|
|
25
|
+
return { stakeBlinding: y.toBigInt(), stakedTokenRecipient: l };
|
|
27
26
|
} catch {
|
|
28
27
|
console.log("failed to decrypt");
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
},
|
|
30
|
+
}, x = (t, e, r, o, i, a) => BigInt(
|
|
32
31
|
c(...[t, e, r, o, i, a].map(BigInt))
|
|
33
|
-
),
|
|
32
|
+
), B = (t, e) => c(t, e), K = (t, e, r, o, i) => n.utils.defaultAbiCoder.encode(
|
|
34
33
|
["uint8", "uint256", "address", "bytes", "bytes"],
|
|
35
34
|
[t, e, r, o, i]
|
|
36
35
|
);
|
|
37
36
|
export {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
B as calculateStakeNullifier,
|
|
38
|
+
x as createStakeCommitment,
|
|
39
|
+
h as decryptStake,
|
|
40
|
+
K as encodeHStakeMetadata,
|
|
41
|
+
_ as encryptStake
|
|
43
42
|
};
|
|
@@ -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("../../../API/callRelayer.cjs");require("../../../constants/chains.constants.cjs");require("ethers");require("libsodium-wrappers");require("../../../constants/vite.constants.cjs");const n=require("../../snarkjs/common.snarkjs.cjs");require("../../../types/circom-data.types.cjs");require("../../utils/external-action.utils.cjs");const u=async(a,r,s,c,t)=>{const o=n.serializeCircomData(c),e=await i.callRelayerTransactAPI(a,{a:r[0],b:r[1],c:r[2],dimData:s,circomData:o,withPrivateMempool:t});if(e.status==="success")return e.message;throw new Error(e.error)};exports.transactCallRelayer=u;
|
|
@@ -1,25 +1,24 @@
|
|
|
1
|
-
import { callRelayerTransactAPI as
|
|
1
|
+
import { callRelayerTransactAPI as i } from "../../../API/callRelayer.mjs";
|
|
2
2
|
import "../../../constants/chains.constants.mjs";
|
|
3
3
|
import "ethers";
|
|
4
4
|
import "libsodium-wrappers";
|
|
5
|
-
import "circomlibjs";
|
|
6
5
|
import "../../../constants/vite.constants.mjs";
|
|
7
6
|
import { serializeCircomData as m } from "../../snarkjs/common.snarkjs.mjs";
|
|
8
7
|
import "../../../types/circom-data.types.mjs";
|
|
9
8
|
import "../../utils/external-action.utils.mjs";
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const g = async (t, r, s, a, c) => {
|
|
10
|
+
const e = m(a), o = await i(t, {
|
|
12
11
|
a: r[0],
|
|
13
12
|
b: r[1],
|
|
14
13
|
c: r[2],
|
|
15
14
|
dimData: s,
|
|
16
|
-
circomData:
|
|
17
|
-
withPrivateMempool:
|
|
15
|
+
circomData: e,
|
|
16
|
+
withPrivateMempool: c
|
|
18
17
|
});
|
|
19
18
|
if (o.status === "success")
|
|
20
19
|
return o.message;
|
|
21
20
|
throw new Error(o.error);
|
|
22
21
|
};
|
|
23
22
|
export {
|
|
24
|
-
|
|
23
|
+
g as transactCallRelayer
|
|
25
24
|
};
|
|
@@ -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("ethers");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("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;
|
|
@@ -15,18 +15,17 @@ import "../../types/circom-data.types.mjs";
|
|
|
15
15
|
import "../../types/transactions.types.mjs";
|
|
16
16
|
import "../../types/curve.types.mjs";
|
|
17
17
|
import "ethers";
|
|
18
|
-
import "circomlibjs";
|
|
19
18
|
import "libsodium-wrappers";
|
|
20
19
|
import "process";
|
|
21
20
|
import "buffer";
|
|
22
|
-
const
|
|
21
|
+
const _ = async (r, t, e, n) => {
|
|
23
22
|
try {
|
|
24
23
|
const o = {
|
|
25
24
|
chainId: r.getCurrentChainId() !== 31337 ? r.getCurrentChainId() : p,
|
|
26
25
|
inputTokens: [
|
|
27
26
|
{
|
|
28
27
|
tokenAddress: t?.wrappedErc20TokenAddress ?? t.erc20TokenAddress,
|
|
29
|
-
amount: u(t,
|
|
28
|
+
amount: u(t, n).toString()
|
|
30
29
|
}
|
|
31
30
|
],
|
|
32
31
|
outputTokens: [
|
|
@@ -39,11 +38,11 @@ const b = async (r, t, e, i) => {
|
|
|
39
38
|
slippageLimitPercent: 10,
|
|
40
39
|
disableRFQs: !0
|
|
41
40
|
// sometimes swap fails because of RFQs
|
|
42
|
-
}, { odosResponse: s, status:
|
|
41
|
+
}, { odosResponse: s, status: i } = await d(
|
|
43
42
|
r.getCurrentChainId(),
|
|
44
43
|
o
|
|
45
44
|
);
|
|
46
|
-
if (
|
|
45
|
+
if (i !== "success")
|
|
47
46
|
throw Error("Odos API Fetch Error");
|
|
48
47
|
return {
|
|
49
48
|
outSwapAmountValue: BigInt(s.outputTokens[0].amount),
|
|
@@ -54,5 +53,5 @@ const b = async (r, t, e, i) => {
|
|
|
54
53
|
}
|
|
55
54
|
};
|
|
56
55
|
export {
|
|
57
|
-
|
|
56
|
+
_ as getOdosPrice
|
|
58
57
|
};
|
|
@@ -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 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("
|
|
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("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 i } 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";
|
|
@@ -16,19 +16,18 @@ 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
18
|
import "ethers";
|
|
19
|
-
import "circomlibjs";
|
|
20
19
|
import "libsodium-wrappers";
|
|
21
20
|
import "process";
|
|
22
21
|
import "buffer";
|
|
23
|
-
const
|
|
22
|
+
const q = async (s, t, n, m) => {
|
|
24
23
|
try {
|
|
25
24
|
const o = {
|
|
26
|
-
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress :
|
|
27
|
-
toTokenAddress:
|
|
25
|
+
fromTokenAddress: t.erc20TokenAddress !== e ? t.erc20TokenAddress : i,
|
|
26
|
+
toTokenAddress: n.erc20TokenAddress !== e ? n.erc20TokenAddress : i,
|
|
28
27
|
fromAddress: e,
|
|
29
28
|
// we user zero address here because this paramater is not relevant to us, only destReceiver is
|
|
30
29
|
destReceiver: s.getContractMetadata(p.OneInchExternalActionContract).address,
|
|
31
|
-
amount: d(t,
|
|
30
|
+
amount: d(t, m),
|
|
32
31
|
slippage: 10,
|
|
33
32
|
disableEstimate: !0,
|
|
34
33
|
// disable gas estimation, we don't need it
|
|
@@ -50,5 +49,5 @@ const v = async (s, t, i, n) => {
|
|
|
50
49
|
}
|
|
51
50
|
};
|
|
52
51
|
export {
|
|
53
|
-
|
|
52
|
+
q as getOneInchPrice
|
|
54
53
|
};
|
|
@@ -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("
|
|
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("libsodium-wrappers");require("process");require("buffer");require("../../constants/reorg-depths.constants.cjs");const d=5e4,m=1,q=11,w=15,g=async(s,o)=>{try{const r=await s.getFeeData(),n=o===0?q: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??m,t??d)},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,18 +1,17 @@
|
|
|
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 T } from "../../error-handling/get-error.message.mjs";
|
|
4
4
|
import "axios";
|
|
5
5
|
import "../../constants/chains.constants.mjs";
|
|
6
6
|
import "../../constants/vite.constants.mjs";
|
|
7
7
|
import "../../types/circom-data.types.mjs";
|
|
8
8
|
import "../../types/transactions.types.mjs";
|
|
9
9
|
import "../../types/curve.types.mjs";
|
|
10
|
-
import "circomlibjs";
|
|
11
10
|
import "libsodium-wrappers";
|
|
12
11
|
import "process";
|
|
13
12
|
import "buffer";
|
|
14
13
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
|
-
const
|
|
14
|
+
const p = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
16
15
|
try {
|
|
17
16
|
const t = await a.getFeeData(), s = e === 0 ? P : d, r = t.gasPrice?.mul(s).div(10) ?? void 0;
|
|
18
17
|
return console.log("getGasPrice , ", r?.toBigInt(), { gasPremiumType: e }), r;
|
|
@@ -47,9 +46,9 @@ const T = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
47
46
|
return console.log("runTransaction: ", n?.hash), await E(
|
|
48
47
|
n,
|
|
49
48
|
i ?? w,
|
|
50
|
-
o ??
|
|
49
|
+
o ?? p
|
|
51
50
|
);
|
|
52
|
-
},
|
|
51
|
+
}, S = async ({
|
|
53
52
|
provider: a,
|
|
54
53
|
contractFunction: e,
|
|
55
54
|
args: t,
|
|
@@ -65,7 +64,7 @@ const T = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
65
64
|
);
|
|
66
65
|
return await u({ contractFunction: e, args: t, gasPrice: o, gasLimit: s, nonce: r, confirmations: i });
|
|
67
66
|
} catch (o) {
|
|
68
|
-
const n =
|
|
67
|
+
const n = T(o);
|
|
69
68
|
if (n === l.MAX_FEE_GAS_ERROR || n === g.TRANSACTION_TIMEOUT) {
|
|
70
69
|
console.log("Timeout Hit: Increase gas");
|
|
71
70
|
const c = await m(
|
|
@@ -79,5 +78,5 @@ const T = 5e4, w = 1, P = 11, d = 15, m = async (a, e) => {
|
|
|
79
78
|
}
|
|
80
79
|
};
|
|
81
80
|
export {
|
|
82
|
-
|
|
81
|
+
S as runContractFunction
|
|
83
82
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=require("ethers"),d=require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const C=require("../../constants/protocol.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const l=require("../../error-handling/error-codes.constants.cjs"),y=require("./etherFunctions.cjs");require("axios");require("../../types/circom-data.types.cjs");const u=require("../../types/ethereum-network.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");require("libsodium-wrappers");require("process");require("buffer");const h=require("../../error-handling/logError.cjs"),w=async(t,c,r,o)=>{const n=(await Promise.all([100,500,3e3,1e4].map(async e=>({poolAddress:await c.getPool(r,o,e),fee:e})))).filter(({poolAddress:e})=>e!==C.zeroAddress),s=await Promise.all(n.map(async e=>({poolAddress:e.poolAddress,fee:e.fee,token1Balance:(await t.balanceOf(e.poolAddress)).toBigInt()}))),i=s.map(e=>e.token1Balance).reduce((e,p)=>p>=e?p:e,0n);if(i===0n)throw new Error(l.transactionErrorCodes.UNISWAP_NOT_ENOUGH_LIQUIDITY);return s.find(e=>e.token1Balance===i)},g=async(t,c,r,o,n)=>{try{if(!d.networkRegistry[t.getCurrentChainId()].quoterV2Address)throw Error("No Quoter Contract Provided");return(await t.getContractWithFetcher(u.ContractType.UniswapV3QuoterContract,d.networkRegistry[t.getCurrentChainId()].quoterV2Address).callStatic.quoteExactInputSingle({tokenIn:c.wrappedErc20TokenAddress??c.erc20TokenAddress,tokenOut:r.wrappedErc20TokenAddress??r.erc20TokenAddress,fee:o,amountIn:n,sqrtPriceLimitX96:0})).amountOut.toBigInt()}catch(s){throw h.logError(s),s}},q=async(t,c,r)=>{try{const o=t.getCurrentChainId(),n=t.getContractWithFetcher(u.ContractType.UniswapV3FactoryContract,d.networkRegistry[o].uniswapV3FactoryAddress),s=t.getContractWithFetcher(u.ContractType.ERC20Contract,r.wrappedErc20TokenAddress??r.erc20TokenAddress),{fee:a}=await w(s,n,c.wrappedErc20TokenAddress??c.erc20TokenAddress,r.wrappedErc20TokenAddress??r.erc20TokenAddress);return a}catch(o){throw console.log("Error in getUniswapFee",o),o}},P=async(t,c,r,o)=>{try{const n=await q(t,r,o),s=A.utils.defaultAbiCoder.encode(["uint24"],[n]),a=y.getAmountInWei(r,c);return{tokenPrice:await g(t,r,o,n,a),poolFee:s}}catch(n){throw console.log({error:n}),Error(l.transactionErrorCodes.NO_UNISWAP_PRICE)}};exports.getUniswapFee=q;exports.getUniswapPrice=P;exports.getUniswapPriceHelper=g;exports.searchPoolAndFee=w;
|
|
@@ -15,7 +15,6 @@ 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 "libsodium-wrappers";
|
|
20
19
|
import "process";
|
|
21
20
|
import "buffer";
|
|
@@ -71,7 +70,7 @@ const g = async (e, c, t, o) => {
|
|
|
71
70
|
} catch (o) {
|
|
72
71
|
throw console.log("Error in getUniswapFee", o), o;
|
|
73
72
|
}
|
|
74
|
-
},
|
|
73
|
+
}, z = async (e, c, t, o) => {
|
|
75
74
|
try {
|
|
76
75
|
const n = await I(e, t, o), s = l.defaultAbiCoder.encode(["uint24"], [n]), a = A(t, c);
|
|
77
76
|
return { tokenPrice: await f(e, t, o, n, a), poolFee: s };
|
|
@@ -81,7 +80,7 @@ const g = async (e, c, t, o) => {
|
|
|
81
80
|
};
|
|
82
81
|
export {
|
|
83
82
|
I as getUniswapFee,
|
|
84
|
-
|
|
83
|
+
z as getUniswapPrice,
|
|
85
84
|
f as getUniswapPriceHelper,
|
|
86
85
|
g as searchPoolAndFee
|
|
87
86
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");const t=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");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 u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const r=require("./EthersProviderAdapter.cjs"),a=async i=>{await u.preProcessing();const e=new t.Hinkal;return r.ethersProvierAdapter.initSigner?.(i),await e.initProviderAdapter(void 0,r.ethersProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareEthersHinkal=a;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "ethers";
|
|
2
2
|
import "libsodium-wrappers";
|
|
3
|
-
import "circomlibjs";
|
|
4
3
|
import { Hinkal as o } from "../data-structures/Hinkal/Hinkal.mjs";
|
|
5
4
|
import "../constants/chains.constants.mjs";
|
|
6
5
|
import "../types/circom-data.types.mjs";
|
|
@@ -21,11 +20,11 @@ import "../functions/web3/events/getShieldedBalance.mjs";
|
|
|
21
20
|
import "../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
22
21
|
import "idb-keyval";
|
|
23
22
|
import { ethersProvierAdapter as i } from "./EthersProviderAdapter.mjs";
|
|
24
|
-
const
|
|
23
|
+
const M = async (t) => {
|
|
25
24
|
await p();
|
|
26
25
|
const r = new o();
|
|
27
26
|
return i.initSigner?.(t), await r.initProviderAdapter(void 0, i), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
28
27
|
};
|
|
29
28
|
export {
|
|
30
|
-
|
|
29
|
+
M as prepareEthersHinkal
|
|
31
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("ethers");require("libsodium-wrappers");const i=require("../data-structures/Hinkal/Hinkal.cjs");require("../constants/chains.constants.cjs");require("../types/circom-data.types.cjs");require("../types/transactions.types.cjs");require("../types/curve.types.cjs");require("../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../constants/vite.constants.cjs");require("axios");require("../constants/coingecko.constants.cjs");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 u=require("../crypto/preProcessing.cjs");require("../functions/utils/external-action.utils.cjs");require("../functions/web3/events/getShieldedBalance.cjs");require("../data-structures/volatile-helper/VolatileHelper.cjs");require("idb-keyval");const a=require("./Wagmiv1ProviderAdapter.cjs"),q=async r=>{await u.preProcessing();const e=new i.Hinkal;return await e.initProviderAdapter(r,a.wagmiv1ProvierAdapter),await e.initUserKeys(),await e.resetMerkle(),e};exports.prepareWagmiv1Hinkal=q;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "ethers";
|
|
2
2
|
import "libsodium-wrappers";
|
|
3
|
-
import "circomlibjs";
|
|
4
3
|
import { Hinkal as t } from "../data-structures/Hinkal/Hinkal.mjs";
|
|
5
4
|
import "../constants/chains.constants.mjs";
|
|
6
5
|
import "../types/circom-data.types.mjs";
|
|
@@ -21,11 +20,11 @@ import "../functions/web3/events/getShieldedBalance.mjs";
|
|
|
21
20
|
import "../data-structures/volatile-helper/VolatileHelper.mjs";
|
|
22
21
|
import "idb-keyval";
|
|
23
22
|
import { wagmiv1ProvierAdapter as p } from "./Wagmiv1ProviderAdapter.mjs";
|
|
24
|
-
const
|
|
23
|
+
const U = async (i) => {
|
|
25
24
|
await o();
|
|
26
25
|
const r = new t();
|
|
27
26
|
return await r.initProviderAdapter(i, p), await r.initUserKeys(), await r.resetMerkle(), r;
|
|
28
27
|
};
|
|
29
28
|
export {
|
|
30
|
-
|
|
29
|
+
U as prepareWagmiv1Hinkal
|
|
31
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/utxoWorkerLauncher-CSVnxNdb.js").href:new URL("../../assets/utxoWorkerLauncher-CSVnxNdb.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-
|
|
1
|
+
"use strict";const e=""+(typeof document>"u"?require("url").pathToFileURL(__dirname+"/../../assets/zkProofWorkerLauncher-B6UuEvvB.js").href:new URL("../../assets/zkProofWorkerLauncher-B6UuEvvB.js",document.currentScript&&document.currentScript.src||document.baseURI).href);module.exports=e;
|