@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/profile.cjs CHANGED
@@ -505,6 +505,104 @@ var p2pConfigFacetAbi = [
505
505
  }
506
506
  ];
507
507
 
508
+ // src/contracts/abis/p2p-stake-boost-facet.ts
509
+ var p2pStakeBoostFacetAbi = [
510
+ {
511
+ inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
512
+ name: "p2pBoostStake",
513
+ outputs: [],
514
+ stateMutability: "nonpayable",
515
+ type: "function"
516
+ },
517
+ {
518
+ inputs: [{ internalType: "uint256", name: "tokens", type: "uint256" }],
519
+ name: "p2pBoostTopUp",
520
+ outputs: [],
521
+ stateMutability: "nonpayable",
522
+ type: "function"
523
+ },
524
+ {
525
+ inputs: [],
526
+ name: "p2pBoostRequestUnstake",
527
+ outputs: [],
528
+ stateMutability: "nonpayable",
529
+ type: "function"
530
+ },
531
+ {
532
+ inputs: [],
533
+ name: "p2pBoostClaimUnstake",
534
+ outputs: [],
535
+ stateMutability: "nonpayable",
536
+ type: "function"
537
+ },
538
+ {
539
+ inputs: [],
540
+ name: "p2pBoostCancelUnstake",
541
+ outputs: [],
542
+ stateMutability: "nonpayable",
543
+ type: "function"
544
+ },
545
+ {
546
+ inputs: [{ internalType: "address", name: "user", type: "address" }],
547
+ name: "getUserStake",
548
+ outputs: [
549
+ {
550
+ components: [
551
+ { internalType: "uint128", name: "stakedAmount", type: "uint128" },
552
+ { internalType: "uint64", name: "cooldownEnd", type: "uint64" },
553
+ { internalType: "uint8", name: "status", type: "uint8" }
554
+ ],
555
+ internalType: "struct P2PStakeBoostStorage.UserStake",
556
+ name: "",
557
+ type: "tuple"
558
+ }
559
+ ],
560
+ stateMutability: "view",
561
+ type: "function"
562
+ },
563
+ {
564
+ inputs: [{ internalType: "bytes32", name: "currency", type: "bytes32" }],
565
+ name: "getStakeBoostConfig",
566
+ outputs: [
567
+ {
568
+ components: [
569
+ {
570
+ internalType: "uint256",
571
+ name: "tokensPerUsdNumerator",
572
+ type: "uint256"
573
+ },
574
+ {
575
+ internalType: "uint256",
576
+ name: "tokensPerUsdDenominator",
577
+ type: "uint256"
578
+ },
579
+ { internalType: "uint256", name: "maxBoostUsd", type: "uint256" }
580
+ ],
581
+ internalType: "struct P2PStakeBoostStorage.BoostConfig",
582
+ name: "",
583
+ type: "tuple"
584
+ }
585
+ ],
586
+ stateMutability: "view",
587
+ type: "function"
588
+ },
589
+ {
590
+ inputs: [],
591
+ name: "getStakeBoostGlobals",
592
+ outputs: [
593
+ { internalType: "address", name: "p2pToken", type: "address" },
594
+ { internalType: "address", name: "fraudReserve", type: "address" },
595
+ { internalType: "uint256", name: "maxStakeTokens", type: "uint256" },
596
+ { internalType: "uint256", name: "normalCooldown", type: "uint256" },
597
+ { internalType: "uint256", name: "blacklistCooldown", type: "uint256" },
598
+ { internalType: "uint8", name: "tokenDecimals", type: "uint8" },
599
+ { internalType: "uint256", name: "totalStaked", type: "uint256" }
600
+ ],
601
+ stateMutability: "view",
602
+ type: "function"
603
+ }
604
+ ];
605
+
508
606
  // src/contracts/abis/reputation-manager.ts
