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