@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.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/index.cjs +12808 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +4406 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +4405 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +12749 -0
- package/dist/index.mjs.map +1 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/package.json +72 -0
- package/src/constants.ts +38 -0
- package/src/dex/generated/accounts/globalConfig.ts +189 -0
- package/src/dex/generated/accounts/index.ts +12 -0
- package/src/dex/generated/accounts/pool.ts +244 -0
- package/src/dex/generated/accounts/rewardAccrual.ts +191 -0
- package/src/dex/generated/accounts/sendDex.accounts.ts +47 -0
- package/src/dex/generated/errors/index.ts +9 -0
- package/src/dex/generated/errors/sendDex.ts +161 -0
- package/src/dex/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/dex/generated/events/creatorClaimEvent.ts +119 -0
- package/src/dex/generated/events/depositQuoteEvent.ts +115 -0
- package/src/dex/generated/events/index.ts +16 -0
- package/src/dex/generated/events/poolCreateEvent.ts +128 -0
- package/src/dex/generated/events/protocolClaimEvent.ts +111 -0
- package/src/dex/generated/events/sendDex.events.ts +184 -0
- package/src/dex/generated/events/tokenCreateEvent.ts +143 -0
- package/src/dex/generated/events/tradeEvent.ts +143 -0
- package/src/dex/generated/index.ts +16 -0
- package/src/dex/generated/instructions/buyExactIn.ts +815 -0
- package/src/dex/generated/instructions/buyExactOut.ts +815 -0
- package/src/dex/generated/instructions/claimCreatorFees.ts +648 -0
- package/src/dex/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/dex/generated/instructions/index.ts +15 -0
- package/src/dex/generated/instructions/sellExactIn.ts +815 -0
- package/src/dex/generated/instructions/sellExactOut.ts +815 -0
- package/src/dex/generated/instructions/sendDex.instructions.ts +173 -0
- package/src/dex/generated/pdas/eventAuthority.ts +20 -0
- package/src/dex/generated/pdas/globalConfig.ts +20 -0
- package/src/dex/generated/pdas/index.ts +14 -0
- package/src/dex/generated/pdas/lpMint.ts +36 -0
- package/src/dex/generated/pdas/pool.ts +34 -0
- package/src/dex/generated/pdas/rewardAccrual.ts +37 -0
- package/src/dex/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/dex/generated/plugins/index.ts +9 -0
- package/src/dex/generated/plugins/sendDex.ts +282 -0
- package/src/dex/generated/programs/index.ts +9 -0
- package/src/dex/generated/programs/sendDex.ts +12 -0
- package/src/dex/generated/types/index.ts +10 -0
- package/src/dex/generated/types/poolStatus.ts +38 -0
- package/src/dex/generated/types/tradeDirection.ts +38 -0
- package/src/dex/index.ts +8 -0
- package/src/dex/trade.ts +215 -0
- package/src/index.ts +8 -0
- package/src/launchpad/create.ts +116 -0
- package/src/launchpad/generated/accounts/bondingCurve.ts +273 -0
- package/src/launchpad/generated/accounts/globalConfig.ts +211 -0
- package/src/launchpad/generated/accounts/index.ts +12 -0
- package/src/launchpad/generated/accounts/rewardAccrual.ts +191 -0
- package/src/launchpad/generated/accounts/sendLaunchpad.accounts.ts +50 -0
- package/src/launchpad/generated/errors/index.ts +9 -0
- package/src/launchpad/generated/errors/sendLaunchpad.ts +175 -0
- package/src/launchpad/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/launchpad/generated/events/completeEvent.ts +120 -0
- package/src/launchpad/generated/events/creatorClaimEvent.ts +122 -0
- package/src/launchpad/generated/events/index.ts +17 -0
- package/src/launchpad/generated/events/migrateEvent.ts +121 -0
- package/src/launchpad/generated/events/protocolClaimEvent.ts +114 -0
- package/src/launchpad/generated/events/recycleEvent.ts +113 -0
- package/src/launchpad/generated/events/sendLaunchpad.events.ts +207 -0
- package/src/launchpad/generated/events/tokenCreateEvent.ts +156 -0
- package/src/launchpad/generated/events/tradeEvent.ts +148 -0
- package/src/launchpad/generated/index.ts +16 -0
- package/src/launchpad/generated/instructions/buyExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/buyExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/claimCreatorFees.ts +651 -0
- package/src/launchpad/generated/instructions/claimProtocolFees.ts +640 -0
- package/src/launchpad/generated/instructions/createToken.ts +1150 -0
- package/src/launchpad/generated/instructions/index.ts +17 -0
- package/src/launchpad/generated/instructions/migrate.ts +840 -0
- package/src/launchpad/generated/instructions/sellExactIn.ts +818 -0
- package/src/launchpad/generated/instructions/sellExactOut.ts +818 -0
- package/src/launchpad/generated/instructions/sendLaunchpad.instructions.ts +210 -0
- package/src/launchpad/generated/pdas/bondingCurve.ts +39 -0
- package/src/launchpad/generated/pdas/eventAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/globalConfig.ts +20 -0
- package/src/launchpad/generated/pdas/index.ts +14 -0
- package/src/launchpad/generated/pdas/migrationAuthority.ts +20 -0
- package/src/launchpad/generated/pdas/rewardAccrual.ts +37 -0
- package/src/launchpad/generated/pdas/wsolRewardAccrual.ts +20 -0
- package/src/launchpad/generated/plugins/index.ts +9 -0
- package/src/launchpad/generated/plugins/sendLaunchpad.ts +315 -0
- package/src/launchpad/generated/programs/index.ts +9 -0
- package/src/launchpad/generated/programs/sendLaunchpad.ts +12 -0
- package/src/launchpad/generated/types/bondingCurveStatus.ts +43 -0
- package/src/launchpad/generated/types/index.ts +10 -0
- package/src/launchpad/generated/types/tradeDirection.ts +38 -0
- package/src/launchpad/index.ts +10 -0
- package/src/launchpad/migrate.ts +54 -0
- package/src/launchpad/trade.ts +247 -0
- package/src/math/amm.ts +511 -0
- package/src/math/fee-decay.ts +49 -0
- package/src/math/fees.ts +75 -0
- package/src/math/index.ts +3 -0
- package/src/math/internal.ts +16 -0
- package/src/nexus/fee-helpers.ts +49 -0
- package/src/nexus/generated/accounts/altRegistry.ts +177 -0
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +200 -0
- package/src/nexus/generated/accounts/feePreset.ts +196 -0
- package/src/nexus/generated/accounts/globalConfig.ts +188 -0
- package/src/nexus/generated/accounts/index.ts +19 -0
- package/src/nexus/generated/accounts/partnerConfig.ts +209 -0
- package/src/nexus/generated/accounts/partnerMetadata.ts +216 -0
- package/src/nexus/generated/accounts/rewardState.ts +209 -0
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +85 -0
- package/src/nexus/generated/accounts/stakingConfig.ts +197 -0
- package/src/nexus/generated/accounts/userRewardDebt.ts +221 -0
- package/src/nexus/generated/accounts/userStakePosition.ts +218 -0
- package/src/nexus/generated/constants/index.ts +9 -0
- package/src/nexus/generated/constants/sendNexus.ts +13 -0
- package/src/nexus/generated/errors/index.ts +9 -0
- package/src/nexus/generated/errors/sendNexus.ts +229 -0
- package/src/nexus/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
- package/src/nexus/generated/events/claimEvent.ts +106 -0
- package/src/nexus/generated/events/index.ts +13 -0
- package/src/nexus/generated/events/sendNexus.events.ts +121 -0
- package/src/nexus/generated/events/stakeEvent.ts +106 -0
- package/src/nexus/generated/events/unstakeEvent.ts +106 -0
- package/src/nexus/generated/index.ts +17 -0
- package/src/nexus/generated/instructions/claim.ts +740 -0
- package/src/nexus/generated/instructions/createUserRewardDebt.ts +498 -0
- package/src/nexus/generated/instructions/index.ts +14 -0
- package/src/nexus/generated/instructions/sendNexus.instructions.ts +146 -0
- package/src/nexus/generated/instructions/settle.ts +517 -0
- package/src/nexus/generated/instructions/stake.ts +615 -0
- package/src/nexus/generated/instructions/unstake.ts +593 -0
- package/src/nexus/generated/pdas/altRegistry.ts +20 -0
- package/src/nexus/generated/pdas/creatorFeeConfig.ts +39 -0
- package/src/nexus/generated/pdas/defaultFeePreset.ts +37 -0
- package/src/nexus/generated/pdas/defaultPartner.ts +40 -0
- package/src/nexus/generated/pdas/defaultPartnerMetadata.ts +42 -0
- package/src/nexus/generated/pdas/eventAuthority.ts +20 -0
- package/src/nexus/generated/pdas/feePreset.ts +39 -0
- package/src/nexus/generated/pdas/globalConfig.ts +20 -0
- package/src/nexus/generated/pdas/index.ts +22 -0
- package/src/nexus/generated/pdas/partnerConfig.ts +36 -0
- package/src/nexus/generated/pdas/partnerMetadata.ts +38 -0
- package/src/nexus/generated/pdas/rewardState.ts +36 -0
- package/src/nexus/generated/pdas/stakingConfig.ts +20 -0
- package/src/nexus/generated/pdas/userRewardDebt.ts +41 -0
- package/src/nexus/generated/pdas/userStakePosition.ts +39 -0
- package/src/nexus/generated/plugins/index.ts +9 -0
- package/src/nexus/generated/plugins/sendNexus.ts +494 -0
- package/src/nexus/generated/programs/index.ts +9 -0
- package/src/nexus/generated/programs/sendNexus.ts +12 -0
- package/src/nexus/generated/types/authPlatformEntry.ts +52 -0
- package/src/nexus/generated/types/callerType.ts +38 -0
- package/src/nexus/generated/types/dexFees.ts +64 -0
- package/src/nexus/generated/types/feeConfig.ts +73 -0
- package/src/nexus/generated/types/index.ts +13 -0
- package/src/nexus/generated/types/launchpadFees.ts +63 -0
- package/src/nexus/index.ts +9 -0
- package/src/nexus/staking.ts +581 -0
- package/src/platform.ts +19 -0
- package/src/transfer-fee.ts +216 -0
- package/src/utils/chunk.ts +21 -0
- package/src/utils/creator-hash.ts +57 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/mint-info.ts +102 -0
- package/src/utils/partner.ts +5 -0
- package/src/utils/pda.ts +24 -0
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
type Address,
|
|
12
|
+
type ReadonlyUint8Array,
|
|
13
|
+
} from '@solana/kit';
|
|
14
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
15
|
+
import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
|
|
16
|
+
import {
|
|
17
|
+
COMPLETE_EVENT_DISCRIMINATOR,
|
|
18
|
+
getCompleteEventDecoder,
|
|
19
|
+
type CompleteEvent,
|
|
20
|
+
} from './completeEvent.js';
|
|
21
|
+
import {
|
|
22
|
+
CREATOR_CLAIM_EVENT_DISCRIMINATOR,
|
|
23
|
+
getCreatorClaimEventDecoder,
|
|
24
|
+
type CreatorClaimEvent,
|
|
25
|
+
} from './creatorClaimEvent.js';
|
|
26
|
+
import {
|
|
27
|
+
getMigrateEventDecoder,
|
|
28
|
+
MIGRATE_EVENT_DISCRIMINATOR,
|
|
29
|
+
type MigrateEvent,
|
|
30
|
+
} from './migrateEvent.js';
|
|
31
|
+
import {
|
|
32
|
+
getProtocolClaimEventDecoder,
|
|
33
|
+
PROTOCOL_CLAIM_EVENT_DISCRIMINATOR,
|
|
34
|
+
type ProtocolClaimEvent,
|
|
35
|
+
} from './protocolClaimEvent.js';
|
|
36
|
+
import {
|
|
37
|
+
getRecycleEventDecoder,
|
|
38
|
+
RECYCLE_EVENT_DISCRIMINATOR,
|
|
39
|
+
type RecycleEvent,
|
|
40
|
+
} from './recycleEvent.js';
|
|
41
|
+
import {
|
|
42
|
+
getTokenCreateEventDecoder,
|
|
43
|
+
TOKEN_CREATE_EVENT_DISCRIMINATOR,
|
|
44
|
+
type TokenCreateEvent,
|
|
45
|
+
} from './tokenCreateEvent.js';
|
|
46
|
+
import {
|
|
47
|
+
getTradeEventDecoder,
|
|
48
|
+
TRADE_EVENT_DISCRIMINATOR,
|
|
49
|
+
type TradeEvent,
|
|
50
|
+
} from './tradeEvent.js';
|
|
51
|
+
|
|
52
|
+
/** Event kinds of the sendLaunchpad program. */
|
|
53
|
+
export type SendLaunchpadEventType =
|
|
54
|
+
| 'completeEvent'
|
|
55
|
+
| 'creatorClaimEvent'
|
|
56
|
+
| 'migrateEvent'
|
|
57
|
+
| 'protocolClaimEvent'
|
|
58
|
+
| 'recycleEvent'
|
|
59
|
+
| 'tokenCreateEvent'
|
|
60
|
+
| 'tradeEvent';
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Identifies sendLaunchpad event data by its discriminators, without decoding.
|
|
64
|
+
* Returns `null` when the event was emitted by another program or no known event matches.
|
|
65
|
+
* Never throws.
|
|
66
|
+
*
|
|
67
|
+
* Raw bytes carry no emitter and SKIP the program check.
|
|
68
|
+
*/
|
|
69
|
+
export function identifySendLaunchpadEvent(
|
|
70
|
+
event:
|
|
71
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
72
|
+
| ReadonlyUint8Array,
|
|
73
|
+
): SendLaunchpadEventType | null {
|
|
74
|
+
if (
|
|
75
|
+
'data' in event &&
|
|
76
|
+
event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
|
|
77
|
+
)
|
|
78
|
+
return null;
|
|
79
|
+
const data = 'data' in event ? event.data : event;
|
|
80
|
+
if (containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0)) {
|
|
81
|
+
if (containsBytes(data, COMPLETE_EVENT_DISCRIMINATOR, 8)) {
|
|
82
|
+
return 'completeEvent';
|
|
83
|
+
}
|
|
84
|
+
if (containsBytes(data, CREATOR_CLAIM_EVENT_DISCRIMINATOR, 8)) {
|
|
85
|
+
return 'creatorClaimEvent';
|
|
86
|
+
}
|
|
87
|
+
if (containsBytes(data, MIGRATE_EVENT_DISCRIMINATOR, 8)) {
|
|
88
|
+
return 'migrateEvent';
|
|
89
|
+
}
|
|
90
|
+
if (containsBytes(data, PROTOCOL_CLAIM_EVENT_DISCRIMINATOR, 8)) {
|
|
91
|
+
return 'protocolClaimEvent';
|
|
92
|
+
}
|
|
93
|
+
if (containsBytes(data, RECYCLE_EVENT_DISCRIMINATOR, 8)) {
|
|
94
|
+
return 'recycleEvent';
|
|
95
|
+
}
|
|
96
|
+
if (containsBytes(data, TOKEN_CREATE_EVENT_DISCRIMINATOR, 8)) {
|
|
97
|
+
return 'tokenCreateEvent';
|
|
98
|
+
}
|
|
99
|
+
if (containsBytes(data, TRADE_EVENT_DISCRIMINATOR, 8)) {
|
|
100
|
+
return 'tradeEvent';
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Parsed sendLaunchpad event: the event kind tag plus its decoded payload. */
|
|
107
|
+
export type ParsedSendLaunchpadEvent =
|
|
108
|
+
| { eventType: 'completeEvent'; data: CompleteEvent }
|
|
109
|
+
| { eventType: 'creatorClaimEvent'; data: CreatorClaimEvent }
|
|
110
|
+
| { eventType: 'migrateEvent'; data: MigrateEvent }
|
|
111
|
+
| { eventType: 'protocolClaimEvent'; data: ProtocolClaimEvent }
|
|
112
|
+
| { eventType: 'recycleEvent'; data: RecycleEvent }
|
|
113
|
+
| { eventType: 'tokenCreateEvent'; data: TokenCreateEvent }
|
|
114
|
+
| { eventType: 'tradeEvent'; data: TradeEvent };
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Parses sendLaunchpad event data into its event kind and decoded payload.
|
|
118
|
+
* Returns `null` when the event was emitted by another program or no known event matches;
|
|
119
|
+
* throws if a matched event fails to decode.
|
|
120
|
+
*
|
|
121
|
+
* Raw bytes carry no emitter and SKIP the program check.
|
|
122
|
+
*/
|
|
123
|
+
export function parseSendLaunchpadEvent(
|
|
124
|
+
event:
|
|
125
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
126
|
+
| ReadonlyUint8Array,
|
|
127
|
+
): ParsedSendLaunchpadEvent | null {
|
|
128
|
+
const checkedEvent =
|
|
129
|
+
'data' in event
|
|
130
|
+
? { data: event.data, programAddress: event.programAddress }
|
|
131
|
+
: event;
|
|
132
|
+
const eventType = identifySendLaunchpadEvent(checkedEvent);
|
|
133
|
+
if (eventType === null) return null;
|
|
134
|
+
const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
|
|
135
|
+
switch (eventType) {
|
|
136
|
+
case 'completeEvent': {
|
|
137
|
+
return {
|
|
138
|
+
eventType: 'completeEvent',
|
|
139
|
+
data: getCompleteEventDecoder().decode(
|
|
140
|
+
data,
|
|
141
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
142
|
+
COMPLETE_EVENT_DISCRIMINATOR.length,
|
|
143
|
+
),
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
case 'creatorClaimEvent': {
|
|
147
|
+
return {
|
|
148
|
+
eventType: 'creatorClaimEvent',
|
|
149
|
+
data: getCreatorClaimEventDecoder().decode(
|
|
150
|
+
data,
|
|
151
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
152
|
+
CREATOR_CLAIM_EVENT_DISCRIMINATOR.length,
|
|
153
|
+
),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case 'migrateEvent': {
|
|
157
|
+
return {
|
|
158
|
+
eventType: 'migrateEvent',
|
|
159
|
+
data: getMigrateEventDecoder().decode(
|
|
160
|
+
data,
|
|
161
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
162
|
+
MIGRATE_EVENT_DISCRIMINATOR.length,
|
|
163
|
+
),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
case 'protocolClaimEvent': {
|
|
167
|
+
return {
|
|
168
|
+
eventType: 'protocolClaimEvent',
|
|
169
|
+
data: getProtocolClaimEventDecoder().decode(
|
|
170
|
+
data,
|
|
171
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
172
|
+
PROTOCOL_CLAIM_EVENT_DISCRIMINATOR.length,
|
|
173
|
+
),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
case 'recycleEvent': {
|
|
177
|
+
return {
|
|
178
|
+
eventType: 'recycleEvent',
|
|
179
|
+
data: getRecycleEventDecoder().decode(
|
|
180
|
+
data,
|
|
181
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
182
|
+
RECYCLE_EVENT_DISCRIMINATOR.length,
|
|
183
|
+
),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
case 'tokenCreateEvent': {
|
|
187
|
+
return {
|
|
188
|
+
eventType: 'tokenCreateEvent',
|
|
189
|
+
data: getTokenCreateEventDecoder().decode(
|
|
190
|
+
data,
|
|
191
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
192
|
+
TOKEN_CREATE_EVENT_DISCRIMINATOR.length,
|
|
193
|
+
),
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
case 'tradeEvent': {
|
|
197
|
+
return {
|
|
198
|
+
eventType: 'tradeEvent',
|
|
199
|
+
data: getTradeEventDecoder().decode(
|
|
200
|
+
data,
|
|
201
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
202
|
+
TRADE_EVENT_DISCRIMINATOR.length,
|
|
203
|
+
),
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
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
|
+
addDecoderSizePrefix,
|
|
11
|
+
containsBytes,
|
|
12
|
+
fixEncoderSize,
|
|
13
|
+
getAddressDecoder,
|
|
14
|
+
getBooleanDecoder,
|
|
15
|
+
getBytesEncoder,
|
|
16
|
+
getI64Decoder,
|
|
17
|
+
getStructDecoder,
|
|
18
|
+
getU32Decoder,
|
|
19
|
+
getU64Decoder,
|
|
20
|
+
getU8Decoder,
|
|
21
|
+
getUtf8Decoder,
|
|
22
|
+
type Address,
|
|
23
|
+
type Decoder,
|
|
24
|
+
type ReadonlyUint8Array,
|
|
25
|
+
} from '@solana/kit';
|
|
26
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
27
|
+
import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
|
|
28
|
+
|
|
29
|
+
export const TOKEN_CREATE_EVENT_DISCRIMINATOR: ReadonlyUint8Array =
|
|
30
|
+
new Uint8Array([152, 16, 194, 59, 171, 105, 172, 45]);
|
|
31
|
+
|
|
32
|
+
export function getTokenCreateEventDiscriminatorBytes(): ReadonlyUint8Array {
|
|
33
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
34
|
+
TOKEN_CREATE_EVENT_DISCRIMINATOR,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type TokenCreateEvent = {
|
|
39
|
+
bondingCurve: Address;
|
|
40
|
+
baseMint: Address;
|
|
41
|
+
baseDecimals: number;
|
|
42
|
+
baseSupply: bigint;
|
|
43
|
+
initialVirtualBase: bigint;
|
|
44
|
+
initialVirtualQuote: bigint;
|
|
45
|
+
initialRealBase: bigint;
|
|
46
|
+
quoteMint: Address;
|
|
47
|
+
quoteDecimals: number;
|
|
48
|
+
coinCreator: Address;
|
|
49
|
+
creatorPlatform: string;
|
|
50
|
+
creatorId: string;
|
|
51
|
+
creatorFeeConfig: Address;
|
|
52
|
+
platformConfig: Address;
|
|
53
|
+
name: string;
|
|
54
|
+
symbol: string;
|
|
55
|
+
uri: string;
|
|
56
|
+
partner: Address;
|
|
57
|
+
isPartner: boolean;
|
|
58
|
+
creationFee: bigint;
|
|
59
|
+
virtualBaseReserves: bigint;
|
|
60
|
+
virtualQuoteReserves: bigint;
|
|
61
|
+
realBaseReserves: bigint;
|
|
62
|
+
realQuoteReserves: bigint;
|
|
63
|
+
timestamp: bigint;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
let getTokenCreateEventDecoderCache: Decoder<TokenCreateEvent> | undefined;
|
|
67
|
+
|
|
68
|
+
export function getTokenCreateEventDecoder(): Decoder<TokenCreateEvent> {
|
|
69
|
+
return (getTokenCreateEventDecoderCache ??= getStructDecoder([
|
|
70
|
+
['bondingCurve', getAddressDecoder()],
|
|
71
|
+
['baseMint', getAddressDecoder()],
|
|
72
|
+
['baseDecimals', getU8Decoder()],
|
|
73
|
+
['baseSupply', getU64Decoder()],
|
|
74
|
+
['initialVirtualBase', getU64Decoder()],
|
|
75
|
+
['initialVirtualQuote', getU64Decoder()],
|
|
76
|
+
['initialRealBase', getU64Decoder()],
|
|
77
|
+
['quoteMint', getAddressDecoder()],
|
|
78
|
+
['quoteDecimals', getU8Decoder()],
|
|
79
|
+
['coinCreator', getAddressDecoder()],
|
|
80
|
+
[
|
|
81
|
+
'creatorPlatform',
|
|
82
|
+
addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder()),
|
|
83
|
+
],
|
|
84
|
+
['creatorId', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
85
|
+
['creatorFeeConfig', getAddressDecoder()],
|
|
86
|
+
['platformConfig', getAddressDecoder()],
|
|
87
|
+
['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
88
|
+
['symbol', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
89
|
+
['uri', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
90
|
+
['partner', getAddressDecoder()],
|
|
91
|
+
['isPartner', getBooleanDecoder()],
|
|
92
|
+
['creationFee', getU64Decoder()],
|
|
93
|
+
['virtualBaseReserves', getU64Decoder()],
|
|
94
|
+
['virtualQuoteReserves', getU64Decoder()],
|
|
95
|
+
['realBaseReserves', getU64Decoder()],
|
|
96
|
+
['realQuoteReserves', getU64Decoder()],
|
|
97
|
+
['timestamp', getI64Decoder()],
|
|
98
|
+
]));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Checks whether the event data matches the framing and discriminator bytes of a
|
|
103
|
+
* {@link TokenCreateEvent}, without decoding. Never throws.
|
|
104
|
+
*
|
|
105
|
+
* Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
|
|
106
|
+
* Raw bytes carry no emitter and SKIP that check.
|
|
107
|
+
*
|
|
108
|
+
* @see parseTokenCreateEvent to decode the matching data
|
|
109
|
+
*/
|
|
110
|
+
export function isTokenCreateEvent(
|
|
111
|
+
event:
|
|
112
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
113
|
+
| ReadonlyUint8Array,
|
|
114
|
+
): boolean {
|
|
115
|
+
if (
|
|
116
|
+
'data' in event &&
|
|
117
|
+
event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
|
|
118
|
+
)
|
|
119
|
+
return false;
|
|
120
|
+
const data = 'data' in event ? event.data : event;
|
|
121
|
+
return (
|
|
122
|
+
containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
|
|
123
|
+
containsBytes(data, TOKEN_CREATE_EVENT_DISCRIMINATOR, 8)
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Parses raw event data as a {@link TokenCreateEvent}. Returns `null` on framing or discriminator
|
|
129
|
+
* mismatch; throws if the event matches but its body fails to decode.
|
|
130
|
+
*
|
|
131
|
+
* Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
|
|
132
|
+
* Raw bytes carry no emitter and SKIP that check.
|
|
133
|
+
*
|
|
134
|
+
* @see isTokenCreateEvent to check without decoding
|
|
135
|
+
* @see identifySendLaunchpadEvent to identify any program event
|
|
136
|
+
* @see parseSendLaunchpadEvent
|
|
137
|
+
*/
|
|
138
|
+
export function parseTokenCreateEvent(
|
|
139
|
+
event:
|
|
140
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
141
|
+
| ReadonlyUint8Array,
|
|
142
|
+
): TokenCreateEvent | null {
|
|
143
|
+
const checkedEvent =
|
|
144
|
+
'data' in event
|
|
145
|
+
? { data: event.data, programAddress: event.programAddress }
|
|
146
|
+
: event;
|
|
147
|
+
if (!isTokenCreateEvent(checkedEvent)) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
|
|
151
|
+
return getTokenCreateEventDecoder().decode(
|
|
152
|
+
data,
|
|
153
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
154
|
+
TOKEN_CREATE_EVENT_DISCRIMINATOR.length,
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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 {
|
|
24
|
+
getTradeDirectionDecoder,
|
|
25
|
+
type TradeDirection,
|
|
26
|
+
} from '../types/index.js';
|
|
27
|
+
import { ANCHOR_EVENT_CPI_DISCRIMINATOR } from './anchorEventCpiDiscriminator.framing.js';
|
|
28
|
+
|
|
29
|
+
export const TRADE_EVENT_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
30
|
+
189, 219, 127, 211, 78, 230, 97, 238,
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
export function getTradeEventDiscriminatorBytes(): ReadonlyUint8Array {
|
|
34
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
35
|
+
TRADE_EVENT_DISCRIMINATOR,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export type TradeEvent = {
|
|
40
|
+
bondingCurve: Address;
|
|
41
|
+
baseMint: Address;
|
|
42
|
+
quoteMint: Address;
|
|
43
|
+
user: Address;
|
|
44
|
+
coinCreator: Address;
|
|
45
|
+
creatorFeeConfig: Address;
|
|
46
|
+
platformConfig: Address;
|
|
47
|
+
baseAmount: bigint;
|
|
48
|
+
quoteAmountGross: bigint;
|
|
49
|
+
quoteAmountNet: bigint;
|
|
50
|
+
tradeDirection: TradeDirection;
|
|
51
|
+
partner: Address;
|
|
52
|
+
isPartner: boolean;
|
|
53
|
+
protocolFee: bigint;
|
|
54
|
+
creatorFee: bigint;
|
|
55
|
+
baseTransferFee: bigint;
|
|
56
|
+
quoteTransferFee: bigint;
|
|
57
|
+
virtualBaseReserves: bigint;
|
|
58
|
+
virtualQuoteReserves: bigint;
|
|
59
|
+
realBaseReserves: bigint;
|
|
60
|
+
realQuoteReserves: bigint;
|
|
61
|
+
timestamp: bigint;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
let getTradeEventDecoderCache: FixedSizeDecoder<TradeEvent> | undefined;
|
|
65
|
+
|
|
66
|
+
export function getTradeEventDecoder(): FixedSizeDecoder<TradeEvent> {
|
|
67
|
+
return (getTradeEventDecoderCache ??= getStructDecoder([
|
|
68
|
+
['bondingCurve', getAddressDecoder()],
|
|
69
|
+
['baseMint', getAddressDecoder()],
|
|
70
|
+
['quoteMint', getAddressDecoder()],
|
|
71
|
+
['user', getAddressDecoder()],
|
|
72
|
+
['coinCreator', getAddressDecoder()],
|
|
73
|
+
['creatorFeeConfig', getAddressDecoder()],
|
|
74
|
+
['platformConfig', getAddressDecoder()],
|
|
75
|
+
['baseAmount', getU64Decoder()],
|
|
76
|
+
['quoteAmountGross', getU64Decoder()],
|
|
77
|
+
['quoteAmountNet', getU64Decoder()],
|
|
78
|
+
['tradeDirection', getTradeDirectionDecoder()],
|
|
79
|
+
['partner', getAddressDecoder()],
|
|
80
|
+
['isPartner', getBooleanDecoder()],
|
|
81
|
+
['protocolFee', getU64Decoder()],
|
|
82
|
+
['creatorFee', getU64Decoder()],
|
|
83
|
+
['baseTransferFee', getU64Decoder()],
|
|
84
|
+
['quoteTransferFee', getU64Decoder()],
|
|
85
|
+
['virtualBaseReserves', getU64Decoder()],
|
|
86
|
+
['virtualQuoteReserves', getU64Decoder()],
|
|
87
|
+
['realBaseReserves', getU64Decoder()],
|
|
88
|
+
['realQuoteReserves', getU64Decoder()],
|
|
89
|
+
['timestamp', getI64Decoder()],
|
|
90
|
+
]));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Checks whether the event data matches the framing and discriminator bytes of a
|
|
95
|
+
* {@link TradeEvent}, without decoding. Never throws.
|
|
96
|
+
*
|
|
97
|
+
* Returns `false` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
|
|
98
|
+
* Raw bytes carry no emitter and SKIP that check.
|
|
99
|
+
*
|
|
100
|
+
* @see parseTradeEvent to decode the matching data
|
|
101
|
+
*/
|
|
102
|
+
export function isTradeEvent(
|
|
103
|
+
event:
|
|
104
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
105
|
+
| ReadonlyUint8Array,
|
|
106
|
+
): boolean {
|
|
107
|
+
if (
|
|
108
|
+
'data' in event &&
|
|
109
|
+
event.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
|
|
110
|
+
)
|
|
111
|
+
return false;
|
|
112
|
+
const data = 'data' in event ? event.data : event;
|
|
113
|
+
return (
|
|
114
|
+
containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0) &&
|
|
115
|
+
containsBytes(data, TRADE_EVENT_DISCRIMINATOR, 8)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Parses raw event data as a {@link TradeEvent}. Returns `null` on framing or discriminator
|
|
121
|
+
* mismatch; throws if the event matches but its body fails to decode.
|
|
122
|
+
*
|
|
123
|
+
* Returns `null` unless `event.programAddress` is SEND_LAUNCHPAD_PROGRAM_ADDRESS.
|
|
124
|
+
* Raw bytes carry no emitter and SKIP that check.
|
|
125
|
+
*
|
|
126
|
+
* @see isTradeEvent to check without decoding
|
|
127
|
+
* @see identifySendLaunchpadEvent to identify any program event
|
|
128
|
+
* @see parseSendLaunchpadEvent
|
|
129
|
+
*/
|
|
130
|
+
export function parseTradeEvent(
|
|
131
|
+
event:
|
|
132
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
133
|
+
| ReadonlyUint8Array,
|
|
134
|
+
): TradeEvent | null {
|
|
135
|
+
const checkedEvent =
|
|
136
|
+
'data' in event
|
|
137
|
+
? { data: event.data, programAddress: event.programAddress }
|
|
138
|
+
: event;
|
|
139
|
+
if (!isTradeEvent(checkedEvent)) {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
const data = 'data' in checkedEvent ? checkedEvent.data : checkedEvent;
|
|
143
|
+
return getTradeEventDecoder().decode(
|
|
144
|
+
data,
|
|
145
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR.length +
|
|
146
|
+
TRADE_EVENT_DISCRIMINATOR.length,
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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 './accounts/index.js';
|
|
10
|
+
export * from './errors/index.js';
|
|
11
|
+
export * from './events/index.js';
|
|
12
|
+
export * from './instructions/index.js';
|
|
13
|
+
export * from './pdas/index.js';
|
|
14
|
+
export * from './plugins/index.js';
|
|
15
|
+
export * from './programs/index.js';
|
|
16
|
+
export * from './types/index.js';
|