@oddmaki-protocol/sdk 0.1.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/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/index.d.mts +15784 -0
- package/dist/index.d.ts +15784 -0
- package/dist/index.js +9507 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9421 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 oddmaki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# OddMaki SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [OddMaki Protocol](https://github.com/oddmaki/oddmaki-core) — a fully on-chain prediction market factory on Base. Built on [viem](https://viem.sh/).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @oddmaki/sdk viem
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { createOddMakiClient } from "@oddmaki/sdk";
|
|
15
|
+
|
|
16
|
+
const client = createOddMakiClient({
|
|
17
|
+
walletClient, // viem WalletClient
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// Read markets
|
|
21
|
+
const markets = await client.public.getMarkets(venueId);
|
|
22
|
+
|
|
23
|
+
// Place a limit order — buy YES at $0.65, 100 USDC, expires in 24h
|
|
24
|
+
await client.trade.placeOrderSimple(marketId, outcomeId, "buy", "0.65", "100", "24h");
|
|
25
|
+
|
|
26
|
+
// Place a market order (Fill-or-Kill)
|
|
27
|
+
await client.trade.placeMarketOrderSimple(marketId, outcomeId, "50", "0.70", 0);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Modules
|
|
31
|
+
|
|
32
|
+
The client exposes functional modules covering the full protocol:
|
|
33
|
+
|
|
34
|
+
| Module | Purpose |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `venue` | Create and configure venues (fee structure, access control, oracle params) |
|
|
37
|
+
| `market` | Create markets and market groups, read pricing and positions |
|
|
38
|
+
| `trade` | Limit orders, market orders (FOK/FAK), batch operations, split/merge |
|
|
39
|
+
| `public` | Subgraph queries — markets, trades, orderbook, analytics, leaderboards |
|
|
40
|
+
| `token` | ERC20 approvals and balance checks |
|
|
41
|
+
| `uma` | UMA oracle lifecycle — assert, settle, report, redeem |
|
|
42
|
+
| `accessControl` | Deploy and manage access control contracts (whitelist, NFT-gated, token-gated) |
|
|
43
|
+
| `priceMarket` | Pyth-powered price markets with automatic resolution |
|
|
44
|
+
|
|
45
|
+
## Trade API
|
|
46
|
+
|
|
47
|
+
Both raw and simplified interfaces are available. The simple API accepts human-readable strings:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// Limit order
|
|
51
|
+
await client.trade.placeOrderSimple(marketId, outcomeId, "buy", "0.65", "100", "24h");
|
|
52
|
+
|
|
53
|
+
// Market order: spend 50 USDC, max price $0.70, Fill-or-Kill
|
|
54
|
+
await client.trade.placeMarketOrderSimple(marketId, outcomeId, "50", "0.70", 0);
|
|
55
|
+
|
|
56
|
+
// Batch: place up to 20 orders atomically
|
|
57
|
+
await client.trade.batchPlaceOrdersSimple(marketId, orders);
|
|
58
|
+
|
|
59
|
+
// Cancel and replace in a single transaction
|
|
60
|
+
await client.trade.cancelAndReplace(cancelIds, marketId, newOrders);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Subgraph Queries
|
|
64
|
+
|
|
65
|
+
The `public` module provides indexed reads:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
// Unified feed (standalone markets + groups)
|
|
69
|
+
const feed = await client.public.getUnifiedMarketFeed(venueId);
|
|
70
|
+
|
|
71
|
+
// Trader profile and positions
|
|
72
|
+
const profile = await client.public.getTraderProfile(address);
|
|
73
|
+
const positions = await client.public.getTraderPositions(address);
|
|
74
|
+
|
|
75
|
+
// Leaderboard
|
|
76
|
+
const leaders = await client.public.getLeaderboard("totalVolume", "desc");
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Utilities
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { priceToTick, tickToPrice, parseAmount } from "@oddmaki/sdk";
|
|
83
|
+
|
|
84
|
+
priceToTick("0.80"); // 80n
|
|
85
|
+
tickToPrice(80n); // "0.80"
|
|
86
|
+
parseAmount("10.5"); // 10500000n (6 decimals)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Development
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
pnpm install
|
|
93
|
+
pnpm run build
|
|
94
|
+
pnpm run test
|
|
95
|
+
pnpm run lint
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Related
|
|
99
|
+
|
|
100
|
+
- [oddmaki-core](https://github.com/oddmaki/oddmaki-core) — Smart contracts
|
|
101
|
+
- [oddmaki-subgraph](https://github.com/oddmaki/oddmaki-subgraph) — Subgraph
|
|
102
|
+
- [oddmaki-venue-starter](https://github.com/oddmaki/oddmaki-venue-starter) — Venue starter template
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
[MIT](./LICENSE)
|