@send-fun/sdk 1.0.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.
Files changed (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/dist/index.cjs +12808 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +4406 -0
  6. package/dist/index.d.cts.map +1 -0
  7. package/dist/index.d.mts +4405 -0
  8. package/dist/index.d.mts.map +1 -0
  9. package/dist/index.mjs +12749 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  12. package/package.json +72 -0
  13. package/src/constants.ts +38 -0
  14. package/src/dex/generated/accounts/globalConfig.ts +189 -0
  15. package/src/dex/generated/accounts/index.ts +12 -0
  16. package/src/dex/generated/accounts/pool.ts +244 -0
  17. package/src/dex/generated/accounts/rewardAccrual.ts +191 -0
  18. package/src/dex/generated/accounts/sendDex.accounts.ts +47 -0
  19. package/src/dex/generated/errors/index.ts +9 -0
  20. package/src/dex/generated/errors/sendDex.ts +161 -0
  21. package/src/dex/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  22. package/src/dex/generated/events/creatorClaimEvent.ts +119 -0
  23. package/src/dex/generated/events/depositQuoteEvent.ts +115 -0
  24. package/src/dex/generated/events/index.ts +16 -0
  25. package/src/dex/generated/events/poolCreateEvent.ts +128 -0
  26. package/src/dex/generated/events/protocolClaimEvent.ts +111 -0
  27. package/src/dex/generated/events/sendDex.events.ts +184 -0
  28. package/src/dex/generated/events/tokenCreateEvent.ts +143 -0
  29. package/src/dex/generated/events/tradeEvent.ts +143 -0
  30. package/src/dex/generated/index.ts +16 -0
  31. package/src/dex/generated/instructions/buyExactIn.ts +815 -0
  32. package/src/dex/generated/instructions/buyExactOut.ts +815 -0
  33. package/src/dex/generated/instructions/claimCreatorFees.ts +648 -0
  34. package/src/dex/generated/instructions/claimProtocolFees.ts +640 -0
  35. package/src/dex/generated/instructions/index.ts +15 -0
  36. package/src/dex/generated/instructions/sellExactIn.ts +815 -0
  37. package/src/dex/generated/instructions/sellExactOut.ts +815 -0
  38. package/src/dex/generated/instructions/sendDex.instructions.ts +173 -0
  39. package/src/dex/generated/pdas/eventAuthority.ts +20 -0
  40. package/src/dex/generated/pdas/globalConfig.ts +20 -0
  41. package/src/dex/generated/pdas/index.ts +14 -0
  42. package/src/dex/generated/pdas/lpMint.ts +36 -0
  43. package/src/dex/generated/pdas/pool.ts +34 -0
  44. package/src/dex/generated/pdas/rewardAccrual.ts +37 -0
  45. package/src/dex/generated/pdas/wsolRewardAccrual.ts +20 -0
  46. package/src/dex/generated/plugins/index.ts +9 -0
  47. package/src/dex/generated/plugins/sendDex.ts +282 -0
  48. package/src/dex/generated/programs/index.ts +9 -0
  49. package/src/dex/generated/programs/sendDex.ts +12 -0
  50. package/src/dex/generated/types/index.ts +10 -0
  51. package/src/dex/generated/types/poolStatus.ts +38 -0
  52. package/src/dex/generated/types/tradeDirection.ts +38 -0
  53. package/src/dex/index.ts +8 -0
  54. package/src/dex/trade.ts +215 -0
  55. package/src/index.ts +8 -0
  56. package/src/launchpad/create.ts +116 -0
  57. package/src/launchpad/generated/accounts/bondingCurve.ts +273 -0
  58. package/src/launchpad/generated/accounts/globalConfig.ts +211 -0
  59. package/src/launchpad/generated/accounts/index.ts +12 -0
  60. package/src/launchpad/generated/accounts/rewardAccrual.ts +191 -0
  61. package/src/launchpad/generated/accounts/sendLaunchpad.accounts.ts +50 -0
  62. package/src/launchpad/generated/errors/index.ts +9 -0
  63. package/src/launchpad/generated/errors/sendLaunchpad.ts +175 -0
  64. package/src/launchpad/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  65. package/src/launchpad/generated/events/completeEvent.ts +120 -0
  66. package/src/launchpad/generated/events/creatorClaimEvent.ts +122 -0
  67. package/src/launchpad/generated/events/index.ts +17 -0
  68. package/src/launchpad/generated/events/migrateEvent.ts +121 -0
  69. package/src/launchpad/generated/events/protocolClaimEvent.ts +114 -0
  70. package/src/launchpad/generated/events/recycleEvent.ts +113 -0
  71. package/src/launchpad/generated/events/sendLaunchpad.events.ts +207 -0
  72. package/src/launchpad/generated/events/tokenCreateEvent.ts +156 -0
  73. package/src/launchpad/generated/events/tradeEvent.ts +148 -0
  74. package/src/launchpad/generated/index.ts +16 -0
  75. package/src/launchpad/generated/instructions/buyExactIn.ts +818 -0
  76. package/src/launchpad/generated/instructions/buyExactOut.ts +818 -0
  77. package/src/launchpad/generated/instructions/claimCreatorFees.ts +651 -0
  78. package/src/launchpad/generated/instructions/claimProtocolFees.ts +640 -0
  79. package/src/launchpad/generated/instructions/createToken.ts +1150 -0
  80. package/src/launchpad/generated/instructions/index.ts +17 -0
  81. package/src/launchpad/generated/instructions/migrate.ts +840 -0
  82. package/src/launchpad/generated/instructions/sellExactIn.ts +818 -0
  83. package/src/launchpad/generated/instructions/sellExactOut.ts +818 -0
  84. package/src/launchpad/generated/instructions/sendLaunchpad.instructions.ts +210 -0
  85. package/src/launchpad/generated/pdas/bondingCurve.ts +39 -0
  86. package/src/launchpad/generated/pdas/eventAuthority.ts +20 -0
  87. package/src/launchpad/generated/pdas/globalConfig.ts +20 -0
  88. package/src/launchpad/generated/pdas/index.ts +14 -0
  89. package/src/launchpad/generated/pdas/migrationAuthority.ts +20 -0
  90. package/src/launchpad/generated/pdas/rewardAccrual.ts +37 -0
  91. package/src/launchpad/generated/pdas/wsolRewardAccrual.ts +20 -0
  92. package/src/launchpad/generated/plugins/index.ts +9 -0
  93. package/src/launchpad/generated/plugins/sendLaunchpad.ts +315 -0
  94. package/src/launchpad/generated/programs/index.ts +9 -0
  95. package/src/launchpad/generated/programs/sendLaunchpad.ts +12 -0
  96. package/src/launchpad/generated/types/bondingCurveStatus.ts +43 -0
  97. package/src/launchpad/generated/types/index.ts +10 -0
  98. package/src/launchpad/generated/types/tradeDirection.ts +38 -0
  99. package/src/launchpad/index.ts +10 -0
  100. package/src/launchpad/migrate.ts +54 -0
  101. package/src/launchpad/trade.ts +247 -0
  102. package/src/math/amm.ts +511 -0
  103. package/src/math/fee-decay.ts +49 -0
  104. package/src/math/fees.ts +75 -0
  105. package/src/math/index.ts +3 -0
  106. package/src/math/internal.ts +16 -0
  107. package/src/nexus/fee-helpers.ts +49 -0
  108. package/src/nexus/generated/accounts/altRegistry.ts +177 -0
  109. package/src/nexus/generated/accounts/creatorFeeConfig.ts +200 -0
  110. package/src/nexus/generated/accounts/feePreset.ts +196 -0
  111. package/src/nexus/generated/accounts/globalConfig.ts +188 -0
  112. package/src/nexus/generated/accounts/index.ts +19 -0
  113. package/src/nexus/generated/accounts/partnerConfig.ts +209 -0
  114. package/src/nexus/generated/accounts/partnerMetadata.ts +216 -0
  115. package/src/nexus/generated/accounts/rewardState.ts +209 -0
  116. package/src/nexus/generated/accounts/sendNexus.accounts.ts +85 -0
  117. package/src/nexus/generated/accounts/stakingConfig.ts +197 -0
  118. package/src/nexus/generated/accounts/userRewardDebt.ts +221 -0
  119. package/src/nexus/generated/accounts/userStakePosition.ts +218 -0
  120. package/src/nexus/generated/constants/index.ts +9 -0
  121. package/src/nexus/generated/constants/sendNexus.ts +13 -0
  122. package/src/nexus/generated/errors/index.ts +9 -0
  123. package/src/nexus/generated/errors/sendNexus.ts +229 -0
  124. package/src/nexus/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  125. package/src/nexus/generated/events/claimEvent.ts +106 -0
  126. package/src/nexus/generated/events/index.ts +13 -0
  127. package/src/nexus/generated/events/sendNexus.events.ts +121 -0
  128. package/src/nexus/generated/events/stakeEvent.ts +106 -0
  129. package/src/nexus/generated/events/unstakeEvent.ts +106 -0
  130. package/src/nexus/generated/index.ts +17 -0
  131. package/src/nexus/generated/instructions/claim.ts +740 -0
  132. package/src/nexus/generated/instructions/createUserRewardDebt.ts +498 -0
  133. package/src/nexus/generated/instructions/index.ts +14 -0
  134. package/src/nexus/generated/instructions/sendNexus.instructions.ts +146 -0
  135. package/src/nexus/generated/instructions/settle.ts +517 -0
  136. package/src/nexus/generated/instructions/stake.ts +615 -0
  137. package/src/nexus/generated/instructions/unstake.ts +593 -0
  138. package/src/nexus/generated/pdas/altRegistry.ts +20 -0
  139. package/src/nexus/generated/pdas/creatorFeeConfig.ts +39 -0
  140. package/src/nexus/generated/pdas/defaultFeePreset.ts +37 -0
  141. package/src/nexus/generated/pdas/defaultPartner.ts +40 -0
  142. package/src/nexus/generated/pdas/defaultPartnerMetadata.ts +42 -0
  143. package/src/nexus/generated/pdas/eventAuthority.ts +20 -0
  144. package/src/nexus/generated/pdas/feePreset.ts +39 -0
  145. package/src/nexus/generated/pdas/globalConfig.ts +20 -0
  146. package/src/nexus/generated/pdas/index.ts +22 -0
  147. package/src/nexus/generated/pdas/partnerConfig.ts +36 -0
  148. package/src/nexus/generated/pdas/partnerMetadata.ts +38 -0
  149. package/src/nexus/generated/pdas/rewardState.ts +36 -0
  150. package/src/nexus/generated/pdas/stakingConfig.ts +20 -0
  151. package/src/nexus/generated/pdas/userRewardDebt.ts +41 -0
  152. package/src/nexus/generated/pdas/userStakePosition.ts +39 -0
  153. package/src/nexus/generated/plugins/index.ts +9 -0
  154. package/src/nexus/generated/plugins/sendNexus.ts +494 -0
  155. package/src/nexus/generated/programs/index.ts +9 -0
  156. package/src/nexus/generated/programs/sendNexus.ts +12 -0
  157. package/src/nexus/generated/types/authPlatformEntry.ts +52 -0
  158. package/src/nexus/generated/types/callerType.ts +38 -0
  159. package/src/nexus/generated/types/dexFees.ts +64 -0
  160. package/src/nexus/generated/types/feeConfig.ts +73 -0
  161. package/src/nexus/generated/types/index.ts +13 -0
  162. package/src/nexus/generated/types/launchpadFees.ts +63 -0
  163. package/src/nexus/index.ts +9 -0
  164. package/src/nexus/staking.ts +581 -0
  165. package/src/platform.ts +19 -0
  166. package/src/transfer-fee.ts +216 -0
  167. package/src/utils/chunk.ts +21 -0
  168. package/src/utils/creator-hash.ts +57 -0
  169. package/src/utils/index.ts +9 -0
  170. package/src/utils/mint-info.ts +102 -0
  171. package/src/utils/partner.ts +5 -0
  172. package/src/utils/pda.ts +24 -0
@@ -0,0 +1,651 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ assertIsInstructionForProgram,
11
+ combineCodec,
12
+ containsBytes,
13
+ fixDecoderSize,
14
+ fixEncoderSize,
15
+ getAddressEncoder,
16
+ getBytesDecoder,
17
+ getBytesEncoder,
18
+ getProgramDerivedAddress,
19
+ getStructDecoder,
20
+ getStructEncoder,
21
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
22
+ SolanaError,
23
+ transformEncoder,
24
+ type AccountMeta,
25
+ type AccountSignerMeta,
26
+ type Address,
27
+ type FixedSizeCodec,
28
+ type FixedSizeDecoder,
29
+ type FixedSizeEncoder,
30
+ type Instruction,
31
+ type InstructionWithAccounts,
32
+ type InstructionWithData,
33
+ type ReadonlyAccount,
34
+ type ReadonlySignerAccount,
35
+ type ReadonlyUint8Array,
36
+ type TransactionSigner,
37
+ type WritableAccount,
38
+ type WritableSignerAccount,
39
+ } from '@solana/kit';
40
+ import {
41
+ getAccountMetaFactory,
42
+ getAddressFromResolvedInstructionAccount,
43
+ type ResolvedInstructionAccount,
44
+ } from '@solana/program-client-core';
45
+ import {
46
+ EVENT_AUTHORITY_PDA_ADDRESS,
47
+ findBondingCurvePda,
48
+ } from '../pdas/index.js';
49
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
50
+
51
+ export const CLAIM_CREATOR_FEES_DISCRIMINATOR: ReadonlyUint8Array =
52
+ new Uint8Array([0, 23, 125, 234, 156, 118, 134, 89]);
53
+
54
+ export function getClaimCreatorFeesDiscriminatorBytes(): ReadonlyUint8Array {
55
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
56
+ CLAIM_CREATOR_FEES_DISCRIMINATOR,
57
+ );
58
+ }
59
+
60
+ export type ClaimCreatorFeesInstruction<
61
+ TProgram extends string = typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
62
+ TAccountClaimer extends string | AccountMeta<string> = string,
63
+ TAccountPayer extends string | AccountMeta<string> = string,
64
+ TAccountBondingCurve extends string | AccountMeta<string> = string,
65
+ TAccountCreatorFeeConfig extends string | AccountMeta<string> = string,
66
+ TAccountNexusGlobalConfig extends string | AccountMeta<string> =
67
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr',
68
+ TAccountBaseMint extends string | AccountMeta<string> = string,
69
+ TAccountQuoteMint extends string | AccountMeta<string> = string,
70
+ TAccountQuoteVault extends string | AccountMeta<string> = string,
71
+ TAccountDestinationOwner extends string | AccountMeta<string> = string,
72
+ TAccountDestination extends string | AccountMeta<string> = string,
73
+ TAccountQuoteTokenProgram extends string | AccountMeta<string> = string,
74
+ TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
75
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
76
+ TAccountSystemProgram extends string | AccountMeta<string> =
77
+ '11111111111111111111111111111111',
78
+ TAccountEventAuthority extends string | AccountMeta<string> =
79
+ 'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
80
+ TAccountProgram extends string | AccountMeta<string> =
81
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
82
+ TRemainingAccounts extends readonly AccountMeta<string>[] = [],
83
+ > = Instruction<TProgram> &
84
+ InstructionWithData<ReadonlyUint8Array> &
85
+ InstructionWithAccounts<
86
+ [
87
+ TAccountClaimer extends string
88
+ ? ReadonlySignerAccount<TAccountClaimer> &
89
+ AccountSignerMeta<TAccountClaimer>
90
+ : TAccountClaimer,
91
+ TAccountPayer extends string
92
+ ? WritableSignerAccount<TAccountPayer> &
93
+ AccountSignerMeta<TAccountPayer>
94
+ : TAccountPayer,
95
+ TAccountBondingCurve extends string
96
+ ? WritableAccount<TAccountBondingCurve>
97
+ : TAccountBondingCurve,
98
+ TAccountCreatorFeeConfig extends string
99
+ ? ReadonlyAccount<TAccountCreatorFeeConfig>
100
+ : TAccountCreatorFeeConfig,
101
+ TAccountNexusGlobalConfig extends string
102
+ ? ReadonlyAccount<TAccountNexusGlobalConfig>
103
+ : TAccountNexusGlobalConfig,
104
+ TAccountBaseMint extends string
105
+ ? ReadonlyAccount<TAccountBaseMint>
106
+ : TAccountBaseMint,
107
+ TAccountQuoteMint extends string
108
+ ? ReadonlyAccount<TAccountQuoteMint>
109
+ : TAccountQuoteMint,
110
+ TAccountQuoteVault extends string
111
+ ? WritableAccount<TAccountQuoteVault>
112
+ : TAccountQuoteVault,
113
+ TAccountDestinationOwner extends string
114
+ ? ReadonlyAccount<TAccountDestinationOwner>
115
+ : TAccountDestinationOwner,
116
+ TAccountDestination extends string
117
+ ? WritableAccount<TAccountDestination>
118
+ : TAccountDestination,
119
+ TAccountQuoteTokenProgram extends string
120
+ ? ReadonlyAccount<TAccountQuoteTokenProgram>
121
+ : TAccountQuoteTokenProgram,
122
+ TAccountAssociatedTokenProgram extends string
123
+ ? ReadonlyAccount<TAccountAssociatedTokenProgram>
124
+ : TAccountAssociatedTokenProgram,
125
+ TAccountSystemProgram extends string
126
+ ? ReadonlyAccount<TAccountSystemProgram>
127
+ : TAccountSystemProgram,
128
+ TAccountEventAuthority extends string
129
+ ? ReadonlyAccount<TAccountEventAuthority>
130
+ : TAccountEventAuthority,
131
+ TAccountProgram extends string
132
+ ? ReadonlyAccount<TAccountProgram>
133
+ : TAccountProgram,
134
+ ...TRemainingAccounts,
135
+ ]
136
+ >;
137
+
138
+ export type ClaimCreatorFeesInstructionData = {
139
+ discriminator: ReadonlyUint8Array;
140
+ };
141
+
142
+ export type ClaimCreatorFeesInstructionDataArgs = {};
143
+
144
+ export function getClaimCreatorFeesInstructionDataEncoder(): FixedSizeEncoder<ClaimCreatorFeesInstructionDataArgs> {
145
+ return transformEncoder(
146
+ getStructEncoder([
147
+ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
148
+ ]),
149
+ (value) => ({
150
+ ...value,
151
+ discriminator: CLAIM_CREATOR_FEES_DISCRIMINATOR,
152
+ }),
153
+ );
154
+ }
155
+
156
+ export function getClaimCreatorFeesInstructionDataDecoder(): FixedSizeDecoder<ClaimCreatorFeesInstructionData> {
157
+ return getStructDecoder([
158
+ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
159
+ ]);
160
+ }
161
+
162
+ export function getClaimCreatorFeesInstructionDataCodec(): FixedSizeCodec<
163
+ ClaimCreatorFeesInstructionDataArgs,
164
+ ClaimCreatorFeesInstructionData
165
+ > {
166
+ return combineCodec(
167
+ getClaimCreatorFeesInstructionDataEncoder(),
168
+ getClaimCreatorFeesInstructionDataDecoder(),
169
+ );
170
+ }
171
+
172
+ export type ClaimCreatorFeesAsyncInput<
173
+ TAccountClaimer extends string = string,
174
+ TAccountPayer extends string = string,
175
+ TAccountBondingCurve extends string = string,
176
+ TAccountCreatorFeeConfig extends string = string,
177
+ TAccountBaseMint extends string = string,
178
+ TAccountQuoteMint extends string = string,
179
+ TAccountQuoteVault extends string = string,
180
+ TAccountDestinationOwner extends string = string,
181
+ TAccountDestination extends string = string,
182
+ TAccountQuoteTokenProgram extends string = string,
183
+ > = {
184
+ claimer: TransactionSigner<TAccountClaimer>;
185
+ payer: TransactionSigner<TAccountPayer>;
186
+ bondingCurve?: Address<TAccountBondingCurve>;
187
+ creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
188
+ baseMint: Address<TAccountBaseMint>;
189
+ quoteMint: Address<TAccountQuoteMint>;
190
+ quoteVault?: Address<TAccountQuoteVault>;
191
+ destinationOwner: Address<TAccountDestinationOwner>;
192
+ destination?: Address<TAccountDestination>;
193
+ quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
194
+ };
195
+
196
+ export async function getClaimCreatorFeesInstructionAsync<
197
+ TAccountClaimer extends string,
198
+ TAccountPayer extends string,
199
+ TAccountBondingCurve extends string,
200
+ TAccountCreatorFeeConfig extends string,
201
+ TAccountBaseMint extends string,
202
+ TAccountQuoteMint extends string,
203
+ TAccountQuoteVault extends string,
204
+ TAccountDestinationOwner extends string,
205
+ TAccountDestination extends string,
206
+ TAccountQuoteTokenProgram extends string,
207
+ >(
208
+ input: ClaimCreatorFeesAsyncInput<
209
+ TAccountClaimer,
210
+ TAccountPayer,
211
+ TAccountBondingCurve,
212
+ TAccountCreatorFeeConfig,
213
+ TAccountBaseMint,
214
+ TAccountQuoteMint,
215
+ TAccountQuoteVault,
216
+ TAccountDestinationOwner,
217
+ TAccountDestination,
218
+ TAccountQuoteTokenProgram
219
+ >,
220
+ ): Promise<
221
+ ClaimCreatorFeesInstruction<
222
+ typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
223
+ TAccountClaimer,
224
+ TAccountPayer,
225
+ TAccountBondingCurve,
226
+ TAccountCreatorFeeConfig,
227
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr',
228
+ TAccountBaseMint,
229
+ TAccountQuoteMint,
230
+ TAccountQuoteVault,
231
+ TAccountDestinationOwner,
232
+ TAccountDestination,
233
+ TAccountQuoteTokenProgram,
234
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
235
+ '11111111111111111111111111111111',
236
+ 'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
237
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
238
+ >
239
+ > {
240
+ // Program address.
241
+ const programAddress = SEND_LAUNCHPAD_PROGRAM_ADDRESS;
242
+
243
+ // Original accounts.
244
+ const originalAccounts = {
245
+ claimer: { value: input.claimer ?? null, isWritable: false },
246
+ payer: { value: input.payer ?? null, isWritable: true },
247
+ bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
248
+ creatorFeeConfig: {
249
+ value: input.creatorFeeConfig ?? null,
250
+ isWritable: false,
251
+ },
252
+ nexusGlobalConfig: { value: null, isWritable: false },
253
+ baseMint: { value: input.baseMint ?? null, isWritable: false },
254
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
255
+ quoteVault: { value: input.quoteVault ?? null, isWritable: true },
256
+ destinationOwner: {
257
+ value: input.destinationOwner ?? null,
258
+ isWritable: false,
259
+ },
260
+ destination: { value: input.destination ?? null, isWritable: true },
261
+ quoteTokenProgram: {
262
+ value: input.quoteTokenProgram ?? null,
263
+ isWritable: false,
264
+ },
265
+ associatedTokenProgram: { value: null, isWritable: false },
266
+ systemProgram: { value: null, isWritable: false },
267
+ eventAuthority: { value: null, isWritable: false },
268
+ program: { value: null, isWritable: false },
269
+ };
270
+ const accounts = originalAccounts as Record<
271
+ keyof typeof originalAccounts,
272
+ ResolvedInstructionAccount
273
+ >;
274
+
275
+ // Resolve default values.
276
+ if (!accounts.bondingCurve.value) {
277
+ accounts.bondingCurve.value = await findBondingCurvePda({
278
+ baseMint: getAddressFromResolvedInstructionAccount(
279
+ 'baseMint',
280
+ accounts.baseMint.value,
281
+ ),
282
+ quoteMint: getAddressFromResolvedInstructionAccount(
283
+ 'quoteMint',
284
+ accounts.quoteMint.value,
285
+ ),
286
+ });
287
+ }
288
+ if (!accounts.nexusGlobalConfig.value) {
289
+ accounts.nexusGlobalConfig.value =
290
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr' as Address<'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr'>;
291
+ }
292
+ if (!accounts.quoteVault.value) {
293
+ accounts.quoteVault.value = await getProgramDerivedAddress({
294
+ programAddress:
295
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>,
296
+ seeds: [
297
+ getAddressEncoder().encode(
298
+ getAddressFromResolvedInstructionAccount(
299
+ 'bondingCurve',
300
+ accounts.bondingCurve.value,
301
+ ),
302
+ ),
303
+ getAddressEncoder().encode(
304
+ getAddressFromResolvedInstructionAccount(
305
+ 'quoteTokenProgram',
306
+ accounts.quoteTokenProgram.value,
307
+ ),
308
+ ),
309
+ getAddressEncoder().encode(
310
+ getAddressFromResolvedInstructionAccount(
311
+ 'quoteMint',
312
+ accounts.quoteMint.value,
313
+ ),
314
+ ),
315
+ ],
316
+ });
317
+ }
318
+ if (!accounts.destination.value) {
319
+ accounts.destination.value = await getProgramDerivedAddress({
320
+ programAddress:
321
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>,
322
+ seeds: [
323
+ getAddressEncoder().encode(
324
+ getAddressFromResolvedInstructionAccount(
325
+ 'destinationOwner',
326
+ accounts.destinationOwner.value,
327
+ ),
328
+ ),
329
+ getAddressEncoder().encode(
330
+ getAddressFromResolvedInstructionAccount(
331
+ 'quoteTokenProgram',
332
+ accounts.quoteTokenProgram.value,
333
+ ),
334
+ ),
335
+ getAddressEncoder().encode(
336
+ getAddressFromResolvedInstructionAccount(
337
+ 'quoteMint',
338
+ accounts.quoteMint.value,
339
+ ),
340
+ ),
341
+ ],
342
+ });
343
+ }
344
+ if (!accounts.associatedTokenProgram.value) {
345
+ accounts.associatedTokenProgram.value =
346
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>;
347
+ }
348
+ if (!accounts.systemProgram.value) {
349
+ accounts.systemProgram.value =
350
+ '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
351
+ }
352
+ if (!accounts.eventAuthority.value) {
353
+ accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS;
354
+ }
355
+ if (!accounts.program.value) {
356
+ accounts.program.value =
357
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
358
+ }
359
+
360
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
361
+ return Object.freeze({
362
+ accounts: [
363
+ getAccountMeta('claimer', accounts.claimer),
364
+ getAccountMeta('payer', accounts.payer),
365
+ getAccountMeta('bondingCurve', accounts.bondingCurve),
366
+ getAccountMeta('creatorFeeConfig', accounts.creatorFeeConfig),
367
+ getAccountMeta('nexusGlobalConfig', accounts.nexusGlobalConfig),
368
+ getAccountMeta('baseMint', accounts.baseMint),
369
+ getAccountMeta('quoteMint', accounts.quoteMint),
370
+ getAccountMeta('quoteVault', accounts.quoteVault),
371
+ getAccountMeta('destinationOwner', accounts.destinationOwner),
372
+ getAccountMeta('destination', accounts.destination),
373
+ getAccountMeta('quoteTokenProgram', accounts.quoteTokenProgram),
374
+ getAccountMeta(
375
+ 'associatedTokenProgram',
376
+ accounts.associatedTokenProgram,
377
+ ),
378
+ getAccountMeta('systemProgram', accounts.systemProgram),
379
+ getAccountMeta('eventAuthority', accounts.eventAuthority),
380
+ getAccountMeta('program', accounts.program),
381
+ ],
382
+ data: getClaimCreatorFeesInstructionDataEncoder().encode({}),
383
+ programAddress,
384
+ } as ClaimCreatorFeesInstruction<
385
+ typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
386
+ TAccountClaimer,
387
+ TAccountPayer,
388
+ TAccountBondingCurve,
389
+ TAccountCreatorFeeConfig,
390
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr',
391
+ TAccountBaseMint,
392
+ TAccountQuoteMint,
393
+ TAccountQuoteVault,
394
+ TAccountDestinationOwner,
395
+ TAccountDestination,
396
+ TAccountQuoteTokenProgram,
397
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
398
+ '11111111111111111111111111111111',
399
+ 'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
400
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
401
+ >);
402
+ }
403
+
404
+ export type ClaimCreatorFeesInput<
405
+ TAccountClaimer extends string = string,
406
+ TAccountPayer extends string = string,
407
+ TAccountBondingCurve extends string = string,
408
+ TAccountCreatorFeeConfig extends string = string,
409
+ TAccountBaseMint extends string = string,
410
+ TAccountQuoteMint extends string = string,
411
+ TAccountQuoteVault extends string = string,
412
+ TAccountDestinationOwner extends string = string,
413
+ TAccountDestination extends string = string,
414
+ TAccountQuoteTokenProgram extends string = string,
415
+ > = {
416
+ claimer: TransactionSigner<TAccountClaimer>;
417
+ payer: TransactionSigner<TAccountPayer>;
418
+ bondingCurve: Address<TAccountBondingCurve>;
419
+ creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
420
+ baseMint: Address<TAccountBaseMint>;
421
+ quoteMint: Address<TAccountQuoteMint>;
422
+ quoteVault: Address<TAccountQuoteVault>;
423
+ destinationOwner: Address<TAccountDestinationOwner>;
424
+ destination: Address<TAccountDestination>;
425
+ quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
426
+ };
427
+
428
+ export function getClaimCreatorFeesInstruction<
429
+ TAccountClaimer extends string,
430
+ TAccountPayer extends string,
431
+ TAccountBondingCurve extends string,
432
+ TAccountCreatorFeeConfig extends string,
433
+ TAccountBaseMint extends string,
434
+ TAccountQuoteMint extends string,
435
+ TAccountQuoteVault extends string,
436
+ TAccountDestinationOwner extends string,
437
+ TAccountDestination extends string,
438
+ TAccountQuoteTokenProgram extends string,
439
+ >(
440
+ input: ClaimCreatorFeesInput<
441
+ TAccountClaimer,
442
+ TAccountPayer,
443
+ TAccountBondingCurve,
444
+ TAccountCreatorFeeConfig,
445
+ TAccountBaseMint,
446
+ TAccountQuoteMint,
447
+ TAccountQuoteVault,
448
+ TAccountDestinationOwner,
449
+ TAccountDestination,
450
+ TAccountQuoteTokenProgram
451
+ >,
452
+ ): ClaimCreatorFeesInstruction<
453
+ typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
454
+ TAccountClaimer,
455
+ TAccountPayer,
456
+ TAccountBondingCurve,
457
+ TAccountCreatorFeeConfig,
458
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr',
459
+ TAccountBaseMint,
460
+ TAccountQuoteMint,
461
+ TAccountQuoteVault,
462
+ TAccountDestinationOwner,
463
+ TAccountDestination,
464
+ TAccountQuoteTokenProgram,
465
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
466
+ '11111111111111111111111111111111',
467
+ 'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
468
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
469
+ > {
470
+ // Program address.
471
+ const programAddress = SEND_LAUNCHPAD_PROGRAM_ADDRESS;
472
+
473
+ // Original accounts.
474
+ const originalAccounts = {
475
+ claimer: { value: input.claimer ?? null, isWritable: false },
476
+ payer: { value: input.payer ?? null, isWritable: true },
477
+ bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
478
+ creatorFeeConfig: {
479
+ value: input.creatorFeeConfig ?? null,
480
+ isWritable: false,
481
+ },
482
+ nexusGlobalConfig: { value: null, isWritable: false },
483
+ baseMint: { value: input.baseMint ?? null, isWritable: false },
484
+ quoteMint: { value: input.quoteMint ?? null, isWritable: false },
485
+ quoteVault: { value: input.quoteVault ?? null, isWritable: true },
486
+ destinationOwner: {
487
+ value: input.destinationOwner ?? null,
488
+ isWritable: false,
489
+ },
490
+ destination: { value: input.destination ?? null, isWritable: true },
491
+ quoteTokenProgram: {
492
+ value: input.quoteTokenProgram ?? null,
493
+ isWritable: false,
494
+ },
495
+ associatedTokenProgram: { value: null, isWritable: false },
496
+ systemProgram: { value: null, isWritable: false },
497
+ eventAuthority: { value: null, isWritable: false },
498
+ program: { value: null, isWritable: false },
499
+ };
500
+ const accounts = originalAccounts as Record<
501
+ keyof typeof originalAccounts,
502
+ ResolvedInstructionAccount
503
+ >;
504
+
505
+ // Resolve default values.
506
+ if (!accounts.nexusGlobalConfig.value) {
507
+ accounts.nexusGlobalConfig.value =
508
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr' as Address<'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr'>;
509
+ }
510
+ if (!accounts.associatedTokenProgram.value) {
511
+ accounts.associatedTokenProgram.value =
512
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>;
513
+ }
514
+ if (!accounts.systemProgram.value) {
515
+ accounts.systemProgram.value =
516
+ '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
517
+ }
518
+ if (!accounts.eventAuthority.value) {
519
+ accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS;
520
+ }
521
+ if (!accounts.program.value) {
522
+ accounts.program.value =
523
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
524
+ }
525
+
526
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
527
+ return Object.freeze({
528
+ accounts: [
529
+ getAccountMeta('claimer', accounts.claimer),
530
+ getAccountMeta('payer', accounts.payer),
531
+ getAccountMeta('bondingCurve', accounts.bondingCurve),
532
+ getAccountMeta('creatorFeeConfig', accounts.creatorFeeConfig),
533
+ getAccountMeta('nexusGlobalConfig', accounts.nexusGlobalConfig),
534
+ getAccountMeta('baseMint', accounts.baseMint),
535
+ getAccountMeta('quoteMint', accounts.quoteMint),
536
+ getAccountMeta('quoteVault', accounts.quoteVault),
537
+ getAccountMeta('destinationOwner', accounts.destinationOwner),
538
+ getAccountMeta('destination', accounts.destination),
539
+ getAccountMeta('quoteTokenProgram', accounts.quoteTokenProgram),
540
+ getAccountMeta(
541
+ 'associatedTokenProgram',
542
+ accounts.associatedTokenProgram,
543
+ ),
544
+ getAccountMeta('systemProgram', accounts.systemProgram),
545
+ getAccountMeta('eventAuthority', accounts.eventAuthority),
546
+ getAccountMeta('program', accounts.program),
547
+ ],
548
+ data: getClaimCreatorFeesInstructionDataEncoder().encode({}),
549
+ programAddress,
550
+ } as ClaimCreatorFeesInstruction<
551
+ typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
552
+ TAccountClaimer,
553
+ TAccountPayer,
554
+ TAccountBondingCurve,
555
+ TAccountCreatorFeeConfig,
556
+ '3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr',
557
+ TAccountBaseMint,
558
+ TAccountQuoteMint,
559
+ TAccountQuoteVault,
560
+ TAccountDestinationOwner,
561
+ TAccountDestination,
562
+ TAccountQuoteTokenProgram,
563
+ 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
564
+ '11111111111111111111111111111111',
565
+ 'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
566
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
567
+ >);
568
+ }
569
+
570
+ export type ParsedClaimCreatorFeesInstruction<
571
+ TProgram extends string = typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
572
+ TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
573
+ > = {
574
+ programAddress: Address<TProgram>;
575
+ accounts: {
576
+ claimer: TAccountMetas[0];
577
+ payer: TAccountMetas[1];
578
+ bondingCurve: TAccountMetas[2];
579
+ creatorFeeConfig: TAccountMetas[3];
580
+ nexusGlobalConfig: TAccountMetas[4];
581
+ baseMint: TAccountMetas[5];
582
+ quoteMint: TAccountMetas[6];
583
+ quoteVault: TAccountMetas[7];
584
+ destinationOwner: TAccountMetas[8];
585
+ destination: TAccountMetas[9];
586
+ quoteTokenProgram: TAccountMetas[10];
587
+ associatedTokenProgram: TAccountMetas[11];
588
+ systemProgram: TAccountMetas[12];
589
+ eventAuthority: TAccountMetas[13];
590
+ program: TAccountMetas[14];
591
+ };
592
+ data: ClaimCreatorFeesInstructionData;
593
+ };
594
+
595
+ export function parseClaimCreatorFeesInstruction<
596
+ TProgram extends string,
597
+ TAccountMetas extends readonly AccountMeta[],
598
+ >(
599
+ instruction: Instruction<TProgram> &
600
+ InstructionWithAccounts<TAccountMetas> &
601
+ InstructionWithData<ReadonlyUint8Array>,
602
+ ): ParsedClaimCreatorFeesInstruction<TProgram, TAccountMetas> {
603
+ assertIsInstructionForProgram(instruction, SEND_LAUNCHPAD_PROGRAM_ADDRESS);
604
+ if (!containsBytes(instruction.data, CLAIM_CREATOR_FEES_DISCRIMINATOR, 0)) {
605
+ const error = new Error(
606
+ `parseClaimCreatorFeesInstruction: instruction data does not match the ClaimCreatorFees discriminator`,
607
+ );
608
+ error.name = 'InstructionDiscriminatorMismatchError';
609
+ throw error;
610
+ }
611
+ if (instruction.accounts.length < 15) {
612
+ throw new SolanaError(
613
+ SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
614
+ {
615
+ actualAccountMetas: instruction.accounts.length,
616
+ expectedAccountMetas: 15,
617
+ },
618
+ );
619
+ }
620
+ let accountIndex = 0;
621
+ const getNextAccount = () => {
622
+ const accountMeta = (instruction.accounts as TAccountMetas)[
623
+ accountIndex
624
+ ]!;
625
+ accountIndex += 1;
626
+ return accountMeta;
627
+ };
628
+ return {
629
+ programAddress: instruction.programAddress,
630
+ accounts: {
631
+ claimer: getNextAccount(),
632
+ payer: getNextAccount(),
633
+ bondingCurve: getNextAccount(),
634
+ creatorFeeConfig: getNextAccount(),
635
+ nexusGlobalConfig: getNextAccount(),
636
+ baseMint: getNextAccount(),
637
+ quoteMint: getNextAccount(),
638
+ quoteVault: getNextAccount(),
639
+ destinationOwner: getNextAccount(),
640
+ destination: getNextAccount(),
641
+ quoteTokenProgram: getNextAccount(),
642
+ associatedTokenProgram: getNextAccount(),
643
+ systemProgram: getNextAccount(),
644
+ eventAuthority: getNextAccount(),
645
+ program: getNextAccount(),
646
+ },
647
+ data: getClaimCreatorFeesInstructionDataDecoder().decode(
648
+ instruction.data,
649
+ ),
650
+ };
651
+ }