@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,211 @@
|
|
|
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
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
containsBytes,
|
|
14
|
+
decodeAccount,
|
|
15
|
+
fetchEncodedAccount,
|
|
16
|
+
fetchEncodedAccounts,
|
|
17
|
+
fixDecoderSize,
|
|
18
|
+
fixEncoderSize,
|
|
19
|
+
getAddressDecoder,
|
|
20
|
+
getAddressEncoder,
|
|
21
|
+
getBooleanDecoder,
|
|
22
|
+
getBooleanEncoder,
|
|
23
|
+
getBytesDecoder,
|
|
24
|
+
getBytesEncoder,
|
|
25
|
+
getStructDecoder,
|
|
26
|
+
getStructEncoder,
|
|
27
|
+
getU64Decoder,
|
|
28
|
+
getU64Encoder,
|
|
29
|
+
getU8Decoder,
|
|
30
|
+
getU8Encoder,
|
|
31
|
+
transformEncoder,
|
|
32
|
+
type Account,
|
|
33
|
+
type Address,
|
|
34
|
+
type EncodedAccount,
|
|
35
|
+
type FetchAccountConfig,
|
|
36
|
+
type FetchAccountsConfig,
|
|
37
|
+
type FixedSizeCodec,
|
|
38
|
+
type FixedSizeDecoder,
|
|
39
|
+
type FixedSizeEncoder,
|
|
40
|
+
type MaybeAccount,
|
|
41
|
+
type MaybeEncodedAccount,
|
|
42
|
+
type ReadonlyUint8Array,
|
|
43
|
+
} from '@solana/kit';
|
|
44
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
45
|
+
|
|
46
|
+
export const GLOBAL_CONFIG_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
47
|
+
149, 8, 156, 202, 160, 252, 176, 217,
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
export function getGlobalConfigDiscriminatorBytes(): ReadonlyUint8Array {
|
|
51
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
52
|
+
GLOBAL_CONFIG_DISCRIMINATOR,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type GlobalConfig = {
|
|
57
|
+
discriminator: ReadonlyUint8Array;
|
|
58
|
+
version: number;
|
|
59
|
+
bump: number;
|
|
60
|
+
authority: Address;
|
|
61
|
+
operator: Address;
|
|
62
|
+
createTokenDisabled: boolean;
|
|
63
|
+
normalizedSolPriceCents: bigint;
|
|
64
|
+
initialBaseSupply: bigint;
|
|
65
|
+
initialVirtualBaseReserves: bigint;
|
|
66
|
+
initialRealBaseReserves: bigint;
|
|
67
|
+
initialVirtualQuoteReserves: bigint;
|
|
68
|
+
reserved: ReadonlyUint8Array;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export type GlobalConfigArgs = {
|
|
72
|
+
version: number;
|
|
73
|
+
bump: number;
|
|
74
|
+
authority: Address;
|
|
75
|
+
operator: Address;
|
|
76
|
+
createTokenDisabled: boolean;
|
|
77
|
+
normalizedSolPriceCents: number | bigint;
|
|
78
|
+
initialBaseSupply: number | bigint;
|
|
79
|
+
initialVirtualBaseReserves: number | bigint;
|
|
80
|
+
initialRealBaseReserves: number | bigint;
|
|
81
|
+
initialVirtualQuoteReserves: number | bigint;
|
|
82
|
+
reserved: ReadonlyUint8Array;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/** Gets the encoder for {@link GlobalConfigArgs} account data. */
|
|
86
|
+
export function getGlobalConfigEncoder(): FixedSizeEncoder<GlobalConfigArgs> {
|
|
87
|
+
return transformEncoder(
|
|
88
|
+
getStructEncoder([
|
|
89
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
90
|
+
['version', getU8Encoder()],
|
|
91
|
+
['bump', getU8Encoder()],
|
|
92
|
+
['authority', getAddressEncoder()],
|
|
93
|
+
['operator', getAddressEncoder()],
|
|
94
|
+
['createTokenDisabled', getBooleanEncoder()],
|
|
95
|
+
['normalizedSolPriceCents', getU64Encoder()],
|
|
96
|
+
['initialBaseSupply', getU64Encoder()],
|
|
97
|
+
['initialVirtualBaseReserves', getU64Encoder()],
|
|
98
|
+
['initialRealBaseReserves', getU64Encoder()],
|
|
99
|
+
['initialVirtualQuoteReserves', getU64Encoder()],
|
|
100
|
+
['reserved', fixEncoderSize(getBytesEncoder(), 64)],
|
|
101
|
+
]),
|
|
102
|
+
(value) => ({ ...value, discriminator: GLOBAL_CONFIG_DISCRIMINATOR }),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Gets the decoder for {@link GlobalConfig} account data. */
|
|
107
|
+
export function getGlobalConfigDecoder(): FixedSizeDecoder<GlobalConfig> {
|
|
108
|
+
return getStructDecoder([
|
|
109
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
110
|
+
['version', getU8Decoder()],
|
|
111
|
+
['bump', getU8Decoder()],
|
|
112
|
+
['authority', getAddressDecoder()],
|
|
113
|
+
['operator', getAddressDecoder()],
|
|
114
|
+
['createTokenDisabled', getBooleanDecoder()],
|
|
115
|
+
['normalizedSolPriceCents', getU64Decoder()],
|
|
116
|
+
['initialBaseSupply', getU64Decoder()],
|
|
117
|
+
['initialVirtualBaseReserves', getU64Decoder()],
|
|
118
|
+
['initialRealBaseReserves', getU64Decoder()],
|
|
119
|
+
['initialVirtualQuoteReserves', getU64Decoder()],
|
|
120
|
+
['reserved', fixDecoderSize(getBytesDecoder(), 64)],
|
|
121
|
+
]);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Gets the codec for {@link GlobalConfig} account data. */
|
|
125
|
+
export function getGlobalConfigCodec(): FixedSizeCodec<
|
|
126
|
+
GlobalConfigArgs,
|
|
127
|
+
GlobalConfig
|
|
128
|
+
> {
|
|
129
|
+
return combineCodec(getGlobalConfigEncoder(), getGlobalConfigDecoder());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
133
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
134
|
+
): Account<GlobalConfig, TAddress>;
|
|
135
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
136
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
137
|
+
): MaybeAccount<GlobalConfig, TAddress>;
|
|
138
|
+
export function decodeGlobalConfig<TAddress extends string = string>(
|
|
139
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
140
|
+
): Account<GlobalConfig, TAddress> | MaybeAccount<GlobalConfig, TAddress> {
|
|
141
|
+
if (!('exists' in encodedAccount) || encodedAccount.exists) {
|
|
142
|
+
if (encodedAccount.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS) {
|
|
143
|
+
const error = new Error(
|
|
144
|
+
`decodeGlobalConfig: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_LAUNCHPAD_PROGRAM_ADDRESS}`,
|
|
145
|
+
);
|
|
146
|
+
error.name = 'AccountOwnerMismatchError';
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
if (
|
|
150
|
+
!containsBytes(encodedAccount.data, GLOBAL_CONFIG_DISCRIMINATOR, 0)
|
|
151
|
+
) {
|
|
152
|
+
const error = new Error(
|
|
153
|
+
`decodeGlobalConfig: account ${encodedAccount.address} does not match the GlobalConfig discriminator`,
|
|
154
|
+
);
|
|
155
|
+
error.name = 'AccountDiscriminatorMismatchError';
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return decodeAccount(
|
|
160
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
161
|
+
getGlobalConfigDecoder(),
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function fetchGlobalConfig<TAddress extends string = string>(
|
|
166
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
167
|
+
address: Address<TAddress>,
|
|
168
|
+
config?: FetchAccountConfig,
|
|
169
|
+
): Promise<Account<GlobalConfig, TAddress>> {
|
|
170
|
+
const maybeAccount = await fetchMaybeGlobalConfig(rpc, address, config);
|
|
171
|
+
assertAccountExists(maybeAccount);
|
|
172
|
+
return maybeAccount;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export async function fetchMaybeGlobalConfig<TAddress extends string = string>(
|
|
176
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
177
|
+
address: Address<TAddress>,
|
|
178
|
+
config?: FetchAccountConfig,
|
|
179
|
+
): Promise<MaybeAccount<GlobalConfig, TAddress>> {
|
|
180
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
181
|
+
return decodeGlobalConfig(maybeAccount);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export async function fetchAllGlobalConfig(
|
|
185
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
186
|
+
addresses: Array<Address>,
|
|
187
|
+
config?: FetchAccountsConfig,
|
|
188
|
+
): Promise<Account<GlobalConfig>[]> {
|
|
189
|
+
const maybeAccounts = await fetchAllMaybeGlobalConfig(
|
|
190
|
+
rpc,
|
|
191
|
+
addresses,
|
|
192
|
+
config,
|
|
193
|
+
);
|
|
194
|
+
assertAccountsExist(maybeAccounts);
|
|
195
|
+
return maybeAccounts;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export async function fetchAllMaybeGlobalConfig(
|
|
199
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
200
|
+
addresses: Array<Address>,
|
|
201
|
+
config?: FetchAccountsConfig,
|
|
202
|
+
): Promise<MaybeAccount<GlobalConfig>[]> {
|
|
203
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
204
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
205
|
+
decodeGlobalConfig(maybeAccount),
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function getGlobalConfigSize(): number {
|
|
210
|
+
return 179;
|
|
211
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 './bondingCurve.js';
|
|
10
|
+
export * from './globalConfig.js';
|
|
11
|
+
export * from './rewardAccrual.js';
|
|
12
|
+
export * from './sendLaunchpad.accounts.js';
|
|
@@ -0,0 +1,191 @@
|
|
|
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
|
+
assertAccountExists,
|
|
11
|
+
assertAccountsExist,
|
|
12
|
+
combineCodec,
|
|
13
|
+
containsBytes,
|
|
14
|
+
decodeAccount,
|
|
15
|
+
fetchEncodedAccount,
|
|
16
|
+
fetchEncodedAccounts,
|
|
17
|
+
fixDecoderSize,
|
|
18
|
+
fixEncoderSize,
|
|
19
|
+
getAddressDecoder,
|
|
20
|
+
getAddressEncoder,
|
|
21
|
+
getBytesDecoder,
|
|
22
|
+
getBytesEncoder,
|
|
23
|
+
getStructDecoder,
|
|
24
|
+
getStructEncoder,
|
|
25
|
+
getU128Decoder,
|
|
26
|
+
getU128Encoder,
|
|
27
|
+
getU64Decoder,
|
|
28
|
+
getU64Encoder,
|
|
29
|
+
getU8Decoder,
|
|
30
|
+
getU8Encoder,
|
|
31
|
+
transformEncoder,
|
|
32
|
+
type Account,
|
|
33
|
+
type Address,
|
|
34
|
+
type EncodedAccount,
|
|
35
|
+
type FetchAccountConfig,
|
|
36
|
+
type FetchAccountsConfig,
|
|
37
|
+
type FixedSizeCodec,
|
|
38
|
+
type FixedSizeDecoder,
|
|
39
|
+
type FixedSizeEncoder,
|
|
40
|
+
type MaybeAccount,
|
|
41
|
+
type MaybeEncodedAccount,
|
|
42
|
+
type ReadonlyUint8Array,
|
|
43
|
+
} from '@solana/kit';
|
|
44
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
45
|
+
|
|
46
|
+
export const REWARD_ACCRUAL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
47
|
+
158, 244, 116, 30, 227, 132, 105, 182,
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
export function getRewardAccrualDiscriminatorBytes(): ReadonlyUint8Array {
|
|
51
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
52
|
+
REWARD_ACCRUAL_DISCRIMINATOR,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type RewardAccrual = {
|
|
57
|
+
discriminator: ReadonlyUint8Array;
|
|
58
|
+
version: number;
|
|
59
|
+
bump: number;
|
|
60
|
+
quoteMint: Address;
|
|
61
|
+
accPerToken: bigint;
|
|
62
|
+
totalDeposited: bigint;
|
|
63
|
+
reserved: ReadonlyUint8Array;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export type RewardAccrualArgs = {
|
|
67
|
+
version: number;
|
|
68
|
+
bump: number;
|
|
69
|
+
quoteMint: Address;
|
|
70
|
+
accPerToken: number | bigint;
|
|
71
|
+
totalDeposited: number | bigint;
|
|
72
|
+
reserved: ReadonlyUint8Array;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** Gets the encoder for {@link RewardAccrualArgs} account data. */
|
|
76
|
+
export function getRewardAccrualEncoder(): FixedSizeEncoder<RewardAccrualArgs> {
|
|
77
|
+
return transformEncoder(
|
|
78
|
+
getStructEncoder([
|
|
79
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
80
|
+
['version', getU8Encoder()],
|
|
81
|
+
['bump', getU8Encoder()],
|
|
82
|
+
['quoteMint', getAddressEncoder()],
|
|
83
|
+
['accPerToken', getU128Encoder()],
|
|
84
|
+
['totalDeposited', getU64Encoder()],
|
|
85
|
+
['reserved', fixEncoderSize(getBytesEncoder(), 64)],
|
|
86
|
+
]),
|
|
87
|
+
(value) => ({ ...value, discriminator: REWARD_ACCRUAL_DISCRIMINATOR }),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Gets the decoder for {@link RewardAccrual} account data. */
|
|
92
|
+
export function getRewardAccrualDecoder(): FixedSizeDecoder<RewardAccrual> {
|
|
93
|
+
return getStructDecoder([
|
|
94
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
95
|
+
['version', getU8Decoder()],
|
|
96
|
+
['bump', getU8Decoder()],
|
|
97
|
+
['quoteMint', getAddressDecoder()],
|
|
98
|
+
['accPerToken', getU128Decoder()],
|
|
99
|
+
['totalDeposited', getU64Decoder()],
|
|
100
|
+
['reserved', fixDecoderSize(getBytesDecoder(), 64)],
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Gets the codec for {@link RewardAccrual} account data. */
|
|
105
|
+
export function getRewardAccrualCodec(): FixedSizeCodec<
|
|
106
|
+
RewardAccrualArgs,
|
|
107
|
+
RewardAccrual
|
|
108
|
+
> {
|
|
109
|
+
return combineCodec(getRewardAccrualEncoder(), getRewardAccrualDecoder());
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function decodeRewardAccrual<TAddress extends string = string>(
|
|
113
|
+
encodedAccount: EncodedAccount<TAddress>,
|
|
114
|
+
): Account<RewardAccrual, TAddress>;
|
|
115
|
+
export function decodeRewardAccrual<TAddress extends string = string>(
|
|
116
|
+
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
117
|
+
): MaybeAccount<RewardAccrual, TAddress>;
|
|
118
|
+
export function decodeRewardAccrual<TAddress extends string = string>(
|
|
119
|
+
encodedAccount: EncodedAccount<TAddress> | MaybeEncodedAccount<TAddress>,
|
|
120
|
+
): Account<RewardAccrual, TAddress> | MaybeAccount<RewardAccrual, TAddress> {
|
|
121
|
+
if (!('exists' in encodedAccount) || encodedAccount.exists) {
|
|
122
|
+
if (encodedAccount.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS) {
|
|
123
|
+
const error = new Error(
|
|
124
|
+
`decodeRewardAccrual: account ${encodedAccount.address} is owned by ${encodedAccount.programAddress}, expected ${SEND_LAUNCHPAD_PROGRAM_ADDRESS}`,
|
|
125
|
+
);
|
|
126
|
+
error.name = 'AccountOwnerMismatchError';
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
if (
|
|
130
|
+
!containsBytes(encodedAccount.data, REWARD_ACCRUAL_DISCRIMINATOR, 0)
|
|
131
|
+
) {
|
|
132
|
+
const error = new Error(
|
|
133
|
+
`decodeRewardAccrual: account ${encodedAccount.address} does not match the RewardAccrual discriminator`,
|
|
134
|
+
);
|
|
135
|
+
error.name = 'AccountDiscriminatorMismatchError';
|
|
136
|
+
throw error;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return decodeAccount(
|
|
140
|
+
encodedAccount as MaybeEncodedAccount<TAddress>,
|
|
141
|
+
getRewardAccrualDecoder(),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export async function fetchRewardAccrual<TAddress extends string = string>(
|
|
146
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
147
|
+
address: Address<TAddress>,
|
|
148
|
+
config?: FetchAccountConfig,
|
|
149
|
+
): Promise<Account<RewardAccrual, TAddress>> {
|
|
150
|
+
const maybeAccount = await fetchMaybeRewardAccrual(rpc, address, config);
|
|
151
|
+
assertAccountExists(maybeAccount);
|
|
152
|
+
return maybeAccount;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function fetchMaybeRewardAccrual<TAddress extends string = string>(
|
|
156
|
+
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
157
|
+
address: Address<TAddress>,
|
|
158
|
+
config?: FetchAccountConfig,
|
|
159
|
+
): Promise<MaybeAccount<RewardAccrual, TAddress>> {
|
|
160
|
+
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
161
|
+
return decodeRewardAccrual(maybeAccount);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export async function fetchAllRewardAccrual(
|
|
165
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
166
|
+
addresses: Array<Address>,
|
|
167
|
+
config?: FetchAccountsConfig,
|
|
168
|
+
): Promise<Account<RewardAccrual>[]> {
|
|
169
|
+
const maybeAccounts = await fetchAllMaybeRewardAccrual(
|
|
170
|
+
rpc,
|
|
171
|
+
addresses,
|
|
172
|
+
config,
|
|
173
|
+
);
|
|
174
|
+
assertAccountsExist(maybeAccounts);
|
|
175
|
+
return maybeAccounts;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export async function fetchAllMaybeRewardAccrual(
|
|
179
|
+
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
180
|
+
addresses: Array<Address>,
|
|
181
|
+
config?: FetchAccountsConfig,
|
|
182
|
+
): Promise<MaybeAccount<RewardAccrual>[]> {
|
|
183
|
+
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
184
|
+
return maybeAccounts.map((maybeAccount) =>
|
|
185
|
+
decodeRewardAccrual(maybeAccount),
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export function getRewardAccrualSize(): number {
|
|
190
|
+
return 130;
|
|
191
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 { BONDING_CURVE_DISCRIMINATOR } from './bondingCurve.js';
|
|
16
|
+
import { GLOBAL_CONFIG_DISCRIMINATOR } from './globalConfig.js';
|
|
17
|
+
import { REWARD_ACCRUAL_DISCRIMINATOR } from './rewardAccrual.js';
|
|
18
|
+
|
|
19
|
+
/** Account kinds of the sendLaunchpad program. */
|
|
20
|
+
export type SendLaunchpadAccountType =
|
|
21
|
+
| 'bondingCurve'
|
|
22
|
+
| 'globalConfig'
|
|
23
|
+
| 'rewardAccrual';
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Identifies sendLaunchpad account data by its discriminators.
|
|
27
|
+
* Returns `null` when the account belongs to another program or the data matches no known account.
|
|
28
|
+
*/
|
|
29
|
+
export function identifySendLaunchpadAccount(
|
|
30
|
+
account:
|
|
31
|
+
| { data: ReadonlyUint8Array; programAddress: Address }
|
|
32
|
+
| ReadonlyUint8Array,
|
|
33
|
+
): SendLaunchpadAccountType | null {
|
|
34
|
+
if (
|
|
35
|
+
'data' in account &&
|
|
36
|
+
account.programAddress !== SEND_LAUNCHPAD_PROGRAM_ADDRESS
|
|
37
|
+
)
|
|
38
|
+
return null;
|
|
39
|
+
const data = 'data' in account ? account.data : account;
|
|
40
|
+
if (containsBytes(data, BONDING_CURVE_DISCRIMINATOR, 0)) {
|
|
41
|
+
return 'bondingCurve';
|
|
42
|
+
}
|
|
43
|
+
if (containsBytes(data, GLOBAL_CONFIG_DISCRIMINATOR, 0)) {
|
|
44
|
+
return 'globalConfig';
|
|
45
|
+
}
|
|
46
|
+
if (containsBytes(data, REWARD_ACCRUAL_DISCRIMINATOR, 0)) {
|
|
47
|
+
return 'rewardAccrual';
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
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 './sendLaunchpad.js';
|
|
@@ -0,0 +1,175 @@
|
|
|
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
|
+
isProgramError,
|
|
11
|
+
type Address,
|
|
12
|
+
type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
|
|
13
|
+
type SolanaError,
|
|
14
|
+
} from '@solana/kit';
|
|
15
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
16
|
+
|
|
17
|
+
/** TokenCreationDisabled: Token creation is disabled */
|
|
18
|
+
export const SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED = 0x1770; // 6000
|
|
19
|
+
/** SlippageExceeded: Slippage tolerance exceeded */
|
|
20
|
+
export const SEND_LAUNCHPAD_ERROR__SLIPPAGE_EXCEEDED = 0x1771; // 6001
|
|
21
|
+
/** AlreadyMigrated: Already migrated */
|
|
22
|
+
export const SEND_LAUNCHPAD_ERROR__ALREADY_MIGRATED = 0x1772; // 6002
|
|
23
|
+
/** ThresholdNotReached: Migration threshold not reached */
|
|
24
|
+
export const SEND_LAUNCHPAD_ERROR__THRESHOLD_NOT_REACHED = 0x1773; // 6003
|
|
25
|
+
/** ThresholdReached: Migration threshold reached - trading disabled until migration completes */
|
|
26
|
+
export const SEND_LAUNCHPAD_ERROR__THRESHOLD_REACHED = 0x1774; // 6004
|
|
27
|
+
/** InvalidBaseMint: Invalid base mint */
|
|
28
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT = 0x1775; // 6005
|
|
29
|
+
/** InvalidQuoteMint: Invalid quote mint */
|
|
30
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT = 0x1776; // 6006
|
|
31
|
+
/** NotTradeable: Bonding curve is not tradeable */
|
|
32
|
+
export const SEND_LAUNCHPAD_ERROR__NOT_TRADEABLE = 0x1777; // 6007
|
|
33
|
+
/** InvalidStatusTransition: Invalid status transition */
|
|
34
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_STATUS_TRANSITION = 0x1778; // 6008
|
|
35
|
+
/** CurveIsLive: Curve is live */
|
|
36
|
+
export const SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE = 0x1779; // 6009
|
|
37
|
+
/** BaseMintNotFound: Base mint not found */
|
|
38
|
+
export const SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND = 0x177a; // 6010
|
|
39
|
+
/** BlockedByHeldSupply: Blocked by held supply */
|
|
40
|
+
export const SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY = 0x177b; // 6011
|
|
41
|
+
/** InvalidCoinCreator: Invalid coin creator */
|
|
42
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR = 0x177c; // 6012
|
|
43
|
+
/** InvalidAuthority: Invalid authority */
|
|
44
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY = 0x177d; // 6013
|
|
45
|
+
/** InsufficientBalance: Insufficient balance in source account */
|
|
46
|
+
export const SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE = 0x177e; // 6014
|
|
47
|
+
/** PoolFeesOutstanding: Pool has unclaimed protocol or creator fees */
|
|
48
|
+
export const SEND_LAUNCHPAD_ERROR__POOL_FEES_OUTSTANDING = 0x177f; // 6015
|
|
49
|
+
/** ProgramPaused: Program is paused */
|
|
50
|
+
export const SEND_LAUNCHPAD_ERROR__PROGRAM_PAUSED = 0x1b58; // 7000
|
|
51
|
+
/** Unauthorized: Unauthorized */
|
|
52
|
+
export const SEND_LAUNCHPAD_ERROR__UNAUTHORIZED = 0x1b59; // 7001
|
|
53
|
+
/** ArithmeticOverflow: Arithmetic overflow */
|
|
54
|
+
export const SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW = 0x1b5a; // 7002
|
|
55
|
+
/** InvalidPythAccount: Invalid Pyth price account */
|
|
56
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT = 0x1b5b; // 7003
|
|
57
|
+
/** InvalidPythFeed: Invalid Pyth feed ID */
|
|
58
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED = 0x1b5c; // 7004
|
|
59
|
+
/** InvalidSlug: Invalid slug: must be non-empty, <= max_len bytes, lowercase alphanumeric or underscore */
|
|
60
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_SLUG = 0x1b5d; // 7005
|
|
61
|
+
/** TextTooLong: Text too long */
|
|
62
|
+
export const SEND_LAUNCHPAD_ERROR__TEXT_TOO_LONG = 0x1b5e; // 7006
|
|
63
|
+
/** UserTokenAccountWrongProgram: User token account owned by the wrong token program */
|
|
64
|
+
export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_PROGRAM = 0x1b5f; // 7007
|
|
65
|
+
/** UserTokenAccountInvalid: User token account is not an initialized token account */
|
|
66
|
+
export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID = 0x1b60; // 7008
|
|
67
|
+
/** UserTokenAccountWrongMint: User token account mint does not match the trade */
|
|
68
|
+
export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 0x1b61; // 7009
|
|
69
|
+
/** UserTokenAccountWrongAuthority: User token account is not owned by the trading user */
|
|
70
|
+
export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 0x1b62; // 7010
|
|
71
|
+
/** NothingToClaim: Nothing to claim */
|
|
72
|
+
export const SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM = 0x1b63; // 7011
|
|
73
|
+
/** InvalidCreatorId: Creator identity is not a decodable wallet address */
|
|
74
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID = 0x1b64; // 7012
|
|
75
|
+
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
76
|
+
export const SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET = 0x1b65; // 7013
|
|
77
|
+
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
78
|
+
export const SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 0x1b66; // 7014
|
|
79
|
+
/** InsufficientLiquidity: Insufficient liquidity */
|
|
80
|
+
export const SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY = 0x1bbc; // 7100
|
|
81
|
+
/** InvalidAmount: Invalid amount */
|
|
82
|
+
export const SEND_LAUNCHPAD_ERROR__INVALID_AMOUNT = 0x1bbd; // 7101
|
|
83
|
+
|
|
84
|
+
export type SendLaunchpadError =
|
|
85
|
+
| typeof SEND_LAUNCHPAD_ERROR__ALREADY_MIGRATED
|
|
86
|
+
| typeof SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW
|
|
87
|
+
| typeof SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND
|
|
88
|
+
| typeof SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY
|
|
89
|
+
| typeof SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE
|
|
90
|
+
| typeof SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE
|
|
91
|
+
| typeof SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY
|
|
92
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_AMOUNT
|
|
93
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY
|
|
94
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT
|
|
95
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR
|
|
96
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID
|
|
97
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT
|
|
98
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED
|
|
99
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT
|
|
100
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_SLUG
|
|
101
|
+
| typeof SEND_LAUNCHPAD_ERROR__INVALID_STATUS_TRANSITION
|
|
102
|
+
| typeof SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM
|
|
103
|
+
| typeof SEND_LAUNCHPAD_ERROR__NOT_TRADEABLE
|
|
104
|
+
| typeof SEND_LAUNCHPAD_ERROR__POOL_FEES_OUTSTANDING
|
|
105
|
+
| typeof SEND_LAUNCHPAD_ERROR__PROGRAM_PAUSED
|
|
106
|
+
| typeof SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET
|
|
107
|
+
| typeof SEND_LAUNCHPAD_ERROR__SLIPPAGE_EXCEEDED
|
|
108
|
+
| typeof SEND_LAUNCHPAD_ERROR__TEXT_TOO_LONG
|
|
109
|
+
| typeof SEND_LAUNCHPAD_ERROR__THRESHOLD_NOT_REACHED
|
|
110
|
+
| typeof SEND_LAUNCHPAD_ERROR__THRESHOLD_REACHED
|
|
111
|
+
| typeof SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED
|
|
112
|
+
| typeof SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE
|
|
113
|
+
| typeof SEND_LAUNCHPAD_ERROR__UNAUTHORIZED
|
|
114
|
+
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID
|
|
115
|
+
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY
|
|
116
|
+
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT
|
|
117
|
+
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_PROGRAM;
|
|
118
|
+
|
|
119
|
+
export const sendLaunchpadErrorMessages: Record<SendLaunchpadError, string> = {
|
|
120
|
+
[SEND_LAUNCHPAD_ERROR__ALREADY_MIGRATED]: `Already migrated`,
|
|
121
|
+
[SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
122
|
+
[SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND]: `Base mint not found`,
|
|
123
|
+
[SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY]: `Blocked by held supply`,
|
|
124
|
+
[SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE]: `Curve is live`,
|
|
125
|
+
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
126
|
+
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
127
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_AMOUNT]: `Invalid amount`,
|
|
128
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
129
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
130
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
131
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
132
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT]: `Invalid Pyth price account`,
|
|
133
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED]: `Invalid Pyth feed ID`,
|
|
134
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT]: `Invalid quote mint`,
|
|
135
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_SLUG]: `Invalid slug: must be non-empty, <= max_len bytes, lowercase alphanumeric or underscore`,
|
|
136
|
+
[SEND_LAUNCHPAD_ERROR__INVALID_STATUS_TRANSITION]: `Invalid status transition`,
|
|
137
|
+
[SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM]: `Nothing to claim`,
|
|
138
|
+
[SEND_LAUNCHPAD_ERROR__NOT_TRADEABLE]: `Bonding curve is not tradeable`,
|
|
139
|
+
[SEND_LAUNCHPAD_ERROR__POOL_FEES_OUTSTANDING]: `Pool has unclaimed protocol or creator fees`,
|
|
140
|
+
[SEND_LAUNCHPAD_ERROR__PROGRAM_PAUSED]: `Program is paused`,
|
|
141
|
+
[SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET]: `Quote mint has no USDC price on its nexus reward state`,
|
|
142
|
+
[SEND_LAUNCHPAD_ERROR__SLIPPAGE_EXCEEDED]: `Slippage tolerance exceeded`,
|
|
143
|
+
[SEND_LAUNCHPAD_ERROR__TEXT_TOO_LONG]: `Text too long`,
|
|
144
|
+
[SEND_LAUNCHPAD_ERROR__THRESHOLD_NOT_REACHED]: `Migration threshold not reached`,
|
|
145
|
+
[SEND_LAUNCHPAD_ERROR__THRESHOLD_REACHED]: `Migration threshold reached - trading disabled until migration completes`,
|
|
146
|
+
[SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED]: `Token creation is disabled`,
|
|
147
|
+
[SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
148
|
+
[SEND_LAUNCHPAD_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
149
|
+
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
150
|
+
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
151
|
+
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
152
|
+
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_PROGRAM]: `User token account owned by the wrong token program`,
|
|
153
|
+
} as const;
|
|
154
|
+
|
|
155
|
+
export function getSendLaunchpadErrorMessage(code: SendLaunchpadError): string {
|
|
156
|
+
return sendLaunchpadErrorMessages[code];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function isSendLaunchpadError<
|
|
160
|
+
TProgramErrorCode extends SendLaunchpadError,
|
|
161
|
+
>(
|
|
162
|
+
error: unknown,
|
|
163
|
+
transactionMessage: {
|
|
164
|
+
instructions: Record<number, { programAddress: Address }>;
|
|
165
|
+
},
|
|
166
|
+
code?: TProgramErrorCode,
|
|
167
|
+
): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> &
|
|
168
|
+
Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> {
|
|
169
|
+
return isProgramError<TProgramErrorCode>(
|
|
170
|
+
error,
|
|
171
|
+
transactionMessage,
|
|
172
|
+
SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
173
|
+
code,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
fixEncoderSize,
|
|
11
|
+
getBytesEncoder,
|
|
12
|
+
type ReadonlyUint8Array,
|
|
13
|
+
} from '@solana/kit';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Shared event-framing tag prepended to every CPI-framed event.
|
|
17
|
+
*
|
|
18
|
+
* `containsBytes(data, ANCHOR_EVENT_CPI_DISCRIMINATOR, 0)` checks whether data is a framed event
|
|
19
|
+
* at all — including event kinds unknown to this program.
|
|
20
|
+
*/
|
|
21
|
+
export const ANCHOR_EVENT_CPI_DISCRIMINATOR: ReadonlyUint8Array =
|
|
22
|
+
new Uint8Array([228, 69, 165, 46, 81, 203, 154, 29]);
|
|
23
|
+
|
|
24
|
+
export function getAnchorEventCpiDiscriminatorBytes(): ReadonlyUint8Array {
|
|
25
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
26
|
+
ANCHOR_EVENT_CPI_DISCRIMINATOR,
|
|
27
|
+
);
|
|
28
|
+
}
|