@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.
- package/README.md +42 -0
- package/dist/index.d.mts +2117 -0
- package/dist/index.d.ts +1903 -34
- package/dist/index.js +3091 -427
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3035 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +19 -11
- package/skills/slvr-bot/SKILL.md +9 -8
- package/skills/slvr-bot/references/api.md +8 -0
- package/dist/connect.d.ts +0 -47
- package/dist/connect.d.ts.map +0 -1
- package/dist/connect.js +0 -56
- package/dist/connect.js.map +0 -1
- package/dist/contracts/autoCommit.d.ts +0 -151
- package/dist/contracts/autoCommit.d.ts.map +0 -1
- package/dist/contracts/autoCommit.js +0 -426
- package/dist/contracts/autoCommit.js.map +0 -1
- package/dist/contracts/hub.d.ts +0 -50
- package/dist/contracts/hub.d.ts.map +0 -1
- package/dist/contracts/hub.js +0 -118
- package/dist/contracts/hub.js.map +0 -1
- package/dist/contracts/index.d.ts +0 -8
- package/dist/contracts/index.d.ts.map +0 -1
- package/dist/contracts/index.js +0 -18
- package/dist/contracts/index.js.map +0 -1
- package/dist/contracts/jackpot.d.ts +0 -21
- package/dist/contracts/jackpot.d.ts.map +0 -1
- package/dist/contracts/jackpot.js +0 -44
- package/dist/contracts/jackpot.js.map +0 -1
- package/dist/contracts/lottery.d.ts +0 -256
- package/dist/contracts/lottery.d.ts.map +0 -1
- package/dist/contracts/lottery.js +0 -767
- package/dist/contracts/lottery.js.map +0 -1
- package/dist/contracts/registry.d.ts +0 -53
- package/dist/contracts/registry.d.ts.map +0 -1
- package/dist/contracts/registry.js +0 -143
- package/dist/contracts/registry.js.map +0 -1
- package/dist/contracts/staking.d.ts +0 -101
- package/dist/contracts/staking.d.ts.map +0 -1
- package/dist/contracts/staking.js +0 -306
- package/dist/contracts/staking.js.map +0 -1
- package/dist/contracts/token.d.ts +0 -95
- package/dist/contracts/token.d.ts.map +0 -1
- package/dist/contracts/token.js +0 -273
- package/dist/contracts/token.js.map +0 -1
- package/dist/deployments.d.ts +0 -117
- package/dist/deployments.d.ts.map +0 -1
- package/dist/deployments.js +0 -74
- package/dist/deployments.js.map +0 -1
- package/dist/errors.d.ts +0 -39
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -67
- package/dist/errors.js.map +0 -1
- package/dist/ev.d.ts +0 -123
- package/dist/ev.d.ts.map +0 -1
- package/dist/ev.js +0 -111
- package/dist/ev.js.map +0 -1
- package/dist/events.d.ts +0 -418
- package/dist/events.d.ts.map +0 -1
- package/dist/events.js +0 -87
- package/dist/events.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/oracle.d.ts +0 -48
- package/dist/oracle.d.ts.map +0 -1
- package/dist/oracle.js +0 -77
- package/dist/oracle.js.map +0 -1
- package/dist/price.d.ts +0 -52
- package/dist/price.d.ts.map +0 -1
- package/dist/price.js +0 -78
- package/dist/price.js.map +0 -1
- package/dist/transaction.d.ts +0 -54
- package/dist/transaction.d.ts.map +0 -1
- package/dist/transaction.js +0 -105
- package/dist/transaction.js.map +0 -1
- package/dist/types.d.ts +0 -162
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -23
- package/dist/types.js.map +0 -1
- package/dist/utils.d.ts +0 -58
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -110
- package/dist/utils.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# @slvr-labs/sdk
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@slvr-labs/sdk)
|
|
4
|
+
[](./LICENSE)
|
|
5
|
+
[](#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
|