509
607
  var reputationManagerAbi = [
510
608
  {
@@ -711,14 +809,16 @@ var reputationManagerAbi = [
711
809
  var DIAMOND_ABI = [
712
810
  ...orderFlowFacetAbi,
713
811
  ...orderProcessorFacetAbi,
714
- ...p2pConfigFacetAbi
812
+ ...p2pConfigFacetAbi,
813
+ ...p2pStakeBoostFacetAbi
715
814
  ];
716
815
  var ABIS = {
717
816
  DIAMOND: DIAMOND_ABI,
718
817
  FACETS: {
719
818
  ORDER_FLOW: orderFlowFacetAbi,
720
819
  ORDER_PROCESSOR: orderProcessorFacetAbi,
721
- CONFIG: p2pConfigFacetAbi
820
+ CONFIG: p2pConfigFacetAbi,
821
+ STAKE: p2pStakeBoostFacetAbi
722
822
  },
723
823
  EXTERNAL: {
724
824
  USDC: import_viem.erc20Abi,
@@ -1286,85 +1386,107 @@ function getPriceConfig(publicClient, diamondAddress, params) {
1286
1386
  );
1287
1387
  }
1288
1388
 
1289
- // src/contracts/reputation-manager/writes.ts
1389
+ // src/contracts/p2p-stake/index.ts
1290
1390
  var import_neverthrow6 = require("neverthrow");
1291
1391
  var import_viem5 = require("viem");
1292
1392
 
1293
- // src/zkkyc/validation.ts
1393
+ // src/stake/validation.ts
1294
1394
  var import_zod4 = require("zod");
1295
- var ZodAnonAadharProofParamsSchema = import_zod4.z.object({
1296
- nullifierSeed: import_zod4.z.bigint(),
1297
- nullifier: import_zod4.z.bigint(),
1298
- timestamp: import_zod4.z.bigint(),
1299
- signal: import_zod4.z.bigint(),
1300
- revealArray: import_zod4.z.tuple([import_zod4.z.bigint(), import_zod4.z.bigint(), import_zod4.z.bigint(), import_zod4.z.bigint()]),
1301
- packedGroth16Proof: import_zod4.z.tuple([
1302
- import_zod4.z.bigint(),
1303
- import_zod4.z.bigint(),
1304
- import_zod4.z.bigint(),
1305
- import_zod4.z.bigint(),
1306
- import_zod4.z.bigint(),
1307
- import_zod4.z.bigint(),
1308
- import_zod4.z.bigint(),
1309
- import_zod4.z.bigint()
1395
+ var ZodGetUserStakeParamsSchema = import_zod4.z.object({
1396
+ user: ZodAddressSchema
1397
+ });
1398
+ var ZodGetStakeBoostConfigParamsSchema = import_zod4.z.object({
1399
+ currency: ZodCurrencySchema
1400
+ });
1401
+ var ZodGetP2pTokenBalanceParamsSchema = import_zod4.z.object({
1402
+ address: ZodAddressSchema
1403
+ });
1404
+ var ZodStakeParamsSchema = import_zod4.z.object({
1405
+ tokens: import_zod4.z.bigint().positive()
1406
+ });
1407
+ var ZodTopUpParamsSchema = import_zod4.z.object({
1408
+ tokens: import_zod4.z.bigint().positive()
1409
+ });
1410
+
1411
+ // src/contracts/reputation-manager/writes.ts
1412
+ var import_neverthrow7 = require("neverthrow");
1413
+ var import_viem6 = require("viem");
1414
+
1415
+ // src/zkkyc/validation.ts
1416
+ var import_zod5 = require("zod");
1417
+ var ZodAnonAadharProofParamsSchema = import_zod5.z.object({
1418
+ nullifierSeed: import_zod5.z.bigint(),
1419
+ nullifier: import_zod5.z.bigint(),
1420
+ timestamp: import_zod5.z.bigint(),
1421
+ signal: import_zod5.z.bigint(),
1422
+ revealArray: import_zod5.z.tuple([import_zod5.z.bigint(), import_zod5.z.bigint(), import_zod5.z.bigint(), import_zod5.z.bigint()]),
1423
+ packedGroth16Proof: import_zod5.z.tuple([
1424
+ import_zod5.z.bigint(),
1425
+ import_zod5.z.bigint(),
1426
+ import_zod5.z.bigint(),
1427
+ import_zod5.z.bigint(),
1428
+ import_zod5.z.bigint(),
1429
+ import_zod5.z.bigint(),
1430
+ import_zod5.z.bigint(),
1431
+ import_zod5.z.bigint()
1310
1432
  ])
1311
1433
  });
1312
- var ZodSocialVerifyParamsSchema = import_zod4.z.object({
1313
- _socialName: import_zod4.z.string(),
1314
- proofs: import_zod4.z.array(
1315
- import_zod4.z.object({
1316
- claimInfo: import_zod4.z.object({
1317
- provider: import_zod4.z.string(),
1318
- parameters: import_zod4.z.string(),
1319
- context: import_zod4.z.string()
1434
+ var ZodSocialVerifyParamsSchema = import_zod5.z.object({
1435
+ _socialName: import_zod5.z.string(),
1436
+ proofs: import_zod5.z.array(
1437
+ import_zod5.z.object({
1438
+ claimInfo: import_zod5.z.object({
1439
+ provider: import_zod5.z.string(),
1440
+ parameters: import_zod5.z.string(),
1441
+ context: import_zod5.z.string()
1320
1442
  }),
1321
- signedClaim: import_zod4.z.object({
1322
- claim: import_zod4.z.object({
1323
- identifier: import_zod4.z.string(),
1443
+ signedClaim: import_zod5.z.object({
1444
+ claim: import_zod5.z.object({
1445
+ identifier: import_zod5.z.string(),
1324
1446
  owner: ZodAddressSchema,
1325
- timestampS: import_zod4.z.number(),
1326
- epoch: import_zod4.z.number()
1447
+ timestampS: import_zod5.z.number(),
1448
+ epoch: import_zod5.z.number()
1327
1449
  }),
1328
- signatures: import_zod4.z.array(import_zod4.z.string())
1450
+ signatures: import_zod5.z.array(import_zod5.z.string())
1329
1451
  })
1330
1452
  })
1331
1453
  )
1332
1454
  });
1333
- var ZodSolidityVerifierParametersSchema = import_zod4.z.object({
1334
- version: import_zod4.z.string().refine((val) => val.startsWith("0x"), {
1455
+ var ZodSolidityVerifierParametersSchema = import_zod5.z.object({
1456
+ version: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
1335
1457
  message: "Version must be a hex string"
1336
1458
  }),
1337
- proofVerificationData: import_zod4.z.object({
1338
- vkeyHash: import_zod4.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
1459
+ proofVerificationData: import_zod5.z.object({
1460
+ vkeyHash: import_zod5.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
1339
1461
  message: "Invalid bytes32 hex string"
1340
1462
  }),
1341
- proof: import_zod4.z.string().refine((val) => val.startsWith("0x"), {
1463
+ proof: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
1342
1464
  message: "Proof must be a hex string"
1343
1465
  }),
1344
- publicInputs: import_zod4.z.array(
1345
- import_zod4.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
1466
+ publicInputs: import_zod5.z.array(
1467
+ import_zod5.z.string().refine((val) => /^0x[a-fA-F0-9]{64}$/.test(val), {
1346
1468
  message: "Each public input must be a valid bytes32 hex string"
1347
1469
  })
1348
1470
  )
1349
1471
  }),
1350
- committedInputs: import_zod4.z.string().refine((val) => val.startsWith("0x"), {
1472
+ committedInputs: import_zod5.z.string().refine((val) => val.startsWith("0x"), {
1351
1473
  message: "Committed inputs must be a hex string"
1352
1474
  }),
1353
- serviceConfig: import_zod4.z.object({
1354
- validityPeriodInSeconds: import_zod4.z.number().int().nonnegative(),
1355
- domain: import_zod4.z.string(),
1356
- scope: import_zod4.z.string(),
1357
- devMode: import_zod4.z.boolean()
1475
+ serviceConfig: import_zod5.z.object({
1476
+ validityPeriodInSeconds: import_zod5.z.number().int().nonnegative(),
1477
+ domain: import_zod5.z.string(),
1478
+ scope: import_zod5.z.string(),
1479
+ devMode: import_zod5.z.boolean()
1358
1480
  })
1359
1481
  });
1360
- var ZodZkPassportRegisterParamsSchema = import_zod4.z.object({
1482
+ var ZodZkPassportRegisterParamsSchema = import_zod5.z.object({
1361
1483
  params: ZodSolidityVerifierParametersSchema,
1362
- isIDCard: import_zod4.z.boolean()
1484
+ isIDCard: import_zod5.z.boolean()
1363
1485
  });
1364
1486
 
1365
1487
  // src/contracts/tx-limits/index.ts
1366
- var import_neverthrow7 = require("neverthrow");
1367
- var import_viem6 = require("viem");
1488
+ var import_neverthrow8 = require("neverthrow");
1489
+ var import_viem7 = require("viem");
1368
1490
 
1369
1491
  // src/profile/errors.ts
1370
1492
  var ProfileError = class extends SdkError {
@@ -1375,18 +1497,18 @@ var ProfileError = class extends SdkError {
1375
1497
  };
1376
1498
 
1377
1499
  // src/profile/validation.ts
1378
- var import_zod5 = require("zod");
1379
- var ZodUsdcBalanceParamsSchema = import_zod5.z.object({
1500
+ var import_zod6 = require("zod");
1501
+ var ZodUsdcBalanceParamsSchema = import_zod6.z.object({
1380
1502
  address: ZodAddressSchema
1381
1503
  });
1382
- var ZodUsdcAllowanceParamsSchema = import_zod5.z.object({
1504
+ var ZodUsdcAllowanceParamsSchema = import_zod6.z.object({
1383
1505
  owner: ZodAddressSchema
1384
1506
  });
1385
- var ZodGetBalancesParamsSchema = import_zod5.z.object({
1507
+ var ZodGetBalancesParamsSchema = import_zod6.z.object({
1386
1508
  address: ZodAddressSchema,
1387
1509
  currency: ZodCurrencySchema
1388
1510
  });
1389
- var ZodTxLimitsParamsSchema = import_zod5.z.object({
1511
+ var ZodTxLimitsParamsSchema = import_zod6.z.object({
1390
1512
  address: ZodAddressSchema,
1391
1513
  currency: ZodCurrencySchema
1392
1514
  });
@@ -1402,12 +1524,12 @@ function getTxLimits(publicClient, diamondAddress, params) {
1402
1524
  context: { params: data }
1403
1525
  })
1404
1526
  ).asyncAndThen(
1405
- (validated) => import_neverthrow7.ResultAsync.fromPromise(
1527
+ (validated) => import_neverthrow8.ResultAsync.fromPromise(
1406
1528
  publicClient.readContract({
1407
1529
  address: diamondAddress,
1408
1530
  abi: ABIS.FACETS.ORDER_FLOW,
1409
1531
  functionName: "userTxLimit",
1410
- args: [validated.address, (0, import_viem6.stringToHex)(validated.currency, { size: 32 })]
1532
+ args: [validated.address, (0, import_viem7.stringToHex)(validated.currency, { size: 32 })]
1411
1533
  }),
1412
1534
  (error) => new ProfileError("Failed to read tx limits", {
1413
1535
  code: "CONTRACT_READ_ERROR",
@@ -1415,15 +1537,15 @@ function getTxLimits(publicClient, diamondAddress, params) {
1415
1537
  context: { address: validated.address, currency: validated.currency, diamondAddress }
1416
1538
  })
1417
1539
  ).map(([buyLimit, sellLimit]) => ({
1418
- buyLimit: Number((0, import_viem6.formatUnits)(buyLimit, 6)),
1419
- sellLimit: Number((0, import_viem6.formatUnits)(sellLimit, 6))
1540
+ buyLimit: Number((0, import_viem7.formatUnits)(buyLimit, 6)),
1541
+ sellLimit: Number((0, import_viem7.formatUnits)(sellLimit, 6))
1420
1542
  }))
1421
1543
  );
1422
1544
  }
1423
1545
 
1424
1546
  // src/contracts/usdc/index.ts
1425
- var import_neverthrow8 = require("neverthrow");
1426
- var import_viem7 = require("viem");
1547
+ var import_neverthrow9 = require("neverthrow");
1548
+ var import_viem8 = require("viem");
1427
1549
  function getUsdcBalance(publicClient, usdcAddress, params) {
1428
1550
  return validate(
1429
1551
  ZodUsdcBalanceParamsSchema,
@@ -1434,7 +1556,7 @@ function getUsdcBalance(publicClient, usdcAddress, params) {
1434
1556
  context: { params: data }
1435
1557
  })
1436
1558
  ).asyncAndThen(
1437
- (validated) => import_neverthrow8.ResultAsync.fromPromise(
1559
+ (validated) => import_neverthrow9.ResultAsync.fromPromise(
1438
1560
  publicClient.readContract({
1439
1561
  address: usdcAddress,
1440
1562
  abi: ABIS.EXTERNAL.USDC,
@@ -1459,10 +1581,10 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
1459
1581
  context: { params: data }
1460
1582
  })
1461
1583
  ).asyncAndThen(
1462
- (validated) => import_neverthrow8.ResultAsync.fromPromise(
1584
+ (validated) => import_neverthrow9.ResultAsync.fromPromise(
1463
1585
  publicClient.readContract({
1464
1586
  address: usdcAddress,
1465
- abi: import_viem7.erc20Abi,
1587
+ abi: import_viem8.erc20Abi,
1466
1588
  functionName: "allowance",
1467
1589
  args: [validated.owner, diamondAddress]
1468
1590
  }),
@@ -1476,8 +1598,8 @@ function getUsdcAllowance(publicClient, usdcAddress, diamondAddress, params) {
1476
1598
  }
1477
1599
 
1478
1600
  // src/profile/contracts/actions.ts
1479
- var import_neverthrow9 = require("neverthrow");
1480
- var import_viem8 = require("viem");
1601
+ var import_neverthrow10 = require("neverthrow");
1602
+ var import_viem9 = require("viem");
1481
1603
  function getBalances(publicClient, usdcAddress, diamondAddress, params) {
1482
1604
  return validate(
1483
1605
  ZodGetBalancesParamsSchema,
@@ -1488,7 +1610,7 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
1488
1610
  context: { params: data }
1489
1611
  })
1490
1612
  ).asyncAndThen(
1491
- (validated) => import_neverthrow9.ResultAsync.combine([
1613
+ (validated) => import_neverthrow10.ResultAsync.combine([
1492
1614
  getUsdcBalance(publicClient, usdcAddress, {
1493
1615
  address: validated.address
1494
1616
  }),
@@ -1502,8 +1624,8 @@ function getBalances(publicClient, usdcAddress, diamondAddress, params) {
1502
1624
  })
1503
1625
  )
1504
1626
  ]).map(([usdc, priceConfig]) => {
1505
- const usdcFormatted = Number((0, import_viem8.formatUnits)(usdc, 6));
1506
- const sellPriceFormatted = Number((0, import_viem8.formatUnits)(priceConfig.sellPrice, 6));
1627
+ const usdcFormatted = Number((0, import_viem9.formatUnits)(usdc, 6));
1628
+ const sellPriceFormatted = Number((0, import_viem9.formatUnits)(priceConfig.sellPrice, 6));
1507
1629
  return {
1508
1630
  usdc: usdcFormatted,
1509
1631
  fiat: usdcFormatted * sellPriceFormatted,