@aegis-engine/core 0.9.0 → 0.9.1
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/README.md +9 -0
- package/dist/aegis-core.js +1047 -910
- package/package.json +1 -1
package/dist/aegis-core.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
var ns = Object.defineProperty;
|
|
2
2
|
var os = (e, t, n) => t in e ? ns(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var
|
|
4
|
-
import { getAddress as D, encodeAbiParameters as Le, keccak256 as so, zeroAddress as
|
|
5
|
-
import { N as co, I as Z, U as _, J as k, K as
|
|
6
|
-
import { af as
|
|
3
|
+
var j = (e, t, n) => os(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { getAddress as D, encodeAbiParameters as Le, keccak256 as so, zeroAddress as ce, encodeFunctionData as bt, decodeFunctionData as as, http as rs, createPublicClient as is, custom as wt, fallback as ss, isAddress as er, createWalletClient as Lt, erc20Abi as qn, hashTypedData as cs, size as ls, BaseError as ds, ContractFunctionRevertedError as us, ContractFunctionZeroDataError as ms, ExecutionRevertedError as Xo, RpcRequestError as Yo, HttpRequestError as ps, TimeoutError as fs, toHex as hs, formatUnits as Jo } from "viem";
|
|
5
|
+
import { N as co, I as Z, U as _, J as k, K as bs, L as it, M as Dt, O as K, s as S, Q as lo, R as de, S as F, n as b, T as ws, V as ks, W as vs, X as te, o as T, Y as Es, d as Ue, Z as Ce, _ as H, l as B, $ as tr, e as ge, b as Ut, a0 as xe, c as uo, a1 as ys, a2 as Is, a3 as Ve, a4 as tn, a5 as Vt, a6 as He, a7 as As, a8 as mo, a9 as nr, aa as gs, ab as po, ac as Ss, A as Zo, ad as Xe, ae as On } from "./transactionHistory-BhNsDpNJ.js";
|
|
6
|
+
import { af as hf, ag as bf, ah as wf, ai as kf, aj as vf, ak as Ef, al as yf, am as If, an as Af, ao as gf, ap as Sf, aq as Cf, ar as xf, as as Tf, at as Rf, au as Pf, av as Bf, aw as Mf, ax as Df, ay as _f, az as Nf, aA as Ff, aB as qf, aC as Of, aD as Lf, aE as Uf, aF as Vf, aG as Hf, aH as $f, aI as Wf, aJ as Kf, aK as zf, g as Gf, h as jf, j as Qf, k as Xf, m as Yf, a as Jf, p as Zf, f as eh, P as th, q as nh, t as oh, u as ah, v as rh, x as ih, y as sh, z as ch, B as lh, C as dh, aL as uh, aM as mh, D as ph, F as fh, G as hh, H as bh } from "./transactionHistory-BhNsDpNJ.js";
|
|
7
7
|
import { bsc as or, ink as ar, mainnet as rr, base as Cs, unichain as xs } from "viem/chains";
|
|
8
|
-
const X = 1,
|
|
8
|
+
const X = 1, be = 56, Me = 57073, Ln = D("0x00581261a1200956ea05d1810fF28ffd66D8E254"), ir = D("0xe2820f3DA0abC9C65B3727A7103E3F59c00D686E"), sr = D("0xe2820f3DA0abC9C65B3727A7103E3F59c00D686E"), cr = {
|
|
9
9
|
[X]: [Ln],
|
|
10
|
-
[
|
|
10
|
+
[be]: [ir],
|
|
11
11
|
[Me]: [sr],
|
|
12
12
|
130: [D("0x9641682f95bad3305c18c549a483f413d23dc72e")],
|
|
13
13
|
8453: [Ln]
|
|
@@ -126,8 +126,8 @@ const Se = {
|
|
|
126
126
|
universalRouterV2_1_1: "0x8b844f885672f333bc0042cb669255f93a4c1e6b",
|
|
127
127
|
permit2: "0x000000000022D473030F116dDEE9F6B43aC78BA3"
|
|
128
128
|
})
|
|
129
|
-
},
|
|
130
|
-
function
|
|
129
|
+
}, bo = Se[X], Hn = bo.permit2, Bs = bo.quoter;
|
|
130
|
+
function wo(e, t) {
|
|
131
131
|
var n;
|
|
132
132
|
return ((n = t.explorerTxUrl) == null ? void 0 : n.call(t, e)) ?? "#";
|
|
133
133
|
}
|
|
@@ -138,7 +138,7 @@ const Ms = {
|
|
|
138
138
|
router: Ln,
|
|
139
139
|
permit2: Hn,
|
|
140
140
|
quoter: Bs,
|
|
141
|
-
v4Contracts:
|
|
141
|
+
v4Contracts: bo,
|
|
142
142
|
rpcUrls: lr,
|
|
143
143
|
explorerTxUrl: (e) => `https://etherscan.io/tx/${e}`,
|
|
144
144
|
poolExplorerUrl: (e) => `https://app.uniswap.org/explore/pools/ethereum/${e}`,
|
|
@@ -148,13 +148,13 @@ const Ms = {
|
|
|
148
148
|
recipient: sn
|
|
149
149
|
}
|
|
150
150
|
}, Ds = {
|
|
151
|
-
chainId:
|
|
151
|
+
chainId: be,
|
|
152
152
|
chain: or,
|
|
153
153
|
name: "BNB Smart Chain",
|
|
154
154
|
router: ir,
|
|
155
|
-
permit2: Se[
|
|
156
|
-
quoter: Se[
|
|
157
|
-
v4Contracts: Se[
|
|
155
|
+
permit2: Se[be].permit2,
|
|
156
|
+
quoter: Se[be].quoter,
|
|
157
|
+
v4Contracts: Se[be],
|
|
158
158
|
rpcUrls: dr,
|
|
159
159
|
explorerTxUrl: (e) => `https://bscscan.com/tx/${e}`,
|
|
160
160
|
poolExplorerUrl: (e) => `https://app.uniswap.org/explore/pools/bnb/${e}`,
|
|
@@ -180,7 +180,7 @@ const Ms = {
|
|
|
180
180
|
}
|
|
181
181
|
}, ko = {
|
|
182
182
|
[X]: Ms,
|
|
183
|
-
[
|
|
183
|
+
[be]: Ds,
|
|
184
184
|
[Me]: _s
|
|
185
185
|
};
|
|
186
186
|
function Ns(e, t) {
|
|
@@ -275,35 +275,35 @@ const pt = {
|
|
|
275
275
|
}
|
|
276
276
|
}, Kp = {
|
|
277
277
|
BNB: {
|
|
278
|
-
chainId:
|
|
278
|
+
chainId: be,
|
|
279
279
|
address: "0x0000000000000000000000000000000000000000",
|
|
280
280
|
name: "BNB",
|
|
281
281
|
symbol: "BNB",
|
|
282
282
|
decimals: 18
|
|
283
283
|
},
|
|
284
284
|
BNCB: {
|
|
285
|
-
chainId:
|
|
285
|
+
chainId: be,
|
|
286
286
|
address: D("0x4902C5ebc598265Ed2212b559B042De8a5Eeec3f"),
|
|
287
287
|
name: "CEA Industries",
|
|
288
288
|
symbol: "BNCB",
|
|
289
289
|
decimals: 18
|
|
290
290
|
},
|
|
291
291
|
QQQB: {
|
|
292
|
-
chainId:
|
|
292
|
+
chainId: be,
|
|
293
293
|
address: D("0x205812CdBed920aFf76C6580abD681a46D11efc7"),
|
|
294
294
|
name: "Invesco QQQ",
|
|
295
295
|
symbol: "QQQB",
|
|
296
296
|
decimals: 18
|
|
297
297
|
},
|
|
298
298
|
NVDAB: {
|
|
299
|
-
chainId:
|
|
299
|
+
chainId: be,
|
|
300
300
|
address: D("0x02Fca66C1D1aFB4E2A7884261eB00F63598a7436"),
|
|
301
301
|
name: "NVIDIA",
|
|
302
302
|
symbol: "NVDAB",
|
|
303
303
|
decimals: 18
|
|
304
304
|
},
|
|
305
305
|
USDC: {
|
|
306
|
-
chainId:
|
|
306
|
+
chainId: be,
|
|
307
307
|
address: D("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),
|
|
308
308
|
name: "USD Coin",
|
|
309
309
|
symbol: "USDC",
|
|
@@ -369,20 +369,20 @@ const pt = {
|
|
|
369
369
|
symbol: "stETH",
|
|
370
370
|
decimals: 18
|
|
371
371
|
}
|
|
372
|
-
},
|
|
372
|
+
}, Fs = {
|
|
373
373
|
USDC: pt.USDC,
|
|
374
374
|
ETH: vo.ETH,
|
|
375
375
|
WATER: pt.WATER,
|
|
376
376
|
WOOD: pt.WOOD,
|
|
377
377
|
GRASS: pt.GRASS,
|
|
378
378
|
STONE: pt.STONE
|
|
379
|
-
},
|
|
379
|
+
}, qs = Object.values(
|
|
380
380
|
vo
|
|
381
|
-
),
|
|
382
|
-
|
|
381
|
+
), Os = Object.values(
|
|
382
|
+
Fs
|
|
383
383
|
), Gp = {
|
|
384
|
-
default:
|
|
385
|
-
wolfgame:
|
|
384
|
+
default: qs,
|
|
385
|
+
wolfgame: Os
|
|
386
386
|
}, jp = vo, Eo = [
|
|
387
387
|
{
|
|
388
388
|
type: "function",
|
|
@@ -596,21 +596,21 @@ function zs(e, t) {
|
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
598
|
function Gs(e, t) {
|
|
599
|
-
return
|
|
599
|
+
return bt({
|
|
600
600
|
abi: Eo,
|
|
601
601
|
functionName: "execute",
|
|
602
602
|
args: [e, t]
|
|
603
603
|
});
|
|
604
604
|
}
|
|
605
605
|
function js(e) {
|
|
606
|
-
return
|
|
606
|
+
return bt({
|
|
607
607
|
abi: Eo,
|
|
608
608
|
functionName: "permitBatch",
|
|
609
609
|
args: [e.owner, e.permitBatch, e.signature]
|
|
610
610
|
});
|
|
611
611
|
}
|
|
612
612
|
function Qs(e) {
|
|
613
|
-
return
|
|
613
|
+
return bt({
|
|
614
614
|
abi: Eo,
|
|
615
615
|
functionName: "multicall",
|
|
616
616
|
args: [e]
|
|
@@ -661,8 +661,8 @@ function We(e) {
|
|
|
661
661
|
)
|
|
662
662
|
);
|
|
663
663
|
}
|
|
664
|
-
function
|
|
665
|
-
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = Xs(e.fee) ? e.fee : null, a = o ? Ys(o, n) : null, r = t.toLowerCase() ===
|
|
664
|
+
function br(e) {
|
|
665
|
+
const t = e.zeroForOne ? e.poolKey.currency0 : e.poolKey.currency1, n = e.zeroForOne ? e.poolKey.currency1 : e.poolKey.currency0, o = Xs(e.fee) ? e.fee : null, a = o ? Ys(o, n) : null, r = t.toLowerCase() === ce, i = r && e.refundNative, s = zs(
|
|
666
666
|
[
|
|
667
667
|
e.swapAction,
|
|
668
668
|
tt.SETTLE,
|
|
@@ -684,7 +684,7 @@ function wr(e) {
|
|
|
684
684
|
};
|
|
685
685
|
}
|
|
686
686
|
function Zs(e) {
|
|
687
|
-
return _t(e.amountIn, "Swap input amount"), _t(e.amountOutMinimum, "Swap minimum output"),
|
|
687
|
+
return _t(e.amountIn, "Swap input amount"), _t(e.amountOutMinimum, "Swap minimum output"), br({
|
|
688
688
|
swapAction: tt.SWAP_EXACT_IN_SINGLE,
|
|
689
689
|
encodedSwapParams: Le(Us, [
|
|
690
690
|
{
|
|
@@ -707,7 +707,7 @@ function Zs(e) {
|
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
709
|
function ec(e) {
|
|
710
|
-
return _t(e.amountOut, "Swap output amount"), _t(e.amountInMaximum, "Swap maximum input"),
|
|
710
|
+
return _t(e.amountOut, "Swap output amount"), _t(e.amountInMaximum, "Swap maximum input"), br({
|
|
711
711
|
swapAction: tt.SWAP_EXACT_OUT_SINGLE,
|
|
712
712
|
encodedSwapParams: Le(Vs, [
|
|
713
713
|
{
|
|
@@ -801,7 +801,7 @@ const na = "DIRECT-MARKET-001", oc = "0x000000000022D473030F116dDEE9F6B43aC78BA3
|
|
|
801
801
|
quoter: "0x3972C00f7ed4885e145823eb7C655375d275A1C5"
|
|
802
802
|
}
|
|
803
803
|
};
|
|
804
|
-
function
|
|
804
|
+
function U(e, t, n, o, a, r, i, s) {
|
|
805
805
|
const l = rc[e];
|
|
806
806
|
if (!l) throw new Error(`Missing trusted direct-swap contracts for chain ${e}.`);
|
|
807
807
|
return {
|
|
@@ -818,7 +818,7 @@ function j(e, t, n, o, a, r, i, s) {
|
|
|
818
818
|
};
|
|
819
819
|
}
|
|
820
820
|
const ic = [
|
|
821
|
-
|
|
821
|
+
U(
|
|
822
822
|
1,
|
|
823
823
|
"0xc516dba7bd70aa2dcb986bb1c27208ea29ecd097fa0ce636611e88e54ae4444d",
|
|
824
824
|
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -828,7 +828,7 @@ const ic = [
|
|
|
828
828
|
30,
|
|
829
829
|
"0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"
|
|
830
830
|
),
|
|
831
|
-
|
|
831
|
+
U(
|
|
832
832
|
1,
|
|
833
833
|
"0x0f8a98e3fdb7ea4438a3f7342f040cbc9d1eced1b90a876d38f3453100243356",
|
|
834
834
|
"0x670AfdD7226e73d3CC55B5cd83933E46aF22DECd",
|
|
@@ -838,7 +838,7 @@ const ic = [
|
|
|
838
838
|
60,
|
|
839
839
|
"0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"
|
|
840
840
|
),
|
|
841
|
-
|
|
841
|
+
U(
|
|
842
842
|
1,
|
|
843
843
|
"0x3fa06e44e4bee9539887681eab6b608b646784e2027ea6292198cde0690aff54",
|
|
844
844
|
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -848,17 +848,17 @@ const ic = [
|
|
|
848
848
|
60,
|
|
849
849
|
"0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"
|
|
850
850
|
),
|
|
851
|
-
|
|
851
|
+
U(
|
|
852
852
|
1,
|
|
853
853
|
"0x34562283ce0470bd58a621a6132ff67c296723cc62890b0a394e50424e3fef3a",
|
|
854
|
-
|
|
854
|
+
ce,
|
|
855
855
|
18,
|
|
856
856
|
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
857
857
|
6,
|
|
858
858
|
10,
|
|
859
859
|
"0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"
|
|
860
860
|
),
|
|
861
|
-
|
|
861
|
+
U(
|
|
862
862
|
1,
|
|
863
863
|
"0x01409fc6f1bf49e20bf05df5d4dcb96ed3977ea717bc4a135e9deacd92ebc0af",
|
|
864
864
|
"0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6",
|
|
@@ -868,27 +868,27 @@ const ic = [
|
|
|
868
868
|
60,
|
|
869
869
|
"0x8f29BD5c8429730fA4C46e6295c4e679eDEdd0cC"
|
|
870
870
|
),
|
|
871
|
-
|
|
871
|
+
U(
|
|
872
872
|
56,
|
|
873
873
|
"0xd6057c3c613f4cfb085cd17efd08c30a06a08608022912c72c28b2b5636ce2bd",
|
|
874
|
-
|
|
874
|
+
ce,
|
|
875
875
|
18,
|
|
876
876
|
"0x4902C5ebc598265Ed2212b559B042De8a5Eeec3f",
|
|
877
877
|
18,
|
|
878
878
|
50,
|
|
879
879
|
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
880
880
|
),
|
|
881
|
-
|
|
881
|
+
U(
|
|
882
882
|
56,
|
|
883
883
|
"0x1e762d241b34548efca74c52f7fd7491bf29865b40f13b58ccbf2a54d427391e",
|
|
884
|
-
|
|
884
|
+
ce,
|
|
885
885
|
18,
|
|
886
886
|
"0x205812CdBed920aFf76C6580abD681a46D11efc7",
|
|
887
887
|
18,
|
|
888
888
|
10,
|
|
889
889
|
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
890
890
|
),
|
|
891
|
-
|
|
891
|
+
U(
|
|
892
892
|
56,
|
|
893
893
|
"0x79eda94d6c0f850d03ee0bcbd97a55d4f8bbdbe901d42db6484453ea71373bbe",
|
|
894
894
|
"0x02Fca66C1D1aFB4E2A7884261eB00F63598a7436",
|
|
@@ -898,7 +898,7 @@ const ic = [
|
|
|
898
898
|
50,
|
|
899
899
|
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
900
900
|
),
|
|
901
|
-
|
|
901
|
+
U(
|
|
902
902
|
130,
|
|
903
903
|
"0x9073b65a558bdf9d0d7d0c82b468128acb847de72f5ad776bd8a4aab98781584",
|
|
904
904
|
"0x078D782b760474a361DdA0AF3839290b0EF57AD6",
|
|
@@ -908,17 +908,17 @@ const ic = [
|
|
|
908
908
|
10,
|
|
909
909
|
"0xA0B0D2D00Fd544D8E0887F1A3cEDD6e24BAF10cC"
|
|
910
910
|
),
|
|
911
|
-
|
|
911
|
+
U(
|
|
912
912
|
130,
|
|
913
913
|
"0x93a9759d15116697734921cf31000f5f6a8bb4cf163ab837071d94c8a48efd36",
|
|
914
|
-
|
|
914
|
+
ce,
|
|
915
915
|
18,
|
|
916
916
|
"0xAaAa68F5D1F7855954ECb361d4b9ff3127Cfefa7",
|
|
917
917
|
18,
|
|
918
918
|
60,
|
|
919
919
|
"0x88C9ff9fc0B22cCA42265d3F1D1c2c39E41cDaCc"
|
|
920
920
|
),
|
|
921
|
-
|
|
921
|
+
U(
|
|
922
922
|
130,
|
|
923
923
|
"0xa35fd8c7554f6ee88af3809067f90d383b1d45ab29b5927294859bfb49e9196d",
|
|
924
924
|
"0x078D782b760474a361DdA0AF3839290b0EF57AD6",
|
|
@@ -928,7 +928,7 @@ const ic = [
|
|
|
928
928
|
10,
|
|
929
929
|
"0xA0B0D2D00Fd544D8E0887F1A3cEDD6e24BAF10cC"
|
|
930
930
|
),
|
|
931
|
-
|
|
931
|
+
U(
|
|
932
932
|
130,
|
|
933
933
|
"0x04a7a357a66b983d6770c1423e12ae16cb4935eac013106d0e309864b269d48e",
|
|
934
934
|
"0x078D782b760474a361DdA0AF3839290b0EF57AD6",
|
|
@@ -938,7 +938,7 @@ const ic = [
|
|
|
938
938
|
60,
|
|
939
939
|
"0x88C9ff9fc0B22cCA42265d3F1D1c2c39E41cDaCc"
|
|
940
940
|
),
|
|
941
|
-
|
|
941
|
+
U(
|
|
942
942
|
130,
|
|
943
943
|
"0xe56f1855a315fe2984a401b8939e7c1c314070ea637e642acdc7ffed0d36387c",
|
|
944
944
|
"0x078D782b760474a361DdA0AF3839290b0EF57AD6",
|
|
@@ -948,17 +948,17 @@ const ic = [
|
|
|
948
948
|
10,
|
|
949
949
|
"0xA0B0D2D00Fd544D8E0887F1A3cEDD6e24BAF10cC"
|
|
950
950
|
),
|
|
951
|
-
|
|
951
|
+
U(
|
|
952
952
|
130,
|
|
953
953
|
"0x410723c1949069324d0f6013dba28829c4a0562f7c81d0f7cb79ded668691e1f",
|
|
954
|
-
|
|
954
|
+
ce,
|
|
955
955
|
18,
|
|
956
956
|
"0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
|
|
957
957
|
8,
|
|
958
958
|
60,
|
|
959
959
|
"0xA0B0D2D00Fd544D8E0887F1A3cEDD6e24BAF10cC"
|
|
960
960
|
),
|
|
961
|
-
|
|
961
|
+
U(
|
|
962
962
|
130,
|
|
963
963
|
"0x332924e23d3ea11964e538131c49c1fa8315fe163218fae8aeaf694ab7164913",
|
|
964
964
|
"0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
|
|
@@ -968,7 +968,7 @@ const ic = [
|
|
|
968
968
|
60,
|
|
969
969
|
"0x3476b53425a786e57aA246839c1837A62fc21AcC"
|
|
970
970
|
),
|
|
971
|
-
|
|
971
|
+
U(
|
|
972
972
|
130,
|
|
973
973
|
"0x055ac9b9a4ed104d328a9e391b5f78f4c6dbddf8e834dd71e1b0b62c2dee2dc0",
|
|
974
974
|
"0x0555E30da8f98308EdB960aa94C0Db47230d2B9c",
|
|
@@ -978,7 +978,7 @@ const ic = [
|
|
|
978
978
|
60,
|
|
979
979
|
"0x88C9ff9fc0B22cCA42265d3F1D1c2c39E41cDaCc"
|
|
980
980
|
),
|
|
981
|
-
|
|
981
|
+
U(
|
|
982
982
|
130,
|
|
983
983
|
"0xe468249c67297374eb4fee862be1143c8d5189e685469e40db9df0fc61b46e2a",
|
|
984
984
|
"0x078D782b760474a361DdA0AF3839290b0EF57AD6",
|
|
@@ -988,7 +988,7 @@ const ic = [
|
|
|
988
988
|
10,
|
|
989
989
|
"0xA0B0D2D00Fd544D8E0887F1A3cEDD6e24BAF10cC"
|
|
990
990
|
),
|
|
991
|
-
|
|
991
|
+
U(
|
|
992
992
|
8453,
|
|
993
993
|
"0xbb8afa02662e873abf49e9b6404f79d0fce76dabe9dd67ac491d8b9985fd4cb3",
|
|
994
994
|
"0x0b3e328455c4059EEb9e3f84b5543F74E24e7E1b",
|
|
@@ -1000,7 +1000,8 @@ const ic = [
|
|
|
1000
1000
|
),
|
|
1001
1001
|
// Ink pools verified on-chain 2026-10-12: pool ids hash from these keys and
|
|
1002
1002
|
// are initialized in the Ink PoolManager. USD₮0-USDG had zero liquidity then.
|
|
1003
|
-
|
|
1003
|
+
// USD₮0-USDC
|
|
1004
|
+
U(
|
|
1004
1005
|
57073,
|
|
1005
1006
|
"0xfff506f639ae6cbe6c4743ddfbac69169bca6f1a38ff6997c6f35ff2f8bd1805",
|
|
1006
1007
|
"0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
@@ -1010,7 +1011,8 @@ const ic = [
|
|
|
1010
1011
|
1,
|
|
1011
1012
|
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1012
1013
|
),
|
|
1013
|
-
|
|
1014
|
+
// USD₮0-USDG
|
|
1015
|
+
U(
|
|
1014
1016
|
57073,
|
|
1015
1017
|
"0xb793047b01dda2187e827c8191f2c7cb40836c00527c9ef4f17fde9b8c63918a",
|
|
1016
1018
|
"0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
@@ -1019,12 +1021,147 @@ const ic = [
|
|
|
1019
1021
|
6,
|
|
1020
1022
|
1,
|
|
1021
1023
|
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1024
|
+
),
|
|
1025
|
+
// Ink pools verified at block 58662145 (2026-10-16): pool ids hash from these
|
|
1026
|
+
// keys, token decimals and router/Permit2/quoter match, and exact-in and
|
|
1027
|
+
// exact-out quotes succeed in both directions.
|
|
1028
|
+
// ETH-wSPYx
|
|
1029
|
+
U(
|
|
1030
|
+
57073,
|
|
1031
|
+
"0xbd0e2c0114cf00cf8601a29add86dd8cc84c2a0cf4354bcc5532b5fb1322ab6e",
|
|
1032
|
+
ce,
|
|
1033
|
+
18,
|
|
1034
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1035
|
+
18,
|
|
1036
|
+
60,
|
|
1037
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1038
|
+
),
|
|
1039
|
+
// wSPCXx-wSPYx
|
|
1040
|
+
U(
|
|
1041
|
+
57073,
|
|
1042
|
+
"0x65e3c7aa84a1b860501abd77cd8bc66386c31c400c2e79600f512e0124802cd3",
|
|
1043
|
+
"0x8e2eeD8b8B5E13Ea7BF38e50d7821d2C57309072",
|
|
1044
|
+
18,
|
|
1045
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1046
|
+
18,
|
|
1047
|
+
1,
|
|
1048
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1049
|
+
),
|
|
1050
|
+
// wNVDAx-wSPYx
|
|
1051
|
+
U(
|
|
1052
|
+
57073,
|
|
1053
|
+
"0xab844d6a3bb696e76797f17873719421c9fd9be4cd9535aa16900d671fd96834",
|
|
1054
|
+
"0xa8ddb5Cd96b5222AFe198316E9A57CAA642850D5",
|
|
1055
|
+
18,
|
|
1056
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1057
|
+
18,
|
|
1058
|
+
1,
|
|
1059
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1060
|
+
),
|
|
1061
|
+
// USDC-kBTC
|
|
1062
|
+
U(
|
|
1063
|
+
57073,
|
|
1064
|
+
"0x92775802e55807c33896544db8e5d71ef062fd73528764883dbc66b4274676c1",
|
|
1065
|
+
"0x2D270e6886d130D724215A266106e6832161EAEd",
|
|
1066
|
+
6,
|
|
1067
|
+
"0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98",
|
|
1068
|
+
8,
|
|
1069
|
+
1,
|
|
1070
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1071
|
+
),
|
|
1072
|
+
// USDC-USDG
|
|
1073
|
+
U(
|
|
1074
|
+
57073,
|
|
1075
|
+
"0xf58608d5185583091b9724b7fd77a5b64b64ff84d9b69367b7edebf3bf07eb06",
|
|
1076
|
+
"0x2D270e6886d130D724215A266106e6832161EAEd",
|
|
1077
|
+
6,
|
|
1078
|
+
"0xe343167631d89B6Ffc58B88d6b7fB0228795491D",
|
|
1079
|
+
6,
|
|
1080
|
+
1,
|
|
1081
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1082
|
+
),
|
|
1083
|
+
// wPLTRx-wSPYx
|
|
1084
|
+
U(
|
|
1085
|
+
57073,
|
|
1086
|
+
"0x0ed5e5b3e484a9db662b76ee1bdc65ba39cc8b7730d589c5aa42f92441e628ba",
|
|
1087
|
+
"0x4A2df09536F62341C9f946427D16414C04e21342",
|
|
1088
|
+
18,
|
|
1089
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1090
|
+
18,
|
|
1091
|
+
1,
|
|
1092
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1093
|
+
),
|
|
1094
|
+
// WETH-kBTC
|
|
1095
|
+
U(
|
|
1096
|
+
57073,
|
|
1097
|
+
"0x5697efeb250053d9ed30169545c9ac3807c4641cfcce25112709a552351b5ed3",
|
|
1098
|
+
"0x4200000000000000000000000000000000000006",
|
|
1099
|
+
18,
|
|
1100
|
+
"0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98",
|
|
1101
|
+
8,
|
|
1102
|
+
1,
|
|
1103
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1104
|
+
),
|
|
1105
|
+
// USD₮0-WETH
|
|
1106
|
+
U(
|
|
1107
|
+
57073,
|
|
1108
|
+
"0xbeb76cc0b8368dc0e4968de92ee0386f2135463f4ab0737edd7c88b9c58430c6",
|
|
1109
|
+
"0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
1110
|
+
6,
|
|
1111
|
+
"0x4200000000000000000000000000000000000006",
|
|
1112
|
+
18,
|
|
1113
|
+
1,
|
|
1114
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1115
|
+
),
|
|
1116
|
+
// wTSLAx-wSPYx
|
|
1117
|
+
U(
|
|
1118
|
+
57073,
|
|
1119
|
+
"0xfc349fd867e86ce6ca534802d48f70ba0c8b35cbf82e0c02f42b4a47df51636e",
|
|
1120
|
+
"0xc3FdBe3A68EE5dE461D30415a8165cf9Aefe1171",
|
|
1121
|
+
18,
|
|
1122
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1123
|
+
18,
|
|
1124
|
+
1,
|
|
1125
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1126
|
+
),
|
|
1127
|
+
// wMSTRx-wSPYx
|
|
1128
|
+
U(
|
|
1129
|
+
57073,
|
|
1130
|
+
"0x0754e0cad325b69c0595c02e02da8b3b9384b27c637b48940589cf8b3a1519dc",
|
|
1131
|
+
"0x30987adF0B11dc698438a99BA04ec3a1AB2c7EaB",
|
|
1132
|
+
18,
|
|
1133
|
+
"0xE7E553Cd128F0011777323A0b44a7b96EA1CB540",
|
|
1134
|
+
18,
|
|
1135
|
+
1,
|
|
1136
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1137
|
+
),
|
|
1138
|
+
// USDC-WETH
|
|
1139
|
+
U(
|
|
1140
|
+
57073,
|
|
1141
|
+
"0xa440c7fd3cf42fdb083109ee84da8ac6bf05aa3e736a587a6d1c0855a2f8350a",
|
|
1142
|
+
"0x2D270e6886d130D724215A266106e6832161EAEd",
|
|
1143
|
+
6,
|
|
1144
|
+
"0x4200000000000000000000000000000000000006",
|
|
1145
|
+
18,
|
|
1146
|
+
1,
|
|
1147
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1148
|
+
),
|
|
1149
|
+
// USD₮0-kBTC
|
|
1150
|
+
U(
|
|
1151
|
+
57073,
|
|
1152
|
+
"0x2c73736abad6d184c68b66646ed1184f70e811acf0abc65f988af6163307957f",
|
|
1153
|
+
"0x0200C29006150606B650577BBE7B6248F58470c1",
|
|
1154
|
+
6,
|
|
1155
|
+
"0x73E0C0d45E048D25Fc26Fa3159b0aA04BfA4Db98",
|
|
1156
|
+
8,
|
|
1157
|
+
1,
|
|
1158
|
+
"0xe449E013004DB4a5681E9622ca10c5Ba0eA610cc"
|
|
1022
1159
|
)
|
|
1023
|
-
],
|
|
1160
|
+
], wr = /* @__PURE__ */ new WeakSet();
|
|
1024
1161
|
class yo extends _ {
|
|
1025
1162
|
constructor(n = "This is not a trusted direct-swap market in the trusted execution catalogue.") {
|
|
1026
1163
|
super(`${na}: ${n}`);
|
|
1027
|
-
|
|
1164
|
+
j(this, "ruleId", na);
|
|
1028
1165
|
this.name = "DirectSwapMarketTrustError";
|
|
1029
1166
|
}
|
|
1030
1167
|
}
|
|
@@ -1052,7 +1189,7 @@ function sc(e, t) {
|
|
|
1052
1189
|
);
|
|
1053
1190
|
}
|
|
1054
1191
|
function Er(e) {
|
|
1055
|
-
return vr(e) ?
|
|
1192
|
+
return vr(e) ? wr.has(e) ? !0 : ic.some((t) => sc(e, t)) : !1;
|
|
1056
1193
|
}
|
|
1057
1194
|
function cn(e) {
|
|
1058
1195
|
if (!Er(e)) throw new yo();
|
|
@@ -1064,7 +1201,7 @@ function cc(e, t) {
|
|
|
1064
1201
|
function Xp(e) {
|
|
1065
1202
|
if (!vr(e))
|
|
1066
1203
|
throw new yo("The host-authorized pool is internally inconsistent.");
|
|
1067
|
-
return
|
|
1204
|
+
return wr.add(e), e;
|
|
1068
1205
|
}
|
|
1069
1206
|
function yr(e) {
|
|
1070
1207
|
if (!Number.isFinite(e) || e < 0 || e > 2e3)
|
|
@@ -1106,7 +1243,7 @@ function hc(e, t, n) {
|
|
|
1106
1243
|
if (!a || !r || k(t.address, n.address))
|
|
1107
1244
|
throw new Error("Selected tokens do not match this direct pool.");
|
|
1108
1245
|
}
|
|
1109
|
-
function
|
|
1246
|
+
function bc(e, t) {
|
|
1110
1247
|
if (Array.isArray(e)) {
|
|
1111
1248
|
const a = e[0], r = e[1];
|
|
1112
1249
|
if (typeof a == "bigint" && typeof r == "bigint")
|
|
@@ -1118,7 +1255,7 @@ function wc(e, t) {
|
|
|
1118
1255
|
return { amount: o, gasEstimate: n.gasEstimate };
|
|
1119
1256
|
throw new Error("Unexpected V4 Quoter response.");
|
|
1120
1257
|
}
|
|
1121
|
-
async function
|
|
1258
|
+
async function wc(e) {
|
|
1122
1259
|
var m, u, h, f;
|
|
1123
1260
|
if ((m = e.signal) != null && m.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
1124
1261
|
if (e.amount <= 0n) throw new Error("Enter an amount to swap.");
|
|
@@ -1140,7 +1277,7 @@ async function bc(e) {
|
|
|
1140
1277
|
account: e.account
|
|
1141
1278
|
});
|
|
1142
1279
|
if ((h = e.signal) != null && h.aborted) throw new DOMException("Quote request aborted", "AbortError");
|
|
1143
|
-
const i =
|
|
1280
|
+
const i = bc(
|
|
1144
1281
|
r.result,
|
|
1145
1282
|
e.mode === "exactOut" ? "amountIn" : "amountOut"
|
|
1146
1283
|
), s = e.mode === "exactOut" ? i.amount : e.amount, l = e.mode === "exactOut" ? a : i.amount, c = e.mode === "exactOut" ? l - e.amount : uc(l, o), p = l - c, d = e.mode === "exactOut" ? p : lc(p, e.slippageBps);
|
|
@@ -1161,7 +1298,7 @@ async function bc(e) {
|
|
|
1161
1298
|
};
|
|
1162
1299
|
}
|
|
1163
1300
|
function Ir(e, t) {
|
|
1164
|
-
return e.mode === t.mode && e.zeroForOne === t.zeroForOne && k(e.poolKey.currency0, t.poolKey.currency0) && k(e.poolKey.currency1, t.poolKey.currency1) && e.poolKey.fee === t.poolKey.fee && e.poolKey.tickSpacing === t.poolKey.tickSpacing && k(e.poolKey.hooks, t.poolKey.hooks) && e.feeBps === t.feeBps &&
|
|
1301
|
+
return e.mode === t.mode && e.zeroForOne === t.zeroForOne && k(e.poolKey.currency0, t.poolKey.currency0) && k(e.poolKey.currency1, t.poolKey.currency1) && e.poolKey.fee === t.poolKey.fee && e.poolKey.tickSpacing === t.poolKey.tickSpacing && k(e.poolKey.hooks, t.poolKey.hooks) && e.feeBps === t.feeBps && bs(e.feeRecipient, t.feeRecipient);
|
|
1165
1302
|
}
|
|
1166
1303
|
function Yp(e, t) {
|
|
1167
1304
|
return Ir(e, t) && e.amountIn === t.amountIn && e.amountOut === t.amountOut && e.grossAmountOut === t.grossAmountOut && e.amountOutMinimum === t.amountOutMinimum && e.amountInMaximum === t.amountInMaximum && e.userAmountOutMinimum === t.userAmountOutMinimum && e.feeAmount === t.feeAmount;
|
|
@@ -1197,10 +1334,10 @@ class Ar extends Error {
|
|
|
1197
1334
|
body: i
|
|
1198
1335
|
}) {
|
|
1199
1336
|
super(r);
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1337
|
+
j(this, "status");
|
|
1338
|
+
j(this, "statusText");
|
|
1339
|
+
j(this, "code");
|
|
1340
|
+
j(this, "body");
|
|
1204
1341
|
this.name = "KyberSwapApiError", this.status = n, this.statusText = o, this.code = a, this.body = i;
|
|
1205
1342
|
}
|
|
1206
1343
|
}
|
|
@@ -1208,8 +1345,8 @@ class Io extends Error {
|
|
|
1208
1345
|
constructor({ endpoint: n, issues: o }) {
|
|
1209
1346
|
const a = o[0], r = a ? `: ${a.path.length > 0 ? a.path.join(".") : "(root)"} ${a.message}` : "";
|
|
1210
1347
|
super(`KyberSwap response violated the expected contract at ${n}${r}`);
|
|
1211
|
-
|
|
1212
|
-
|
|
1348
|
+
j(this, "endpoint");
|
|
1349
|
+
j(this, "issues");
|
|
1213
1350
|
this.name = "KyberSwapContractError", this.endpoint = n, this.issues = o;
|
|
1214
1351
|
}
|
|
1215
1352
|
}
|
|
@@ -1223,10 +1360,10 @@ class ve extends Error {
|
|
|
1223
1360
|
super(
|
|
1224
1361
|
`REMOTE-LIMIT-001: KyberSwap ${n} ${r} exceeds the ${o} limit` + (a === void 0 ? "." : ` (received ${a}).`)
|
|
1225
1362
|
);
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1363
|
+
j(this, "ruleId", "REMOTE-LIMIT-001");
|
|
1364
|
+
j(this, "endpoint");
|
|
1365
|
+
j(this, "limit");
|
|
1366
|
+
j(this, "actual");
|
|
1230
1367
|
this.name = "KyberSwapResourceLimitError", this.endpoint = n, this.limit = o, this.actual = a;
|
|
1231
1368
|
}
|
|
1232
1369
|
}
|
|
@@ -1394,20 +1531,20 @@ async function Tr(e) {
|
|
|
1394
1531
|
function Rr(e) {
|
|
1395
1532
|
return e instanceof Ar ? e.status === 429 || e.status >= 500 : e instanceof Io || e instanceof ve ? !1 : e instanceof TypeError ? !0 : e instanceof Error && e.name === "TimeoutError";
|
|
1396
1533
|
}
|
|
1397
|
-
const nt =
|
|
1534
|
+
const nt = de.refine(
|
|
1398
1535
|
(e) => e.length <= 78,
|
|
1399
1536
|
"uint256 decimal string must contain at most 78 digits"
|
|
1400
1537
|
), Je = S().max(256), Sc = Dt({
|
|
1401
1538
|
pool: S().max(256).optional(),
|
|
1402
|
-
tokenIn:
|
|
1403
|
-
tokenOut:
|
|
1539
|
+
tokenIn: K.optional(),
|
|
1540
|
+
tokenOut: K.optional(),
|
|
1404
1541
|
swapAmount: nt.optional(),
|
|
1405
1542
|
amountOut: nt.optional(),
|
|
1406
1543
|
exchange: S().max(128).optional(),
|
|
1407
1544
|
poolType: S().max(128).optional()
|
|
1408
1545
|
}), Cc = Dt({
|
|
1409
|
-
tokenIn:
|
|
1410
|
-
tokenOut:
|
|
1546
|
+
tokenIn: K,
|
|
1547
|
+
tokenOut: K,
|
|
1411
1548
|
amountIn: nt,
|
|
1412
1549
|
amountOut: nt,
|
|
1413
1550
|
gas: Je.optional(),
|
|
@@ -1415,15 +1552,15 @@ const nt = le.refine(
|
|
|
1415
1552
|
gasUsd: Je.optional(),
|
|
1416
1553
|
amountInUsd: Je.optional(),
|
|
1417
1554
|
amountOutUsd: Je.optional(),
|
|
1418
|
-
priceImpact:
|
|
1419
|
-
route:
|
|
1420
|
-
routeComposition:
|
|
1555
|
+
priceImpact: b().optional(),
|
|
1556
|
+
route: F(F(Sc).max(64)).max(64).optional(),
|
|
1557
|
+
routeComposition: F(Dt({
|
|
1421
1558
|
name: S().max(128),
|
|
1422
|
-
part:
|
|
1559
|
+
part: b()
|
|
1423
1560
|
})).max(128).optional()
|
|
1424
1561
|
}), xc = Dt({
|
|
1425
1562
|
routeSummary: Cc,
|
|
1426
|
-
routerAddress:
|
|
1563
|
+
routerAddress: K,
|
|
1427
1564
|
requestId: S().max(256).optional()
|
|
1428
1565
|
}), Tc = Dt({
|
|
1429
1566
|
amountIn: nt,
|
|
@@ -1434,7 +1571,7 @@ const nt = le.refine(
|
|
|
1434
1571
|
(e) => e.length <= Wn,
|
|
1435
1572
|
`calldata must contain at most ${Wn} characters`
|
|
1436
1573
|
),
|
|
1437
|
-
routerAddress:
|
|
1574
|
+
routerAddress: K,
|
|
1438
1575
|
transactionValue: nt.optional(),
|
|
1439
1576
|
requestId: S().max(256).optional()
|
|
1440
1577
|
});
|
|
@@ -1601,77 +1738,77 @@ const Pr = [
|
|
|
1601
1738
|
]
|
|
1602
1739
|
}
|
|
1603
1740
|
], _c = 0x40n, Nc = 0x80n, gn = _c | Nc;
|
|
1604
|
-
class
|
|
1741
|
+
class pe extends _ {
|
|
1605
1742
|
constructor(n) {
|
|
1606
1743
|
super("Swap transaction data failed verification. Refresh the quote and try again.");
|
|
1607
|
-
|
|
1744
|
+
j(this, "reason");
|
|
1608
1745
|
this.name = "AggregatedSwapCalldataError", this.reason = n;
|
|
1609
1746
|
}
|
|
1610
1747
|
}
|
|
1611
|
-
function
|
|
1748
|
+
function Fc(e, t) {
|
|
1612
1749
|
if (!t) {
|
|
1613
1750
|
if (e.feeReceivers.length !== 0 || e.feeAmounts.length !== 0 || (e.flags & gn) !== 0n)
|
|
1614
|
-
throw new
|
|
1751
|
+
throw new pe(
|
|
1615
1752
|
"calldata contains fee receivers, amounts, or fee-mode flags for a fee-free quote"
|
|
1616
1753
|
);
|
|
1617
1754
|
return;
|
|
1618
1755
|
}
|
|
1619
1756
|
if (!Number.isInteger(t.feeBps) || t.feeBps <= 0 || t.feeBps > 1e4)
|
|
1620
|
-
throw new
|
|
1757
|
+
throw new pe(`invalid expected fee policy ${t.feeBps} bps`);
|
|
1621
1758
|
if (e.feeReceivers.length !== 1 || e.feeAmounts.length !== 1)
|
|
1622
|
-
throw new
|
|
1759
|
+
throw new pe(
|
|
1623
1760
|
`calldata fee arrays must contain exactly one receiver and one amount; received ${e.feeReceivers.length} and ${e.feeAmounts.length}`
|
|
1624
1761
|
);
|
|
1625
1762
|
if (!k(e.feeReceivers[0], t.receiver))
|
|
1626
|
-
throw new
|
|
1763
|
+
throw new pe(
|
|
1627
1764
|
`calldata routes fees to ${e.feeReceivers[0]}, expected ${t.receiver}`
|
|
1628
1765
|
);
|
|
1629
1766
|
if (e.feeAmounts[0] !== BigInt(t.feeBps))
|
|
1630
|
-
throw new
|
|
1767
|
+
throw new pe(
|
|
1631
1768
|
`calldata fee ${e.feeAmounts[0]} bps does not match the reviewed ${t.feeBps} bps policy`
|
|
1632
1769
|
);
|
|
1633
1770
|
if ((e.flags & gn) !== gn)
|
|
1634
|
-
throw new
|
|
1771
|
+
throw new pe(
|
|
1635
1772
|
`calldata fee flags ${e.flags} do not encode an output-denominated bps fee`
|
|
1636
1773
|
);
|
|
1637
1774
|
}
|
|
1638
|
-
function
|
|
1775
|
+
function qc(e) {
|
|
1639
1776
|
let t;
|
|
1640
1777
|
try {
|
|
1641
1778
|
t = as({ abi: Dc, data: e });
|
|
1642
1779
|
} catch {
|
|
1643
|
-
throw new
|
|
1780
|
+
throw new pe(
|
|
1644
1781
|
"calldata does not decode as a known MetaAggregationRouterV2 entrypoint"
|
|
1645
1782
|
);
|
|
1646
1783
|
}
|
|
1647
1784
|
return t.functionName === "swapSimpleMode" ? t.args[1] : t.args[0].desc;
|
|
1648
1785
|
}
|
|
1649
|
-
function
|
|
1650
|
-
const t =
|
|
1786
|
+
function Oc(e) {
|
|
1787
|
+
const t = qc(e.data);
|
|
1651
1788
|
if (!k(t.srcToken, e.inputToken))
|
|
1652
|
-
throw new
|
|
1789
|
+
throw new pe(
|
|
1653
1790
|
`calldata swaps ${t.srcToken}, quote reviewed ${e.inputToken}`
|
|
1654
1791
|
);
|
|
1655
1792
|
if (!k(t.dstToken, e.outputToken))
|
|
1656
|
-
throw new
|
|
1793
|
+
throw new pe(
|
|
1657
1794
|
`calldata pays out ${t.dstToken}, quote reviewed ${e.outputToken}`
|
|
1658
1795
|
);
|
|
1659
1796
|
if (t.amount !== e.amount)
|
|
1660
|
-
throw new
|
|
1797
|
+
throw new pe(
|
|
1661
1798
|
`calldata pulls ${t.amount}, quote reviewed ${e.amount}`
|
|
1662
1799
|
);
|
|
1663
1800
|
if (!k(t.dstReceiver, e.recipient))
|
|
1664
|
-
throw new
|
|
1801
|
+
throw new pe(
|
|
1665
1802
|
`calldata pays ${t.dstReceiver}, expected the connected account`
|
|
1666
1803
|
);
|
|
1667
1804
|
if (t.minReturnAmount < e.minReturnFloor)
|
|
1668
|
-
throw new
|
|
1805
|
+
throw new pe(
|
|
1669
1806
|
`calldata slippage floor ${t.minReturnAmount} is below the reviewed minimum ${e.minReturnFloor}`
|
|
1670
1807
|
);
|
|
1671
|
-
|
|
1808
|
+
Fc(t, e.feePolicy);
|
|
1672
1809
|
const n = t.srcAmounts.reduce((o, a) => o + a, 0n);
|
|
1673
1810
|
if (n > t.amount)
|
|
1674
|
-
throw new
|
|
1811
|
+
throw new pe(
|
|
1675
1812
|
`calldata source transfers ${n} exceed the swap amount ${t.amount}`
|
|
1676
1813
|
);
|
|
1677
1814
|
}
|
|
@@ -1679,7 +1816,7 @@ const Lc = 2, Uc = "Route temporarily unavailable. Refresh the quote and try aga
|
|
|
1679
1816
|
[X]: Rs
|
|
1680
1817
|
};
|
|
1681
1818
|
function Jp(e, t) {
|
|
1682
|
-
return Rr(e) ? Uc :
|
|
1819
|
+
return Rr(e) ? Uc : ws(e, t);
|
|
1683
1820
|
}
|
|
1684
1821
|
class da extends _ {
|
|
1685
1822
|
constructor({
|
|
@@ -1688,9 +1825,9 @@ class da extends _ {
|
|
|
1688
1825
|
actual: a
|
|
1689
1826
|
}) {
|
|
1690
1827
|
super("Swap route changed unexpectedly. Refresh the quote and try again.");
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1828
|
+
j(this, "field");
|
|
1829
|
+
j(this, "expected");
|
|
1830
|
+
j(this, "actual");
|
|
1694
1831
|
this.name = "AggregatedSwapBuildMismatchError", this.field = n, this.expected = o, this.actual = a;
|
|
1695
1832
|
}
|
|
1696
1833
|
}
|
|
@@ -1833,7 +1970,7 @@ async function ma(e, t, n, o, a = "exactIn", r, i, s, l) {
|
|
|
1833
1970
|
signal: i
|
|
1834
1971
|
});
|
|
1835
1972
|
Kn(u.routerAddress, e.chainId), Qc(u, e, t, n);
|
|
1836
|
-
const h = BigInt(u.routeSummary.amountOut), f = c ? Un : 0,
|
|
1973
|
+
const h = BigInt(u.routeSummary.amountOut), f = c ? Un : 0, w = Kc(h, f), y = $c(h, o), E = l == null ? void 0 : l.reviewedAmountOutMinimum, C = E !== void 0 && h < E, x = E === void 0 ? y : Hc(y, E);
|
|
1837
1974
|
let A = null;
|
|
1838
1975
|
try {
|
|
1839
1976
|
A = r && !C ? await Mc({
|
|
@@ -1856,7 +1993,7 @@ async function ma(e, t, n, o, a = "exactIn", r, i, s, l) {
|
|
|
1856
1993
|
if (A && r) {
|
|
1857
1994
|
if (Kn(A.routerAddress, e.chainId), !k(A.routerAddress, u.routerAddress))
|
|
1858
1995
|
throw new _("Swap route changed unexpectedly. Refresh the quote and try again.");
|
|
1859
|
-
Jc(A, n, x),
|
|
1996
|
+
Jc(A, n, x), Oc({
|
|
1860
1997
|
data: A.data,
|
|
1861
1998
|
inputToken: e.address,
|
|
1862
1999
|
outputToken: t.address,
|
|
@@ -1888,7 +2025,7 @@ async function ma(e, t, n, o, a = "exactIn", r, i, s, l) {
|
|
|
1888
2025
|
expiresAt: A != null && A.deadline ? new Date(A.deadline * 1e3).toISOString() : void 0,
|
|
1889
2026
|
transactionValue: P,
|
|
1890
2027
|
priceImpact: u.routeSummary.priceImpact ?? 0,
|
|
1891
|
-
feeAmount:
|
|
2028
|
+
feeAmount: w,
|
|
1892
2029
|
feeBps: f,
|
|
1893
2030
|
feeRecipient: c ? Vn : null,
|
|
1894
2031
|
// A route below the immutable floor is returned only for renewed review;
|
|
@@ -1905,7 +2042,7 @@ async function ma(e, t, n, o, a = "exactIn", r, i, s, l) {
|
|
|
1905
2042
|
class _e extends Error {
|
|
1906
2043
|
constructor(n, o) {
|
|
1907
2044
|
super(o);
|
|
1908
|
-
|
|
2045
|
+
j(this, "code");
|
|
1909
2046
|
this.name = "AegisContractGuardError", this.code = n;
|
|
1910
2047
|
}
|
|
1911
2048
|
}
|
|
@@ -2034,12 +2171,12 @@ function vt(e) {
|
|
|
2034
2171
|
var t;
|
|
2035
2172
|
return ((t = Dr.get(e)) == null ? void 0 : t.version) ?? null;
|
|
2036
2173
|
}
|
|
2037
|
-
function
|
|
2174
|
+
function ue(e) {
|
|
2038
2175
|
var t;
|
|
2039
2176
|
return ((t = Dr.get(e)) == null ? void 0 : t.addresses) ?? null;
|
|
2040
2177
|
}
|
|
2041
|
-
function
|
|
2042
|
-
const t =
|
|
2178
|
+
function e0(e) {
|
|
2179
|
+
const t = ue(e);
|
|
2043
2180
|
if (!t) throw new Error(`No trusted Aegis Engine registry for chain ${e}.`);
|
|
2044
2181
|
return t.aegisRouterV1;
|
|
2045
2182
|
}
|
|
@@ -2066,11 +2203,11 @@ function hl(e) {
|
|
|
2066
2203
|
account: dn(e.account)
|
|
2067
2204
|
};
|
|
2068
2205
|
}
|
|
2069
|
-
async function
|
|
2206
|
+
async function bl(e) {
|
|
2070
2207
|
const t = await e.request({ method: "eth_accounts" });
|
|
2071
2208
|
return dn(t == null ? void 0 : t[0]);
|
|
2072
2209
|
}
|
|
2073
|
-
async function
|
|
2210
|
+
async function wl(e) {
|
|
2074
2211
|
const t = await e.request({ method: "eth_requestAccounts" });
|
|
2075
2212
|
return dn(t == null ? void 0 : t[0]);
|
|
2076
2213
|
}
|
|
@@ -2137,7 +2274,7 @@ async function Al(e, t) {
|
|
|
2137
2274
|
params: [{ chainId: o }]
|
|
2138
2275
|
});
|
|
2139
2276
|
}
|
|
2140
|
-
function
|
|
2277
|
+
function t0(e, t, n) {
|
|
2141
2278
|
var s, l;
|
|
2142
2279
|
const o = t.length > 1, a = t.map(
|
|
2143
2280
|
(c) => rs(c, {
|
|
@@ -2149,7 +2286,7 @@ function tf(e, t, n) {
|
|
|
2149
2286
|
timeout: o ? 5e3 : 1e4
|
|
2150
2287
|
})
|
|
2151
2288
|
), r = !!((s = e.contracts) != null && s.multicall3);
|
|
2152
|
-
return ((((l = cr[e.id]) == null ? void 0 : l.length) ?? 0) > 0 ||
|
|
2289
|
+
return ((((l = cr[e.id]) == null ? void 0 : l.length) ?? 0) > 0 || ue(e.id) !== null) && !r && console.warn(
|
|
2153
2290
|
`[AegisCore][${ml}] Trusted chain ${e.id} (${e.name}) is missing chain.contracts.multicall3 metadata; Multicall3 batching is disabled and reads will use individual eth_call requests.`
|
|
2154
2291
|
), is({
|
|
2155
2292
|
chain: e,
|
|
@@ -2158,10 +2295,10 @@ function tf(e, t, n) {
|
|
|
2158
2295
|
// public RPCs meter per call. Only when the chain declares a multicall3
|
|
2159
2296
|
// deployment; custom host chains without one keep plain eth_calls.
|
|
2160
2297
|
...!n && r ? { batch: { multicall: { wait: 16 } } } : {},
|
|
2161
|
-
transport: n ?
|
|
2298
|
+
transport: n ? wt(n, { retryCount: 0 }) : a.length === 1 ? a[0] : ss(a, { retryCount: 1, retryDelay: 150 })
|
|
2162
2299
|
});
|
|
2163
2300
|
}
|
|
2164
|
-
function
|
|
2301
|
+
function n0(e, t) {
|
|
2165
2302
|
const n = e;
|
|
2166
2303
|
if (!n.on || !n.removeListener) return () => {
|
|
2167
2304
|
};
|
|
@@ -2251,7 +2388,7 @@ const xl = "0x1626ba7e", Tl = [
|
|
|
2251
2388
|
],
|
|
2252
2389
|
outputs: [{ name: "magicValue", type: "bytes4" }]
|
|
2253
2390
|
}
|
|
2254
|
-
], go = 600, Rl = 1800, So = 1800, Pl = go,
|
|
2391
|
+
], go = 600, Rl = 1800, So = 1800, Pl = go, Fr = 2 ** 48 - 1;
|
|
2255
2392
|
function Bl(e) {
|
|
2256
2393
|
try {
|
|
2257
2394
|
e == null || e();
|
|
@@ -2288,13 +2425,13 @@ const Ml = {
|
|
|
2288
2425
|
{ name: "nonce", type: "uint48" }
|
|
2289
2426
|
]
|
|
2290
2427
|
};
|
|
2291
|
-
async function
|
|
2428
|
+
async function qr(e) {
|
|
2292
2429
|
var a;
|
|
2293
2430
|
(a = e.signal) == null || a.throwIfAborted();
|
|
2294
2431
|
const t = e.amount ?? Ee, n = Lt({
|
|
2295
2432
|
account: e.account,
|
|
2296
2433
|
chain: e.chain,
|
|
2297
|
-
transport:
|
|
2434
|
+
transport: wt(ln(e.provider, e.signal))
|
|
2298
2435
|
}), { request: o } = await e.publicClient.simulateContract({
|
|
2299
2436
|
address: e.token,
|
|
2300
2437
|
abi: Nr,
|
|
@@ -2317,7 +2454,7 @@ async function Or(e) {
|
|
|
2317
2454
|
function Ht(e) {
|
|
2318
2455
|
return e.publicClient.readContract({
|
|
2319
2456
|
address: e.token,
|
|
2320
|
-
abi:
|
|
2457
|
+
abi: qn,
|
|
2321
2458
|
functionName: "allowance",
|
|
2322
2459
|
args: [e.owner, e.spender]
|
|
2323
2460
|
});
|
|
@@ -2328,7 +2465,7 @@ async function Dl(e) {
|
|
|
2328
2465
|
const t = e.amount ?? Ee, n = Lt({
|
|
2329
2466
|
account: e.account,
|
|
2330
2467
|
chain: e.chain,
|
|
2331
|
-
transport:
|
|
2468
|
+
transport: wt(e.provider)
|
|
2332
2469
|
}), { request: o } = await e.publicClient.simulateContract({
|
|
2333
2470
|
address: e.token,
|
|
2334
2471
|
abi: Nr,
|
|
@@ -2348,13 +2485,13 @@ async function Dl(e) {
|
|
|
2348
2485
|
onSubmitted: e.onSubmitted
|
|
2349
2486
|
});
|
|
2350
2487
|
}
|
|
2351
|
-
async function
|
|
2488
|
+
async function Or(e) {
|
|
2352
2489
|
var i;
|
|
2353
2490
|
(i = e.signal) == null || i.throwIfAborted();
|
|
2354
|
-
const t = e.amount ?? De, n = t > De ? De : t, o = e.expiration ??
|
|
2491
|
+
const t = e.amount ?? De, n = t > De ? De : t, o = e.expiration ?? Fr, a = Lt({
|
|
2355
2492
|
account: e.account,
|
|
2356
2493
|
chain: e.chain,
|
|
2357
|
-
transport:
|
|
2494
|
+
transport: wt(ln(e.provider, e.signal))
|
|
2358
2495
|
}), { request: r } = await e.publicClient.simulateContract({
|
|
2359
2496
|
address: e.permit2,
|
|
2360
2497
|
abi: mr,
|
|
@@ -2433,7 +2570,7 @@ async function Nl(e) {
|
|
|
2433
2570
|
mode: "eoa"
|
|
2434
2571
|
});
|
|
2435
2572
|
}
|
|
2436
|
-
async function
|
|
2573
|
+
async function Fl(e) {
|
|
2437
2574
|
var s, l, c, p, d;
|
|
2438
2575
|
(s = e.signal) == null || s.throwIfAborted();
|
|
2439
2576
|
const t = await (e.allowanceRead ?? ot(e));
|
|
@@ -2453,7 +2590,7 @@ async function ql(e) {
|
|
|
2453
2590
|
}, r = Lt({
|
|
2454
2591
|
account: e.account,
|
|
2455
2592
|
chain: e.chain,
|
|
2456
|
-
transport:
|
|
2593
|
+
transport: wt(e.provider)
|
|
2457
2594
|
});
|
|
2458
2595
|
(c = e.signal) == null || c.throwIfAborted(), Bl(e.onWalletRequest), (p = e.signal) == null || p.throwIfAborted();
|
|
2459
2596
|
const i = await r.signTypedData({
|
|
@@ -2466,18 +2603,18 @@ async function ql(e) {
|
|
|
2466
2603
|
signature: i
|
|
2467
2604
|
};
|
|
2468
2605
|
}
|
|
2469
|
-
const
|
|
2470
|
-
chainId:
|
|
2606
|
+
const ql = "https://ichi-images.s3.us-east-1.amazonaws.com/tokens", Ol = 15e3, Ll = T({
|
|
2607
|
+
chainId: b().nullable().catch(null),
|
|
2471
2608
|
address: S().nullable().catch(null),
|
|
2472
2609
|
symbol: S().nullable().catch(null),
|
|
2473
2610
|
displayName: S().nullable().catch(null),
|
|
2474
2611
|
fullName: S().nullable().catch(null),
|
|
2475
|
-
decimals:
|
|
2612
|
+
decimals: b().nullable().catch(null),
|
|
2476
2613
|
iconURL: S().nullable().catch(null),
|
|
2477
|
-
price:
|
|
2614
|
+
price: b().nullable().catch(null)
|
|
2478
2615
|
}), Ul = T({
|
|
2479
2616
|
data: Es(S(), Ll.nullable().catch(null)).optional(),
|
|
2480
|
-
errors:
|
|
2617
|
+
errors: F(T({ message: S().optional() })).optional()
|
|
2481
2618
|
}), Vl = 512, Ze = /* @__PURE__ */ new Map();
|
|
2482
2619
|
function Hl(e, t) {
|
|
2483
2620
|
if (!Ze.has(e) && Ze.size >= Vl) {
|
|
@@ -2500,16 +2637,16 @@ function Wl(e) {
|
|
|
2500
2637
|
}
|
|
2501
2638
|
function Kl(e) {
|
|
2502
2639
|
const t = Wl(e);
|
|
2503
|
-
return t ? `${
|
|
2640
|
+
return t ? `${ql}/logo_256_${t}.svg` : null;
|
|
2504
2641
|
}
|
|
2505
|
-
function
|
|
2642
|
+
function o0(e, t) {
|
|
2506
2643
|
var n, o;
|
|
2507
2644
|
return ((n = e.iconUrl) != null && n.trim() ? e.iconUrl : null) ?? ((o = t[te(e.address)]) == null ? void 0 : o.iconURL) ?? Kl(e.symbol);
|
|
2508
2645
|
}
|
|
2509
2646
|
function zl(e, t) {
|
|
2510
2647
|
return `query AegisSwapWidgetTokenMetadata { ${t.map((o, a) => `t${a}: getGlobalToken(id: ${JSON.stringify($l(e, o))}) { chainId address symbol displayName fullName decimals iconURL price }`).join(" ")} }`;
|
|
2511
2648
|
}
|
|
2512
|
-
async function
|
|
2649
|
+
async function a0(e) {
|
|
2513
2650
|
var p, d;
|
|
2514
2651
|
const t = e.endpoint.trim();
|
|
2515
2652
|
if (!Number.isSafeInteger(e.chainId))
|
|
@@ -2530,7 +2667,7 @@ async function af(e) {
|
|
|
2530
2667
|
if (!a.length || typeof fetch != "function") return o;
|
|
2531
2668
|
const { signal: r, cleanup: i } = it({
|
|
2532
2669
|
signal: e.signal,
|
|
2533
|
-
timeoutMs: e.timeoutMs ??
|
|
2670
|
+
timeoutMs: e.timeoutMs ?? Ol,
|
|
2534
2671
|
timeoutMessage: "Token metadata request timed out."
|
|
2535
2672
|
});
|
|
2536
2673
|
let s;
|
|
@@ -2565,17 +2702,17 @@ const Gl = 15e3, jl = 900 * 1e3, Ql = 512, Xl = 4096, xo = ge({
|
|
|
2565
2702
|
ttlMs: jl,
|
|
2566
2703
|
maxEntries: Ql
|
|
2567
2704
|
}), Yl = T({
|
|
2568
|
-
t:
|
|
2569
|
-
p:
|
|
2705
|
+
t: b().int().nonnegative(),
|
|
2706
|
+
p: b().finite().positive()
|
|
2570
2707
|
}).strict(), Jl = T({
|
|
2571
|
-
chainId:
|
|
2708
|
+
chainId: b().int().positive(),
|
|
2572
2709
|
address: S().regex(/^0x[0-9a-fA-F]{40}$/),
|
|
2573
2710
|
symbol: S().nullable(),
|
|
2574
2711
|
resolution: B("12h"),
|
|
2575
|
-
window:
|
|
2576
|
-
status:
|
|
2577
|
-
points:
|
|
2578
|
-
pointCount:
|
|
2712
|
+
window: H(["7d", "30d", "90d", "180d"]),
|
|
2713
|
+
status: H(["ready", "warming_up", "no_data"]),
|
|
2714
|
+
points: F(Yl).max(Xl),
|
|
2715
|
+
pointCount: b().int().nonnegative(),
|
|
2579
2716
|
updatedAt: Ce.nullable()
|
|
2580
2717
|
}).strict().superRefine(tr);
|
|
2581
2718
|
function Zl(e) {
|
|
@@ -2588,7 +2725,7 @@ function Zl(e) {
|
|
|
2588
2725
|
uo(e.headers)
|
|
2589
2726
|
].join("|");
|
|
2590
2727
|
}
|
|
2591
|
-
function
|
|
2728
|
+
function r0() {
|
|
2592
2729
|
xo.clear();
|
|
2593
2730
|
}
|
|
2594
2731
|
function Ur(e) {
|
|
@@ -2596,7 +2733,7 @@ function Ur(e) {
|
|
|
2596
2733
|
if (!t) return null;
|
|
2597
2734
|
if (!Number.isSafeInteger(e.chainId) || e.chainId <= 0)
|
|
2598
2735
|
throw new Error("Token price history chainId must be a positive safe integer.");
|
|
2599
|
-
const n = D(e.tokenAddress), o = xe(n) ?
|
|
2736
|
+
const n = D(e.tokenAddress), o = xe(n) ? ce : n, a = e.window ?? "30d";
|
|
2600
2737
|
return {
|
|
2601
2738
|
key: Zl({
|
|
2602
2739
|
baseUrl: t,
|
|
@@ -2612,7 +2749,7 @@ function Ur(e) {
|
|
|
2612
2749
|
window: a
|
|
2613
2750
|
};
|
|
2614
2751
|
}
|
|
2615
|
-
function
|
|
2752
|
+
function i0(e) {
|
|
2616
2753
|
const t = Ur(e);
|
|
2617
2754
|
return t ? xo.peek(t.key) ?? null : null;
|
|
2618
2755
|
}
|
|
@@ -2661,7 +2798,7 @@ async function ed(e) {
|
|
|
2661
2798
|
updatedAt: a.data.updatedAt
|
|
2662
2799
|
};
|
|
2663
2800
|
}
|
|
2664
|
-
async function
|
|
2801
|
+
async function s0(e) {
|
|
2665
2802
|
const t = Ur(e);
|
|
2666
2803
|
if (!t) return null;
|
|
2667
2804
|
const n = xo.read(
|
|
@@ -2745,7 +2882,7 @@ async function Wr(e) {
|
|
|
2745
2882
|
const t = Lt({
|
|
2746
2883
|
account: e.wallet.account,
|
|
2747
2884
|
chain: e.chain,
|
|
2748
|
-
transport:
|
|
2885
|
+
transport: wt(ln(e.wallet.provider, e.signal))
|
|
2749
2886
|
}), n = await _r({
|
|
2750
2887
|
provider: e.wallet.provider,
|
|
2751
2888
|
publicClient: e.publicClient,
|
|
@@ -2839,7 +2976,7 @@ async function rd({
|
|
|
2839
2976
|
fee: h
|
|
2840
2977
|
});
|
|
2841
2978
|
c("submitting");
|
|
2842
|
-
const
|
|
2979
|
+
const w = await Vr(t, {
|
|
2843
2980
|
account: e.account,
|
|
2844
2981
|
to: o.router,
|
|
2845
2982
|
data: f.calldata,
|
|
@@ -2859,7 +2996,7 @@ async function rd({
|
|
|
2859
2996
|
to: o.router,
|
|
2860
2997
|
data: f.calldata,
|
|
2861
2998
|
value: f.value,
|
|
2862
|
-
gas:
|
|
2999
|
+
gas: w,
|
|
2863
3000
|
signal: l,
|
|
2864
3001
|
swapDetails: y,
|
|
2865
3002
|
// Lets the receipt summary report the settled (not quoted) output amount.
|
|
@@ -2904,7 +3041,7 @@ async function zr({
|
|
|
2904
3041
|
if (c == null || c.throwIfAborted(), un(h, i, s))
|
|
2905
3042
|
return d == null || d({ planned: 0, completed: 0 }), null;
|
|
2906
3043
|
d == null || d({ planned: 1, completed: 0 });
|
|
2907
|
-
const f = await
|
|
3044
|
+
const f = await Fl({
|
|
2908
3045
|
provider: e.provider,
|
|
2909
3046
|
publicClient: t,
|
|
2910
3047
|
account: e.account,
|
|
@@ -2918,20 +3055,20 @@ async function zr({
|
|
|
2918
3055
|
allowanceRead: Promise.resolve(h),
|
|
2919
3056
|
signal: c,
|
|
2920
3057
|
onWalletRequest: m
|
|
2921
|
-
}).catch((
|
|
2922
|
-
if (Is(
|
|
3058
|
+
}).catch((w) => {
|
|
3059
|
+
if (Is(w) || !sd(w)) throw w;
|
|
2923
3060
|
});
|
|
2924
3061
|
if (c == null || c.throwIfAborted(), f === null)
|
|
2925
3062
|
return d == null || d({ planned: 0, completed: 0 }), null;
|
|
2926
3063
|
if (f) {
|
|
2927
|
-
const
|
|
3064
|
+
const w = await t.getCode({ address: f.owner });
|
|
2928
3065
|
c == null || c.throwIfAborted();
|
|
2929
3066
|
const y = await Nl({
|
|
2930
3067
|
publicClient: t,
|
|
2931
3068
|
chainId: n.chainId,
|
|
2932
3069
|
permit2: o,
|
|
2933
3070
|
signed: f,
|
|
2934
|
-
ownerCode:
|
|
3071
|
+
ownerCode: w
|
|
2935
3072
|
});
|
|
2936
3073
|
if (c == null || c.throwIfAborted(), y)
|
|
2937
3074
|
return d == null || d({ planned: 1, completed: 1 }), f;
|
|
@@ -2940,7 +3077,7 @@ async function zr({
|
|
|
2940
3077
|
retryable: !0
|
|
2941
3078
|
});
|
|
2942
3079
|
}
|
|
2943
|
-
return c == null || c.throwIfAborted(), p("approving"), await
|
|
3080
|
+
return c == null || c.throwIfAborted(), p("approving"), await Or({
|
|
2944
3081
|
provider: e.provider,
|
|
2945
3082
|
publicClient: t,
|
|
2946
3083
|
account: e.account,
|
|
@@ -2953,15 +3090,15 @@ async function zr({
|
|
|
2953
3090
|
expiration: Math.floor(Date.now() / 1e3) + So,
|
|
2954
3091
|
signal: c,
|
|
2955
3092
|
onWalletRequest: m,
|
|
2956
|
-
onHash: (
|
|
2957
|
-
u == null || u(
|
|
3093
|
+
onHash: (w) => {
|
|
3094
|
+
u == null || u(w), d == null || d({ planned: 1, completed: 0, pendingHash: w });
|
|
2958
3095
|
}
|
|
2959
3096
|
}), d == null || d({ planned: 1, completed: 1 }), null;
|
|
2960
3097
|
}
|
|
2961
|
-
function
|
|
3098
|
+
function c0() {
|
|
2962
3099
|
return typeof document > "u" ? !0 : document.visibilityState !== "hidden";
|
|
2963
3100
|
}
|
|
2964
|
-
async function
|
|
3101
|
+
async function l0(e, t, n, o) {
|
|
2965
3102
|
let a;
|
|
2966
3103
|
for (let r = 0; r < t; r += 1) {
|
|
2967
3104
|
r > 0 && await new Promise((i) => setTimeout(i, n));
|
|
@@ -3019,13 +3156,13 @@ async function jr(e) {
|
|
|
3019
3156
|
return (s = e.onApprovalProgress) == null || s.call(e, { planned: 0, completed: 0 }), { approvalHashes: [], allowance: n };
|
|
3020
3157
|
(l = e.onApprovalProgress) == null || l.call(e, { planned: o.planned, completed: 0, request: t }), (c = e.onStatus) == null || c.call(e, "approving");
|
|
3021
3158
|
const a = e.executeStep ?? ((h, f) => f({
|
|
3022
|
-
onHash: (
|
|
3159
|
+
onHash: (w) => {
|
|
3023
3160
|
var y;
|
|
3024
3161
|
return (y = e.onApprovalProgress) == null ? void 0 : y.call(e, {
|
|
3025
3162
|
planned: o.planned,
|
|
3026
3163
|
completed: h === "reset" ? 0 : o.planned - 1,
|
|
3027
3164
|
request: t,
|
|
3028
|
-
pendingHash:
|
|
3165
|
+
pendingHash: w
|
|
3029
3166
|
});
|
|
3030
3167
|
}
|
|
3031
3168
|
})), r = [];
|
|
@@ -3072,7 +3209,7 @@ async function Ke(e) {
|
|
|
3072
3209
|
if ((s = e.signal) == null || s.throwIfAborted(), (l = e.onChainId) == null || l.call(e, a), !o)
|
|
3073
3210
|
throw new Error("Network switch did not complete. Switch to the correct network and try again.");
|
|
3074
3211
|
}
|
|
3075
|
-
async function
|
|
3212
|
+
async function d0(e = {}) {
|
|
3076
3213
|
var a;
|
|
3077
3214
|
let n = e.provider !== void 0 || !!e.getProvider ? e.provider ?? await ((a = e.getProvider) == null ? void 0 : a.call(e)) ?? null : pl(), o = dn(e.account);
|
|
3078
3215
|
if ((!n || !o) && e.connectWallet) {
|
|
@@ -3080,13 +3217,13 @@ async function uf(e = {}) {
|
|
|
3080
3217
|
n = r.provider ?? n, o = o ?? r.account;
|
|
3081
3218
|
}
|
|
3082
3219
|
if (!n) throw new Error("No wallet provider found.");
|
|
3083
|
-
if (o || (o = e.requestAccount === !1 ? await
|
|
3220
|
+
if (o || (o = e.requestAccount === !1 ? await bl(n) : await wl(n)), !o) throw new Error("Wallet connection was not completed.");
|
|
3084
3221
|
return { provider: n, account: o };
|
|
3085
3222
|
}
|
|
3086
3223
|
class ha extends Error {
|
|
3087
3224
|
constructor(n) {
|
|
3088
3225
|
super("Price moved beyond your slippage tolerance. Review the updated quote and try again.");
|
|
3089
|
-
|
|
3226
|
+
j(this, "quote");
|
|
3090
3227
|
this.name = "DirectPoolSwapPriceMovedError", this.quote = n;
|
|
3091
3228
|
}
|
|
3092
3229
|
}
|
|
@@ -3106,8 +3243,8 @@ function md(e) {
|
|
|
3106
3243
|
if (!t && !n)
|
|
3107
3244
|
throw new TypeError("Selected tokens do not match the trusted direct-swap market.");
|
|
3108
3245
|
}
|
|
3109
|
-
function
|
|
3110
|
-
return
|
|
3246
|
+
function ba(e) {
|
|
3247
|
+
return wc({
|
|
3111
3248
|
publicClient: e.publicClient,
|
|
3112
3249
|
account: e.account,
|
|
3113
3250
|
market: e.market,
|
|
@@ -3133,7 +3270,7 @@ async function pd(e) {
|
|
|
3133
3270
|
owner: e.wallet.account,
|
|
3134
3271
|
spender: t
|
|
3135
3272
|
}),
|
|
3136
|
-
write: (r, i) =>
|
|
3273
|
+
write: (r, i) => qr({
|
|
3137
3274
|
provider: e.wallet.provider,
|
|
3138
3275
|
publicClient: e.publicClient,
|
|
3139
3276
|
account: e.wallet.account,
|
|
@@ -3154,7 +3291,7 @@ async function pd(e) {
|
|
|
3154
3291
|
});
|
|
3155
3292
|
return { approvalHash: n.at(-1) ?? null, allowance: o };
|
|
3156
3293
|
}
|
|
3157
|
-
async function
|
|
3294
|
+
async function u0(e) {
|
|
3158
3295
|
var y, E, C, x, A, P, g;
|
|
3159
3296
|
md(e), await Ke({
|
|
3160
3297
|
provider: e.wallet.provider,
|
|
@@ -3175,7 +3312,7 @@ async function mf(e) {
|
|
|
3175
3312
|
});
|
|
3176
3313
|
o == null || o.catch(() => {
|
|
3177
3314
|
});
|
|
3178
|
-
const a = await
|
|
3315
|
+
const a = await ba({
|
|
3179
3316
|
publicClient: e.publicClient,
|
|
3180
3317
|
account: e.wallet.account,
|
|
3181
3318
|
activeChain: e.activeChain,
|
|
@@ -3225,14 +3362,14 @@ async function mf(e) {
|
|
|
3225
3362
|
approvalMode: c,
|
|
3226
3363
|
allowanceRead: o,
|
|
3227
3364
|
signal: e.signal,
|
|
3228
|
-
setStatus: (
|
|
3365
|
+
setStatus: (O) => {
|
|
3229
3366
|
var L;
|
|
3230
|
-
return (L = e.onStatus) == null ? void 0 : L.call(e,
|
|
3367
|
+
return (L = e.onStatus) == null ? void 0 : L.call(e, O);
|
|
3231
3368
|
},
|
|
3232
3369
|
onAuthorizationProgress: e.onAuthorizationProgress
|
|
3233
3370
|
});
|
|
3234
3371
|
}
|
|
3235
|
-
const d = await
|
|
3372
|
+
const d = await ba({
|
|
3236
3373
|
publicClient: e.publicClient,
|
|
3237
3374
|
account: e.wallet.account,
|
|
3238
3375
|
activeChain: e.activeChain,
|
|
@@ -3249,7 +3386,7 @@ async function mf(e) {
|
|
|
3249
3386
|
), u = m.quote, h = u.mode === "exactOut" ? u.amountIn > s : aa(u) > s;
|
|
3250
3387
|
if (m.priceMovedBeyondTolerance || h)
|
|
3251
3388
|
throw (P = e.onStatus) == null || P.call(e, "idle"), new ha(d);
|
|
3252
|
-
const f = u.mode === "exactOut" && u.amountInMaximum > s ? { ...u, amountInMaximum: s } : u,
|
|
3389
|
+
const f = u.mode === "exactOut" && u.amountInMaximum > s ? { ...u, amountInMaximum: s } : u, w = await rd({
|
|
3253
3390
|
wallet: e.wallet,
|
|
3254
3391
|
publicClient: e.publicClient,
|
|
3255
3392
|
activeChain: e.activeChain,
|
|
@@ -3260,22 +3397,22 @@ async function mf(e) {
|
|
|
3260
3397
|
permit: p,
|
|
3261
3398
|
signal: e.signal,
|
|
3262
3399
|
setStatus: (M) => {
|
|
3263
|
-
var
|
|
3264
|
-
return (
|
|
3400
|
+
var O;
|
|
3401
|
+
return (O = e.onStatus) == null ? void 0 : O.call(e, M);
|
|
3265
3402
|
},
|
|
3266
3403
|
setTxHash: (M) => {
|
|
3267
|
-
var
|
|
3268
|
-
return (
|
|
3404
|
+
var O;
|
|
3405
|
+
return (O = e.onTxHash) == null ? void 0 : O.call(e, M);
|
|
3269
3406
|
},
|
|
3270
3407
|
onTransactionObservation: e.onTransactionObservation,
|
|
3271
3408
|
onSubmitted: e.onSubmitted
|
|
3272
3409
|
});
|
|
3273
3410
|
return (g = e.onStatus) == null || g.call(e, "success"), {
|
|
3274
|
-
hash:
|
|
3275
|
-
explorerUrl:
|
|
3411
|
+
hash: w.receipt.transactionHash,
|
|
3412
|
+
explorerUrl: wo(w.receipt.transactionHash, e.activeChain),
|
|
3276
3413
|
quote: f,
|
|
3277
|
-
receiptSummary:
|
|
3278
|
-
swap:
|
|
3414
|
+
receiptSummary: w.summary,
|
|
3415
|
+
swap: w.swapDetails
|
|
3279
3416
|
};
|
|
3280
3417
|
}
|
|
3281
3418
|
function Yr(e) {
|
|
@@ -3284,7 +3421,7 @@ function Yr(e) {
|
|
|
3284
3421
|
class fd extends _ {
|
|
3285
3422
|
constructor(n) {
|
|
3286
3423
|
super("Price moved beyond your slippage tolerance. Review the updated quote and try again.");
|
|
3287
|
-
|
|
3424
|
+
j(this, "quote");
|
|
3288
3425
|
this.name = "KyberSwapPriceMovedError", this.quote = n;
|
|
3289
3426
|
}
|
|
3290
3427
|
}
|
|
@@ -3294,7 +3431,7 @@ function hd(e, t) {
|
|
|
3294
3431
|
if (e.userAmountOutMinimum <= 0n)
|
|
3295
3432
|
throw new _("The reviewed swap minimum must be greater than zero.");
|
|
3296
3433
|
}
|
|
3297
|
-
async function
|
|
3434
|
+
async function bd(e) {
|
|
3298
3435
|
var t, n, o;
|
|
3299
3436
|
if ((t = e.signal) == null || t.throwIfAborted(), e.inputToken.chainId !== e.activeChain.chainId)
|
|
3300
3437
|
throw new _(
|
|
@@ -3326,7 +3463,7 @@ async function wd(e) {
|
|
|
3326
3463
|
onApprovalProgress: e.onApprovalProgress
|
|
3327
3464
|
});
|
|
3328
3465
|
}
|
|
3329
|
-
function
|
|
3466
|
+
function wd(e) {
|
|
3330
3467
|
return {
|
|
3331
3468
|
mode: "exactIn",
|
|
3332
3469
|
inputSymbol: e.inputToken.symbol,
|
|
@@ -3337,7 +3474,7 @@ function bd(e) {
|
|
|
3337
3474
|
feeBps: e.feeBps
|
|
3338
3475
|
};
|
|
3339
3476
|
}
|
|
3340
|
-
async function
|
|
3477
|
+
async function m0(e) {
|
|
3341
3478
|
var l, c, p;
|
|
3342
3479
|
if (e.inputToken.chainId !== e.activeChain.chainId || e.outputToken.chainId !== e.activeChain.chainId)
|
|
3343
3480
|
throw new Error(
|
|
@@ -3356,7 +3493,7 @@ async function pf(e) {
|
|
|
3356
3493
|
provider: e.wallet.provider,
|
|
3357
3494
|
chain: e.activeChain,
|
|
3358
3495
|
onChainId: e.onWalletChainId
|
|
3359
|
-
}), await
|
|
3496
|
+
}), await bd({
|
|
3360
3497
|
wallet: e.wallet,
|
|
3361
3498
|
publicClient: e.publicClient,
|
|
3362
3499
|
activeChain: e.activeChain,
|
|
@@ -3391,7 +3528,7 @@ async function pf(e) {
|
|
|
3391
3528
|
to: n.routerAddress,
|
|
3392
3529
|
data: n.calldata,
|
|
3393
3530
|
value: o
|
|
3394
|
-
}), r =
|
|
3531
|
+
}), r = wd(n), { receipt: i, summary: s } = await Kr({
|
|
3395
3532
|
wallet: e.wallet,
|
|
3396
3533
|
publicClient: e.publicClient,
|
|
3397
3534
|
chain: e.activeChain.chain,
|
|
@@ -3409,16 +3546,16 @@ async function pf(e) {
|
|
|
3409
3546
|
});
|
|
3410
3547
|
return (p = e.onStatus) == null || p.call(e, "success"), {
|
|
3411
3548
|
hash: i.transactionHash,
|
|
3412
|
-
explorerUrl:
|
|
3549
|
+
explorerUrl: wo(i.transactionHash, e.activeChain),
|
|
3413
3550
|
quote: n,
|
|
3414
3551
|
receiptSummary: s,
|
|
3415
3552
|
swap: r
|
|
3416
3553
|
};
|
|
3417
3554
|
}
|
|
3418
|
-
function
|
|
3555
|
+
function p0(e) {
|
|
3419
3556
|
return e === "approving" || e === "signing" || e === "submitting";
|
|
3420
3557
|
}
|
|
3421
|
-
function
|
|
3558
|
+
function f0(e) {
|
|
3422
3559
|
const t = (e == null ? void 0 : e.steps) ?? (e == null ? void 0 : e.walletPrompts.total);
|
|
3423
3560
|
return t !== void 0 && Number.isFinite(t) && t >= 2 ? Math.floor(t) : void 0;
|
|
3424
3561
|
}
|
|
@@ -3456,7 +3593,7 @@ function Ed({
|
|
|
3456
3593
|
authorizationsCompleted: p,
|
|
3457
3594
|
retainIdlePlan: d
|
|
3458
3595
|
}) {
|
|
3459
|
-
const m = ht(a ?? (o || r ? i ? 2 : 1 : 0)), u = r ? m : Math.min(ht(s), m), h = ht(c ?? (l ? 1 : 0)), f = Math.min(ht(p), h),
|
|
3596
|
+
const m = ht(a ?? (o || r ? i ? 2 : 1 : 0)), u = r ? m : Math.min(ht(s), m), h = ht(c ?? (l ? 1 : 0)), f = Math.min(ht(p), h), w = u > 0 || f > 0, y = m > 0 || h > 0, E = e === "idle" && !r && !w && !(d && y) ? 0 : 1 + m + h;
|
|
3460
3597
|
if (E === 0) return kd;
|
|
3461
3598
|
if (e === "success") return { total: E, completed: E, active: null };
|
|
3462
3599
|
if (e === "idle")
|
|
@@ -3492,7 +3629,7 @@ function Ed({
|
|
|
3492
3629
|
active: t ? null : E
|
|
3493
3630
|
};
|
|
3494
3631
|
}
|
|
3495
|
-
function
|
|
3632
|
+
function h0({
|
|
3496
3633
|
status: e,
|
|
3497
3634
|
inputSymbol: t,
|
|
3498
3635
|
txHash: n,
|
|
@@ -3591,7 +3728,7 @@ const Jr = {
|
|
|
3591
3728
|
};
|
|
3592
3729
|
function yd(e) {
|
|
3593
3730
|
if (e === X) return [...lr];
|
|
3594
|
-
if (e ===
|
|
3731
|
+
if (e === be) return [...dr];
|
|
3595
3732
|
const t = Jr[e];
|
|
3596
3733
|
return t ? [...t.rpcUrls.default.http] : [];
|
|
3597
3734
|
}
|
|
@@ -3668,7 +3805,7 @@ function Rd(e) {
|
|
|
3668
3805
|
function Pd(e) {
|
|
3669
3806
|
return e.map(Rd);
|
|
3670
3807
|
}
|
|
3671
|
-
function
|
|
3808
|
+
function b0(e, t, n = {}) {
|
|
3672
3809
|
var i, s, l, c, p, d, m;
|
|
3673
3810
|
const o = {}, a = Id(e), r = Td(n.enabledChainIds);
|
|
3674
3811
|
for (const u of e.chains) {
|
|
@@ -3685,14 +3822,14 @@ function bf(e, t, n = {}) {
|
|
|
3685
3822
|
})
|
|
3686
3823
|
);
|
|
3687
3824
|
if (!f) continue;
|
|
3688
|
-
const { router:
|
|
3689
|
-
if (!
|
|
3825
|
+
const { router: w, permit2: y, quoter: E, contracts: C } = f, x = Se[h], A = ((i = t == null ? void 0 : t[h]) == null ? void 0 : i.chain) ?? Jr[h];
|
|
3826
|
+
if (!w || !y || !E || !A) {
|
|
3690
3827
|
Be(n.onSkip, {
|
|
3691
3828
|
kind: "chain",
|
|
3692
3829
|
chainId: h,
|
|
3693
3830
|
reason: "chain skipped: missing router/permit2/quoter or unknown chain",
|
|
3694
3831
|
context: {
|
|
3695
|
-
router: !!
|
|
3832
|
+
router: !!w,
|
|
3696
3833
|
permit2: !!y,
|
|
3697
3834
|
quoter: !!E,
|
|
3698
3835
|
viemChain: !!A
|
|
@@ -3716,17 +3853,17 @@ function bf(e, t, n = {}) {
|
|
|
3716
3853
|
permit2: y,
|
|
3717
3854
|
quoter: E,
|
|
3718
3855
|
poolManager: C.v4PoolManager ?? ((d = (p = t == null ? void 0 : t[h]) == null ? void 0 : p.v4Contracts) == null ? void 0 : d.poolManager)
|
|
3719
|
-
},
|
|
3856
|
+
}, O = Object.prototype.hasOwnProperty.call(n, "metadataEndpoint") ? n.metadataEndpoint : (m = t == null ? void 0 : t[h]) == null ? void 0 : m.metadataEndpoint, L = {
|
|
3720
3857
|
...t == null ? void 0 : t[h],
|
|
3721
3858
|
chainId: h,
|
|
3722
3859
|
chain: A,
|
|
3723
3860
|
name: u.name,
|
|
3724
|
-
router:
|
|
3861
|
+
router: w,
|
|
3725
3862
|
permit2: y,
|
|
3726
3863
|
quoter: E,
|
|
3727
3864
|
v4Contracts: M,
|
|
3728
3865
|
rpcUrls: g,
|
|
3729
|
-
metadataEndpoint:
|
|
3866
|
+
metadataEndpoint: O
|
|
3730
3867
|
};
|
|
3731
3868
|
o[h] = {
|
|
3732
3869
|
...ur(L),
|
|
@@ -3735,7 +3872,7 @@ function bf(e, t, n = {}) {
|
|
|
3735
3872
|
}
|
|
3736
3873
|
return o;
|
|
3737
3874
|
}
|
|
3738
|
-
function
|
|
3875
|
+
function w0({
|
|
3739
3876
|
config: e,
|
|
3740
3877
|
markets: t,
|
|
3741
3878
|
tokens: n,
|
|
@@ -3807,11 +3944,11 @@ function kf({
|
|
|
3807
3944
|
permit2: m,
|
|
3808
3945
|
quoter: u,
|
|
3809
3946
|
...s.label ? { label: s.label } : {}
|
|
3810
|
-
},
|
|
3947
|
+
}, w = Er(f), y = o.find(
|
|
3811
3948
|
(g) => g.chainId === s.chainId && g.poolId !== void 0 && Z(g.poolId, s.poolId)
|
|
3812
3949
|
), E = y != null && y.router && y.permit2 && y.quoter ? k(y.poolKey.currency0, s.poolKey.currency0) && k(y.poolKey.currency1, s.poolKey.currency1) && y.poolKey.fee === s.poolKey.fee && y.poolKey.tickSpacing === s.poolKey.tickSpacing && k(y.poolKey.hooks, s.poolKey.hooks) && k(y.router, d) && k(y.permit2, m) && k(y.quoter, u) : !1;
|
|
3813
3950
|
if (!y || !E)
|
|
3814
|
-
return
|
|
3951
|
+
return w ? [f] : (Be(r, {
|
|
3815
3952
|
kind: "market",
|
|
3816
3953
|
chainId: s.chainId,
|
|
3817
3954
|
marketId: s.id,
|
|
@@ -3849,7 +3986,7 @@ function kf({
|
|
|
3849
3986
|
}];
|
|
3850
3987
|
});
|
|
3851
3988
|
}
|
|
3852
|
-
const ze =
|
|
3989
|
+
const ze = b().int().positive(), Et = b().finite().nullable().optional(), xn = b().int().nullable().optional(), Qn = Ce.nullable().optional(), ut = b().finite().nullable(), Tn = b().int().nonnegative().nullable(), Qt = Ve().nullable(), et = de.nullable(), Bd = b().int().min(0).max(16777215), ei = B("post_swap_surge_trigger"), Q = S().regex(
|
|
3853
3990
|
/^-?[0-9]+$/,
|
|
3854
3991
|
"Expected a signed base-10 integer string."
|
|
3855
3992
|
), yt = lo.refine(
|
|
@@ -3860,35 +3997,35 @@ const ze = w().int().positive(), Et = w().finite().nullable().optional(), xn = w
|
|
|
3860
3997
|
"Engine transaction hash must be a 32-byte hex value."
|
|
3861
3998
|
), nn = T({
|
|
3862
3999
|
chainId: ze,
|
|
3863
|
-
address:
|
|
4000
|
+
address: K,
|
|
3864
4001
|
name: S(),
|
|
3865
4002
|
symbol: S(),
|
|
3866
|
-
decimals:
|
|
4003
|
+
decimals: b().int().min(0).max(255),
|
|
3867
4004
|
iconUrl: S().nullable().optional(),
|
|
3868
4005
|
priceUsd: Et.transform((e) => e ?? void 0),
|
|
3869
4006
|
stable: Ve().nullable().optional().transform((e) => e ?? void 0)
|
|
3870
4007
|
}), ti = T({
|
|
3871
4008
|
source: B("canopy"),
|
|
3872
4009
|
updatedAt: Qn,
|
|
3873
|
-
blockNumber:
|
|
3874
|
-
marketCount:
|
|
4010
|
+
blockNumber: b().int().nonnegative().nullable().optional(),
|
|
4011
|
+
marketCount: b().int().nonnegative()
|
|
3875
4012
|
}).strict(), Dd = T({
|
|
3876
4013
|
schemaVersion: B("1"),
|
|
3877
4014
|
chainId: ze,
|
|
3878
|
-
markets:
|
|
4015
|
+
markets: F(tn()),
|
|
3879
4016
|
freshness: ti
|
|
3880
4017
|
}), _d = T({
|
|
3881
4018
|
schemaVersion: B("2"),
|
|
3882
4019
|
chainId: ze,
|
|
3883
|
-
markets:
|
|
4020
|
+
markets: F(tn()),
|
|
3884
4021
|
freshness: ti
|
|
3885
4022
|
}).strict(), Ro = S().regex(
|
|
3886
4023
|
/^evm_[1-9]\d*_0x[0-9a-fA-F]{64}$/,
|
|
3887
4024
|
"Engine marketId must contain a positive chain id and 32-byte pool id."
|
|
3888
4025
|
), ni = T({
|
|
3889
|
-
t:
|
|
4026
|
+
t: b().int().nonnegative(),
|
|
3890
4027
|
observedAt: Ce,
|
|
3891
|
-
blockNumber:
|
|
4028
|
+
blockNumber: b().int().nonnegative(),
|
|
3892
4029
|
utilizationPct: ut,
|
|
3893
4030
|
borrowAprPct: ut,
|
|
3894
4031
|
lendApyPct: ut,
|
|
@@ -3907,7 +4044,7 @@ const ze = w().int().positive(), Et = w().finite().nullable().optional(), xn = w
|
|
|
3907
4044
|
inCapEvent: Qt,
|
|
3908
4045
|
manualOverride: Qt,
|
|
3909
4046
|
perSwapMode: Qt,
|
|
3910
|
-
warnings:
|
|
4047
|
+
warnings: F(S())
|
|
3911
4048
|
}).strict(), Nd = ni.extend({
|
|
3912
4049
|
adaptiveTickThresholdTicks: Bd.nullable(),
|
|
3913
4050
|
adaptiveTickThresholdMode: ei.nullable(),
|
|
@@ -3933,30 +4070,30 @@ function oi(e, t) {
|
|
|
3933
4070
|
message: "updatedAt must equal the newest point observedAt."
|
|
3934
4071
|
});
|
|
3935
4072
|
}
|
|
3936
|
-
const
|
|
4073
|
+
const Fd = T({
|
|
3937
4074
|
marketId: Ro,
|
|
3938
4075
|
resolution: B("12h"),
|
|
3939
|
-
window:
|
|
3940
|
-
status:
|
|
3941
|
-
pointCount:
|
|
3942
|
-
points:
|
|
4076
|
+
window: H(["7d", "30d", "60d"]),
|
|
4077
|
+
status: H(["ready", "warming_up", "no_data"]),
|
|
4078
|
+
pointCount: b().int().nonnegative(),
|
|
4079
|
+
points: F(ni),
|
|
3943
4080
|
updatedAt: Ce.nullable()
|
|
3944
|
-
}).strict().superRefine(oi),
|
|
4081
|
+
}).strict().superRefine(oi), qd = T({
|
|
3945
4082
|
schemaVersion: B("2"),
|
|
3946
4083
|
marketId: Ro,
|
|
3947
4084
|
resolution: B("12h"),
|
|
3948
|
-
window:
|
|
3949
|
-
status:
|
|
3950
|
-
pointCount:
|
|
3951
|
-
points:
|
|
4085
|
+
window: H(["7d", "30d", "60d"]),
|
|
4086
|
+
status: H(["ready", "warming_up", "no_data"]),
|
|
4087
|
+
pointCount: b().int().nonnegative(),
|
|
4088
|
+
points: F(Nd),
|
|
3952
4089
|
updatedAt: Ce.nullable()
|
|
3953
|
-
}).strict().superRefine(oi),
|
|
3954
|
-
raw:
|
|
4090
|
+
}).strict().superRefine(oi), wa = T({
|
|
4091
|
+
raw: de,
|
|
3955
4092
|
formatted: S(),
|
|
3956
4093
|
valueUsd: Et
|
|
3957
|
-
}),
|
|
3958
|
-
principalRaw:
|
|
3959
|
-
borrowIndexWadAtLastDebt:
|
|
4094
|
+
}), Od = T({
|
|
4095
|
+
principalRaw: de,
|
|
4096
|
+
borrowIndexWadAtLastDebt: de.nullable().optional()
|
|
3960
4097
|
}), Ld = T({
|
|
3961
4098
|
lastLockedPips: xn,
|
|
3962
4099
|
lastLockedPct: Et,
|
|
@@ -3965,45 +4102,45 @@ const qd = T({
|
|
|
3965
4102
|
}).strict(), Ud = T({
|
|
3966
4103
|
id: S().nullable().optional(),
|
|
3967
4104
|
kind: S().nullable().optional(),
|
|
3968
|
-
tokenId:
|
|
3969
|
-
liquidityRaw:
|
|
4105
|
+
tokenId: de.nullable().optional(),
|
|
4106
|
+
liquidityRaw: de.nullable().optional()
|
|
3970
4107
|
}), ai = T({
|
|
3971
4108
|
id: S(),
|
|
3972
4109
|
chainId: ze,
|
|
3973
|
-
account:
|
|
3974
|
-
vaultId:
|
|
3975
|
-
status:
|
|
4110
|
+
account: K,
|
|
4111
|
+
vaultId: de,
|
|
4112
|
+
status: H(["open", "debt", "collateral", "empty"]),
|
|
3976
4113
|
marketId: S().nullable().optional(),
|
|
3977
4114
|
marketName: S().nullable().optional(),
|
|
3978
4115
|
poolId: yt,
|
|
3979
4116
|
token0: nn.nullable().optional(),
|
|
3980
4117
|
token1: nn.nullable().optional(),
|
|
3981
|
-
amount0:
|
|
3982
|
-
amount1:
|
|
4118
|
+
amount0: wa,
|
|
4119
|
+
amount1: wa,
|
|
3983
4120
|
collateralValueUsd: Et,
|
|
3984
|
-
debt:
|
|
4121
|
+
debt: Od,
|
|
3985
4122
|
ltv: Ld,
|
|
3986
4123
|
nfts: T({
|
|
3987
|
-
count:
|
|
3988
|
-
items:
|
|
4124
|
+
count: b().int().nonnegative(),
|
|
4125
|
+
items: F(Ud)
|
|
3989
4126
|
}),
|
|
3990
4127
|
createdAt: Qn,
|
|
3991
|
-
createdBlockNumber:
|
|
4128
|
+
createdBlockNumber: b().int().nonnegative().nullable().optional(),
|
|
3992
4129
|
updatedAt: Qn,
|
|
3993
|
-
warnings:
|
|
4130
|
+
warnings: F(S())
|
|
3994
4131
|
}), Vd = T({
|
|
3995
4132
|
schemaVersion: B("1"),
|
|
3996
4133
|
chainId: ze,
|
|
3997
|
-
account:
|
|
3998
|
-
positions:
|
|
4134
|
+
account: K,
|
|
4135
|
+
positions: F(ai),
|
|
3999
4136
|
totals: T({
|
|
4000
4137
|
collateralValueUsd: Et,
|
|
4001
|
-
positionCount:
|
|
4138
|
+
positionCount: b().int().nonnegative()
|
|
4002
4139
|
}).strict(),
|
|
4003
4140
|
freshness: T({
|
|
4004
4141
|
source: B("subgraph"),
|
|
4005
|
-
blockNumber:
|
|
4006
|
-
positionCount:
|
|
4142
|
+
blockNumber: b().int().nonnegative().nullable().optional(),
|
|
4143
|
+
positionCount: b().int().nonnegative()
|
|
4007
4144
|
})
|
|
4008
4145
|
}).superRefine((e, t) => {
|
|
4009
4146
|
for (const [n, o] of [
|
|
@@ -4021,7 +4158,7 @@ const qd = T({
|
|
|
4021
4158
|
kind: B("lend_shares"),
|
|
4022
4159
|
id: S(),
|
|
4023
4160
|
chainId: ze,
|
|
4024
|
-
account:
|
|
4161
|
+
account: K,
|
|
4025
4162
|
// Backend always emits these (null when the owned pool has no market
|
|
4026
4163
|
// metadata), so require them — the client enforces the documented shape.
|
|
4027
4164
|
marketId: S().nullable(),
|
|
@@ -4029,11 +4166,11 @@ const qd = T({
|
|
|
4029
4166
|
poolId: yt,
|
|
4030
4167
|
token0: nn.nullable(),
|
|
4031
4168
|
token1: nn.nullable(),
|
|
4032
|
-
indexedBalanceRaw:
|
|
4033
|
-
warnings:
|
|
4169
|
+
indexedBalanceRaw: de,
|
|
4170
|
+
warnings: F(S()),
|
|
4034
4171
|
freshness: T({
|
|
4035
4172
|
source: B("subgraph"),
|
|
4036
|
-
indexedBlockNumber:
|
|
4173
|
+
indexedBlockNumber: b().int().nonnegative().nullable()
|
|
4037
4174
|
})
|
|
4038
4175
|
}), Wd = Vt("kind", [
|
|
4039
4176
|
Hd,
|
|
@@ -4041,18 +4178,18 @@ const qd = T({
|
|
|
4041
4178
|
]), Kd = T({
|
|
4042
4179
|
schemaVersion: B("2"),
|
|
4043
4180
|
chainId: ze,
|
|
4044
|
-
account:
|
|
4045
|
-
positions:
|
|
4181
|
+
account: K,
|
|
4182
|
+
positions: F(Wd),
|
|
4046
4183
|
totals: T({
|
|
4047
4184
|
collateralValueUsd: Et,
|
|
4048
|
-
positionCount:
|
|
4049
|
-
borrowVaultCount:
|
|
4050
|
-
lendPositionCount:
|
|
4185
|
+
positionCount: b().int().nonnegative(),
|
|
4186
|
+
borrowVaultCount: b().int().nonnegative(),
|
|
4187
|
+
lendPositionCount: b().int().nonnegative()
|
|
4051
4188
|
}).strict(),
|
|
4052
4189
|
freshness: T({
|
|
4053
4190
|
source: B("subgraph"),
|
|
4054
|
-
blockNumber:
|
|
4055
|
-
positionCount:
|
|
4191
|
+
blockNumber: b().int().nonnegative().nullable().optional(),
|
|
4192
|
+
positionCount: b().int().nonnegative()
|
|
4056
4193
|
})
|
|
4057
4194
|
}).superRefine((e, t) => {
|
|
4058
4195
|
const n = e.positions.filter((r) => r.kind === "borrow_vault").length, o = e.positions.length - n, a = [
|
|
@@ -4069,25 +4206,25 @@ const qd = T({
|
|
|
4069
4206
|
});
|
|
4070
4207
|
}), Te = T({
|
|
4071
4208
|
id: S().min(1),
|
|
4072
|
-
timestamp:
|
|
4073
|
-
blockNumber:
|
|
4074
|
-
transactionIndex:
|
|
4209
|
+
timestamp: b().int().nonnegative(),
|
|
4210
|
+
blockNumber: b().int().nonnegative(),
|
|
4211
|
+
transactionIndex: b().int().nonnegative(),
|
|
4075
4212
|
txHash: Md,
|
|
4076
|
-
logIndex:
|
|
4213
|
+
logIndex: b().int().nonnegative()
|
|
4077
4214
|
}).strict(), zd = Te.extend({
|
|
4078
4215
|
kind: B("vault_created"),
|
|
4079
|
-
owner:
|
|
4216
|
+
owner: K
|
|
4080
4217
|
}).strict(), Gd = Te.extend({
|
|
4081
4218
|
kind: B("vault_burned"),
|
|
4082
|
-
caller:
|
|
4219
|
+
caller: K
|
|
4083
4220
|
}).strict(), jd = Te.extend({
|
|
4084
4221
|
kind: B("vault_locked"),
|
|
4085
|
-
ltvPips:
|
|
4222
|
+
ltvPips: b().int().nullable()
|
|
4086
4223
|
}).strict(), Qd = Te.extend({
|
|
4087
4224
|
kind: B("debt_modified"),
|
|
4088
4225
|
principalDeltaRequestedRaw: Q,
|
|
4089
4226
|
principalDeltaActualRaw: Q,
|
|
4090
|
-
borrowIndexWad:
|
|
4227
|
+
borrowIndexWad: de,
|
|
4091
4228
|
deltaIdle0Raw: Q,
|
|
4092
4229
|
deltaIdle1Raw: Q
|
|
4093
4230
|
}).strict(), Xd = Te.extend({
|
|
@@ -4096,7 +4233,7 @@ const qd = T({
|
|
|
4096
4233
|
deltaAmount1Raw: Q
|
|
4097
4234
|
}).strict(), Yd = Te.extend({
|
|
4098
4235
|
kind: B("vault_micro_liquidated"),
|
|
4099
|
-
caller:
|
|
4236
|
+
caller: K,
|
|
4100
4237
|
zeroForOne: Ve(),
|
|
4101
4238
|
swapDelta0Raw: Q,
|
|
4102
4239
|
swapDelta1Raw: Q,
|
|
@@ -4105,7 +4242,7 @@ const qd = T({
|
|
|
4105
4242
|
idleDelta1Raw: Q,
|
|
4106
4243
|
keeperFee0Raw: Q,
|
|
4107
4244
|
keeperFee1Raw: Q,
|
|
4108
|
-
initialLtvPips:
|
|
4245
|
+
initialLtvPips: b().int().nullable()
|
|
4109
4246
|
}).strict(), Jd = Vt("kind", [
|
|
4110
4247
|
zd,
|
|
4111
4248
|
Gd,
|
|
@@ -4125,12 +4262,12 @@ const qd = T({
|
|
|
4125
4262
|
deltaAmount1Raw: Q
|
|
4126
4263
|
}).strict(), tu = Te.extend({
|
|
4127
4264
|
kind: B("transfer_in"),
|
|
4128
|
-
sharesRaw:
|
|
4129
|
-
counterparty:
|
|
4265
|
+
sharesRaw: de,
|
|
4266
|
+
counterparty: K
|
|
4130
4267
|
}).strict(), nu = Te.extend({
|
|
4131
4268
|
kind: B("transfer_out"),
|
|
4132
|
-
sharesRaw:
|
|
4133
|
-
counterparty:
|
|
4269
|
+
sharesRaw: de,
|
|
4270
|
+
counterparty: K
|
|
4134
4271
|
}).strict(), ou = Vt("kind", [
|
|
4135
4272
|
Zd,
|
|
4136
4273
|
eu,
|
|
@@ -4156,45 +4293,45 @@ const ru = T({
|
|
|
4156
4293
|
marketName: S().nullable(),
|
|
4157
4294
|
poolId: yt,
|
|
4158
4295
|
borrowIndexWad: et,
|
|
4159
|
-
lastAccrueTimestamp:
|
|
4296
|
+
lastAccrueTimestamp: b().int().nonnegative().nullable(),
|
|
4160
4297
|
ratePerSecondWad: et,
|
|
4161
4298
|
rateUpdatedAt: Ce.nullable(),
|
|
4162
4299
|
totalRlBorrowed: et,
|
|
4163
4300
|
shareTotalSupply: et,
|
|
4164
|
-
warnings:
|
|
4301
|
+
warnings: F(S())
|
|
4165
4302
|
}).strict(), iu = T({
|
|
4166
|
-
vaultId:
|
|
4303
|
+
vaultId: de,
|
|
4167
4304
|
poolId: yt,
|
|
4168
4305
|
marketId: S().nullable(),
|
|
4169
4306
|
marketName: S().nullable(),
|
|
4170
4307
|
createdAt: Ce.nullable(),
|
|
4171
4308
|
burnedAt: Ce.nullable(),
|
|
4172
|
-
actions:
|
|
4309
|
+
actions: F(Jd)
|
|
4173
4310
|
}).strict().superRefine((e, t) => {
|
|
4174
4311
|
ri(e.actions, t);
|
|
4175
4312
|
}), su = T({
|
|
4176
4313
|
poolId: yt,
|
|
4177
4314
|
marketId: S().nullable(),
|
|
4178
4315
|
marketName: S().nullable(),
|
|
4179
|
-
actions:
|
|
4316
|
+
actions: F(ou)
|
|
4180
4317
|
}).strict().superRefine((e, t) => {
|
|
4181
4318
|
ri(e.actions, t);
|
|
4182
4319
|
}), cu = T({
|
|
4183
4320
|
schemaVersion: B("1"),
|
|
4184
4321
|
chainId: ze,
|
|
4185
|
-
account:
|
|
4186
|
-
marketState:
|
|
4187
|
-
vaults:
|
|
4188
|
-
lend:
|
|
4322
|
+
account: K,
|
|
4323
|
+
marketState: F(ru),
|
|
4324
|
+
vaults: F(iu),
|
|
4325
|
+
lend: F(su),
|
|
4189
4326
|
totals: T({
|
|
4190
|
-
vaultCount:
|
|
4191
|
-
lendMarketCount:
|
|
4192
|
-
vaultActionCount:
|
|
4193
|
-
lendActionCount:
|
|
4327
|
+
vaultCount: b().int().nonnegative(),
|
|
4328
|
+
lendMarketCount: b().int().nonnegative(),
|
|
4329
|
+
vaultActionCount: b().int().nonnegative(),
|
|
4330
|
+
lendActionCount: b().int().nonnegative()
|
|
4194
4331
|
}).strict(),
|
|
4195
4332
|
freshness: T({
|
|
4196
4333
|
source: B("subgraph"),
|
|
4197
|
-
blockNumber:
|
|
4334
|
+
blockNumber: b().int().nonnegative().nullable()
|
|
4198
4335
|
}).strict()
|
|
4199
4336
|
}).strict().superRefine((e, t) => {
|
|
4200
4337
|
const n = e.vaults.reduce(
|
|
@@ -4245,7 +4382,7 @@ const ru = T({
|
|
|
4245
4382
|
message: "Engine activity is missing the referenced market state."
|
|
4246
4383
|
});
|
|
4247
4384
|
}), lu = 10n ** 18n;
|
|
4248
|
-
function
|
|
4385
|
+
function Ft(e) {
|
|
4249
4386
|
if (!e) return null;
|
|
4250
4387
|
try {
|
|
4251
4388
|
return BigInt(e);
|
|
@@ -4262,7 +4399,7 @@ function uu(e) {
|
|
|
4262
4399
|
for (const n of e.actions) {
|
|
4263
4400
|
if (n.kind !== "idle_modified" || !du(n.txHash, t.txHash))
|
|
4264
4401
|
continue;
|
|
4265
|
-
const o =
|
|
4402
|
+
const o = Ft(n.deltaAmount0Raw), a = Ft(n.deltaAmount1Raw);
|
|
4266
4403
|
if (!(o === null || a === null)) {
|
|
4267
4404
|
if (o > 0n && a === 0n) return { raw: o.toString(), side: 0 };
|
|
4268
4405
|
if (a > 0n && o === 0n) return { raw: a.toString(), side: 1 };
|
|
@@ -4274,7 +4411,7 @@ function mu(e) {
|
|
|
4274
4411
|
let t = 0n, n = null;
|
|
4275
4412
|
for (const o of e) {
|
|
4276
4413
|
if (o.kind !== "debt_modified") continue;
|
|
4277
|
-
const a =
|
|
4414
|
+
const a = Ft(o.principalDeltaActualRaw), r = Ft(o.borrowIndexWad);
|
|
4278
4415
|
if (a === null || r === null || r === 0n) return null;
|
|
4279
4416
|
t += a, n = r;
|
|
4280
4417
|
}
|
|
@@ -4284,7 +4421,7 @@ function ka(e, t) {
|
|
|
4284
4421
|
return e * t / lu;
|
|
4285
4422
|
}
|
|
4286
4423
|
function pu(e, t) {
|
|
4287
|
-
const n = mu(e.actions), o =
|
|
4424
|
+
const n = mu(e.actions), o = Ft((t == null ? void 0 : t.borrowIndexWad) ?? null), a = n ? ka(n.principal, n.openIndex) : null, r = n && o !== null ? ka(n.principal, o) : null, i = a === null || r === null ? null : r > a ? r - a : 0n;
|
|
4288
4425
|
return {
|
|
4289
4426
|
deposited: uu(e),
|
|
4290
4427
|
principalRaw: n ? n.principal.toString() : null,
|
|
@@ -4318,7 +4455,7 @@ function $t(e, t) {
|
|
|
4318
4455
|
function hu(e, t) {
|
|
4319
4456
|
return k(e.currency0, t.currency0) && k(e.currency1, t.currency1) && e.fee === t.fee && e.tickSpacing === t.tickSpacing && k(e.hooks, t.hooks);
|
|
4320
4457
|
}
|
|
4321
|
-
function
|
|
4458
|
+
function qe(e, t, n) {
|
|
4322
4459
|
if (!t || !k(t, n))
|
|
4323
4460
|
throw new Error(`${e} does not match the trusted Engine deployment.`);
|
|
4324
4461
|
}
|
|
@@ -4335,10 +4472,10 @@ function It(e) {
|
|
|
4335
4472
|
}
|
|
4336
4473
|
function Po(e, t = {}) {
|
|
4337
4474
|
It(e);
|
|
4338
|
-
const n =
|
|
4475
|
+
const n = ue(e.chainId);
|
|
4339
4476
|
if (!n)
|
|
4340
4477
|
throw new Error(`No trusted Aegis Engine deployment is configured for chain ${e.chainId}.`);
|
|
4341
|
-
return
|
|
4478
|
+
return qe("Engine", e.engine, n.aegisEngine), qe("StateView", e.stateView, n.aegisStateView), qe("V4 StateView", e.v4StateView, n.stateView), t.quoter !== !1 && qe("V4 quoter", e.v4Quoter, n.uniswapV4Quoter), qe("router", e.router, n.aegisRouterV1), t.permit2 !== !1 && qe("Permit2", e.permit2, n.permit2), qe("Pool hooks", e.poolKey.hooks, n.aegisHook), t.vaultRegistry !== !1 && qe("VaultRegistry", e.vaultRegistry, n.vaultRegistry), n;
|
|
4342
4479
|
}
|
|
4343
4480
|
function ii(e) {
|
|
4344
4481
|
if (It(e.market), e.chainId !== e.market.chainId || !Z(e.poolId, e.market.poolId))
|
|
@@ -4348,18 +4485,18 @@ function ii(e) {
|
|
|
4348
4485
|
if (e.decimals0 !== void 0 && e.decimals0 !== e.market.token0.decimals || e.decimals1 !== void 0 && e.decimals1 !== e.market.token1.decimals)
|
|
4349
4486
|
throw new Error("Engine token decimals do not match the on-chain market context.");
|
|
4350
4487
|
}
|
|
4351
|
-
const je =
|
|
4488
|
+
const je = K.nullable().optional().transform((e) => e ?? void 0).catch(void 0), Qe = K.optional();
|
|
4352
4489
|
function Bo(e) {
|
|
4353
4490
|
function t(n) {
|
|
4354
4491
|
const o = n.nullable().optional();
|
|
4355
4492
|
return e ? o : o.catch(void 0);
|
|
4356
4493
|
}
|
|
4357
4494
|
return {
|
|
4358
|
-
number: t(
|
|
4359
|
-
nonnegativeInteger: t(
|
|
4495
|
+
number: t(b().finite()),
|
|
4496
|
+
nonnegativeInteger: t(b().int().nonnegative()),
|
|
4360
4497
|
boolean: t(Ve()),
|
|
4361
4498
|
string: t(S()),
|
|
4362
|
-
decimalString: t(
|
|
4499
|
+
decimalString: t(de),
|
|
4363
4500
|
dateTime: t(Ce)
|
|
4364
4501
|
};
|
|
4365
4502
|
}
|
|
@@ -4401,10 +4538,10 @@ function si(e) {
|
|
|
4401
4538
|
});
|
|
4402
4539
|
return e.strict ? { metrics: o.strict(), freshness: a.strict() } : { metrics: o, freshness: a };
|
|
4403
4540
|
}
|
|
4404
|
-
const on = Bo(!1),
|
|
4405
|
-
adaptiveTickThresholdTicks:
|
|
4541
|
+
const on = Bo(!1), qt = Bo(!0), ci = si({ strict: !1, metricsComputedAt: !0 }), Xn = si({ strict: !0, metricsComputedAt: !1 }), li = Xn.metrics.extend({
|
|
4542
|
+
adaptiveTickThresholdTicks: b().int().min(0).max(16777215).optional(),
|
|
4406
4543
|
adaptiveTickThresholdMode: ei.optional(),
|
|
4407
|
-
feeObservedAt:
|
|
4544
|
+
feeObservedAt: qt.dateTime
|
|
4408
4545
|
}).strict().superRefine((e, t) => {
|
|
4409
4546
|
const n = e.adaptiveTickThresholdTicks !== void 0, o = e.adaptiveTickThresholdMode !== void 0;
|
|
4410
4547
|
n !== o && t.addIssue({
|
|
@@ -4412,33 +4549,33 @@ const on = Bo(!1), Ot = Bo(!0), ci = si({ strict: !1, metricsComputedAt: !0 }),
|
|
|
4412
4549
|
message: "adaptiveTickThresholdTicks and adaptiveTickThresholdMode must be provided together."
|
|
4413
4550
|
});
|
|
4414
4551
|
}), Yn = T({
|
|
4415
|
-
chainId:
|
|
4416
|
-
address:
|
|
4552
|
+
chainId: b().int().positive(),
|
|
4553
|
+
address: K,
|
|
4417
4554
|
name: S(),
|
|
4418
4555
|
symbol: S(),
|
|
4419
|
-
decimals:
|
|
4556
|
+
decimals: b().int().min(0).max(255),
|
|
4420
4557
|
iconUrl: S().nullable().optional(),
|
|
4421
4558
|
priceUsd: on.number.transform((e) => e ?? void 0),
|
|
4422
4559
|
stable: on.boolean.transform((e) => e ?? void 0)
|
|
4423
4560
|
}), va = Yn.extend({
|
|
4424
|
-
priceUsd:
|
|
4425
|
-
stable:
|
|
4561
|
+
priceUsd: qt.number.transform((e) => e ?? void 0),
|
|
4562
|
+
stable: qt.boolean.transform((e) => e ?? void 0)
|
|
4426
4563
|
}).strict(), di = T({
|
|
4427
4564
|
id: S().min(1),
|
|
4428
|
-
chainId:
|
|
4429
|
-
source:
|
|
4430
|
-
status:
|
|
4565
|
+
chainId: b().int().positive(),
|
|
4566
|
+
source: H(["rest", "static"]).optional(),
|
|
4567
|
+
status: H(["enabled", "disabled", "hidden", "malformed"]).catch("malformed"),
|
|
4431
4568
|
displayName: S().min(1),
|
|
4432
|
-
labels:
|
|
4569
|
+
labels: F(S()).optional(),
|
|
4433
4570
|
poolId: yt,
|
|
4434
4571
|
token0: Yn,
|
|
4435
4572
|
token1: Yn,
|
|
4436
4573
|
poolKey: T({
|
|
4437
|
-
currency0:
|
|
4438
|
-
currency1:
|
|
4439
|
-
fee:
|
|
4440
|
-
tickSpacing:
|
|
4441
|
-
hooks:
|
|
4574
|
+
currency0: K,
|
|
4575
|
+
currency1: K,
|
|
4576
|
+
fee: b().int().min(0).max(16777215),
|
|
4577
|
+
tickSpacing: b().int().min(1).max(8388607),
|
|
4578
|
+
hooks: K
|
|
4442
4579
|
}),
|
|
4443
4580
|
engine: je,
|
|
4444
4581
|
stateView: je,
|
|
@@ -4451,18 +4588,18 @@ const on = Bo(!1), Ot = Bo(!0), ci = si({ strict: !1, metricsComputedAt: !0 }),
|
|
|
4451
4588
|
lendEnabled: Ve().catch(!1),
|
|
4452
4589
|
canBorrow: on.boolean,
|
|
4453
4590
|
canLend: on.boolean,
|
|
4454
|
-
maxLtvPips:
|
|
4455
|
-
hardLtvPips:
|
|
4456
|
-
warnings:
|
|
4591
|
+
maxLtvPips: b().int().min(0).max(1e6).nullable().optional().catch(void 0),
|
|
4592
|
+
hardLtvPips: b().int().min(0).max(1e6).nullable().optional().catch(void 0),
|
|
4593
|
+
warnings: F(S()).nullable().optional().transform((e) => e ?? []).catch([]),
|
|
4457
4594
|
disabledReasons: T({
|
|
4458
|
-
borrow:
|
|
4459
|
-
lend:
|
|
4595
|
+
borrow: F(S()).catch([]),
|
|
4596
|
+
lend: F(S()).catch([])
|
|
4460
4597
|
}).optional().catch(void 0),
|
|
4461
4598
|
metrics: tn().optional(),
|
|
4462
4599
|
freshness: tn().optional()
|
|
4463
4600
|
}), ui = di.extend({
|
|
4464
4601
|
source: B("rest"),
|
|
4465
|
-
status:
|
|
4602
|
+
status: H(["enabled", "disabled"]),
|
|
4466
4603
|
token0: va,
|
|
4467
4604
|
token1: va,
|
|
4468
4605
|
engine: Qe,
|
|
@@ -4474,21 +4611,21 @@ const on = Bo(!1), Ot = Bo(!0), ci = si({ strict: !1, metricsComputedAt: !0 }),
|
|
|
4474
4611
|
vaultRegistry: Qe,
|
|
4475
4612
|
borrowEnabled: Ve(),
|
|
4476
4613
|
lendEnabled: Ve(),
|
|
4477
|
-
canBorrow:
|
|
4478
|
-
canLend:
|
|
4479
|
-
maxLtvPips:
|
|
4480
|
-
hardLtvPips:
|
|
4481
|
-
warnings:
|
|
4614
|
+
canBorrow: qt.boolean,
|
|
4615
|
+
canLend: qt.boolean,
|
|
4616
|
+
maxLtvPips: b().int().min(0).max(1e6).nullable().optional(),
|
|
4617
|
+
hardLtvPips: b().int().min(0).max(1e6).nullable().optional(),
|
|
4618
|
+
warnings: F(S()),
|
|
4482
4619
|
disabledReasons: T({
|
|
4483
|
-
borrow:
|
|
4484
|
-
lend:
|
|
4620
|
+
borrow: F(S()),
|
|
4621
|
+
lend: F(S())
|
|
4485
4622
|
}).strict(),
|
|
4486
4623
|
metrics: Xn.metrics,
|
|
4487
4624
|
freshness: Xn.freshness
|
|
4488
|
-
}).strict(),
|
|
4625
|
+
}).strict(), bu = ui.extend({
|
|
4489
4626
|
metrics: li
|
|
4490
4627
|
}).strict();
|
|
4491
|
-
function
|
|
4628
|
+
function wu(e, t) {
|
|
4492
4629
|
const n = (t === "2" ? li : ci.metrics).safeParse(e);
|
|
4493
4630
|
if (!n.success) return;
|
|
4494
4631
|
const o = Object.fromEntries(
|
|
@@ -4504,9 +4641,9 @@ function ku(e) {
|
|
|
4504
4641
|
);
|
|
4505
4642
|
}
|
|
4506
4643
|
function vu(e, t, n = "1") {
|
|
4507
|
-
const a = (t === "rest" ? n === "2" ?
|
|
4644
|
+
const a = (t === "rest" ? n === "2" ? bu : ui : di).safeParse(e);
|
|
4508
4645
|
if (!a.success) return null;
|
|
4509
|
-
const { metrics: r, freshness: i, source: s, ...l } = a.data, c =
|
|
4646
|
+
const { metrics: r, freshness: i, source: s, ...l } = a.data, c = wu(
|
|
4510
4647
|
r,
|
|
4511
4648
|
t === "rest" ? n : void 0
|
|
4512
4649
|
), p = ku(i);
|
|
@@ -4518,7 +4655,7 @@ function vu(e, t, n = "1") {
|
|
|
4518
4655
|
};
|
|
4519
4656
|
}
|
|
4520
4657
|
function Eu(e) {
|
|
4521
|
-
const t =
|
|
4658
|
+
const t = ue(e.chainId);
|
|
4522
4659
|
if (!t)
|
|
4523
4660
|
return `Engine execution disabled: no trusted contract registry for chain ${e.chainId}.`;
|
|
4524
4661
|
const o = [
|
|
@@ -4590,7 +4727,7 @@ function Rn(e) {
|
|
|
4590
4727
|
return gu(t);
|
|
4591
4728
|
}
|
|
4592
4729
|
let Ea = null;
|
|
4593
|
-
function
|
|
4730
|
+
function z() {
|
|
4594
4731
|
return Ea ?? (Ea = import("./sdkRuntime-CIhmlpGl.js").then(({ engineSdkRuntime: e }) => e)), Ea;
|
|
4595
4732
|
}
|
|
4596
4733
|
const Pn = 2500;
|
|
@@ -4608,7 +4745,7 @@ function Su(e) {
|
|
|
4608
4745
|
}
|
|
4609
4746
|
function Mo(e) {
|
|
4610
4747
|
It(e.market);
|
|
4611
|
-
const { stateView: t, v4StateView: n } = Su(e), o =
|
|
4748
|
+
const { stateView: t, v4StateView: n } = Su(e), o = ue(e.market.chainId);
|
|
4612
4749
|
if (!o)
|
|
4613
4750
|
throw new fe(
|
|
4614
4751
|
`No trusted Aegis Engine deployment is configured for chain ${e.market.chainId}.`
|
|
@@ -4639,7 +4776,7 @@ const Cu = [{
|
|
|
4639
4776
|
}];
|
|
4640
4777
|
async function Do(e) {
|
|
4641
4778
|
if (e.market.source !== "rest") return;
|
|
4642
|
-
const t = [e.market.token0, e.market.token1].some((l) => k(l.address,
|
|
4779
|
+
const t = [e.market.token0, e.market.token1].some((l) => k(l.address, ce)), n = e.publicClient.chain;
|
|
4643
4780
|
if (t && (n == null ? void 0 : n.id) !== e.market.chainId)
|
|
4644
4781
|
throw new fe("Native token chain does not match the market.");
|
|
4645
4782
|
const o = t ? n == null ? void 0 : n.nativeCurrency.decimals : void 0, a = fn(e.publicClient).tokenDecimals, r = hn(e, [
|
|
@@ -4648,7 +4785,7 @@ async function Do(e) {
|
|
|
4648
4785
|
String(o ?? "")
|
|
4649
4786
|
]), [i, s] = await a.read(r, async () => {
|
|
4650
4787
|
const l = async (c) => {
|
|
4651
|
-
const p = k(c,
|
|
4788
|
+
const p = k(c, ce) ? o : await e.publicClient.readContract({
|
|
4652
4789
|
address: c,
|
|
4653
4790
|
abi: Cu,
|
|
4654
4791
|
functionName: "decimals"
|
|
@@ -4671,7 +4808,7 @@ function hn(e, t) {
|
|
|
4671
4808
|
...t.map((n) => n.toLowerCase())
|
|
4672
4809
|
].join(":");
|
|
4673
4810
|
}
|
|
4674
|
-
function
|
|
4811
|
+
function k0() {
|
|
4675
4812
|
Jn = /* @__PURE__ */ new WeakMap();
|
|
4676
4813
|
}
|
|
4677
4814
|
async function xu(e) {
|
|
@@ -4684,7 +4821,7 @@ async function xu(e) {
|
|
|
4684
4821
|
fetchMarketLtvThresholds: i,
|
|
4685
4822
|
fetchMarketSharePriceLatest: s,
|
|
4686
4823
|
fetchPoolState: l
|
|
4687
|
-
} = await
|
|
4824
|
+
} = await z(), [c, p, d, m] = await Promise.all([
|
|
4688
4825
|
r(e.publicClient, t, e.market.poolId),
|
|
4689
4826
|
i(e.publicClient, t, e.market.poolId),
|
|
4690
4827
|
l(e.publicClient, n, e.market.poolId),
|
|
@@ -4695,8 +4832,8 @@ async function xu(e) {
|
|
|
4695
4832
|
return { market: c, thresholds: p, poolState: d, sharePriceWadLatest: m };
|
|
4696
4833
|
});
|
|
4697
4834
|
}
|
|
4698
|
-
async function
|
|
4699
|
-
const t = await xu(e), { priceFromSqrtX96: n } = await
|
|
4835
|
+
async function v0(e) {
|
|
4836
|
+
const t = await xu(e), { priceFromSqrtX96: n } = await z(), o = n(
|
|
4700
4837
|
t.poolState.sqrtPriceX96,
|
|
4701
4838
|
e.market.token0.decimals,
|
|
4702
4839
|
e.market.token1.decimals
|
|
@@ -4723,7 +4860,7 @@ async function Tu(e) {
|
|
|
4723
4860
|
);
|
|
4724
4861
|
const a = fn(e.publicClient).lendContexts, r = hn(e, [t, n, o]);
|
|
4725
4862
|
return a.read(r, async () => {
|
|
4726
|
-
const { fetchLendQuoteContext: i } = await
|
|
4863
|
+
const { fetchLendQuoteContext: i } = await z(), s = await i(e.publicClient, {
|
|
4727
4864
|
chainId: e.market.chainId,
|
|
4728
4865
|
version: o,
|
|
4729
4866
|
poolId: e.market.poolId
|
|
@@ -4754,7 +4891,7 @@ async function _o(e, t, n = {}) {
|
|
|
4754
4891
|
((c = t == null ? void 0 : t.vaultId) == null ? void 0 : c.toString()) ?? ""
|
|
4755
4892
|
]);
|
|
4756
4893
|
return s.read(l, async () => {
|
|
4757
|
-
const { fetchBorrowQuoteContext: p } = await
|
|
4894
|
+
const { fetchBorrowQuoteContext: p } = await z(), d = await p(e.publicClient, {
|
|
4758
4895
|
chainId: e.market.chainId,
|
|
4759
4896
|
version: i,
|
|
4760
4897
|
poolId: e.market.poolId,
|
|
@@ -4916,8 +5053,8 @@ async function Mu(e) {
|
|
|
4916
5053
|
});
|
|
4917
5054
|
return { ...e.result, vaults: a, shares: r };
|
|
4918
5055
|
}
|
|
4919
|
-
async function
|
|
4920
|
-
var h, f,
|
|
5056
|
+
async function E0(e) {
|
|
5057
|
+
var h, f, w, y;
|
|
4921
5058
|
Ru(e);
|
|
4922
5059
|
const t = vt(e.chainId);
|
|
4923
5060
|
if (!t)
|
|
@@ -4927,7 +5064,7 @@ async function yf(e) {
|
|
|
4927
5064
|
const n = e.positions.map((E) => BigInt(E.vaultId)), o = e.lendPositions.map((E) => ({
|
|
4928
5065
|
account: e.expectedAccount,
|
|
4929
5066
|
poolId: E.poolId
|
|
4930
|
-
})), { fetchPositionsBatch: a, fetchMarket: r, fetchPoolState: i, getAmountsForFullRangeLiquidity: s } = await
|
|
5067
|
+
})), { fetchPositionsBatch: a, fetchMarket: r, fetchPoolState: i, getAmountsForFullRangeLiquidity: s } = await z(), l = {
|
|
4931
5068
|
chainId: e.chainId,
|
|
4932
5069
|
version: t,
|
|
4933
5070
|
vaultIds: n,
|
|
@@ -4953,7 +5090,7 @@ async function yf(e) {
|
|
|
4953
5090
|
result: c,
|
|
4954
5091
|
...e.signal !== void 0 ? { signal: e.signal } : {}
|
|
4955
5092
|
});
|
|
4956
|
-
const p =
|
|
5093
|
+
const p = ue(e.chainId), d = /* @__PURE__ */ new Map(), m = [...new Set(c.vaults.flatMap(
|
|
4957
5094
|
(E) => E.status === "ok" && E.vault.debtLLatest > 0n ? [E.vault.poolId] : []
|
|
4958
5095
|
))];
|
|
4959
5096
|
if (p)
|
|
@@ -4972,7 +5109,7 @@ async function yf(e) {
|
|
|
4972
5109
|
}
|
|
4973
5110
|
if (d.size)
|
|
4974
5111
|
try {
|
|
4975
|
-
((
|
|
5112
|
+
((w = (await e.publicClient.getBlock({ blockNumber: c.frame.blockNumber })).hash) == null ? void 0 : w.toLowerCase()) !== c.frame.blockHash.toLowerCase() && d.clear();
|
|
4976
5113
|
} catch {
|
|
4977
5114
|
d.clear();
|
|
4978
5115
|
}
|
|
@@ -5037,10 +5174,10 @@ function mi(e) {
|
|
|
5037
5174
|
receivedIsToken0: o ? o.deltaAmount0 < 0n : null
|
|
5038
5175
|
};
|
|
5039
5176
|
}
|
|
5040
|
-
async function
|
|
5177
|
+
async function y0(e) {
|
|
5041
5178
|
const t = vt(e.market.chainId);
|
|
5042
5179
|
if (!t) return null;
|
|
5043
|
-
const { createSubgraphClient: n, fetchVaultDebtActions: o, fetchVaultIdleActions: a } = await
|
|
5180
|
+
const { createSubgraphClient: n, fetchVaultDebtActions: o, fetchVaultIdleActions: a } = await z(), r = n(
|
|
5044
5181
|
e.market.chainId,
|
|
5045
5182
|
t
|
|
5046
5183
|
), i = e.vaultId.toString(), [s, l] = await Promise.all([
|
|
@@ -5059,25 +5196,25 @@ async function If(e) {
|
|
|
5059
5196
|
}))
|
|
5060
5197
|
});
|
|
5061
5198
|
}
|
|
5062
|
-
const pi = 1e4,
|
|
5199
|
+
const pi = 1e4, Ot = "Engine market request aborted.", Du = "Engine position activity request aborted.", Ia = 2 * 1024 * 1024, Aa = 1024 * 1024, ga = 4 * 1024 * 1024, _u = 8 * 1024 * 1024, fi = ge({
|
|
5063
5200
|
ttlMs: 6e4,
|
|
5064
5201
|
maxEntries: 32
|
|
5065
5202
|
}), hi = ge({
|
|
5066
5203
|
ttlMs: 15 * 6e4,
|
|
5067
5204
|
maxEntries: 128
|
|
5068
|
-
}),
|
|
5205
|
+
}), bi = ge({
|
|
5069
5206
|
ttlMs: 15e3,
|
|
5070
5207
|
maxEntries: 64
|
|
5071
|
-
}),
|
|
5208
|
+
}), wi = ge({
|
|
5072
5209
|
ttlMs: 15e3,
|
|
5073
5210
|
maxEntries: 64
|
|
5074
|
-
}), Nu = 60 * 6e4,
|
|
5075
|
-
function
|
|
5211
|
+
}), Nu = 60 * 6e4, Fu = 60 * 6e4, qu = 60 * 6e4, No = /* @__PURE__ */ new Map(), Zn = /* @__PURE__ */ new Map(), eo = /* @__PURE__ */ new Map();
|
|
5212
|
+
function Fo(e, t) {
|
|
5076
5213
|
const n = e.get(t);
|
|
5077
5214
|
return n === void 0 ? !1 : n <= Date.now() ? (e.delete(t), !1) : !0;
|
|
5078
5215
|
}
|
|
5079
|
-
function
|
|
5080
|
-
return
|
|
5216
|
+
function Ou(e) {
|
|
5217
|
+
return Fo(No, e);
|
|
5081
5218
|
}
|
|
5082
5219
|
function At(e) {
|
|
5083
5220
|
return e.kind === "static" ? [e.kind, e.markets.map((t) => t.id).join(",")].join("|") : [
|
|
@@ -5097,7 +5234,7 @@ function Lu(e) {
|
|
|
5097
5234
|
throw new RangeError("Engine REST timeoutMs must be a positive finite number.");
|
|
5098
5235
|
return t;
|
|
5099
5236
|
}
|
|
5100
|
-
async function
|
|
5237
|
+
async function bn(e) {
|
|
5101
5238
|
const t = Lu(e.source), { signal: n, cleanup: o } = it({
|
|
5102
5239
|
timeoutMs: t,
|
|
5103
5240
|
timeoutMessage: `Engine REST ${e.resource} request timed out after ${t}ms.`
|
|
@@ -5138,11 +5275,11 @@ async function Sa(e) {
|
|
|
5138
5275
|
defaultV4Quoter: e.defaultV4Quoter
|
|
5139
5276
|
});
|
|
5140
5277
|
const t = e.source, n = Wt(t), o = At(t), a = `chainId=${e.chainId}${t.includeLabels ? "&includeLabels=true" : ""}`;
|
|
5141
|
-
return
|
|
5278
|
+
return bn({
|
|
5142
5279
|
source: t,
|
|
5143
5280
|
resource: "markets",
|
|
5144
5281
|
request: async (r) => {
|
|
5145
|
-
if (!
|
|
5282
|
+
if (!Fo(Zn, o)) {
|
|
5146
5283
|
const l = await fetch(
|
|
5147
5284
|
`${n}/v1/engine/markets/v2?${a}`,
|
|
5148
5285
|
{ headers: t.headers, signal: r }
|
|
@@ -5166,7 +5303,7 @@ async function Sa(e) {
|
|
|
5166
5303
|
if (l.status !== 404) throw at(l);
|
|
5167
5304
|
Zn.set(
|
|
5168
5305
|
o,
|
|
5169
|
-
Date.now() +
|
|
5306
|
+
Date.now() + Fu
|
|
5170
5307
|
);
|
|
5171
5308
|
}
|
|
5172
5309
|
const i = await fetch(`${n}/v1/engine/markets?${a}`, {
|
|
@@ -5191,49 +5328,49 @@ async function Sa(e) {
|
|
|
5191
5328
|
}
|
|
5192
5329
|
});
|
|
5193
5330
|
}
|
|
5194
|
-
function
|
|
5331
|
+
function I0() {
|
|
5195
5332
|
fi.clear();
|
|
5196
5333
|
}
|
|
5197
|
-
function
|
|
5334
|
+
function A0() {
|
|
5198
5335
|
hi.clear();
|
|
5199
5336
|
}
|
|
5200
|
-
function
|
|
5201
|
-
wi.clear();
|
|
5202
|
-
}
|
|
5203
|
-
function Cf() {
|
|
5337
|
+
function g0() {
|
|
5204
5338
|
bi.clear();
|
|
5205
5339
|
}
|
|
5206
|
-
function
|
|
5340
|
+
function S0() {
|
|
5341
|
+
wi.clear();
|
|
5342
|
+
}
|
|
5343
|
+
function C0() {
|
|
5207
5344
|
No.clear();
|
|
5208
5345
|
}
|
|
5209
|
-
function
|
|
5346
|
+
function x0() {
|
|
5210
5347
|
Zn.clear();
|
|
5211
5348
|
}
|
|
5212
|
-
function
|
|
5349
|
+
function T0() {
|
|
5213
5350
|
eo.clear();
|
|
5214
5351
|
}
|
|
5215
|
-
async function
|
|
5352
|
+
async function R0(e) {
|
|
5216
5353
|
if (e.source.kind === "static")
|
|
5217
|
-
return Ue(Sa(e), e.signal,
|
|
5354
|
+
return Ue(Sa(e), e.signal, Ot);
|
|
5218
5355
|
const t = fi.read(
|
|
5219
5356
|
Uu(e),
|
|
5220
5357
|
() => Sa(e)
|
|
5221
5358
|
);
|
|
5222
|
-
return Ue(t, e.signal,
|
|
5359
|
+
return Ue(t, e.signal, Ot);
|
|
5223
5360
|
}
|
|
5224
5361
|
function Hu(e) {
|
|
5225
5362
|
const { source: t, marketId: n, window: o } = e, a = Wt(t), r = At(t);
|
|
5226
|
-
return
|
|
5363
|
+
return bn({
|
|
5227
5364
|
source: t,
|
|
5228
5365
|
resource: "history",
|
|
5229
5366
|
request: async (i) => {
|
|
5230
|
-
if (!
|
|
5367
|
+
if (!Fo(eo, r)) {
|
|
5231
5368
|
const c = await fetch(
|
|
5232
5369
|
`${a}/v1/engine/markets/${encodeURIComponent(n)}/history/v2?window=${o}`,
|
|
5233
5370
|
{ headers: t.headers, signal: i }
|
|
5234
5371
|
);
|
|
5235
5372
|
if (c.ok) {
|
|
5236
|
-
const p =
|
|
5373
|
+
const p = qd.parse(
|
|
5237
5374
|
await He(c, Aa, "Engine history")
|
|
5238
5375
|
);
|
|
5239
5376
|
if (p.marketId !== n)
|
|
@@ -5250,7 +5387,7 @@ function Hu(e) {
|
|
|
5250
5387
|
if (c.status !== 404) throw at(c);
|
|
5251
5388
|
eo.set(
|
|
5252
5389
|
r,
|
|
5253
|
-
Date.now() +
|
|
5390
|
+
Date.now() + qu
|
|
5254
5391
|
);
|
|
5255
5392
|
}
|
|
5256
5393
|
const s = await fetch(
|
|
@@ -5258,7 +5395,7 @@ function Hu(e) {
|
|
|
5258
5395
|
{ headers: t.headers, signal: i }
|
|
5259
5396
|
);
|
|
5260
5397
|
if (!s.ok) throw at(s);
|
|
5261
|
-
const l =
|
|
5398
|
+
const l = Fd.parse(
|
|
5262
5399
|
await He(s, Aa, "Engine history")
|
|
5263
5400
|
);
|
|
5264
5401
|
if (l.marketId !== n)
|
|
@@ -5273,13 +5410,13 @@ function Hu(e) {
|
|
|
5273
5410
|
}
|
|
5274
5411
|
});
|
|
5275
5412
|
}
|
|
5276
|
-
async function
|
|
5413
|
+
async function P0(e) {
|
|
5277
5414
|
if (e.source.kind === "static") return null;
|
|
5278
5415
|
const t = e.source, n = Ro.parse(e.marketId), o = e.window ?? "30d", a = hi.read(
|
|
5279
5416
|
Vu({ source: t, marketId: n, window: o }),
|
|
5280
5417
|
() => Hu({ source: t, marketId: n, window: o })
|
|
5281
5418
|
);
|
|
5282
|
-
return Ue(a, e.signal,
|
|
5419
|
+
return Ue(a, e.signal, Ot);
|
|
5283
5420
|
}
|
|
5284
5421
|
function Ca(e, t, n) {
|
|
5285
5422
|
if (n.chainId !== e)
|
|
@@ -5333,13 +5470,13 @@ async function xa(e) {
|
|
|
5333
5470
|
chainId: String(e.chainId),
|
|
5334
5471
|
account: e.account
|
|
5335
5472
|
});
|
|
5336
|
-
return
|
|
5473
|
+
return bn({
|
|
5337
5474
|
source: t,
|
|
5338
5475
|
resource: "positions",
|
|
5339
5476
|
// Position loads are shared in the session cache. One consumer aborting
|
|
5340
5477
|
// must not cancel an in-flight request another mounted widget still uses.
|
|
5341
5478
|
request: async (r) => {
|
|
5342
|
-
if (!
|
|
5479
|
+
if (!Ou(o)) {
|
|
5343
5480
|
const l = await fetch(`${n}/v1/engine/positions/v2?${a}`, {
|
|
5344
5481
|
headers: t.headers,
|
|
5345
5482
|
signal: r
|
|
@@ -5393,15 +5530,15 @@ async function xa(e) {
|
|
|
5393
5530
|
}
|
|
5394
5531
|
});
|
|
5395
5532
|
}
|
|
5396
|
-
async function
|
|
5533
|
+
async function B0(e) {
|
|
5397
5534
|
if (e.source.kind === "static")
|
|
5398
|
-
return Ue(xa(e), e.signal,
|
|
5399
|
-
const t =
|
|
5535
|
+
return Ue(xa(e), e.signal, Ot);
|
|
5536
|
+
const t = bi.read(
|
|
5400
5537
|
ki(e),
|
|
5401
5538
|
() => xa(e),
|
|
5402
5539
|
e.force
|
|
5403
5540
|
);
|
|
5404
|
-
return Ue(t, e.signal,
|
|
5541
|
+
return Ue(t, e.signal, Ot);
|
|
5405
5542
|
}
|
|
5406
5543
|
function $u(e, t, n) {
|
|
5407
5544
|
if (n.chainId !== e)
|
|
@@ -5423,7 +5560,7 @@ async function Wu(e) {
|
|
|
5423
5560
|
chainId: String(e.chainId),
|
|
5424
5561
|
account: e.account
|
|
5425
5562
|
});
|
|
5426
|
-
return
|
|
5563
|
+
return bn({
|
|
5427
5564
|
source: e.source,
|
|
5428
5565
|
resource: "position activity",
|
|
5429
5566
|
// The request is shared through the short wallet cache. Keep consumer
|
|
@@ -5466,7 +5603,7 @@ async function vi(e) {
|
|
|
5466
5603
|
freshness: { source: "static", blockNumber: null }
|
|
5467
5604
|
} : null;
|
|
5468
5605
|
}
|
|
5469
|
-
const t = e.source, n =
|
|
5606
|
+
const t = e.source, n = wi.read(
|
|
5470
5607
|
ki(e),
|
|
5471
5608
|
() => Wu({
|
|
5472
5609
|
source: t,
|
|
@@ -5483,7 +5620,7 @@ function Ku(e) {
|
|
|
5483
5620
|
throw new TypeError("Engine vaultId must be an unsigned decimal integer.");
|
|
5484
5621
|
return BigInt(t).toString();
|
|
5485
5622
|
}
|
|
5486
|
-
async function
|
|
5623
|
+
async function M0(e) {
|
|
5487
5624
|
const t = Ku(e.vaultId), n = await vi(e);
|
|
5488
5625
|
if (!n) return null;
|
|
5489
5626
|
const o = n.vaults.find(
|
|
@@ -5507,7 +5644,7 @@ async function Df(e) {
|
|
|
5507
5644
|
}))
|
|
5508
5645
|
});
|
|
5509
5646
|
}
|
|
5510
|
-
async function
|
|
5647
|
+
async function D0(e) {
|
|
5511
5648
|
const t = await vi(e);
|
|
5512
5649
|
if (!t) return null;
|
|
5513
5650
|
const n = e.poolId.toLowerCase(), o = t.lend.find((a) => a.poolId.toLowerCase() === n);
|
|
@@ -5630,7 +5767,7 @@ function tm(e, t, n) {
|
|
|
5630
5767
|
}
|
|
5631
5768
|
return n - Math.max(...o) >= Xu;
|
|
5632
5769
|
}
|
|
5633
|
-
function
|
|
5770
|
+
function _0(e) {
|
|
5634
5771
|
const t = e.position !== null, n = e.position ? Zu(e.position, e.market, e.hydration) : null, o = em(t, n, e.additionalValueUsd), a = e.history, r = (a == null ? void 0 : a.status) === "ready" && a.marketId === e.market.id ? Qu(a) : null, i = (r == null ? void 0 : r.weeklyEarningsPer100Usd) ?? null, s = a && r && i !== null ? {
|
|
5635
5772
|
weeklyEarningsPer100Usd: i,
|
|
5636
5773
|
currentWeeklyEarningsUsd: Pa(
|
|
@@ -5674,7 +5811,7 @@ function Mn(e, t) {
|
|
|
5674
5811
|
}
|
|
5675
5812
|
async function am(e) {
|
|
5676
5813
|
if (It(e.market), e.blockNumber < 0n) throw new TypeError("Dynamic fee blockNumber must be non-negative.");
|
|
5677
|
-
const t =
|
|
5814
|
+
const t = ue(e.market.chainId);
|
|
5678
5815
|
if (!t)
|
|
5679
5816
|
throw new Error(
|
|
5680
5817
|
`No trusted Aegis Engine deployment is configured for chain ${e.market.chainId}.`
|
|
@@ -5733,8 +5870,8 @@ function rm({
|
|
|
5733
5870
|
}
|
|
5734
5871
|
const h = m * BigInt(1e4 - Math.max(1, s)) / 10000n;
|
|
5735
5872
|
if (h <= 0n || !d(h)) return 0n;
|
|
5736
|
-
const f = c(h),
|
|
5737
|
-
return
|
|
5873
|
+
const f = c(h), w = o.rL0 + p(f.gammaNewL), y = e.minDebtFloorRl(t.equityLWad, t.borrowIndexWad);
|
|
5874
|
+
return w > 0n && w < y ? 0n : h;
|
|
5738
5875
|
}
|
|
5739
5876
|
const im = [
|
|
5740
5877
|
"constant-rate-estimate",
|
|
@@ -5743,7 +5880,7 @@ const im = [
|
|
|
5743
5880
|
"liquidation-risk-not-modeled",
|
|
5744
5881
|
"repay-quote-not-modeled"
|
|
5745
5882
|
];
|
|
5746
|
-
function
|
|
5883
|
+
function qo(e) {
|
|
5747
5884
|
return e != null && Number.isFinite(e) && e >= 0;
|
|
5748
5885
|
}
|
|
5749
5886
|
function Ba(e) {
|
|
@@ -5754,7 +5891,7 @@ function sm(e) {
|
|
|
5754
5891
|
return e.token0.stable && t !== null ? { side: "token0", priceUsd: t } : e.token1.stable && n !== null ? { side: "token1", priceUsd: n } : t !== null && n === null ? { side: "token0", priceUsd: t } : n !== null && t === null ? { side: "token1", priceUsd: n } : null;
|
|
5755
5892
|
}
|
|
5756
5893
|
function Yt(e) {
|
|
5757
|
-
return
|
|
5894
|
+
return qo(e) ? e : null;
|
|
5758
5895
|
}
|
|
5759
5896
|
function Ma(e, t, n) {
|
|
5760
5897
|
if (!n) return null;
|
|
@@ -5773,10 +5910,10 @@ function Da(e, t, n) {
|
|
|
5773
5910
|
};
|
|
5774
5911
|
}
|
|
5775
5912
|
function cm(e) {
|
|
5776
|
-
return e.feasible ?
|
|
5913
|
+
return e.feasible ? qo(e.display.postBorrowAprPct) ? { aprPct: e.display.postBorrowAprPct, basis: "projected-post-borrow" } : { aprPct: null, basis: null } : { aprPct: null, basis: null };
|
|
5777
5914
|
}
|
|
5778
5915
|
function _a(e) {
|
|
5779
|
-
return e === "INF" ||
|
|
5916
|
+
return e === "INF" || qo(e);
|
|
5780
5917
|
}
|
|
5781
5918
|
function lm(e) {
|
|
5782
5919
|
if (!e.feasible) return { days: null, basis: null };
|
|
@@ -5793,8 +5930,8 @@ function dm({
|
|
|
5793
5930
|
quote: a,
|
|
5794
5931
|
computeVaultStateSnapshot: r
|
|
5795
5932
|
}) {
|
|
5796
|
-
var
|
|
5797
|
-
const i = [], s = sm(e), l = ((
|
|
5933
|
+
var w;
|
|
5934
|
+
const i = [], s = sm(e), l = ((w = a.finalVault) == null ? void 0 : w.gammaTotalLPostRounded) ?? null;
|
|
5798
5935
|
let c = null, p = null;
|
|
5799
5936
|
if (o)
|
|
5800
5937
|
try {
|
|
@@ -5849,7 +5986,7 @@ function dm({
|
|
|
5849
5986
|
async function yi(e) {
|
|
5850
5987
|
var r, i;
|
|
5851
5988
|
(r = e.signal) == null || r.throwIfAborted();
|
|
5852
|
-
const { uniswapV4QuoterAbi: t } = await
|
|
5989
|
+
const { uniswapV4QuoterAbi: t } = await z(), { result: n } = await e.publicClient.simulateContract({
|
|
5853
5990
|
address: e.quoter,
|
|
5854
5991
|
abi: t,
|
|
5855
5992
|
functionName: "quoteExactInputSingle",
|
|
@@ -5910,10 +6047,10 @@ async function um(e) {
|
|
|
5910
6047
|
amountOut: i.toString()
|
|
5911
6048
|
}]], amountOutQuoted: i, amountOutMinimum: s, blockNumber: a.blockNumber };
|
|
5912
6049
|
}
|
|
5913
|
-
function
|
|
6050
|
+
function Oo(e, t) {
|
|
5914
6051
|
return 10 ** ((e + t) / 2);
|
|
5915
6052
|
}
|
|
5916
|
-
function
|
|
6053
|
+
function Fa(e, t) {
|
|
5917
6054
|
return Number(e) / 1e18 / t;
|
|
5918
6055
|
}
|
|
5919
6056
|
function mm(e, t) {
|
|
@@ -5924,11 +6061,11 @@ function mm(e, t) {
|
|
|
5924
6061
|
}
|
|
5925
6062
|
const Dn = 1e6, Lo = 31556736;
|
|
5926
6063
|
async function pm(e) {
|
|
5927
|
-
const { UTILIZATION_CAP_PIPS: t, priceFromSqrtX96: n } = await
|
|
6064
|
+
const { UTILIZATION_CAP_PIPS: t, priceFromSqrtX96: n } = await z(), { market: o, aprProjection: a } = e, r = Oo(o.decimals0, o.decimals1);
|
|
5928
6065
|
return {
|
|
5929
6066
|
Ppool: n(o.sqrtPriceX96, o.decimals0, o.decimals1),
|
|
5930
|
-
SIdle:
|
|
5931
|
-
BM:
|
|
6067
|
+
SIdle: Fa(o.equityLWad - o.borrowedLWad, r),
|
|
6068
|
+
BM: Fa(o.borrowedLWad, r),
|
|
5932
6069
|
M: Number(o.borrowIndexWad) / 1e18,
|
|
5933
6070
|
Ucap: Number(t) / Dn,
|
|
5934
6071
|
thetaL: o.maxLtvPips / Dn,
|
|
@@ -5947,7 +6084,7 @@ async function pm(e) {
|
|
|
5947
6084
|
};
|
|
5948
6085
|
}
|
|
5949
6086
|
async function fm(e, t) {
|
|
5950
|
-
const { estimatePostBorrowRate: n } = await
|
|
6087
|
+
const { estimatePostBorrowRate: n } = await z(), { projection: o } = e, a = n({
|
|
5951
6088
|
equityLWad: o.equityLWad,
|
|
5952
6089
|
borrowedLWad: o.borrowedLWad,
|
|
5953
6090
|
deltaLWad: BigInt(Math.round(t.gamma * o.kappa * 1e18)),
|
|
@@ -5961,11 +6098,11 @@ async function fm(e, t) {
|
|
|
5961
6098
|
});
|
|
5962
6099
|
return a.oracleSupported ? { aprPct: a.postBorrowAprPct, basis: "projected-post-borrow" } : { aprPct: e.aprPct, basis: "current-apr" };
|
|
5963
6100
|
}
|
|
5964
|
-
const to = 2e-3, hm = 86400,
|
|
5965
|
-
function
|
|
6101
|
+
const to = 2e-3, hm = 86400, bm = 3;
|
|
6102
|
+
function Oe(e, t = null) {
|
|
5966
6103
|
return { lMin: null, lMax: null, chosen: null, candidates: [], diagnostics: t, infeasibleReason: e };
|
|
5967
6104
|
}
|
|
5968
|
-
function
|
|
6105
|
+
function wm(e) {
|
|
5969
6106
|
return e.Ppool > 0 && e.M > 0 && e.Ucap > 0 && e.Ucap <= 1 && e.thetaL > to && e.thetaL < 1.5 && // A market whose liquidation threshold sits under its open cap would size
|
|
5970
6107
|
// positions that are already liquidatable at lock.
|
|
5971
6108
|
e.thetaLiq >= e.thetaL && e.thetaLiq < 1.5;
|
|
@@ -5998,22 +6135,22 @@ async function ym(e) {
|
|
|
5998
6135
|
leverageTarget: l
|
|
5999
6136
|
} = e;
|
|
6000
6137
|
if (!Number.isFinite(a) || !Number.isFinite(r) || a <= 0 || r < 0 || !(s > 0) || l !== void 0 && (!Number.isFinite(l) || !(l > 0)))
|
|
6001
|
-
return
|
|
6002
|
-
if (i === 0) return
|
|
6003
|
-
if (!Number.isFinite(i)) return
|
|
6004
|
-
if (!
|
|
6138
|
+
return Oe({ kind: "invalid-input" });
|
|
6139
|
+
if (i === 0) return Oe({ kind: "zero-price-move" });
|
|
6140
|
+
if (!Number.isFinite(i)) return Oe({ kind: "price-move-out-of-range" });
|
|
6141
|
+
if (!wm(t)) return Oe({ kind: "invalid-market-state" });
|
|
6005
6142
|
const c = n === "long" ? Math.abs(i) : -Math.abs(i);
|
|
6006
|
-
if (c <= -1) return
|
|
6143
|
+
if (c <= -1) return Oe({ kind: "price-move-out-of-range" });
|
|
6007
6144
|
const {
|
|
6008
6145
|
buildDegenPosition: p,
|
|
6009
6146
|
computeMaxEfficientDeposit: d,
|
|
6010
6147
|
deltaMaxByUtil: m,
|
|
6011
6148
|
interestCostOverHorizon: u,
|
|
6012
6149
|
tauFromTimeToLiq: h
|
|
6013
|
-
} = await
|
|
6014
|
-
const g = P.aprPct > 0 ? P.aprPct / 100 : 0, M = t.thetaL - to,
|
|
6015
|
-
tau:
|
|
6016
|
-
tauBinding:
|
|
6150
|
+
} = await z(), f = t.Ppool, w = Math.sqrt(f), y = f * (1 + c), E = m(t.SIdle, t.BM, t.Ucap, t.M), C = (P) => {
|
|
6151
|
+
const g = P.aprPct > 0 ? P.aprPct / 100 : 0, M = t.thetaL - to, O = Math.min(h(t.thetaL, g, r), s, M), L = {
|
|
6152
|
+
tau: O,
|
|
6153
|
+
tauBinding: O === M ? "theta-margin" : O === s ? "tau-bar" : "horizon",
|
|
6017
6154
|
thetaL: t.thetaL,
|
|
6018
6155
|
thetaLiq: t.thetaLiq,
|
|
6019
6156
|
rEffAnnual: g,
|
|
@@ -6027,8 +6164,8 @@ async function ym(e) {
|
|
|
6027
6164
|
candidatesSurviving: 0
|
|
6028
6165
|
};
|
|
6029
6166
|
if (!(E > 0))
|
|
6030
|
-
return { result:
|
|
6031
|
-
const ee = { ...t, thetaL:
|
|
6167
|
+
return { result: Oe({ kind: "no-borrow-capacity" }, L), anchor: null };
|
|
6168
|
+
const ee = { ...t, thetaL: O + to }, Y = p(ee, {
|
|
6032
6169
|
direction: n,
|
|
6033
6170
|
depositAsset: o,
|
|
6034
6171
|
depositAmount: a,
|
|
@@ -6036,14 +6173,14 @@ async function ym(e) {
|
|
|
6036
6173
|
horizonMinutes: 0
|
|
6037
6174
|
});
|
|
6038
6175
|
if (!Y.ok) {
|
|
6039
|
-
const
|
|
6176
|
+
const q = d(ee, {
|
|
6040
6177
|
direction: n,
|
|
6041
6178
|
depositAsset: o,
|
|
6042
6179
|
targetPrice: y,
|
|
6043
6180
|
horizonMinutes: 0
|
|
6044
|
-
}), J =
|
|
6181
|
+
}), J = q === null ? null : q;
|
|
6045
6182
|
return {
|
|
6046
|
-
result:
|
|
6183
|
+
result: Oe(
|
|
6047
6184
|
J !== null && a > J ? { kind: "deposit-above-max", maxEfficientDeposit: J } : { kind: "no-feasible-band" },
|
|
6048
6185
|
{ ...L, maxEfficientDeposit: J }
|
|
6049
6186
|
),
|
|
@@ -6056,45 +6193,45 @@ async function ym(e) {
|
|
|
6056
6193
|
isCapConstrained: Y.diagnostics.isCapConstrained,
|
|
6057
6194
|
candidatesTotal: Y.diagnostics.candidatesTotal,
|
|
6058
6195
|
candidatesSurviving: Y.diagnostics.candidatesSurviving
|
|
6059
|
-
}, Re = (
|
|
6060
|
-
const J =
|
|
6196
|
+
}, Re = (q) => {
|
|
6197
|
+
const J = q.y - q.gamma * q.gamma / q.x;
|
|
6061
6198
|
return {
|
|
6062
|
-
alpha:
|
|
6063
|
-
leverage:
|
|
6064
|
-
localLeverage:
|
|
6065
|
-
asymptoticLeverage:
|
|
6066
|
-
ltv:
|
|
6067
|
-
delta:
|
|
6068
|
-
gamma:
|
|
6069
|
-
x:
|
|
6070
|
-
y:
|
|
6071
|
-
q:
|
|
6072
|
-
equity:
|
|
6073
|
-
equityAtTarget:
|
|
6074
|
-
interestCost: u(
|
|
6199
|
+
alpha: q.alpha,
|
|
6200
|
+
leverage: q.L_display,
|
|
6201
|
+
localLeverage: q.L0,
|
|
6202
|
+
asymptoticLeverage: q.L_infty,
|
|
6203
|
+
ltv: q.LTV,
|
|
6204
|
+
delta: q.delta,
|
|
6205
|
+
gamma: q.gamma,
|
|
6206
|
+
x: q.x,
|
|
6207
|
+
y: q.y,
|
|
6208
|
+
q: q.q,
|
|
6209
|
+
equity: q.E0,
|
|
6210
|
+
equityAtTarget: q.E_target,
|
|
6211
|
+
interestCost: u(q.gamma, w, g, r),
|
|
6075
6212
|
equityMin: J,
|
|
6076
|
-
equityMinRatio: J /
|
|
6077
|
-
cappedByDelta:
|
|
6213
|
+
equityMinRatio: J / q.E0,
|
|
6214
|
+
cappedByDelta: q.cappedByDelta
|
|
6078
6215
|
};
|
|
6079
|
-
},
|
|
6080
|
-
(
|
|
6216
|
+
}, we = Y.candidates.map(Re), ye = we.filter(
|
|
6217
|
+
(q) => q.leverage >= 1 && (n === "long" ? q.q >= 0 : q.q <= 0)
|
|
6081
6218
|
), he = vm(ye);
|
|
6082
6219
|
if (he.length === 0)
|
|
6083
|
-
return { result:
|
|
6084
|
-
const
|
|
6085
|
-
(
|
|
6220
|
+
return { result: Oe({ kind: "no-feasible-band" }, ne), anchor: null };
|
|
6221
|
+
const G = he.reduce(
|
|
6222
|
+
(q, J) => Math.min(q, J.leverage),
|
|
6086
6223
|
he[0].leverage
|
|
6087
|
-
),
|
|
6088
|
-
(
|
|
6224
|
+
), W = he.reduce(
|
|
6225
|
+
(q, J) => Math.max(q, J.leverage),
|
|
6089
6226
|
he[0].leverage
|
|
6090
|
-
),
|
|
6227
|
+
), V = Math.min(W, Math.max(G, l ?? W)), oe = Em(he, V);
|
|
6091
6228
|
return {
|
|
6092
|
-
result: { lMin:
|
|
6229
|
+
result: { lMin: G, lMax: W, chosen: oe, candidates: we, diagnostics: ne },
|
|
6093
6230
|
anchor: oe
|
|
6094
6231
|
};
|
|
6095
6232
|
};
|
|
6096
6233
|
let x = { aprPct: t.aprPct, basis: "current-apr" }, A = C(x);
|
|
6097
|
-
for (let P = 0; P <
|
|
6234
|
+
for (let P = 0; P < bm; P++) {
|
|
6098
6235
|
const g = A.anchor;
|
|
6099
6236
|
if (!g) break;
|
|
6100
6237
|
const M = await fm(t, g);
|
|
@@ -6108,7 +6245,7 @@ async function ym(e) {
|
|
|
6108
6245
|
return A.result;
|
|
6109
6246
|
}
|
|
6110
6247
|
const Im = 1e-6;
|
|
6111
|
-
function
|
|
6248
|
+
function wn(e, t) {
|
|
6112
6249
|
const n = Math.floor(e * 10 ** t);
|
|
6113
6250
|
return Number.isFinite(n) && n > 0 ? BigInt(n) : 0n;
|
|
6114
6251
|
}
|
|
@@ -6126,7 +6263,7 @@ function Am(e) {
|
|
|
6126
6263
|
};
|
|
6127
6264
|
if (c !== (n === "short"))
|
|
6128
6265
|
return { ok: !1, reason: "swap-direction-mismatch" };
|
|
6129
|
-
const d =
|
|
6266
|
+
const d = wn(p, c ? a : r), m = c ? i : s, u = d < m ? d : m;
|
|
6130
6267
|
return u <= 0n ? { ok: !1, reason: "insufficient-idle" } : {
|
|
6131
6268
|
ok: !0,
|
|
6132
6269
|
leg: {
|
|
@@ -6149,7 +6286,7 @@ function gm(e) {
|
|
|
6149
6286
|
return e.v4Quoter;
|
|
6150
6287
|
}
|
|
6151
6288
|
async function Ai(e, t, n) {
|
|
6152
|
-
const { verifyPermit2Batch: o } = await
|
|
6289
|
+
const { verifyPermit2Batch: o } = await z();
|
|
6153
6290
|
return {
|
|
6154
6291
|
...t,
|
|
6155
6292
|
verification: await o(e, {
|
|
@@ -6220,7 +6357,7 @@ function Ci(e, t, n) {
|
|
|
6220
6357
|
if (n && !k(e.owner, n))
|
|
6221
6358
|
throw new TypeError(`Borrow vault ${e.vaultId} is not owned by ${n}.`);
|
|
6222
6359
|
}
|
|
6223
|
-
const
|
|
6360
|
+
const qa = 1000000000000n, Oa = 1000000000000000000n, La = (1n << 127n) - 1n, Cm = 100, mt = 1e6;
|
|
6224
6361
|
function xm(e, t) {
|
|
6225
6362
|
switch (e) {
|
|
6226
6363
|
case "v0.4.0":
|
|
@@ -6234,7 +6371,7 @@ function xm(e, t) {
|
|
|
6234
6371
|
}
|
|
6235
6372
|
}
|
|
6236
6373
|
}
|
|
6237
|
-
function
|
|
6374
|
+
function N0({
|
|
6238
6375
|
requestedMaxLtvPips: e,
|
|
6239
6376
|
postBorrowLtvPips: t,
|
|
6240
6377
|
marketMaxLtvPips: n
|
|
@@ -6244,8 +6381,8 @@ function qf({
|
|
|
6244
6381
|
}
|
|
6245
6382
|
function xi(e, t, n, o) {
|
|
6246
6383
|
if (t <= 0n) return 0;
|
|
6247
|
-
const a = e * 10n ** BigInt(n) *
|
|
6248
|
-
return Number(a > r ? r : a) / Number(
|
|
6384
|
+
const a = e * 10n ** BigInt(n) * qa / (t * 10n ** BigInt(o)), r = BigInt(Number.MAX_SAFE_INTEGER);
|
|
6385
|
+
return Number(a > r ? r : a) / Number(qa);
|
|
6249
6386
|
}
|
|
6250
6387
|
function Ti(e, t, n) {
|
|
6251
6388
|
if (e !== void 0 && t !== void 0)
|
|
@@ -6273,8 +6410,8 @@ function Tm({
|
|
|
6273
6410
|
}
|
|
6274
6411
|
return a;
|
|
6275
6412
|
}
|
|
6276
|
-
async function
|
|
6277
|
-
const { quoteDeposit: t } = await
|
|
6413
|
+
async function F0(e) {
|
|
6414
|
+
const { quoteDeposit: t } = await z();
|
|
6278
6415
|
if (!e.market.lendEnabled || e.market.canLend === !1)
|
|
6279
6416
|
throw new Error("Lending is disabled for this market.");
|
|
6280
6417
|
Po(e.market, {
|
|
@@ -6360,7 +6497,7 @@ async function Of(e) {
|
|
|
6360
6497
|
};
|
|
6361
6498
|
}
|
|
6362
6499
|
async function Ri(e, t) {
|
|
6363
|
-
const { computeVaultStateSnapshot: n, fetchBorrowVaultContext: o, quoteBorrow: a, quoteExactInputSingle: r } = await
|
|
6500
|
+
const { computeVaultStateSnapshot: n, fetchBorrowVaultContext: o, quoteBorrow: a, quoteExactInputSingle: r } = await z();
|
|
6364
6501
|
if (!t.allowDisabledBorrow && (!e.market.borrowEnabled || e.market.canBorrow === !1))
|
|
6365
6502
|
throw new Error("Borrowing is disabled for this market.");
|
|
6366
6503
|
const i = Po(e.market, {
|
|
@@ -6387,22 +6524,22 @@ async function Ri(e, t) {
|
|
|
6387
6524
|
owner: e.owner,
|
|
6388
6525
|
expectedPoolId: e.market.poolId,
|
|
6389
6526
|
frame: l.frame
|
|
6390
|
-
}) : null, d = Ti(e.tauPips, e.tauPercentOfMaxLtv, c), m = async (
|
|
6527
|
+
}) : null, d = Ti(e.tauPips, e.tauPercentOfMaxLtv, c), m = async (w) => {
|
|
6391
6528
|
const y = rt(
|
|
6392
6529
|
"V4 quoter",
|
|
6393
6530
|
e.market.v4Quoter,
|
|
6394
6531
|
i.uniswapV4Quoter
|
|
6395
6532
|
), E = await r(e.publicClient, y, {
|
|
6396
6533
|
poolKey: c.poolKey,
|
|
6397
|
-
zeroForOne:
|
|
6398
|
-
exactAmount:
|
|
6399
|
-
}), C = kt(E.amountOut, e.slippageBps), x =
|
|
6534
|
+
zeroForOne: w.inputIsToken0,
|
|
6535
|
+
exactAmount: w.amountIn
|
|
6536
|
+
}), C = kt(E.amountOut, e.slippageBps), x = w.inputIsToken0 ? e.market.token0 : e.market.token1, A = w.inputIsToken0 ? e.market.token1 : e.market.token0;
|
|
6400
6537
|
return {
|
|
6401
6538
|
minAmountOut: C,
|
|
6402
6539
|
route: null,
|
|
6403
6540
|
effectivePrice: xi(
|
|
6404
6541
|
C,
|
|
6405
|
-
|
|
6542
|
+
w.amountIn,
|
|
6406
6543
|
x.decimals,
|
|
6407
6544
|
A.decimals
|
|
6408
6545
|
)
|
|
@@ -6460,10 +6597,10 @@ async function Ri(e, t) {
|
|
|
6460
6597
|
tx: st(e.market, f.call)
|
|
6461
6598
|
};
|
|
6462
6599
|
}
|
|
6463
|
-
async function
|
|
6600
|
+
async function q0(e) {
|
|
6464
6601
|
return Ri(e, { allowDisabledBorrow: !1 });
|
|
6465
6602
|
}
|
|
6466
|
-
async function
|
|
6603
|
+
async function O0(e) {
|
|
6467
6604
|
if (e.collateralIn <= 0n)
|
|
6468
6605
|
throw new RangeError("Collateral amount must be greater than zero.");
|
|
6469
6606
|
const { trustedPermit2: t } = Kt(e.market, e.target, "add-collateral");
|
|
@@ -6483,7 +6620,7 @@ async function Lf(e) {
|
|
|
6483
6620
|
), o = n.quote.expiresAt;
|
|
6484
6621
|
if (o === null)
|
|
6485
6622
|
throw new Error("Collateral quote did not include a live expiry frame.");
|
|
6486
|
-
const a = e.inputIsToken0 ? e.market.token0 : e.market.token1, r = k(a.address,
|
|
6623
|
+
const a = e.inputIsToken0 ? e.market.token0 : e.market.token1, r = k(a.address, ce), i = [
|
|
6487
6624
|
{
|
|
6488
6625
|
approvalType: "permit2",
|
|
6489
6626
|
token: a.address,
|
|
@@ -6516,8 +6653,8 @@ async function Lf(e) {
|
|
|
6516
6653
|
tx: n.tx
|
|
6517
6654
|
};
|
|
6518
6655
|
}
|
|
6519
|
-
async function
|
|
6520
|
-
const t = await
|
|
6656
|
+
async function L0(e) {
|
|
6657
|
+
const t = await z(), { computeBorrowCapacity: n, dMinNoSwap: o, forwardFunctionNoSwap: a, invertSqrtPriceX96: r } = t;
|
|
6521
6658
|
if (!e.market.borrowEnabled || e.market.canBorrow === !1)
|
|
6522
6659
|
throw new Error("Borrowing is disabled for this market.");
|
|
6523
6660
|
St(e.slippageBps);
|
|
@@ -6556,7 +6693,7 @@ async function Uf(e) {
|
|
|
6556
6693
|
yWtarget: d,
|
|
6557
6694
|
tauPips: l
|
|
6558
6695
|
}).feasible
|
|
6559
|
-
}) : null,
|
|
6696
|
+
}) : null, w = f === 0n && d !== null ? a({ market: u, vault: p, deposit: 0n, yWtarget: d, tauPips: l }) : null, y = (w == null ? void 0 : w.regime) === "no-new-borrow" && w.gammaNewL === 0n && e.vault && d !== null && p.y0 >= d ? "existing-idle" : (w == null ? void 0 : w.regime) === "needs-borrow" || ((w == null ? void 0 : w.gammaNewL) ?? 0n) > 0n ? "new-debt" : "unknown", E = d === null ? { status: "not-requested" } : m ? { status: "infeasible", reason: "utilization-capped" } : h === null ? { status: "unavailable", reason: "closed-form-not-applicable", retryable: !1 } : f === null ? { status: "unavailable", reason: "forward-validation-unavailable", retryable: !0 } : f === 0n ? { status: "ready-zero", amountIn: 0n, outputSource: y } : { status: "ready-positive", amountIn: f };
|
|
6560
6697
|
let C;
|
|
6561
6698
|
if (e.includeBorrowLimits || e.walletCollateralIn !== void 0) {
|
|
6562
6699
|
const x = e.walletCollateralIn ?? null;
|
|
@@ -6614,7 +6751,7 @@ async function Uf(e) {
|
|
|
6614
6751
|
}
|
|
6615
6752
|
function Pi(e, t) {
|
|
6616
6753
|
It(e);
|
|
6617
|
-
const n =
|
|
6754
|
+
const n = ue(e.chainId);
|
|
6618
6755
|
if (!n)
|
|
6619
6756
|
throw new Error(`No trusted Aegis Engine deployment is configured for chain ${e.chainId}.`);
|
|
6620
6757
|
const o = [
|
|
@@ -6660,7 +6797,7 @@ function rt(e, t, n) {
|
|
|
6660
6797
|
return t;
|
|
6661
6798
|
}
|
|
6662
6799
|
function Rm(e) {
|
|
6663
|
-
const t =
|
|
6800
|
+
const t = ue(e);
|
|
6664
6801
|
if (!t)
|
|
6665
6802
|
throw new Error(`No trusted Aegis Engine deployment is configured for chain ${e}.`);
|
|
6666
6803
|
return t.permit2;
|
|
@@ -6670,7 +6807,7 @@ function kn(e, t, n) {
|
|
|
6670
6807
|
}
|
|
6671
6808
|
function Pm(e, t, n, o) {
|
|
6672
6809
|
return async (a) => {
|
|
6673
|
-
const { quoteExactInputSingle: r } = await
|
|
6810
|
+
const { quoteExactInputSingle: r } = await z(), i = rt("V4 quoter", t.v4Quoter, o), s = await r(e, i, {
|
|
6674
6811
|
poolKey: t.poolKey,
|
|
6675
6812
|
zeroForOne: a.inputIsToken0,
|
|
6676
6813
|
exactAmount: a.amountIn,
|
|
@@ -6696,13 +6833,13 @@ function Mi(e) {
|
|
|
6696
6833
|
var t, n;
|
|
6697
6834
|
return e.infeasibleReason ? e.infeasibleReason : ((t = e.execution) == null ? void 0 : t.status) === "rejected-at-frame" || ((n = e.execution) == null ? void 0 : n.status) === "re-quote-required" ? e.execution.reason ?? null : null;
|
|
6698
6835
|
}
|
|
6699
|
-
async function
|
|
6836
|
+
async function U0(e) {
|
|
6700
6837
|
St(e.slippageBps);
|
|
6701
6838
|
const { chainId: t, version: n, trustedPermit2: o, trustedQuoter: a } = Kt(
|
|
6702
6839
|
e.market,
|
|
6703
6840
|
e.target,
|
|
6704
6841
|
"repay"
|
|
6705
|
-
), { quoteRepay: r } = await
|
|
6842
|
+
), { quoteRepay: r } = await z(), i = await Bi(
|
|
6706
6843
|
() => r(e.publicClient, {
|
|
6707
6844
|
chainId: t,
|
|
6708
6845
|
version: n,
|
|
@@ -6753,12 +6890,12 @@ async function Vf(e) {
|
|
|
6753
6890
|
tx: st(e.market, i.call)
|
|
6754
6891
|
};
|
|
6755
6892
|
}
|
|
6756
|
-
async function
|
|
6893
|
+
async function V0(e) {
|
|
6757
6894
|
const { chainId: t, version: n, trustedPermit2: o } = Kt(
|
|
6758
6895
|
e.market,
|
|
6759
6896
|
e.target,
|
|
6760
6897
|
"close"
|
|
6761
|
-
), { quoteCloseVault: a } = await
|
|
6898
|
+
), { quoteCloseVault: a } = await z(), r = await Bi(
|
|
6762
6899
|
() => a(e.publicClient, {
|
|
6763
6900
|
chainId: t,
|
|
6764
6901
|
version: n,
|
|
@@ -6795,8 +6932,8 @@ async function Hf(e) {
|
|
|
6795
6932
|
tx: st(e.market, r.call)
|
|
6796
6933
|
};
|
|
6797
6934
|
}
|
|
6798
|
-
async function
|
|
6799
|
-
const { chainId: t, version: n } = Kt(e.market, e.target, "withdraw"), { quoteIdleWithdraw: o } = await
|
|
6935
|
+
async function H0(e) {
|
|
6936
|
+
const { chainId: t, version: n } = Kt(e.market, e.target, "withdraw"), { quoteIdleWithdraw: o } = await z(), a = await o(e.publicClient, {
|
|
6800
6937
|
chainId: t,
|
|
6801
6938
|
version: n,
|
|
6802
6939
|
poolId: e.market.poolId,
|
|
@@ -6830,7 +6967,7 @@ async function $f(e) {
|
|
|
6830
6967
|
tx: st(e.market, a.call)
|
|
6831
6968
|
};
|
|
6832
6969
|
}
|
|
6833
|
-
async function
|
|
6970
|
+
async function $0(e) {
|
|
6834
6971
|
var x;
|
|
6835
6972
|
St(e.slippageBps);
|
|
6836
6973
|
const { chainId: t, version: n } = Kt(e.market, e.target, "redeem"), {
|
|
@@ -6839,7 +6976,7 @@ async function Wf(e) {
|
|
|
6839
6976
|
PIPS_DENOMINATOR: r,
|
|
6840
6977
|
quoteRedeem: i,
|
|
6841
6978
|
UTILIZATION_CAP_PIPS: s
|
|
6842
|
-
} = await
|
|
6979
|
+
} = await z(), l = e.deadline ?? gt(), c = xm(n, s), p = {
|
|
6843
6980
|
chainId: t,
|
|
6844
6981
|
version: n,
|
|
6845
6982
|
poolId: e.market.poolId,
|
|
@@ -6868,11 +7005,11 @@ async function Wf(e) {
|
|
|
6868
7005
|
if (c !== null) {
|
|
6869
7006
|
const g = e.market.stateView;
|
|
6870
7007
|
if (!g) throw new Error("Market is missing Aegis StateView.");
|
|
6871
|
-
const [M,
|
|
7008
|
+
const [M, O] = await Promise.all([
|
|
6872
7009
|
o(e.publicClient, g, e.market.poolId, A),
|
|
6873
7010
|
a(e.publicClient, g, e.market.poolId, A)
|
|
6874
|
-
]), L = M.market.totalRlBorrowed * M.latestBorrowIndexWad, ee = L === 0n ? 0n : L * r / (c + 1n) + 1n, ne = (M.latestEquityLWad >= ee ? M.latestEquityLWad - ee : 0n) /
|
|
6875
|
-
h = ne > 0n && M.latestEquityLWad > 0n &&
|
|
7011
|
+
]), L = M.market.totalRlBorrowed * M.latestBorrowIndexWad, ee = L === 0n ? 0n : L * r / (c + 1n) + 1n, ne = (M.latestEquityLWad >= ee ? M.latestEquityLWad - ee : 0n) / Oa, Re = O * Oa;
|
|
7012
|
+
h = ne > 0n && M.latestEquityLWad > 0n && O > 0n ? ((ne + 1n) * Re - 1n) / M.latestEquityLWad : 0n, h < P && (P = h);
|
|
6876
7013
|
}
|
|
6877
7014
|
P > 0n ? (d.sharesDelta !== P && (d = await i(e.publicClient, {
|
|
6878
7015
|
...p,
|
|
@@ -6889,12 +7026,12 @@ async function Wf(e) {
|
|
|
6889
7026
|
const A = (x = d.projection) == null ? void 0 : x.capAssessment;
|
|
6890
7027
|
A != null && A.applies && !A.passesEstimate && (u = !0);
|
|
6891
7028
|
}
|
|
6892
|
-
const f = d.status === "verified-at-frame",
|
|
7029
|
+
const f = d.status === "verified-at-frame", w = f || d.status === "blocked", y = d.status === "rejected" ? d.reason === "utilization-cap" ? "utilization-blocked" : d.reason : d.status === "unavailable" ? d.reason : null, E = d.status === "verified-at-frame" ? { amount0: d.output.amount0, amount1: d.output.amount1 } : null, C = w && !u && d.shareBalance !== null && d.sharesDelta !== null ? d.shareBalance - d.sharesDelta : null;
|
|
6893
7030
|
return {
|
|
6894
7031
|
kind: "redeem",
|
|
6895
7032
|
market: e.market,
|
|
6896
7033
|
target: e.target,
|
|
6897
|
-
feasible: u ? !1 :
|
|
7034
|
+
feasible: u ? !1 : w,
|
|
6898
7035
|
executable: f,
|
|
6899
7036
|
infeasibleReason: u ? "utilization-blocked" : y,
|
|
6900
7037
|
gateFailures: d.gateFailures,
|
|
@@ -6956,7 +7093,7 @@ function Mm(e, t, n, o) {
|
|
|
6956
7093
|
case "deposit-above-max":
|
|
6957
7094
|
return {
|
|
6958
7095
|
...Pt,
|
|
6959
|
-
maxCollateralIn:
|
|
7096
|
+
maxCollateralIn: wn(e.maxEfficientDeposit, t)
|
|
6960
7097
|
};
|
|
6961
7098
|
case "leverage-above-max":
|
|
6962
7099
|
return {
|
|
@@ -6982,7 +7119,7 @@ function Di(e, t, n, o) {
|
|
|
6982
7119
|
return c <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(c) : Number.NaN;
|
|
6983
7120
|
}
|
|
6984
7121
|
function Dm(e) {
|
|
6985
|
-
const t = Number(e.collateral0) / 10 ** e.decimals0, n = Number(e.collateral1) / 10 ** e.decimals1, o = Number(e.debtLiquidityL) /
|
|
7122
|
+
const t = Number(e.collateral0) / 10 ** e.decimals0, n = Number(e.collateral1) / 10 ** e.decimals1, o = Number(e.debtLiquidityL) / Oo(e.decimals0, e.decimals1), a = Math.sqrt(e.entryPrice), r = (m) => m * t + n - 2 * o * Math.sqrt(m), i = r(e.entryPrice), s = r(e.targetPrice), l = e.targetPrice / e.entryPrice, c = (s - i) / i / (l - 1), p = 2 * o * a * e.rEffAnnual * (e.horizonSeconds / Lo), d = p * Math.sqrt(l);
|
|
6986
7123
|
return {
|
|
6987
7124
|
scenario: {
|
|
6988
7125
|
entryEquity: i,
|
|
@@ -6992,7 +7129,7 @@ function Dm(e) {
|
|
|
6992
7129
|
leverage: Math.abs(c),
|
|
6993
7130
|
localLeverage: (e.entryPrice * t - o * a) / i,
|
|
6994
7131
|
asymptoticLeverage: e.entryPrice * t / i,
|
|
6995
|
-
interestCostToken1:
|
|
7132
|
+
interestCostToken1: wn(p, e.decimals1),
|
|
6996
7133
|
worstEquityRatio: (n - o * o / t) / i,
|
|
6997
7134
|
grossReturnAtTargetPct: (s - i) / i * 100
|
|
6998
7135
|
};
|
|
@@ -7036,7 +7173,7 @@ async function _m(e) {
|
|
|
7036
7173
|
), i = a.market, s = e.inputIsToken0 ? e.market.token0 : e.market.token1, l = e.inputIsToken0 ? i.decimals0 : i.decimals1, c = {
|
|
7037
7174
|
amount0: e.inputIsToken0 ? e.collateralIn : 0n,
|
|
7038
7175
|
amount1: e.inputIsToken0 ? 0n : e.collateralIn
|
|
7039
|
-
}, p = k(s.address,
|
|
7176
|
+
}, p = k(s.address, ce), d = [
|
|
7040
7177
|
{
|
|
7041
7178
|
approvalType: "permit2",
|
|
7042
7179
|
token: s.address,
|
|
@@ -7082,7 +7219,7 @@ async function _m(e) {
|
|
|
7082
7219
|
swap: M,
|
|
7083
7220
|
tx: null
|
|
7084
7221
|
}), f = await pm(a);
|
|
7085
|
-
let
|
|
7222
|
+
let w = Math.min(e.tauPips ?? i.maxLtvPips, i.maxLtvPips), y = Pt;
|
|
7086
7223
|
for (let P = 0; P < Ua; P++) {
|
|
7087
7224
|
const g = await ym({
|
|
7088
7225
|
state: f,
|
|
@@ -7091,7 +7228,7 @@ async function _m(e) {
|
|
|
7091
7228
|
depositAmount: Number(e.collateralIn) / 10 ** l,
|
|
7092
7229
|
tlSeconds: e.horizonSeconds,
|
|
7093
7230
|
deltaLev: e.priceMove,
|
|
7094
|
-
tauBar:
|
|
7231
|
+
tauBar: w / mt,
|
|
7095
7232
|
rootPolicy: e.rootPolicy ?? "min-carry",
|
|
7096
7233
|
...e.leverage !== void 0 ? { leverageTarget: e.leverage } : {}
|
|
7097
7234
|
});
|
|
@@ -7104,21 +7241,21 @@ async function _m(e) {
|
|
|
7104
7241
|
Mm(N, l, g.lMax, g.lMin)
|
|
7105
7242
|
);
|
|
7106
7243
|
}
|
|
7107
|
-
const { chosen: M, diagnostics:
|
|
7244
|
+
const { chosen: M, diagnostics: O } = g, L = {
|
|
7108
7245
|
maxLeverage: g.lMax,
|
|
7109
7246
|
minLeverage: g.lMin,
|
|
7110
|
-
maxCollateralIn:
|
|
7247
|
+
maxCollateralIn: O.maxEfficientDeposit === null ? null : wn(O.maxEfficientDeposit, l)
|
|
7111
7248
|
};
|
|
7112
7249
|
y = L;
|
|
7113
|
-
const { buildTapOpenPosition: ee, computeActualLtvPips: Y, minDebtFloorRl: ne, previewFullRangeBorrow: Re } = await
|
|
7250
|
+
const { buildTapOpenPosition: ee, computeActualLtvPips: Y, minDebtFloorRl: ne, previewFullRangeBorrow: Re } = await z(), we = mm(
|
|
7114
7251
|
M.delta,
|
|
7115
|
-
|
|
7252
|
+
Oo(i.decimals0, i.decimals1)
|
|
7116
7253
|
);
|
|
7117
|
-
if (
|
|
7254
|
+
if (we < ne(i.equityLWad, i.borrowIndexWad))
|
|
7118
7255
|
return h("debt-below-minimum", L);
|
|
7119
|
-
if (M.delta >
|
|
7256
|
+
if (M.delta > O.deltaCap) return h("delta-above-cap", L);
|
|
7120
7257
|
const ye = Re(
|
|
7121
|
-
|
|
7258
|
+
we,
|
|
7122
7259
|
i.borrowIndexWad,
|
|
7123
7260
|
i.poolKey,
|
|
7124
7261
|
{
|
|
@@ -7130,47 +7267,47 @@ async function _m(e) {
|
|
|
7130
7267
|
}
|
|
7131
7268
|
);
|
|
7132
7269
|
if (!ye) return h("invalid-market-state", L);
|
|
7133
|
-
const he = c.amount0 + ye.amount0,
|
|
7270
|
+
const he = c.amount0 + ye.amount0, G = c.amount1 + ye.amount1, W = Am({
|
|
7134
7271
|
candidate: M,
|
|
7135
7272
|
direction: e.direction,
|
|
7136
|
-
entryPrice:
|
|
7273
|
+
entryPrice: O.entryPrice,
|
|
7137
7274
|
decimals0: i.decimals0,
|
|
7138
7275
|
decimals1: i.decimals1,
|
|
7139
7276
|
idle0: he,
|
|
7140
|
-
idle1:
|
|
7277
|
+
idle1: G
|
|
7141
7278
|
});
|
|
7142
|
-
if (
|
|
7143
|
-
const
|
|
7279
|
+
if (!W.ok) return h(W.reason, L);
|
|
7280
|
+
const V = W.leg, oe = await um({
|
|
7144
7281
|
publicClient: e.publicClient,
|
|
7145
7282
|
quoter: o,
|
|
7146
7283
|
context: a,
|
|
7147
7284
|
token0: e.market.token0,
|
|
7148
7285
|
token1: e.market.token1,
|
|
7149
|
-
leg:
|
|
7286
|
+
leg: V,
|
|
7150
7287
|
slippageBps: e.slippageBps,
|
|
7151
7288
|
...e.signal ? { signal: e.signal } : {}
|
|
7152
7289
|
});
|
|
7153
7290
|
if ((A = e.signal) == null || A.throwIfAborted(), oe.blockNumber !== a.frame.blockNumber || !await _i(e.publicClient, a.frame, e.signal))
|
|
7154
7291
|
return h("stale-frame", L);
|
|
7155
|
-
const
|
|
7156
|
-
|
|
7292
|
+
const q = V.needed ? Di(
|
|
7293
|
+
V.amountIn,
|
|
7157
7294
|
oe.amountOutQuoted,
|
|
7158
|
-
|
|
7295
|
+
V.inputIsToken0,
|
|
7159
7296
|
i.sqrtPriceX96
|
|
7160
7297
|
) : null;
|
|
7161
|
-
if (
|
|
7298
|
+
if (q !== null && !Number.isSafeInteger(q))
|
|
7162
7299
|
return h("price-impact-unavailable", L);
|
|
7163
|
-
const J =
|
|
7164
|
-
inputIsToken0:
|
|
7165
|
-
amountIn:
|
|
7300
|
+
const J = V.needed ? {
|
|
7301
|
+
inputIsToken0: V.inputIsToken0,
|
|
7302
|
+
amountIn: V.amountIn,
|
|
7166
7303
|
amountOutQuoted: oe.amountOutQuoted,
|
|
7167
7304
|
amountOutMinimum: oe.amountOutMinimum,
|
|
7168
|
-
priceImpactBps:
|
|
7169
|
-
clampedByIdle:
|
|
7305
|
+
priceImpactBps: q,
|
|
7306
|
+
clampedByIdle: V.clampedByIdle
|
|
7170
7307
|
} : null;
|
|
7171
7308
|
if (J && J.priceImpactBps > e.maxPriceImpactBps)
|
|
7172
7309
|
return h("price-impact-limit", L, J);
|
|
7173
|
-
const Ct =
|
|
7310
|
+
const Ct = V.inputIsToken0 ? V.amountIn : 0n, xt = V.inputIsToken0 ? 0n : V.amountIn, zt = V.inputIsToken0 ? 0n : oe.amountOutMinimum, Pe = V.inputIsToken0 ? oe.amountOutMinimum : 0n, Tt = he - Ct + zt, Ge = G - xt + Pe, ct = Y(
|
|
7174
7311
|
ye.liquidityL,
|
|
7175
7312
|
Tt,
|
|
7176
7313
|
Ge,
|
|
@@ -7178,13 +7315,13 @@ async function _m(e) {
|
|
|
7178
7315
|
i.decimals1
|
|
7179
7316
|
);
|
|
7180
7317
|
if (ct >= i.maxLtvPips - Va) {
|
|
7181
|
-
const N = i.maxLtvPips - Va, Ie = Math.max(1, Math.floor(M.ltv * mt)),
|
|
7182
|
-
|
|
7318
|
+
const N = i.maxLtvPips - Va, Ie = Math.max(1, Math.floor(M.ltv * mt)), Fe = Math.min(
|
|
7319
|
+
w - 1,
|
|
7183
7320
|
Math.floor(Ie * N / ct)
|
|
7184
7321
|
);
|
|
7185
|
-
if (P === Ua - 1 ||
|
|
7322
|
+
if (P === Ua - 1 || Fe <= 0)
|
|
7186
7323
|
return h("ltv-above-max", L);
|
|
7187
|
-
|
|
7324
|
+
w = Fe;
|
|
7188
7325
|
continue;
|
|
7189
7326
|
}
|
|
7190
7327
|
const An = ee({
|
|
@@ -7194,10 +7331,10 @@ async function _m(e) {
|
|
|
7194
7331
|
deadline: m,
|
|
7195
7332
|
deposit0: c.amount0,
|
|
7196
7333
|
deposit1: c.amount1,
|
|
7197
|
-
principalDelta:
|
|
7334
|
+
principalDelta: we,
|
|
7198
7335
|
swapRoute: oe.route,
|
|
7199
|
-
swapInputAmount:
|
|
7200
|
-
swapInputIsToken0:
|
|
7336
|
+
swapInputAmount: V.amountIn,
|
|
7337
|
+
swapInputIsToken0: V.inputIsToken0,
|
|
7201
7338
|
depositAfterSwap0: zt,
|
|
7202
7339
|
depositAfterSwap1: Pe,
|
|
7203
7340
|
maxLtvPips: BigInt(i.maxLtvPips),
|
|
@@ -7208,12 +7345,12 @@ async function _m(e) {
|
|
|
7208
7345
|
debtLiquidityL: ye.liquidityL,
|
|
7209
7346
|
decimals0: i.decimals0,
|
|
7210
7347
|
decimals1: i.decimals1,
|
|
7211
|
-
entryPrice:
|
|
7212
|
-
targetPrice:
|
|
7213
|
-
rEffAnnual:
|
|
7348
|
+
entryPrice: O.entryPrice,
|
|
7349
|
+
targetPrice: O.targetPrice,
|
|
7350
|
+
rEffAnnual: O.rEffAnnual,
|
|
7214
7351
|
horizonSeconds: e.horizonSeconds
|
|
7215
7352
|
}), v = (N) => i.equityLWad > 0n ? Number(N * BigInt(mt) / i.equityLWad) : 0, I = v(i.borrowedLWad), R = v(
|
|
7216
|
-
i.borrowedLWad +
|
|
7353
|
+
i.borrowedLWad + we * i.borrowIndexWad
|
|
7217
7354
|
);
|
|
7218
7355
|
return {
|
|
7219
7356
|
...u,
|
|
@@ -7230,16 +7367,16 @@ async function _m(e) {
|
|
|
7230
7367
|
executionLtvPips: ct,
|
|
7231
7368
|
daysToLiquidation: km(
|
|
7232
7369
|
ct / mt,
|
|
7233
|
-
|
|
7234
|
-
|
|
7370
|
+
O.thetaLiq,
|
|
7371
|
+
O.rEffAnnual
|
|
7235
7372
|
),
|
|
7236
7373
|
scenario: Ne.scenario,
|
|
7237
7374
|
interestCostToken1: Ne.interestCostToken1,
|
|
7238
7375
|
worstEquityRatio: Ne.worstEquityRatio,
|
|
7239
|
-
entryPrice:
|
|
7240
|
-
targetPrice:
|
|
7376
|
+
entryPrice: O.entryPrice,
|
|
7377
|
+
targetPrice: O.targetPrice,
|
|
7241
7378
|
grossReturnAtTargetPct: Ne.grossReturnAtTargetPct,
|
|
7242
|
-
principalDeltaRl:
|
|
7379
|
+
principalDeltaRl: we,
|
|
7243
7380
|
marketUtilization: {
|
|
7244
7381
|
beforePips: I,
|
|
7245
7382
|
afterPips: R,
|
|
@@ -7254,7 +7391,7 @@ async function _m(e) {
|
|
|
7254
7391
|
}
|
|
7255
7392
|
return h("ltv-above-max", y);
|
|
7256
7393
|
}
|
|
7257
|
-
function
|
|
7394
|
+
function W0(e) {
|
|
7258
7395
|
if (e.collateralFloor) return e.collateralFloor;
|
|
7259
7396
|
if (e.borrowOut === null) return { status: "not-requested" };
|
|
7260
7397
|
if (e.utilizationCapped) return { status: "infeasible", reason: "utilization-capped" };
|
|
@@ -7312,8 +7449,8 @@ const Ni = [
|
|
|
7312
7449
|
],
|
|
7313
7450
|
outputs: []
|
|
7314
7451
|
}
|
|
7315
|
-
],
|
|
7316
|
-
function
|
|
7452
|
+
], Fm = "The Engine quote expired before it reached your wallet. Try again.", qm = "The network did not respond, so we could not check this transaction. Nothing was sent. Try again.";
|
|
7453
|
+
function Om(e) {
|
|
7317
7454
|
return To({
|
|
7318
7455
|
currentAllowance: e.currentAmount,
|
|
7319
7456
|
amount: e.spendAmount,
|
|
@@ -7350,7 +7487,7 @@ function $a(e) {
|
|
|
7350
7487
|
};
|
|
7351
7488
|
}
|
|
7352
7489
|
function Um(e) {
|
|
7353
|
-
const t =
|
|
7490
|
+
const t = ue(e.chainId);
|
|
7354
7491
|
if (!t)
|
|
7355
7492
|
throw new Error(`No trusted Aegis Engine deployment is configured for chain ${e.chainId}.`);
|
|
7356
7493
|
if (!e.router || !k(e.router, t.aegisRouterV1))
|
|
@@ -7381,7 +7518,7 @@ function Vm(e) {
|
|
|
7381
7518
|
throw new TypeError(
|
|
7382
7519
|
`Engine position ${o.positionId} does not belong to market ${n.id}.`
|
|
7383
7520
|
);
|
|
7384
|
-
const a =
|
|
7521
|
+
const a = ue(n.chainId);
|
|
7385
7522
|
if (!a)
|
|
7386
7523
|
throw new Error(`No trusted Aegis Engine deployment is configured for chain ${n.chainId}.`);
|
|
7387
7524
|
if (!n.router || !k(n.router, a.aegisRouterV1))
|
|
@@ -7391,7 +7528,7 @@ function Vm(e) {
|
|
|
7391
7528
|
throw new Error("VaultRegistry does not match the trusted Engine deployment.");
|
|
7392
7529
|
return {
|
|
7393
7530
|
to: a.vaultRegistry,
|
|
7394
|
-
data:
|
|
7531
|
+
data: bt({
|
|
7395
7532
|
abi: Ni,
|
|
7396
7533
|
functionName: "approve",
|
|
7397
7534
|
args: [a.aegisRouterV1, o.vaultId]
|
|
@@ -7405,7 +7542,7 @@ function Vm(e) {
|
|
|
7405
7542
|
throw new TypeError("A positive lender-share allowance is required.");
|
|
7406
7543
|
return {
|
|
7407
7544
|
to: a.aegisEngine,
|
|
7408
|
-
data:
|
|
7545
|
+
data: bt({
|
|
7409
7546
|
abi: Nm,
|
|
7410
7547
|
functionName: "approve",
|
|
7411
7548
|
args: [a.aegisRouterV1, BigInt(o.poolId), e.amount]
|
|
@@ -7561,13 +7698,13 @@ async function zm(e) {
|
|
|
7561
7698
|
scope: E.scope
|
|
7562
7699
|
});
|
|
7563
7700
|
}
|
|
7564
|
-
const
|
|
7701
|
+
const w = Zt({
|
|
7565
7702
|
allowance: p,
|
|
7566
7703
|
spendAmount: e.amount,
|
|
7567
7704
|
approvalMode: t
|
|
7568
7705
|
});
|
|
7569
7706
|
if (Lm({
|
|
7570
|
-
satisfied:
|
|
7707
|
+
satisfied: w,
|
|
7571
7708
|
spendAmount: e.amount,
|
|
7572
7709
|
approvalMode: t
|
|
7573
7710
|
})) {
|
|
@@ -7575,13 +7712,13 @@ async function zm(e) {
|
|
|
7575
7712
|
currentAmount: E,
|
|
7576
7713
|
spendAmount: e.amount,
|
|
7577
7714
|
maximumAmount: De,
|
|
7578
|
-
satisfied:
|
|
7715
|
+
satisfied: w,
|
|
7579
7716
|
approvalMode: t
|
|
7580
7717
|
});
|
|
7581
7718
|
d.push({
|
|
7582
7719
|
id: "permit2-router",
|
|
7583
7720
|
kind: "permit2-router",
|
|
7584
|
-
status:
|
|
7721
|
+
status: w ? "satisfied" : "required",
|
|
7585
7722
|
walletAction: n === "signature" ? "signature-or-transaction" : "transaction",
|
|
7586
7723
|
target: r,
|
|
7587
7724
|
spender: a,
|
|
@@ -7589,7 +7726,7 @@ async function zm(e) {
|
|
|
7589
7726
|
currentAmount: E,
|
|
7590
7727
|
currentExpiration: Number(C),
|
|
7591
7728
|
requestedAmount: x.requestedAmount,
|
|
7592
|
-
expiration:
|
|
7729
|
+
expiration: w ? Number(C) : n === "signature" ? o : Fr,
|
|
7593
7730
|
// Permit2 decrements finite allowances during transfer. Any excess that
|
|
7594
7731
|
// was already live remains active after this position opens.
|
|
7595
7732
|
persistent: x.persistent,
|
|
@@ -7699,7 +7836,7 @@ async function Ho(e) {
|
|
|
7699
7836
|
}), i;
|
|
7700
7837
|
}
|
|
7701
7838
|
}
|
|
7702
|
-
async function
|
|
7839
|
+
async function Fi(e) {
|
|
7703
7840
|
const t = () => vn(e), n = e.approvalMode ?? "exact", o = () => Ht({
|
|
7704
7841
|
publicClient: e.publicClient,
|
|
7705
7842
|
token: e.token.address,
|
|
@@ -7714,7 +7851,7 @@ async function qi(e) {
|
|
|
7714
7851
|
}
|
|
7715
7852
|
const { approvalHashes: r, allowance: i } = await jr({
|
|
7716
7853
|
read: o,
|
|
7717
|
-
write: (s, l, c) =>
|
|
7854
|
+
write: (s, l, c) => qr({
|
|
7718
7855
|
provider: e.wallet.provider,
|
|
7719
7856
|
publicClient: e.publicClient,
|
|
7720
7857
|
account: e.wallet.account,
|
|
@@ -7747,7 +7884,7 @@ async function qi(e) {
|
|
|
7747
7884
|
} : Gr,
|
|
7748
7885
|
onStatus: e.onStatus
|
|
7749
7886
|
});
|
|
7750
|
-
if (e.replaceAllowance && i !== e.amount || !
|
|
7887
|
+
if (e.replaceAllowance && i !== e.amount || !Om({
|
|
7751
7888
|
currentAmount: i,
|
|
7752
7889
|
spendAmount: e.amount,
|
|
7753
7890
|
approvalMode: n
|
|
@@ -7755,7 +7892,7 @@ async function qi(e) {
|
|
|
7755
7892
|
throw new Error(`Approve ${e.token.symbol} before continuing.`);
|
|
7756
7893
|
return r.at(-1) ?? null;
|
|
7757
7894
|
}
|
|
7758
|
-
async function
|
|
7895
|
+
async function qi(e) {
|
|
7759
7896
|
var a, r;
|
|
7760
7897
|
const t = () => vn(e), n = e.approvalMode ?? "exact", o = await ot({
|
|
7761
7898
|
publicClient: e.publicClient,
|
|
@@ -7772,7 +7909,7 @@ async function Oi(e) {
|
|
|
7772
7909
|
input: e,
|
|
7773
7910
|
kind: "permit2-router",
|
|
7774
7911
|
run: async (i) => {
|
|
7775
|
-
const s = await
|
|
7912
|
+
const s = await Or({
|
|
7776
7913
|
provider: e.wallet.provider,
|
|
7777
7914
|
publicClient: e.publicClient,
|
|
7778
7915
|
account: e.wallet.account,
|
|
@@ -7803,17 +7940,17 @@ async function Oi(e) {
|
|
|
7803
7940
|
}
|
|
7804
7941
|
}), t(), await ((r = e.onAuthorizationCheckpoint) == null ? void 0 : r.call(e)), t()));
|
|
7805
7942
|
}
|
|
7806
|
-
async function
|
|
7943
|
+
async function K0(e) {
|
|
7807
7944
|
Uo(e);
|
|
7808
7945
|
const t = Vo(e), n = () => vn(t);
|
|
7809
|
-
return n(), xe(t.token.address) ? { approvalHash: null } : t.amount <= 0n && (t.approvalMode ?? "exact") !== "max" ? { approvalHash: null } : (await Ke({ provider: t.wallet.provider, chain: t.activeChain, signal: t.signal }), n(), { approvalHash: await
|
|
7946
|
+
return n(), xe(t.token.address) ? { approvalHash: null } : t.amount <= 0n && (t.approvalMode ?? "exact") !== "max" ? { approvalHash: null } : (await Ke({ provider: t.wallet.provider, chain: t.activeChain, signal: t.signal }), n(), { approvalHash: await Fi(t) });
|
|
7810
7947
|
}
|
|
7811
|
-
async function
|
|
7948
|
+
async function z0(e) {
|
|
7812
7949
|
Uo(e, !0);
|
|
7813
7950
|
const t = Vo(e), n = () => vn(t);
|
|
7814
|
-
n(), !xe(t.token.address) && (t.amount <= 0n && !t.replaceAllowance && (t.approvalMode ?? "exact") !== "max" || (await Ke({ provider: t.wallet.provider, chain: t.activeChain, signal: t.signal }), n(), await
|
|
7951
|
+
n(), !xe(t.token.address) && (t.amount <= 0n && !t.replaceAllowance && (t.approvalMode ?? "exact") !== "max" || (await Ke({ provider: t.wallet.provider, chain: t.activeChain, signal: t.signal }), n(), await qi(t)));
|
|
7815
7952
|
}
|
|
7816
|
-
async function
|
|
7953
|
+
async function Oi(e) {
|
|
7817
7954
|
var s, l;
|
|
7818
7955
|
Uo(e);
|
|
7819
7956
|
const t = Vo(e), n = () => {
|
|
@@ -7827,9 +7964,9 @@ async function Fi(e) {
|
|
|
7827
7964
|
chain: t.activeChain,
|
|
7828
7965
|
signal: t.signal
|
|
7829
7966
|
}), n();
|
|
7830
|
-
const o = await
|
|
7967
|
+
const o = await Fi(t);
|
|
7831
7968
|
if (n(), (t.permit2AuthorizationMode ?? "spending-cap") === "spending-cap")
|
|
7832
|
-
return await
|
|
7969
|
+
return await qi(t), { approvalHash: o, permit: null };
|
|
7833
7970
|
n(), (s = t.onStatus) == null || s.call(t, "signing");
|
|
7834
7971
|
const a = t.approvalMode ?? "exact", r = ot({
|
|
7835
7972
|
publicClient: t.publicClient,
|
|
@@ -7860,7 +7997,7 @@ async function Fi(e) {
|
|
|
7860
7997
|
});
|
|
7861
7998
|
return n(), await ((l = e.onAuthorizationCheckpoint) == null ? void 0 : l.call(e)), n(), { approvalHash: o, permit: i };
|
|
7862
7999
|
}
|
|
7863
|
-
async function
|
|
8000
|
+
async function G0(e) {
|
|
7864
8001
|
var n;
|
|
7865
8002
|
const t = Vm(e);
|
|
7866
8003
|
return (n = e.onStatus) == null || n.call(e, "approving"), En({
|
|
@@ -7876,7 +8013,7 @@ async function jf(e) {
|
|
|
7876
8013
|
});
|
|
7877
8014
|
}
|
|
7878
8015
|
async function Gm(e) {
|
|
7879
|
-
const t =
|
|
8016
|
+
const t = ue(e.market.chainId);
|
|
7880
8017
|
if (!t)
|
|
7881
8018
|
throw new Error(
|
|
7882
8019
|
`No trusted Aegis Engine deployment is configured for chain ${e.market.chainId}.`
|
|
@@ -7901,7 +8038,7 @@ async function Gm(e) {
|
|
|
7901
8038
|
}
|
|
7902
8039
|
async function jm(e) {
|
|
7903
8040
|
var n;
|
|
7904
|
-
const t =
|
|
8041
|
+
const t = ue(e.market.chainId);
|
|
7905
8042
|
if (!t)
|
|
7906
8043
|
throw new Error(
|
|
7907
8044
|
`No trusted Aegis Engine deployment is configured for chain ${e.market.chainId}.`
|
|
@@ -7916,7 +8053,7 @@ async function jm(e) {
|
|
|
7916
8053
|
activeChain: e.activeChain,
|
|
7917
8054
|
tx: {
|
|
7918
8055
|
to: t.vaultRegistry,
|
|
7919
|
-
data:
|
|
8056
|
+
data: bt({
|
|
7920
8057
|
abi: Ni,
|
|
7921
8058
|
functionName: "setApprovalForAll",
|
|
7922
8059
|
args: [t.aegisRouterV1, !0]
|
|
@@ -7936,7 +8073,7 @@ function Ka(e) {
|
|
|
7936
8073
|
if (t < 0n)
|
|
7937
8074
|
throw new TypeError("Engine transaction minimum validity cannot be negative.");
|
|
7938
8075
|
if (BigInt(Math.floor(Date.now() / 1e3)) + t >= e.expiresAt)
|
|
7939
|
-
throw new _(
|
|
8076
|
+
throw new _(Fm);
|
|
7940
8077
|
}
|
|
7941
8078
|
async function En(e) {
|
|
7942
8079
|
var a, r, i, s, l, c, p;
|
|
@@ -7954,7 +8091,7 @@ async function En(e) {
|
|
|
7954
8091
|
value: e.tx.value
|
|
7955
8092
|
});
|
|
7956
8093
|
} catch (d) {
|
|
7957
|
-
throw (l = e.signal) == null || l.throwIfAborted(), $m(d) ? new _(
|
|
8094
|
+
throw (l = e.signal) == null || l.throwIfAborted(), $m(d) ? new _(qm, {
|
|
7958
8095
|
kind: "rpc",
|
|
7959
8096
|
retryable: !0
|
|
7960
8097
|
}) : new _(await Km(d, e));
|
|
@@ -7978,17 +8115,17 @@ async function En(e) {
|
|
|
7978
8115
|
});
|
|
7979
8116
|
return (p = e.onStatus) == null || p.call(e, "success"), {
|
|
7980
8117
|
hash: n.transactionHash,
|
|
7981
|
-
explorerUrl:
|
|
8118
|
+
explorerUrl: wo(n.transactionHash, e.activeChain),
|
|
7982
8119
|
receipt: n,
|
|
7983
8120
|
summary: o
|
|
7984
8121
|
};
|
|
7985
8122
|
}
|
|
7986
|
-
function
|
|
8123
|
+
function j0(e) {
|
|
7987
8124
|
return e.router ? e.permit2 ? e.stateView ? e.v4StateView ? e.v4Quoter ? null : "Missing V4 quoter." : "Missing V4 StateView." : "Missing StateView." : "Missing Permit2." : "Missing engine router.";
|
|
7988
8125
|
}
|
|
7989
8126
|
const Li = /* @__PURE__ */ new WeakMap();
|
|
7990
8127
|
function Ui(e) {
|
|
7991
|
-
const t =
|
|
8128
|
+
const t = ue(e.chainId), n = vt(e.chainId);
|
|
7992
8129
|
if (!t || !n || !e.lendEnabled || e.canLend === !1)
|
|
7993
8130
|
throw new _("Balanced lending is unavailable for this market.");
|
|
7994
8131
|
if ([
|
|
@@ -8012,15 +8149,15 @@ async function za(e, t, n) {
|
|
|
8012
8149
|
return o.number === t.blockNumber && ((a = o.hash) == null ? void 0 : a.toLowerCase()) === t.blockHash.toLowerCase();
|
|
8013
8150
|
}
|
|
8014
8151
|
async function Ga(e) {
|
|
8015
|
-
var
|
|
8016
|
-
(
|
|
8152
|
+
var w, y, E, C, x, A, P;
|
|
8153
|
+
(w = e.signal) == null || w.throwIfAborted();
|
|
8017
8154
|
const t = structuredClone(e.market), { registry: n, version: o } = Ui(t);
|
|
8018
|
-
if (!er(e.owner) || k(e.owner,
|
|
8155
|
+
if (!er(e.owner) || k(e.owner, ce) || e.nativeGasReserve < 0n)
|
|
8019
8156
|
throw new _("Balanced lending requires an account and a valid native reserve.");
|
|
8020
8157
|
if (e.publicClient.chain && e.publicClient.chain.id !== t.chainId || await e.publicClient.getChainId() !== t.chainId)
|
|
8021
8158
|
throw new _("Select the market network before quoting.");
|
|
8022
8159
|
(y = e.signal) == null || y.throwIfAborted();
|
|
8023
|
-
const { fetchLendQuoteContext: a, quoteBalancedDeposit: r } = await
|
|
8160
|
+
const { fetchLendQuoteContext: a, quoteBalancedDeposit: r } = await z(), i = await a(e.publicClient, {
|
|
8024
8161
|
chainId: t.chainId,
|
|
8025
8162
|
version: o,
|
|
8026
8163
|
poolId: t.poolId
|
|
@@ -8033,24 +8170,24 @@ async function Ga(e) {
|
|
|
8033
8170
|
}), c = await Promise.all(
|
|
8034
8171
|
[t.token0, t.token1].map(async (g) => {
|
|
8035
8172
|
var ee;
|
|
8036
|
-
const M = k(g.address,
|
|
8173
|
+
const M = k(g.address, ce), [O, L] = M ? [l, (ee = e.publicClient.chain) == null ? void 0 : ee.nativeCurrency.decimals] : await Promise.all([
|
|
8037
8174
|
e.publicClient.readContract({
|
|
8038
8175
|
address: g.address,
|
|
8039
|
-
abi:
|
|
8176
|
+
abi: qn,
|
|
8040
8177
|
functionName: "balanceOf",
|
|
8041
8178
|
args: [e.owner],
|
|
8042
8179
|
blockNumber: s.blockNumber
|
|
8043
8180
|
}),
|
|
8044
8181
|
e.publicClient.readContract({
|
|
8045
8182
|
address: g.address,
|
|
8046
|
-
abi:
|
|
8183
|
+
abi: qn,
|
|
8047
8184
|
functionName: "decimals",
|
|
8048
8185
|
blockNumber: s.blockNumber
|
|
8049
8186
|
})
|
|
8050
8187
|
]);
|
|
8051
8188
|
if (L !== g.decimals)
|
|
8052
8189
|
throw new _("Token precision changed. Refresh the market before continuing.");
|
|
8053
|
-
return
|
|
8190
|
+
return O;
|
|
8054
8191
|
})
|
|
8055
8192
|
);
|
|
8056
8193
|
(C = e.signal) == null || C.throwIfAborted();
|
|
@@ -8133,7 +8270,7 @@ async function Ga(e) {
|
|
|
8133
8270
|
nativeGasReserve: e.nativeGasReserve
|
|
8134
8271
|
}), f;
|
|
8135
8272
|
}
|
|
8136
|
-
async function
|
|
8273
|
+
async function Q0(e) {
|
|
8137
8274
|
var s, l, c, p, d, m;
|
|
8138
8275
|
(s = e.signal) == null || s.throwIfAborted(), await ((l = e.onCheckpoint) == null ? void 0 : l.call(e));
|
|
8139
8276
|
const t = Li.get(e.quote);
|
|
@@ -8146,7 +8283,7 @@ async function Xf(e) {
|
|
|
8146
8283
|
[t.market.token0, t.amount0Max],
|
|
8147
8284
|
[t.market.token1, t.amount1Max]
|
|
8148
8285
|
])
|
|
8149
|
-
(p = e.signal) == null || p.throwIfAborted(), await ((d = e.onCheckpoint) == null ? void 0 : d.call(e)), await
|
|
8286
|
+
(p = e.signal) == null || p.throwIfAborted(), await ((d = e.onCheckpoint) == null ? void 0 : d.call(e)), await Oi({
|
|
8150
8287
|
wallet: e.wallet,
|
|
8151
8288
|
publicClient: e.publicClient,
|
|
8152
8289
|
activeChain: e.activeChain,
|
|
@@ -8159,8 +8296,8 @@ async function Xf(e) {
|
|
|
8159
8296
|
onStatus: e.onStatus,
|
|
8160
8297
|
onAuthorizationExecution: e.onAuthorizationExecution,
|
|
8161
8298
|
onAuthorizationCheckpoint: async () => {
|
|
8162
|
-
var f,
|
|
8163
|
-
(f = e.signal) == null || f.throwIfAborted(), await ((
|
|
8299
|
+
var f, w;
|
|
8300
|
+
(f = e.signal) == null || f.throwIfAborted(), await ((w = e.onCheckpoint) == null ? void 0 : w.call(e));
|
|
8164
8301
|
}
|
|
8165
8302
|
});
|
|
8166
8303
|
const r = await Ga({ ...n, withExecutionEvidence: !0 });
|
|
@@ -8179,7 +8316,7 @@ async function Xf(e) {
|
|
|
8179
8316
|
}) };
|
|
8180
8317
|
}
|
|
8181
8318
|
const $o = 1000000n, Qm = 5e3;
|
|
8182
|
-
function
|
|
8319
|
+
function X0(e) {
|
|
8183
8320
|
return Math.max(0, e - Qm);
|
|
8184
8321
|
}
|
|
8185
8322
|
function Wo(e) {
|
|
@@ -8203,13 +8340,13 @@ function Xm(e) {
|
|
|
8203
8340
|
function Hi(e) {
|
|
8204
8341
|
return Vi(e.debtLLatest * $o, BigInt(e.maxLtvPips));
|
|
8205
8342
|
}
|
|
8206
|
-
function
|
|
8343
|
+
function Y0(e) {
|
|
8207
8344
|
if (Wo(e), e.debtLLatest === 0n) return !0;
|
|
8208
8345
|
if (e.maxLtvPips === 0) return !1;
|
|
8209
8346
|
const t = Hi(e);
|
|
8210
8347
|
return e.idle0 * e.idle1 >= t * t;
|
|
8211
8348
|
}
|
|
8212
|
-
function
|
|
8349
|
+
function J0(e) {
|
|
8213
8350
|
Wo(e);
|
|
8214
8351
|
const t = e.side === "token0" ? e.idle0 : e.idle1;
|
|
8215
8352
|
if (t === 0n || e.debtLLatest === 0n) return t;
|
|
@@ -8219,7 +8356,7 @@ function Zf(e) {
|
|
|
8219
8356
|
const o = Hi(e), a = Vi(o * o, n);
|
|
8220
8357
|
return a >= t ? 0n : t - a;
|
|
8221
8358
|
}
|
|
8222
|
-
function
|
|
8359
|
+
function Z0(e) {
|
|
8223
8360
|
if (Wo(e), e.withdrawAmount < 0n)
|
|
8224
8361
|
throw new RangeError("Engine withdrawal amount must be non-negative.");
|
|
8225
8362
|
if (e.debtLLatest === 0n) return null;
|
|
@@ -8263,13 +8400,13 @@ function Wi(e) {
|
|
|
8263
8400
|
const t = e;
|
|
8264
8401
|
return t.schemaVersion === "1" && typeof t.chainId == "number" && Number.isSafeInteger(t.chainId) && t.chainId > 0 && typeof t.account == "string" && /^0x[0-9a-fA-F]{40}$/.test(t.account) && typeof t.marketId == "string" && t.marketId.length > 0 && typeof t.poolId == "string" && /^0x[0-9a-fA-F]{64}$/.test(t.poolId) && typeof t.txHash == "string" && /^0x[0-9a-fA-F]{64}$/.test(t.txHash) && (t.direction === "long" || t.direction === "short") && typeof t.averageLeverage == "number" && Number.isFinite(t.averageLeverage) && t.averageLeverage > 1 && typeof t.targetPrice == "number" && Number.isFinite(t.targetPrice) && t.targetPrice > 0 && typeof t.horizonSeconds == "number" && Number.isSafeInteger(t.horizonSeconds) && t.horizonSeconds >= 0 && typeof t.recordedAt == "string" && Number.isFinite(Date.parse(t.recordedAt));
|
|
8265
8402
|
}
|
|
8266
|
-
function
|
|
8403
|
+
function ef(e) {
|
|
8267
8404
|
return Wi(e);
|
|
8268
8405
|
}
|
|
8269
8406
|
function Zm(e, t, n, o, a) {
|
|
8270
8407
|
return a.find((r) => Wi(r) && r.chainId === e.chainId && k(r.account, e.account) && Z(r.poolId, e.poolId) && $i(r.txHash, n) && r.direction === o && (t === null || $t(r.marketId, t))) ?? null;
|
|
8271
8408
|
}
|
|
8272
|
-
function
|
|
8409
|
+
function tf(e, t, n = []) {
|
|
8273
8410
|
var x, A, P;
|
|
8274
8411
|
let o, a;
|
|
8275
8412
|
try {
|
|
@@ -8307,12 +8444,12 @@ function n0(e, t, n = []) {
|
|
|
8307
8444
|
(g) => g.kind === "idle_modified"
|
|
8308
8445
|
);
|
|
8309
8446
|
if (h.length !== 1 || f.length !== 2) return null;
|
|
8310
|
-
const
|
|
8311
|
-
if (
|
|
8312
|
-
const y =
|
|
8447
|
+
const w = _n(f[0], "negative");
|
|
8448
|
+
if (w === null) return null;
|
|
8449
|
+
const y = w === 0 ? 1 : 0;
|
|
8313
8450
|
if (_n(h[0], "positive") !== y || _n(f[1], "positive") !== y)
|
|
8314
8451
|
return null;
|
|
8315
|
-
const E =
|
|
8452
|
+
const E = w === 1 ? "long" : "short", C = Zm(e, r, s.txHash, E, n);
|
|
8316
8453
|
return {
|
|
8317
8454
|
kind: "trade",
|
|
8318
8455
|
vaultId: a.toString(),
|
|
@@ -8336,26 +8473,26 @@ function n0(e, t, n = []) {
|
|
|
8336
8473
|
source: C ? "indexed-actions+stored-intent" : "indexed-actions"
|
|
8337
8474
|
};
|
|
8338
8475
|
}
|
|
8339
|
-
const Ki = /* @__PURE__ */ new Set(["1", "56", "130", "8453", "4663"]), ep =
|
|
8476
|
+
const Ki = /* @__PURE__ */ new Set(["1", "56", "130", "8453", "4663"]), ep = b().int().positive().refine((e) => Ki.has(String(e))), Ko = S().regex(/^0x[0-9a-fA-F]{40}$/), $e = S().regex(/^0x[0-9a-fA-F]{64}$/), Qa = S().datetime(), Mt = /^(?:0|[1-9][0-9]*)(?:\.[0-9]*[1-9])?$/, tp = ["1d", "7d", "30d", "90d", "180d"], np = ["5m", "1h", "1d"], zi = { "5m": 300, "1h": 3600, "1d": 86400 }, Gi = {
|
|
8340
8477
|
"1d": { resolution: "5m", windowSeconds: 86400, bucketCount: 288 },
|
|
8341
8478
|
"7d": { resolution: "1h", windowSeconds: 604800, bucketCount: 168 },
|
|
8342
8479
|
"30d": { resolution: "1d", windowSeconds: 2592e3, bucketCount: 30 },
|
|
8343
8480
|
"90d": { resolution: "1d", windowSeconds: 7776e3, bucketCount: 90 },
|
|
8344
8481
|
"180d": { resolution: "1d", windowSeconds: 15552e3, bucketCount: 180 }
|
|
8345
|
-
}, ji =
|
|
8482
|
+
}, ji = H(tp), op = H(np);
|
|
8346
8483
|
T({
|
|
8347
8484
|
window: ji.default("1d"),
|
|
8348
|
-
basis:
|
|
8485
|
+
basis: H(["pool", "token_market_reference"]).default("pool")
|
|
8349
8486
|
});
|
|
8350
8487
|
const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must be a canonical Engine market id").refine(
|
|
8351
8488
|
(e) => Ki.has(e.split("_")[1] ?? ""),
|
|
8352
8489
|
"Unsupported chainId"
|
|
8353
|
-
), ap =
|
|
8490
|
+
), ap = H(["uniswap_v4_subgraph", "pool_manager_rpc"]), rp = H([
|
|
8354
8491
|
"ready",
|
|
8355
8492
|
"warming_up",
|
|
8356
8493
|
"source_unavailable",
|
|
8357
8494
|
"reorg_detected"
|
|
8358
|
-
]), ip =
|
|
8495
|
+
]), ip = H([
|
|
8359
8496
|
"ENGINE-CANDLE-SOURCE-001",
|
|
8360
8497
|
"ENGINE-CANDLE-SOURCE-002",
|
|
8361
8498
|
"ENGINE-CANDLE-SOURCE-003",
|
|
@@ -8366,24 +8503,24 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8366
8503
|
"ENGINE-CANDLE-REORG-001"
|
|
8367
8504
|
]), an = T({
|
|
8368
8505
|
address: Ko,
|
|
8369
|
-
decimals:
|
|
8506
|
+
decimals: b().int().min(0).max(255)
|
|
8370
8507
|
}).strict(), Xa = T({
|
|
8371
|
-
blockNumber:
|
|
8508
|
+
blockNumber: b().int().nonnegative(),
|
|
8372
8509
|
blockHash: $e.nullable(),
|
|
8373
8510
|
transactionHash: $e,
|
|
8374
|
-
logIndex:
|
|
8511
|
+
logIndex: b().int().nonnegative()
|
|
8375
8512
|
}).strict(), Qi = {
|
|
8376
|
-
t:
|
|
8377
|
-
open:
|
|
8378
|
-
high:
|
|
8379
|
-
low:
|
|
8380
|
-
close:
|
|
8513
|
+
t: b().int().nonnegative(),
|
|
8514
|
+
open: b().positive(),
|
|
8515
|
+
high: b().positive(),
|
|
8516
|
+
low: b().positive(),
|
|
8517
|
+
close: b().positive(),
|
|
8381
8518
|
volumeToken0: S().regex(Mt),
|
|
8382
8519
|
volumeToken1: S().regex(Mt)
|
|
8383
8520
|
}, Xi = (e) => e.low <= Math.min(e.open, e.close) && e.high >= Math.max(e.open, e.close) && e.low <= e.high, sp = T({
|
|
8384
8521
|
...Qi,
|
|
8385
8522
|
aggregation: B("exact_swaps"),
|
|
8386
|
-
swapCount:
|
|
8523
|
+
swapCount: b().int().positive(),
|
|
8387
8524
|
provenance: T({
|
|
8388
8525
|
firstSwap: Xa,
|
|
8389
8526
|
lastSwap: Xa
|
|
@@ -8395,7 +8532,7 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8395
8532
|
}), cp = T({
|
|
8396
8533
|
...Qi,
|
|
8397
8534
|
aggregation: B("uniswap_pool_aggregate"),
|
|
8398
|
-
txCount:
|
|
8535
|
+
txCount: b().int().nonnegative(),
|
|
8399
8536
|
volumeUSD: S().regex(Mt).optional(),
|
|
8400
8537
|
feesUSD: S().regex(Mt).optional(),
|
|
8401
8538
|
tvlUSD: S().regex(Mt).optional()
|
|
@@ -8405,22 +8542,22 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8405
8542
|
sp,
|
|
8406
8543
|
cp
|
|
8407
8544
|
]), dp = T({
|
|
8408
|
-
requestedFrom:
|
|
8409
|
-
requestedTo:
|
|
8410
|
-
coverageStart:
|
|
8411
|
-
completedThrough:
|
|
8412
|
-
expectedBucketCount:
|
|
8413
|
-
completeBucketCount:
|
|
8545
|
+
requestedFrom: b().int().nonnegative(),
|
|
8546
|
+
requestedTo: b().int().nonnegative(),
|
|
8547
|
+
coverageStart: b().int().nonnegative(),
|
|
8548
|
+
completedThrough: b().int().nonnegative(),
|
|
8549
|
+
expectedBucketCount: b().int().min(1).max(288),
|
|
8550
|
+
completeBucketCount: b().int().min(0).max(288)
|
|
8414
8551
|
}).strict().superRefine((e, t) => {
|
|
8415
8552
|
e.coverageStart === 0 && e.completedThrough === 0 || e.coverageStart > 0 && e.completedThrough > e.coverageStart || t.addIssue({ code: "custom", message: "Invalid candle coverage" });
|
|
8416
8553
|
}), up = T({
|
|
8417
|
-
from:
|
|
8418
|
-
to:
|
|
8419
|
-
reason:
|
|
8554
|
+
from: b().int().nonnegative(),
|
|
8555
|
+
to: b().int().nonnegative(),
|
|
8556
|
+
reason: H(["indexing_gap", "invalid_row"])
|
|
8420
8557
|
}).strict(), mp = T({
|
|
8421
|
-
blockNumber:
|
|
8558
|
+
blockNumber: b().int().nonnegative().nullable(),
|
|
8422
8559
|
blockHash: $e.nullable(),
|
|
8423
|
-
timestamp:
|
|
8560
|
+
timestamp: b().int().nonnegative().nullable()
|
|
8424
8561
|
}).strict().superRefine((e, t) => {
|
|
8425
8562
|
const n = [e.blockNumber, e.blockHash, e.timestamp].filter(
|
|
8426
8563
|
(o) => o === null
|
|
@@ -8428,12 +8565,12 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8428
8565
|
n !== 0 && n !== 3 && t.addIssue({ code: "custom", message: "Partial as-of provenance" });
|
|
8429
8566
|
}), pp = T({
|
|
8430
8567
|
status: rp,
|
|
8431
|
-
lastProcessedBlockNumber:
|
|
8568
|
+
lastProcessedBlockNumber: b().int().nonnegative().nullable(),
|
|
8432
8569
|
lastProcessedBlockHash: $e.nullable(),
|
|
8433
|
-
confirmationDepth:
|
|
8570
|
+
confirmationDepth: b().int().nonnegative(),
|
|
8434
8571
|
observedAt: Qa,
|
|
8435
8572
|
updatedAt: Qa,
|
|
8436
|
-
warnings:
|
|
8573
|
+
warnings: F(ip).max(8)
|
|
8437
8574
|
}).strict().superRefine((e, t) => {
|
|
8438
8575
|
e.lastProcessedBlockNumber === null != (e.lastProcessedBlockHash === null) && t.addIssue({ code: "custom", message: "Partial cursor provenance" });
|
|
8439
8576
|
}), rn = T({
|
|
@@ -8447,19 +8584,19 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8447
8584
|
orientation: B("quote_per_base"),
|
|
8448
8585
|
resolution: op,
|
|
8449
8586
|
window: ji,
|
|
8450
|
-
status:
|
|
8451
|
-
candles:
|
|
8452
|
-
candleCount:
|
|
8587
|
+
status: H(["ready", "partial", "no_data"]),
|
|
8588
|
+
candles: F(lp).max(288),
|
|
8589
|
+
candleCount: b().int().min(0).max(288),
|
|
8453
8590
|
priceReference: T({
|
|
8454
8591
|
kind: B("pool_state"),
|
|
8455
|
-
price:
|
|
8456
|
-
blockNumber:
|
|
8592
|
+
price: b().finite().positive(),
|
|
8593
|
+
blockNumber: b().int().nonnegative(),
|
|
8457
8594
|
blockHash: $e,
|
|
8458
|
-
timestamp:
|
|
8595
|
+
timestamp: b().int().nonnegative(),
|
|
8459
8596
|
observedAt: S().datetime()
|
|
8460
8597
|
}).strict().nullable().optional(),
|
|
8461
8598
|
coverage: dp,
|
|
8462
|
-
gaps:
|
|
8599
|
+
gaps: F(up).max(288),
|
|
8463
8600
|
source: ap,
|
|
8464
8601
|
asOf: mp,
|
|
8465
8602
|
freshness: pp
|
|
@@ -8532,11 +8669,11 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8532
8669
|
code: "custom",
|
|
8533
8670
|
message: "RPC candle provenance requires block hashes"
|
|
8534
8671
|
});
|
|
8535
|
-
for (const
|
|
8536
|
-
e.asOf.blockNumber !== null && e.asOf.blockHash !== null &&
|
|
8672
|
+
for (const w of [h, f])
|
|
8673
|
+
e.asOf.blockNumber !== null && e.asOf.blockHash !== null && w.blockNumber === e.asOf.blockNumber && w.blockHash !== null && w.blockHash !== e.asOf.blockHash && t.addIssue({
|
|
8537
8674
|
code: "custom",
|
|
8538
8675
|
message: "Swap block hash disagrees with source head"
|
|
8539
|
-
}), e.freshness.lastProcessedBlockNumber !== null && e.freshness.lastProcessedBlockHash !== null &&
|
|
8676
|
+
}), e.freshness.lastProcessedBlockNumber !== null && e.freshness.lastProcessedBlockHash !== null && w.blockNumber === e.freshness.lastProcessedBlockNumber && w.blockHash !== null && w.blockHash !== e.freshness.lastProcessedBlockHash && t.addIssue({
|
|
8540
8677
|
code: "custom",
|
|
8541
8678
|
message: "Swap block hash disagrees with source cursor"
|
|
8542
8679
|
});
|
|
@@ -8549,22 +8686,22 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8549
8686
|
message: "Null provenance is only valid before the first source read"
|
|
8550
8687
|
});
|
|
8551
8688
|
}), oo = T({
|
|
8552
|
-
blockNumber:
|
|
8689
|
+
blockNumber: b().int().positive(),
|
|
8553
8690
|
blockHash: $e,
|
|
8554
|
-
timestamp:
|
|
8691
|
+
timestamp: b().int().positive(),
|
|
8555
8692
|
observedAt: S().datetime()
|
|
8556
8693
|
}).strict(), Ya = T({
|
|
8557
|
-
role:
|
|
8558
|
-
chainId:
|
|
8694
|
+
role: H(["base", "quote"]),
|
|
8695
|
+
chainId: b().int().positive(),
|
|
8559
8696
|
address: Ko,
|
|
8560
|
-
decimals:
|
|
8561
|
-
resolution:
|
|
8562
|
-
sourceDataset:
|
|
8563
|
-
status:
|
|
8697
|
+
decimals: b().int().min(0).max(255),
|
|
8698
|
+
resolution: H(["1h", "1d"]),
|
|
8699
|
+
sourceDataset: H(["TokenHourData", "TokenDayData"]),
|
|
8700
|
+
status: H(["ready", "warming_up", "source_unavailable"]),
|
|
8564
8701
|
independence: B("unknown"),
|
|
8565
8702
|
independenceReason: B("historical_price_venue_untracked"),
|
|
8566
|
-
coverageStart:
|
|
8567
|
-
completedThrough:
|
|
8703
|
+
coverageStart: b().int().nonnegative(),
|
|
8704
|
+
completedThrough: b().int().nonnegative(),
|
|
8568
8705
|
sourceHead: oo.nullable()
|
|
8569
8706
|
}).strict(), Yi = T({
|
|
8570
8707
|
schemaVersion: B("1"),
|
|
@@ -8573,39 +8710,39 @@ const zo = S().max(90).regex(/^evm_[1-9][0-9]{0,15}_0x[0-9a-fA-F]{64}$/, "Must b
|
|
|
8573
8710
|
method: B("ratio_of_bucket_closes"),
|
|
8574
8711
|
sampleSynchronization: B("bucket_only"),
|
|
8575
8712
|
usage: B("display_only"),
|
|
8576
|
-
chainId:
|
|
8713
|
+
chainId: b().int().positive(),
|
|
8577
8714
|
marketId: zo,
|
|
8578
8715
|
poolId: $e,
|
|
8579
8716
|
baseAsset: an,
|
|
8580
8717
|
quoteAsset: an,
|
|
8581
8718
|
orientation: B("quote_per_base"),
|
|
8582
|
-
resolution:
|
|
8583
|
-
window:
|
|
8584
|
-
status:
|
|
8585
|
-
points:
|
|
8719
|
+
resolution: H(["1h", "1d"]),
|
|
8720
|
+
window: H(["7d", "30d", "90d", "180d"]),
|
|
8721
|
+
status: H(["ready", "partial", "no_data"]),
|
|
8722
|
+
points: F(
|
|
8586
8723
|
T({
|
|
8587
|
-
t:
|
|
8588
|
-
value:
|
|
8724
|
+
t: b().int().nonnegative(),
|
|
8725
|
+
value: b().finite().positive(),
|
|
8589
8726
|
baseCloseUsd: S().regex(/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/),
|
|
8590
8727
|
quoteCloseUsd: S().regex(/^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$/),
|
|
8591
8728
|
baseSource: oo,
|
|
8592
8729
|
quoteSource: oo
|
|
8593
8730
|
}).strict()
|
|
8594
8731
|
).max(180),
|
|
8595
|
-
pointCount:
|
|
8732
|
+
pointCount: b().int().min(0).max(180),
|
|
8596
8733
|
components: gs([Ya, Ya]),
|
|
8597
|
-
gaps:
|
|
8734
|
+
gaps: F(
|
|
8598
8735
|
T({
|
|
8599
|
-
from:
|
|
8600
|
-
to:
|
|
8601
|
-
reason:
|
|
8736
|
+
from: b().int().nonnegative(),
|
|
8737
|
+
to: b().int().positive(),
|
|
8738
|
+
reason: H(["missing_component", "invalid_component", "outside_coverage"])
|
|
8602
8739
|
}).strict()
|
|
8603
8740
|
).max(180),
|
|
8604
8741
|
coverage: T({
|
|
8605
|
-
requestedFrom:
|
|
8606
|
-
requestedTo:
|
|
8607
|
-
expectedBucketCount:
|
|
8608
|
-
observedPairCount:
|
|
8742
|
+
requestedFrom: b().int().nonnegative(),
|
|
8743
|
+
requestedTo: b().int().positive(),
|
|
8744
|
+
expectedBucketCount: b().int().min(1).max(180),
|
|
8745
|
+
observedPairCount: b().int().min(0).max(180)
|
|
8609
8746
|
}).strict(),
|
|
8610
8747
|
source: B("uniswap_v4_subgraph"),
|
|
8611
8748
|
attribution: T({
|
|
@@ -8619,7 +8756,7 @@ po([
|
|
|
8619
8756
|
]);
|
|
8620
8757
|
const en = S().regex(/^(0|[1-9][0-9]*)$/).max(78).refine(
|
|
8621
8758
|
(e) => /^(0|[1-9][0-9]*)$/.test(e) && e.length <= 78 && BigInt(e) < 1n << 256n
|
|
8622
|
-
), re =
|
|
8759
|
+
), re = b().int().nonnegative().max(Number.MAX_SAFE_INTEGER), Ja = b().nonnegative().nullable(), fp = Vt("status", [
|
|
8623
8760
|
T({
|
|
8624
8761
|
status: B("verified"),
|
|
8625
8762
|
basis: B("irm-accrual-preview"),
|
|
@@ -8632,7 +8769,7 @@ const en = S().regex(/^(0|[1-9][0-9]*)$/).max(78).refine(
|
|
|
8632
8769
|
}).strict(),
|
|
8633
8770
|
T({
|
|
8634
8771
|
status: B("unavailable"),
|
|
8635
|
-
reason:
|
|
8772
|
+
reason: H(["legacy-unpinned", "invalid-provenance"])
|
|
8636
8773
|
}).strict()
|
|
8637
8774
|
]), hp = T({
|
|
8638
8775
|
t: re,
|
|
@@ -8641,19 +8778,19 @@ const en = S().regex(/^(0|[1-9][0-9]*)$/).max(78).refine(
|
|
|
8641
8778
|
borrowAprPct: Ja,
|
|
8642
8779
|
lendAprPct: Ja,
|
|
8643
8780
|
lendingRateBasis: B("simple-borrow-interest-apr"),
|
|
8644
|
-
utilizationPct:
|
|
8781
|
+
utilizationPct: b().min(0).max(100).nullable(),
|
|
8645
8782
|
ratePerSecondWad: en.nullable(),
|
|
8646
8783
|
fullUtilizationRate: en.nullable(),
|
|
8647
8784
|
sharePriceWad: en.nullable(),
|
|
8648
8785
|
rateObservation: fp
|
|
8649
|
-
}).strict(),
|
|
8786
|
+
}).strict(), bp = T({
|
|
8650
8787
|
schemaVersion: B("1"),
|
|
8651
8788
|
marketId: S().regex(/^evm_[0-9]+_0x[0-9a-fA-F]+$/),
|
|
8652
8789
|
resolution: B("12h"),
|
|
8653
|
-
window:
|
|
8654
|
-
status:
|
|
8790
|
+
window: H(["7d", "30d", "60d"]),
|
|
8791
|
+
status: H(["ready", "partial", "warming_up", "no_data"]),
|
|
8655
8792
|
pointCount: re,
|
|
8656
|
-
points:
|
|
8793
|
+
points: F(hp).max(121),
|
|
8657
8794
|
updatedAt: S().datetime().nullable(),
|
|
8658
8795
|
coverage: T({
|
|
8659
8796
|
fromBucket: re,
|
|
@@ -8662,21 +8799,21 @@ const en = S().regex(/^(0|[1-9][0-9]*)$/).max(78).refine(
|
|
|
8662
8799
|
firstObservedBucket: re.nullable(),
|
|
8663
8800
|
leadingMissingBucketCount: re,
|
|
8664
8801
|
presentClosedBuckets: re,
|
|
8665
|
-
missingBuckets:
|
|
8666
|
-
missingRateBuckets:
|
|
8802
|
+
missingBuckets: F(re).max(120),
|
|
8803
|
+
missingRateBuckets: F(re).max(120),
|
|
8667
8804
|
verifiedRatePoints: re,
|
|
8668
8805
|
legacyRatePoints: re,
|
|
8669
8806
|
invalidRows: re
|
|
8670
8807
|
}).strict()
|
|
8671
|
-
}).strict(),
|
|
8808
|
+
}).strict(), wp = po([
|
|
8672
8809
|
rn,
|
|
8673
8810
|
T({
|
|
8674
8811
|
schemaVersion: B("1"),
|
|
8675
8812
|
history: rn,
|
|
8676
|
-
segments:
|
|
8677
|
-
from:
|
|
8678
|
-
to:
|
|
8679
|
-
price:
|
|
8813
|
+
segments: F(T({
|
|
8814
|
+
from: b().int().nonnegative(),
|
|
8815
|
+
to: b().int().nonnegative(),
|
|
8816
|
+
price: b().finite().positive()
|
|
8680
8817
|
}).strict()).max(289)
|
|
8681
8818
|
}).strict()
|
|
8682
8819
|
]).superRefine((e, t) => {
|
|
@@ -8691,22 +8828,22 @@ const en = S().regex(/^(0|[1-9][0-9]*)$/).max(78).refine(
|
|
|
8691
8828
|
o = a.to;
|
|
8692
8829
|
}
|
|
8693
8830
|
});
|
|
8694
|
-
class
|
|
8831
|
+
class le extends Error {
|
|
8695
8832
|
constructor(n, o = 503, a = null) {
|
|
8696
8833
|
super("Engine market data is unavailable.");
|
|
8697
|
-
|
|
8834
|
+
j(this, "name", "AegisEngineMarketDataReadError");
|
|
8698
8835
|
this.code = n, this.status = o, this.retryAfterSeconds = a;
|
|
8699
8836
|
}
|
|
8700
8837
|
}
|
|
8701
8838
|
function ie() {
|
|
8702
|
-
throw new
|
|
8839
|
+
throw new le("invalid-response");
|
|
8703
8840
|
}
|
|
8704
8841
|
const kp = 3e4, ao = 16, Ji = ge({
|
|
8705
8842
|
ttlMs: kp,
|
|
8706
8843
|
maxEntries: ao
|
|
8707
8844
|
}), Ye = /* @__PURE__ */ new Map();
|
|
8708
8845
|
let ro = 0, Nn = 0;
|
|
8709
|
-
function
|
|
8846
|
+
function nf() {
|
|
8710
8847
|
Ji.clear(), Ye.clear(), ro++;
|
|
8711
8848
|
}
|
|
8712
8849
|
function yn(e, t, n, o) {
|
|
@@ -8724,7 +8861,7 @@ function yn(e, t, n, o) {
|
|
|
8724
8861
|
d.until <= Date.now() && Ye.delete(p);
|
|
8725
8862
|
const i = Ye.get(r);
|
|
8726
8863
|
if (i && i.until > Date.now())
|
|
8727
|
-
return Promise.reject(new
|
|
8864
|
+
return Promise.reject(new le(
|
|
8728
8865
|
i.error.code,
|
|
8729
8866
|
i.error.status,
|
|
8730
8867
|
Math.ceil((i.until - Date.now()) / 1e3)
|
|
@@ -8732,12 +8869,12 @@ function yn(e, t, n, o) {
|
|
|
8732
8869
|
Ye.delete(r);
|
|
8733
8870
|
const s = ro, l = Ji.read(r, async () => {
|
|
8734
8871
|
if (Nn >= ao || Ye.size >= ao)
|
|
8735
|
-
throw new
|
|
8872
|
+
throw new le("unavailable", 503, 30);
|
|
8736
8873
|
Nn++;
|
|
8737
8874
|
try {
|
|
8738
8875
|
return await o({ ...e, source: a, signal: void 0 });
|
|
8739
8876
|
} catch (p) {
|
|
8740
|
-
const d = p instanceof
|
|
8877
|
+
const d = p instanceof le ? p : p instanceof Error && p.name === "TimeoutError" ? new le("unavailable", 504) : null;
|
|
8741
8878
|
if (s === ro && d && (d.status === 404 || d.status === 408 || d.status === 429 || d.status >= 500) && d.code === "unavailable") {
|
|
8742
8879
|
const m = Math.max(d.status === 404 ? 60 : 30, d.retryAfterSeconds ?? 0);
|
|
8743
8880
|
Ye.set(r, { until: Date.now() + m * 1e3, error: d });
|
|
@@ -8757,7 +8894,7 @@ function Go(e, t) {
|
|
|
8757
8894
|
async function In(e, t, n, o) {
|
|
8758
8895
|
var c, p, d;
|
|
8759
8896
|
if (!zo.safeParse(e.marketId).success)
|
|
8760
|
-
throw new
|
|
8897
|
+
throw new le("invalid-query", 400);
|
|
8761
8898
|
const a = e.source.timeoutMs ?? 15e3;
|
|
8762
8899
|
if (!Number.isFinite(a) || a <= 0 || a > 12e4)
|
|
8763
8900
|
throw new RangeError("Market request timeout must be between 1 and 120000 milliseconds.");
|
|
@@ -8782,7 +8919,7 @@ async function In(e, t, n, o) {
|
|
|
8782
8919
|
);
|
|
8783
8920
|
if (!u.ok)
|
|
8784
8921
|
throw (c = u.body) == null || c.cancel().catch(() => {
|
|
8785
|
-
}), new
|
|
8922
|
+
}), new le(
|
|
8786
8923
|
"unavailable",
|
|
8787
8924
|
u.status,
|
|
8788
8925
|
mo(u.headers.get("retry-after"), 300)
|
|
@@ -8790,18 +8927,18 @@ async function In(e, t, n, o) {
|
|
|
8790
8927
|
const h = 512 * 1024;
|
|
8791
8928
|
if (Number(u.headers.get("content-length")) > h)
|
|
8792
8929
|
throw (p = u.body) == null || p.cancel().catch(() => {
|
|
8793
|
-
}), new
|
|
8930
|
+
}), new le("response-limit");
|
|
8794
8931
|
s = (d = u.body) == null ? void 0 : d.getReader(), s || ie(), r == null || r.addEventListener("abort", l, { once: !0 });
|
|
8795
8932
|
const f = [];
|
|
8796
|
-
let
|
|
8933
|
+
let w = 0;
|
|
8797
8934
|
for (; ; ) {
|
|
8798
8935
|
r == null || r.throwIfAborted();
|
|
8799
8936
|
const A = await s.read();
|
|
8800
8937
|
if (r == null || r.throwIfAborted(), A.done) break;
|
|
8801
|
-
if (
|
|
8938
|
+
if (w += A.value.byteLength, w > h) throw new le("response-limit");
|
|
8802
8939
|
f.push(A.value);
|
|
8803
8940
|
}
|
|
8804
|
-
const y = new Uint8Array(
|
|
8941
|
+
const y = new Uint8Array(w);
|
|
8805
8942
|
let E = 0;
|
|
8806
8943
|
for (const A of f)
|
|
8807
8944
|
y.set(A, E), E += A.length;
|
|
@@ -8814,7 +8951,7 @@ async function In(e, t, n, o) {
|
|
|
8814
8951
|
const x = o.safeParse(C);
|
|
8815
8952
|
return x.success || ie(), x.data;
|
|
8816
8953
|
} catch (m) {
|
|
8817
|
-
throw r == null || r.throwIfAborted(), m instanceof
|
|
8954
|
+
throw r == null || r.throwIfAborted(), m instanceof le ? m : new le("unavailable");
|
|
8818
8955
|
} finally {
|
|
8819
8956
|
r == null || r.removeEventListener("abort", l), l(), s == null || s.releaseLock(), i();
|
|
8820
8957
|
}
|
|
@@ -8827,7 +8964,7 @@ function jo(e, t, n) {
|
|
|
8827
8964
|
async function vp(e) {
|
|
8828
8965
|
const t = e.window ?? "1d";
|
|
8829
8966
|
if (!["1d", "7d", "30d", "90d", "180d"].includes(t))
|
|
8830
|
-
throw new
|
|
8967
|
+
throw new le("invalid-query", 400);
|
|
8831
8968
|
const n = await In(
|
|
8832
8969
|
e,
|
|
8833
8970
|
"/v1/engine/markets/{marketId}/candles",
|
|
@@ -8839,7 +8976,7 @@ async function vp(e) {
|
|
|
8839
8976
|
async function Ep(e) {
|
|
8840
8977
|
const t = e.window ?? "7d";
|
|
8841
8978
|
if (!["7d", "30d", "90d", "180d"].includes(t))
|
|
8842
|
-
throw new
|
|
8979
|
+
throw new le("invalid-query", 400);
|
|
8843
8980
|
const n = await In(
|
|
8844
8981
|
e,
|
|
8845
8982
|
"/v1/engine/markets/{marketId}/candles",
|
|
@@ -8875,12 +9012,12 @@ async function Ip(e) {
|
|
|
8875
9012
|
var u, h;
|
|
8876
9013
|
const t = e.window ?? "30d";
|
|
8877
9014
|
if (!["7d", "30d", "60d"].includes(t))
|
|
8878
|
-
throw new
|
|
9015
|
+
throw new le("invalid-query", 400);
|
|
8879
9016
|
const n = await In(
|
|
8880
9017
|
e,
|
|
8881
9018
|
"/v1/engine/markets/{marketId}/rates/history",
|
|
8882
9019
|
{ window: t },
|
|
8883
|
-
|
|
9020
|
+
bp
|
|
8884
9021
|
);
|
|
8885
9022
|
(n.marketId !== e.marketId || n.window !== t) && ie();
|
|
8886
9023
|
const o = n.coverage, a = Number(t.slice(0, -1)) * 2, r = 43200;
|
|
@@ -8891,15 +9028,15 @@ async function Ip(e) {
|
|
|
8891
9028
|
(f.t <= i || f.t % r || f.t < o.fromBucket || f.t > o.throughClosedBucket + r || Date.parse(f.observedAt) / 1e3 < f.t || Date.parse(f.observedAt) / 1e3 >= f.t + r || f.rateObservation.status === "verified" && (f.rateObservation.observedAt !== f.observedAt || f.ratePerSecondWad === null || BigInt(f.rateObservation.elapsedSeconds) > BigInt(Math.floor(Date.parse(f.observedAt) / 1e3)))) && ie(), s.set(f.t, f), i = f.t;
|
|
8892
9029
|
const l = [], c = [];
|
|
8893
9030
|
for (let f = o.fromBucket; f <= o.throughClosedBucket; f += r) {
|
|
8894
|
-
const
|
|
8895
|
-
|
|
9031
|
+
const w = s.get(f);
|
|
9032
|
+
w || l.push(f), (!w || w.borrowAprPct === null || w.lendAprPct === null || w.ratePerSecondWad === null) && c.push(f);
|
|
8896
9033
|
}
|
|
8897
9034
|
const p = ((h = n.points[0]) == null ? void 0 : h.t) ?? null, d = p === null ? 0 : l.filter((f) => f < p).length, m = n.pointCount === 0 ? "no_data" : n.pointCount === 1 ? "warming_up" : c.length > d || o.invalidRows ? "partial" : "ready";
|
|
8898
9035
|
return (JSON.stringify(o.missingBuckets) !== JSON.stringify(l) || JSON.stringify(o.missingRateBuckets) !== JSON.stringify(c) || o.presentClosedBuckets !== a - l.length || o.firstObservedBucket !== p || o.leadingMissingBucketCount !== d || n.status !== m || o.verifiedRatePoints !== n.points.filter((f) => f.rateObservation.status === "verified").length || o.legacyRatePoints !== n.points.filter(
|
|
8899
9036
|
(f) => f.rateObservation.status === "unavailable" && f.rateObservation.reason === "legacy-unpinned"
|
|
8900
9037
|
).length) && ie(), n;
|
|
8901
9038
|
}
|
|
8902
|
-
async function
|
|
9039
|
+
async function of(e) {
|
|
8903
9040
|
const t = e.window ?? "1d", n = await yn(
|
|
8904
9041
|
e,
|
|
8905
9042
|
"pool",
|
|
@@ -8908,26 +9045,26 @@ async function a0(e) {
|
|
|
8908
9045
|
);
|
|
8909
9046
|
return Go(e.expectedAssets, n), n;
|
|
8910
9047
|
}
|
|
8911
|
-
async function
|
|
9048
|
+
async function af(e) {
|
|
8912
9049
|
const t = await yn(e, "pool_price_line", "1d", async (n) => {
|
|
8913
9050
|
const o = await In(
|
|
8914
9051
|
n,
|
|
8915
9052
|
"/v1/engine/markets/{marketId}/candles",
|
|
8916
9053
|
{ window: "1d", basis: "pool", format: "price_line" },
|
|
8917
|
-
|
|
9054
|
+
wp
|
|
8918
9055
|
), a = "history" in o ? o.history : o;
|
|
8919
9056
|
return jo(n, a, "1d"), "segments" in o ? { ...a, priceSegments: o.segments } : a;
|
|
8920
9057
|
});
|
|
8921
9058
|
return Go(e.expectedAssets, t), t;
|
|
8922
9059
|
}
|
|
8923
|
-
function
|
|
9060
|
+
function rf(e) {
|
|
8924
9061
|
return e.freshness.status === "reorg_detected" ? [] : e.priceSegments ? e.priceSegments : e.candles.flatMap((t, n) => {
|
|
8925
9062
|
var i;
|
|
8926
9063
|
const o = t.t + zi[e.resolution], a = e.gaps.find((s) => s.to > o), r = Math.min(e.coverage.completedThrough, ((i = e.candles[n + 1]) == null ? void 0 : i.t) ?? 1 / 0, (a == null ? void 0 : a.from) ?? 1 / 0);
|
|
8927
9064
|
return r >= o ? [{ from: o, to: r, price: t.close }] : [];
|
|
8928
9065
|
});
|
|
8929
9066
|
}
|
|
8930
|
-
async function
|
|
9067
|
+
async function sf(e) {
|
|
8931
9068
|
const t = e.window ?? "7d", n = await yn(
|
|
8932
9069
|
e,
|
|
8933
9070
|
"token_market_reference",
|
|
@@ -8936,7 +9073,7 @@ async function s0(e) {
|
|
|
8936
9073
|
);
|
|
8937
9074
|
return Go(e.expectedAssets, n), n;
|
|
8938
9075
|
}
|
|
8939
|
-
async function
|
|
9076
|
+
async function cf(e) {
|
|
8940
9077
|
const t = e.window ?? "30d";
|
|
8941
9078
|
return yn(
|
|
8942
9079
|
e,
|
|
@@ -8945,7 +9082,7 @@ async function c0(e) {
|
|
|
8945
9082
|
(n) => Ip({ ...n, window: t })
|
|
8946
9083
|
);
|
|
8947
9084
|
}
|
|
8948
|
-
function
|
|
9085
|
+
function lf(e) {
|
|
8949
9086
|
const t = [];
|
|
8950
9087
|
let n = 0;
|
|
8951
9088
|
for (const o of e.candles) {
|
|
@@ -8957,23 +9094,23 @@ function l0(e) {
|
|
|
8957
9094
|
return t;
|
|
8958
9095
|
}
|
|
8959
9096
|
const Ap = 180n, io = 60n, gp = 6e4, Sp = /^[A-Za-z0-9._:-]+$/;
|
|
8960
|
-
function
|
|
9097
|
+
function $(e, t) {
|
|
8961
9098
|
return e.toLowerCase() === t.toLowerCase();
|
|
8962
9099
|
}
|
|
8963
|
-
function
|
|
9100
|
+
function me(e, t = /* @__PURE__ */ new WeakMap()) {
|
|
8964
9101
|
if (e === null || typeof e != "object") return e;
|
|
8965
9102
|
const n = t.get(e);
|
|
8966
9103
|
if (n) return n;
|
|
8967
9104
|
if (Array.isArray(e)) {
|
|
8968
9105
|
const a = [];
|
|
8969
9106
|
t.set(e, a);
|
|
8970
|
-
for (const r of e) a.push(
|
|
9107
|
+
for (const r of e) a.push(me(r, t));
|
|
8971
9108
|
return Object.freeze(a);
|
|
8972
9109
|
}
|
|
8973
9110
|
const o = {};
|
|
8974
9111
|
t.set(e, o);
|
|
8975
9112
|
for (const a of Reflect.ownKeys(e))
|
|
8976
|
-
o[a] =
|
|
9113
|
+
o[a] = me(e[a], t);
|
|
8977
9114
|
return Object.freeze(o);
|
|
8978
9115
|
}
|
|
8979
9116
|
function Cp() {
|
|
@@ -8987,10 +9124,10 @@ function xp(e) {
|
|
|
8987
9124
|
return t;
|
|
8988
9125
|
}
|
|
8989
9126
|
function Zi(e, t) {
|
|
8990
|
-
return e.walletAction === t.walletAction &&
|
|
9127
|
+
return e.walletAction === t.walletAction && $(e.target, t.target) && (e.spender === null ? t.spender === null : t.spender !== null && $(e.spender, t.spender)) && e.requestedAmount === t.requestedAmount && e.expiration === t.expiration && e.scope === t.scope;
|
|
8991
9128
|
}
|
|
8992
9129
|
function Qo(e, t) {
|
|
8993
|
-
return e.operation === t.operation && e.chainId === t.chainId &&
|
|
9130
|
+
return e.operation === t.operation && e.chainId === t.chainId && $(e.account, t.account) && e.marketId === t.marketId && $(e.token.address, t.token.address) && e.amount === t.amount && e.approvalMode === t.approvalMode && $(e.router, t.router) && $(e.permit2, t.permit2) && $(e.vaultRegistry, t.vaultRegistry);
|
|
8994
9131
|
}
|
|
8995
9132
|
function Tp(e, t) {
|
|
8996
9133
|
if (!Qo(e, t)) return [{ kind: "intent-changed" }];
|
|
@@ -9005,7 +9142,7 @@ function Tp(e, t) {
|
|
|
9005
9142
|
return n;
|
|
9006
9143
|
}
|
|
9007
9144
|
function es(e, t) {
|
|
9008
|
-
return e.direction === t.direction && e.market.chainId === t.market.chainId && e.market.id === t.market.id && e.market.poolId.toLowerCase() === t.market.poolId.toLowerCase() &&
|
|
9145
|
+
return e.direction === t.direction && e.market.chainId === t.market.chainId && e.market.id === t.market.id && e.market.poolId.toLowerCase() === t.market.poolId.toLowerCase() && $(e.market.token0.address, t.market.token0.address) && $(e.market.token1.address, t.market.token1.address) && $(e.collateralToken.address, t.collateralToken.address) && $(e.intent.owner, t.intent.owner) && e.intent.inputIsToken0 === t.intent.inputIsToken0 && e.intent.collateralIn === t.intent.collateralIn && e.intent.leverage === t.intent.leverage && e.intent.horizonSeconds === t.intent.horizonSeconds && e.intent.priceMove === t.intent.priceMove && e.intent.slippageBps === t.intent.slippageBps && e.intent.maxPriceImpactBps === t.intent.maxPriceImpactBps && e.deposit.amount0 === t.deposit.amount0 && e.deposit.amount1 === t.deposit.amount1;
|
|
9009
9146
|
}
|
|
9010
9147
|
function Rp(e, t) {
|
|
9011
9148
|
return !e || !t ? e !== t : e.daysToLiquidation === "INF" ? t.daysToLiquidation !== "INF" : t.daysToLiquidation === "INF" ? !1 : Math.floor(t.daysToLiquidation) < Math.floor(e.daysToLiquidation);
|
|
@@ -9024,7 +9161,7 @@ function Pp(e, t) {
|
|
|
9024
9161
|
}
|
|
9025
9162
|
function Bp(e) {
|
|
9026
9163
|
const { intent: t, reviewed: n } = e;
|
|
9027
|
-
if (e.activeChain.chainId !== t.market.chainId ||
|
|
9164
|
+
if (e.activeChain.chainId !== t.market.chainId || !$(e.wallet.account, t.owner) || t.token.chainId !== t.market.chainId || !$(t.token.address, t.market.token0.address) && !$(t.token.address, t.market.token1.address))
|
|
9028
9165
|
throw new TypeError("Engine execution context does not match this trade intent.");
|
|
9029
9166
|
const o = {
|
|
9030
9167
|
...n.plan,
|
|
@@ -9034,8 +9171,8 @@ function Bp(e) {
|
|
|
9034
9171
|
token: t.token,
|
|
9035
9172
|
amount: t.amount,
|
|
9036
9173
|
approvalMode: t.approvalMode
|
|
9037
|
-
}, a =
|
|
9038
|
-
if (!Qo(o, n.plan) || n.quote.direction !== t.direction || n.quote.market.chainId !== t.market.chainId || n.quote.market.id !== t.market.id || n.quote.market.poolId.toLowerCase() !== t.market.poolId.toLowerCase() ||
|
|
9174
|
+
}, a = $(t.token.address, t.market.token0.address) ? n.quote.deposit.amount0 : n.quote.deposit.amount1, r = n.quote.intent;
|
|
9175
|
+
if (!Qo(o, n.plan) || n.quote.direction !== t.direction || n.quote.market.chainId !== t.market.chainId || n.quote.market.id !== t.market.id || n.quote.market.poolId.toLowerCase() !== t.market.poolId.toLowerCase() || !$(n.quote.market.token0.address, t.market.token0.address) || !$(n.quote.market.token1.address, t.market.token1.address) || !$(n.quote.collateralToken.address, t.token.address) || !$(r.owner, t.owner) || r.inputIsToken0 !== $(t.token.address, t.market.token0.address) || r.collateralIn !== t.amount || r.leverage !== (t.leverage ?? null) || r.horizonSeconds !== t.horizonSeconds || r.priceMove !== t.priceMove || r.slippageBps !== t.slippageBps || r.maxPriceImpactBps !== t.maxPriceImpactBps || !t.market.router || !$(n.plan.router, t.market.router) || !t.market.permit2 || !$(n.plan.permit2, t.market.permit2) || !t.market.vaultRegistry || !$(n.plan.vaultRegistry, t.market.vaultRegistry) || a !== t.amount)
|
|
9039
9176
|
throw new TypeError("Reviewed Engine plan or quote does not match this trade intent.");
|
|
9040
9177
|
}
|
|
9041
9178
|
function Mp(e) {
|
|
@@ -9046,7 +9183,7 @@ function Dp(e) {
|
|
|
9046
9183
|
const t = Object.freeze({
|
|
9047
9184
|
provider: e.wallet.provider,
|
|
9048
9185
|
account: e.wallet.account
|
|
9049
|
-
}), n = e.publicClient, o =
|
|
9186
|
+
}), n = e.publicClient, o = me(e.activeChain), a = { wallet: t, publicClient: n, activeChain: o };
|
|
9050
9187
|
return {
|
|
9051
9188
|
async readPlan(r, i) {
|
|
9052
9189
|
i == null || i.throwIfAborted();
|
|
@@ -9081,7 +9218,7 @@ function Dp(e) {
|
|
|
9081
9218
|
});
|
|
9082
9219
|
},
|
|
9083
9220
|
async authorizeToken(r, i, s) {
|
|
9084
|
-
await
|
|
9221
|
+
await Oi({
|
|
9085
9222
|
...a,
|
|
9086
9223
|
market: r.market,
|
|
9087
9224
|
token: r.token,
|
|
@@ -9107,7 +9244,7 @@ function Dp(e) {
|
|
|
9107
9244
|
owner: r.owner,
|
|
9108
9245
|
direction: r.direction,
|
|
9109
9246
|
collateralIn: r.amount,
|
|
9110
|
-
inputIsToken0:
|
|
9247
|
+
inputIsToken0: $(r.token.address, r.market.token0.address),
|
|
9111
9248
|
horizonSeconds: r.horizonSeconds,
|
|
9112
9249
|
priceMove: r.priceMove,
|
|
9113
9250
|
leverage: r.leverage,
|
|
@@ -9148,7 +9285,7 @@ function Dp(e) {
|
|
|
9148
9285
|
}
|
|
9149
9286
|
};
|
|
9150
9287
|
}
|
|
9151
|
-
function
|
|
9288
|
+
function df(e) {
|
|
9152
9289
|
return _p(
|
|
9153
9290
|
e,
|
|
9154
9291
|
Dp(e)
|
|
@@ -9156,10 +9293,10 @@ function d0(e) {
|
|
|
9156
9293
|
}
|
|
9157
9294
|
function _p(e, t) {
|
|
9158
9295
|
Bp(e);
|
|
9159
|
-
const n =
|
|
9160
|
-
let r =
|
|
9161
|
-
const
|
|
9162
|
-
s =
|
|
9296
|
+
const n = me(e.intent), o = e.onChange, a = xp(e.sessionId);
|
|
9297
|
+
let r = me(e.reviewed.plan), i = me(e.reviewed.quote), s = r, l = i, c = "ready", p = null, d = 0, m = null, u = { kind: "none" }, h = null, f = null, w = !1, y = null, E, C = 0, x = (/* @__PURE__ */ new Date()).toISOString(), A = null, P = null, g = null, M = null;
|
|
9298
|
+
const O = /* @__PURE__ */ new Set(), L = /* @__PURE__ */ new Set(), ee = [], Y = [], ne = /* @__PURE__ */ new Map(), Re = (v) => {
|
|
9299
|
+
s = me(v);
|
|
9163
9300
|
for (const I of s.steps) {
|
|
9164
9301
|
Y.includes(I.kind) || Y.push(I.kind);
|
|
9165
9302
|
const R = ne.get(I.kind);
|
|
@@ -9167,7 +9304,7 @@ function _p(e, t) {
|
|
|
9167
9304
|
}
|
|
9168
9305
|
};
|
|
9169
9306
|
Re(s);
|
|
9170
|
-
const
|
|
9307
|
+
const we = () => c === "quote-review-required" && p ? { kind: "accept-review", revision: p.revision } : c === "awaiting-receipt" && f ? { kind: "check-receipt", hash: f } : c === "ready" || c === "resume-required" ? { kind: "continue" } : (c === "failed" || c === "cancelled") && u.kind !== "none" && u.kind !== "view-transaction" ? { kind: "continue" } : c === "executing" && !f ? { kind: "cancel" } : { kind: "none" }, ye = () => c === "quote-review-required", he = () => {
|
|
9171
9308
|
const v = Object.freeze(
|
|
9172
9309
|
Y.flatMap((ke) => {
|
|
9173
9310
|
const se = ne.get(ke);
|
|
@@ -9178,7 +9315,7 @@ function _p(e, t) {
|
|
|
9178
9315
|
reasons: Object.freeze(
|
|
9179
9316
|
p.reasons.map((ke) => Object.freeze({ ...ke }))
|
|
9180
9317
|
)
|
|
9181
|
-
}) : null, N = Object.freeze({ ...
|
|
9318
|
+
}) : null, N = Object.freeze({ ...we() }), Ie = m ? Object.freeze({ ...m }) : null, Fe = Object.freeze({ ...u });
|
|
9182
9319
|
return Object.freeze({
|
|
9183
9320
|
schemaVersion: "1",
|
|
9184
9321
|
kind: "engine-trade-open-execution",
|
|
@@ -9200,24 +9337,24 @@ function _p(e, t) {
|
|
|
9200
9337
|
...E ? { receiptSummary: E } : {},
|
|
9201
9338
|
quoteReviewRequired: p !== null,
|
|
9202
9339
|
failure: Ie,
|
|
9203
|
-
recovery:
|
|
9340
|
+
recovery: Fe
|
|
9204
9341
|
});
|
|
9205
|
-
},
|
|
9342
|
+
}, G = () => A ?? (A = he()), W = () => {
|
|
9206
9343
|
C += 1, x = (/* @__PURE__ */ new Date()).toISOString(), A = he();
|
|
9207
9344
|
try {
|
|
9208
9345
|
o == null || o(A);
|
|
9209
9346
|
} catch {
|
|
9210
9347
|
}
|
|
9211
|
-
for (const v of
|
|
9348
|
+
for (const v of O)
|
|
9212
9349
|
try {
|
|
9213
9350
|
v();
|
|
9214
9351
|
} catch {
|
|
9215
9352
|
}
|
|
9216
|
-
},
|
|
9353
|
+
}, V = (v, I, R) => {
|
|
9217
9354
|
Y.includes(v) || Y.push(v), ne.set(v, { kind: v, status: I, hash: R });
|
|
9218
9355
|
}, oe = (v, I) => {
|
|
9219
9356
|
ee.some((R) => R.kind === v && R.hash === I) || ee.push({ kind: v, hash: I });
|
|
9220
|
-
},
|
|
9357
|
+
}, q = (v, I) => I && v.kind !== "tx-reverted" && v.kind !== "tx-cancelled" ? { kind: "view-transaction", hash: I } : v.kind === "wallet-rejected" ? { kind: "retry-wallet" } : v.kind === "wrong-chain" ? { kind: "switch-network", chainId: n.market.chainId } : v.kind === "tx-reverted" || v.kind === "tx-cancelled" || v.kind === "quote" ? { kind: "review-quote" } : v.retryable && L.size ? { kind: "resume-remaining" } : v.retryable ? { kind: "retry-wallet" } : { kind: "none" }, J = (v, I, R) => {
|
|
9221
9358
|
var N;
|
|
9222
9359
|
return R ? "confirmation" : !I || ((N = ne.get(I)) == null ? void 0 : N.status) !== "wallet-requested" ? "preparation" : v.kind === "wallet-rejected" ? "wallet-request" : "submission";
|
|
9223
9360
|
}, Ct = (v, I = h, R = f ?? Mp(v)) => {
|
|
@@ -9227,23 +9364,23 @@ function _p(e, t) {
|
|
|
9227
9364
|
step: I,
|
|
9228
9365
|
hash: R,
|
|
9229
9366
|
failurePhase: J(N, I, R)
|
|
9230
|
-
}, u =
|
|
9367
|
+
}, u = q(N, R), R && N.kind !== "tx-reverted" && N.kind !== "tx-cancelled" ? (c = "awaiting-receipt", f = R, I && V(I, "submitted", R)) : (c = N.kind === "wallet-rejected" || N.kind === "tx-cancelled" ? "cancelled" : "failed", I && V(I, c === "cancelled" ? "cancelled" : "failed", R), h = null, f = null), W();
|
|
9231
9368
|
}, xt = (v, I, R, N) => {
|
|
9232
|
-
Re(R), l =
|
|
9369
|
+
Re(R), l = me(N), d += 1, p = v === "permissions" ? { kind: v, revision: d, reasons: I } : { kind: v, revision: d, reasons: I }, c = "quote-review-required", m = {
|
|
9233
9370
|
message: v === "permissions" ? "Wallet permissions changed. Review before continuing." : "The executable quote changed. Review before continuing.",
|
|
9234
9371
|
kind: "quote",
|
|
9235
9372
|
retryable: !0,
|
|
9236
9373
|
step: null,
|
|
9237
9374
|
hash: null,
|
|
9238
9375
|
failurePhase: "preparation"
|
|
9239
|
-
}, u = { kind: "review-quote" }, h = null, f = null,
|
|
9376
|
+
}, u = { kind: "review-quote" }, h = null, f = null, W();
|
|
9240
9377
|
}, zt = (v) => {
|
|
9241
9378
|
if (!Qo(r, v)) throw new TypeError("Fresh authorization plan does not match the frozen trade intent.");
|
|
9242
9379
|
}, Pe = async (v, I = {}) => {
|
|
9243
9380
|
const R = await t.readPlan(n, v);
|
|
9244
9381
|
v.throwIfAborted(), zt(R);
|
|
9245
9382
|
const N = Tp(r, R);
|
|
9246
|
-
return N.length ? (xt("permissions", N, R, l), P == null || P.abort(new Error("review-required")), !1) : (Re(R), I.publishResult !== !1 &&
|
|
9383
|
+
return N.length ? (xt("permissions", N, R, l), P == null || P.abort(new Error("review-required")), !1) : (Re(R), I.publishResult !== !1 && W(), !0);
|
|
9247
9384
|
}, Tt = (v) => {
|
|
9248
9385
|
if (v === "open-position") return s.readyForOpen && r.steps.some((N) => N.kind === v);
|
|
9249
9386
|
const I = r.steps.find((N) => N.kind === v), R = s.steps.find((N) => N.kind === v);
|
|
@@ -9254,16 +9391,16 @@ function _p(e, t) {
|
|
|
9254
9391
|
xt("permissions", [{ kind: "unexpected-wallet-request", step: v }], s, l), P == null || P.abort(new Error("unreviewed-wallet-request"));
|
|
9255
9392
|
return;
|
|
9256
9393
|
}
|
|
9257
|
-
h = v, f = null,
|
|
9394
|
+
h = v, f = null, w = !1, V(v, "wallet-requested", null), W();
|
|
9258
9395
|
},
|
|
9259
9396
|
onHash(v, I, R) {
|
|
9260
|
-
|
|
9397
|
+
w || (w = R === !0), h = v, f = I, y = I, V(v, "submitted", I), W();
|
|
9261
9398
|
},
|
|
9262
9399
|
async onCheckpoint() {
|
|
9263
9400
|
const v = P == null ? void 0 : P.signal;
|
|
9264
9401
|
if (!v) throw new Error("Engine execution checkpoint has no active command.");
|
|
9265
9402
|
const I = h, R = f;
|
|
9266
|
-
await Pe(v) && I && R && (
|
|
9403
|
+
await Pe(v) && I && R && (V(I, "confirmed", R), L.add(I), oe(I, R), h = null, f = null, W());
|
|
9267
9404
|
}
|
|
9268
9405
|
}, ct = async (v) => {
|
|
9269
9406
|
let I = await t.quote(n, v);
|
|
@@ -9273,31 +9410,31 @@ function _p(e, t) {
|
|
|
9273
9410
|
return I;
|
|
9274
9411
|
}, An = async (v) => {
|
|
9275
9412
|
var I;
|
|
9276
|
-
p = null, m = null, u = { kind: "none" }, c = "executing",
|
|
9413
|
+
p = null, m = null, u = { kind: "none" }, c = "executing", W();
|
|
9277
9414
|
try {
|
|
9278
9415
|
if (!await Pe(v) || s.walletChainSwitchRequired && (await t.ensureChain(n, v), v.throwIfAborted(), !await Pe(v)))
|
|
9279
|
-
return
|
|
9416
|
+
return G();
|
|
9280
9417
|
if (s.steps.some((se) => se.kind === "vault-operator" && se.status === "required")) {
|
|
9281
9418
|
h = "vault-operator";
|
|
9282
9419
|
const se = await t.authorizeVault(n, Ge, v);
|
|
9283
9420
|
if (se.receipt.status !== "success") throw new _("Vault authorization reverted on-chain.", { kind: "tx-reverted" });
|
|
9284
|
-
if (y = se.hash,
|
|
9421
|
+
if (y = se.hash, V("vault-operator", "confirmed", se.hash), L.add("vault-operator"), oe("vault-operator", se.hash), h = null, f = null, !await Pe(v)) return G();
|
|
9285
9422
|
}
|
|
9286
9423
|
if (s.steps.some(
|
|
9287
9424
|
(se) => se.kind !== "vault-operator" && se.kind !== "open-position" && se.status === "required"
|
|
9288
9425
|
) && (await t.authorizeToken(n, Ge, v), v.throwIfAborted(), !await Pe(v)))
|
|
9289
|
-
return
|
|
9426
|
+
return G();
|
|
9290
9427
|
if (!s.readyForOpen) throw new _("Required permissions are still missing.", { kind: "validation", retryable: !0 });
|
|
9291
9428
|
const N = await ct(v), Ie = Pp(i, N);
|
|
9292
9429
|
if (Ie.length)
|
|
9293
|
-
return xt("quote", Ie, s, N),
|
|
9294
|
-
l =
|
|
9295
|
-
const
|
|
9296
|
-
if (
|
|
9297
|
-
const ke =
|
|
9298
|
-
y = ke, E =
|
|
9430
|
+
return xt("quote", Ie, s, N), G();
|
|
9431
|
+
l = me(N), h = "open-position";
|
|
9432
|
+
const Fe = await t.sendOpen(n, l, Ge, v);
|
|
9433
|
+
if (Fe.receipt.status !== "success") throw new _("Engine transaction reverted on-chain.", { kind: "tx-reverted" });
|
|
9434
|
+
const ke = Fe.hash;
|
|
9435
|
+
y = ke, E = me(Fe.summary), V("open-position", "confirmed", ke), oe("open-position", ke), c = "success", h = null, f = null, m = null, u = { kind: "none" }, W();
|
|
9299
9436
|
} catch (R) {
|
|
9300
|
-
if (ye()) return
|
|
9437
|
+
if (ye()) return G();
|
|
9301
9438
|
v.aborted && !f ? (c = "cancelled", m = {
|
|
9302
9439
|
message: "Execution cancelled.",
|
|
9303
9440
|
kind: "unknown",
|
|
@@ -9305,9 +9442,9 @@ function _p(e, t) {
|
|
|
9305
9442
|
step: h,
|
|
9306
9443
|
hash: null,
|
|
9307
9444
|
failurePhase: h && ((I = ne.get(h)) == null ? void 0 : I.status) === "wallet-requested" ? "wallet-request" : "preparation"
|
|
9308
|
-
}, u = { kind: "none" }, h &&
|
|
9445
|
+
}, u = { kind: "none" }, h && V(h, "cancelled", null), h = null, W()) : Ct(R);
|
|
9309
9446
|
}
|
|
9310
|
-
return
|
|
9447
|
+
return G();
|
|
9311
9448
|
}, Gt = async () => {
|
|
9312
9449
|
var R;
|
|
9313
9450
|
if (c !== "awaiting-receipt" || !h || !f) throw new TypeError("No submitted Engine transaction is awaiting receipt reconciliation.");
|
|
@@ -9316,52 +9453,52 @@ function _p(e, t) {
|
|
|
9316
9453
|
try {
|
|
9317
9454
|
I = await t.checkReceipt(n, v, f);
|
|
9318
9455
|
} catch (N) {
|
|
9319
|
-
return Ct(N, v, f),
|
|
9456
|
+
return Ct(N, v, f), G();
|
|
9320
9457
|
}
|
|
9321
|
-
|
|
9458
|
+
w || (w = I.executionChanged === !0);
|
|
9322
9459
|
try {
|
|
9323
9460
|
(R = e.onTransactionObservation) == null || R.call(e, {
|
|
9324
9461
|
hash: I.hash,
|
|
9325
9462
|
...I.replacesHash ? { replacesHash: I.replacesHash } : {},
|
|
9326
|
-
...
|
|
9327
|
-
status: I.status === "unresolved" ? "submitted" :
|
|
9463
|
+
...w ? { executionChanged: !0 } : {},
|
|
9464
|
+
status: I.status === "unresolved" ? "submitted" : w ? "cancelled" : I.status
|
|
9328
9465
|
}, v === "open-position" ? "action" : "authorization");
|
|
9329
9466
|
} catch {
|
|
9330
9467
|
}
|
|
9331
|
-
if (y = I.hash, f = I.hash,
|
|
9332
|
-
return u = { kind: "view-transaction", hash: I.hash },
|
|
9333
|
-
if (
|
|
9468
|
+
if (y = I.hash, f = I.hash, V(v, "submitted", I.hash), I.status === "unresolved")
|
|
9469
|
+
return u = { kind: "view-transaction", hash: I.hash }, W(), G();
|
|
9470
|
+
if (w || I.status === "cancelled" || I.status === "reverted")
|
|
9334
9471
|
return Ct(new _(
|
|
9335
|
-
|
|
9336
|
-
{ kind:
|
|
9337
|
-
), v, I.hash),
|
|
9338
|
-
if (
|
|
9339
|
-
E =
|
|
9472
|
+
w || I.status === "cancelled" ? "Engine transaction was cancelled in the wallet." : "Engine transaction reverted on-chain.",
|
|
9473
|
+
{ kind: w || I.status === "cancelled" ? "tx-cancelled" : "tx-reverted", retryable: !0 }
|
|
9474
|
+
), v, I.hash), G();
|
|
9475
|
+
if (V(v, "confirmed", I.hash), oe(v, I.hash), h = null, f = null, m = null, v === "open-position")
|
|
9476
|
+
E = me($r(I.receipt)), c = "success", u = { kind: "none" }, W();
|
|
9340
9477
|
else {
|
|
9341
9478
|
L.add(v), c = "resume-required", u = { kind: "resume-remaining" };
|
|
9342
9479
|
const N = new AbortController();
|
|
9343
9480
|
P = N;
|
|
9344
9481
|
try {
|
|
9345
|
-
await Pe(N.signal, { publishResult: !1 }), ye() ||
|
|
9482
|
+
await Pe(N.signal, { publishResult: !1 }), ye() || W();
|
|
9346
9483
|
} catch {
|
|
9347
|
-
|
|
9484
|
+
W();
|
|
9348
9485
|
} finally {
|
|
9349
9486
|
P = null;
|
|
9350
9487
|
}
|
|
9351
9488
|
}
|
|
9352
|
-
return
|
|
9489
|
+
return G();
|
|
9353
9490
|
};
|
|
9354
9491
|
return {
|
|
9355
|
-
getSnapshot:
|
|
9492
|
+
getSnapshot: G,
|
|
9356
9493
|
subscribe(v) {
|
|
9357
|
-
return
|
|
9358
|
-
|
|
9494
|
+
return O.add(v), () => {
|
|
9495
|
+
O.delete(v);
|
|
9359
9496
|
};
|
|
9360
9497
|
},
|
|
9361
9498
|
dispatch(v, I) {
|
|
9362
9499
|
if (v.kind === "continue") {
|
|
9363
9500
|
if (g) return g;
|
|
9364
|
-
if (
|
|
9501
|
+
if (we().kind !== "continue") return Promise.reject(new TypeError(`Engine execution cannot continue in phase ${c}.`));
|
|
9365
9502
|
P = new AbortController();
|
|
9366
9503
|
const R = I == null ? void 0 : I.signal, N = () => P == null ? void 0 : P.abort(R == null ? void 0 : R.reason);
|
|
9367
9504
|
R == null || R.addEventListener("abort", N, { once: !0 }), R != null && R.aborted && N();
|
|
@@ -9371,7 +9508,7 @@ function _p(e, t) {
|
|
|
9371
9508
|
return g = Ie, Ie;
|
|
9372
9509
|
}
|
|
9373
9510
|
if (v.kind === "accept-review")
|
|
9374
|
-
return c !== "quote-review-required" || !p || v.revision !== p.revision ? Promise.reject(new TypeError("Engine review revision is stale or not pending.")) : (r =
|
|
9511
|
+
return c !== "quote-review-required" || !p || v.revision !== p.revision ? Promise.reject(new TypeError("Engine review revision is stale or not pending.")) : (r = me(s), i = me(l), p = null, m = null, u = { kind: "none" }, c = "ready", W(), Promise.resolve(G()));
|
|
9375
9512
|
if (v.kind === "check-receipt") {
|
|
9376
9513
|
if (M) return M;
|
|
9377
9514
|
const R = Gt().finally(() => {
|
|
@@ -9386,39 +9523,39 @@ function _p(e, t) {
|
|
|
9386
9523
|
step: h,
|
|
9387
9524
|
hash: null,
|
|
9388
9525
|
failurePhase: "preparation"
|
|
9389
|
-
}, u = { kind: "none" },
|
|
9526
|
+
}, u = { kind: "none" }, W(), Promise.resolve(G()));
|
|
9390
9527
|
}
|
|
9391
9528
|
};
|
|
9392
9529
|
}
|
|
9393
|
-
const
|
|
9530
|
+
const Fn = S().regex(/^[0-9]+$/), ts = T({
|
|
9394
9531
|
schemaVersion: B("1"),
|
|
9395
|
-
chainId:
|
|
9396
|
-
txHash:
|
|
9532
|
+
chainId: b().int(),
|
|
9533
|
+
txHash: On,
|
|
9397
9534
|
account: Xe,
|
|
9398
9535
|
status: B("reconciled"),
|
|
9399
9536
|
execution: T({
|
|
9400
9537
|
basis: B("receipt-reconciled-opening-swap-leg"),
|
|
9401
|
-
poolId:
|
|
9402
|
-
vaultId:
|
|
9538
|
+
poolId: On,
|
|
9539
|
+
vaultId: Fn,
|
|
9403
9540
|
owner: Xe,
|
|
9404
9541
|
key: T({ currency0: Xe, currency1: Xe }),
|
|
9405
9542
|
block: T({ canonicality: B("rpc-checked-at-read") }),
|
|
9406
9543
|
swap: T({
|
|
9407
9544
|
inputCurrency: Xe,
|
|
9408
9545
|
outputCurrency: Xe,
|
|
9409
|
-
inputRaw:
|
|
9410
|
-
outputRaw:
|
|
9546
|
+
inputRaw: Fn,
|
|
9547
|
+
outputRaw: Fn,
|
|
9411
9548
|
inputBasis: B("pool-input-plus-hook-input-fee")
|
|
9412
9549
|
})
|
|
9413
9550
|
})
|
|
9414
9551
|
}), Np = T({
|
|
9415
9552
|
schemaVersion: B("1"),
|
|
9416
|
-
chainId:
|
|
9417
|
-
txHash:
|
|
9553
|
+
chainId: b().int(),
|
|
9554
|
+
txHash: On,
|
|
9418
9555
|
account: Xe,
|
|
9419
9556
|
status: B("unavailable")
|
|
9420
|
-
}).loose(),
|
|
9421
|
-
async function
|
|
9557
|
+
}).loose(), uf = po([ts, Np]);
|
|
9558
|
+
async function mf({ source: e, position: t, strategy: n, signal: o }) {
|
|
9422
9559
|
var s;
|
|
9423
9560
|
if (!t.token0 || !t.token1) return null;
|
|
9424
9561
|
const a = `/v1/engine/transactions/${t.chainId}/${n.openTxHash}/opening-execution`, r = `${Ut(e.baseUrl)}${a}?${new URLSearchParams({ account: t.account })}`, i = it({ signal: o, timeoutMs: e.timeoutMs ?? 1e4, timeoutMessage: "Opening execution read timed out." });
|
|
@@ -9440,9 +9577,9 @@ async function m0({ source: e, position: t, strategy: n, signal: o }) {
|
|
|
9440
9577
|
if (p.chainId !== t.chainId || p.txHash !== n.openTxHash.toLowerCase() || p.account !== t.account.toLowerCase() || d.owner !== p.account || d.poolId !== t.poolId.toLowerCase() || d.poolId !== n.poolId.toLowerCase() || BigInt(d.vaultId) !== BigInt(t.vaultId) || d.key.currency0 !== t.token0.address.toLowerCase() || d.key.currency1 !== t.token1.address.toLowerCase()) return null;
|
|
9441
9578
|
const u = m.inputCurrency === d.key.currency0 && m.outputCurrency === d.key.currency1, h = m.inputCurrency === d.key.currency1 && m.outputCurrency === d.key.currency0;
|
|
9442
9579
|
if (!u && !h) return null;
|
|
9443
|
-
const f = BigInt(u ? m.inputRaw : m.outputRaw),
|
|
9444
|
-
if (f <= 0n ||
|
|
9445
|
-
const y = Number(Jo(
|
|
9580
|
+
const f = BigInt(u ? m.inputRaw : m.outputRaw), w = BigInt(u ? m.outputRaw : m.inputRaw);
|
|
9581
|
+
if (f <= 0n || w <= 0n) return null;
|
|
9582
|
+
const y = Number(Jo(w, t.token1.decimals)) / Number(Jo(f, t.token0.decimals));
|
|
9446
9583
|
return Number.isFinite(y) && y > 0 ? y : null;
|
|
9447
9584
|
} catch (l) {
|
|
9448
9585
|
if (o != null && o.aborted || l instanceof Zo) throw l;
|
|
@@ -9452,10 +9589,10 @@ async function m0({ source: e, position: t, strategy: n, signal: o }) {
|
|
|
9452
9589
|
}
|
|
9453
9590
|
}
|
|
9454
9591
|
export {
|
|
9455
|
-
|
|
9592
|
+
hf as AEGIS_BACKEND_PROD_BASE_URL,
|
|
9456
9593
|
$p as AEGIS_DYNAMIC_FEE_FLAG,
|
|
9457
9594
|
Ds as AEGIS_SWAP_BSC_CHAIN,
|
|
9458
|
-
|
|
9595
|
+
be as AEGIS_SWAP_BSC_CHAIN_ID,
|
|
9459
9596
|
Vp as AEGIS_SWAP_BSC_HOOK,
|
|
9460
9597
|
ir as AEGIS_SWAP_BSC_ROUTER,
|
|
9461
9598
|
dr as AEGIS_SWAP_BSC_RPC_URLS,
|
|
@@ -9474,7 +9611,7 @@ export {
|
|
|
9474
9611
|
Ts as AEGIS_SWAP_INK_RPC_URLS,
|
|
9475
9612
|
zp as AEGIS_SWAP_INK_TOKENS,
|
|
9476
9613
|
Ms as AEGIS_SWAP_MAINNET_CHAIN,
|
|
9477
|
-
|
|
9614
|
+
bo as AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS,
|
|
9478
9615
|
Hn as AEGIS_SWAP_PERMIT2,
|
|
9479
9616
|
Ln as AEGIS_SWAP_ROUTER,
|
|
9480
9617
|
pt as AEGIS_SWAP_TOKENS,
|
|
@@ -9482,25 +9619,25 @@ export {
|
|
|
9482
9619
|
Bs as AEGIS_SWAP_V4_QUOTER,
|
|
9483
9620
|
jp as AGGREGATED_SWAP_CURATED_TOKENS,
|
|
9484
9621
|
vo as AGGREGATED_SWAP_DEFAULT_TOKENS,
|
|
9485
|
-
|
|
9622
|
+
qs as AGGREGATED_SWAP_DEFAULT_TOKEN_LIST,
|
|
9486
9623
|
Ps as AGGREGATED_SWAP_SUPPORTED_CHAIN_IDS,
|
|
9487
9624
|
Gp as AGGREGATED_SWAP_TOKEN_PRESETS,
|
|
9488
|
-
|
|
9489
|
-
|
|
9625
|
+
Fs as AGGREGATED_SWAP_WOLFGAME_TOKENS,
|
|
9626
|
+
Os as AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST,
|
|
9490
9627
|
As as AegisBackendApiError,
|
|
9491
|
-
|
|
9628
|
+
bf as AegisBackendContractError,
|
|
9492
9629
|
_e as AegisContractGuardError,
|
|
9493
9630
|
Zo as AegisEngineAccountReadError,
|
|
9494
|
-
|
|
9631
|
+
le as AegisEngineMarketDataReadError,
|
|
9495
9632
|
fe as AegisEngineMarketNotReadyError,
|
|
9496
9633
|
da as AggregatedSwapBuildMismatchError,
|
|
9497
|
-
|
|
9634
|
+
pe as AggregatedSwapCalldataError,
|
|
9498
9635
|
So as DEFAULT_PERMIT_EXPIRATION_SECONDS,
|
|
9499
9636
|
na as DIRECT_SWAP_MARKET_TRUST_RULE_ID,
|
|
9500
9637
|
ha as DirectPoolSwapPriceMovedError,
|
|
9501
9638
|
yo as DirectSwapMarketTrustError,
|
|
9502
9639
|
kp as ENGINE_MARKET_SERIES_TTL_MS,
|
|
9503
|
-
|
|
9640
|
+
wf as ENGINE_PORTFOLIO_CHAIN_IDS,
|
|
9504
9641
|
Zp as ENGINE_UTILIZATION_CAP_PCT,
|
|
9505
9642
|
Ar as KyberSwapApiError,
|
|
9506
9643
|
Io as KyberSwapContractError,
|
|
@@ -9510,53 +9647,53 @@ export {
|
|
|
9510
9647
|
De as MAX_UINT160,
|
|
9511
9648
|
Ee as MAX_UINT256,
|
|
9512
9649
|
co as NATIVE_TOKEN_ADDRESS,
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9650
|
+
Fr as PERMIT2_FAR_FUTURE_EXPIRATION,
|
|
9651
|
+
kf as PortfolioPageQuerySchema,
|
|
9652
|
+
vf as PortfolioPageSchema,
|
|
9653
|
+
Ef as PortfolioQuerySchema,
|
|
9654
|
+
yf as PortfolioResponseSchema,
|
|
9518
9655
|
ml as SDK_RPC_MULTICALL_RULE_ID,
|
|
9519
9656
|
go as SWAP_TX_DEADLINE_SECONDS,
|
|
9520
|
-
|
|
9521
|
-
|
|
9657
|
+
If as SubmittedTransactionReceiptError,
|
|
9658
|
+
Af as TransactionReceiptTimeoutError,
|
|
9522
9659
|
Se as UNISWAP_V4_CONTRACTS_BY_CHAIN,
|
|
9523
9660
|
Gn as UNLIMITED_ERC20_FLOOR,
|
|
9524
9661
|
gl as UNLIMITED_PERMIT2_FLOOR,
|
|
9525
|
-
|
|
9662
|
+
gf as USER_REJECTED_MESSAGE,
|
|
9526
9663
|
_ as UserFacingError,
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9664
|
+
Sf as aegisBackendAddressAllowlistSchema,
|
|
9665
|
+
K as aegisBackendAddressSchema,
|
|
9666
|
+
Cf as aegisBackendAllowlistsByChainSchema,
|
|
9667
|
+
xf as aegisBackendChainIdSchema,
|
|
9668
|
+
Tf as aegisBackendChainSchema,
|
|
9669
|
+
Rf as aegisBackendConfigSchema,
|
|
9670
|
+
Pf as aegisBackendContractRegistrySchema,
|
|
9671
|
+
Bf as aegisBackendContractsByChainSchema,
|
|
9672
|
+
de as aegisBackendDecimalStringSchema,
|
|
9673
|
+
Mf as aegisBackendFeeConfigSchema,
|
|
9674
|
+
Df as aegisBackendHealthResponseSchema,
|
|
9538
9675
|
lo as aegisBackendHexSchema,
|
|
9539
9676
|
Ce as aegisBackendIsoDateTimeSchema,
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
|
|
9548
|
-
|
|
9549
|
-
$
|
|
9550
|
-
|
|
9551
|
-
|
|
9677
|
+
_f as aegisBackendMarketMetricsSchema,
|
|
9678
|
+
Nf as aegisBackendMarketSchema,
|
|
9679
|
+
Ff as aegisBackendMarketStatusSchema,
|
|
9680
|
+
qf as aegisBackendMarketsResponseSchema,
|
|
9681
|
+
Of as aegisBackendQuoteDefaultsSchema,
|
|
9682
|
+
Lf as aegisBackendQuoteModeSchema,
|
|
9683
|
+
Uf as aegisBackendSwapProviderSchema,
|
|
9684
|
+
Vf as aegisBackendSwapQuoteRequestSchema,
|
|
9685
|
+
Hf as aegisBackendSwapQuoteResponseSchema,
|
|
9686
|
+
$f as aegisBackendTokenSchema,
|
|
9687
|
+
Wf as aegisBackendTokensResponseSchema,
|
|
9688
|
+
Kf as aegisPoolKeySchema,
|
|
9552
9689
|
Jp as aggregatedSwapErrorMessage,
|
|
9553
9690
|
pd as approveDirectPoolSwapInput,
|
|
9554
|
-
|
|
9555
|
-
|
|
9691
|
+
z0 as approveEnginePermit2ToRouter,
|
|
9692
|
+
K0 as approveEngineTokenToPermit2,
|
|
9556
9693
|
Dl as approveErc20Spender,
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9694
|
+
qr as approveErc20ToPermit2,
|
|
9695
|
+
bd as approveKyberSwapInput,
|
|
9696
|
+
Or as approvePermit2ToRouter,
|
|
9560
9697
|
al as assertCalldataHash,
|
|
9561
9698
|
rl as assertChainMatches,
|
|
9562
9699
|
cn as assertDirectSwapMarketTrusted,
|
|
@@ -9568,7 +9705,7 @@ export {
|
|
|
9568
9705
|
Po as assertTrustedEngineMarket,
|
|
9569
9706
|
_t as assertUint128,
|
|
9570
9707
|
fu as attachEngineActivityLotDisplays,
|
|
9571
|
-
|
|
9708
|
+
G0 as authorizeEnginePositionRouter,
|
|
9572
9709
|
jm as authorizeEngineVaultOperator,
|
|
9573
9710
|
Xp as authorizeHostDirectSwapMarket,
|
|
9574
9711
|
Rd as backendTokenToAegisSwapToken,
|
|
@@ -9576,105 +9713,105 @@ export {
|
|
|
9576
9713
|
Zs as buildExactInSwapTransaction,
|
|
9577
9714
|
ec as buildExactOutSwapTransaction,
|
|
9578
9715
|
Mc as buildKyberSwapRoute,
|
|
9579
|
-
|
|
9716
|
+
Fl as buildSignedPermitBatch,
|
|
9580
9717
|
mi as classifyEngineVaultActivity,
|
|
9581
9718
|
nr as classifyError,
|
|
9582
|
-
|
|
9583
|
-
|
|
9584
|
-
|
|
9585
|
-
|
|
9586
|
-
|
|
9587
|
-
|
|
9588
|
-
|
|
9589
|
-
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
|
|
9719
|
+
A0 as clearEngineMarketHistoryCache,
|
|
9720
|
+
T0 as clearEngineMarketHistoryV2ProbeCache,
|
|
9721
|
+
nf as clearEngineMarketSeriesCache,
|
|
9722
|
+
I0 as clearEngineMarketsCache,
|
|
9723
|
+
x0 as clearEngineMarketsV2ProbeCache,
|
|
9724
|
+
S0 as clearEnginePositionActivityCache,
|
|
9725
|
+
g0 as clearEnginePositionsCache,
|
|
9726
|
+
C0 as clearEnginePositionsV2ProbeCache,
|
|
9727
|
+
k0 as clearEngineReadCaches,
|
|
9728
|
+
r0 as clearTokenPriceHistoryCache,
|
|
9729
|
+
Z0 as computeEngineIdleWithdrawPostLtvPips,
|
|
9730
|
+
J0 as computeEngineMaxIdleWithdraw,
|
|
9594
9731
|
We as computePoolId,
|
|
9595
|
-
|
|
9732
|
+
zf as createAegisBackendApiClient,
|
|
9596
9733
|
ur as createAegisSwapChainConfig,
|
|
9597
9734
|
Wp as createAegisSwapChains,
|
|
9598
|
-
|
|
9735
|
+
b0 as createAegisSwapChainsFromBackendConfig,
|
|
9599
9736
|
Qp as createAegisSwapMarketsFromPools,
|
|
9600
9737
|
nc as createAegisSwapPoolMarket,
|
|
9601
|
-
|
|
9738
|
+
w0 as createAegisSwapPoolsFromBackendMarkets,
|
|
9602
9739
|
Ae as createAegisSwapUniswapV4Contracts,
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9740
|
+
df as createEngineTradeOpenExecutionSession,
|
|
9741
|
+
Gf as createEngineTransactionHistory,
|
|
9742
|
+
t0 as createSwapPublicClient,
|
|
9606
9743
|
pu as deriveEngineActivityLotDisplay,
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9744
|
+
tf as deriveEngineTradePositionStrategy,
|
|
9745
|
+
jf as engineAccountPositionKey,
|
|
9746
|
+
Qf as engineAccountTransactionKey,
|
|
9610
9747
|
Tp as engineAuthorizationPlanReviewReasons,
|
|
9611
|
-
|
|
9612
|
-
|
|
9748
|
+
Xf as engineHistoryCatalogResponseSchema,
|
|
9749
|
+
Y0 as engineIdleWithdrawPassesResidualLtv,
|
|
9613
9750
|
rn as engineMarketCandlesResponseSchema,
|
|
9614
9751
|
Ro as engineMarketIdSchema,
|
|
9615
9752
|
Dd as engineMarketsRestResponseSchema,
|
|
9616
9753
|
_d as engineMarketsV2RestResponseSchema,
|
|
9617
|
-
|
|
9618
|
-
|
|
9619
|
-
|
|
9754
|
+
Fd as engineMetricHistoryRestResponseSchema,
|
|
9755
|
+
qd as engineMetricHistoryV2RestResponseSchema,
|
|
9756
|
+
uf as engineOpeningExecutionResponseSchema,
|
|
9620
9757
|
Zt as enginePermit2GrantSatisfies,
|
|
9621
|
-
|
|
9622
|
-
|
|
9623
|
-
|
|
9624
|
-
|
|
9758
|
+
wp as enginePoolPriceLineResponseSchema,
|
|
9759
|
+
rf as enginePoolPriceSegments,
|
|
9760
|
+
Yf as enginePortfolioPriceFor,
|
|
9761
|
+
Jf as enginePositionAccountingResponseSchema,
|
|
9625
9762
|
cu as enginePositionActivityRestResponseSchema,
|
|
9626
|
-
|
|
9763
|
+
Zf as enginePositionHistoryResponseSchema,
|
|
9627
9764
|
eh as enginePositionPerformanceResponseSchema,
|
|
9628
9765
|
th as enginePositionPnlResponseSchema,
|
|
9629
9766
|
Vd as enginePositionsRestResponseSchema,
|
|
9630
9767
|
Kd as enginePositionsV2RestResponseSchema,
|
|
9631
|
-
|
|
9632
|
-
|
|
9633
|
-
|
|
9768
|
+
X0 as enginePreviewMaxLtvPips,
|
|
9769
|
+
e0 as engineRouterForChain,
|
|
9770
|
+
Om as engineTokenGrantSatisfies,
|
|
9634
9771
|
Pp as engineTradeQuoteReviewReasons,
|
|
9635
9772
|
nh as engineTransactionStorageKey,
|
|
9636
9773
|
Ke as ensureWalletChain,
|
|
9637
9774
|
ld as erc20ApprovalRequest,
|
|
9638
|
-
|
|
9775
|
+
ws as errorMessage,
|
|
9639
9776
|
Vr as estimateSwapGasWithBuffer,
|
|
9640
|
-
|
|
9641
|
-
|
|
9642
|
-
|
|
9643
|
-
|
|
9777
|
+
u0 as executeDirectPoolSwap,
|
|
9778
|
+
Q0 as executeEngineBalancedDeposit,
|
|
9779
|
+
m0 as executeKyberSwap,
|
|
9780
|
+
N0 as executionLtvGuardPips,
|
|
9644
9781
|
ma as fetchAggregatedSwapQuote,
|
|
9645
|
-
|
|
9782
|
+
ba as fetchDirectPoolSwapQuote,
|
|
9646
9783
|
oh as fetchEngineAccountActivity,
|
|
9647
9784
|
ah as fetchEngineAccountPortfolio,
|
|
9648
9785
|
rh as fetchEngineHistoryPositions,
|
|
9649
|
-
|
|
9650
|
-
|
|
9651
|
-
|
|
9652
|
-
|
|
9653
|
-
|
|
9654
|
-
|
|
9655
|
-
|
|
9786
|
+
D0 as fetchEngineLendActivity,
|
|
9787
|
+
of as fetchEngineMarketCandles,
|
|
9788
|
+
P0 as fetchEngineMarketHistory,
|
|
9789
|
+
sf as fetchEngineMarketReferenceHistory,
|
|
9790
|
+
R0 as fetchEngineMarkets,
|
|
9791
|
+
mf as fetchEngineOpeningEntry,
|
|
9792
|
+
af as fetchEnginePoolPriceHistory,
|
|
9656
9793
|
vi as fetchEnginePositionActivitySnapshot,
|
|
9657
9794
|
ih as fetchEnginePositionHistory,
|
|
9658
|
-
|
|
9659
|
-
|
|
9795
|
+
B0 as fetchEnginePositionsSnapshot,
|
|
9796
|
+
cf as fetchEngineRateHistory,
|
|
9660
9797
|
sh as fetchEngineTransactionStatus,
|
|
9661
|
-
|
|
9662
|
-
|
|
9798
|
+
M0 as fetchEngineVaultActivity,
|
|
9799
|
+
a0 as fetchGlobalTokenMetadata,
|
|
9663
9800
|
Bc as fetchKyberSwapRoute,
|
|
9664
|
-
|
|
9801
|
+
s0 as fetchTokenPriceHistory,
|
|
9665
9802
|
ch as formatEngineAccountTokenAmount,
|
|
9666
|
-
|
|
9803
|
+
wo as getExplorerUrl,
|
|
9667
9804
|
pl as getInjectedProvider,
|
|
9668
|
-
|
|
9805
|
+
bl as getProviderAccount,
|
|
9669
9806
|
Nt as getProviderChainId,
|
|
9670
9807
|
fc as getZeroForOne,
|
|
9671
9808
|
lh as groupEngineAccountActivity,
|
|
9672
9809
|
dh as groupEnginePortfolioPositions,
|
|
9673
9810
|
un as hasUsablePermit2Allowance,
|
|
9674
|
-
|
|
9675
|
-
|
|
9811
|
+
ef as isAegisEngineTradePositionIntent,
|
|
9812
|
+
p0 as isBusy,
|
|
9676
9813
|
Er as isDirectSwapMarketTrusted,
|
|
9677
|
-
|
|
9814
|
+
c0 as isDocumentVisible,
|
|
9678
9815
|
fl as isEip1193Provider,
|
|
9679
9816
|
xe as isNativeAssetAddress,
|
|
9680
9817
|
Yr as isNativeToken,
|
|
@@ -9685,7 +9822,7 @@ export {
|
|
|
9685
9822
|
Cl as isUnlimitedPermit2Approval,
|
|
9686
9823
|
Is as isUserRejectedError,
|
|
9687
9824
|
ph as mergeEngineTransactionRecord,
|
|
9688
|
-
|
|
9825
|
+
j0 as missingEngineExecutionReason,
|
|
9689
9826
|
dn as normalizeAccount,
|
|
9690
9827
|
Ut as normalizeAegisBackendBaseUrl,
|
|
9691
9828
|
Rn as normalizeEngineMarkets,
|
|
@@ -9693,55 +9830,55 @@ export {
|
|
|
9693
9830
|
kc as outputFeeForQuote,
|
|
9694
9831
|
ul as parseEngineDeploymentManifest,
|
|
9695
9832
|
fh as parseEngineTransactionRecords,
|
|
9696
|
-
|
|
9833
|
+
i0 as peekTokenPriceHistory,
|
|
9697
9834
|
mn as pollUntil,
|
|
9698
|
-
|
|
9699
|
-
|
|
9700
|
-
|
|
9835
|
+
Oi as prepareEnginePermit,
|
|
9836
|
+
f0 as progressRailSteps,
|
|
9837
|
+
O0 as quoteEngineAddCollateral,
|
|
9701
9838
|
Ga as quoteEngineBalancedDeposit,
|
|
9702
|
-
|
|
9703
|
-
|
|
9704
|
-
|
|
9705
|
-
|
|
9706
|
-
|
|
9707
|
-
|
|
9708
|
-
|
|
9839
|
+
q0 as quoteEngineBorrow,
|
|
9840
|
+
L0 as quoteEngineBorrowCapacity,
|
|
9841
|
+
V0 as quoteEngineCloseVault,
|
|
9842
|
+
F0 as quoteEngineDeposit,
|
|
9843
|
+
H0 as quoteEngineIdleWithdraw,
|
|
9844
|
+
$0 as quoteEngineRedeem,
|
|
9845
|
+
U0 as quoteEngineRepay,
|
|
9709
9846
|
_m as quoteEngineTradeOpen,
|
|
9710
9847
|
aa as quoteSpendAmount,
|
|
9711
9848
|
am as readEngineAdaptiveFeeEvidence,
|
|
9712
9849
|
zm as readEngineAuthorizationPlan,
|
|
9713
9850
|
_o as readEngineBorrowQuoteContext,
|
|
9714
9851
|
Tu as readEngineLendQuoteContext,
|
|
9715
|
-
|
|
9852
|
+
v0 as readEngineMarketMark,
|
|
9716
9853
|
xu as readEngineMarketSnapshot,
|
|
9717
|
-
|
|
9718
|
-
|
|
9854
|
+
E0 as readEnginePositionsHydration,
|
|
9855
|
+
y0 as readEngineVaultActivity,
|
|
9719
9856
|
Gm as readEngineVaultRouterApproved,
|
|
9720
9857
|
Ht as readErc20Allowance,
|
|
9721
9858
|
ot as readPermit2RouterAllowance,
|
|
9722
9859
|
oa as reconcileSubmitQuote,
|
|
9723
9860
|
Ss as reconcileSubmittedReceipt,
|
|
9724
|
-
|
|
9861
|
+
wl as requestProviderAccount,
|
|
9725
9862
|
pn as requiresErc20ApprovalReset,
|
|
9726
9863
|
hh as resolveEngineAccountPositionTarget,
|
|
9727
|
-
|
|
9728
|
-
|
|
9729
|
-
|
|
9730
|
-
|
|
9864
|
+
W0 as resolveEngineBorrowCollateralFloor,
|
|
9865
|
+
o0 as resolveTokenIconUrl,
|
|
9866
|
+
d0 as resolveWalletSession,
|
|
9867
|
+
l0 as retryOnError,
|
|
9731
9868
|
$t as sameEngineMarketId,
|
|
9732
9869
|
Yp as sameQuote,
|
|
9733
9870
|
En as sendEngineTransaction,
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9871
|
+
bh as serializeEngineTransactionRecords,
|
|
9872
|
+
lf as splitEngineMarketCandleSegments,
|
|
9873
|
+
n0 as subscribeProvider,
|
|
9737
9874
|
Qu as summarizeEngineLendShareGrowth,
|
|
9738
|
-
|
|
9875
|
+
_0 as summarizeEngineSimpleYieldPosition,
|
|
9739
9876
|
$r as summarizeTransactionReceipt,
|
|
9740
9877
|
Al as switchProviderChain,
|
|
9741
9878
|
Jl as tokenPriceHistoryRestResponseSchema,
|
|
9742
|
-
|
|
9879
|
+
h0 as transactionProgressView,
|
|
9743
9880
|
vd as transactionSequenceProgress,
|
|
9744
|
-
|
|
9881
|
+
ue as trustedEngineRegistryForChain,
|
|
9745
9882
|
vt as trustedEngineVersionForChain,
|
|
9746
9883
|
dd as waitForProviderChain
|
|
9747
9884
|
};
|