@slvr-labs/sdk 0.1.0 → 0.1.2

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.
Files changed (83) hide show
  1. package/README.md +42 -0
  2. package/dist/index.d.mts +2117 -0
  3. package/dist/index.d.ts +1903 -34
  4. package/dist/index.js +3091 -427
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +3035 -0
  7. package/dist/index.mjs.map +1 -0
  8. package/package.json +19 -11
  9. package/skills/slvr-bot/SKILL.md +9 -8
  10. package/skills/slvr-bot/references/api.md +8 -0
  11. package/dist/connect.d.ts +0 -47
  12. package/dist/connect.d.ts.map +0 -1
  13. package/dist/connect.js +0 -56
  14. package/dist/connect.js.map +0 -1
  15. package/dist/contracts/autoCommit.d.ts +0 -151
  16. package/dist/contracts/autoCommit.d.ts.map +0 -1
  17. package/dist/contracts/autoCommit.js +0 -426
  18. package/dist/contracts/autoCommit.js.map +0 -1
  19. package/dist/contracts/hub.d.ts +0 -50
  20. package/dist/contracts/hub.d.ts.map +0 -1
  21. package/dist/contracts/hub.js +0 -118
  22. package/dist/contracts/hub.js.map +0 -1
  23. package/dist/contracts/index.d.ts +0 -8
  24. package/dist/contracts/index.d.ts.map +0 -1
  25. package/dist/contracts/index.js +0 -18
  26. package/dist/contracts/index.js.map +0 -1
  27. package/dist/contracts/jackpot.d.ts +0 -21
  28. package/dist/contracts/jackpot.d.ts.map +0 -1
  29. package/dist/contracts/jackpot.js +0 -44
  30. package/dist/contracts/jackpot.js.map +0 -1
  31. package/dist/contracts/lottery.d.ts +0 -256
  32. package/dist/contracts/lottery.d.ts.map +0 -1
  33. package/dist/contracts/lottery.js +0 -767
  34. package/dist/contracts/lottery.js.map +0 -1
  35. package/dist/contracts/registry.d.ts +0 -53
  36. package/dist/contracts/registry.d.ts.map +0 -1
  37. package/dist/contracts/registry.js +0 -143
  38. package/dist/contracts/registry.js.map +0 -1
  39. package/dist/contracts/staking.d.ts +0 -101
  40. package/dist/contracts/staking.d.ts.map +0 -1
  41. package/dist/contracts/staking.js +0 -306
  42. package/dist/contracts/staking.js.map +0 -1
  43. package/dist/contracts/token.d.ts +0 -95
  44. package/dist/contracts/token.d.ts.map +0 -1
  45. package/dist/contracts/token.js +0 -273
  46. package/dist/contracts/token.js.map +0 -1
  47. package/dist/deployments.d.ts +0 -117
  48. package/dist/deployments.d.ts.map +0 -1
  49. package/dist/deployments.js +0 -74
  50. package/dist/deployments.js.map +0 -1
  51. package/dist/errors.d.ts +0 -39
  52. package/dist/errors.d.ts.map +0 -1
  53. package/dist/errors.js +0 -67
  54. package/dist/errors.js.map +0 -1
  55. package/dist/ev.d.ts +0 -123
  56. package/dist/ev.d.ts.map +0 -1
  57. package/dist/ev.js +0 -111
  58. package/dist/ev.js.map +0 -1
  59. package/dist/events.d.ts +0 -418
  60. package/dist/events.d.ts.map +0 -1
  61. package/dist/events.js +0 -87
  62. package/dist/events.js.map +0 -1
  63. package/dist/index.d.ts.map +0 -1
  64. package/dist/oracle.d.ts +0 -48
  65. package/dist/oracle.d.ts.map +0 -1
  66. package/dist/oracle.js +0 -77
  67. package/dist/oracle.js.map +0 -1
  68. package/dist/price.d.ts +0 -52
  69. package/dist/price.d.ts.map +0 -1
  70. package/dist/price.js +0 -78
  71. package/dist/price.js.map +0 -1
  72. package/dist/transaction.d.ts +0 -54
  73. package/dist/transaction.d.ts.map +0 -1
  74. package/dist/transaction.js +0 -105
  75. package/dist/transaction.js.map +0 -1
  76. package/dist/types.d.ts +0 -162
  77. package/dist/types.d.ts.map +0 -1
  78. package/dist/types.js +0 -23
  79. package/dist/types.js.map +0 -1
  80. package/dist/utils.d.ts +0 -58
  81. package/dist/utils.d.ts.map +0 -1
  82. package/dist/utils.js +0 -110
  83. package/dist/utils.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @slvr-labs/sdk
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/@slvr-labs/sdk.svg)](https://www.npmjs.com/package/@slvr-labs/sdk)
4
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
5
+ [![types: included](https://img.shields.io/badge/types-included-blue.svg)](#installation)
6
+
3
7
  TypeScript SDK for interacting with the Slvr protocol on Robinhood Chain.
4
8
 
5
9
  ## Installation
@@ -8,6 +12,9 @@ TypeScript SDK for interacting with the Slvr protocol on Robinhood Chain.
8
12
  npm install @slvr-labs/sdk viem
9
13
  ```
10
14
 
15
+ Ships both **ESM and CommonJS** builds with TypeScript declarations, so `import`
16
+ and `require` both work out of the box.
17
+
11
18
  ## Quick Start
12
19
 
13
20
  The fastest way — `SlvrSDK.connect` builds resilient clients (Multicall3
@@ -443,6 +450,32 @@ const stopBets = sdk.lottery.watchBets((e) => console.log(`bet of ${e.total} on
443
450
  // later: stopResolved(); stopBets();
444
451
  ```
445
452
 
453
+ ### Preflight, typed errors & gas control
454
+
455
+ Catch reverts before spending gas, and get the protocol's custom errors decoded
456
+ into typed, readable failures:
457
+
458
+ ```typescript
459
+ import { SlvrRevertError, decodeSlvrRevert } from '@slvr-labs/sdk';
460
+
461
+ // Preflight a bet (eth_call, no tx). Throws a typed SlvrRevertError on revert.
462
+ try {
463
+ await sdk.lottery.simulateBet({ roundId, squares, amounts });
464
+ await sdk.lottery.bet({ roundId, squares, amounts });
465
+ } catch (e) {
466
+ if (e instanceof SlvrRevertError) console.log(e.errorName, '—', e.message); // e.g. "RoundNotOpen — betting is closed…"
467
+ }
468
+
469
+ // bet() and claim() also decode reverts, and accept gas/nonce overrides:
470
+ await sdk.lottery.bet({ roundId, squares, amounts, overrides: { maxFeePerGas, nonce } });
471
+
472
+ // Decode any caught contract error yourself:
473
+ const revert = decodeSlvrRevert(err); // SlvrRevertError | null
474
+ ```
475
+
476
+ `sdk.getJackpotPool(roundId?)` returns the round's jackpot pool in wei (0 when no
477
+ jackpot is set), and `estimateRoundEv` now reads it automatically.
478
+
446
479
  ### Helper Functions
447
480
 
448
481
  #### Format Token Amounts
@@ -533,6 +566,7 @@ Interface for the lottery contract.
533
566
  - `getExpectedReward(account: Address, roundId: bigint): Promise<bigint>` - estimated reward for an account in a round
534
567
  - `latestResolvedRoundId(): Promise<bigint>`
535
568
  - `getRound(roundId: bigint): Promise<RoundInfo>` - flat 16-value round tuple
569
+ - `getRoundState(roundId?: bigint): Promise<{ roundId, open, resolved, bettingEnd, roundEnd, totalWager, winningSquare, secondsUntilBettingClose }>` - **batched** per-tick snapshot; `secondsUntilBettingClose` uses on-chain `block.timestamp`. Defaults to the current round.
536
570
  - `getTotalOnSquare(roundId: bigint, square: number): Promise<bigint>`
537
571
  - `getBettorsOnSquare(roundId: bigint, square: number): Promise<bigint>`
538
572
  - `getUserBet(roundId: bigint, square: number, bettor: Address): Promise<bigint>`
@@ -843,6 +877,14 @@ const txHash = await strategy.betOnLeastAllocated(
843
877
 
844
878
  See the [examples README](./examples/README.md) for more detailed examples and strategies.
845
879
 
880
+ ## Disclaimer
881
+
882
+ This SDK is built for real use — it interacts with live smart contracts on
883
+ Robinhood Chain and moves real ETH and SLVR. That also means it's provided **"as
884
+ is", without warranty of any kind** (see [LICENSE](./LICENSE)); you're
885
+ responsible for the transactions you send. Sensible precautions: review your code,
886
+ start with small amounts, and keep your keys safe.
887
+
846
888
  ## License
847
889
 
848
890
  MIT