@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,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
|
+
}
|