@p2pdotme/sdk 1.1.8 → 1.2.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.mjs +1 -1
- package/dist/orders.cjs +204 -82
- package/dist/orders.cjs.map +1 -1
- package/dist/orders.mjs +183 -61
- package/dist/orders.mjs.map +1 -1
- package/dist/prices.cjs +179 -57
- package/dist/prices.cjs.map +1 -1
- package/dist/prices.mjs +177 -55
- package/dist/prices.mjs.map +1 -1
- package/dist/profile.cjs +191 -69
- package/dist/profile.cjs.map +1 -1
- package/dist/profile.mjs +183 -61
- package/dist/profile.mjs.map +1 -1
- package/dist/react.cjs +579 -100
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +137 -1
- package/dist/react.d.ts +137 -1
- package/dist/react.mjs +545 -67
- package/dist/react.mjs.map +1 -1
- package/dist/stake.cjs +1246 -0
- package/dist/stake.cjs.map +1 -0
- package/dist/stake.d.cts +197 -0
- package/dist/stake.d.ts +197 -0
- package/dist/stake.mjs +1218 -0
- package/dist/stake.mjs.map +1 -0
- package/dist/zkkyc.cjs +102 -2
- package/dist/zkkyc.cjs.map +1 -1
- package/dist/zkkyc.mjs +102 -2
- package/dist/zkkyc.mjs.map +1 -1
- package/package.json +7 -1
package/dist/react.cjs
CHANGED
|
@@ -37,6 +37,7 @@ __export(react_exports, {
|
|
|
37
37
|
usePrices: () => usePrices,
|
|
38
38
|
useProfile: () => useProfile,
|
|
39
39
|
useSdk: () => useSdk,
|
|
40
|
+
useStake: () => useStake,
|
|
40
41
|
useWatchOrders: () => useWatchOrders,
|
|
41
42
|
useZkkyc: () => useZkkyc
|
|
42
43
|
});
|
|
@@ -685,7 +686,7 @@ function createFraudEngine(config) {
|
|
|
685
686
|
}
|
|
686
687
|
|
|
687
688
|
// src/orders/client.ts
|
|
688
|
-
var
|
|
689
|
+
var import_neverthrow18 = require("neverthrow");
|
|
689
690
|
|
|
690
691
|
// src/contracts/order-processor/index.ts
|
|
691
692
|
var import_neverthrow5 = require("neverthrow");
|
|
@@ -1171,6 +1172,104 @@ var p2pConfigFacetAbi = [
|
|
|
1171
1172
|
}
|
|
1172
1173
|
];
|
|
1173
1174
|
|
|
1175
|
+
// src/contracts/abis/p2p-stake-boost-facet.ts
|
|
1176
|
+
var p2pStakeBoostFacetAbi = [
|
|
1177
|
+
{
|
|
1178
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
1179
|
+
name: "p2pBoostStake",
|
|
1180
|
+
outputs: [],
|
|
1181
|
+
stateMutability: "nonpayable",
|
|
1182
|
+
type: "function"
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
|
|
1186
|
+
name: "p2pBoostTopUp",
|
|
1187
|
+
outputs: [],
|
|
1188
|
+
stateMutability: "nonpayable",
|
|
1189
|
+
type: "function"
|
|
1190
|
+
},
|
|
1191
|
+
{
|
|
1192
|
+
inputs: [],
|
|
1193
|
+
name: "p2pBoostRequestUnstake",
|
|
1194
|
+
outputs: [],
|
|
1195
|
+
stateMutability: "nonpayable",
|
|
1196
|
+
type: "function"
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
inputs: [],
|
|
1200
|
+
name: "p2pBoostClaimUnstake",
|
|
1201
|
+
outputs: [],
|
|
1202
|
+
stateMutability: "nonpayable",
|
|
1203
|
+
type: "function"
|
|
1204
|
+
},
|
|
1205
|
+
{
|
|
1206
|
+
inputs: [],
|
|
1207
|
+
name: "p2pBoostCancelUnstake",
|
|
1208
|
+
outputs: [],
|
|
1209
|
+
stateMutability: "nonpayable",
|
|
1210
|
+
type: "function"
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
inputs: [{ internalType: "address", name: "user", type: "address" }],
|
|
1214
|
+
name: "getUserStake",
|
|
1215
|
+
outputs: [
|
|
1216
|
+
{
|
|
1217
|
+
components: [
|
|
1218
|
+
{ internalType: "uint128", name: "stakedAmount", type: "uint128" },
|
|
1219
|
+
{ internalType: "uint64", name: "cooldownEnd", type: "uint64" },
|
|
1220
|
+
{ internalType: "uint8", name: "status", type: "uint8" }
|
|
1221
|
+
],
|
|
1222
|
+
internalType: "struct P2PStakeBoostStorage.UserStake",
|
|
1223
|
+
name: "",
|
|
1224
|
+
type: "tuple"
|
|
1225
|
+
}
|
|
1226
|
+
],
|
|
1227
|
+
stateMutability: "view",
|
|
1228
|
+
type: "function"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
|
|
1232
|
+
name: "getStakeBoostConfig",
|
|
1233
|
+
outputs: [
|
|
1234
|
+
{
|
|
1235
|
+
components: [
|
|
1236
|
+
{
|
|
1237
|
+
internalType: "uint256",
|
|
1238
|
+
name: "tokensPerUsdNumerator",
|
|
1239
|
+
type: "uint256"
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
internalType: "uint256",
|
|
1243
|
+
name: "tokensPerUsdDenominator",
|
|
1244
|
+
type: "uint256"
|
|
1245
|
+
},
|
|
1246
|
+
{ internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
|
|
1247
|
+
],
|
|
1248
|
+
internalType: "struct P2PStakeBoostStorage.BoostConfig",
|
|
1249
|
+
name: "",
|
|
1250
|
+
type: "tuple"
|
|
1251
|
+
}
|
|
1252
|
+
],
|
|
1253
|
+
stateMutability: "view",
|
|
1254
|
+
type: "function"
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
inputs: [],
|
|
1258
|
+
name: "getStakeBoostGlobals",
|
|
1259
|
+
outputs: [
|
|
1260
|
+
{ internalType: "address", name: "p2pToken", type: "address" },
|
|
1261
|
+
{ internalType: "address", name: "fraudReserve", type: "address" },
|
|
1262
|
+
{ internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
|
|
1263
|
+
{ internalType: "uint256", name: "normalCooldown", type: "uint256" },
|
|
1264
|
+
{ internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
|
|
1265
|
+
{ internalType: "uint8", name: "tokenDecimals", type: "uint8" },
|
|
1266
|
+
{ internalType: "uint256", name: "totalStaked", type: "uint256" }
|
|
1267
|
+
],
|
|
1268
|
+
stateMutability: "view",
|
|
1269
|
+
type: "function"
|
|
1270
|
+
}
|
|
1271
|
+
];
|
|
1272
|
+
|
|
1174
1273
|
// src/contracts/abis/reputation-manager.ts
|
|
1175
1274
|
var reputationManagerAbi = [
|
|
1176
1275
|
{
|
|
@@ -1377,14 +1476,16 @@ var reputationManagerAbi = [
|
|
|
1377
1476
|
var DIAMOND_ABI = [
|
|
1378
1477
|
...orderFlowFacetAbi,
|
|
1379
1478
|
...orderProcessorFacetAbi,
|
|
1380
|
-
...p2pConfigFacetAbi
|
|
1479
|
+
...p2pConfigFacetAbi,
|
|
1480
|
+
...p2pStakeBoostFacetAbi
|
|
1381
1481
|
];
|
|
1382
1482
|
var ABIS = {
|
|
1383
1483
|
DIAMOND: DIAMOND_ABI,
|
|
1384
1484
|
FACETS: {
|
|
1385
1485
|
ORDER_FLOW: orderFlowFacetAbi,
|
|
1386
1486
|
ORDER_PROCESSOR: orderProcessorFacetAbi,
|
|
1387
|
-
CONFIG: p2pConfigFacetAbi
|
|
1487
|
+
CONFIG: p2pConfigFacetAbi,
|
|
1488
|
+
STAKE: p2pStakeBoostFacetAbi
|
|
1388
1489
|
},
|
|
1389
1490
|
EXTERNAL: {
|
|
1390
1491
|
USDC: import_viem2.erc20Abi,
|
|
@@ -3898,15 +3999,15 @@ function weierstrassPoints(opts) {
|
|
|
3898
3999
|
throw new Error("ProjectivePoint expected");
|
|
3899
4000
|
}
|
|
3900
4001
|
const toAffineMemo = memoized((p, iz) => {
|
|
3901
|
-
const { px: x, py: y, pz:
|
|
3902
|
-
if (Fp.eql(
|
|
4002
|
+
const { px: x, py: y, pz: z11 } = p;
|
|
4003
|
+
if (Fp.eql(z11, Fp.ONE))
|
|
3903
4004
|
return { x, y };
|
|
3904
4005
|
const is0 = p.is0();
|
|
3905
4006
|
if (iz == null)
|
|
3906
|
-
iz = is0 ? Fp.ONE : Fp.inv(
|
|
4007
|
+
iz = is0 ? Fp.ONE : Fp.inv(z11);
|
|
3907
4008
|
const ax = Fp.mul(x, iz);
|
|
3908
4009
|
const ay = Fp.mul(y, iz);
|
|
3909
|
-
const zz = Fp.mul(
|
|
4010
|
+
const zz = Fp.mul(z11, iz);
|
|
3910
4011
|
if (is0)
|
|
3911
4012
|
return { x: Fp.ZERO, y: Fp.ZERO };
|
|
3912
4013
|
if (!Fp.eql(zz, Fp.ONE))
|
|
@@ -4901,7 +5002,7 @@ function createSetSellOrderUpiAction(input) {
|
|
|
4901
5002
|
}
|
|
4902
5003
|
|
|
4903
5004
|
// src/orders/internal/routing/client.ts
|
|
4904
|
-
var
|
|
5005
|
+
var import_viem17 = require("viem");
|
|
4905
5006
|
|
|
4906
5007
|
// src/contracts/errors.ts
|
|
4907
5008
|
var contractErrors = {
|
|
@@ -5493,10 +5594,132 @@ function getReputationPerUsdcLimit(publicClient, diamondAddress, params) {
|
|
|
5493
5594
|
);
|
|
5494
5595
|
}
|
|
5495
5596
|
|
|
5496
|
-
// src/contracts/
|
|
5597
|
+
// src/contracts/p2p-stake/index.ts
|
|
5497
5598
|
var import_neverthrow11 = require("neverthrow");
|
|
5498
5599
|
var import_viem13 = require("viem");
|
|
5499
5600
|
|
|
5601
|
+
// src/stake/errors.ts
|
|
5602
|
+
var StakeError = class extends SdkError {
|
|
5603
|
+
constructor(message, options) {
|
|
5604
|
+
super(message, options);
|
|
5605
|
+
this.name = "StakeError";
|
|
5606
|
+
}
|
|
5607
|
+
};
|
|
5608
|
+
|
|
5609
|
+
// src/stake/validation.ts
|
|
5610
|
+
var import_zod8 = require("zod");
|
|
5611
|
+
var ZodGetUserStakeParamsSchema = import_zod8.z.object({
|
|
5612
|
+
user: ZodAddressSchema
|
|
5613
|
+
});
|
|
5614
|
+
var ZodGetStakeBoostConfigParamsSchema = import_zod8.z.object({
|
|
5615
|
+
currency: ZodCurrencySchema
|
|
5616
|
+
});
|
|
5617
|
+
var ZodGetP2pTokenBalanceParamsSchema = import_zod8.z.object({
|
|
5618
|
+
address: ZodAddressSchema
|
|
5619
|
+
});
|
|
5620
|
+
var ZodStakeParamsSchema = import_zod8.z.object({
|
|
5621
|
+
tokens: import_zod8.z.bigint().positive()
|
|
5622
|
+
});
|
|
5623
|
+
var ZodTopUpParamsSchema = import_zod8.z.object({
|
|
5624
|
+
tokens: import_zod8.z.bigint().positive()
|
|
5625
|
+
});
|
|
5626
|
+
|
|
5627
|
+
// src/contracts/p2p-stake/index.ts
|
|
5628
|
+
function getUserStake(publicClient, diamondAddress, params) {
|
|
5629
|
+
return validate(
|
|
5630
|
+
ZodGetUserStakeParamsSchema,
|
|
5631
|
+
params,
|
|
5632
|
+
(message, cause, data) => new StakeError(message, {
|
|
5633
|
+
code: "VALIDATION_ERROR",
|
|
5634
|
+
cause,
|
|
5635
|
+
context: { params: data }
|
|
5636
|
+
})
|
|
5637
|
+
).asyncAndThen(
|
|
5638
|
+
(validated) => import_neverthrow11.ResultAsync.fromPromise(
|
|
5639
|
+
publicClient.readContract({
|
|
5640
|
+
address: diamondAddress,
|
|
5641
|
+
abi: ABIS.FACETS.STAKE,
|
|
5642
|
+
functionName: "getUserStake",
|
|
5643
|
+
args: [validated.user]
|
|
5644
|
+
}),
|
|
5645
|
+
(error) => new StakeError("Failed to read user stake", {
|
|
5646
|
+
code: "CONTRACT_READ_ERROR",
|
|
5647
|
+
cause: error,
|
|
5648
|
+
context: { user: validated.user, diamondAddress }
|
|
5649
|
+
})
|
|
5650
|
+
)
|
|
5651
|
+
);
|
|
5652
|
+
}
|
|
5653
|
+
function getStakeBoostConfig(publicClient, diamondAddress, params) {
|
|
5654
|
+
return validate(
|
|
5655
|
+
ZodGetStakeBoostConfigParamsSchema,
|
|
5656
|
+
params,
|
|
5657
|
+
(message, cause, data) => new StakeError(message, {
|
|
5658
|
+
code: "VALIDATION_ERROR",
|
|
5659
|
+
cause,
|
|
5660
|
+
context: { params: data }
|
|
5661
|
+
})
|
|
5662
|
+
).asyncAndThen(
|
|
5663
|
+
(validated) => import_neverthrow11.ResultAsync.fromPromise(
|
|
5664
|
+
publicClient.readContract({
|
|
5665
|
+
address: diamondAddress,
|
|
5666
|
+
abi: ABIS.FACETS.STAKE,
|
|
5667
|
+
functionName: "getStakeBoostConfig",
|
|
5668
|
+
args: [(0, import_viem13.stringToHex)(validated.currency, { size: 32 })]
|
|
5669
|
+
}),
|
|
5670
|
+
(error) => new StakeError("Failed to read stake boost config", {
|
|
5671
|
+
code: "CONTRACT_READ_ERROR",
|
|
5672
|
+
cause: error,
|
|
5673
|
+
context: { currency: validated.currency, diamondAddress }
|
|
5674
|
+
})
|
|
5675
|
+
)
|
|
5676
|
+
);
|
|
5677
|
+
}
|
|
5678
|
+
function getStakeBoostGlobals(publicClient, diamondAddress) {
|
|
5679
|
+
return import_neverthrow11.ResultAsync.fromPromise(
|
|
5680
|
+
publicClient.readContract({
|
|
5681
|
+
address: diamondAddress,
|
|
5682
|
+
abi: ABIS.FACETS.STAKE,
|
|
5683
|
+
functionName: "getStakeBoostGlobals",
|
|
5684
|
+
args: []
|
|
5685
|
+
}),
|
|
5686
|
+
(error) => new StakeError("Failed to read stake boost globals", {
|
|
5687
|
+
code: "CONTRACT_READ_ERROR",
|
|
5688
|
+
cause: error,
|
|
5689
|
+
context: { diamondAddress }
|
|
5690
|
+
})
|
|
5691
|
+
);
|
|
5692
|
+
}
|
|
5693
|
+
function getP2pTokenBalance(publicClient, p2pTokenAddress, params) {
|
|
5694
|
+
return validate(
|
|
5695
|
+
ZodGetP2pTokenBalanceParamsSchema,
|
|
5696
|
+
params,
|
|
5697
|
+
(message, cause, data) => new StakeError(message, {
|
|
5698
|
+
code: "VALIDATION_ERROR",
|
|
5699
|
+
cause,
|
|
5700
|
+
context: { params: data }
|
|
5701
|
+
})
|
|
5702
|
+
).asyncAndThen(
|
|
5703
|
+
(validated) => import_neverthrow11.ResultAsync.fromPromise(
|
|
5704
|
+
publicClient.readContract({
|
|
5705
|
+
address: p2pTokenAddress,
|
|
5706
|
+
abi: ABIS.EXTERNAL.USDC,
|
|
5707
|
+
functionName: "balanceOf",
|
|
5708
|
+
args: [validated.address]
|
|
5709
|
+
}),
|
|
5710
|
+
(error) => new StakeError("Failed to read P2P token balance", {
|
|
5711
|
+
code: "CONTRACT_READ_ERROR",
|
|
5712
|
+
cause: error,
|
|
5713
|
+
context: { address: validated.address, p2pTokenAddress }
|
|
5714
|
+
})
|
|
5715
|
+
)
|
|
5716
|
+
);
|
|
5717
|
+
}
|
|
5718
|
+
|
|
5719
|
+
// src/contracts/reputation-manager/writes.ts
|
|
5720
|
+
var import_neverthrow12 = require("neverthrow");
|
|
5721
|
+
var import_viem14 = require("viem");
|
|
5722
|
+
|
|
5500
5723
|
// src/zkkyc/errors.ts
|
|
5501
5724
|
var ZkkycError = class extends SdkError {
|
|
5502
5725
|
constructor(message, options) {
|
|
@@ -5506,75 +5729,75 @@ var ZkkycError = class extends SdkError {
|
|
|
5506
5729
|
};
|
|
5507
5730
|
|
|
5508
5731
|
// src/zkkyc/validation.ts
|
|
5509
|
-
var
|
|
5510
|
-
var ZodAnonAadharProofParamsSchema =
|
|
5511
|
-
nullifierSeed:
|
|
5512
|
-
nullifier:
|
|
5513
|
-
timestamp:
|
|
5514
|
-
signal:
|
|
5515
|
-
revealArray:
|
|
5516
|
-
packedGroth16Proof:
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5732
|
+
var import_zod9 = require("zod");
|
|
5733
|
+
var ZodAnonAadharProofParamsSchema = import_zod9.z.object({
|
|
5734
|
+
nullifierSeed: import_zod9.z.bigint(),
|
|
5735
|
+
nullifier: import_zod9.z.bigint(),
|
|
5736
|
+
timestamp: import_zod9.z.bigint(),
|
|
5737
|
+
signal: import_zod9.z.bigint(),
|
|
5738
|
+
revealArray: import_zod9.z.tuple([import_zod9.z.bigint(), import_zod9.z.bigint(), import_zod9.z.bigint(), import_zod9.z.bigint()]),
|
|
5739
|
+
packedGroth16Proof: import_zod9.z.tuple([
|
|
5740
|
+
import_zod9.z.bigint(),
|
|
5741
|
+
import_zod9.z.bigint(),
|
|
5742
|
+
import_zod9.z.bigint(),
|
|
5743
|
+
import_zod9.z.bigint(),
|
|
5744
|
+
import_zod9.z.bigint(),
|
|
5745
|
+
import_zod9.z.bigint(),
|
|
5746
|
+
import_zod9.z.bigint(),
|
|
5747
|
+
import_zod9.z.bigint()
|
|
5525
5748
|
])
|
|
5526
5749
|
});
|
|
5527
|
-
var ZodSocialVerifyParamsSchema =
|
|
5528
|
-
_socialName:
|
|
5529
|
-
proofs:
|
|
5530
|
-
|
|
5531
|
-
claimInfo:
|
|
5532
|
-
provider:
|
|
5533
|
-
parameters:
|
|
5534
|
-
context:
|
|
5750
|
+
var ZodSocialVerifyParamsSchema = import_zod9.z.object({
|
|
5751
|
+
_socialName: import_zod9.z.string(),
|
|
5752
|
+
proofs: import_zod9.z.array(
|
|
5753
|
+
import_zod9.z.object({
|
|
5754
|
+
claimInfo: import_zod9.z.object({
|
|
5755
|
+
provider: import_zod9.z.string(),
|
|
5756
|
+
parameters: import_zod9.z.string(),
|
|
5757
|
+
context: import_zod9.z.string()
|
|
5535
5758
|
}),
|
|
5536
|
-
signedClaim:
|
|
5537
|
-
claim:
|
|
5538
|
-
identifier:
|
|
5759
|
+
signedClaim: import_zod9.z.object({
|
|
5760
|
+
claim: import_zod9.z.object({
|
|
5761
|
+
identifier: import_zod9.z.string(),
|
|
5539
5762
|
owner: ZodAddressSchema,
|
|
5540
|
-
timestampS:
|
|
5541
|
-
epoch:
|
|
5763
|
+
timestampS: import_zod9.z.number(),
|
|
5764
|
+
epoch: import_zod9.z.number()
|
|
5542
5765
|
}),
|
|
5543
|
-
signatures:
|
|
5766
|
+
signatures: import_zod9.z.array(import_zod9.z.string())
|
|
5544
5767
|
})
|
|
5545
5768
|
})
|
|
5546
5769
|
)
|
|
5547
5770
|
});
|
|
5548
|
-
var ZodSolidityVerifierParametersSchema =
|
|
5549
|
-
version:
|
|
5771
|
+
var ZodSolidityVerifierParametersSchema = import_zod9.z.object({
|
|
5772
|
+
version: import_zod9.z.string().refine((val) => val.startsWith("0x"), {
|
|
5550
5773
|
message: "Version must be a hex string"
|
|
5551
5774
|
}),
|
|
5552
|
-
proofVerificationData:
|
|
5553
|
-
vkeyHash:
|
|
5775
|
+
proofVerificationData: import_zod9.z.object({
|
|
5776
|
+
vkeyHash: import_zod9.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5554
5777
|
message: "Invalid bytes32 hex string"
|
|
5555
5778
|
}),
|
|
5556
|
-
proof:
|
|
5779
|
+
proof: import_zod9.z.string().refine((val) => val.startsWith("0x"), {
|
|
5557
5780
|
message: "Proof must be a hex string"
|
|
5558
5781
|
}),
|
|
5559
|
-
publicInputs:
|
|
5560
|
-
|
|
5782
|
+
publicInputs: import_zod9.z.array(
|
|
5783
|
+
import_zod9.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
|
|
5561
5784
|
message: "Each public input must be a valid bytes32 hex string"
|
|
5562
5785
|
})
|
|
5563
5786
|
)
|
|
5564
5787
|
}),
|
|
5565
|
-
committedInputs:
|
|
5788
|
+
committedInputs: import_zod9.z.string().refine((val) => val.startsWith("0x"), {
|
|
5566
5789
|
message: "Committed inputs must be a hex string"
|
|
5567
5790
|
}),
|
|
5568
|
-
serviceConfig:
|
|
5569
|
-
validityPeriodInSeconds:
|
|
5570
|
-
domain:
|
|
5571
|
-
scope:
|
|
5572
|
-
devMode:
|
|
5791
|
+
serviceConfig: import_zod9.z.object({
|
|
5792
|
+
validityPeriodInSeconds: import_zod9.z.number().int().nonnegative(),
|
|
5793
|
+
domain: import_zod9.z.string(),
|
|
5794
|
+
scope: import_zod9.z.string(),
|
|
5795
|
+
devMode: import_zod9.z.boolean()
|
|
5573
5796
|
})
|
|
5574
5797
|
});
|
|
5575
|
-
var ZodZkPassportRegisterParamsSchema =
|
|
5798
|
+
var ZodZkPassportRegisterParamsSchema = import_zod9.z.object({
|
|
5576
5799
|
params: ZodSolidityVerifierParametersSchema,
|
|
5577
|
-
isIDCard:
|
|
5800
|
+
isIDCard: import_zod9.z.boolean()
|
|
5578
5801
|
});
|
|
5579
5802
|
|
|
5580
5803
|
// src/contracts/reputation-manager/writes.ts
|
|
@@ -5584,10 +5807,10 @@ function prepareSocialVerify(reputationManagerAddress, params) {
|
|
|
5584
5807
|
params,
|
|
5585
5808
|
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
5586
5809
|
).andThen(
|
|
5587
|
-
(validated) =>
|
|
5810
|
+
(validated) => import_neverthrow12.Result.fromThrowable(
|
|
5588
5811
|
() => ({
|
|
5589
5812
|
to: reputationManagerAddress,
|
|
5590
|
-
data: (0,
|
|
5813
|
+
data: (0, import_viem14.encodeFunctionData)({
|
|
5591
5814
|
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
5592
5815
|
functionName: "socialVerify",
|
|
5593
5816
|
args: [
|
|
@@ -5619,10 +5842,10 @@ function prepareSubmitAnonAadharProof(reputationManagerAddress, params) {
|
|
|
5619
5842
|
params,
|
|
5620
5843
|
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
5621
5844
|
).andThen(
|
|
5622
|
-
(validated) =>
|
|
5845
|
+
(validated) => import_neverthrow12.Result.fromThrowable(
|
|
5623
5846
|
() => ({
|
|
5624
5847
|
to: reputationManagerAddress,
|
|
5625
|
-
data: (0,
|
|
5848
|
+
data: (0, import_viem14.encodeFunctionData)({
|
|
5626
5849
|
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
5627
5850
|
functionName: "submitAnonAadharProof",
|
|
5628
5851
|
args: [
|
|
@@ -5648,7 +5871,7 @@ function prepareZkPassportRegister(reputationManagerAddress, params) {
|
|
|
5648
5871
|
params,
|
|
5649
5872
|
(message, cause, data) => new ZkkycError(message, { code: "VALIDATION_ERROR", cause, context: { params: data } })
|
|
5650
5873
|
).andThen(
|
|
5651
|
-
(validated) =>
|
|
5874
|
+
(validated) => import_neverthrow12.Result.fromThrowable(
|
|
5652
5875
|
() => {
|
|
5653
5876
|
const { proofVerificationData, serviceConfig, committedInputs, version } = validated.params;
|
|
5654
5877
|
const proofVerificationParams = {
|
|
@@ -5668,7 +5891,7 @@ function prepareZkPassportRegister(reputationManagerAddress, params) {
|
|
|
5668
5891
|
};
|
|
5669
5892
|
return {
|
|
5670
5893
|
to: reputationManagerAddress,
|
|
5671
|
-
data: (0,
|
|
5894
|
+
data: (0, import_viem14.encodeFunctionData)({
|
|
5672
5895
|
abi: ABIS.EXTERNAL.REPUTATION_MANAGER,
|
|
5673
5896
|
functionName: "zkPassportRegister",
|
|
5674
5897
|
args: [proofVerificationParams, validated.isIDCard]
|
|
@@ -5684,8 +5907,8 @@ function prepareZkPassportRegister(reputationManagerAddress, params) {
|
|
|
5684
5907
|
}
|
|
5685
5908
|
|
|
5686
5909
|
// src/contracts/tx-limits/index.ts
|
|
5687
|
-
var
|
|
5688
|
-
var
|
|
5910
|
+
var import_neverthrow13 = require("neverthrow");
|
|
5911
|
+
var import_viem15 = require("viem");
|
|
5689
5912
|
|
|
5690
5913
|
// src/profile/errors.ts
|
|
5691
5914
|
var ProfileError = class extends SdkError {
|
|
@@ -5696,18 +5919,18 @@ var ProfileError = class extends SdkError {
|
|
|
5696
5919
|
};
|
|
5697
5920
|
|
|
5698
5921
|
// src/profile/validation.ts
|
|
5699
|
-
var
|
|
5700
|
-
var ZodUsdcBalanceParamsSchema =
|
|
5922
|
+
var import_zod10 = require("zod");
|
|
5923
|
+
var ZodUsdcBalanceParamsSchema = import_zod10.z.object({
|
|
5701
5924
|
address: ZodAddressSchema
|
|
5702
5925
|
});
|
|
5703
|
-
var ZodUsdcAllowanceParamsSchema =
|
|
5926
|
+
var ZodUsdcAllowanceParamsSchema = import_zod10.z.object({
|
|
5704
5927
|
owner: ZodAddressSchema
|
|
5705
5928
|
});
|
|
5706
|
-
var ZodGetBalancesParamsSchema =
|
|
5929
|
+
var ZodGetBalancesParamsSchema = import_zod10.z.object({
|
|
5707
5930
|
address: ZodAddressSchema,
|
|
5708
5931
|
currency: ZodCurrencySchema
|
|
5709
5932
|
});
|
|
5710
|
-
var ZodTxLimitsParamsSchema =
|
|
5933
|
+
var ZodTxLimitsParamsSchema = import_zod10.z.object({
|
|
5711
5934
|
address: ZodAddressSchema,
|
|
5712
5935
|
currency: ZodCurrencySchema
|
|
5713
5936
|
});
|
|
@@ -5723,12 +5946,12 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
5723
5946
|
context: { params: data }
|
|
5724
5947
|
})
|
|
5725
5948
|
).asyncAndThen(
|
|
5726
|
-
(validated) =>
|
|
5949
|
+
(validated) => import_neverthrow13.ResultAsync.fromPromise(
|
|
5727
5950
|
publicClient.readContract({
|
|
5728
5951
|
address: diamondAddress,
|
|
5729
5952
|
abi: ABIS.FACETS.ORDER_FLOW,
|
|
5730
5953
|
functionName: "userTxLimit",
|
|
5731
|
-
args: [validated.address, (0,
|
|
5954
|
+
args: [validated.address, (0, import_viem15.stringToHex)(validated.currency, { size: 32 })]
|
|
5732
5955
|
}),
|
|
5733
5956
|
(error) => new ProfileError("Failed to read tx limits", {
|
|
5734
5957
|
code: "CONTRACT_READ_ERROR",
|
|
@@ -5736,15 +5959,15 @@ function getTxLimits(publicClient, diamondAddress, params) {
|
|
|
5736
5959
|
context: { address: validated.address, currency: validated.currency, diamondAddress }
|
|
5737
5960
|
})
|
|
5738
5961
|
).map(([buyLimit, sellLimit]) => ({
|
|
5739
|
-
buyLimit: Number((0,
|
|
5740
|
-
sellLimit: Number((0,
|
|
5962
|
+
buyLimit: Number((0, import_viem15.formatUnits)(buyLimit, 6)),
|
|
5963
|
+
sellLimit: Number((0, import_viem15.formatUnits)(sellLimit, 6))
|
|
5741
5964
|
}))
|
|
5742
5965
|
);
|
|
5743
5966
|
}
|
|
5744
5967
|
|
|
5745
5968
|
// src/contracts/usdc/index.ts
|
|
5746
|
-
var
|
|
5747
|
-
var
|
|
5969
|
+
var import_neverthrow14 = require("neverthrow");
|
|
5970
|
+
var import_viem16 = require("viem");
|
|
5748
5971
|
function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
5749
5972
|
return validate(
|
|
5750
5973
|
ZodUsdcBalanceParamsSchema,
|
|
@@ -5755,7 +5978,7 @@ function getUsdcBalance(publicClient, usdcAddress, params) {
|
|
|
5755
5978
|
context: { params: data }
|
|
5756
5979
|
})
|
|
5757
5980
|
).asyncAndThen(
|
|
5758
|
-
(validated) =>
|
|
5981
|
+
(validated) => import_neverthrow14.ResultAsync.fromPromise(
|
|
5759
5982
|
publicClient.readContract({
|
|
5760
5983
|
address: usdcAddress,
|
|
5761
5984
|
abi: ABIS.EXTERNAL.USDC,
|
|
@@ -5780,10 +6003,10 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
5780
6003
|
context: { params: data }
|
|
5781
6004
|
})
|
|
5782
6005
|
).asyncAndThen(
|
|
5783
|
-
(validated) =>
|
|
6006
|
+
(validated) => import_neverthrow14.ResultAsync.fromPromise(
|
|
5784
6007
|
publicClient.readContract({
|
|
5785
6008
|
address: usdcAddress,
|
|
5786
|
-
abi:
|
|
6009
|
+
abi: import_viem16.erc20Abi,
|
|
5787
6010
|
functionName: "allowance",
|
|
5788
6011
|
args: [validated.owner, diamondAddress]
|
|
5789
6012
|
}),
|
|
@@ -5797,7 +6020,7 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
5797
6020
|
}
|
|
5798
6021
|
|
|
5799
6022
|
// src/orders/internal/routing/routing.ts
|
|
5800
|
-
var
|
|
6023
|
+
var import_neverthrow15 = require("neverthrow");
|
|
5801
6024
|
var EPSILON = 0.25;
|
|
5802
6025
|
var RECOVERY_SCALE = 0.3;
|
|
5803
6026
|
var BOOTSTRAP_MAX_WEIGHT = 25;
|
|
@@ -5864,7 +6087,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5864
6087
|
attemptsLeft,
|
|
5865
6088
|
remainingCircles: remaining.length
|
|
5866
6089
|
});
|
|
5867
|
-
return (0,
|
|
6090
|
+
return (0, import_neverthrow15.errAsync)(
|
|
5868
6091
|
new OrderRoutingError("No eligible circles found", {
|
|
5869
6092
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5870
6093
|
})
|
|
@@ -5872,7 +6095,7 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5872
6095
|
}
|
|
5873
6096
|
const selected = selectCircle(remaining);
|
|
5874
6097
|
if (!selected) {
|
|
5875
|
-
return (0,
|
|
6098
|
+
return (0, import_neverthrow15.errAsync)(
|
|
5876
6099
|
new OrderRoutingError("No eligible circles found", {
|
|
5877
6100
|
code: "NO_ELIGIBLE_CIRCLES"
|
|
5878
6101
|
})
|
|
@@ -5890,11 +6113,11 @@ function selectCircleForOrderAsync(circles, orderCurrency, validateCircle, logge
|
|
|
5890
6113
|
circleId: String(circleId),
|
|
5891
6114
|
error: String(error)
|
|
5892
6115
|
});
|
|
5893
|
-
return (0,
|
|
6116
|
+
return (0, import_neverthrow15.okAsync)(false);
|
|
5894
6117
|
}).andThen((isValid) => {
|
|
5895
6118
|
if (isValid) {
|
|
5896
6119
|
logger.info("circle validated successfully", { circleId: String(circleId) });
|
|
5897
|
-
return (0,
|
|
6120
|
+
return (0, import_neverthrow15.okAsync)(circleId);
|
|
5898
6121
|
}
|
|
5899
6122
|
logger.debug("circle failed validation, retrying", {
|
|
5900
6123
|
circleId: String(circleId),
|
|
@@ -5972,7 +6195,7 @@ function createOrderRouter(config) {
|
|
|
5972
6195
|
const logger = config.logger ?? noopLogger;
|
|
5973
6196
|
return {
|
|
5974
6197
|
selectCircle(params) {
|
|
5975
|
-
const currencyHex = (0,
|
|
6198
|
+
const currencyHex = (0, import_viem17.stringToHex)(params.currency, { size: 32 });
|
|
5976
6199
|
logger.info("selectCircle started", {
|
|
5977
6200
|
currency: params.currency,
|
|
5978
6201
|
user: params.user,
|
|
@@ -6004,8 +6227,8 @@ function createOrderRouter(config) {
|
|
|
6004
6227
|
}
|
|
6005
6228
|
|
|
6006
6229
|
// src/orders/normalize.ts
|
|
6007
|
-
var
|
|
6008
|
-
var
|
|
6230
|
+
var import_neverthrow16 = require("neverthrow");
|
|
6231
|
+
var import_viem18 = require("viem");
|
|
6009
6232
|
var ORDER_TYPE_MAP = {
|
|
6010
6233
|
[ORDER_TYPE.BUY]: "buy",
|
|
6011
6234
|
[ORDER_TYPE.SELL]: "sell",
|
|
@@ -6031,23 +6254,23 @@ function malformed(field, value, context) {
|
|
|
6031
6254
|
}
|
|
6032
6255
|
function mapOrderType(v, ctx) {
|
|
6033
6256
|
const t = ORDER_TYPE_MAP[v];
|
|
6034
|
-
return t ? (0,
|
|
6257
|
+
return t ? (0, import_neverthrow16.ok)(t) : (0, import_neverthrow16.err)(malformed("orderType", v, ctx));
|
|
6035
6258
|
}
|
|
6036
6259
|
function mapOrderStatus(v, ctx) {
|
|
6037
6260
|
const s = ORDER_STATUS_MAP[v];
|
|
6038
|
-
return s ? (0,
|
|
6261
|
+
return s ? (0, import_neverthrow16.ok)(s) : (0, import_neverthrow16.err)(malformed("status", v, ctx));
|
|
6039
6262
|
}
|
|
6040
6263
|
function mapDisputeStatus(v, ctx) {
|
|
6041
6264
|
const s = DISPUTE_STATUS_MAP[v];
|
|
6042
|
-
return s ? (0,
|
|
6265
|
+
return s ? (0, import_neverthrow16.ok)(s) : (0, import_neverthrow16.err)(malformed("disputeStatus", v, ctx));
|
|
6043
6266
|
}
|
|
6044
6267
|
function decodeCurrency(hex) {
|
|
6045
|
-
return (0,
|
|
6268
|
+
return (0, import_viem18.hexToString)(hex, { size: 32 }).replaceAll("\0", "");
|
|
6046
6269
|
}
|
|
6047
6270
|
function normalizeContractOrder(raw, details) {
|
|
6048
|
-
if (raw.id === 0n && (0,
|
|
6271
|
+
if (raw.id === 0n && (0, import_viem18.isAddressEqual)(raw.user, import_viem18.zeroAddress)) return (0, import_neverthrow16.ok)(null);
|
|
6049
6272
|
const ctx = { orderId: raw.id.toString() };
|
|
6050
|
-
return
|
|
6273
|
+
return import_neverthrow16.Result.combine([
|
|
6051
6274
|
mapOrderType(raw.orderType, ctx),
|
|
6052
6275
|
mapOrderStatus(raw.status, ctx),
|
|
6053
6276
|
mapDisputeStatus(raw.disputeInfo.status, ctx)
|
|
@@ -6078,7 +6301,7 @@ function normalizeContractOrder(raw, details) {
|
|
|
6078
6301
|
}
|
|
6079
6302
|
function normalizeSubgraphOrder(raw) {
|
|
6080
6303
|
const ctx = { orderId: raw.orderId };
|
|
6081
|
-
return
|
|
6304
|
+
return import_neverthrow16.Result.combine([
|
|
6082
6305
|
mapOrderType(raw.type, ctx),
|
|
6083
6306
|
mapOrderStatus(raw.status, ctx),
|
|
6084
6307
|
mapDisputeStatus(raw.disputeStatus, ctx)
|
|
@@ -6111,7 +6334,7 @@ function normalizeSubgraphOrder(raw) {
|
|
|
6111
6334
|
}
|
|
6112
6335
|
|
|
6113
6336
|
// src/orders/subgraph/index.ts
|
|
6114
|
-
var
|
|
6337
|
+
var import_neverthrow17 = require("neverthrow");
|
|
6115
6338
|
|
|
6116
6339
|
// src/orders/subgraph/queries.ts
|
|
6117
6340
|
var ORDERS_BY_USER_QUERY = (
|
|
@@ -6172,7 +6395,7 @@ function getOrdersForUser(subgraphUrl, userAddress, skip, limit, logger = noopLo
|
|
|
6172
6395
|
context: { data: d }
|
|
6173
6396
|
})
|
|
6174
6397
|
).andThen(
|
|
6175
|
-
(validated) =>
|
|
6398
|
+
(validated) => import_neverthrow17.Result.combine(validated.orders_collection.map(normalizeSubgraphOrder))
|
|
6176
6399
|
)
|
|
6177
6400
|
);
|
|
6178
6401
|
}
|
|
@@ -6326,7 +6549,7 @@ function createOrders(config) {
|
|
|
6326
6549
|
).andThen(
|
|
6327
6550
|
({ order, details }) => normalizeContractOrder(order, details).asyncAndThen((normalized) => {
|
|
6328
6551
|
if (!normalized) {
|
|
6329
|
-
return (0,
|
|
6552
|
+
return (0, import_neverthrow18.errAsync)(
|
|
6330
6553
|
new OrdersError("Order not found", {
|
|
6331
6554
|
code: "ORDER_NOT_FOUND",
|
|
6332
6555
|
context: { orderId: params.orderId.toString() }
|
|
@@ -6334,7 +6557,7 @@ function createOrders(config) {
|
|
|
6334
6557
|
);
|
|
6335
6558
|
}
|
|
6336
6559
|
logger.debug("getOrder resolved", { orderId: params.orderId.toString() });
|
|
6337
|
-
return (0,
|
|
6560
|
+
return (0, import_neverthrow18.okAsync)(normalized);
|
|
6338
6561
|
})
|
|
6339
6562
|
);
|
|
6340
6563
|
},
|
|
@@ -6420,8 +6643,8 @@ function createPrices(config) {
|
|
|
6420
6643
|
}
|
|
6421
6644
|
|
|
6422
6645
|
// src/profile/contracts/actions.ts
|
|
6423
|
-
var
|
|
6424
|
-
var
|
|
6646
|
+
var import_neverthrow19 = require("neverthrow");
|
|
6647
|
+
var import_viem19 = require("viem");
|
|
6425
6648
|
function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
6426
6649
|
return validate(
|
|
6427
6650
|
ZodGetBalancesParamsSchema,
|
|
@@ -6432,7 +6655,7 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
6432
6655
|
context: { params: data }
|
|
6433
6656
|
})
|
|
6434
6657
|
).asyncAndThen(
|
|
6435
|
-
(validated) =>
|
|
6658
|
+
(validated) => import_neverthrow19.ResultAsync.combine([
|
|
6436
6659
|
getUsdcBalance(publicClient, usdcAddress, {
|
|
6437
6660
|
address: validated.address
|
|
6438
6661
|
}),
|
|
@@ -6446,8 +6669,8 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
|
|
|
6446
6669
|
})
|
|
6447
6670
|
)
|
|
6448
6671
|
]).map(([usdc, priceConfig]) => {
|
|
6449
|
-
const usdcFormatted = Number((0,
|
|
6450
|
-
const sellPriceFormatted = Number((0,
|
|
6672
|
+
const usdcFormatted = Number((0, import_viem19.formatUnits)(usdc, 6));
|
|
6673
|
+
const sellPriceFormatted = Number((0, import_viem19.formatUnits)(priceConfig.sellPrice, 6));
|
|
6451
6674
|
return {
|
|
6452
6675
|
usdc: usdcFormatted,
|
|
6453
6676
|
fiat: usdcFormatted * sellPriceFormatted,
|
|
@@ -6468,6 +6691,252 @@ function createProfile(config) {
|
|
|
6468
6691
|
};
|
|
6469
6692
|
}
|
|
6470
6693
|
|
|
6694
|
+
// src/stake/actions/cancel-unstake.ts
|
|
6695
|
+
var import_neverthrow21 = require("neverthrow");
|
|
6696
|
+
var import_viem20 = require("viem");
|
|
6697
|
+
|
|
6698
|
+
// src/stake/tx.ts
|
|
6699
|
+
var import_neverthrow20 = require("neverthrow");
|
|
6700
|
+
function submitPreparedTx2(input) {
|
|
6701
|
+
const { prepared, walletClient, publicClient, waitForReceipt } = input;
|
|
6702
|
+
const account = walletClient.account;
|
|
6703
|
+
if (!account) {
|
|
6704
|
+
return (0, import_neverthrow20.errAsync)(
|
|
6705
|
+
new StakeError("WalletClient is missing an account", {
|
|
6706
|
+
code: "TX_SUBMISSION_FAILED"
|
|
6707
|
+
})
|
|
6708
|
+
);
|
|
6709
|
+
}
|
|
6710
|
+
const chain = walletClient.chain;
|
|
6711
|
+
return import_neverthrow20.ResultAsync.fromPromise(
|
|
6712
|
+
walletClient.sendTransaction({
|
|
6713
|
+
account,
|
|
6714
|
+
chain,
|
|
6715
|
+
to: prepared.to,
|
|
6716
|
+
data: prepared.data,
|
|
6717
|
+
value: prepared.value
|
|
6718
|
+
}),
|
|
6719
|
+
(cause) => new StakeError("walletClient.sendTransaction rejected", {
|
|
6720
|
+
code: "TX_SUBMISSION_FAILED",
|
|
6721
|
+
cause
|
|
6722
|
+
})
|
|
6723
|
+
).andThen((hash) => {
|
|
6724
|
+
if (!waitForReceipt) {
|
|
6725
|
+
return (0, import_neverthrow20.okAsync)({ hash });
|
|
6726
|
+
}
|
|
6727
|
+
return import_neverthrow20.ResultAsync.fromPromise(
|
|
6728
|
+
publicClient.waitForTransactionReceipt({ hash }),
|
|
6729
|
+
(cause) => new StakeError("waitForTransactionReceipt failed", {
|
|
6730
|
+
code: "RECEIPT_TIMEOUT",
|
|
6731
|
+
cause
|
|
6732
|
+
})
|
|
6733
|
+
).andThen((receipt) => {
|
|
6734
|
+
if (receipt.status !== "success") {
|
|
6735
|
+
return (0, import_neverthrow20.errAsync)(
|
|
6736
|
+
new StakeError("Transaction reverted", {
|
|
6737
|
+
code: "TX_REVERTED",
|
|
6738
|
+
context: { hash, blockNumber: receipt.blockNumber.toString() }
|
|
6739
|
+
})
|
|
6740
|
+
);
|
|
6741
|
+
}
|
|
6742
|
+
return (0, import_neverthrow20.okAsync)({ hash, receipt });
|
|
6743
|
+
});
|
|
6744
|
+
});
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
// src/stake/actions/cancel-unstake.ts
|
|
6748
|
+
function createCancelUnstakeAction(input) {
|
|
6749
|
+
const { publicClient, diamondAddress } = input;
|
|
6750
|
+
const prepareFn = () => (0, import_neverthrow21.okAsync)({
|
|
6751
|
+
to: diamondAddress,
|
|
6752
|
+
data: (0, import_viem20.encodeFunctionData)({
|
|
6753
|
+
abi: ABIS.FACETS.STAKE,
|
|
6754
|
+
functionName: "p2pBoostCancelUnstake",
|
|
6755
|
+
args: []
|
|
6756
|
+
}),
|
|
6757
|
+
value: 0n
|
|
6758
|
+
});
|
|
6759
|
+
return {
|
|
6760
|
+
prepare() {
|
|
6761
|
+
return prepareFn();
|
|
6762
|
+
},
|
|
6763
|
+
execute({ walletClient, waitForReceipt }) {
|
|
6764
|
+
return prepareFn().andThen(
|
|
6765
|
+
(prepared) => submitPreparedTx2({ prepared, walletClient, publicClient, waitForReceipt })
|
|
6766
|
+
);
|
|
6767
|
+
}
|
|
6768
|
+
};
|
|
6769
|
+
}
|
|
6770
|
+
|
|
6771
|
+
// src/stake/actions/claim-unstake.ts
|
|
6772
|
+
var import_neverthrow22 = require("neverthrow");
|
|
6773
|
+
var import_viem21 = require("viem");
|
|
6774
|
+
function createClaimUnstakeAction(input) {
|
|
6775
|
+
const { publicClient, diamondAddress } = input;
|
|
6776
|
+
const prepareFn = () => (0, import_neverthrow22.okAsync)({
|
|
6777
|
+
to: diamondAddress,
|
|
6778
|
+
data: (0, import_viem21.encodeFunctionData)({
|
|
6779
|
+
abi: ABIS.FACETS.STAKE,
|
|
6780
|
+
functionName: "p2pBoostClaimUnstake",
|
|
6781
|
+
args: []
|
|
6782
|
+
}),
|
|
6783
|
+
value: 0n
|
|
6784
|
+
});
|
|
6785
|
+
return {
|
|
6786
|
+
prepare() {
|
|
6787
|
+
return prepareFn();
|
|
6788
|
+
},
|
|
6789
|
+
execute({ walletClient, waitForReceipt }) {
|
|
6790
|
+
return prepareFn().andThen(
|
|
6791
|
+
(prepared) => submitPreparedTx2({ prepared, walletClient, publicClient, waitForReceipt })
|
|
6792
|
+
);
|
|
6793
|
+
}
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
6796
|
+
|
|
6797
|
+
// src/stake/actions/request-unstake.ts
|
|
6798
|
+
var import_neverthrow23 = require("neverthrow");
|
|
6799
|
+
var import_viem22 = require("viem");
|
|
6800
|
+
function createRequestUnstakeAction(input) {
|
|
6801
|
+
const { publicClient, diamondAddress } = input;
|
|
6802
|
+
const prepareFn = () => (0, import_neverthrow23.okAsync)({
|
|
6803
|
+
to: diamondAddress,
|
|
6804
|
+
data: (0, import_viem22.encodeFunctionData)({
|
|
6805
|
+
abi: ABIS.FACETS.STAKE,
|
|
6806
|
+
functionName: "p2pBoostRequestUnstake",
|
|
6807
|
+
args: []
|
|
6808
|
+
}),
|
|
6809
|
+
value: 0n
|
|
6810
|
+
});
|
|
6811
|
+
return {
|
|
6812
|
+
prepare() {
|
|
6813
|
+
return prepareFn();
|
|
6814
|
+
},
|
|
6815
|
+
execute({ walletClient, waitForReceipt }) {
|
|
6816
|
+
return prepareFn().andThen(
|
|
6817
|
+
(prepared) => submitPreparedTx2({ prepared, walletClient, publicClient, waitForReceipt })
|
|
6818
|
+
);
|
|
6819
|
+
}
|
|
6820
|
+
};
|
|
6821
|
+
}
|
|
6822
|
+
|
|
6823
|
+
// src/stake/actions/stake.ts
|
|
6824
|
+
var import_viem23 = require("viem");
|
|
6825
|
+
function createStakeAction(input) {
|
|
6826
|
+
const { publicClient, diamondAddress } = input;
|
|
6827
|
+
const prepareFn = (params) => validate(
|
|
6828
|
+
ZodStakeParamsSchema,
|
|
6829
|
+
params,
|
|
6830
|
+
(message, cause, data) => new StakeError(message, {
|
|
6831
|
+
code: "VALIDATION_ERROR",
|
|
6832
|
+
cause,
|
|
6833
|
+
context: { data }
|
|
6834
|
+
})
|
|
6835
|
+
).map(({ tokens }) => ({
|
|
6836
|
+
to: diamondAddress,
|
|
6837
|
+
data: (0, import_viem23.encodeFunctionData)({
|
|
6838
|
+
abi: ABIS.FACETS.STAKE,
|
|
6839
|
+
functionName: "p2pBoostStake",
|
|
6840
|
+
args: [tokens]
|
|
6841
|
+
}),
|
|
6842
|
+
value: 0n
|
|
6843
|
+
}));
|
|
6844
|
+
return {
|
|
6845
|
+
prepare(params) {
|
|
6846
|
+
return prepareFn(params).asyncMap(async (tx) => tx);
|
|
6847
|
+
},
|
|
6848
|
+
execute({ walletClient, waitForReceipt, ...params }) {
|
|
6849
|
+
return prepareFn(params).asyncAndThen(
|
|
6850
|
+
(prepared) => submitPreparedTx2({ prepared, walletClient, publicClient, waitForReceipt })
|
|
6851
|
+
);
|
|
6852
|
+
}
|
|
6853
|
+
};
|
|
6854
|
+
}
|
|
6855
|
+
|
|
6856
|
+
// src/stake/actions/top-up.ts
|
|
6857
|
+
var import_viem24 = require("viem");
|
|
6858
|
+
function createTopUpAction(input) {
|
|
6859
|
+
const { publicClient, diamondAddress } = input;
|
|
6860
|
+
const prepareFn = (params) => validate(
|
|
6861
|
+
ZodTopUpParamsSchema,
|
|
6862
|
+
params,
|
|
6863
|
+
(message, cause, data) => new StakeError(message, {
|
|
6864
|
+
code: "VALIDATION_ERROR",
|
|
6865
|
+
cause,
|
|
6866
|
+
context: { data }
|
|
6867
|
+
})
|
|
6868
|
+
).map(({ tokens }) => ({
|
|
6869
|
+
to: diamondAddress,
|
|
6870
|
+
data: (0, import_viem24.encodeFunctionData)({
|
|
6871
|
+
abi: ABIS.FACETS.STAKE,
|
|
6872
|
+
functionName: "p2pBoostTopUp",
|
|
6873
|
+
args: [tokens]
|
|
6874
|
+
}),
|
|
6875
|
+
value: 0n
|
|
6876
|
+
}));
|
|
6877
|
+
return {
|
|
6878
|
+
prepare(params) {
|
|
6879
|
+
return prepareFn(params).asyncMap(async (tx) => tx);
|
|
6880
|
+
},
|
|
6881
|
+
execute({ walletClient, waitForReceipt, ...params }) {
|
|
6882
|
+
return prepareFn(params).asyncAndThen(
|
|
6883
|
+
(prepared) => submitPreparedTx2({ prepared, walletClient, publicClient, waitForReceipt })
|
|
6884
|
+
);
|
|
6885
|
+
}
|
|
6886
|
+
};
|
|
6887
|
+
}
|
|
6888
|
+
|
|
6889
|
+
// src/stake/normalize.ts
|
|
6890
|
+
var STATUS_MAP = {
|
|
6891
|
+
0: "none",
|
|
6892
|
+
1: "active",
|
|
6893
|
+
2: "cooldown",
|
|
6894
|
+
3: "seized"
|
|
6895
|
+
};
|
|
6896
|
+
function normalizeUserStake(raw) {
|
|
6897
|
+
return {
|
|
6898
|
+
stakedAmount: raw.stakedAmount,
|
|
6899
|
+
cooldownEnd: raw.cooldownEnd,
|
|
6900
|
+
status: STATUS_MAP[raw.status] ?? "none"
|
|
6901
|
+
};
|
|
6902
|
+
}
|
|
6903
|
+
function normalizeStakeBoostGlobals(raw) {
|
|
6904
|
+
const [
|
|
6905
|
+
p2pToken,
|
|
6906
|
+
fraudReserve,
|
|
6907
|
+
maxStakeTokens,
|
|
6908
|
+
normalCooldown,
|
|
6909
|
+
blacklistCooldown,
|
|
6910
|
+
tokenDecimals,
|
|
6911
|
+
totalStaked
|
|
6912
|
+
] = raw;
|
|
6913
|
+
return {
|
|
6914
|
+
p2pToken,
|
|
6915
|
+
fraudReserve,
|
|
6916
|
+
maxStakeTokens,
|
|
6917
|
+
normalCooldown,
|
|
6918
|
+
blacklistCooldown,
|
|
6919
|
+
tokenDecimals,
|
|
6920
|
+
totalStaked
|
|
6921
|
+
};
|
|
6922
|
+
}
|
|
6923
|
+
|
|
6924
|
+
// src/stake/client.ts
|
|
6925
|
+
function createStake(config) {
|
|
6926
|
+
const { publicClient, diamondAddress, p2pTokenAddress } = config;
|
|
6927
|
+
return {
|
|
6928
|
+
getUserStake: (params) => getUserStake(publicClient, diamondAddress, params).map(normalizeUserStake),
|
|
6929
|
+
getStakeBoostConfig: (params) => getStakeBoostConfig(publicClient, diamondAddress, params),
|
|
6930
|
+
getStakeBoostGlobals: () => getStakeBoostGlobals(publicClient, diamondAddress).map(normalizeStakeBoostGlobals),
|
|
6931
|
+
getP2pTokenBalance: (params) => getP2pTokenBalance(publicClient, p2pTokenAddress, params),
|
|
6932
|
+
stake: createStakeAction({ publicClient, diamondAddress }),
|
|
6933
|
+
topUp: createTopUpAction({ publicClient, diamondAddress }),
|
|
6934
|
+
requestUnstake: createRequestUnstakeAction({ publicClient, diamondAddress }),
|
|
6935
|
+
cancelUnstake: createCancelUnstakeAction({ publicClient, diamondAddress }),
|
|
6936
|
+
claimUnstake: createClaimUnstakeAction({ publicClient, diamondAddress })
|
|
6937
|
+
};
|
|
6938
|
+
}
|
|
6939
|
+
|
|
6471
6940
|
// src/zkkyc/client.ts
|
|
6472
6941
|
function createZkkyc(config) {
|
|
6473
6942
|
const { reputationManagerAddress } = config;
|
|
@@ -6527,6 +6996,11 @@ function SdkProvider({ children, ...config }) {
|
|
|
6527
6996
|
relayIdentity,
|
|
6528
6997
|
logger
|
|
6529
6998
|
}),
|
|
6999
|
+
stake: createStake({
|
|
7000
|
+
publicClient,
|
|
7001
|
+
diamondAddress: config.diamondAddress,
|
|
7002
|
+
p2pTokenAddress: config.p2pTokenAddress
|
|
7003
|
+
}),
|
|
6530
7004
|
zkkyc: config.reputationManagerAddress ? createZkkyc({
|
|
6531
7005
|
reputationManagerAddress: config.reputationManagerAddress
|
|
6532
7006
|
}) : void 0,
|
|
@@ -6537,6 +7011,7 @@ function SdkProvider({ children, ...config }) {
|
|
|
6537
7011
|
config.subgraphUrl,
|
|
6538
7012
|
config.diamondAddress,
|
|
6539
7013
|
config.usdcAddress,
|
|
7014
|
+
config.p2pTokenAddress,
|
|
6540
7015
|
config.reputationManagerAddress,
|
|
6541
7016
|
relayIdentityStore,
|
|
6542
7017
|
relayIdentity,
|
|
@@ -6561,6 +7036,9 @@ function usePrices() {
|
|
|
6561
7036
|
function useOrders() {
|
|
6562
7037
|
return useSdk().orders;
|
|
6563
7038
|
}
|
|
7039
|
+
function useStake() {
|
|
7040
|
+
return useSdk().stake;
|
|
7041
|
+
}
|
|
6564
7042
|
function useZkkyc() {
|
|
6565
7043
|
const zkkyc = useSdk().zkkyc;
|
|
6566
7044
|
if (!zkkyc) {
|
|
@@ -6637,6 +7115,7 @@ function useFingerprint(enabled) {
|
|
|
6637
7115
|
usePrices,
|
|
6638
7116
|
useProfile,
|
|
6639
7117
|
useSdk,
|
|
7118
|
+
useStake,
|
|
6640
7119
|
useWatchOrders,
|
|
6641
7120
|
useZkkyc
|
|
6642
7121
|
});
|