@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,120 @@
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
+ containsBytes,
11
+ fixEncoderSize,
12
+ getAddressDecoder,
13
+ getBooleanDecoder,
14
+ getBytesEncoder,
15
+ getI64Decoder,
16
+ getStructDecoder,
17
+ getU64Decoder,
18
+ type Address,
19
+ type FixedSizeDecoder,
20
+ type ReadonlyUint8Array,
21
+ } from '@solana/kit';
22
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
23
+ import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
24
+
25
+ export const COMPLETE_EVENT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
26
+ 95, 114, 97, 156, 212, 46, 152, 8,
27
+ ]);
28
+
29
+ export function getCompleteEventDiscriminatorBytes(): ReadonlyUint8Array {
30
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
31
+ COMPLETE_EVENT_DISCRIMINATOR,
32
+ );
33
+ }
34
+
35
+ export type CompleteEvent = {
36
+ bondingCurve: Address;
37
+ baseMint: Address;
38
+ quoteMint: Address;
39
+ coinCreator: Address;
40
+ creatorFeeConfig: Address;
41
+ platformConfig: Address;
42
+ curvePartner: Address;
43
+ isPartner: boolean;
44
+ realQuoteReserves: bigint;
45
+ timestamp: bigint;
46
+ };
47
+
48
+ let getCompleteEventDecoderCache: FixedSizeDecoder<CompleteEvent> | undefined;
49
+
50
+ export function getCompleteEventDecoder(): FixedSizeDecoder<CompleteEvent> {
51
+ return (getCompleteEventDecoderCache ??= getStructDecoder([
52
+ ['bondingCurve', getAddressDecoder()],
53
+ ['baseMint', getAddressDecoder()],
54
+ ['quoteMint', getAddressDecoder()],
55
+ ['coinCreator', getAddressDecoder()],
56
+ ['creatorFeeConfig', getAddressDecoder()],
57
+ ['platformConfig', getAddressDecoder()],
58
+ ['curvePartner', getAddressDecoder()],
59
+ ['isPartner', getBooleanDecoder()],
60
+ ['realQuoteReserves', getU64Decoder()],
61
+ ['timestamp', getI64Decoder()],
62
+ ]));
63
+ }
64
+
65
+ /**
66
+ * Checks whether the event data matches the framing and discriminator bytes of a
67
+ * {@link CompleteEvent}, without decoding. Never throws.
68
+ *
69
+ * Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
70
+ * Raw bytes carry no emitter and SKIP that check.
71
+ *
72
+ * @see parseCompleteEvent to decode the matching data
73
+ */
74
+ export function isCompleteEvent(
75
+ event:
76
+ | { data: ReadonlyUint8Array; programAddress: Address }
77
+ | ReadonlyUint8Array,
78
+ ): boolean {
79
+ if (
80
+ 'data' in event &&
81
+ event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
82
+ )
83
+ return false;
84
+ const data = 'data' in event ? event.data : event;
85
+ return (
86
+ containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
87
+ containsBytes(data, COMPLETE_EVENT_DISCRIMINATOR, 8)
88
+ );
89
+ }
90
+
91
+ /**
92
+ * Parses raw event data as a {@link CompleteEvent}. Returns `null` on framing or discriminator
93
+ * mismatch; throws if the event matches but its body fails to decode.
94
+ *
95
+ * Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
96
+ * Raw bytes carry no emitter and SKIP that check.
97
+ *
98
+ * @see isCompleteEvent to check without decoding
99
+ * @see identifySendLaunchpadEvent to identify any program event
100
+ * @see parseSendLaunchpadEvent
101
+ */
102
+ export function parseCompleteEvent(
103
+ event:
104
+ | { data: ReadonlyUint8Array; programAddress: Address }
105
+ | ReadonlyUint8Array,
106
+ ): CompleteEvent | null {
107
+ const checkedEvent =
108
+ 'data' in event
109
+ ? { data: event.data, programAddress: event.programAddress }
110
+ : event;
111
+ if (!isCompleteEvent(checkedEvent)) {
112
+ return null;
113
+ }
114
+ const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
115
+ return getCompleteEventDecoder().decode(
116
+ data,
117
+ ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
118
+ COMPLETE_EVENT_DISCRIMINATOR.length,
119
+ );
120
+ }
@@ -0,0 +1,122 @@
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
+ containsBytes,
11
+ fixEncoderSize,
12
+ getAddressDecoder,
13
+ getBytesEncoder,
14
+ getI64Decoder,
15
+ getStructDecoder,
16
+ getU64Decoder,
17
+ type Address,
18
+ type FixedSizeDecoder,
19
+ type ReadonlyUint8Array,
20
+ } from '@solana/kit';
21
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
22
+ import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
23
+
24
+ export const CREATOR_CLAIM_EVENT_DISCRIMINATOR: ReadonlyUint8Array =
25
+ new Uint8Array([232, 58, 157, 141, 123, 5, 142, 9]);
26
+
27
+ export function getCreatorClaimEventDiscriminatorBytes(): ReadonlyUint8Array {
28
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
29
+ CREATOR_CLAIM_EVENT_DISCRIMINATOR,
30
+ );
31
+ }
32
+
33
+ export type CreatorClaimEvent = {
34
+ bondingCurve: Address;
35
+ baseMint: Address;
36
+ quoteMint: Address;
37
+ platformConfig: Address;
38
+ coinCreator: Address;
39
+ creatorFeeConfig: Address;
40
+ claimer: Address;
41
+ destinationOwner: Address;
42
+ amount: bigint;
43
+ quoteTransferFee: bigint;
44
+ timestamp: bigint;
45
+ };
46
+
47
+ let getCreatorClaimEventDecoderCache:
48
+ | FixedSizeDecoder<CreatorClaimEvent>
49
+ | undefined;
50
+
51
+ export function getCreatorClaimEventDecoder(): FixedSizeDecoder<CreatorClaimEvent> {
52
+ return (getCreatorClaimEventDecoderCache ??= getStructDecoder([
53
+ ['bondingCurve', getAddressDecoder()],
54
+ ['baseMint', getAddressDecoder()],
55
+ ['quoteMint', getAddressDecoder()],
56
+ ['platformConfig', getAddressDecoder()],
57
+ ['coinCreator', getAddressDecoder()],
58
+ ['creatorFeeConfig', getAddressDecoder()],
59
+ ['claimer', getAddressDecoder()],
60
+ ['destinationOwner', getAddressDecoder()],
61
+ ['amount', getU64Decoder()],
62
+ ['quoteTransferFee', getU64Decoder()],
63
+ ['timestamp', getI64Decoder()],
64
+ ]));
65
+ }
66
+
67
+ /**
68
+ * Checks whether the event data matches the framing and discriminator bytes of a
69
+ * {@link CreatorClaimEvent}, without decoding. Never throws.
70
+ *
71
+ * Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
72
+ * Raw bytes carry no emitter and SKIP that check.
73
+ *
74
+ * @see parseCreatorClaimEvent to decode the matching data
75
+ */
76
+ export function isCreatorClaimEvent(
77
+ event:
78
+ | { data: ReadonlyUint8Array; programAddress: Address }
79
+ | ReadonlyUint8Array,
80
+ ): boolean {
81
+ if (
82
+ 'data' in event &&
83
+ event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
84
+ )
85
+ return false;
86
+ const data = 'data' in event ? event.data : event;
87
+ return (
88
+ containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
89
+ containsBytes(data, CREATOR_CLAIM_EVENT_DISCRIMINATOR, 8)
90
+ );
91
+ }
92
+
93
+ /**
94
+ * Parses raw event data as a {@link CreatorClaimEvent}. Returns `null` on framing or discriminator
95
+ * mismatch; throws if the event matches but its body fails to decode.
96
+ *
97
+ * Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
98
+ * Raw bytes carry no emitter and SKIP that check.
99
+ *
100
+ * @see isCreatorClaimEvent to check without decoding
101
+ * @see identifySendLaunchpadEvent to identify any program event
102
+ * @see parseSendLaunchpadEvent
103
+ */
104
+ export function parseCreatorClaimEvent(
105
+ event:
106
+ | { data: ReadonlyUint8Array; programAddress: Address }
107
+ | ReadonlyUint8Array,
108
+ ): CreatorClaimEvent | null {
109
+ const checkedEvent =
110
+ 'data' in event
111
+ ? { data: event.data, programAddress: event.programAddress }
112
+ : event;
113
+ if (!isCreatorClaimEvent(checkedEvent)) {
114
+ return null;
115
+ }
116
+ const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
117
+ return getCreatorClaimEventDecoder().decode(
118
+ data,
119
+ ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
120
+ CREATOR_CLAIM_EVENT_DISCRIMINATOR.length,
121
+ );
122
+ }
@@ -0,0 +1,17 @@
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
+ export * from './anchorEventCpiDiscriminator.framing.js';
10
+ export * from './completeEvent.js';
11
+ export * from './creatorClaimEvent.js';
12
+ export * from './migrateEvent.js';
13
+ export * from './protocolClaimEvent.js';
14
+ export * from './recycleEvent.js';
15
+ export * from './sendLaunchpad.events.js';
16
+ export * from './tokenCreateEvent.js';
17
+ export * from './tradeEvent.js';
@@ -0,0 +1,121 @@
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
+ containsBytes,
11
+ fixEncoderSize,
12
+ getAddressDecoder,
13
+ getBytesEncoder,
14
+ getI64Decoder,
15
+ getStructDecoder,
16
+ getU64Decoder,
17
+ type Address,
18
+ type FixedSizeDecoder,
19
+ type ReadonlyUint8Array,
20
+ } from '@solana/kit';
21
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
22
+ import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
23
+
24
+ export const MIGRATE_EVENT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
25
+ 216, 175, 231, 95, 45, 98, 108, 21,
26
+ ]);
27
+
28
+ export function getMigrateEventDiscriminatorBytes(): ReadonlyUint8Array {
29
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
30
+ MIGRATE_EVENT_DISCRIMINATOR,
31
+ );
32
+ }
33
+
34
+ export type MigrateEvent = {
35
+ bondingCurve: Address;
36
+ baseMint: Address;
37
+ quoteMint: Address;
38
+ pool: Address;
39
+ coinCreator: Address;
40
+ creatorFeeConfig: Address;
41
+ platformConfig: Address;
42
+ baseAmount: bigint;
43
+ quoteAmount: bigint;
44
+ realQuoteReserves: bigint;
45
+ timestamp: bigint;
46
+ };
47
+
48
+ let getMigrateEventDecoderCache: FixedSizeDecoder<MigrateEvent> | undefined;
49
+
50
+ export function getMigrateEventDecoder(): FixedSizeDecoder<MigrateEvent> {
51
+ return (getMigrateEventDecoderCache ??= getStructDecoder([
52
+ ['bondingCurve', getAddressDecoder()],
53
+ ['baseMint', getAddressDecoder()],
54
+ ['quoteMint', getAddressDecoder()],
55
+ ['pool', getAddressDecoder()],
56
+ ['coinCreator', getAddressDecoder()],
57
+ ['creatorFeeConfig', getAddressDecoder()],
58
+ ['platformConfig', getAddressDecoder()],
59
+ ['baseAmount', getU64Decoder()],
60
+ ['quoteAmount', getU64Decoder()],
61
+ ['realQuoteReserves', getU64Decoder()],
62
+ ['timestamp', getI64Decoder()],
63
+ ]));
64
+ }
65
+
66
+ /**
67
+ * Checks whether the event data matches the framing and discriminator bytes of a
68
+ * {@link MigrateEvent}, without decoding. Never throws.
69
+ *
70
+ * Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
71
+ * Raw bytes carry no emitter and SKIP that check.
72
+ *
73
+ * @see parseMigrateEvent to decode the matching data
74
+ */
75
+ export function isMigrateEvent(
76
+ event:
77
+ | { data: ReadonlyUint8Array; programAddress: Address }
78
+ | ReadonlyUint8Array,
79
+ ): boolean {
80
+ if (
81
+ 'data' in event &&
82
+ event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
83
+ )
84
+ return false;
85
+ const data = 'data' in event ? event.data : event;
86
+ return (
87
+ containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
88
+ containsBytes(data, MIGRATE_EVENT_DISCRIMINATOR, 8)
89
+ );
90
+ }
91
+
92
+ /**
93
+ * Parses raw event data as a {@link MigrateEvent}. Returns `null` on framing or discriminator
94
+ * mismatch; throws if the event matches but its body fails to decode.
95
+ *
96
+ * Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
97
+ * Raw bytes carry no emitter and SKIP that check.
98
+ *
99
+ * @see isMigrateEvent to check without decoding
100
+ * @see identifySendLaunchpadEvent to identify any program event
101
+ * @see parseSendLaunchpadEvent
102
+ */
103
+ export function parseMigrateEvent(
104
+ event:
105
+ | { data: ReadonlyUint8Array; programAddress: Address }
106
+ | ReadonlyUint8Array,
107
+ ): MigrateEvent | null {
108
+ const checkedEvent =
109
+ 'data' in event
110
+ ? { data: event.data, programAddress: event.programAddress }
111
+ : event;
112
+ if (!isMigrateEvent(checkedEvent)) {
113
+ return null;
114
+ }
115
+ const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
116
+ return getMigrateEventDecoder().decode(
117
+ data,
118
+ ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
119
+ MIGRATE_EVENT_DISCRIMINATOR.length,
120
+ );
121
+ }
@@ -0,0 +1,114 @@
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
+ containsBytes,
11
+ fixEncoderSize,
12
+ getAddressDecoder,
13
+ getBytesEncoder,
14
+ getI64Decoder,
15
+ getStructDecoder,
16
+ getU64Decoder,
17
+ type Address,
18
+ type FixedSizeDecoder,
19
+ type ReadonlyUint8Array,
20
+ } from '@solana/kit';
21
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
22
+ import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
23
+
24
+ export const PROTOCOL_CLAIM_EVENT_DISCRIMINATOR: ReadonlyUint8Array =
25
+ new Uint8Array([149, 70, 119, 5, 21, 57, 123, 244]);
26
+
27
+ export function getProtocolClaimEventDiscriminatorBytes(): ReadonlyUint8Array {
28
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
29
+ PROTOCOL_CLAIM_EVENT_DISCRIMINATOR,
30
+ );
31
+ }
32
+
33
+ export type ProtocolClaimEvent = {
34
+ bondingCurve: Address;
35
+ baseMint: Address;
36
+ quoteMint: Address;
37
+ platformConfig: Address;
38
+ amount: bigint;
39
+ quoteTransferFee: bigint;
40
+ timestamp: bigint;
41
+ };
42
+
43
+ let getProtocolClaimEventDecoderCache:
44
+ | FixedSizeDecoder<ProtocolClaimEvent>
45
+ | undefined;
46
+
47
+ export function getProtocolClaimEventDecoder(): FixedSizeDecoder<ProtocolClaimEvent> {
48
+ return (getProtocolClaimEventDecoderCache ??= getStructDecoder([
49
+ ['bondingCurve', getAddressDecoder()],
50
+ ['baseMint', getAddressDecoder()],
51
+ ['quoteMint', getAddressDecoder()],
52
+ ['platformConfig', getAddressDecoder()],
53
+ ['amount', getU64Decoder()],
54
+ ['quoteTransferFee', getU64Decoder()],
55
+ ['timestamp', getI64Decoder()],
56
+ ]));
57
+ }
58
+
59
+ /**
60
+ * Checks whether the event data matches the framing and discriminator bytes of a
61
+ * {@link ProtocolClaimEvent}, without decoding. Never throws.
62
+ *
63
+ * Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
64
+ * Raw bytes carry no emitter and SKIP that check.
65
+ *
66
+ * @see parseProtocolClaimEvent to decode the matching data
67
+ */
68
+ export function isProtocolClaimEvent(
69
+ event:
70
+ | { data: ReadonlyUint8Array; programAddress: Address }
71
+ | ReadonlyUint8Array,
72
+ ): boolean {
73
+ if (
74
+ 'data' in event &&
75
+ event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
76
+ )
77
+ return false;
78
+ const data = 'data' in event ? event.data : event;
79
+ return (
80
+ containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
81
+ containsBytes(data, PROTOCOL_CLAIM_EVENT_DISCRIMINATOR, 8)
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Parses raw event data as a {@link ProtocolClaimEvent}. Returns `null` on framing or discriminator
87
+ * mismatch; throws if the event matches but its body fails to decode.
88
+ *
89
+ * Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
90
+ * Raw bytes carry no emitter and SKIP that check.
91
+ *
92
+ * @see isProtocolClaimEvent to check without decoding
93
+ * @see identifySendLaunchpadEvent to identify any program event
94
+ * @see parseSendLaunchpadEvent
95
+ */
96
+ export function parseProtocolClaimEvent(
97
+ event:
98
+ | { data: ReadonlyUint8Array; programAddress: Address }
99
+ | ReadonlyUint8Array,
100
+ ): ProtocolClaimEvent | null {
101
+ const checkedEvent =
102
+ 'data' in event
103
+ ? { data: event.data, programAddress: event.programAddress }
104
+ : event;
105
+ if (!isProtocolClaimEvent(checkedEvent)) {
106
+ return null;
107
+ }
108
+ const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
109
+ return getProtocolClaimEventDecoder().decode(
110
+ data,
111
+ ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
112
+ PROTOCOL_CLAIM_EVENT_DISCRIMINATOR.length,
113
+ );
114
+ }
@@ -0,0 +1,113 @@
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
+ containsBytes,
11
+ fixEncoderSize,
12
+ getAddressDecoder,
13
+ getBytesEncoder,
14
+ getI64Decoder,
15
+ getStructDecoder,
16
+ getU64Decoder,
17
+ type Address,
18
+ type FixedSizeDecoder,
19
+ type ReadonlyUint8Array,
20
+ } from '@solana/kit';
21
+ import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
22
+ import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
23
+
24
+ export const RECYCLE_EVENT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
25
+ 63, 115, 223, 82, 233, 208, 57, 35,
26
+ ]);
27
+
28
+ export function getRecycleEventDiscriminatorBytes(): ReadonlyUint8Array {
29
+ return fixEncoderSize(getBytesEncoder(), 8).encode(
30
+ RECYCLE_EVENT_DISCRIMINATOR,
31
+ );
32
+ }
33
+
34
+ export type RecycleEvent = {
35
+ bondingCurve: Address;
36
+ baseMint: Address;
37
+ quoteMint: Address;
38
+ platformConfig: Address;
39
+ quoteRecycled: bigint;
40
+ rentRecycled: bigint;
41
+ timestamp: bigint;
42
+ };
43
+
44
+ let getRecycleEventDecoderCache: FixedSizeDecoder<RecycleEvent> | undefined;
45
+
46
+ export function getRecycleEventDecoder(): FixedSizeDecoder<RecycleEvent> {
47
+ return (getRecycleEventDecoderCache ??= getStructDecoder([
48
+ ['bondingCurve', getAddressDecoder()],
49
+ ['baseMint', getAddressDecoder()],
50
+ ['quoteMint', getAddressDecoder()],
51
+ ['platformConfig', getAddressDecoder()],
52
+ ['quoteRecycled', getU64Decoder()],
53
+ ['rentRecycled', getU64Decoder()],
54
+ ['timestamp', getI64Decoder()],
55
+ ]));
56
+ }
57
+
58
+ /**
59
+ * Checks whether the event data matches the framing and discriminator bytes of a
60
+ * {@link RecycleEvent}, without decoding. Never throws.
61
+ *
62
+ * Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
63
+ * Raw bytes carry no emitter and SKIP that check.
64
+ *
65
+ * @see parseRecycleEvent to decode the matching data
66
+ */
67
+ export function isRecycleEvent(
68
+ event:
69
+ | { data: ReadonlyUint8Array; programAddress: Address }
70
+ | ReadonlyUint8Array,
71
+ ): boolean {
72
+ if (
73
+ 'data' in event &&
74
+ event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
75
+ )
76
+ return false;
77
+ const data = 'data' in event ? event.data : event;
78
+ return (
79
+ containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
80
+ containsBytes(data, RECYCLE_EVENT_DISCRIMINATOR, 8)
81
+ );
82
+ }
83
+
84
+ /**
85
+ * Parses raw event data as a {@link RecycleEvent}. Returns `null` on framing or discriminator
86
+ * mismatch; throws if the event matches but its body fails to decode.
87
+ *
88
+ * Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
89
+ * Raw bytes carry no emitter and SKIP that check.
90
+ *
91
+ * @see isRecycleEvent to check without decoding
92
+ * @see identifySendLaunchpadEvent to identify any program event
93
+ * @see parseSendLaunchpadEvent
94
+ */
95
+ export function parseRecycleEvent(
96
+ event:
97
+ | { data: ReadonlyUint8Array; programAddress: Address }
98
+ | ReadonlyUint8Array,
99
+ ): RecycleEvent | null {
100
+ const checkedEvent =
101
+ 'data' in event
102
+ ? { data: event.data, programAddress: event.programAddress }
103
+ : event;
104
+ if (!isRecycleEvent(checkedEvent)) {
105
+ return null;
106
+ }
107
+ const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
108
+ return getRecycleEventDecoder().decode(
109
+ data,
110
+ ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
111
+ RECYCLE_EVENT_DISCRIMINATOR.length,
112
+ );
113
+ }