@wzrd_sol/sdk 0.1.1 → 0.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 +2 -0
- package/dist/accounts.d.ts +13 -0
- package/dist/accounts.js +42 -1
- package/dist/accounts.test.d.ts +1 -0
- package/dist/accounts.test.js +47 -0
- package/dist/agent-auth.d.ts +89 -0
- package/dist/agent-auth.js +147 -0
- package/dist/agent-loop.d.ts +87 -0
- package/dist/agent-loop.js +388 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +3 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +13 -5
- package/dist/instructions.d.ts +551 -5
- package/dist/instructions.js +1466 -24
- package/dist/instructions.test.d.ts +7 -0
- package/dist/instructions.test.js +318 -0
- package/dist/model-selector.d.ts +141 -0
- package/dist/model-selector.js +247 -0
- package/dist/nav.d.ts +40 -0
- package/dist/nav.js +39 -0
- package/dist/nav.test.d.ts +4 -0
- package/dist/nav.test.js +98 -0
- package/dist/pda.d.ts +4 -0
- package/dist/pda.js +10 -1
- package/dist/stream.d.ts +88 -0
- package/dist/stream.js +220 -0
- package/dist/stream.test.d.ts +7 -0
- package/dist/stream.test.js +296 -0
- package/package.json +9 -3
package/dist/instructions.d.ts
CHANGED
|
@@ -12,6 +12,50 @@ import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
|
12
12
|
export declare function anchorDisc(name: string): Promise<Buffer>;
|
|
13
13
|
/** Build a CreateIdempotent ATA instruction (instruction index 1). Never fails if ATA exists. */
|
|
14
14
|
export declare function createAtaIdempotentIx(payer: PublicKey, ata: PublicKey, owner: PublicKey, mint: PublicKey, tokenProgramId?: PublicKey): TransactionInstruction;
|
|
15
|
+
/**
|
|
16
|
+
* Meteora DLMM program ID (mainnet).
|
|
17
|
+
* Used for addLiquidity / removeLiquidity instructions.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DLMM_PROGRAM_ID: PublicKey;
|
|
20
|
+
/**
|
|
21
|
+
* Build a Meteora DLMM `addLiquidity` TransactionInstruction.
|
|
22
|
+
*
|
|
23
|
+
* This is the agent LP pattern: deposit CCM + counterpart (SOL/USDC) into
|
|
24
|
+
* a DLMM concentrated liquidity position to earn swap fees from other agents.
|
|
25
|
+
*
|
|
26
|
+
* Note: For Token-2022 mints like CCM, transfer fees are deducted automatically
|
|
27
|
+
* on transfer_checked. The DLMM program handles this internally.
|
|
28
|
+
*
|
|
29
|
+
* @param pool - DLMM pool address (e.g., CCM/SOL, CCM/USDC)
|
|
30
|
+
* @param position - Position account (create with DLMM initPosition first)
|
|
31
|
+
* @param owner - Position owner (signer)
|
|
32
|
+
* @param tokenXMint - Pool token X mint
|
|
33
|
+
* @param tokenYMint - Pool token Y mint
|
|
34
|
+
* @param userTokenX - Owner's token X ATA
|
|
35
|
+
* @param userTokenY - Owner's token Y ATA
|
|
36
|
+
* @param reserveX - Pool reserve X account
|
|
37
|
+
* @param reserveY - Pool reserve Y account
|
|
38
|
+
* @param binArrayLower - Lower bin array account
|
|
39
|
+
* @param binArrayUpper - Upper bin array account
|
|
40
|
+
* @param amountX - Token X amount (native units)
|
|
41
|
+
* @param amountY - Token Y amount (native units)
|
|
42
|
+
*/
|
|
43
|
+
export declare function createAddLiquidityIx(pool: PublicKey, position: PublicKey, owner: PublicKey, tokenXMint: PublicKey, tokenYMint: PublicKey, userTokenX: PublicKey, userTokenY: PublicKey, reserveX: PublicKey, reserveY: PublicKey, binArrayLower: PublicKey, binArrayUpper: PublicKey, amountX: bigint, amountY: bigint, activeBinId: number, binCount: number, tokenXProgram?: PublicKey, tokenYProgram?: PublicKey): TransactionInstruction;
|
|
44
|
+
/**
|
|
45
|
+
* Build a Meteora DLMM `removeLiquidity` TransactionInstruction.
|
|
46
|
+
*
|
|
47
|
+
* Agent pattern: withdraw LP position to recover tokens and accrued fees.
|
|
48
|
+
*/
|
|
49
|
+
export declare function createRemoveLiquidityIx(pool: PublicKey, position: PublicKey, owner: PublicKey, reserveX: PublicKey, reserveY: PublicKey, userTokenX: PublicKey, userTokenY: PublicKey, tokenXMint: PublicKey, tokenYMint: PublicKey, binArrayLower: PublicKey, binArrayUpper: PublicKey, bpsBasisPointsToRemove: number, tokenXProgram?: PublicKey, tokenYProgram?: PublicKey): TransactionInstruction;
|
|
50
|
+
/**
|
|
51
|
+
* `settle_market` account layout mode.
|
|
52
|
+
*
|
|
53
|
+
* `legacy_ccm` matches the currently deployed mainnet ABI, which still validates
|
|
54
|
+
* `ccm_mint` / `user_ccm_ata` accounts even though the instruction no longer mints CCM.
|
|
55
|
+
* `current` matches the slimmer source layout after those accounts were removed.
|
|
56
|
+
* `auto` selects `legacy_ccm` for the current mainnet program ID and `current` otherwise.
|
|
57
|
+
*/
|
|
58
|
+
export type SettleAccountsMode = 'auto' | 'current' | 'legacy_ccm';
|
|
15
59
|
/**
|
|
16
60
|
* Build a `deposit_market` TransactionInstruction.
|
|
17
61
|
*
|
|
@@ -45,15 +89,21 @@ amount: bigint | number, programId?: PublicKey): Promise<TransactionInstruction[
|
|
|
45
89
|
* 5. user_vlofi_ata (writable)
|
|
46
90
|
* 6. vault_usdc_ata (writable)
|
|
47
91
|
* 7. user_usdc_ata (writable)
|
|
48
|
-
* 8. ccm_mint (
|
|
49
|
-
* 9. user_ccm_ata (
|
|
92
|
+
* 8. ccm_mint (legacy mainnet ABI only)
|
|
93
|
+
* 9. user_ccm_ata (legacy mainnet ABI only)
|
|
50
94
|
* 10. token_program (readonly) — legacy SPL (USDC)
|
|
51
95
|
* 11. token_2022_program (readonly) — vLOFI burn
|
|
52
|
-
* 12. ccm_token_program (readonly) —
|
|
96
|
+
* 12. ccm_token_program (readonly) — Token-2022 for legacy mainnet ABI
|
|
97
|
+
*
|
|
98
|
+
* The deployed mainnet program still expects the legacy CCM accounts even though
|
|
99
|
+
* the instruction no longer mints CCM. In `auto` mode we include them for mainnet
|
|
100
|
+
* and use the slimmer layout elsewhere.
|
|
53
101
|
*
|
|
54
|
-
* @returns Array
|
|
102
|
+
* @returns Array containing the settle IX.
|
|
55
103
|
*/
|
|
56
|
-
export declare function createSettleMarketIx(connection: Connection, user: PublicKey, marketId: number, programId?: PublicKey
|
|
104
|
+
export declare function createSettleMarketIx(connection: Connection, user: PublicKey, marketId: number, programId?: PublicKey, options?: {
|
|
105
|
+
accountsMode?: SettleAccountsMode;
|
|
106
|
+
}): Promise<TransactionInstruction[]>;
|
|
57
107
|
/**
|
|
58
108
|
* Build an `initialize_market_vault` TransactionInstruction.
|
|
59
109
|
*
|
|
@@ -87,6 +137,13 @@ export declare function createInitializeMarketVaultIx(admin: PublicKey, marketId
|
|
|
87
137
|
export declare function createClaimGlobalIx(connection: Connection, claimer: PublicKey, rootSeq: number, cumulativeTotal: bigint | number,
|
|
88
138
|
/** Hex-encoded 32-byte sibling hashes from the claims API */
|
|
89
139
|
proofHex: string[], programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
140
|
+
/**
|
|
141
|
+
* Build a `claim_global_v2` TransactionInstruction (V5 leaf format).
|
|
142
|
+
*
|
|
143
|
+
* Same accounts as claim_global, but args split cumulative_total into
|
|
144
|
+
* base_yield + attention_bonus for V5 merkle leaf verification.
|
|
145
|
+
*/
|
|
146
|
+
export declare function createClaimGlobalV2Ix(connection: Connection, claimer: PublicKey, rootSeq: number, baseYield: bigint | number, attentionBonus: bigint | number, proofHex: string[], programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
90
147
|
/**
|
|
91
148
|
* Build a `create_channel_config_v2` TransactionInstruction.
|
|
92
149
|
*
|
|
@@ -105,3 +162,492 @@ proofHex: string[], programId?: PublicKey): Promise<TransactionInstruction[]>;
|
|
|
105
162
|
export declare function createChannelConfigV2Ix(admin: PublicKey,
|
|
106
163
|
/** CCM mint pubkey (from ProtocolState.mint) */
|
|
107
164
|
mint: PublicKey, subject: PublicKey, authority: PublicKey, creatorWallet: PublicKey, creatorFeeBps: number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
165
|
+
/**
|
|
166
|
+
* Build a `create_market` TransactionInstruction (prediction markets).
|
|
167
|
+
*
|
|
168
|
+
* Accounts (order must match CreateMarket struct in markets.rs):
|
|
169
|
+
* 0. authority (signer, writable)
|
|
170
|
+
* 1. protocol_state (readonly)
|
|
171
|
+
* 2. global_root_config (readonly)
|
|
172
|
+
* 3. market_state (writable, init)
|
|
173
|
+
* 4. system_program (readonly)
|
|
174
|
+
*
|
|
175
|
+
* Args (Borsh):
|
|
176
|
+
* market_id: u64
|
|
177
|
+
* creator_wallet: Pubkey (32 bytes)
|
|
178
|
+
* metric: u8
|
|
179
|
+
* target: u64
|
|
180
|
+
* resolution_root_seq: u64
|
|
181
|
+
*/
|
|
182
|
+
export declare function createCreateMarketIx(authority: PublicKey, ccmMint: PublicKey, marketId: number, creatorWallet: PublicKey, metric: number, target: bigint | number, resolutionRootSeq: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
183
|
+
/**
|
|
184
|
+
* Build an `update_attention` TransactionInstruction.
|
|
185
|
+
*
|
|
186
|
+
* Oracle pushes attention multiplier to a user's market position.
|
|
187
|
+
*
|
|
188
|
+
* Accounts (order must match UpdateAttention struct in vault.rs):
|
|
189
|
+
* 0. oracle_authority (signer, writable)
|
|
190
|
+
* 1. protocol_state (readonly)
|
|
191
|
+
* 2. market_vault (readonly)
|
|
192
|
+
* 3. user_market_position (writable)
|
|
193
|
+
*
|
|
194
|
+
* Args: market_id (u64), user_pubkey (Pubkey), multiplier_bps (u64)
|
|
195
|
+
*/
|
|
196
|
+
export declare function createUpdateAttentionIx(oracleAuthority: PublicKey, marketId: number, userPubkey: PublicKey, multiplierBps: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
197
|
+
/**
|
|
198
|
+
* Build a `publish_global_root` TransactionInstruction.
|
|
199
|
+
*
|
|
200
|
+
* Accounts (order must match PublishGlobalRoot struct in global.rs):
|
|
201
|
+
* 0. payer (signer, writable)
|
|
202
|
+
* 1. protocol_state (readonly)
|
|
203
|
+
* 2. global_root_config (writable)
|
|
204
|
+
*
|
|
205
|
+
* Args: root_seq (u64), root ([u8; 32]), dataset_hash ([u8; 32])
|
|
206
|
+
*/
|
|
207
|
+
export declare function createPublishGlobalRootIx(payer: PublicKey, ccmMint: PublicKey, rootSeq: bigint | number,
|
|
208
|
+
/** 32-byte merkle root (hex string or Buffer) */
|
|
209
|
+
root: string | Buffer,
|
|
210
|
+
/** 32-byte dataset hash (hex string or Buffer) */
|
|
211
|
+
datasetHash: string | Buffer, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
212
|
+
/**
|
|
213
|
+
* Build a `claim_yield` TransactionInstruction.
|
|
214
|
+
*
|
|
215
|
+
* NOTE: This instruction is deprecated on-chain and always returns
|
|
216
|
+
* `ClaimYieldDeprecated`. Included for SDK completeness.
|
|
217
|
+
*
|
|
218
|
+
* Accounts (order must match ClaimYield struct in vault.rs):
|
|
219
|
+
* 0. user (signer, writable)
|
|
220
|
+
* 1. protocol_state (readonly)
|
|
221
|
+
* 2. market_vault (readonly)
|
|
222
|
+
* 3. user_market_position (writable)
|
|
223
|
+
*
|
|
224
|
+
* Args: market_id (u64)
|
|
225
|
+
*/
|
|
226
|
+
export declare function createClaimYieldIx(user: PublicKey, marketId: number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
227
|
+
/**
|
|
228
|
+
* Build a `close_market` TransactionInstruction (prediction markets).
|
|
229
|
+
*
|
|
230
|
+
* Accounts (order must match CloseMarket struct in markets.rs):
|
|
231
|
+
* 0. admin (signer, writable)
|
|
232
|
+
* 1. protocol_state (readonly)
|
|
233
|
+
* 2. market_state (writable, close -> admin)
|
|
234
|
+
* 3. vault (writable) — must be empty
|
|
235
|
+
* 4. ccm_mint (readonly)
|
|
236
|
+
* 5. mint_authority (readonly)
|
|
237
|
+
* 6. token_program (readonly) — Token-2022
|
|
238
|
+
*/
|
|
239
|
+
export declare function createCloseMarketIx(admin: PublicKey, ccmMint: PublicKey, marketId: number, vault: PublicKey, mintAuthority: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
240
|
+
/**
|
|
241
|
+
* Build an `update_nav` TransactionInstruction.
|
|
242
|
+
*
|
|
243
|
+
* Oracle authority sets NAV per vLOFI share on a MarketVault.
|
|
244
|
+
*
|
|
245
|
+
* Accounts (order must match UpdateNav struct in vault.rs):
|
|
246
|
+
* 0. oracle_authority (signer, writable)
|
|
247
|
+
* 1. protocol_state (readonly)
|
|
248
|
+
* 2. market_vault (writable)
|
|
249
|
+
*
|
|
250
|
+
* Args: market_id (u64), nav_per_share_bps (u64)
|
|
251
|
+
*/
|
|
252
|
+
export declare function createUpdateNavIx(oracleAuthority: PublicKey, marketId: number, navPerShareBps: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
253
|
+
/**
|
|
254
|
+
* Build an `initialize_protocol_state` TransactionInstruction.
|
|
255
|
+
*
|
|
256
|
+
* One-time protocol setup. Creates the singleton ProtocolState PDA.
|
|
257
|
+
*
|
|
258
|
+
* Accounts (order must match InitializeProtocolState struct in vault.rs):
|
|
259
|
+
* 0. admin (signer, writable)
|
|
260
|
+
* 1. protocol_state (writable, init)
|
|
261
|
+
* 2. system_program (readonly)
|
|
262
|
+
*
|
|
263
|
+
* Args: publisher (Pubkey), treasury (Pubkey), oracle_authority (Pubkey), ccm_mint (Pubkey)
|
|
264
|
+
*/
|
|
265
|
+
export declare function createInitializeProtocolStateIx(admin: PublicKey, publisher: PublicKey, treasury: PublicKey, oracleAuthority: PublicKey, ccmMint: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
266
|
+
/**
|
|
267
|
+
* Build an `update_publisher_open` TransactionInstruction.
|
|
268
|
+
*
|
|
269
|
+
* Admin updates the allowlisted publisher address.
|
|
270
|
+
*
|
|
271
|
+
* Accounts (order must match UpdatePublisherOpen struct in admin.rs):
|
|
272
|
+
* 0. admin (signer, writable)
|
|
273
|
+
* 1. protocol_state (writable)
|
|
274
|
+
*
|
|
275
|
+
* Args: new_publisher (Pubkey)
|
|
276
|
+
*/
|
|
277
|
+
export declare function createUpdateProtocolStateIx(admin: PublicKey, newPublisher: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
278
|
+
/**
|
|
279
|
+
* Build a `set_treasury` TransactionInstruction.
|
|
280
|
+
*
|
|
281
|
+
* Admin updates the treasury wallet (fee destination owner).
|
|
282
|
+
*
|
|
283
|
+
* Accounts (order must match SetTreasury struct in admin.rs):
|
|
284
|
+
* 0. admin (signer, writable)
|
|
285
|
+
* 1. protocol_state (writable)
|
|
286
|
+
*
|
|
287
|
+
* Args: new_treasury (Pubkey)
|
|
288
|
+
*/
|
|
289
|
+
export declare function createSetTreasuryIx(admin: PublicKey, newTreasury: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
290
|
+
/**
|
|
291
|
+
* Build a `stake_channel` TransactionInstruction.
|
|
292
|
+
*
|
|
293
|
+
* Accounts (order must match StakeChannel struct in staking.rs):
|
|
294
|
+
* 0. user (signer)
|
|
295
|
+
* 1. payer (signer, writable)
|
|
296
|
+
* 2. protocol_state (readonly)
|
|
297
|
+
* 3. channel_config (readonly)
|
|
298
|
+
* 4. mint (readonly) — CCM Token-2022
|
|
299
|
+
* 5. stake_pool (writable)
|
|
300
|
+
* 6. user_stake (writable, init)
|
|
301
|
+
* 7. vault (writable) — pool's staking vault
|
|
302
|
+
* 8. user_token_account (writable) — user's CCM ATA
|
|
303
|
+
* 9. nft_mint (writable) — soulbound NFT mint PDA
|
|
304
|
+
* 10. nft_ata (writable) — user's NFT ATA
|
|
305
|
+
* 11. token_program (readonly) — Token-2022
|
|
306
|
+
* 12. associated_token_program (readonly)
|
|
307
|
+
* 13. system_program (readonly)
|
|
308
|
+
* 14. rent (readonly)
|
|
309
|
+
*
|
|
310
|
+
* Args: amount (u64), lock_duration (u64)
|
|
311
|
+
*/
|
|
312
|
+
export declare function createStakeChannelIx(user: PublicKey, payer: PublicKey, ccmMint: PublicKey, channelConfig: PublicKey, amount: bigint | number, lockDuration: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
313
|
+
/**
|
|
314
|
+
* Build an `unstake_channel` TransactionInstruction.
|
|
315
|
+
*
|
|
316
|
+
* Accounts (order must match UnstakeChannel struct in staking.rs):
|
|
317
|
+
* 0. user (signer, writable)
|
|
318
|
+
* 1. channel_config (readonly)
|
|
319
|
+
* 2. mint (readonly) — CCM Token-2022
|
|
320
|
+
* 3. stake_pool (writable)
|
|
321
|
+
* 4. user_stake (writable, close -> user)
|
|
322
|
+
* 5. vault (writable)
|
|
323
|
+
* 6. user_token_account (writable)
|
|
324
|
+
* 7. nft_mint (writable)
|
|
325
|
+
* 8. nft_ata (writable)
|
|
326
|
+
* 9. token_program (readonly) — Token-2022
|
|
327
|
+
* 10. associated_token_program (readonly)
|
|
328
|
+
*
|
|
329
|
+
* No args (no instruction data beyond disc).
|
|
330
|
+
*/
|
|
331
|
+
export declare function createUnstakeChannelIx(user: PublicKey, ccmMint: PublicKey, channelConfig: PublicKey, nftMint: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
332
|
+
/**
|
|
333
|
+
* Build a `claim_channel_rewards` TransactionInstruction.
|
|
334
|
+
*
|
|
335
|
+
* Accounts (order must match ClaimChannelRewards struct in staking.rs):
|
|
336
|
+
* 0. user (signer, writable)
|
|
337
|
+
* 1. channel_config (readonly)
|
|
338
|
+
* 2. mint (readonly) — CCM Token-2022
|
|
339
|
+
* 3. stake_pool (writable)
|
|
340
|
+
* 4. user_stake (writable)
|
|
341
|
+
* 5. vault (writable) — pool vault
|
|
342
|
+
* 6. user_token_account (writable) — receives rewards
|
|
343
|
+
* 7. token_program (readonly) — Token-2022
|
|
344
|
+
*
|
|
345
|
+
* No args beyond disc.
|
|
346
|
+
*/
|
|
347
|
+
export declare function createClaimChannelRewardsIx(user: PublicKey, ccmMint: PublicKey, channelConfig: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
348
|
+
/**
|
|
349
|
+
* Build an `initialize_stake_pool` TransactionInstruction.
|
|
350
|
+
*
|
|
351
|
+
* Accounts (order must match InitializeStakePool struct in staking.rs):
|
|
352
|
+
* 0. payer (signer, writable)
|
|
353
|
+
* 1. protocol_state (readonly)
|
|
354
|
+
* 2. channel_config (readonly)
|
|
355
|
+
* 3. mint (readonly) — CCM Token-2022
|
|
356
|
+
* 4. stake_pool (writable, init)
|
|
357
|
+
* 5. vault (writable, init) — pool's CCM vault
|
|
358
|
+
* 6. token_program (readonly) — Token-2022
|
|
359
|
+
* 7. system_program (readonly)
|
|
360
|
+
*
|
|
361
|
+
* No args beyond disc.
|
|
362
|
+
*/
|
|
363
|
+
export declare function createInitializeStakePoolIx(payer: PublicKey, ccmMint: PublicKey, channelConfig: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
364
|
+
/**
|
|
365
|
+
* Build an `initialize_strategy_vault` TransactionInstruction.
|
|
366
|
+
*
|
|
367
|
+
* Accounts (order must match InitializeStrategyVault struct in strategy.rs):
|
|
368
|
+
* 0. admin_authority (signer, writable)
|
|
369
|
+
* 1. protocol_state (readonly)
|
|
370
|
+
* 2. market_vault (readonly)
|
|
371
|
+
* 3. deposit_mint (readonly)
|
|
372
|
+
* 4. strategy_vault (writable, init)
|
|
373
|
+
* 5. system_program (readonly)
|
|
374
|
+
*
|
|
375
|
+
* Args: reserve_ratio_bps (u16), utilization_cap_bps (u16),
|
|
376
|
+
* operator_authority (Pubkey), klend_program (Pubkey),
|
|
377
|
+
* klend_reserve (Pubkey), klend_lending_market (Pubkey), ctoken_ata (Pubkey)
|
|
378
|
+
*/
|
|
379
|
+
export declare function createInitializeStrategyVaultIx(adminAuthority: PublicKey, marketId: number, depositMint: PublicKey, reserveRatioBps: number, utilizationCapBps: number, operatorAuthority: PublicKey, klendProgram: PublicKey, klendReserve: PublicKey, klendLendingMarket: PublicKey, ctokenAta: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
380
|
+
/**
|
|
381
|
+
* Build a `deploy_to_strategy` TransactionInstruction.
|
|
382
|
+
*
|
|
383
|
+
* Deploys USDC from MarketVault into Kamino K-Lend. Requires all Kamino
|
|
384
|
+
* oracle accounts. All account addresses are pinned at strategy vault init.
|
|
385
|
+
*
|
|
386
|
+
* Accounts (order must match DeployToStrategy struct in strategy.rs):
|
|
387
|
+
* 0. operator_authority (signer, writable)
|
|
388
|
+
* 1. protocol_state (readonly)
|
|
389
|
+
* 2. market_vault (readonly)
|
|
390
|
+
* 3. strategy_vault (writable)
|
|
391
|
+
* 4. deposit_mint (readonly)
|
|
392
|
+
* 5. vault_usdc_ata (writable)
|
|
393
|
+
* 6. ctoken_ata (writable)
|
|
394
|
+
* 7. klend_program (readonly)
|
|
395
|
+
* 8. klend_reserve (writable)
|
|
396
|
+
* 9. klend_lending_market (readonly)
|
|
397
|
+
* 10. klend_lending_market_authority (readonly)
|
|
398
|
+
* 11. reserve_liquidity_supply (writable)
|
|
399
|
+
* 12. reserve_collateral_mint (writable)
|
|
400
|
+
* 13. pyth_oracle (readonly)
|
|
401
|
+
* 14. switchboard_price_oracle (readonly)
|
|
402
|
+
* 15. switchboard_twap_oracle (readonly)
|
|
403
|
+
* 16. scope_prices (readonly)
|
|
404
|
+
* 17. instruction_sysvar_account (readonly)
|
|
405
|
+
* 18. token_program (readonly) — SPL Token
|
|
406
|
+
*
|
|
407
|
+
* Args: amount (u64)
|
|
408
|
+
*/
|
|
409
|
+
export declare function createDeployToStrategyIx(operatorAuthority: PublicKey, marketId: number, depositMint: PublicKey, vaultUsdcAta: PublicKey, ctokenAta: PublicKey, klendProgram: PublicKey, klendReserve: PublicKey, klendLendingMarket: PublicKey, klendLendingMarketAuthority: PublicKey, reserveLiquiditySupply: PublicKey, reserveCollateralMint: PublicKey, pythOracle: PublicKey, switchboardPriceOracle: PublicKey, switchboardTwapOracle: PublicKey, scopePrices: PublicKey, amount: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
410
|
+
/**
|
|
411
|
+
* Build a `withdraw_from_strategy` TransactionInstruction.
|
|
412
|
+
*
|
|
413
|
+
* Withdraws USDC from Kamino back into the MarketVault reserve.
|
|
414
|
+
* Same Kamino oracle accounts as deploy_to_strategy.
|
|
415
|
+
*
|
|
416
|
+
* Accounts (order must match WithdrawFromStrategy struct in strategy.rs):
|
|
417
|
+
* Same layout as DeployToStrategy.
|
|
418
|
+
*
|
|
419
|
+
* Args: amount (u64)
|
|
420
|
+
*/
|
|
421
|
+
export declare function createWithdrawFromStrategyIx(operatorAuthority: PublicKey, marketId: number, depositMint: PublicKey, vaultUsdcAta: PublicKey, ctokenAta: PublicKey, klendProgram: PublicKey, klendReserve: PublicKey, klendLendingMarket: PublicKey, klendLendingMarketAuthority: PublicKey, reserveLiquiditySupply: PublicKey, reserveCollateralMint: PublicKey, pythOracle: PublicKey, switchboardPriceOracle: PublicKey, switchboardTwapOracle: PublicKey, scopePrices: PublicKey, amount: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
422
|
+
/**
|
|
423
|
+
* Build a `harvest_strategy_yield` TransactionInstruction.
|
|
424
|
+
*
|
|
425
|
+
* Harvests yield (NAV above principal) from Kamino and sends it to treasury.
|
|
426
|
+
*
|
|
427
|
+
* Accounts (order must match HarvestStrategyYield struct in strategy.rs):
|
|
428
|
+
* 0. operator_authority (signer, writable)
|
|
429
|
+
* 1. protocol_state (readonly)
|
|
430
|
+
* 2. market_vault (readonly)
|
|
431
|
+
* 3. strategy_vault (writable)
|
|
432
|
+
* 4. deposit_mint (readonly)
|
|
433
|
+
* 5. vault_usdc_ata (readonly) — for validation
|
|
434
|
+
* 6. treasury_ata (writable) — receives yield USDC
|
|
435
|
+
* 7. ctoken_ata (writable)
|
|
436
|
+
* 8. klend_program (readonly)
|
|
437
|
+
* 9. klend_reserve (writable)
|
|
438
|
+
* 10. klend_lending_market (readonly)
|
|
439
|
+
* 11. klend_lending_market_authority (readonly)
|
|
440
|
+
* 12. reserve_liquidity_supply (writable)
|
|
441
|
+
* 13. reserve_collateral_mint (writable)
|
|
442
|
+
* 14. pyth_oracle (readonly)
|
|
443
|
+
* 15. switchboard_price_oracle (readonly)
|
|
444
|
+
* 16. switchboard_twap_oracle (readonly)
|
|
445
|
+
* 17. scope_prices (readonly)
|
|
446
|
+
* 18. instruction_sysvar_account (readonly)
|
|
447
|
+
* 19. token_program (readonly) — SPL Token
|
|
448
|
+
*
|
|
449
|
+
* No args beyond disc.
|
|
450
|
+
*/
|
|
451
|
+
export declare function createHarvestStrategyYieldIx(operatorAuthority: PublicKey, marketId: number, depositMint: PublicKey, vaultUsdcAta: PublicKey, treasuryAta: PublicKey, ctokenAta: PublicKey, klendProgram: PublicKey, klendReserve: PublicKey, klendLendingMarket: PublicKey, klendLendingMarketAuthority: PublicKey, reserveLiquiditySupply: PublicKey, reserveCollateralMint: PublicKey, pythOracle: PublicKey, switchboardPriceOracle: PublicKey, switchboardTwapOracle: PublicKey, scopePrices: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
452
|
+
/**
|
|
453
|
+
* Build a `harvest_fees` TransactionInstruction.
|
|
454
|
+
*
|
|
455
|
+
* Permissionless. Sweeps Token-2022 withheld fees from source accounts
|
|
456
|
+
* into the treasury ATA. Source accounts are passed via `sourceAccounts`.
|
|
457
|
+
*
|
|
458
|
+
* Accounts (order must match HarvestFees struct in governance.rs):
|
|
459
|
+
* 0. authority (signer, writable)
|
|
460
|
+
* 1. protocol_state (readonly) — legacy PDA (seeds = ["protocol", mint])
|
|
461
|
+
* 2. mint (writable)
|
|
462
|
+
* 3. treasury (writable) — treasury ATA
|
|
463
|
+
* 4. token_program (readonly) — Token-2022
|
|
464
|
+
* + remaining_accounts: source token accounts to sweep
|
|
465
|
+
*
|
|
466
|
+
* No args beyond disc.
|
|
467
|
+
*/
|
|
468
|
+
export declare function createHarvestAndDistributeFeesIx(authority: PublicKey, ccmMint: PublicKey, treasuryAta: PublicKey,
|
|
469
|
+
/** Token-2022 accounts with withheld fees to sweep (max 30). */
|
|
470
|
+
sourceAccounts: PublicKey[], programId?: PublicKey): Promise<TransactionInstruction>;
|
|
471
|
+
/**
|
|
472
|
+
* Build a `route_treasury` TransactionInstruction.
|
|
473
|
+
*
|
|
474
|
+
* Phase 2 treasury routing — moves CCM from treasury to destination with min_reserve guard.
|
|
475
|
+
*
|
|
476
|
+
* Accounts (order must match RouteTreasury struct in governance.rs):
|
|
477
|
+
* 0. admin (signer, writable)
|
|
478
|
+
* 1. protocol_state (readonly) — legacy PDA (seeds = ["protocol", mint])
|
|
479
|
+
* 2. mint (readonly)
|
|
480
|
+
* 3. treasury_ata (writable) — source
|
|
481
|
+
* 4. destination_ata (writable) — target
|
|
482
|
+
* 5. token_program (readonly) — Token-2022
|
|
483
|
+
*
|
|
484
|
+
* Args: amount (u64), min_reserve (u64)
|
|
485
|
+
*/
|
|
486
|
+
export declare function createRouteTreasuryIx(admin: PublicKey, ccmMint: PublicKey, treasuryAta: PublicKey, destinationAta: PublicKey, amount: bigint | number, minReserve: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
487
|
+
/**
|
|
488
|
+
* Build a `withdraw_fees_from_mint` TransactionInstruction.
|
|
489
|
+
*
|
|
490
|
+
* Permissionless. Moves accumulated withheld fees from the mint itself to treasury.
|
|
491
|
+
*
|
|
492
|
+
* Accounts (order must match WithdrawFeesFromMint struct in governance.rs):
|
|
493
|
+
* 0. authority (signer, writable)
|
|
494
|
+
* 1. protocol_state (readonly) — legacy PDA (seeds = ["protocol", mint])
|
|
495
|
+
* 2. mint (writable)
|
|
496
|
+
* 3. treasury_ata (writable)
|
|
497
|
+
* 4. token_program (readonly) — Token-2022
|
|
498
|
+
*
|
|
499
|
+
* No args beyond disc.
|
|
500
|
+
*/
|
|
501
|
+
export declare function createWithdrawFeesFromMintIx(authority: PublicKey, ccmMint: PublicKey, treasuryAta: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
502
|
+
/**
|
|
503
|
+
* Build a `realloc_legacy_protocol` TransactionInstruction.
|
|
504
|
+
*
|
|
505
|
+
* One-shot migration: extends the legacy 141-byte ProtocolState PDA
|
|
506
|
+
* (seeds = ["protocol", mint]) to 173 bytes and inserts oracle_authority.
|
|
507
|
+
*
|
|
508
|
+
* Accounts (order must match ReallocLegacyProtocol struct in governance.rs):
|
|
509
|
+
* 0. admin (signer, writable)
|
|
510
|
+
* 1. live_protocol_state (readonly) — current ProtocolState (seeds = ["protocol_state"])
|
|
511
|
+
* 2. legacy_protocol_state (writable) — legacy PDA (seeds = ["protocol", mint])
|
|
512
|
+
* 3. mint (readonly)
|
|
513
|
+
* 4. system_program (readonly)
|
|
514
|
+
*
|
|
515
|
+
* No args beyond disc.
|
|
516
|
+
*/
|
|
517
|
+
export declare function createReallocLegacyProtocolIx(admin: PublicKey, ccmMint: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
518
|
+
/**
|
|
519
|
+
* Build a `realloc_market_vault` TransactionInstruction.
|
|
520
|
+
*
|
|
521
|
+
* Grows existing MarketVault PDA from 137 to 153 bytes (Phase 2 NAV fields).
|
|
522
|
+
* Admin-only. No-op if already at target size.
|
|
523
|
+
*
|
|
524
|
+
* Accounts (order must match ReallocMarketVault struct in vault.rs):
|
|
525
|
+
* 0. payer (signer, writable)
|
|
526
|
+
* 1. protocol_state (readonly)
|
|
527
|
+
* 2. market_vault (writable) — UncheckedAccount (may be undersized)
|
|
528
|
+
* 3. system_program (readonly)
|
|
529
|
+
*
|
|
530
|
+
* Args: market_id (u64)
|
|
531
|
+
*/
|
|
532
|
+
export declare function createReallocMarketVaultIx(payer: PublicKey, marketId: number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
533
|
+
/**
|
|
534
|
+
* Build a `resolve_market` TransactionInstruction (prediction markets).
|
|
535
|
+
*
|
|
536
|
+
* Accounts (order must match ResolveMarket struct in markets.rs):
|
|
537
|
+
* 0. resolver (signer)
|
|
538
|
+
* 1. protocol_state (readonly)
|
|
539
|
+
* 2. global_root_config (readonly)
|
|
540
|
+
* 3. market_state (writable)
|
|
541
|
+
*
|
|
542
|
+
* Args: cumulative_total (u64), proof (Vec<[u8; 32]>)
|
|
543
|
+
*/
|
|
544
|
+
export declare function createResolveMarketIx(resolver: PublicKey, ccmMint: PublicKey, marketId: number, cumulativeTotal: bigint | number, proofHex: string[], programId?: PublicKey): Promise<TransactionInstruction>;
|
|
545
|
+
/**
|
|
546
|
+
* Build a `set_paused_open` TransactionInstruction.
|
|
547
|
+
*
|
|
548
|
+
* Emergency pause/unpause toggle. Admin-only.
|
|
549
|
+
*
|
|
550
|
+
* Accounts (order must match SetPausedOpen struct in admin.rs):
|
|
551
|
+
* 0. admin (signer, writable)
|
|
552
|
+
* 1. protocol_state (writable)
|
|
553
|
+
*
|
|
554
|
+
* Args: paused (bool, serialized as u8: 0 or 1)
|
|
555
|
+
*/
|
|
556
|
+
export declare function createSetPausedOpenIx(admin: PublicKey, paused: boolean, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
557
|
+
/**
|
|
558
|
+
* Build an `initialize_global_root` TransactionInstruction.
|
|
559
|
+
*
|
|
560
|
+
* Creates the singleton GlobalRootConfig PDA for merkle root publishing.
|
|
561
|
+
*
|
|
562
|
+
* Accounts (order must match InitializeGlobalRoot struct in global.rs):
|
|
563
|
+
* 0. payer (signer, writable)
|
|
564
|
+
* 1. protocol_state (readonly)
|
|
565
|
+
* 2. global_root_config (writable, init)
|
|
566
|
+
* 3. system_program (readonly)
|
|
567
|
+
*
|
|
568
|
+
* No args beyond disc.
|
|
569
|
+
*/
|
|
570
|
+
export declare function createInitializeGlobalRootIx(payer: PublicKey, ccmMint: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
571
|
+
/**
|
|
572
|
+
* Build a `set_price_updater` TransactionInstruction.
|
|
573
|
+
*
|
|
574
|
+
* Authority rotates the cranker key for a price feed.
|
|
575
|
+
*
|
|
576
|
+
* Accounts (order must match SetPriceUpdater struct in price_feed.rs):
|
|
577
|
+
* 0. authority (signer)
|
|
578
|
+
* 1. price_feed (writable)
|
|
579
|
+
*
|
|
580
|
+
* Args: label ([u8; 32]), new_updater (Pubkey)
|
|
581
|
+
*/
|
|
582
|
+
export declare function createSetPriceUpdaterIx(authority: PublicKey,
|
|
583
|
+
/** 32-byte label (zero-padded). Use `Buffer.alloc(32)` and write your label. */
|
|
584
|
+
label: Buffer, newUpdater: PublicKey, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
585
|
+
/**
|
|
586
|
+
* Build a `mint_shares` TransactionInstruction (prediction markets).
|
|
587
|
+
*
|
|
588
|
+
* Deposits CCM into the prediction market vault and receives 1:1 YES + NO tokens.
|
|
589
|
+
*
|
|
590
|
+
* Accounts (13 fixed, order matches markets.rs mint_shares):
|
|
591
|
+
* 0. depositor (signer, writable)
|
|
592
|
+
* 1. protocol_state (readonly)
|
|
593
|
+
* 2. market_state (writable)
|
|
594
|
+
* 3. ccm_mint (readonly)
|
|
595
|
+
* 4. depositor_ccm_ata (writable)
|
|
596
|
+
* 5. vault (writable)
|
|
597
|
+
* 6. yes_mint (writable)
|
|
598
|
+
* 7. no_mint (writable)
|
|
599
|
+
* 8. depositor_yes_ata (writable)
|
|
600
|
+
* 9. depositor_no_ata (writable)
|
|
601
|
+
* 10. mint_authority (readonly)
|
|
602
|
+
* 11. token_program (Token-2022, for CCM)
|
|
603
|
+
* 12. outcome_token_prog (SPL Token, for YES/NO)
|
|
604
|
+
*
|
|
605
|
+
* Args: amount (u64) — CCM native units to deposit
|
|
606
|
+
*/
|
|
607
|
+
export declare function createMintSharesIx(depositor: PublicKey, ccmMint: PublicKey, marketId: number, amount: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
608
|
+
/**
|
|
609
|
+
* Build a `redeem_shares` TransactionInstruction (prediction markets).
|
|
610
|
+
*
|
|
611
|
+
* Burns equal YES + NO shares and returns CCM. Pre-resolution only.
|
|
612
|
+
*
|
|
613
|
+
* Accounts (13 fixed, order matches markets.rs redeem_shares):
|
|
614
|
+
* 0. redeemer (signer, writable)
|
|
615
|
+
* 1. protocol_state (readonly)
|
|
616
|
+
* 2. market_state (writable)
|
|
617
|
+
* 3. ccm_mint (readonly)
|
|
618
|
+
* 4. vault (writable)
|
|
619
|
+
* 5. yes_mint (writable)
|
|
620
|
+
* 6. no_mint (writable)
|
|
621
|
+
* 7. redeemer_yes_ata (writable)
|
|
622
|
+
* 8. redeemer_no_ata (writable)
|
|
623
|
+
* 9. redeemer_ccm_ata (writable)
|
|
624
|
+
* 10. mint_authority (readonly)
|
|
625
|
+
* 11. token_program (Token-2022, for CCM)
|
|
626
|
+
* 12. outcome_token_prog (SPL Token, for YES/NO)
|
|
627
|
+
*
|
|
628
|
+
* Args: shares (u64) — number of YES+NO pairs to redeem
|
|
629
|
+
*/
|
|
630
|
+
export declare function createRedeemSharesIx(redeemer: PublicKey, ccmMint: PublicKey, marketId: number, shares: bigint | number, programId?: PublicKey): Promise<TransactionInstruction>;
|
|
631
|
+
/**
|
|
632
|
+
* Build a `settle` TransactionInstruction (prediction markets).
|
|
633
|
+
*
|
|
634
|
+
* Burns winning-side tokens and returns CCM 1:1. Post-resolution only.
|
|
635
|
+
*
|
|
636
|
+
* Accounts (11 fixed, order matches markets.rs settle):
|
|
637
|
+
* 0. settler (signer, writable)
|
|
638
|
+
* 1. protocol_state (readonly)
|
|
639
|
+
* 2. market_state (readonly)
|
|
640
|
+
* 3. ccm_mint (readonly)
|
|
641
|
+
* 4. vault (writable)
|
|
642
|
+
* 5. winning_mint (writable) — yes_mint if YES won, no_mint if NO
|
|
643
|
+
* 6. settler_winning (writable) — settler's ATA for the winning mint
|
|
644
|
+
* 7. settler_ccm (writable) — settler's CCM ATA
|
|
645
|
+
* 8. mint_authority (readonly)
|
|
646
|
+
* 9. token_program (Token-2022, for CCM)
|
|
647
|
+
* 10. outcome_token_prog (SPL Token, for YES/NO)
|
|
648
|
+
*
|
|
649
|
+
* Args: shares (u64) — winning tokens to settle
|
|
650
|
+
*/
|
|
651
|
+
export declare function createSettlePredictionIx(settler: PublicKey, ccmMint: PublicKey, marketId: number, shares: bigint | number,
|
|
652
|
+
/** true = YES won, false = NO won */
|
|
653
|
+
yesOutcome: boolean, programId?: PublicKey): Promise<TransactionInstruction>;
|