@puul/partner-sdk 1.0.0 → 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/README.md CHANGED
@@ -139,8 +139,20 @@ await puul.wallet.deposit({
139
139
  currency: 'USDC',
140
140
  idempotency_key: 'dep_unique_123',
141
141
  });
142
+
143
+ // Withdraw from omnibus to configured bank/crypto destination
144
+ const withdrawal = await puul.wallet.withdraw({
145
+ amount: 500000, // $5,000 in minor units
146
+ currency: 'USDC',
147
+ method: 'bank', // or 'crypto'
148
+ });
149
+ // withdrawal.withdrawalId, withdrawal.status
142
150
  ```
143
151
 
152
+ > **Auto-Settlement:** If your `payout_method` is configured (via the admin dashboard),
153
+ > revenue share is automatically paid out after each market settlement. You don't need
154
+ > to call `withdraw()` manually — it happens at settlement time.
155
+
144
156
  ### Webhook Verification
145
157
 
146
158
  ```typescript
@@ -163,9 +175,16 @@ app.post('/webhooks/puul', express.raw({ type: '*/*' }), (req, res) => {
163
175
  case 'prediction.settled':
164
176
  console.log('Prediction settled:', event.data);
165
177
  break;
178
+ case 'prediction.voided':
179
+ console.log('Prediction voided:', event.data);
180
+ // Handle refund — user gets full stake back
181
+ break;
166
182
  case 'deposit.confirmed':
167
183
  console.log('Deposit confirmed:', event.data);
168
184
  break;
185
+ case 'withdrawal.completed':
186
+ console.log('Withdrawal completed:', event.data);
187
+ break;
169
188
  }
170
189
 
171
190
  res.status(200).send('OK');
package/dist/index.d.mts CHANGED
@@ -33,22 +33,27 @@ interface MarketOutcome {
33
33
  id: string;
34
34
  slug: string;
35
35
  label: string;
36
- pool: {
37
- pool_amount: string;
38
- total_bets: number;
39
- };
36
+ display_order: number;
37
+ pool_amount: string;
38
+ predictor_count: number;
39
+ prediction_count: number;
40
40
  }
41
41
  interface Market {
42
42
  id: string;
43
43
  question: string;
44
- description: string;
45
44
  category: string;
45
+ image_url: string;
46
+ market_type: string;
46
47
  status: string;
47
48
  currency: string;
48
49
  close_time: string;
49
50
  freeze_at: string | null;
50
- target_countries: string[];
51
51
  outcomes: MarketOutcome[];
52
+ volume: number;
53
+ volume_currency: string;
54
+ predictor_count: number;
55
+ prediction_count: number;
56
+ created_at: string;
52
57
  }
53
58
  type PredictionStatus = 'OPEN' | 'WON' | 'LOST' | 'VOIDED';
54
59
  type Currency = 'NGN' | 'USDC' | 'USDT' | 'KES' | 'GHS' | 'ZAR';
@@ -149,26 +154,136 @@ interface DepositParams {
149
154
  idempotency_key: string;
150
155
  reference?: string;
151
156
  }
152
- type WebhookEventType = 'prediction.settled' | 'deposit.confirmed' | 'withdrawal.completed';
153
- interface WebhookEvent<T = {
154
- [key: string]: unknown;
155
- }> {
157
+ type WithdrawMethod = 'bank' | 'crypto';
158
+ interface WithdrawParams {
159
+ /** Amount to withdraw in minor units (cents) */
160
+ amount: number;
161
+ /** Currency to withdraw. Defaults to USDC */
162
+ currency?: Currency;
163
+ /** Payout method: 'bank' for fiat, 'crypto' for on-chain */
164
+ method?: WithdrawMethod;
165
+ }
166
+ interface WithdrawResult {
167
+ withdrawalId: string;
168
+ partnerId: string;
169
+ amount: number;
170
+ currency: string;
171
+ method: WithdrawMethod;
172
+ payoutReference: string | null;
173
+ status: string;
174
+ }
175
+ type WebhookEventType = 'user.created' | 'prediction.placed' | 'prediction.settled' | 'prediction.voided' | 'market.closed' | 'market.settled' | 'deposit.confirmed' | 'withdrawal.completed' | 'withdrawal.failed';
176
+ interface WebhookEvent<T = unknown> {
156
177
  event: WebhookEventType;
157
178
  timestamp: string;
158
179
  data: T;
159
180
  }
160
- interface PredictionSettledData {
181
+ interface UserCreatedData {
182
+ puul_user_id: string;
183
+ external_user_id: string;
184
+ email: string;
185
+ phone: string;
186
+ country_code: string;
187
+ created_at: string;
188
+ }
189
+ interface PredictionPlacedData {
161
190
  prediction_id: string;
191
+ user_id: string;
192
+ user_external_id: string;
162
193
  market_id: string;
194
+ market_question: string;
163
195
  outcome_id: string;
164
196
  outcome_slug: string;
197
+ outcome_label: string;
198
+ stake_amount: number;
199
+ stake_currency: string;
200
+ estimated_return: string;
201
+ idempotency_key: string;
202
+ placed_at: string;
203
+ }
204
+ interface PredictionSettledData {
205
+ prediction_id: string;
206
+ user_id: string;
165
207
  user_external_id: string;
166
- status: 'WON' | 'LOST' | 'VOIDED';
208
+ market_id: string;
209
+ market_question: string;
210
+ outcome_id: string;
211
+ outcome_slug: string;
212
+ outcome_label: string;
213
+ stake_amount: string;
214
+ stake_currency: string;
215
+ status: 'WON' | 'LOST';
216
+ payout: string;
217
+ multiplier: string;
218
+ settled_at: string;
219
+ }
220
+ interface PredictionVoidedData {
221
+ prediction_id: string;
222
+ user_id: string;
223
+ user_external_id: string | null;
224
+ market_id: string;
225
+ market_question: string | null;
226
+ outcome_label: string | null;
167
227
  stake_amount: string;
168
228
  stake_currency: string;
169
- final_return: string;
229
+ refund_amount: string;
230
+ voided_at: string;
231
+ reason: string;
232
+ }
233
+ interface MarketClosedData {
234
+ market_id: string;
235
+ market_question: string;
236
+ market_type: string;
237
+ close_time: string;
238
+ closed_at: string;
239
+ currency: string;
240
+ volume: number;
241
+ prediction_count: number;
242
+ }
243
+ interface MarketSettledData {
244
+ market_id: string;
245
+ market_question: string;
246
+ market_type: string;
247
+ winning_outcome_id: string;
248
+ winning_outcome_slug: string | null;
249
+ winning_outcome_label: string | null;
250
+ currency: string;
251
+ total_pool: number;
252
+ winners_count: number;
253
+ total_payout: number;
170
254
  settled_at: string;
171
255
  }
256
+ interface DepositConfirmedData {
257
+ deposit_id: string;
258
+ user_id: string;
259
+ external_user_id: string;
260
+ amount: number;
261
+ currency: string;
262
+ amount_usd: number;
263
+ tx_hash: string;
264
+ status: string;
265
+ confirmed_at: string;
266
+ }
267
+ interface WithdrawalCompletedData {
268
+ withdrawal_id: string;
269
+ partner_id: string;
270
+ external_user_id: string;
271
+ amount: number;
272
+ currency: string;
273
+ method: string;
274
+ payout_reference: string | null;
275
+ completed_at: string;
276
+ }
277
+ interface WithdrawalFailedData {
278
+ withdrawal_id: string;
279
+ partner_id: string;
280
+ external_user_id: string;
281
+ amount: number;
282
+ currency: string;
283
+ method: string;
284
+ reason: string;
285
+ failed_at: string;
286
+ }
172
287
  interface PuulApiError {
173
288
  statusCode: number;
174
289
  message: string | string[];
@@ -274,6 +389,20 @@ declare class WalletAPI {
274
389
  deposit(params: DepositParams): Promise<unknown>;
275
390
  /** Get withdrawal fee estimate */
276
391
  getWithdrawalFees(currency: string, amount: number): Promise<unknown>;
392
+ /**
393
+ * Withdraw from omnibus balance.
394
+ * Initiates a payout to the partner's configured bank account or crypto wallet.
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const result = await puul.wallet.withdraw({
399
+ * amount: 500000, // $5,000 in cents
400
+ * currency: 'USDC',
401
+ * method: 'bank', // or 'crypto'
402
+ * });
403
+ * ```
404
+ */
405
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
277
406
  }
278
407
 
279
408
  /**
@@ -318,22 +447,37 @@ declare function verifyWebhookSignature(payload: string, signature: string, secr
318
447
  * const event = parseWebhookEvent(req.body);
319
448
  *
320
449
  * if (event.event === 'prediction.settled') {
321
- * const { prediction_id, status, final_return } = event.data;
450
+ * const { prediction_id, status, payout } = event.data;
322
451
  * // Handle settlement...
323
452
  * }
324
453
  * ```
325
454
  */
326
455
  declare function parseWebhookEvent(body: unknown): WebhookEvent;
327
- /**
328
- * Type guard for prediction.settled events.
329
- * Returns true if the event type is 'prediction.settled'.
330
- * Use this to narrow the type before accessing `.data` as PredictionSettledData.
331
- */
332
- declare function isPredictionSettledEvent(event: WebhookEvent): boolean;
456
+ /** Type guard for prediction.placed events. */
457
+ declare function isPredictionPlacedEvent(event: WebhookEvent): event is WebhookEvent<PredictionPlacedData>;
458
+ /** Type guard for prediction.settled events. */
459
+ declare function isPredictionSettledEvent(event: WebhookEvent): event is WebhookEvent<PredictionSettledData>;
460
+ /** Type guard for prediction.voided events. */
461
+ declare function isPredictionVoidedEvent(event: WebhookEvent): event is WebhookEvent<PredictionVoidedData>;
462
+ /** Type guard for market.closed events. */
463
+ declare function isMarketClosedEvent(event: WebhookEvent): event is WebhookEvent<MarketClosedData>;
464
+ /** Type guard for market.settled events. */
465
+ declare function isMarketSettledEvent(event: WebhookEvent): event is WebhookEvent<MarketSettledData>;
466
+ /** Type guard for deposit.confirmed events. */
467
+ declare function isDepositConfirmedEvent(event: WebhookEvent): event is WebhookEvent<DepositConfirmedData>;
468
+ /** Type guard for withdrawal.completed events. */
469
+ declare function isWithdrawalCompletedEvent(event: WebhookEvent): event is WebhookEvent<WithdrawalCompletedData>;
470
+ /** Type guard for withdrawal.failed events. */
471
+ declare function isWithdrawalFailedEvent(event: WebhookEvent): event is WebhookEvent<WithdrawalFailedData>;
333
472
  /**
334
473
  * Convenience cast for prediction.settled event data.
335
474
  * Call after verifying with `isPredictionSettledEvent`.
336
475
  */
337
476
  declare function asPredictionSettledData(event: WebhookEvent): PredictionSettledData;
477
+ /**
478
+ * Convenience cast for market.settled event data.
479
+ * Call after verifying with `isMarketSettledEvent`.
480
+ */
481
+ declare function asMarketSettledData(event: WebhookEvent): MarketSettledData;
338
482
 
339
- export { type AccessTokenResponse, type CreateLinkTokenParams, type CreatePendingPredictionParams, type CreateQuoteParams, type Currency, type DepositAccountInfo, type DepositParams, type LinkTokenResponse, type Market, type MarketOutcome, type PendingPrediction, type PlacePredictionParams, type Prediction, type PredictionListResponse, type PredictionSettledData, type PredictionStatus, type PuulApiError, PuulError, PuulPartner, type PuulPartnerConfig, type QuoteResponse, type SessionResponse, type WalletBalance, type WebhookEvent, type WebhookEventType, asPredictionSettledData, isPredictionSettledEvent, parseWebhookEvent, verifyWebhookSignature };
483
+ export { type AccessTokenResponse, type CreateLinkTokenParams, type CreatePendingPredictionParams, type CreateQuoteParams, type Currency, type DepositAccountInfo, type DepositConfirmedData, type DepositParams, type LinkTokenResponse, type Market, type MarketClosedData, type MarketOutcome, type MarketSettledData, type PendingPrediction, type PlacePredictionParams, type Prediction, type PredictionListResponse, type PredictionPlacedData, type PredictionSettledData, type PredictionStatus, type PredictionVoidedData, type PuulApiError, PuulError, PuulPartner, type PuulPartnerConfig, type QuoteResponse, type SessionResponse, type UserCreatedData, type WalletBalance, type WebhookEvent, type WebhookEventType, type WithdrawMethod, type WithdrawParams, type WithdrawResult, type WithdrawalCompletedData, type WithdrawalFailedData, asMarketSettledData, asPredictionSettledData, isDepositConfirmedEvent, isMarketClosedEvent, isMarketSettledEvent, isPredictionPlacedEvent, isPredictionSettledEvent, isPredictionVoidedEvent, isWithdrawalCompletedEvent, isWithdrawalFailedEvent, parseWebhookEvent, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -33,22 +33,27 @@ interface MarketOutcome {
33
33
  id: string;
34
34
  slug: string;
35
35
  label: string;
36
- pool: {
37
- pool_amount: string;
38
- total_bets: number;
39
- };
36
+ display_order: number;
37
+ pool_amount: string;
38
+ predictor_count: number;
39
+ prediction_count: number;
40
40
  }
41
41
  interface Market {
42
42
  id: string;
43
43
  question: string;
44
- description: string;
45
44
  category: string;
45
+ image_url: string;
46
+ market_type: string;
46
47
  status: string;
47
48
  currency: string;
48
49
  close_time: string;
49
50
  freeze_at: string | null;
50
- target_countries: string[];
51
51
  outcomes: MarketOutcome[];
52
+ volume: number;
53
+ volume_currency: string;
54
+ predictor_count: number;
55
+ prediction_count: number;
56
+ created_at: string;
52
57
  }
53
58
  type PredictionStatus = 'OPEN' | 'WON' | 'LOST' | 'VOIDED';
54
59
  type Currency = 'NGN' | 'USDC' | 'USDT' | 'KES' | 'GHS' | 'ZAR';
@@ -149,26 +154,136 @@ interface DepositParams {
149
154
  idempotency_key: string;
150
155
  reference?: string;
151
156
  }
152
- type WebhookEventType = 'prediction.settled' | 'deposit.confirmed' | 'withdrawal.completed';
153
- interface WebhookEvent<T = {
154
- [key: string]: unknown;
155
- }> {
157
+ type WithdrawMethod = 'bank' | 'crypto';
158
+ interface WithdrawParams {
159
+ /** Amount to withdraw in minor units (cents) */
160
+ amount: number;
161
+ /** Currency to withdraw. Defaults to USDC */
162
+ currency?: Currency;
163
+ /** Payout method: 'bank' for fiat, 'crypto' for on-chain */
164
+ method?: WithdrawMethod;
165
+ }
166
+ interface WithdrawResult {
167
+ withdrawalId: string;
168
+ partnerId: string;
169
+ amount: number;
170
+ currency: string;
171
+ method: WithdrawMethod;
172
+ payoutReference: string | null;
173
+ status: string;
174
+ }
175
+ type WebhookEventType = 'user.created' | 'prediction.placed' | 'prediction.settled' | 'prediction.voided' | 'market.closed' | 'market.settled' | 'deposit.confirmed' | 'withdrawal.completed' | 'withdrawal.failed';
176
+ interface WebhookEvent<T = unknown> {
156
177
  event: WebhookEventType;
157
178
  timestamp: string;
158
179
  data: T;
159
180
  }
160
- interface PredictionSettledData {
181
+ interface UserCreatedData {
182
+ puul_user_id: string;
183
+ external_user_id: string;
184
+ email: string;
185
+ phone: string;
186
+ country_code: string;
187
+ created_at: string;
188
+ }
189
+ interface PredictionPlacedData {
161
190
  prediction_id: string;
191
+ user_id: string;
192
+ user_external_id: string;
162
193
  market_id: string;
194
+ market_question: string;
163
195
  outcome_id: string;
164
196
  outcome_slug: string;
197
+ outcome_label: string;
198
+ stake_amount: number;
199
+ stake_currency: string;
200
+ estimated_return: string;
201
+ idempotency_key: string;
202
+ placed_at: string;
203
+ }
204
+ interface PredictionSettledData {
205
+ prediction_id: string;
206
+ user_id: string;
165
207
  user_external_id: string;
166
- status: 'WON' | 'LOST' | 'VOIDED';
208
+ market_id: string;
209
+ market_question: string;
210
+ outcome_id: string;
211
+ outcome_slug: string;
212
+ outcome_label: string;
213
+ stake_amount: string;
214
+ stake_currency: string;
215
+ status: 'WON' | 'LOST';
216
+ payout: string;
217
+ multiplier: string;
218
+ settled_at: string;
219
+ }
220
+ interface PredictionVoidedData {
221
+ prediction_id: string;
222
+ user_id: string;
223
+ user_external_id: string | null;
224
+ market_id: string;
225
+ market_question: string | null;
226
+ outcome_label: string | null;
167
227
  stake_amount: string;
168
228
  stake_currency: string;
169
- final_return: string;
229
+ refund_amount: string;
230
+ voided_at: string;
231
+ reason: string;
232
+ }
233
+ interface MarketClosedData {
234
+ market_id: string;
235
+ market_question: string;
236
+ market_type: string;
237
+ close_time: string;
238
+ closed_at: string;
239
+ currency: string;
240
+ volume: number;
241
+ prediction_count: number;
242
+ }
243
+ interface MarketSettledData {
244
+ market_id: string;
245
+ market_question: string;
246
+ market_type: string;
247
+ winning_outcome_id: string;
248
+ winning_outcome_slug: string | null;
249
+ winning_outcome_label: string | null;
250
+ currency: string;
251
+ total_pool: number;
252
+ winners_count: number;
253
+ total_payout: number;
170
254
  settled_at: string;
171
255
  }
256
+ interface DepositConfirmedData {
257
+ deposit_id: string;
258
+ user_id: string;
259
+ external_user_id: string;
260
+ amount: number;
261
+ currency: string;
262
+ amount_usd: number;
263
+ tx_hash: string;
264
+ status: string;
265
+ confirmed_at: string;
266
+ }
267
+ interface WithdrawalCompletedData {
268
+ withdrawal_id: string;
269
+ partner_id: string;
270
+ external_user_id: string;
271
+ amount: number;
272
+ currency: string;
273
+ method: string;
274
+ payout_reference: string | null;
275
+ completed_at: string;
276
+ }
277
+ interface WithdrawalFailedData {
278
+ withdrawal_id: string;
279
+ partner_id: string;
280
+ external_user_id: string;
281
+ amount: number;
282
+ currency: string;
283
+ method: string;
284
+ reason: string;
285
+ failed_at: string;
286
+ }
172
287
  interface PuulApiError {
173
288
  statusCode: number;
174
289
  message: string | string[];
@@ -274,6 +389,20 @@ declare class WalletAPI {
274
389
  deposit(params: DepositParams): Promise<unknown>;
275
390
  /** Get withdrawal fee estimate */
276
391
  getWithdrawalFees(currency: string, amount: number): Promise<unknown>;
392
+ /**
393
+ * Withdraw from omnibus balance.
394
+ * Initiates a payout to the partner's configured bank account or crypto wallet.
395
+ *
396
+ * @example
397
+ * ```typescript
398
+ * const result = await puul.wallet.withdraw({
399
+ * amount: 500000, // $5,000 in cents
400
+ * currency: 'USDC',
401
+ * method: 'bank', // or 'crypto'
402
+ * });
403
+ * ```
404
+ */
405
+ withdraw(params: WithdrawParams): Promise<WithdrawResult>;
277
406
  }
278
407
 
279
408
  /**
@@ -318,22 +447,37 @@ declare function verifyWebhookSignature(payload: string, signature: string, secr
318
447
  * const event = parseWebhookEvent(req.body);
319
448
  *
320
449
  * if (event.event === 'prediction.settled') {
321
- * const { prediction_id, status, final_return } = event.data;
450
+ * const { prediction_id, status, payout } = event.data;
322
451
  * // Handle settlement...
323
452
  * }
324
453
  * ```
325
454
  */
326
455
  declare function parseWebhookEvent(body: unknown): WebhookEvent;
327
- /**
328
- * Type guard for prediction.settled events.
329
- * Returns true if the event type is 'prediction.settled'.
330
- * Use this to narrow the type before accessing `.data` as PredictionSettledData.
331
- */
332
- declare function isPredictionSettledEvent(event: WebhookEvent): boolean;
456
+ /** Type guard for prediction.placed events. */
457
+ declare function isPredictionPlacedEvent(event: WebhookEvent): event is WebhookEvent<PredictionPlacedData>;
458
+ /** Type guard for prediction.settled events. */
459
+ declare function isPredictionSettledEvent(event: WebhookEvent): event is WebhookEvent<PredictionSettledData>;
460
+ /** Type guard for prediction.voided events. */
461
+ declare function isPredictionVoidedEvent(event: WebhookEvent): event is WebhookEvent<PredictionVoidedData>;
462
+ /** Type guard for market.closed events. */
463
+ declare function isMarketClosedEvent(event: WebhookEvent): event is WebhookEvent<MarketClosedData>;
464
+ /** Type guard for market.settled events. */
465
+ declare function isMarketSettledEvent(event: WebhookEvent): event is WebhookEvent<MarketSettledData>;
466
+ /** Type guard for deposit.confirmed events. */
467
+ declare function isDepositConfirmedEvent(event: WebhookEvent): event is WebhookEvent<DepositConfirmedData>;
468
+ /** Type guard for withdrawal.completed events. */
469
+ declare function isWithdrawalCompletedEvent(event: WebhookEvent): event is WebhookEvent<WithdrawalCompletedData>;
470
+ /** Type guard for withdrawal.failed events. */
471
+ declare function isWithdrawalFailedEvent(event: WebhookEvent): event is WebhookEvent<WithdrawalFailedData>;
333
472
  /**
334
473
  * Convenience cast for prediction.settled event data.
335
474
  * Call after verifying with `isPredictionSettledEvent`.
336
475
  */
337
476
  declare function asPredictionSettledData(event: WebhookEvent): PredictionSettledData;
477
+ /**
478
+ * Convenience cast for market.settled event data.
479
+ * Call after verifying with `isMarketSettledEvent`.
480
+ */
481
+ declare function asMarketSettledData(event: WebhookEvent): MarketSettledData;
338
482
 
339
- export { type AccessTokenResponse, type CreateLinkTokenParams, type CreatePendingPredictionParams, type CreateQuoteParams, type Currency, type DepositAccountInfo, type DepositParams, type LinkTokenResponse, type Market, type MarketOutcome, type PendingPrediction, type PlacePredictionParams, type Prediction, type PredictionListResponse, type PredictionSettledData, type PredictionStatus, type PuulApiError, PuulError, PuulPartner, type PuulPartnerConfig, type QuoteResponse, type SessionResponse, type WalletBalance, type WebhookEvent, type WebhookEventType, asPredictionSettledData, isPredictionSettledEvent, parseWebhookEvent, verifyWebhookSignature };
483
+ export { type AccessTokenResponse, type CreateLinkTokenParams, type CreatePendingPredictionParams, type CreateQuoteParams, type Currency, type DepositAccountInfo, type DepositConfirmedData, type DepositParams, type LinkTokenResponse, type Market, type MarketClosedData, type MarketOutcome, type MarketSettledData, type PendingPrediction, type PlacePredictionParams, type Prediction, type PredictionListResponse, type PredictionPlacedData, type PredictionSettledData, type PredictionStatus, type PredictionVoidedData, type PuulApiError, PuulError, PuulPartner, type PuulPartnerConfig, type QuoteResponse, type SessionResponse, type UserCreatedData, type WalletBalance, type WebhookEvent, type WebhookEventType, type WithdrawMethod, type WithdrawParams, type WithdrawResult, type WithdrawalCompletedData, type WithdrawalFailedData, asMarketSettledData, asPredictionSettledData, isDepositConfirmedEvent, isMarketClosedEvent, isMarketSettledEvent, isPredictionPlacedEvent, isPredictionSettledEvent, isPredictionVoidedEvent, isWithdrawalCompletedEvent, isWithdrawalFailedEvent, parseWebhookEvent, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -22,8 +22,16 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  PuulError: () => PuulError,
24
24
  PuulPartner: () => PuulPartner,
25
+ asMarketSettledData: () => asMarketSettledData,
25
26
  asPredictionSettledData: () => asPredictionSettledData,
27
+ isDepositConfirmedEvent: () => isDepositConfirmedEvent,
28
+ isMarketClosedEvent: () => isMarketClosedEvent,
29
+ isMarketSettledEvent: () => isMarketSettledEvent,
30
+ isPredictionPlacedEvent: () => isPredictionPlacedEvent,
26
31
  isPredictionSettledEvent: () => isPredictionSettledEvent,
32
+ isPredictionVoidedEvent: () => isPredictionVoidedEvent,
33
+ isWithdrawalCompletedEvent: () => isWithdrawalCompletedEvent,
34
+ isWithdrawalFailedEvent: () => isWithdrawalFailedEvent,
27
35
  parseWebhookEvent: () => parseWebhookEvent,
28
36
  verifyWebhookSignature: () => verifyWebhookSignature
29
37
  });
@@ -229,6 +237,22 @@ var WalletAPI = class {
229
237
  async getWithdrawalFees(currency, amount) {
230
238
  return this.client.request("GET", `/partner/wallet/withdrawal-fees?currency=${currency}&amount=${amount}`);
231
239
  }
240
+ /**
241
+ * Withdraw from omnibus balance.
242
+ * Initiates a payout to the partner's configured bank account or crypto wallet.
243
+ *
244
+ * @example
245
+ * ```typescript
246
+ * const result = await puul.wallet.withdraw({
247
+ * amount: 500000, // $5,000 in cents
248
+ * currency: 'USDC',
249
+ * method: 'bank', // or 'crypto'
250
+ * });
251
+ * ```
252
+ */
253
+ async withdraw(params) {
254
+ return this.client.request("POST", "/partner/wallet/withdraw", params);
255
+ }
232
256
  };
233
257
 
234
258
  // src/webhooks.ts
@@ -263,18 +287,50 @@ function parseWebhookEvent(body) {
263
287
  data: event.data || {}
264
288
  };
265
289
  }
290
+ function isPredictionPlacedEvent(event) {
291
+ return event.event === "prediction.placed";
292
+ }
266
293
  function isPredictionSettledEvent(event) {
267
294
  return event.event === "prediction.settled";
268
295
  }
296
+ function isPredictionVoidedEvent(event) {
297
+ return event.event === "prediction.voided";
298
+ }
299
+ function isMarketClosedEvent(event) {
300
+ return event.event === "market.closed";
301
+ }
302
+ function isMarketSettledEvent(event) {
303
+ return event.event === "market.settled";
304
+ }
305
+ function isDepositConfirmedEvent(event) {
306
+ return event.event === "deposit.confirmed";
307
+ }
308
+ function isWithdrawalCompletedEvent(event) {
309
+ return event.event === "withdrawal.completed";
310
+ }
311
+ function isWithdrawalFailedEvent(event) {
312
+ return event.event === "withdrawal.failed";
313
+ }
269
314
  function asPredictionSettledData(event) {
270
315
  return event.data;
271
316
  }
317
+ function asMarketSettledData(event) {
318
+ return event.data;
319
+ }
272
320
  // Annotate the CommonJS export names for ESM import in node:
273
321
  0 && (module.exports = {
274
322
  PuulError,
275
323
  PuulPartner,
324
+ asMarketSettledData,
276
325
  asPredictionSettledData,
326
+ isDepositConfirmedEvent,
327
+ isMarketClosedEvent,
328
+ isMarketSettledEvent,
329
+ isPredictionPlacedEvent,
277
330
  isPredictionSettledEvent,
331
+ isPredictionVoidedEvent,
332
+ isWithdrawalCompletedEvent,
333
+ isWithdrawalFailedEvent,
278
334
  parseWebhookEvent,
279
335
  verifyWebhookSignature
280
336
  });
package/dist/index.mjs CHANGED
@@ -198,6 +198,22 @@ var WalletAPI = class {
198
198
  async getWithdrawalFees(currency, amount) {
199
199
  return this.client.request("GET", `/partner/wallet/withdrawal-fees?currency=${currency}&amount=${amount}`);
200
200
  }
201
+ /**
202
+ * Withdraw from omnibus balance.
203
+ * Initiates a payout to the partner's configured bank account or crypto wallet.
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const result = await puul.wallet.withdraw({
208
+ * amount: 500000, // $5,000 in cents
209
+ * currency: 'USDC',
210
+ * method: 'bank', // or 'crypto'
211
+ * });
212
+ * ```
213
+ */
214
+ async withdraw(params) {
215
+ return this.client.request("POST", "/partner/wallet/withdraw", params);
216
+ }
201
217
  };
202
218
 
203
219
  // src/webhooks.ts
@@ -232,17 +248,49 @@ function parseWebhookEvent(body) {
232
248
  data: event.data || {}
233
249
  };
234
250
  }
251
+ function isPredictionPlacedEvent(event) {
252
+ return event.event === "prediction.placed";
253
+ }
235
254
  function isPredictionSettledEvent(event) {
236
255
  return event.event === "prediction.settled";
237
256
  }
257
+ function isPredictionVoidedEvent(event) {
258
+ return event.event === "prediction.voided";
259
+ }
260
+ function isMarketClosedEvent(event) {
261
+ return event.event === "market.closed";
262
+ }
263
+ function isMarketSettledEvent(event) {
264
+ return event.event === "market.settled";
265
+ }
266
+ function isDepositConfirmedEvent(event) {
267
+ return event.event === "deposit.confirmed";
268
+ }
269
+ function isWithdrawalCompletedEvent(event) {
270
+ return event.event === "withdrawal.completed";
271
+ }
272
+ function isWithdrawalFailedEvent(event) {
273
+ return event.event === "withdrawal.failed";
274
+ }
238
275
  function asPredictionSettledData(event) {
239
276
  return event.data;
240
277
  }
278
+ function asMarketSettledData(event) {
279
+ return event.data;
280
+ }
241
281
  export {
242
282
  PuulError,
243
283
  PuulPartner,
284
+ asMarketSettledData,
244
285
  asPredictionSettledData,
286
+ isDepositConfirmedEvent,
287
+ isMarketClosedEvent,
288
+ isMarketSettledEvent,
289
+ isPredictionPlacedEvent,
245
290
  isPredictionSettledEvent,
291
+ isPredictionVoidedEvent,
292
+ isWithdrawalCompletedEvent,
293
+ isWithdrawalFailedEvent,
246
294
  parseWebhookEvent,
247
295
  verifyWebhookSignature
248
296
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@puul/partner-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Official TypeScript SDK for the Puul Partner API — integrate prediction markets into your platform",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -42,4 +42,4 @@
42
42
  "engines": {
43
43
  "node": ">=18.0.0"
44
44
  }
45
- }
45
+ }