@hinkal/common 0.1.33 → 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/fees.constants.cjs +1 -1
- package/constants/fees.constants.mjs +22 -22
- package/data-structures/Hinkal/Hinkal.cjs +1 -1
- package/data-structures/Hinkal/Hinkal.d.ts +1 -0
- package/data-structures/Hinkal/Hinkal.mjs +13 -10
- package/data-structures/Hinkal/IHinkal.d.ts +2 -1
- package/data-structures/Hinkal/hinkalActionBeefy.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionBeefy.mjs +18 -20
- package/data-structures/Hinkal/hinkalActionConvex.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionConvex.mjs +18 -21
- package/data-structures/Hinkal/hinkalActionLidoEth.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionLidoEth.mjs +31 -31
- package/data-structures/Hinkal/hinkalActionPendle.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendle.mjs +77 -80
- package/data-structures/Hinkal/hinkalActionPendleLP.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionPendleLP.mjs +34 -34
- package/data-structures/Hinkal/hinkalActionStake.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionStake.mjs +48 -52
- package/data-structures/Hinkal/hinkalActionVolatile.cjs +1 -1
- package/data-structures/Hinkal/hinkalActionVolatile.mjs +38 -44
- package/data-structures/Hinkal/hinkalDeposit.cjs +1 -1
- package/data-structures/Hinkal/hinkalDeposit.mjs +27 -28
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.cjs +1 -4
- package/data-structures/event-service/AbstractCommitmentsSnapshotService.mjs +11 -16
- package/data-structures/transactions-manager/TransactionsManager.cjs +1 -1
- package/data-structures/transactions-manager/TransactionsManager.mjs +66 -74
- package/data-structures/transactions-manager/history/getVolatileData.cjs +1 -1
- package/data-structures/transactions-manager/history/getVolatileData.mjs +13 -13
- package/data-structures/volatile-helper/VolatileHelper.cjs +1 -1
- package/data-structures/volatile-helper/VolatileHelper.mjs +60 -60
- package/functions/pre-transaction/getFlatFees.cjs +1 -1
- package/functions/pre-transaction/getFlatFees.mjs +42 -42
- package/functions/pre-transaction/process-gas-estimates.cjs +1 -1
- package/functions/pre-transaction/process-gas-estimates.mjs +17 -26
- package/functions/protocols/pendle.helpers.cjs +1 -1
- package/functions/protocols/pendle.helpers.mjs +27 -27
- package/functions/snarkjs/constructGeneralZkProof.cjs +1 -1
- package/functions/snarkjs/constructGeneralZkProof.mjs +35 -37
- package/functions/utils/cacheFunctions.cjs +1 -1
- package/functions/utils/cacheFunctions.mjs +27 -30
- package/functions/web3/events/getShieldedBalance.cjs +2 -2
- package/functions/web3/events/getShieldedBalance.mjs +25 -25
- package/functions/web3/functionCalls/transactCallDirect.cjs +1 -1
- package/functions/web3/functionCalls/transactCallDirect.mjs +15 -15
- package/functions/web3/runContractFunction.cjs +1 -1
- package/functions/web3/runContractFunction.mjs +37 -37
- package/functions/web3/uniswapAPI.cjs +1 -1
- package/functions/web3/uniswapAPI.mjs +28 -28
- package/package.json +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLauncher.mjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.cjs +1 -1
- package/webworker/snarkjsWorker/snarkjsWorkerLogic.mjs +16 -17
|
@@ -7,10 +7,10 @@ import { getERC20Token as l } from "../../../functions/utils/erc20tokenFunctions
|
|
|
7
7
|
import { caseInsensitiveEqual as i } from "../../../functions/utils/caseInsensitive.utils.mjs";
|
|
8
8
|
import { getERC20Registry as W } from "../../../constants/token-data/ERC20Registry.mjs";
|
|
9
9
|
import { VolatileHelper as g } from "../../volatile-helper/VolatileHelper.mjs";
|
|
10
|
-
const
|
|
11
|
-
const c = W(s), { externalActionMetadata: B } = n, { volatileAmounts: k, redirectActionId:
|
|
10
|
+
const C = async (n, u, s) => {
|
|
11
|
+
const c = W(s), { externalActionMetadata: B } = n, { volatileAmounts: k, redirectActionId: V, volatileAction: A } = g.decodeVolatileMetadata(B);
|
|
12
12
|
if (A === f.Deposit) {
|
|
13
|
-
const r = n.erc20TokenAddresses[0], e = c.find((
|
|
13
|
+
const r = n.erc20TokenAddresses[0], e = c.find((t) => i(t.sharedAddress, r));
|
|
14
14
|
if (!e)
|
|
15
15
|
throw Error("Volatile not found in statistics");
|
|
16
16
|
return {
|
|
@@ -22,7 +22,7 @@ const N = async (n, u, s) => {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
if (A === f.Withdraw) {
|
|
25
|
-
const r = n.erc20TokenAddresses[0], e = c.find((
|
|
25
|
+
const r = n.erc20TokenAddresses[0], e = c.find((t) => i(t.sharedAddress, r));
|
|
26
26
|
if (!e)
|
|
27
27
|
throw Error("Volatile not found in statistics");
|
|
28
28
|
return {
|
|
@@ -34,22 +34,22 @@ const N = async (n, u, s) => {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
if (A === f.Swap) {
|
|
37
|
-
const r = n.erc20TokenAddresses[0], e = n.erc20TokenAddresses[1], T = n.amountChanges[0].toBigInt(), a = c.find((
|
|
38
|
-
if (!a && !
|
|
37
|
+
const r = n.erc20TokenAddresses[0], e = n.erc20TokenAddresses[1], T = n.amountChanges[0].toBigInt(), a = c.find((o) => i(o.sharedAddress, r)), t = c.find((o) => i(o.sharedAddress, e));
|
|
38
|
+
if (!a && !t)
|
|
39
39
|
throw Error("Volatile not found in swap statistics");
|
|
40
|
-
const
|
|
40
|
+
const E = {
|
|
41
41
|
token: l(a ? a.erc20TokenAddress : r, s),
|
|
42
42
|
balance: a ? k[0].toBigInt() : T
|
|
43
|
-
}, m = u.find((
|
|
43
|
+
}, m = u.find((o) => i(o.erc20TokenAddress, e));
|
|
44
44
|
let p = { token: l(e, s), balance: m?.amount };
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
|
|
45
|
+
if (t) {
|
|
46
|
+
const o = await g.getVolatileTokenBalance(s, e, m?.amount ?? 0n);
|
|
47
|
+
p = { token: t, balance: o };
|
|
48
48
|
}
|
|
49
|
-
return { tokenIn:
|
|
49
|
+
return { tokenIn: E, tokenOut: p, type: d.SWAP, protocol: V.toBigInt() };
|
|
50
50
|
}
|
|
51
51
|
return { type: d.UNKNOWN };
|
|
52
52
|
};
|
|
53
53
|
export {
|
|
54
|
-
|
|
54
|
+
C as getVolatileData
|
|
55
55
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),d=require("../../constants/protocol.constants.cjs"),h=require("../../constants/chains.constants.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("ethers"),d=require("../../constants/protocol.constants.cjs"),h=require("../../constants/chains.constants.cjs"),i=require("../../types/hinkal.types.cjs"),w=require("../../types/ethereum-network.types.cjs"),A=require("../../types/external-action.types.cjs"),v=require("../../functions/utils/erc20tokenFunctions.cjs"),T=require("../../functions/utils/external-action.utils.cjs"),f=require("../../functions/utils/enum.utils.cjs"),g=new u.ethers.utils.Interface(["function volatileTokenToShareToken(address volatileToken) external view returns (address)","function shareTokenToVolatileToken(address volatileToken) external view returns (address)","function shareToVolatile(address shareToken, uint shareValue) external view returns (uint)","function volatileToShare(address volatileToken, uint volatileTokenValue, uint volatileTokenBalanceOverride) external view returns (uint)"]);class a{static getVolatileTokenAction(o){const n=h.networkRegistry[o],{fetchRpcUrl:t}=n,{volatileTokenActionInstanceAddress:e}=n.contractData;if(!e)throw Error("Volatile Token Address not found");const r=new u.ethers.providers.JsonRpcProvider(t);return new u.ethers.Contract(e,g,r)}static getVolatileTokenAddress=async(o,n)=>{try{const e=await a.getVolatileTokenAction(o).shareTokenToVolatileToken(n);if(e===d.zeroAddress)throw new Error("Can't get share token address");return e}catch(t){console.log("getShareTokenAddress error ",t.message);return}};static getShareTokenAddress=async(o,n)=>{if(n===d.zeroAddress)return a.getShareTokenAddress(o,d.ethVolatileAddress);try{const e=await a.getVolatileTokenAction(o).volatileTokenToShareToken(n);if(e===d.zeroAddress)throw new Error("Can't get share token address");return e}catch(t){console.log("getShareTokenAddress error ",t.message);return}};static getVolatileTokenBalance=async(o,n,t,e)=>{try{if(t===0n)return 0n;const r=a.getVolatileTokenAction(o),l=t<0n?-1n:1n,c=e?{blockTag:e}:{};return l*(await r.shareToVolatile(n,l*t,c)).toBigInt()}catch(r){return console.log("getVolatileTokenBalance convertToShare error",r),0n}};static getShareTokenBalance=async(o,n,t)=>{if(n===d.zeroAddress)return this.getShareTokenBalance(o,d.ethVolatileAddress,t);try{if(t===0n)return 0n;const e=a.getVolatileTokenAction(o),r=t<0n?-1n:1n;return r*(await e.volatileToShare(n,r*t,0n)).toBigInt()}catch(e){return console.log("getShareTokenBalance convertToShare error",e),0n}};static processVolatileData=async(o,n,t,e)=>{let r=[];if(n===i.VolatileAction.Deposit)e[0]=0n,t[0]=await a.getShareTokenAddress(o,t[0]),r=[!0];else if(n===i.VolatileAction.Withdraw)e[0]=-1n*await a.getShareTokenBalance(o,t[0],-e[0]),t[0]=await a.getShareTokenAddress(o,t[0]),r=[!1];else if(n===i.VolatileAction.Swap){const l=t.map(c=>v.getERC20Token(c,o));await Promise.all(l.map(async(c,s)=>{c?.isVolatile&&(e[s]<0n?e[s]=-1n*await a.getShareTokenBalance(o,t[s],-e[s]):e[s]>=0n&&(e[s]=0n),t[s]=await a.getShareTokenAddress(o,c.erc20TokenAddress))})),r=[!1,!0]}return{erc20Addresses:t,amountChanges:e,onChainCreation:r}};static decodeVolatileMetadata=o=>{const n=T.decodeMetadata(A.ExternalActionId.Volatile,o),t=n[0],e=n[2],r=n[4],l=f.toEnumValue(i.VolatileAction,r);return{volatileAmounts:t,redirectActionId:e,volatileAction:l}};static encodeVolatileActionMetadata=({actionType:o=i.VolatileAction.Deposit,volatileAmounts:n=[],withdrawRecipient:t=d.zeroAddress,redirectActionId:e=0,redirectMetadata:r="0x00"})=>u.ethers.utils.defaultAbiCoder.encode(["uint256[]","address","uint256","bytes","uint8"],[n,t,e,r,o]);static getVolotileMetadata=(o,n,t,e,r)=>{if(o===i.VolatileAction.Deposit)return{actionType:o,volatileAmounts:n};if(o===i.VolatileAction.Withdraw){if(!t)throw Error("No withdrawal recipient");return{actionType:o,volatileAmounts:n,withdrawRecipient:t}}if(o===i.VolatileAction.Swap){if(e===void 0||!r)throw Error("No redirect action Id");return{actionType:o,volatileAmounts:n,redirectActionId:T.getExternalActionIdHash(e),redirectMetadata:r}}throw new Error("Invalid Request")};static getVolatileExternalData=async(o,n,t,e,r,l)=>{const s=o.getContractWithFetcher(w.ContractType.VolatileTokenAction).address;let k=[];return n===i.VolatileAction.Deposit&&(k=t),n===i.VolatileAction.Withdraw&&(k=[-t[0]]),n===i.VolatileAction.Swap&&(k=[-t[0],0n]),{externalActionId:A.ExternalActionId.Volatile,externalAddress:s,externalActionMetadata:this.encodeVolatileActionMetadata(this.getVolotileMetadata(n,k,e,r,l))}};static decodeExternalActionId=o=>{let n=!1,t;const{externalActionId:e}=o.decodedInput;return(typeof e=="string"?e:e.toBigInt())===T.getExternalActionIdHash(A.ExternalActionId.Volatile)&&({redirectActionId:t}=a.decodeVolatileMetadata(o.decodedInput.externalActionMetadata),n=!0),{isVolatile:n,redirectActionId:t}}}exports.VolatileHelper=a;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { ethers as T } from "ethers";
|
|
2
2
|
import { zeroAddress as d, ethVolatileAddress as u } from "../../constants/protocol.constants.mjs";
|
|
3
3
|
import { networkRegistry as h } from "../../constants/chains.constants.mjs";
|
|
4
|
-
import { VolatileAction as
|
|
5
|
-
import { ContractType as
|
|
4
|
+
import { VolatileAction as i } from "../../types/hinkal.types.mjs";
|
|
5
|
+
import { ContractType as v } from "../../types/ethereum-network.types.mjs";
|
|
6
6
|
import { ExternalActionId as f } from "../../types/external-action.types.mjs";
|
|
7
|
-
import { getERC20Token as
|
|
8
|
-
import { decodeMetadata as A, getExternalActionIdHash as
|
|
7
|
+
import { getERC20Token as g } from "../../functions/utils/erc20tokenFunctions.mjs";
|
|
8
|
+
import { decodeMetadata as A, getExternalActionIdHash as w } from "../../functions/utils/external-action.utils.mjs";
|
|
9
9
|
import { toEnumValue as S } from "../../functions/utils/enum.utils.mjs";
|
|
10
10
|
const V = new T.utils.Interface([
|
|
11
11
|
"function volatileTokenToShareToken(address volatileToken) external view returns (address)",
|
|
@@ -14,16 +14,16 @@ const V = new T.utils.Interface([
|
|
|
14
14
|
"function volatileToShare(address volatileToken, uint volatileTokenValue, uint volatileTokenBalanceOverride) external view returns (uint)"
|
|
15
15
|
]);
|
|
16
16
|
class a {
|
|
17
|
-
static getVolatileTokenAction(
|
|
18
|
-
const
|
|
17
|
+
static getVolatileTokenAction(o) {
|
|
18
|
+
const n = h[o], { fetchRpcUrl: t } = n, { volatileTokenActionInstanceAddress: e } = n.contractData;
|
|
19
19
|
if (!e)
|
|
20
20
|
throw Error("Volatile Token Address not found");
|
|
21
21
|
const r = new T.providers.JsonRpcProvider(t);
|
|
22
22
|
return new T.Contract(e, V, r);
|
|
23
23
|
}
|
|
24
|
-
static getVolatileTokenAddress = async (
|
|
24
|
+
static getVolatileTokenAddress = async (o, n) => {
|
|
25
25
|
try {
|
|
26
|
-
const e = await a.getVolatileTokenAction(
|
|
26
|
+
const e = await a.getVolatileTokenAction(o).shareTokenToVolatileToken(n);
|
|
27
27
|
if (e === d)
|
|
28
28
|
throw new Error("Can't get share token address");
|
|
29
29
|
return e;
|
|
@@ -32,11 +32,11 @@ class a {
|
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
static getShareTokenAddress = async (
|
|
36
|
-
if (
|
|
37
|
-
return a.getShareTokenAddress(
|
|
35
|
+
static getShareTokenAddress = async (o, n) => {
|
|
36
|
+
if (n === d)
|
|
37
|
+
return a.getShareTokenAddress(o, u);
|
|
38
38
|
try {
|
|
39
|
-
const e = await a.getVolatileTokenAction(
|
|
39
|
+
const e = await a.getVolatileTokenAction(o).volatileTokenToShareToken(n);
|
|
40
40
|
if (e === d)
|
|
41
41
|
throw new Error("Can't get share token address");
|
|
42
42
|
return e;
|
|
@@ -45,29 +45,29 @@ class a {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
static getVolatileTokenBalance = async (
|
|
48
|
+
static getVolatileTokenBalance = async (o, n, t, e) => {
|
|
49
49
|
try {
|
|
50
50
|
if (t === 0n)
|
|
51
51
|
return 0n;
|
|
52
|
-
const r = a.getVolatileTokenAction(
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
const r = a.getVolatileTokenAction(o), l = t < 0n ? -1n : 1n, s = e ? { blockTag: e } : {};
|
|
53
|
+
return l * (await r.shareToVolatile(
|
|
54
|
+
n,
|
|
55
|
+
l * t,
|
|
56
56
|
s
|
|
57
57
|
)).toBigInt();
|
|
58
58
|
} catch (r) {
|
|
59
59
|
return console.log("getVolatileTokenBalance convertToShare error", r), 0n;
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
static getShareTokenBalance = async (
|
|
63
|
-
if (
|
|
64
|
-
return this.getShareTokenBalance(
|
|
62
|
+
static getShareTokenBalance = async (o, n, t) => {
|
|
63
|
+
if (n === d)
|
|
64
|
+
return this.getShareTokenBalance(o, u, t);
|
|
65
65
|
try {
|
|
66
66
|
if (t === 0n)
|
|
67
67
|
return 0n;
|
|
68
|
-
const e = a.getVolatileTokenAction(
|
|
68
|
+
const e = a.getVolatileTokenAction(o), r = t < 0n ? -1n : 1n;
|
|
69
69
|
return r * (await e.volatileToShare(
|
|
70
|
-
|
|
70
|
+
n,
|
|
71
71
|
r * t,
|
|
72
72
|
0n
|
|
73
73
|
)).toBigInt();
|
|
@@ -75,85 +75,85 @@ class a {
|
|
|
75
75
|
return console.log("getShareTokenBalance convertToShare error", e), 0n;
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
|
-
static processVolatileData = async (
|
|
78
|
+
static processVolatileData = async (o, n, t, e) => {
|
|
79
79
|
let r = [];
|
|
80
|
-
if (
|
|
81
|
-
e[0] = 0n, t[0] = await a.getShareTokenAddress(
|
|
82
|
-
else if (
|
|
83
|
-
e[0] = -1n * await a.getShareTokenBalance(
|
|
84
|
-
else if (
|
|
85
|
-
const
|
|
80
|
+
if (n === i.Deposit)
|
|
81
|
+
e[0] = 0n, t[0] = await a.getShareTokenAddress(o, t[0]), r = [!0];
|
|
82
|
+
else if (n === i.Withdraw)
|
|
83
|
+
e[0] = -1n * await a.getShareTokenBalance(o, t[0], -e[0]), t[0] = await a.getShareTokenAddress(o, t[0]), r = [!1];
|
|
84
|
+
else if (n === i.Swap) {
|
|
85
|
+
const l = t.map((s) => g(s, o));
|
|
86
86
|
await Promise.all(
|
|
87
|
-
|
|
88
|
-
s?.isVolatile && (
|
|
87
|
+
l.map(async (s, c) => {
|
|
88
|
+
s?.isVolatile && (e[c] < 0n ? e[c] = -1n * await a.getShareTokenBalance(o, t[c], -e[c]) : e[c] >= 0n && (e[c] = 0n), t[c] = await a.getShareTokenAddress(o, s.erc20TokenAddress));
|
|
89
89
|
})
|
|
90
90
|
), r = [!1, !0];
|
|
91
91
|
}
|
|
92
92
|
return { erc20Addresses: t, amountChanges: e, onChainCreation: r };
|
|
93
93
|
};
|
|
94
|
-
static decodeVolatileMetadata = (
|
|
95
|
-
const
|
|
96
|
-
return { volatileAmounts: t, redirectActionId: e, volatileAction:
|
|
94
|
+
static decodeVolatileMetadata = (o) => {
|
|
95
|
+
const n = A(f.Volatile, o), t = n[0], e = n[2], r = n[4], l = S(i, r);
|
|
96
|
+
return { volatileAmounts: t, redirectActionId: e, volatileAction: l };
|
|
97
97
|
};
|
|
98
98
|
// TODO: Type descriminate these base on actionType
|
|
99
99
|
static encodeVolatileActionMetadata = ({
|
|
100
|
-
actionType:
|
|
101
|
-
volatileAmounts:
|
|
100
|
+
actionType: o = i.Deposit,
|
|
101
|
+
volatileAmounts: n = [],
|
|
102
102
|
withdrawRecipient: t = d,
|
|
103
103
|
redirectActionId: e = 0,
|
|
104
104
|
redirectMetadata: r = "0x00"
|
|
105
|
-
}) =>
|
|
105
|
+
}) => T.utils.defaultAbiCoder.encode(
|
|
106
106
|
["uint256[]", "address", "uint256", "bytes", "uint8"],
|
|
107
|
-
[
|
|
108
|
-
)
|
|
109
|
-
static getVolotileMetadata = (
|
|
110
|
-
if (
|
|
107
|
+
[n, t, e, r, o]
|
|
108
|
+
);
|
|
109
|
+
static getVolotileMetadata = (o, n, t, e, r) => {
|
|
110
|
+
if (o === i.Deposit)
|
|
111
111
|
return {
|
|
112
|
-
actionType:
|
|
113
|
-
volatileAmounts:
|
|
112
|
+
actionType: o,
|
|
113
|
+
volatileAmounts: n
|
|
114
114
|
};
|
|
115
|
-
if (
|
|
115
|
+
if (o === i.Withdraw) {
|
|
116
116
|
if (!t)
|
|
117
117
|
throw Error("No withdrawal recipient");
|
|
118
118
|
return {
|
|
119
|
-
actionType:
|
|
120
|
-
volatileAmounts:
|
|
119
|
+
actionType: o,
|
|
120
|
+
volatileAmounts: n,
|
|
121
121
|
withdrawRecipient: t
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
if (
|
|
124
|
+
if (o === i.Swap) {
|
|
125
125
|
if (e === void 0 || !r)
|
|
126
126
|
throw Error("No redirect action Id");
|
|
127
127
|
return {
|
|
128
|
-
actionType:
|
|
129
|
-
volatileAmounts:
|
|
130
|
-
redirectActionId:
|
|
128
|
+
actionType: o,
|
|
129
|
+
volatileAmounts: n,
|
|
130
|
+
redirectActionId: w(e),
|
|
131
131
|
redirectMetadata: r
|
|
132
132
|
};
|
|
133
133
|
}
|
|
134
134
|
throw new Error("Invalid Request");
|
|
135
135
|
};
|
|
136
|
-
static getVolatileExternalData = async (
|
|
137
|
-
const
|
|
136
|
+
static getVolatileExternalData = async (o, n, t, e, r, l) => {
|
|
137
|
+
const c = o.getContractWithFetcher(v.VolatileTokenAction).address;
|
|
138
138
|
let k = [];
|
|
139
|
-
return
|
|
139
|
+
return n === i.Deposit && (k = t), n === i.Withdraw && (k = [-t[0]]), n === i.Swap && (k = [-t[0], 0n]), {
|
|
140
140
|
externalActionId: f.Volatile,
|
|
141
|
-
externalAddress:
|
|
141
|
+
externalAddress: c,
|
|
142
142
|
externalActionMetadata: this.encodeVolatileActionMetadata(
|
|
143
143
|
this.getVolotileMetadata(
|
|
144
|
-
|
|
144
|
+
n,
|
|
145
145
|
k,
|
|
146
146
|
e,
|
|
147
147
|
r,
|
|
148
|
-
|
|
148
|
+
l
|
|
149
149
|
)
|
|
150
150
|
)
|
|
151
151
|
};
|
|
152
152
|
};
|
|
153
|
-
static decodeExternalActionId = (
|
|
154
|
-
let
|
|
155
|
-
const { externalActionId: e } =
|
|
156
|
-
return (typeof e == "string" ? e : e.toBigInt()) ===
|
|
153
|
+
static decodeExternalActionId = (o) => {
|
|
154
|
+
let n = !1, t;
|
|
155
|
+
const { externalActionId: e } = o.decodedInput;
|
|
156
|
+
return (typeof e == "string" ? e : e.toBigInt()) === w(f.Volatile) && ({ redirectActionId: t } = a.decodeVolatileMetadata(o.decodedInput.externalActionMetadata), n = !0), { isVolatile: n, redirectActionId: t };
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
159
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const T=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const R=require("../utils/erc20tokenFunctions.cjs"),D=require("./process-gas-estimates.cjs"),c=require("./interaction-to-action.cjs"),g=async(a,I,o,_,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("../../types/beefy.types.cjs");require("../../types/circom-data.types.cjs");const T=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");require("../../types/curve.types.cjs");const R=require("../utils/erc20tokenFunctions.cjs"),D=require("./process-gas-estimates.cjs"),c=require("./interaction-to-action.cjs"),g=async(a,I,o,_,n,L)=>{let N;const A=c.getInteractionFromAction(o,n);if(A===T.INTERACTION.NONE)throw Error("No interaction was choosen");let t,k,C;switch(A){case T.INTERACTION.WITHDRAW:N=R.getERC20Token(I[0],a);break;case T.INTERACTION.SWAP:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.CURVE_DEPOSIT:N=R.getERC20Token(I[I.length-1],a);break;case T.INTERACTION.CURVE_WITHDRAW:{if(C=I.findIndex(O=>O.toLowerCase()===L?.toLowerCase()),C===-1)throw Error("Curve Withdraw Token Index not found");N=R.getERC20Token(I[C],a);break}case T.INTERACTION.STAKING:case T.INTERACTION.UNSTAKING:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.CLAIMING:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.BEEFY:t=P.isBeefyDeposit(n)?1:0,N=R.getERC20Token(I[t],a);break;case T.INTERACTION.BEEFY_STAKE:case T.INTERACTION.BEEFY_UNSTAKE:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.BEEFY_GET_REWARDS:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.LIDO_STAKE:N=R.getERC20Token(I[0],a);break;case T.INTERACTION.LIDO_REQUEST:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.LIDO_CLAIM:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.PENDLE_TRANSACT:N=R.getERC20Token(I[0],a);break;case T.INTERACTION.PENDLE_YT_IN_SWAP:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.PENDLE_YT_OUT_SWAP:N=R.getERC20Token(I[0],a);break;case T.INTERACTION.PENDLE_PT_SWAP:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.PENDLE_MINT:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.PENDLE_REDEEM:N=R.getERC20Token(I[2],a);break;case T.INTERACTION.PENDLE_CLAIM:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.VOLATILE_WITHDRAW:N=R.getERC20Token(I[0],a);break;case T.INTERACTION.VOLATILE_SWAP:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.PENDLE_LP:k=_.findIndex(O=>O>0),N=R.getERC20Token(I[k],a);break;case T.INTERACTION.PENDLE_LP_CLAIM:N=R.getERC20Token(I[1],a);break;case T.INTERACTION.EMPORIUM:}let E,b;const r=_.length;N&&({priceOfTransactionInToken:E,priceOfTransactionInUSD:b}=await D.processGasEstimates(a,N,o,n,r));const e=new Array(r).fill(0n);switch(A){case T.INTERACTION.WITHDRAW:e[0]=E||0n;break;case T.INTERACTION.SWAP:e[1]=E||0n;break;case T.INTERACTION.CURVE_DEPOSIT:e[e.length-1]=E||0n;break;case T.INTERACTION.CURVE_WITHDRAW:C!==void 0&&(e[C]=E||0n);break;case T.INTERACTION.STAKING:case T.INTERACTION.UNSTAKING:e[1]=E||0n,e[0]=E||0n;break;case T.INTERACTION.CLAIMING:e[1]=E||0n;break;case T.INTERACTION.BEEFY:t&&(e[t]=E||0n);break;case T.INTERACTION.BEEFY_STAKE:e[1]=E||0n,e[0]=E||0n;break;case T.INTERACTION.BEEFY_GET_REWARDS:e[1]=E||0n;break;case T.INTERACTION.LIDO_STAKE:e[0]=E||0n;break;case T.INTERACTION.LIDO_REQUEST:e[1]=E||0n;break;case T.INTERACTION.LIDO_CLAIM:e[1]=E||0n;break;case T.INTERACTION.PENDLE_TRANSACT:e[0]=E||0n;break;case T.INTERACTION.PENDLE_YT_IN_SWAP:e[1]=E||0n;break;case T.INTERACTION.PENDLE_YT_OUT_SWAP:e[0]=E||0n;break;case T.INTERACTION.PENDLE_PT_SWAP:e[1]=E||0n;break;case T.INTERACTION.PENDLE_MINT:e[1]=E||0n;break;case T.INTERACTION.PENDLE_REDEEM:e[2]=E||0n;break;case T.INTERACTION.PENDLE_CLAIM:e[1]=E||0n;break;case T.INTERACTION.VOLATILE_WITHDRAW:e[0]=E||0n;break;case T.INTERACTION.VOLATILE_SWAP:e[1]=E||0n;break;case T.INTERACTION.PENDLE_LP:k!==void 0&&(e[k]=E||0n);break;case T.INTERACTION.PENDLE_LP_CLAIM:e[1]=E||0n;break;case T.INTERACTION.EMPORIUM:break}return{flatFees:e,priceOfTransactionInToken:E,feeUnit:N,priceOfTransactionInUSD:b}};exports.getFlatFees=g;
|
|
@@ -6,102 +6,102 @@ import "../../types/curve.types.mjs";
|
|
|
6
6
|
import { getERC20Token as T } from "../utils/erc20tokenFunctions.mjs";
|
|
7
7
|
import { processGasEstimates as R } from "./process-gas-estimates.mjs";
|
|
8
8
|
import { getInteractionFromAction as A } from "./interaction-to-action.mjs";
|
|
9
|
-
const
|
|
9
|
+
const F = async (t, _, D, N, n, W) => {
|
|
10
10
|
let k;
|
|
11
|
-
const
|
|
12
|
-
if (
|
|
11
|
+
const P = A(D, n);
|
|
12
|
+
if (P === a.NONE)
|
|
13
13
|
throw Error("No interaction was choosen");
|
|
14
|
-
let
|
|
15
|
-
switch (
|
|
14
|
+
let L, o, b;
|
|
15
|
+
switch (P) {
|
|
16
16
|
case a.WITHDRAW:
|
|
17
|
-
k = T(
|
|
17
|
+
k = T(_[0], t);
|
|
18
18
|
break;
|
|
19
19
|
case a.SWAP:
|
|
20
|
-
k = T(
|
|
20
|
+
k = T(_[1], t);
|
|
21
21
|
break;
|
|
22
22
|
case a.CURVE_DEPOSIT:
|
|
23
|
-
k = T(
|
|
23
|
+
k = T(_[_.length - 1], t);
|
|
24
24
|
break;
|
|
25
25
|
case a.CURVE_WITHDRAW: {
|
|
26
|
-
if (b =
|
|
27
|
-
(
|
|
28
|
-
),
|
|
26
|
+
if (b = _.findIndex(
|
|
27
|
+
(r) => r.toLowerCase() === W?.toLowerCase()
|
|
28
|
+
), b === -1)
|
|
29
29
|
throw Error("Curve Withdraw Token Index not found");
|
|
30
|
-
k = T(
|
|
30
|
+
k = T(_[b], t);
|
|
31
31
|
break;
|
|
32
32
|
}
|
|
33
33
|
case a.STAKING:
|
|
34
34
|
case a.UNSTAKING:
|
|
35
|
-
k = T(
|
|
35
|
+
k = T(_[1], t);
|
|
36
36
|
break;
|
|
37
37
|
case a.CLAIMING:
|
|
38
|
-
k = T(
|
|
38
|
+
k = T(_[1], t);
|
|
39
39
|
break;
|
|
40
40
|
case a.BEEFY:
|
|
41
|
-
|
|
41
|
+
L = f(n) ? 1 : 0, k = T(_[L], t);
|
|
42
42
|
break;
|
|
43
43
|
case a.BEEFY_STAKE:
|
|
44
44
|
case a.BEEFY_UNSTAKE:
|
|
45
|
-
k = T(
|
|
45
|
+
k = T(_[1], t);
|
|
46
46
|
break;
|
|
47
47
|
case a.BEEFY_GET_REWARDS:
|
|
48
|
-
k = T(
|
|
48
|
+
k = T(_[1], t);
|
|
49
49
|
break;
|
|
50
50
|
case a.LIDO_STAKE:
|
|
51
|
-
k = T(
|
|
51
|
+
k = T(_[0], t);
|
|
52
52
|
break;
|
|
53
53
|
case a.LIDO_REQUEST:
|
|
54
|
-
k = T(
|
|
54
|
+
k = T(_[1], t);
|
|
55
55
|
break;
|
|
56
56
|
case a.LIDO_CLAIM:
|
|
57
|
-
k = T(
|
|
57
|
+
k = T(_[1], t);
|
|
58
58
|
break;
|
|
59
59
|
case a.PENDLE_TRANSACT:
|
|
60
|
-
k = T(
|
|
60
|
+
k = T(_[0], t);
|
|
61
61
|
break;
|
|
62
62
|
case a.PENDLE_YT_IN_SWAP:
|
|
63
|
-
k = T(
|
|
63
|
+
k = T(_[1], t);
|
|
64
64
|
break;
|
|
65
65
|
case a.PENDLE_YT_OUT_SWAP:
|
|
66
|
-
k = T(
|
|
66
|
+
k = T(_[0], t);
|
|
67
67
|
break;
|
|
68
68
|
case a.PENDLE_PT_SWAP:
|
|
69
|
-
k = T(
|
|
69
|
+
k = T(_[1], t);
|
|
70
70
|
break;
|
|
71
71
|
case a.PENDLE_MINT:
|
|
72
|
-
k = T(
|
|
72
|
+
k = T(_[1], t);
|
|
73
73
|
break;
|
|
74
74
|
case a.PENDLE_REDEEM:
|
|
75
|
-
k = T(
|
|
75
|
+
k = T(_[2], t);
|
|
76
76
|
break;
|
|
77
77
|
case a.PENDLE_CLAIM:
|
|
78
|
-
k = T(
|
|
78
|
+
k = T(_[1], t);
|
|
79
79
|
break;
|
|
80
80
|
case a.VOLATILE_WITHDRAW:
|
|
81
|
-
k = T(
|
|
81
|
+
k = T(_[0], t);
|
|
82
82
|
break;
|
|
83
83
|
case a.VOLATILE_SWAP:
|
|
84
|
-
k = T(
|
|
84
|
+
k = T(_[1], t);
|
|
85
85
|
break;
|
|
86
86
|
case a.PENDLE_LP:
|
|
87
|
-
|
|
87
|
+
o = N.findIndex((r) => r > 0), k = T(_[o], t);
|
|
88
88
|
break;
|
|
89
89
|
case a.PENDLE_LP_CLAIM:
|
|
90
|
-
k = T(
|
|
90
|
+
k = T(_[1], t);
|
|
91
91
|
break;
|
|
92
92
|
case a.EMPORIUM:
|
|
93
93
|
}
|
|
94
|
-
let E,
|
|
95
|
-
const
|
|
96
|
-
k && ({ priceOfTransactionInToken: E, priceOfTransactionInUSD:
|
|
97
|
-
|
|
94
|
+
let E, S;
|
|
95
|
+
const I = N.length;
|
|
96
|
+
k && ({ priceOfTransactionInToken: E, priceOfTransactionInUSD: S } = await R(
|
|
97
|
+
t,
|
|
98
98
|
k,
|
|
99
99
|
D,
|
|
100
100
|
n,
|
|
101
|
-
|
|
101
|
+
I
|
|
102
102
|
));
|
|
103
|
-
const e = new Array(
|
|
104
|
-
switch (
|
|
103
|
+
const e = new Array(I).fill(0n);
|
|
104
|
+
switch (P) {
|
|
105
105
|
case a.WITHDRAW:
|
|
106
106
|
e[0] = E || 0n;
|
|
107
107
|
break;
|
|
@@ -122,7 +122,7 @@ const i = async (_, t, D, N, n, S) => {
|
|
|
122
122
|
e[1] = E || 0n;
|
|
123
123
|
break;
|
|
124
124
|
case a.BEEFY:
|
|
125
|
-
|
|
125
|
+
L && (e[L] = E || 0n);
|
|
126
126
|
break;
|
|
127
127
|
case a.BEEFY_STAKE:
|
|
128
128
|
e[1] = E || 0n, e[0] = E || 0n;
|
|
@@ -167,7 +167,7 @@ const i = async (_, t, D, N, n, S) => {
|
|
|
167
167
|
e[1] = E || 0n;
|
|
168
168
|
break;
|
|
169
169
|
case a.PENDLE_LP:
|
|
170
|
-
|
|
170
|
+
o !== void 0 && (e[o] = E || 0n);
|
|
171
171
|
break;
|
|
172
172
|
case a.PENDLE_LP_CLAIM:
|
|
173
173
|
e[1] = E || 0n;
|
|
@@ -175,8 +175,8 @@ const i = async (_, t, D, N, n, S) => {
|
|
|
175
175
|
case a.EMPORIUM:
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
|
-
return { flatFees: e, priceOfTransactionInToken: E, feeUnit: k, priceOfTransactionInUSD:
|
|
178
|
+
return { flatFees: e, priceOfTransactionInToken: E, feeUnit: k, priceOfTransactionInUSD: S };
|
|
179
179
|
};
|
|
180
180
|
export {
|
|
181
|
-
|
|
181
|
+
F as getFlatFees
|
|
182
182
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("axios");require("../../constants/coingecko.constants.cjs");const q=require("../../API/getGasEstimates.cjs");require("ethers");require("../../types/curve.types.cjs");const l=require("../../error-handling/logError.cjs"),m=require("../utils/amounts.utils.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 g=require("../web3/etherFunctions.cjs"),T=async(s,e,i,n,o,a)=>{let t,r;try{({priceOfTransactionInUSD:t,priceOfTransactionInToken:r}=await q.getGasEstimates(s,e.erc20TokenAddress,i,n,o,a))}catch(u){l.logError("processGasEstimates error:",u)}const c=r?g.getAmountInWei(e,m.getValueFirstNDigit(r,e.decimals)):void 0;return{priceOfTransactionInUSD:t,priceOfTransactionInToken:c}};exports.processGasEstimates=T;
|
|
@@ -2,43 +2,34 @@ import "../../constants/chains.constants.mjs";
|
|
|
2
2
|
import "../../constants/vite.constants.mjs";
|
|
3
3
|
import "axios";
|
|
4
4
|
import "../../constants/coingecko.constants.mjs";
|
|
5
|
-
import { getGasEstimates as
|
|
5
|
+
import { getGasEstimates as c } from "../../API/getGasEstimates.mjs";
|
|
6
6
|
import "ethers";
|
|
7
7
|
import "../../types/curve.types.mjs";
|
|
8
|
-
import { logError as
|
|
9
|
-
import { getValueFirstNDigit as
|
|
8
|
+
import { logError as f } from "../../error-handling/logError.mjs";
|
|
9
|
+
import { getValueFirstNDigit as T } from "../utils/amounts.utils.mjs";
|
|
10
10
|
import "../../constants/contracts.constants.mjs";
|
|
11
11
|
import "../../constants/kyc.constants.mjs";
|
|
12
12
|
import "../../constants/axelar.constants.mjs";
|
|
13
13
|
import "../../constants/rewards.constants.mjs";
|
|
14
14
|
import "../../constants/reorg-depths.constants.mjs";
|
|
15
|
-
import { getAmountInWei as
|
|
16
|
-
const
|
|
17
|
-
let
|
|
15
|
+
import { getAmountInWei as g } from "../web3/etherFunctions.mjs";
|
|
16
|
+
const F = async (i, r, e, m, s, p) => {
|
|
17
|
+
let o, t;
|
|
18
18
|
try {
|
|
19
|
-
({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} = await T(
|
|
19
|
+
({ priceOfTransactionInUSD: o, priceOfTransactionInToken: t } = await c(
|
|
20
|
+
i,
|
|
21
|
+
r.erc20TokenAddress,
|
|
22
|
+
e,
|
|
24
23
|
m,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
p,
|
|
28
|
-
n,
|
|
29
|
-
c
|
|
24
|
+
s,
|
|
25
|
+
p
|
|
30
26
|
));
|
|
31
|
-
} catch (
|
|
32
|
-
|
|
27
|
+
} catch (n) {
|
|
28
|
+
f("processGasEstimates error:", n);
|
|
33
29
|
}
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
status: i,
|
|
37
|
-
priceOfTransactionInUSD: o,
|
|
38
|
-
priceOfTransactionInTokenEstimate: r,
|
|
39
|
-
priceOfTransactionInToken: s
|
|
40
|
-
}), { priceOfTransactionInUSD: o, priceOfTransactionInToken: s };
|
|
30
|
+
const a = t ? g(r, T(t, r.decimals)) : void 0;
|
|
31
|
+
return { priceOfTransactionInUSD: o, priceOfTransactionInToken: a };
|
|
41
32
|
};
|
|
42
33
|
export {
|
|
43
|
-
|
|
34
|
+
F as processGasEstimates
|
|
44
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("../../data-structures/crypto-keys/keys.cjs");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("../../constants/chains.constants.cjs");require("../../constants/vite.constants.cjs");require("../../constants/contracts.constants.cjs");require("../../constants/kyc.constants.cjs");const o=require("../../constants/server.constants.cjs");require("../../constants/coingecko.constants.cjs");require("../../constants/axelar.constants.cjs");require("../../constants/rewards.constants.cjs");require("../../constants/reorg-depths.constants.cjs");const i=require("../utils/caseInsensitive.utils.cjs");require("../../types/circom-data.types.cjs");const s=require("../../types/hinkal.types.cjs");require("../../types/transactions.types.cjs");const n=require("../../types/pendle.types.cjs");require("../../types/curve.types.cjs");require("ethers");require("circomlibjs");require("../../data-structures/crypto-keys/keys.cjs");require("idb-keyval");require("../utils/external-action.utils.cjs");const c=require("../utils/erc20tokenFunctions.cjs");require("../utils/convertIntegrationProviderToExternalActionId.cjs");require("axios");require("../utils/userAgent.cjs");require("../../data-structures/custom-token-registry/CustomTokenRegistry.cjs");require("../../data-structures/volatile-helper/VolatileHelper.cjs");const T=require("../utils/enum.utils.cjs");function P(e){if(!e)return;const r=c.getERC20Token(e.address,e.chainId);if(!r?.isVolatile)return r}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;
|