pepay-streams-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/README.md +405 -0
- package/dist/api/index.d.mts +321 -0
- package/dist/api/index.d.ts +321 -0
- package/dist/api/index.js +312 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/index.mjs +306 -0
- package/dist/api/index.mjs.map +1 -0
- package/dist/automation/index.d.mts +140 -0
- package/dist/automation/index.d.ts +140 -0
- package/dist/automation/index.js +331 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/index.mjs +326 -0
- package/dist/automation/index.mjs.map +1 -0
- package/dist/campaigns/index.d.mts +286 -0
- package/dist/campaigns/index.d.ts +286 -0
- package/dist/campaigns/index.js +652 -0
- package/dist/campaigns/index.js.map +1 -0
- package/dist/campaigns/index.mjs +645 -0
- package/dist/campaigns/index.mjs.map +1 -0
- package/dist/claims/index.d.mts +190 -0
- package/dist/claims/index.d.ts +190 -0
- package/dist/claims/index.js +414 -0
- package/dist/claims/index.js.map +1 -0
- package/dist/claims/index.mjs +409 -0
- package/dist/claims/index.mjs.map +1 -0
- package/dist/index-BTG0TRJt.d.mts +555 -0
- package/dist/index-BTG0TRJt.d.ts +555 -0
- package/dist/index.d.mts +170 -0
- package/dist/index.d.ts +170 -0
- package/dist/index.js +2926 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2888 -0
- package/dist/index.mjs.map +1 -0
- package/dist/marketplace/index.d.mts +225 -0
- package/dist/marketplace/index.d.ts +225 -0
- package/dist/marketplace/index.js +529 -0
- package/dist/marketplace/index.js.map +1 -0
- package/dist/marketplace/index.mjs +524 -0
- package/dist/marketplace/index.mjs.map +1 -0
- package/dist/react/index.d.mts +185 -0
- package/dist/react/index.d.ts +185 -0
- package/dist/react/index.js +340 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/index.mjs +333 -0
- package/dist/react/index.mjs.map +1 -0
- package/dist/staking/index.d.mts +158 -0
- package/dist/staking/index.d.ts +158 -0
- package/dist/staking/index.js +359 -0
- package/dist/staking/index.js.map +1 -0
- package/dist/staking/index.mjs +354 -0
- package/dist/staking/index.mjs.map +1 -0
- package/package.json +106 -0
- package/src/api/index.ts +577 -0
- package/src/automation/index.ts +436 -0
- package/src/campaigns/index.ts +835 -0
- package/src/claims/index.ts +530 -0
- package/src/client.ts +518 -0
- package/src/index.ts +101 -0
- package/src/marketplace/index.ts +730 -0
- package/src/react/index.ts +498 -0
- package/src/staking/index.ts +449 -0
- package/src/types/index.ts +631 -0
package/README.md
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# @pepay-streams/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for interacting with the Pepay Streams protocol - a production-grade EVM token distribution platform built on EIP-2535 Diamond architecture.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Token Distribution**: Create instant airdrops, vested airdrops, token locks, and vesting streams
|
|
8
|
+
- **Staking Pools**: Create and manage fixed-duration staking pools with APY-based rewards
|
|
9
|
+
- **P2P Marketplace**: Trade unvested positions through INSTANT, VESTED, and TRADABLE orders
|
|
10
|
+
- **Automation**: Enable keeper-powered auto-withdraw and auto-release
|
|
11
|
+
- **Meta-Transactions**: Support for gasless claims via EIP-712 signatures
|
|
12
|
+
- **Type-Safe**: Full TypeScript support with comprehensive types
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @pepay-streams/sdk viem
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @pepay-streams/sdk viem
|
|
20
|
+
# or
|
|
21
|
+
yarn add @pepay-streams/sdk viem
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
### Read-Only Client
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { PepayStreamsClient } from '@pepay-streams/sdk';
|
|
30
|
+
|
|
31
|
+
const client = new PepayStreamsClient({
|
|
32
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
33
|
+
diamondAddress: '0x...',
|
|
34
|
+
chainId: 1,
|
|
35
|
+
apiBaseUrl: 'https://api.pepaystreams.com', // Optional
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Query campaigns
|
|
39
|
+
const campaign = await client.campaigns.getCampaign(1n);
|
|
40
|
+
console.log('Campaign:', campaign.name);
|
|
41
|
+
|
|
42
|
+
// Check claimable amount
|
|
43
|
+
const due = await client.claims.getDueAmount(1n, '0x...');
|
|
44
|
+
console.log('Due amount:', due);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Client with Signer (for transactions)
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
import { PepayStreamsClient } from '@pepay-streams/sdk';
|
|
51
|
+
import { createWalletClient, http } from 'viem';
|
|
52
|
+
import { privateKeyToAccount } from 'viem/accounts';
|
|
53
|
+
import { mainnet } from 'viem/chains';
|
|
54
|
+
|
|
55
|
+
// From private key (Node.js/scripts)
|
|
56
|
+
const client = PepayStreamsClient.fromPrivateKey({
|
|
57
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
58
|
+
diamondAddress: '0x...',
|
|
59
|
+
chainId: 1,
|
|
60
|
+
privateKey: '0x...',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
// Or attach a wallet client
|
|
64
|
+
const walletClient = createWalletClient({
|
|
65
|
+
chain: mainnet,
|
|
66
|
+
transport: http(),
|
|
67
|
+
account: privateKeyToAccount('0x...'),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const clientWithSigner = new PepayStreamsClient({
|
|
71
|
+
rpcUrl: 'https://eth.llamarpc.com',
|
|
72
|
+
diamondAddress: '0x...',
|
|
73
|
+
chainId: 1,
|
|
74
|
+
}).withSigner(walletClient);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Browser Wallet
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { PepayStreamsClient } from '@pepay-streams/sdk';
|
|
81
|
+
|
|
82
|
+
// Connect to browser wallet (MetaMask, etc.)
|
|
83
|
+
const client = await PepayStreamsClient.fromBrowserWallet({
|
|
84
|
+
diamondAddress: '0x...',
|
|
85
|
+
chainId: 1,
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Campaign Operations
|
|
90
|
+
|
|
91
|
+
### Create an Instant Airdrop
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
import { parseEther } from 'viem';
|
|
95
|
+
|
|
96
|
+
const result = await client.campaigns.createInstantAirdrop({
|
|
97
|
+
token: '0x...', // Token address
|
|
98
|
+
name: 'Community Airdrop',
|
|
99
|
+
recipients: [
|
|
100
|
+
{ address: '0x...', amount: parseEther('100') },
|
|
101
|
+
{ address: '0x...', amount: parseEther('50') },
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await result.wait();
|
|
106
|
+
console.log('Created! Tx:', result.hash);
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Create a Vested Airdrop
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const result = await client.campaigns.createVestedAirdrop({
|
|
113
|
+
token: '0x...',
|
|
114
|
+
name: 'Team Vesting',
|
|
115
|
+
recipients: [
|
|
116
|
+
{ address: '0x...', amount: parseEther('10000') },
|
|
117
|
+
],
|
|
118
|
+
startTime: Math.floor(Date.now() / 1000), // Start now
|
|
119
|
+
duration: 365 * 24 * 60 * 60, // 1 year
|
|
120
|
+
cliffDuration: 90 * 24 * 60 * 60, // 3 month cliff
|
|
121
|
+
steps: 12, // Monthly releases
|
|
122
|
+
});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Create a Token Lock
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const result = await client.campaigns.createLock({
|
|
129
|
+
token: '0x...',
|
|
130
|
+
name: 'Liquidity Lock',
|
|
131
|
+
recipient: '0x...',
|
|
132
|
+
amount: parseEther('1000000'),
|
|
133
|
+
unlockTime: Math.floor(Date.now() / 1000) + 180 * 24 * 60 * 60, // 6 months
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Create a Vesting Stream (Payment)
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
const result = await client.campaigns.createVesting({
|
|
141
|
+
token: '0x...',
|
|
142
|
+
name: 'Salary Stream',
|
|
143
|
+
recipient: '0x...',
|
|
144
|
+
amount: parseEther('120000'),
|
|
145
|
+
startTime: Math.floor(Date.now() / 1000),
|
|
146
|
+
duration: 365 * 24 * 60 * 60, // 1 year
|
|
147
|
+
steps: 12, // Monthly
|
|
148
|
+
enableAutoWithdraw: true,
|
|
149
|
+
autoWithdrawFrequency: 30 * 24 * 60 * 60, // Monthly auto-claim
|
|
150
|
+
});
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Claiming
|
|
154
|
+
|
|
155
|
+
### Claim Tokens
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
// Single claim
|
|
159
|
+
const result = await client.claims.claim({ campaignId: 1n });
|
|
160
|
+
await result.wait();
|
|
161
|
+
|
|
162
|
+
// Batch claim from multiple campaigns
|
|
163
|
+
const result = await client.claims.claimBatch({
|
|
164
|
+
campaignIds: [1n, 2n, 3n],
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Release a lock
|
|
168
|
+
const result = await client.claims.releaseLock(campaignId);
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Check Claimable Amount
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const due = await client.claims.getDueAmount(campaignId, recipientAddress);
|
|
175
|
+
console.log('Claimable:', formatEther(due));
|
|
176
|
+
|
|
177
|
+
const status = await client.claims.getRecipientStatus(campaignId, recipientAddress);
|
|
178
|
+
console.log('Allocated:', status.allocated);
|
|
179
|
+
console.log('Claimed:', status.claimed);
|
|
180
|
+
console.log('Due:', status.due);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### Meta-Transaction (Gasless) Claims
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
// Recipient signs off-chain
|
|
187
|
+
const { signature, nonce, deadline } = await client.claims.signClaimMessage(
|
|
188
|
+
campaignId,
|
|
189
|
+
Math.floor(Date.now() / 1000) + 3600 // 1 hour deadline
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// Relayer submits the transaction
|
|
193
|
+
const result = await relayerClient.claims.claimWithSig({
|
|
194
|
+
campaignId,
|
|
195
|
+
signature,
|
|
196
|
+
deadline,
|
|
197
|
+
signer: recipientAddress,
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Staking
|
|
202
|
+
|
|
203
|
+
### Create a Staking Pool
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
const result = await client.staking.createPool({
|
|
207
|
+
stakeToken: '0x...', // Token users stake
|
|
208
|
+
rewardToken: '0x...', // Token users earn
|
|
209
|
+
rewardBudget: parseEther('100000'), // Total rewards
|
|
210
|
+
duration: 30 * 24 * 60 * 60, // 30 days
|
|
211
|
+
minStake: parseEther('100'),
|
|
212
|
+
maxStake: parseEther('10000'),
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Stake Tokens
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// Approve first
|
|
220
|
+
await client.approve(stakeToken, amount);
|
|
221
|
+
|
|
222
|
+
// Then stake
|
|
223
|
+
const result = await client.staking.stake(poolId, amount);
|
|
224
|
+
await result.wait();
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Claim Rewards
|
|
228
|
+
|
|
229
|
+
```typescript
|
|
230
|
+
// Check pending rewards
|
|
231
|
+
const pending = await client.staking.getPendingRewards(poolId, address);
|
|
232
|
+
|
|
233
|
+
// Claim
|
|
234
|
+
await client.staking.claimRewards(poolId);
|
|
235
|
+
|
|
236
|
+
// Or unstake (automatically claims rewards)
|
|
237
|
+
await client.staking.unstake(poolId, amount);
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Marketplace
|
|
241
|
+
|
|
242
|
+
### Create an Order
|
|
243
|
+
|
|
244
|
+
```typescript
|
|
245
|
+
import { zeroAddress } from 'viem';
|
|
246
|
+
|
|
247
|
+
// INSTANT order - immediate delivery
|
|
248
|
+
await client.marketplace.createInstantOrder({
|
|
249
|
+
sellToken: '0x...',
|
|
250
|
+
sellAmount: parseEther('1000'),
|
|
251
|
+
payToken: zeroAddress, // Native ETH
|
|
252
|
+
pricePerToken: parseEther('0.001'),
|
|
253
|
+
expiryTTL: 7 * 24 * 60 * 60, // 7 days
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
// TRADABLE order - list unvested campaign position
|
|
257
|
+
await client.marketplace.createTradableOrder({
|
|
258
|
+
campaignId: 10n,
|
|
259
|
+
pricePerToken: parseEther('0.05'),
|
|
260
|
+
payToken: zeroAddress,
|
|
261
|
+
expiryTTL: 30 * 24 * 60 * 60,
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Fill an Order
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
// Get quote
|
|
269
|
+
const quote = await client.marketplace.getQuote(orderId);
|
|
270
|
+
console.log('Total price:', quote.totalPrice);
|
|
271
|
+
|
|
272
|
+
// Fill with native payment
|
|
273
|
+
await client.marketplace.fillOrder(orderId, {
|
|
274
|
+
value: quote.totalPrice,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// Or with ERC20 (approve first)
|
|
278
|
+
await client.approve(payToken, quote.totalPrice);
|
|
279
|
+
await client.marketplace.fillOrder(orderId);
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### Cancel an Order
|
|
283
|
+
|
|
284
|
+
```typescript
|
|
285
|
+
await client.marketplace.cancelOrder(orderId);
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## Automation
|
|
289
|
+
|
|
290
|
+
### Enable Auto-Withdraw
|
|
291
|
+
|
|
292
|
+
```typescript
|
|
293
|
+
await client.automation.enableAutoWithdraw({
|
|
294
|
+
campaignId: 1n,
|
|
295
|
+
frequency: 7 * 24 * 60 * 60, // Weekly
|
|
296
|
+
tipAmount: parseEther('0.1'), // Keeper tip
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Enable Auto-Release for Locks
|
|
301
|
+
|
|
302
|
+
```typescript
|
|
303
|
+
await client.automation.enableAutoRelease({
|
|
304
|
+
campaignId: 5n,
|
|
305
|
+
tipAmount: parseEther('0.05'),
|
|
306
|
+
});
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
### Check Automation Status
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
const status = await client.automation.getAutoWithdrawStatus(campaignId);
|
|
313
|
+
console.log('Enabled:', status.enabled);
|
|
314
|
+
console.log('Next run:', new Date(status.nextRun * 1000));
|
|
315
|
+
console.log('Tip balance:', status.tipBalance);
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## API Client (Indexed Data)
|
|
319
|
+
|
|
320
|
+
```typescript
|
|
321
|
+
const client = new PepayStreamsClient({
|
|
322
|
+
rpcUrl: '...',
|
|
323
|
+
diamondAddress: '0x...',
|
|
324
|
+
chainId: 1,
|
|
325
|
+
apiBaseUrl: 'https://api.pepaystreams.com',
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
// Get campaigns with filtering
|
|
329
|
+
const campaigns = await client.api.getCampaigns({
|
|
330
|
+
kind: 'vested_airdrop',
|
|
331
|
+
status: 'active',
|
|
332
|
+
page: 1,
|
|
333
|
+
pageSize: 20,
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// Get wallet activity
|
|
337
|
+
const activity = await client.api.getWalletActivity(address);
|
|
338
|
+
|
|
339
|
+
// Get marketplace orders
|
|
340
|
+
const orders = await client.api.getOrders({
|
|
341
|
+
orderType: 'tradable',
|
|
342
|
+
status: 'open',
|
|
343
|
+
});
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## React Integration
|
|
347
|
+
|
|
348
|
+
See `@pepay-streams/sdk/react` for React-specific helpers:
|
|
349
|
+
|
|
350
|
+
```typescript
|
|
351
|
+
import { queryKeys, formatters } from '@pepay-streams/sdk/react';
|
|
352
|
+
|
|
353
|
+
// Use with react-query
|
|
354
|
+
const { data } = useQuery({
|
|
355
|
+
queryKey: queryKeys.campaign(campaignId),
|
|
356
|
+
queryFn: () => client.campaigns.getCampaign(campaignId),
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
// Format amounts
|
|
360
|
+
formatters.formatTokenAmount(amount, 18); // "1,234.56"
|
|
361
|
+
formatters.shortenAddress(address); // "0x1234...5678"
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
## Module Exports
|
|
365
|
+
|
|
366
|
+
```typescript
|
|
367
|
+
// Main client
|
|
368
|
+
import { PepayStreamsClient } from '@pepay-streams/sdk';
|
|
369
|
+
|
|
370
|
+
// Individual modules
|
|
371
|
+
import { CampaignsModule } from '@pepay-streams/sdk/campaigns';
|
|
372
|
+
import { ClaimsModule } from '@pepay-streams/sdk/claims';
|
|
373
|
+
import { StakingModule } from '@pepay-streams/sdk/staking';
|
|
374
|
+
import { MarketplaceModule } from '@pepay-streams/sdk/marketplace';
|
|
375
|
+
import { AutomationModule } from '@pepay-streams/sdk/automation';
|
|
376
|
+
import { ApiClient } from '@pepay-streams/sdk/api';
|
|
377
|
+
|
|
378
|
+
// React helpers
|
|
379
|
+
import { queryKeys, formatters } from '@pepay-streams/sdk/react';
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
## Types
|
|
383
|
+
|
|
384
|
+
All types are fully exported:
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
import type {
|
|
388
|
+
PepayStreamsConfig,
|
|
389
|
+
CampaignInfo,
|
|
390
|
+
PoolInfo,
|
|
391
|
+
OrderInfo,
|
|
392
|
+
RecipientStatus,
|
|
393
|
+
// ... and more
|
|
394
|
+
} from '@pepay-streams/sdk';
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
## Supported Chains
|
|
398
|
+
|
|
399
|
+
- Ethereum Mainnet (1)
|
|
400
|
+
- BNB Smart Chain (56)
|
|
401
|
+
- Local Anvil (31337)
|
|
402
|
+
|
|
403
|
+
## License
|
|
404
|
+
|
|
405
|
+
MIT
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { i as PaginatedResponse, j as ApiCampaign, k as ApiOrder, l as ApiStakingPool } from '../index-BTG0TRJt.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* API Client Module
|
|
6
|
+
*
|
|
7
|
+
* Provides methods for querying indexed blockchain data:
|
|
8
|
+
* - Campaign queries
|
|
9
|
+
* - Order queries
|
|
10
|
+
* - Wallet activity
|
|
11
|
+
* - Token information
|
|
12
|
+
* - Staking pool queries
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Query parameters for campaigns
|
|
17
|
+
*/
|
|
18
|
+
interface CampaignQueryParams {
|
|
19
|
+
/** Filter by campaign kind */
|
|
20
|
+
kind?: 'instant_airdrop' | 'vested_airdrop' | 'lock' | 'vesting';
|
|
21
|
+
/** Filter by creator address */
|
|
22
|
+
creator?: Address;
|
|
23
|
+
/** Filter by token address */
|
|
24
|
+
token?: Address;
|
|
25
|
+
/** Filter by status */
|
|
26
|
+
status?: 'active' | 'paused' | 'finalized';
|
|
27
|
+
/** Page number (1-indexed) */
|
|
28
|
+
page?: number;
|
|
29
|
+
/** Items per page */
|
|
30
|
+
pageSize?: number;
|
|
31
|
+
/** Sort field */
|
|
32
|
+
sortBy?: 'createdAt' | 'totalAllocated' | 'recipientCount';
|
|
33
|
+
/** Sort direction */
|
|
34
|
+
sortOrder?: 'asc' | 'desc';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Query parameters for orders
|
|
38
|
+
*/
|
|
39
|
+
interface OrderQueryParams {
|
|
40
|
+
/** Filter by order type */
|
|
41
|
+
orderType?: 'instant' | 'vested' | 'tradable';
|
|
42
|
+
/** Filter by seller */
|
|
43
|
+
seller?: Address;
|
|
44
|
+
/** Filter by sell token */
|
|
45
|
+
sellToken?: Address;
|
|
46
|
+
/** Filter by pay token */
|
|
47
|
+
payToken?: Address;
|
|
48
|
+
/** Filter by status */
|
|
49
|
+
status?: 'open' | 'filled' | 'canceled' | 'expired';
|
|
50
|
+
/** Filter by campaign (for tradable) */
|
|
51
|
+
campaignId?: string;
|
|
52
|
+
/** Page number */
|
|
53
|
+
page?: number;
|
|
54
|
+
/** Items per page */
|
|
55
|
+
pageSize?: number;
|
|
56
|
+
/** Sort field */
|
|
57
|
+
sortBy?: 'createdAt' | 'totalPrice' | 'expiresAt';
|
|
58
|
+
/** Sort direction */
|
|
59
|
+
sortOrder?: 'asc' | 'desc';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Query parameters for staking pools
|
|
63
|
+
*/
|
|
64
|
+
interface PoolQueryParams {
|
|
65
|
+
/** Filter by stake token */
|
|
66
|
+
stakeToken?: Address;
|
|
67
|
+
/** Filter by reward token */
|
|
68
|
+
rewardToken?: Address;
|
|
69
|
+
/** Filter by creator */
|
|
70
|
+
creator?: Address;
|
|
71
|
+
/** Filter by active status */
|
|
72
|
+
isActive?: boolean;
|
|
73
|
+
/** Page number */
|
|
74
|
+
page?: number;
|
|
75
|
+
/** Items per page */
|
|
76
|
+
pageSize?: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Wallet activity summary
|
|
80
|
+
*/
|
|
81
|
+
interface WalletActivity {
|
|
82
|
+
address: Address;
|
|
83
|
+
/** Campaigns where wallet is a recipient */
|
|
84
|
+
campaigns: {
|
|
85
|
+
id: string;
|
|
86
|
+
kind: string;
|
|
87
|
+
allocated: string;
|
|
88
|
+
claimed: string;
|
|
89
|
+
due: string;
|
|
90
|
+
}[];
|
|
91
|
+
/** Open orders created by wallet */
|
|
92
|
+
openOrders: ApiOrder[];
|
|
93
|
+
/** Staking positions */
|
|
94
|
+
stakes: {
|
|
95
|
+
poolId: string;
|
|
96
|
+
amount: string;
|
|
97
|
+
pendingRewards: string;
|
|
98
|
+
}[];
|
|
99
|
+
/** Total value across all positions (in USD if available) */
|
|
100
|
+
totalValue?: string;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Token information from enrichment
|
|
104
|
+
*/
|
|
105
|
+
interface TokenInfo {
|
|
106
|
+
address: Address;
|
|
107
|
+
chainId: number;
|
|
108
|
+
symbol: string;
|
|
109
|
+
name: string;
|
|
110
|
+
decimals: number;
|
|
111
|
+
logoUrl?: string;
|
|
112
|
+
priceUsd?: string;
|
|
113
|
+
marketCap?: string;
|
|
114
|
+
volume24h?: string;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* API client for indexed blockchain data
|
|
118
|
+
*/
|
|
119
|
+
declare class ApiClient {
|
|
120
|
+
private readonly baseUrl;
|
|
121
|
+
private readonly chainId;
|
|
122
|
+
constructor(baseUrl: string, chainId: number);
|
|
123
|
+
/**
|
|
124
|
+
* Get campaigns with optional filtering
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* const campaigns = await sdk.api.getCampaigns({
|
|
129
|
+
* kind: 'vested_airdrop',
|
|
130
|
+
* status: 'active',
|
|
131
|
+
* page: 1,
|
|
132
|
+
* pageSize: 20,
|
|
133
|
+
* });
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
getCampaigns(params?: CampaignQueryParams): Promise<PaginatedResponse<ApiCampaign>>;
|
|
137
|
+
/**
|
|
138
|
+
* Get a single campaign by ID
|
|
139
|
+
*/
|
|
140
|
+
getCampaign(campaignId: string): Promise<ApiCampaign>;
|
|
141
|
+
/**
|
|
142
|
+
* Get campaign recipients
|
|
143
|
+
*/
|
|
144
|
+
getCampaignRecipients(campaignId: string, params?: {
|
|
145
|
+
page?: number;
|
|
146
|
+
pageSize?: number;
|
|
147
|
+
}): Promise<PaginatedResponse<{
|
|
148
|
+
address: Address;
|
|
149
|
+
allocated: string;
|
|
150
|
+
claimed: string;
|
|
151
|
+
blocked: boolean;
|
|
152
|
+
}>>;
|
|
153
|
+
/**
|
|
154
|
+
* Get campaign activity/claims
|
|
155
|
+
*/
|
|
156
|
+
getCampaignActivity(campaignId: string, params?: {
|
|
157
|
+
page?: number;
|
|
158
|
+
pageSize?: number;
|
|
159
|
+
}): Promise<PaginatedResponse<{
|
|
160
|
+
recipient: Address;
|
|
161
|
+
amount: string;
|
|
162
|
+
timestamp: string;
|
|
163
|
+
txHash: string;
|
|
164
|
+
}>>;
|
|
165
|
+
/**
|
|
166
|
+
* Get marketplace orders with optional filtering
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const orders = await sdk.api.getOrders({
|
|
171
|
+
* orderType: 'tradable',
|
|
172
|
+
* status: 'open',
|
|
173
|
+
* sortBy: 'totalPrice',
|
|
174
|
+
* sortOrder: 'asc',
|
|
175
|
+
* });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
getOrders(params?: OrderQueryParams): Promise<PaginatedResponse<ApiOrder>>;
|
|
179
|
+
/**
|
|
180
|
+
* Get a single order by ID
|
|
181
|
+
*/
|
|
182
|
+
getOrder(orderId: string): Promise<ApiOrder>;
|
|
183
|
+
/**
|
|
184
|
+
* Get order price quote
|
|
185
|
+
*/
|
|
186
|
+
getOrderQuote(orderId: string): Promise<{
|
|
187
|
+
totalPrice: string;
|
|
188
|
+
protocolFee: string;
|
|
189
|
+
sellerReceives: string;
|
|
190
|
+
isValid: boolean;
|
|
191
|
+
}>;
|
|
192
|
+
/**
|
|
193
|
+
* Get staking pools with optional filtering
|
|
194
|
+
*/
|
|
195
|
+
getStakingPools(params?: PoolQueryParams): Promise<PaginatedResponse<ApiStakingPool>>;
|
|
196
|
+
/**
|
|
197
|
+
* Get a single staking pool by ID
|
|
198
|
+
*/
|
|
199
|
+
getStakingPool(poolId: string): Promise<ApiStakingPool>;
|
|
200
|
+
/**
|
|
201
|
+
* Get stakers for a pool
|
|
202
|
+
*/
|
|
203
|
+
getPoolStakers(poolId: string, params?: {
|
|
204
|
+
page?: number;
|
|
205
|
+
pageSize?: number;
|
|
206
|
+
}): Promise<PaginatedResponse<{
|
|
207
|
+
address: Address;
|
|
208
|
+
amount: string;
|
|
209
|
+
pendingRewards: string;
|
|
210
|
+
}>>;
|
|
211
|
+
/**
|
|
212
|
+
* Get wallet activity summary
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const activity = await sdk.api.getWalletActivity(address);
|
|
217
|
+
* console.log('Campaigns:', activity.campaigns.length);
|
|
218
|
+
* console.log('Open orders:', activity.openOrders.length);
|
|
219
|
+
* console.log('Stakes:', activity.stakes.length);
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
getWalletActivity(address: Address): Promise<WalletActivity>;
|
|
223
|
+
/**
|
|
224
|
+
* Get wallet claims history
|
|
225
|
+
*/
|
|
226
|
+
getWalletClaims(address: Address, params?: {
|
|
227
|
+
page?: number;
|
|
228
|
+
pageSize?: number;
|
|
229
|
+
}): Promise<PaginatedResponse<{
|
|
230
|
+
campaignId: string;
|
|
231
|
+
amount: string;
|
|
232
|
+
timestamp: string;
|
|
233
|
+
txHash: string;
|
|
234
|
+
}>>;
|
|
235
|
+
/**
|
|
236
|
+
* Get wallet positions (campaigns where wallet has allocations)
|
|
237
|
+
*/
|
|
238
|
+
getWalletPositions(address: Address): Promise<{
|
|
239
|
+
campaignId: string;
|
|
240
|
+
kind: string;
|
|
241
|
+
token: Address;
|
|
242
|
+
allocated: string;
|
|
243
|
+
claimed: string;
|
|
244
|
+
due: string;
|
|
245
|
+
vestingProgress: number;
|
|
246
|
+
}[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Search for tokens
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* ```typescript
|
|
252
|
+
* const tokens = await sdk.api.searchTokens('USDC');
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
searchTokens(query: string): Promise<TokenInfo[]>;
|
|
256
|
+
/**
|
|
257
|
+
* Get token information by address
|
|
258
|
+
*/
|
|
259
|
+
getToken(address: Address): Promise<TokenInfo>;
|
|
260
|
+
/**
|
|
261
|
+
* Get token price
|
|
262
|
+
*/
|
|
263
|
+
getTokenPrice(address: Address): Promise<{
|
|
264
|
+
priceUsd: string;
|
|
265
|
+
priceChange24h: string;
|
|
266
|
+
timestamp: string;
|
|
267
|
+
}>;
|
|
268
|
+
/**
|
|
269
|
+
* Check API health
|
|
270
|
+
*/
|
|
271
|
+
health(): Promise<{
|
|
272
|
+
status: 'ok' | 'degraded' | 'down';
|
|
273
|
+
indexerBlockHeight: number;
|
|
274
|
+
chainBlockHeight: number;
|
|
275
|
+
lag: number;
|
|
276
|
+
}>;
|
|
277
|
+
/**
|
|
278
|
+
* Get supported chains
|
|
279
|
+
*/
|
|
280
|
+
getChains(): Promise<{
|
|
281
|
+
chainId: number;
|
|
282
|
+
name: string;
|
|
283
|
+
rpcUrl: string;
|
|
284
|
+
diamondAddress: Address;
|
|
285
|
+
}[]>;
|
|
286
|
+
/**
|
|
287
|
+
* Prepare a claim transaction
|
|
288
|
+
*
|
|
289
|
+
* Returns the calldata for a claim transaction.
|
|
290
|
+
*/
|
|
291
|
+
prepareClaimTx(params: {
|
|
292
|
+
campaignId: string;
|
|
293
|
+
recipient: Address;
|
|
294
|
+
}): Promise<{
|
|
295
|
+
to: Address;
|
|
296
|
+
data: `0x${string}`;
|
|
297
|
+
value: string;
|
|
298
|
+
estimatedGas: string;
|
|
299
|
+
}>;
|
|
300
|
+
/**
|
|
301
|
+
* Prepare a fill order transaction
|
|
302
|
+
*/
|
|
303
|
+
prepareFillOrderTx(params: {
|
|
304
|
+
orderId: string;
|
|
305
|
+
}): Promise<{
|
|
306
|
+
to: Address;
|
|
307
|
+
data: `0x${string}`;
|
|
308
|
+
value: string;
|
|
309
|
+
estimatedGas: string;
|
|
310
|
+
}>;
|
|
311
|
+
private fetch;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* API error class
|
|
315
|
+
*/
|
|
316
|
+
declare class ApiError extends Error {
|
|
317
|
+
readonly status: number;
|
|
318
|
+
constructor(status: number, message: string);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export { ApiClient, ApiError, type CampaignQueryParams, type OrderQueryParams, type PoolQueryParams, type TokenInfo, type WalletActivity, ApiClient as default };
|