@argent/x-shared 1.59.0 → 1.60.0
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/dist/index.cjs +1 -1
- package/dist/index.js +224 -214
- package/dist/simulation.cjs +1 -1
- package/dist/simulation.js +68 -55
- package/dist/src/features/simulation/fees/schema.cjs +1 -1
- package/dist/src/features/simulation/fees/schema.d.ts +848 -0
- package/dist/src/features/simulation/fees/schema.js +36 -4
- package/dist/src/features/simulation/transactionReview/schema.cjs +1 -1
- package/dist/src/features/simulation/transactionReview/schema.d.ts +8264 -148
- package/dist/src/features/simulation/transactionReview/schema.js +105 -85
- package/dist/src/staking/schema.d.ts +24 -24
- package/dist/src/transactions/estimate/index.d.ts +1 -0
- package/dist/src/transactions/estimate/utilsV2.cjs +1 -0
- package/dist/src/transactions/estimate/utilsV2.d.ts +14 -0
- package/dist/src/transactions/estimate/utilsV2.js +96 -0
- package/dist/src/transactions/getTransactionVersion.cjs +1 -1
- package/dist/src/transactions/getTransactionVersion.d.ts +6 -0
- package/dist/src/transactions/getTransactionVersion.js +15 -12
- package/dist/src/transactions/txv3.cjs +1 -1
- package/dist/src/transactions/txv3.js +4 -4
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/type.utils.d.ts +215 -0
- package/package.json +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
|
-
import { estimatedFeesSchema as
|
|
3
|
-
import { severitySchema as
|
|
4
|
-
import { addressSchemaArgentBackend as
|
|
5
|
-
const
|
|
2
|
+
import { estimatedFeesSchema as h, estimatedFeesV2Schema as S } from "../fees/schema.js";
|
|
3
|
+
import { severitySchema as y, reasonsSchema as f } from "../warning/schema.js";
|
|
4
|
+
import { addressSchemaArgentBackend as n, addressSchema as j } from "../../../chains/starknet/address.js";
|
|
5
|
+
const k = t.object({
|
|
6
6
|
name: t.string(),
|
|
7
7
|
url: t.string(),
|
|
8
8
|
position: t.number()
|
|
9
|
-
}),
|
|
9
|
+
}), o = t.object({
|
|
10
10
|
address: t.string(),
|
|
11
11
|
name: t.string(),
|
|
12
12
|
symbol: t.string().optional(),
|
|
@@ -14,11 +14,11 @@ const j = t.object({
|
|
|
14
14
|
unknown: t.boolean(),
|
|
15
15
|
iconUrl: t.string().optional(),
|
|
16
16
|
type: t.string()
|
|
17
|
-
}),
|
|
17
|
+
}), s = t.discriminatedUnion("type", [
|
|
18
18
|
t.object({
|
|
19
19
|
type: t.literal("amount"),
|
|
20
20
|
label: t.string(),
|
|
21
|
-
token:
|
|
21
|
+
token: o,
|
|
22
22
|
amount: t.string(),
|
|
23
23
|
usd: t.string(),
|
|
24
24
|
editable: t.boolean()
|
|
@@ -39,7 +39,7 @@ const j = t.object({
|
|
|
39
39
|
t.object({
|
|
40
40
|
type: t.literal("token_address"),
|
|
41
41
|
label: t.string(),
|
|
42
|
-
token:
|
|
42
|
+
token: o
|
|
43
43
|
}),
|
|
44
44
|
t.object({
|
|
45
45
|
type: t.literal("calldata"),
|
|
@@ -60,42 +60,42 @@ const j = t.object({
|
|
|
60
60
|
t.object({
|
|
61
61
|
type: t.literal("nft"),
|
|
62
62
|
label: t.string(),
|
|
63
|
-
token:
|
|
63
|
+
token: o
|
|
64
64
|
})
|
|
65
|
-
]),
|
|
65
|
+
]), v = t.object({
|
|
66
66
|
name: t.string(),
|
|
67
|
-
properties: t.array(
|
|
68
|
-
defaultProperties: t.array(
|
|
69
|
-
}),
|
|
67
|
+
properties: t.array(s),
|
|
68
|
+
defaultProperties: t.array(s).optional()
|
|
69
|
+
}), w = t.union([
|
|
70
70
|
t.literal("verified"),
|
|
71
71
|
t.literal("neutral"),
|
|
72
72
|
t.literal("partial"),
|
|
73
73
|
t.literal("warn")
|
|
74
|
-
]),
|
|
74
|
+
]), E = t.object({
|
|
75
75
|
unknown_token: t.unknown().optional(),
|
|
76
76
|
date_of_addition: t.string().optional(),
|
|
77
|
-
contract_address:
|
|
77
|
+
contract_address: j.optional(),
|
|
78
78
|
reason: t.string().optional(),
|
|
79
79
|
value: t.string().or(t.number()).optional()
|
|
80
80
|
}), l = t.object({
|
|
81
|
-
reason:
|
|
82
|
-
details:
|
|
83
|
-
severity:
|
|
84
|
-
}),
|
|
85
|
-
assessment:
|
|
81
|
+
reason: f,
|
|
82
|
+
details: E.optional(),
|
|
83
|
+
severity: y
|
|
84
|
+
}), F = t.object({
|
|
85
|
+
assessment: w,
|
|
86
86
|
warnings: t.array(l).optional(),
|
|
87
87
|
assessmentReasons: t.array(t.string()).optional(),
|
|
88
88
|
assessmentDetails: t.object({
|
|
89
89
|
contract_address: t.string()
|
|
90
90
|
}).optional(),
|
|
91
|
-
action:
|
|
92
|
-
}),
|
|
91
|
+
action: v
|
|
92
|
+
}), U = t.object({
|
|
93
93
|
name: t.string(),
|
|
94
94
|
description: t.string(),
|
|
95
95
|
logoUrl: t.string(),
|
|
96
96
|
iconUrl: t.string(),
|
|
97
97
|
argentVerified: t.boolean(),
|
|
98
|
-
links: t.array(
|
|
98
|
+
links: t.array(k)
|
|
99
99
|
}), c = t.object({
|
|
100
100
|
assessment: t.union([
|
|
101
101
|
t.literal("verified"),
|
|
@@ -107,19 +107,19 @@ const j = t.object({
|
|
|
107
107
|
assessmentDetails: t.object({
|
|
108
108
|
contract_address: t.string()
|
|
109
109
|
}).optional(),
|
|
110
|
-
targetedDapp:
|
|
111
|
-
reviews: t.array(
|
|
112
|
-
}).optional(),
|
|
110
|
+
targetedDapp: U.optional(),
|
|
111
|
+
reviews: t.array(F)
|
|
112
|
+
}).optional(), m = t.object({
|
|
113
113
|
banner: t.string().nullable().optional(),
|
|
114
114
|
preview: t.string().nullable().optional(),
|
|
115
115
|
full: t.string().nullable().optional(),
|
|
116
116
|
original: t.string().nullable().optional()
|
|
117
|
-
}),
|
|
117
|
+
}), x = t.object({
|
|
118
118
|
twitter: t.string().optional(),
|
|
119
119
|
external: t.string().optional(),
|
|
120
120
|
discord: t.string().optional()
|
|
121
121
|
}), i = t.object({
|
|
122
|
-
address:
|
|
122
|
+
address: n,
|
|
123
123
|
decimals: t.number().optional(),
|
|
124
124
|
symbol: t.string().optional(),
|
|
125
125
|
name: t.string(),
|
|
@@ -128,38 +128,47 @@ const j = t.object({
|
|
|
128
128
|
usdValue: t.string().optional(),
|
|
129
129
|
iconUrl: t.string().optional(),
|
|
130
130
|
unknown: t.boolean().optional(),
|
|
131
|
-
imageUrls:
|
|
132
|
-
links:
|
|
133
|
-
}),
|
|
134
|
-
tokenAddress:
|
|
135
|
-
owner:
|
|
136
|
-
spender:
|
|
131
|
+
imageUrls: m.optional(),
|
|
132
|
+
links: x.optional()
|
|
133
|
+
}), A = t.object({
|
|
134
|
+
tokenAddress: n,
|
|
135
|
+
owner: n,
|
|
136
|
+
spender: n,
|
|
137
137
|
value: t.string().optional(),
|
|
138
138
|
approvalForAll: t.boolean(),
|
|
139
139
|
details: i.optional()
|
|
140
|
-
}),
|
|
141
|
-
tokenAddress:
|
|
142
|
-
from:
|
|
143
|
-
to:
|
|
140
|
+
}), D = t.object({
|
|
141
|
+
tokenAddress: n,
|
|
142
|
+
from: n,
|
|
143
|
+
to: n,
|
|
144
144
|
tokenId: t.string().optional(),
|
|
145
145
|
value: t.string().optional(),
|
|
146
146
|
details: i.optional()
|
|
147
|
-
}),
|
|
148
|
-
overallFee:
|
|
149
|
-
gasPrice:
|
|
150
|
-
gasUsage:
|
|
151
|
-
dataGasPrice:
|
|
152
|
-
dataGasConsumed:
|
|
153
|
-
},
|
|
154
|
-
...
|
|
155
|
-
unit: t.string().transform((
|
|
156
|
-
maxFee:
|
|
157
|
-
})
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
147
|
+
}), e = t.union([t.string(), t.number(), t.bigint()]).transform((a) => parseInt(a.toString(), 10)), p = {
|
|
148
|
+
overallFee: e,
|
|
149
|
+
gasPrice: e,
|
|
150
|
+
gasUsage: e,
|
|
151
|
+
dataGasPrice: e.optional(),
|
|
152
|
+
dataGasConsumed: e.optional()
|
|
153
|
+
}, P = t.object({
|
|
154
|
+
...p,
|
|
155
|
+
unit: t.string().transform((a) => a.toUpperCase()).pipe(t.literal("WEI")),
|
|
156
|
+
maxFee: e
|
|
157
|
+
}), g = t.object({
|
|
158
|
+
address: n,
|
|
159
|
+
unknown: t.boolean(),
|
|
160
|
+
type: t.literal("ERC20")
|
|
161
|
+
}), T = t.object({
|
|
162
|
+
...p,
|
|
163
|
+
unit: t.string().transform((a) => a.toUpperCase()).pipe(t.literal("FRI")),
|
|
164
|
+
maxAmount: e,
|
|
165
|
+
maxPricePerUnit: e,
|
|
166
|
+
token: g
|
|
167
|
+
}), _ = t.object({
|
|
168
|
+
token: g,
|
|
169
|
+
overallFee: e,
|
|
170
|
+
maxFee: e
|
|
171
|
+
}), d = P.or(T), V = d.or(_), I = t.object({
|
|
163
172
|
type: t.string(),
|
|
164
173
|
label: t.string(),
|
|
165
174
|
tokenId: t.string().optional(),
|
|
@@ -170,51 +179,62 @@ const j = t.object({
|
|
|
170
179
|
tokenIdDetails: t.object({
|
|
171
180
|
name: t.string().optional(),
|
|
172
181
|
description: t.string().optional(),
|
|
173
|
-
imageUrls:
|
|
182
|
+
imageUrls: m.optional()
|
|
174
183
|
}).optional()
|
|
175
|
-
}),
|
|
176
|
-
approvals: t.array(
|
|
177
|
-
transfers: t.array(
|
|
184
|
+
}), N = t.object({
|
|
185
|
+
approvals: t.array(A).optional(),
|
|
186
|
+
transfers: t.array(D).optional(),
|
|
178
187
|
calculatedNonce: t.string().optional(),
|
|
179
|
-
feeEstimation:
|
|
180
|
-
|
|
181
|
-
|
|
188
|
+
feeEstimation: d,
|
|
189
|
+
feeEstimations: t.array(V),
|
|
190
|
+
summary: t.array(I).optional()
|
|
191
|
+
}), R = t.object({
|
|
182
192
|
label: t.string().optional(),
|
|
183
193
|
code: t.number().optional(),
|
|
184
194
|
message: t.string().optional(),
|
|
185
195
|
error: t.string().optional()
|
|
186
|
-
}),
|
|
196
|
+
}), b = t.object({
|
|
187
197
|
reviewOfTransaction: c,
|
|
188
|
-
simulation:
|
|
198
|
+
simulation: N,
|
|
189
199
|
simulationError: t.undefined()
|
|
190
|
-
}),
|
|
200
|
+
}), u = t.object({
|
|
191
201
|
reviewOfTransaction: c,
|
|
192
202
|
simulation: t.undefined(),
|
|
193
|
-
simulationError:
|
|
194
|
-
}),
|
|
195
|
-
transactions: t.array(
|
|
196
|
-
}),
|
|
197
|
-
transactions: t.array(
|
|
198
|
-
enrichedFeeEstimation:
|
|
203
|
+
simulationError: R
|
|
204
|
+
}), r = b.or(u), z = t.object({
|
|
205
|
+
transactions: t.array(r).optional()
|
|
206
|
+
}), H = t.object({
|
|
207
|
+
transactions: t.array(r).optional(),
|
|
208
|
+
enrichedFeeEstimation: h.optional(),
|
|
209
|
+
isBackendDown: t.boolean().default(!1).optional()
|
|
210
|
+
}), W = t.object({
|
|
211
|
+
transactions: t.array(r).optional(),
|
|
212
|
+
enrichedFeeEstimation: t.array(S).optional(),
|
|
199
213
|
isBackendDown: t.boolean().default(!1).optional()
|
|
200
214
|
});
|
|
201
|
-
function
|
|
202
|
-
return
|
|
215
|
+
function q(a) {
|
|
216
|
+
return b.safeParse(a).success;
|
|
203
217
|
}
|
|
204
|
-
function
|
|
205
|
-
return
|
|
218
|
+
function J(a) {
|
|
219
|
+
return u.safeParse(a).success;
|
|
206
220
|
}
|
|
207
221
|
export {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
222
|
+
v as actionSchema,
|
|
223
|
+
w as assessmentSchema,
|
|
224
|
+
H as enrichedSimulateAndReviewSchema,
|
|
225
|
+
W as enrichedSimulateAndReviewV2Schema,
|
|
226
|
+
V as feeEstimationNativeOrPaymasterSchema,
|
|
227
|
+
d as feeEstimationSchema,
|
|
228
|
+
P as feeEstimationTxV1Schema,
|
|
229
|
+
T as feeEstimationTxV3Schema,
|
|
230
|
+
q as isNotTransactionSimulationError,
|
|
231
|
+
J as isTransactionSimulationError,
|
|
232
|
+
_ as paymasterFeeEstimationSchema,
|
|
233
|
+
g as paymasterFeeTokenSchema,
|
|
234
|
+
s as propertySchema,
|
|
235
|
+
F as reviewSchema,
|
|
236
|
+
z as simulateAndReviewSchema,
|
|
237
|
+
U as targetedDappSchema,
|
|
238
|
+
E as warningDetailsSchema,
|
|
219
239
|
l as warningSchema
|
|
220
240
|
};
|
|
@@ -147,8 +147,8 @@ export declare const liquidStakingInvestmentSchema: z.ZodObject<z.objectUtil.ext
|
|
|
147
147
|
}>, "strip", z.ZodTypeAny, {
|
|
148
148
|
name: string;
|
|
149
149
|
chain: string;
|
|
150
|
-
dappId: string;
|
|
151
150
|
description: string;
|
|
151
|
+
dappId: string;
|
|
152
152
|
metrics: {
|
|
153
153
|
baseApy: string;
|
|
154
154
|
totalApy: string;
|
|
@@ -199,8 +199,8 @@ export declare const liquidStakingInvestmentSchema: z.ZodObject<z.objectUtil.ext
|
|
|
199
199
|
}, {
|
|
200
200
|
name: string;
|
|
201
201
|
chain: string;
|
|
202
|
-
dappId: string;
|
|
203
202
|
description: string;
|
|
203
|
+
dappId: string;
|
|
204
204
|
metrics: {
|
|
205
205
|
baseApy: string;
|
|
206
206
|
totalApy: string;
|
|
@@ -359,8 +359,8 @@ export declare const lendingInvestmentSchema: z.ZodObject<z.objectUtil.extendSha
|
|
|
359
359
|
}>, "strip", z.ZodTypeAny, {
|
|
360
360
|
name: string;
|
|
361
361
|
chain: string;
|
|
362
|
-
dappId: string;
|
|
363
362
|
description: string;
|
|
363
|
+
dappId: string;
|
|
364
364
|
metrics: {
|
|
365
365
|
baseApy: string;
|
|
366
366
|
totalApy: string;
|
|
@@ -403,8 +403,8 @@ export declare const lendingInvestmentSchema: z.ZodObject<z.objectUtil.extendSha
|
|
|
403
403
|
}, {
|
|
404
404
|
name: string;
|
|
405
405
|
chain: string;
|
|
406
|
-
dappId: string;
|
|
407
406
|
description: string;
|
|
407
|
+
dappId: string;
|
|
408
408
|
metrics: {
|
|
409
409
|
baseApy: string;
|
|
410
410
|
totalApy: string;
|
|
@@ -655,8 +655,8 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
|
|
|
655
655
|
}>, "strip", z.ZodTypeAny, {
|
|
656
656
|
name: string;
|
|
657
657
|
chain: string;
|
|
658
|
-
dappId: string;
|
|
659
658
|
description: string;
|
|
659
|
+
dappId: string;
|
|
660
660
|
metrics: {
|
|
661
661
|
baseApy: string;
|
|
662
662
|
totalApy: string;
|
|
@@ -721,8 +721,8 @@ export declare const strkDelegatedStakingInvestmentSchema: z.ZodObject<z.objectU
|
|
|
721
721
|
}, {
|
|
722
722
|
name: string;
|
|
723
723
|
chain: string;
|
|
724
|
-
dappId: string;
|
|
725
724
|
description: string;
|
|
725
|
+
dappId: string;
|
|
726
726
|
metrics: {
|
|
727
727
|
baseApy: string;
|
|
728
728
|
totalApy: string;
|
|
@@ -933,8 +933,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
933
933
|
}>, "strip", z.ZodTypeAny, {
|
|
934
934
|
name: string;
|
|
935
935
|
chain: string;
|
|
936
|
-
dappId: string;
|
|
937
936
|
description: string;
|
|
937
|
+
dappId: string;
|
|
938
938
|
metrics: {
|
|
939
939
|
baseApy: string;
|
|
940
940
|
totalApy: string;
|
|
@@ -985,8 +985,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
985
985
|
}, {
|
|
986
986
|
name: string;
|
|
987
987
|
chain: string;
|
|
988
|
-
dappId: string;
|
|
989
988
|
description: string;
|
|
989
|
+
dappId: string;
|
|
990
990
|
metrics: {
|
|
991
991
|
baseApy: string;
|
|
992
992
|
totalApy: string;
|
|
@@ -1144,8 +1144,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
1144
1144
|
}>, "strip", z.ZodTypeAny, {
|
|
1145
1145
|
name: string;
|
|
1146
1146
|
chain: string;
|
|
1147
|
-
dappId: string;
|
|
1148
1147
|
description: string;
|
|
1148
|
+
dappId: string;
|
|
1149
1149
|
metrics: {
|
|
1150
1150
|
baseApy: string;
|
|
1151
1151
|
totalApy: string;
|
|
@@ -1188,8 +1188,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
1188
1188
|
}, {
|
|
1189
1189
|
name: string;
|
|
1190
1190
|
chain: string;
|
|
1191
|
-
dappId: string;
|
|
1192
1191
|
description: string;
|
|
1192
|
+
dappId: string;
|
|
1193
1193
|
metrics: {
|
|
1194
1194
|
baseApy: string;
|
|
1195
1195
|
totalApy: string;
|
|
@@ -1425,8 +1425,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
1425
1425
|
}>, "strip", z.ZodTypeAny, {
|
|
1426
1426
|
name: string;
|
|
1427
1427
|
chain: string;
|
|
1428
|
-
dappId: string;
|
|
1429
1428
|
description: string;
|
|
1429
|
+
dappId: string;
|
|
1430
1430
|
metrics: {
|
|
1431
1431
|
baseApy: string;
|
|
1432
1432
|
totalApy: string;
|
|
@@ -1491,8 +1491,8 @@ export declare const investmentSchema: z.ZodDiscriminatedUnion<"category", [z.Zo
|
|
|
1491
1491
|
}, {
|
|
1492
1492
|
name: string;
|
|
1493
1493
|
chain: string;
|
|
1494
|
-
dappId: string;
|
|
1495
1494
|
description: string;
|
|
1495
|
+
dappId: string;
|
|
1496
1496
|
metrics: {
|
|
1497
1497
|
baseApy: string;
|
|
1498
1498
|
totalApy: string;
|
|
@@ -1708,8 +1708,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
1708
1708
|
}>, "strip", z.ZodTypeAny, {
|
|
1709
1709
|
name: string;
|
|
1710
1710
|
chain: string;
|
|
1711
|
-
dappId: string;
|
|
1712
1711
|
description: string;
|
|
1712
|
+
dappId: string;
|
|
1713
1713
|
metrics: {
|
|
1714
1714
|
baseApy: string;
|
|
1715
1715
|
totalApy: string;
|
|
@@ -1760,8 +1760,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
1760
1760
|
}, {
|
|
1761
1761
|
name: string;
|
|
1762
1762
|
chain: string;
|
|
1763
|
-
dappId: string;
|
|
1764
1763
|
description: string;
|
|
1764
|
+
dappId: string;
|
|
1765
1765
|
metrics: {
|
|
1766
1766
|
baseApy: string;
|
|
1767
1767
|
totalApy: string;
|
|
@@ -1919,8 +1919,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
1919
1919
|
}>, "strip", z.ZodTypeAny, {
|
|
1920
1920
|
name: string;
|
|
1921
1921
|
chain: string;
|
|
1922
|
-
dappId: string;
|
|
1923
1922
|
description: string;
|
|
1923
|
+
dappId: string;
|
|
1924
1924
|
metrics: {
|
|
1925
1925
|
baseApy: string;
|
|
1926
1926
|
totalApy: string;
|
|
@@ -1963,8 +1963,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
1963
1963
|
}, {
|
|
1964
1964
|
name: string;
|
|
1965
1965
|
chain: string;
|
|
1966
|
-
dappId: string;
|
|
1967
1966
|
description: string;
|
|
1967
|
+
dappId: string;
|
|
1968
1968
|
metrics: {
|
|
1969
1969
|
baseApy: string;
|
|
1970
1970
|
totalApy: string;
|
|
@@ -2200,8 +2200,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2200
2200
|
}>, "strip", z.ZodTypeAny, {
|
|
2201
2201
|
name: string;
|
|
2202
2202
|
chain: string;
|
|
2203
|
-
dappId: string;
|
|
2204
2203
|
description: string;
|
|
2204
|
+
dappId: string;
|
|
2205
2205
|
metrics: {
|
|
2206
2206
|
baseApy: string;
|
|
2207
2207
|
totalApy: string;
|
|
@@ -2266,8 +2266,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2266
2266
|
}, {
|
|
2267
2267
|
name: string;
|
|
2268
2268
|
chain: string;
|
|
2269
|
-
dappId: string;
|
|
2270
2269
|
description: string;
|
|
2270
|
+
dappId: string;
|
|
2271
2271
|
metrics: {
|
|
2272
2272
|
baseApy: string;
|
|
2273
2273
|
totalApy: string;
|
|
@@ -2334,8 +2334,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2334
2334
|
investments: ({
|
|
2335
2335
|
name: string;
|
|
2336
2336
|
chain: string;
|
|
2337
|
-
dappId: string;
|
|
2338
2337
|
description: string;
|
|
2338
|
+
dappId: string;
|
|
2339
2339
|
metrics: {
|
|
2340
2340
|
baseApy: string;
|
|
2341
2341
|
totalApy: string;
|
|
@@ -2386,8 +2386,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2386
2386
|
} | {
|
|
2387
2387
|
name: string;
|
|
2388
2388
|
chain: string;
|
|
2389
|
-
dappId: string;
|
|
2390
2389
|
description: string;
|
|
2390
|
+
dappId: string;
|
|
2391
2391
|
metrics: {
|
|
2392
2392
|
baseApy: string;
|
|
2393
2393
|
totalApy: string;
|
|
@@ -2430,8 +2430,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2430
2430
|
} | {
|
|
2431
2431
|
name: string;
|
|
2432
2432
|
chain: string;
|
|
2433
|
-
dappId: string;
|
|
2434
2433
|
description: string;
|
|
2434
|
+
dappId: string;
|
|
2435
2435
|
metrics: {
|
|
2436
2436
|
baseApy: string;
|
|
2437
2437
|
totalApy: string;
|
|
@@ -2498,8 +2498,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2498
2498
|
investments: ({
|
|
2499
2499
|
name: string;
|
|
2500
2500
|
chain: string;
|
|
2501
|
-
dappId: string;
|
|
2502
2501
|
description: string;
|
|
2502
|
+
dappId: string;
|
|
2503
2503
|
metrics: {
|
|
2504
2504
|
baseApy: string;
|
|
2505
2505
|
totalApy: string;
|
|
@@ -2550,8 +2550,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2550
2550
|
} | {
|
|
2551
2551
|
name: string;
|
|
2552
2552
|
chain: string;
|
|
2553
|
-
dappId: string;
|
|
2554
2553
|
description: string;
|
|
2554
|
+
dappId: string;
|
|
2555
2555
|
metrics: {
|
|
2556
2556
|
baseApy: string;
|
|
2557
2557
|
totalApy: string;
|
|
@@ -2594,8 +2594,8 @@ export declare const investmentsResponseSchema: z.ZodObject<{
|
|
|
2594
2594
|
} | {
|
|
2595
2595
|
name: string;
|
|
2596
2596
|
chain: string;
|
|
2597
|
-
dappId: string;
|
|
2598
2597
|
description: string;
|
|
2598
|
+
dappId: string;
|
|
2599
2599
|
metrics: {
|
|
2600
2600
|
baseApy: string;
|
|
2601
2601
|
totalApy: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("lodash-es"),m=require("starknet"),l=require("./error.cjs"),o=require("./utils.cjs"),c=require("../../chains/starknet/constants.cjs"),A=require("../../chains/starknet/address.cjs"),v=e=>{const{transactions:t}=e;if(!t)throw new l.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const n=t.map(s=>{if(!s.simulation)throw new l.EstimateError({code:"SIMULATE_AND_REVIEW_FAILED"});const{nativeFeeEstimation:u,paymasterFeeEstimations:T}=g(s.simulation.feeEstimations);return{...s.simulation,feeEstimation:u,paymasterFeeEstimations:T}}),a=o.getEstimatedFeeFromBulkSimulation(n),[r,d]=n.length===1?[n[0],void 0]:[n[1],n[0]],y=E(a.transactions,r),F=a.deployment&&d?E(a.deployment,d):void 0;return[{type:"native",transactions:y,deployment:F},...p(n)]},E=(e,t)=>({...e,dataGasConsumed:e.dataGasConsumed??0n,dataGasPrice:e.dataGasPrice??0n,max:o.toMax(o.castFeeEstimation(t.feeEstimation,m.num.toBigInt))}),g=e=>{const[t,n]=f.partition(e,a=>"unit"in a&&(a.unit==="FRI"||a.unit==="WEI"));return{nativeFeeEstimation:t[0],paymasterFeeEstimations:n}},p=e=>{if(!e)return[];if(!Array.isArray(e))throw Error(`Unexpected simulation response. Expected array. Got ${typeof e}`);if(e.length===1)return e[0].paymasterFeeEstimations.map(t=>({type:"paymaster",transactions:i(t),deployment:void 0}));if(e.length===2){const t=e[0].paymasterFeeEstimations,n=e[1].paymasterFeeEstimations;if(t.length!==n.length)throw Error("Deployment and transaction fee estimations length mismatch");return n.map((a,r)=>({type:"paymaster",transactions:i(a),deployment:i(t[r])}))}throw Error("Unexpected simulation response length")},i=e=>({feeTokenAddress:e.token.address,maxFee:BigInt(e.maxFee),overallFee:BigInt(e.overallFee)}),S=e=>{var a;if(e.type==="paymaster")return e.transactions.maxFee+(((a=e.deployment)==null?void 0:a.maxFee)??0n);if(e.deployment&&!A.isEqualAddress(e.deployment.feeTokenAddress,e.transactions.feeTokenAddress))throw Error("Cannot calculate estimated fees for different tokens");const t=e.deployment?o.estimatedFeeToMaxFeeTotal(e.deployment):0n,n=o.estimatedFeeToMaxFeeTotal(e.transactions);return t+n},N=e=>{var t;return e.type==="paymaster"?e.transactions.overallFee+(((t=e.deployment)==null?void 0:t.overallFee)??0n):o.estimatedFeeToTotal(e.transactions)},h=e=>{const t=e==null?void 0:e.find(n=>n.type==="native");return t||{type:"native",transactions:{amount:0n,feeTokenAddress:c.STRK_TOKEN_ADDRESS,pricePerUnit:0n}}},I=e=>e.filter(t=>t.type==="paymaster"),_=e=>e===m.constants.TRANSACTION_VERSION.V1||e===m.constants.TRANSACTION_VERSION.F1?c.ETH_TOKEN_ADDRESS:c.STRK_TOKEN_ADDRESS;exports.estimatedFeesToMaxFeeTotalV2=S;exports.estimatedFeesToTotalV2=N;exports.filterPaymasterEstimatedFees=I;exports.getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2=v;exports.getNativeEstimatedFees=h;exports.getNativeFeeTokenAddress=_;exports.getPaymasterFeeFromSimulation=p;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Address } from '../../chains';
|
|
2
|
+
import { PaymasterFeeEstimation, SimulateAndReview } from '../../features/simulation';
|
|
3
|
+
import { EstimatedFeesV2, NativeEstimatedFees, PaymasterEstimatedFees } from '../../features/simulation/fees/schema';
|
|
4
|
+
import { StrictOmit } from '../../utils/type.utils';
|
|
5
|
+
import { TransactionVersion } from '../transactionVersion';
|
|
6
|
+
export declare const getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2: (simulateAndReviewResult: Pick<SimulateAndReview, "transactions">) => EstimatedFeesV2[];
|
|
7
|
+
export declare const getPaymasterFeeFromSimulation: (simulation: {
|
|
8
|
+
paymasterFeeEstimations: PaymasterFeeEstimation[];
|
|
9
|
+
}[]) => EstimatedFeesV2[];
|
|
10
|
+
export declare const estimatedFeesToMaxFeeTotalV2: (estimatedFees: EstimatedFeesV2) => bigint;
|
|
11
|
+
export declare const estimatedFeesToTotalV2: (estimatedFees: EstimatedFeesV2) => bigint;
|
|
12
|
+
export declare const getNativeEstimatedFees: (estimatedFees?: EstimatedFeesV2[]) => NativeEstimatedFees;
|
|
13
|
+
export declare const filterPaymasterEstimatedFees: (estimatedFees: EstimatedFeesV2[]) => StrictOmit<PaymasterEstimatedFees, "type">[];
|
|
14
|
+
export declare const getNativeFeeTokenAddress: (transactionVersion: TransactionVersion) => Address;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { partition as u } from "lodash-es";
|
|
2
|
+
import { num as T, constants as m } from "starknet";
|
|
3
|
+
import { EstimateError as c } from "./error.js";
|
|
4
|
+
import { getEstimatedFeeFromBulkSimulation as A, toMax as v, castFeeEstimation as g, estimatedFeeToMaxFeeTotal as p, estimatedFeeToTotal as I } from "./utils.js";
|
|
5
|
+
import { STRK_TOKEN_ADDRESS as E, ETH_TOKEN_ADDRESS as h } from "../../chains/starknet/constants.js";
|
|
6
|
+
import { isEqualAddress as N } from "../../chains/starknet/address.js";
|
|
7
|
+
const O = (t) => {
|
|
8
|
+
const { transactions: e } = t;
|
|
9
|
+
if (!e)
|
|
10
|
+
throw new c({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
11
|
+
const n = e.map((r) => {
|
|
12
|
+
if (!r.simulation)
|
|
13
|
+
throw new c({ code: "SIMULATE_AND_REVIEW_FAILED" });
|
|
14
|
+
const { nativeFeeEstimation: F, paymasterFeeEstimations: f } = S(r.simulation.feeEstimations);
|
|
15
|
+
return {
|
|
16
|
+
...r.simulation,
|
|
17
|
+
feeEstimation: F,
|
|
18
|
+
paymasterFeeEstimations: f
|
|
19
|
+
};
|
|
20
|
+
}), a = A(n), [o, i] = n.length === 1 ? [n[0], void 0] : [n[1], n[0]], l = d(a.transactions, o), y = a.deployment && i ? d(a.deployment, i) : void 0;
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
type: "native",
|
|
24
|
+
transactions: l,
|
|
25
|
+
deployment: y
|
|
26
|
+
},
|
|
27
|
+
..._(n)
|
|
28
|
+
];
|
|
29
|
+
}, d = (t, e) => ({
|
|
30
|
+
...t,
|
|
31
|
+
dataGasConsumed: t.dataGasConsumed ?? 0n,
|
|
32
|
+
dataGasPrice: t.dataGasPrice ?? 0n,
|
|
33
|
+
max: v(g(e.feeEstimation, T.toBigInt))
|
|
34
|
+
}), S = (t) => {
|
|
35
|
+
const [e, n] = u(t, (a) => "unit" in a && (a.unit === "FRI" || a.unit === "WEI"));
|
|
36
|
+
return {
|
|
37
|
+
nativeFeeEstimation: e[0],
|
|
38
|
+
paymasterFeeEstimations: n
|
|
39
|
+
};
|
|
40
|
+
}, _ = (t) => {
|
|
41
|
+
if (!t)
|
|
42
|
+
return [];
|
|
43
|
+
if (!Array.isArray(t))
|
|
44
|
+
throw Error(`Unexpected simulation response. Expected array. Got ${typeof t}`);
|
|
45
|
+
if (t.length === 1)
|
|
46
|
+
return t[0].paymasterFeeEstimations.map((e) => ({
|
|
47
|
+
type: "paymaster",
|
|
48
|
+
transactions: s(e),
|
|
49
|
+
deployment: void 0
|
|
50
|
+
}));
|
|
51
|
+
if (t.length === 2) {
|
|
52
|
+
const e = t[0].paymasterFeeEstimations, n = t[1].paymasterFeeEstimations;
|
|
53
|
+
if (e.length !== n.length)
|
|
54
|
+
throw Error("Deployment and transaction fee estimations length mismatch");
|
|
55
|
+
return n.map((a, o) => ({
|
|
56
|
+
type: "paymaster",
|
|
57
|
+
transactions: s(a),
|
|
58
|
+
deployment: s(e[o])
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
throw Error("Unexpected simulation response length");
|
|
62
|
+
}, s = (t) => ({
|
|
63
|
+
feeTokenAddress: t.token.address,
|
|
64
|
+
maxFee: BigInt(t.maxFee),
|
|
65
|
+
overallFee: BigInt(t.overallFee)
|
|
66
|
+
}), P = (t) => {
|
|
67
|
+
var a;
|
|
68
|
+
if (t.type === "paymaster")
|
|
69
|
+
return t.transactions.maxFee + (((a = t.deployment) == null ? void 0 : a.maxFee) ?? 0n);
|
|
70
|
+
if (t.deployment && !N(t.deployment.feeTokenAddress, t.transactions.feeTokenAddress))
|
|
71
|
+
throw Error("Cannot calculate estimated fees for different tokens");
|
|
72
|
+
const e = t.deployment ? p(t.deployment) : 0n, n = p(t.transactions);
|
|
73
|
+
return e + n;
|
|
74
|
+
}, U = (t) => {
|
|
75
|
+
var e;
|
|
76
|
+
return t.type === "paymaster" ? t.transactions.overallFee + (((e = t.deployment) == null ? void 0 : e.overallFee) ?? 0n) : I(t.transactions);
|
|
77
|
+
}, C = (t) => {
|
|
78
|
+
const e = t == null ? void 0 : t.find((n) => n.type === "native");
|
|
79
|
+
return e || {
|
|
80
|
+
type: "native",
|
|
81
|
+
transactions: {
|
|
82
|
+
amount: 0n,
|
|
83
|
+
feeTokenAddress: E,
|
|
84
|
+
pricePerUnit: 0n
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}, G = (t) => t.filter((e) => e.type === "paymaster"), M = (t) => t === m.TRANSACTION_VERSION.V1 || t === m.TRANSACTION_VERSION.F1 ? h : E;
|
|
88
|
+
export {
|
|
89
|
+
P as estimatedFeesToMaxFeeTotalV2,
|
|
90
|
+
U as estimatedFeesToTotalV2,
|
|
91
|
+
G as filterPaymasterEstimatedFees,
|
|
92
|
+
O as getEstimatedFeeFromSimulationAndRespectWatermarkFeeV2,
|
|
93
|
+
C as getNativeEstimatedFees,
|
|
94
|
+
M as getNativeFeeTokenAddress,
|
|
95
|
+
_ as getPaymasterFeeFromSimulation
|
|
96
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("starknet"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("starknet"),n=require("./txv3.cjs");function r(t){return n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V1}function s(t){return n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.F3:e.constants.TRANSACTION_VERSION.F1}function T(t,o){return e.isSierra(o.contract)?n.feeTokenNeedsTxV3Support({address:t})?e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V2:e.constants.TRANSACTION_VERSION.V1}const N=({classHash:t})=>t&&!n.classHashSupportsTxV3(t)?e.constants.TRANSACTION_VERSION.V1:e.constants.TRANSACTION_VERSION.V3,c=({classHash:t},o)=>e.isSierra(o.contract)?t&&!n.classHashSupportsTxV3(t)?e.constants.TRANSACTION_VERSION.V2:e.constants.TRANSACTION_VERSION.V3:e.constants.TRANSACTION_VERSION.V1;exports.getAccountTxVersion=N;exports.getSimulationTxVersionFromFeeToken=s;exports.getTxVersionForDeclareContract=c;exports.getTxVersionFromFeeToken=r;exports.getTxVersionFromFeeTokenForDeclareContract=T;
|
|
@@ -4,3 +4,9 @@ import { TransactionInvokeVersion, TransactionSimulationVersion } from './transa
|
|
|
4
4
|
export declare function getTxVersionFromFeeToken(feeTokenAddress: Address): TransactionInvokeVersion;
|
|
5
5
|
export declare function getSimulationTxVersionFromFeeToken(feeTokenAddress: Address): TransactionSimulationVersion;
|
|
6
6
|
export declare function getTxVersionFromFeeTokenForDeclareContract(feeTokenAddress: Address, payload: DeclareContractPayload): TransactionInvokeVersion;
|
|
7
|
+
type AccountClassHash = {
|
|
8
|
+
classHash?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const getAccountTxVersion: ({ classHash }: AccountClassHash) => "0x1" | "0x3";
|
|
11
|
+
export declare const getTxVersionForDeclareContract: ({ classHash }: AccountClassHash, payload: DeclareContractPayload) => TransactionInvokeVersion;
|
|
12
|
+
export {};
|