@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,840 @@
|
|
|
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
|
+
address,
|
|
11
|
+
assertIsInstructionForProgram,
|
|
12
|
+
combineCodec,
|
|
13
|
+
containsBytes,
|
|
14
|
+
fixDecoderSize,
|
|
15
|
+
fixEncoderSize,
|
|
16
|
+
getAddressEncoder,
|
|
17
|
+
getBytesDecoder,
|
|
18
|
+
getBytesEncoder,
|
|
19
|
+
getProgramDerivedAddress,
|
|
20
|
+
getStructDecoder,
|
|
21
|
+
getStructEncoder,
|
|
22
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
23
|
+
SolanaError,
|
|
24
|
+
transformEncoder,
|
|
25
|
+
type AccountMeta,
|
|
26
|
+
type AccountSignerMeta,
|
|
27
|
+
type Address,
|
|
28
|
+
type FixedSizeCodec,
|
|
29
|
+
type FixedSizeDecoder,
|
|
30
|
+
type FixedSizeEncoder,
|
|
31
|
+
type Instruction,
|
|
32
|
+
type InstructionWithAccounts,
|
|
33
|
+
type InstructionWithData,
|
|
34
|
+
type ReadonlyAccount,
|
|
35
|
+
type ReadonlyUint8Array,
|
|
36
|
+
type TransactionSigner,
|
|
37
|
+
type WritableAccount,
|
|
38
|
+
type WritableSignerAccount,
|
|
39
|
+
} from '@solana/kit';
|
|
40
|
+
import {
|
|
41
|
+
getAccountMetaFactory,
|
|
42
|
+
getAddressFromResolvedInstructionAccount,
|
|
43
|
+
type ResolvedInstructionAccount,
|
|
44
|
+
} from '@solana/program-client-core';
|
|
45
|
+
import {
|
|
46
|
+
EVENT_AUTHORITY_PDA_ADDRESS,
|
|
47
|
+
findBondingCurvePda,
|
|
48
|
+
MIGRATION_AUTHORITY_PDA_ADDRESS,
|
|
49
|
+
} from '../pdas/index.js';
|
|
50
|
+
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
51
|
+
|
|
52
|
+
export const MIGRATE_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
53
|
+
155, 234, 231, 146, 236, 158, 162, 30,
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
export function getMigrateDiscriminatorBytes(): ReadonlyUint8Array {
|
|
57
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(MIGRATE_DISCRIMINATOR);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type MigrateInstruction<
|
|
61
|
+
TProgram extends string = typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
62
|
+
TAccountCaller extends string | AccountMeta<string> = string,
|
|
63
|
+
TAccountBondingCurve extends string | AccountMeta<string> = string,
|
|
64
|
+
TAccountBaseMint extends string | AccountMeta<string> = string,
|
|
65
|
+
TAccountQuoteMint extends string | AccountMeta<string> = string,
|
|
66
|
+
TAccountBaseVault extends string | AccountMeta<string> = string,
|
|
67
|
+
TAccountQuoteVault extends string | AccountMeta<string> = string,
|
|
68
|
+
TAccountDexProgram extends string | AccountMeta<string> =
|
|
69
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX',
|
|
70
|
+
TAccountMigrationAuthority extends string | AccountMeta<string> =
|
|
71
|
+
'932vp5VTARoqoAKNgLSawfCsAx43jUJ5YURggmXBX6V',
|
|
72
|
+
TAccountPool extends string | AccountMeta<string> = string,
|
|
73
|
+
TAccountLpMint extends string | AccountMeta<string> = string,
|
|
74
|
+
TAccountPoolBaseVault extends string | AccountMeta<string> = string,
|
|
75
|
+
TAccountPoolQuoteVault extends string | AccountMeta<string> = string,
|
|
76
|
+
TAccountPoolLpAccount extends string | AccountMeta<string> = string,
|
|
77
|
+
TAccountDexEventAuthority extends string | AccountMeta<string> =
|
|
78
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t',
|
|
79
|
+
TAccountNexusProgram extends string | AccountMeta<string> =
|
|
80
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX',
|
|
81
|
+
TAccountCreatorFeeConfig extends string | AccountMeta<string> = string,
|
|
82
|
+
TAccountBaseTokenProgram extends string | AccountMeta<string> =
|
|
83
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
84
|
+
TAccountQuoteTokenProgram extends string | AccountMeta<string> = string,
|
|
85
|
+
TAccountAssociatedTokenProgram extends string | AccountMeta<string> =
|
|
86
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
87
|
+
TAccountSystemProgram extends string | AccountMeta<string> =
|
|
88
|
+
'11111111111111111111111111111111',
|
|
89
|
+
TAccountEventAuthority extends string | AccountMeta<string> =
|
|
90
|
+
'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
|
|
91
|
+
TAccountProgram extends string | AccountMeta<string> =
|
|
92
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP',
|
|
93
|
+
TRemainingAccounts extends readonly AccountMeta<string>[] = [],
|
|
94
|
+
> = Instruction<TProgram> &
|
|
95
|
+
InstructionWithData<ReadonlyUint8Array> &
|
|
96
|
+
InstructionWithAccounts<
|
|
97
|
+
[
|
|
98
|
+
TAccountCaller extends string
|
|
99
|
+
? WritableSignerAccount<TAccountCaller> &
|
|
100
|
+
AccountSignerMeta<TAccountCaller>
|
|
101
|
+
: TAccountCaller,
|
|
102
|
+
TAccountBondingCurve extends string
|
|
103
|
+
? WritableAccount<TAccountBondingCurve>
|
|
104
|
+
: TAccountBondingCurve,
|
|
105
|
+
TAccountBaseMint extends string
|
|
106
|
+
? WritableAccount<TAccountBaseMint>
|
|
107
|
+
: TAccountBaseMint,
|
|
108
|
+
TAccountQuoteMint extends string
|
|
109
|
+
? ReadonlyAccount<TAccountQuoteMint>
|
|
110
|
+
: TAccountQuoteMint,
|
|
111
|
+
TAccountBaseVault extends string
|
|
112
|
+
? WritableAccount<TAccountBaseVault>
|
|
113
|
+
: TAccountBaseVault,
|
|
114
|
+
TAccountQuoteVault extends string
|
|
115
|
+
? WritableAccount<TAccountQuoteVault>
|
|
116
|
+
: TAccountQuoteVault,
|
|
117
|
+
TAccountDexProgram extends string
|
|
118
|
+
? ReadonlyAccount<TAccountDexProgram>
|
|
119
|
+
: TAccountDexProgram,
|
|
120
|
+
TAccountMigrationAuthority extends string
|
|
121
|
+
? ReadonlyAccount<TAccountMigrationAuthority>
|
|
122
|
+
: TAccountMigrationAuthority,
|
|
123
|
+
TAccountPool extends string
|
|
124
|
+
? WritableAccount<TAccountPool>
|
|
125
|
+
: TAccountPool,
|
|
126
|
+
TAccountLpMint extends string
|
|
127
|
+
? WritableAccount<TAccountLpMint>
|
|
128
|
+
: TAccountLpMint,
|
|
129
|
+
TAccountPoolBaseVault extends string
|
|
130
|
+
? WritableAccount<TAccountPoolBaseVault>
|
|
131
|
+
: TAccountPoolBaseVault,
|
|
132
|
+
TAccountPoolQuoteVault extends string
|
|
133
|
+
? WritableAccount<TAccountPoolQuoteVault>
|
|
134
|
+
: TAccountPoolQuoteVault,
|
|
135
|
+
TAccountPoolLpAccount extends string
|
|
136
|
+
? WritableAccount<TAccountPoolLpAccount>
|
|
137
|
+
: TAccountPoolLpAccount,
|
|
138
|
+
TAccountDexEventAuthority extends string
|
|
139
|
+
? ReadonlyAccount<TAccountDexEventAuthority>
|
|
140
|
+
: TAccountDexEventAuthority,
|
|
141
|
+
TAccountNexusProgram extends string
|
|
142
|
+
? ReadonlyAccount<TAccountNexusProgram>
|
|
143
|
+
: TAccountNexusProgram,
|
|
144
|
+
TAccountCreatorFeeConfig extends string
|
|
145
|
+
? ReadonlyAccount<TAccountCreatorFeeConfig>
|
|
146
|
+
: TAccountCreatorFeeConfig,
|
|
147
|
+
TAccountBaseTokenProgram extends string
|
|
148
|
+
? ReadonlyAccount<TAccountBaseTokenProgram>
|
|
149
|
+
: TAccountBaseTokenProgram,
|
|
150
|
+
TAccountQuoteTokenProgram extends string
|
|
151
|
+
? ReadonlyAccount<TAccountQuoteTokenProgram>
|
|
152
|
+
: TAccountQuoteTokenProgram,
|
|
153
|
+
TAccountAssociatedTokenProgram extends string
|
|
154
|
+
? ReadonlyAccount<TAccountAssociatedTokenProgram>
|
|
155
|
+
: TAccountAssociatedTokenProgram,
|
|
156
|
+
TAccountSystemProgram extends string
|
|
157
|
+
? ReadonlyAccount<TAccountSystemProgram>
|
|
158
|
+
: TAccountSystemProgram,
|
|
159
|
+
TAccountEventAuthority extends string
|
|
160
|
+
? ReadonlyAccount<TAccountEventAuthority>
|
|
161
|
+
: TAccountEventAuthority,
|
|
162
|
+
TAccountProgram extends string
|
|
163
|
+
? ReadonlyAccount<TAccountProgram>
|
|
164
|
+
: TAccountProgram,
|
|
165
|
+
...TRemainingAccounts,
|
|
166
|
+
]
|
|
167
|
+
>;
|
|
168
|
+
|
|
169
|
+
export type MigrateInstructionData = { discriminator: ReadonlyUint8Array };
|
|
170
|
+
|
|
171
|
+
export type MigrateInstructionDataArgs = {};
|
|
172
|
+
|
|
173
|
+
export function getMigrateInstructionDataEncoder(): FixedSizeEncoder<MigrateInstructionDataArgs> {
|
|
174
|
+
return transformEncoder(
|
|
175
|
+
getStructEncoder([
|
|
176
|
+
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
177
|
+
]),
|
|
178
|
+
(value) => ({ ...value, discriminator: MIGRATE_DISCRIMINATOR }),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function getMigrateInstructionDataDecoder(): FixedSizeDecoder<MigrateInstructionData> {
|
|
183
|
+
return getStructDecoder([
|
|
184
|
+
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
185
|
+
]);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export function getMigrateInstructionDataCodec(): FixedSizeCodec<
|
|
189
|
+
MigrateInstructionDataArgs,
|
|
190
|
+
MigrateInstructionData
|
|
191
|
+
> {
|
|
192
|
+
return combineCodec(
|
|
193
|
+
getMigrateInstructionDataEncoder(),
|
|
194
|
+
getMigrateInstructionDataDecoder(),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export type MigrateAsyncInput<
|
|
199
|
+
TAccountCaller extends string = string,
|
|
200
|
+
TAccountBondingCurve extends string = string,
|
|
201
|
+
TAccountBaseMint extends string = string,
|
|
202
|
+
TAccountQuoteMint extends string = string,
|
|
203
|
+
TAccountBaseVault extends string = string,
|
|
204
|
+
TAccountQuoteVault extends string = string,
|
|
205
|
+
TAccountPool extends string = string,
|
|
206
|
+
TAccountLpMint extends string = string,
|
|
207
|
+
TAccountPoolBaseVault extends string = string,
|
|
208
|
+
TAccountPoolQuoteVault extends string = string,
|
|
209
|
+
TAccountPoolLpAccount extends string = string,
|
|
210
|
+
TAccountCreatorFeeConfig extends string = string,
|
|
211
|
+
TAccountQuoteTokenProgram extends string = string,
|
|
212
|
+
> = {
|
|
213
|
+
caller: TransactionSigner<TAccountCaller>;
|
|
214
|
+
bondingCurve?: Address<TAccountBondingCurve>;
|
|
215
|
+
baseMint: Address<TAccountBaseMint>;
|
|
216
|
+
quoteMint: Address<TAccountQuoteMint>;
|
|
217
|
+
baseVault?: Address<TAccountBaseVault>;
|
|
218
|
+
quoteVault?: Address<TAccountQuoteVault>;
|
|
219
|
+
pool?: Address<TAccountPool>;
|
|
220
|
+
lpMint?: Address<TAccountLpMint>;
|
|
221
|
+
poolBaseVault: Address<TAccountPoolBaseVault>;
|
|
222
|
+
poolQuoteVault: Address<TAccountPoolQuoteVault>;
|
|
223
|
+
poolLpAccount: Address<TAccountPoolLpAccount>;
|
|
224
|
+
creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
|
|
225
|
+
quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
export async function getMigrateInstructionAsync<
|
|
229
|
+
TAccountCaller extends string,
|
|
230
|
+
TAccountBondingCurve extends string,
|
|
231
|
+
TAccountBaseMint extends string,
|
|
232
|
+
TAccountQuoteMint extends string,
|
|
233
|
+
TAccountBaseVault extends string,
|
|
234
|
+
TAccountQuoteVault extends string,
|
|
235
|
+
TAccountPool extends string,
|
|
236
|
+
TAccountLpMint extends string,
|
|
237
|
+
TAccountPoolBaseVault extends string,
|
|
238
|
+
TAccountPoolQuoteVault extends string,
|
|
239
|
+
TAccountPoolLpAccount extends string,
|
|
240
|
+
TAccountCreatorFeeConfig extends string,
|
|
241
|
+
TAccountQuoteTokenProgram extends string,
|
|
242
|
+
>(
|
|
243
|
+
input: MigrateAsyncInput<
|
|
244
|
+
TAccountCaller,
|
|
245
|
+
TAccountBondingCurve,
|
|
246
|
+
TAccountBaseMint,
|
|
247
|
+
TAccountQuoteMint,
|
|
248
|
+
TAccountBaseVault,
|
|
249
|
+
TAccountQuoteVault,
|
|
250
|
+
TAccountPool,
|
|
251
|
+
TAccountLpMint,
|
|
252
|
+
TAccountPoolBaseVault,
|
|
253
|
+
TAccountPoolQuoteVault,
|
|
254
|
+
TAccountPoolLpAccount,
|
|
255
|
+
TAccountCreatorFeeConfig,
|
|
256
|
+
TAccountQuoteTokenProgram
|
|
257
|
+
>,
|
|
258
|
+
): Promise<
|
|
259
|
+
MigrateInstruction<
|
|
260
|
+
typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
261
|
+
TAccountCaller,
|
|
262
|
+
TAccountBondingCurve,
|
|
263
|
+
TAccountBaseMint,
|
|
264
|
+
TAccountQuoteMint,
|
|
265
|
+
TAccountBaseVault,
|
|
266
|
+
TAccountQuoteVault,
|
|
267
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX',
|
|
268
|
+
'932vp5VTARoqoAKNgLSawfCsAx43jUJ5YURggmXBX6V',
|
|
269
|
+
TAccountPool,
|
|
270
|
+
TAccountLpMint,
|
|
271
|
+
TAccountPoolBaseVault,
|
|
272
|
+
TAccountPoolQuoteVault,
|
|
273
|
+
TAccountPoolLpAccount,
|
|
274
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t',
|
|
275
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX',
|
|
276
|
+
TAccountCreatorFeeConfig,
|
|
277
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
278
|
+
TAccountQuoteTokenProgram,
|
|
279
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
280
|
+
'11111111111111111111111111111111',
|
|
281
|
+
'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
|
|
282
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
|
|
283
|
+
>
|
|
284
|
+
> {
|
|
285
|
+
// Program address.
|
|
286
|
+
const programAddress = SEND_LAUNCHPAD_PROGRAM_ADDRESS;
|
|
287
|
+
|
|
288
|
+
// Original accounts.
|
|
289
|
+
const originalAccounts = {
|
|
290
|
+
caller: { value: input.caller ?? null, isWritable: true },
|
|
291
|
+
bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
|
|
292
|
+
baseMint: { value: input.baseMint ?? null, isWritable: true },
|
|
293
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
294
|
+
baseVault: { value: input.baseVault ?? null, isWritable: true },
|
|
295
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: true },
|
|
296
|
+
dexProgram: { value: null, isWritable: false },
|
|
297
|
+
migrationAuthority: { value: null, isWritable: false },
|
|
298
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
299
|
+
lpMint: { value: input.lpMint ?? null, isWritable: true },
|
|
300
|
+
poolBaseVault: { value: input.poolBaseVault ?? null, isWritable: true },
|
|
301
|
+
poolQuoteVault: {
|
|
302
|
+
value: input.poolQuoteVault ?? null,
|
|
303
|
+
isWritable: true,
|
|
304
|
+
},
|
|
305
|
+
poolLpAccount: { value: input.poolLpAccount ?? null, isWritable: true },
|
|
306
|
+
dexEventAuthority: { value: null, isWritable: false },
|
|
307
|
+
nexusProgram: { value: null, isWritable: false },
|
|
308
|
+
creatorFeeConfig: {
|
|
309
|
+
value: input.creatorFeeConfig ?? null,
|
|
310
|
+
isWritable: false,
|
|
311
|
+
},
|
|
312
|
+
baseTokenProgram: { value: null, isWritable: false },
|
|
313
|
+
quoteTokenProgram: {
|
|
314
|
+
value: input.quoteTokenProgram ?? null,
|
|
315
|
+
isWritable: false,
|
|
316
|
+
},
|
|
317
|
+
associatedTokenProgram: { value: null, isWritable: false },
|
|
318
|
+
systemProgram: { value: null, isWritable: false },
|
|
319
|
+
eventAuthority: { value: null, isWritable: false },
|
|
320
|
+
program: { value: null, isWritable: false },
|
|
321
|
+
};
|
|
322
|
+
const accounts = originalAccounts as Record<
|
|
323
|
+
keyof typeof originalAccounts,
|
|
324
|
+
ResolvedInstructionAccount
|
|
325
|
+
>;
|
|
326
|
+
|
|
327
|
+
// Resolve default values.
|
|
328
|
+
if (!accounts.bondingCurve.value) {
|
|
329
|
+
accounts.bondingCurve.value = await findBondingCurvePda({
|
|
330
|
+
baseMint: getAddressFromResolvedInstructionAccount(
|
|
331
|
+
'baseMint',
|
|
332
|
+
accounts.baseMint.value,
|
|
333
|
+
),
|
|
334
|
+
quoteMint: getAddressFromResolvedInstructionAccount(
|
|
335
|
+
'quoteMint',
|
|
336
|
+
accounts.quoteMint.value,
|
|
337
|
+
),
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
if (!accounts.baseVault.value) {
|
|
341
|
+
accounts.baseVault.value = await getProgramDerivedAddress({
|
|
342
|
+
programAddress:
|
|
343
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>,
|
|
344
|
+
seeds: [
|
|
345
|
+
getAddressEncoder().encode(
|
|
346
|
+
getAddressFromResolvedInstructionAccount(
|
|
347
|
+
'bondingCurve',
|
|
348
|
+
accounts.bondingCurve.value,
|
|
349
|
+
),
|
|
350
|
+
),
|
|
351
|
+
getAddressEncoder().encode(
|
|
352
|
+
address('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'),
|
|
353
|
+
),
|
|
354
|
+
getAddressEncoder().encode(
|
|
355
|
+
getAddressFromResolvedInstructionAccount(
|
|
356
|
+
'baseMint',
|
|
357
|
+
accounts.baseMint.value,
|
|
358
|
+
),
|
|
359
|
+
),
|
|
360
|
+
],
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
if (!accounts.quoteVault.value) {
|
|
364
|
+
accounts.quoteVault.value = await getProgramDerivedAddress({
|
|
365
|
+
programAddress:
|
|
366
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>,
|
|
367
|
+
seeds: [
|
|
368
|
+
getAddressEncoder().encode(
|
|
369
|
+
getAddressFromResolvedInstructionAccount(
|
|
370
|
+
'bondingCurve',
|
|
371
|
+
accounts.bondingCurve.value,
|
|
372
|
+
),
|
|
373
|
+
),
|
|
374
|
+
getAddressEncoder().encode(
|
|
375
|
+
getAddressFromResolvedInstructionAccount(
|
|
376
|
+
'quoteTokenProgram',
|
|
377
|
+
accounts.quoteTokenProgram.value,
|
|
378
|
+
),
|
|
379
|
+
),
|
|
380
|
+
getAddressEncoder().encode(
|
|
381
|
+
getAddressFromResolvedInstructionAccount(
|
|
382
|
+
'quoteMint',
|
|
383
|
+
accounts.quoteMint.value,
|
|
384
|
+
),
|
|
385
|
+
),
|
|
386
|
+
],
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
if (!accounts.dexProgram.value) {
|
|
390
|
+
accounts.dexProgram.value =
|
|
391
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX' as Address<'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX'>;
|
|
392
|
+
}
|
|
393
|
+
if (!accounts.migrationAuthority.value) {
|
|
394
|
+
accounts.migrationAuthority.value = MIGRATION_AUTHORITY_PDA_ADDRESS;
|
|
395
|
+
}
|
|
396
|
+
if (!accounts.pool.value) {
|
|
397
|
+
accounts.pool.value = await getProgramDerivedAddress({
|
|
398
|
+
programAddress:
|
|
399
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX' as Address<'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX'>,
|
|
400
|
+
seeds: [
|
|
401
|
+
getBytesEncoder().encode(new Uint8Array([112, 111, 111, 108])),
|
|
402
|
+
getAddressEncoder().encode(
|
|
403
|
+
getAddressFromResolvedInstructionAccount(
|
|
404
|
+
'baseMint',
|
|
405
|
+
accounts.baseMint.value,
|
|
406
|
+
),
|
|
407
|
+
),
|
|
408
|
+
getAddressEncoder().encode(
|
|
409
|
+
getAddressFromResolvedInstructionAccount(
|
|
410
|
+
'quoteMint',
|
|
411
|
+
accounts.quoteMint.value,
|
|
412
|
+
),
|
|
413
|
+
),
|
|
414
|
+
],
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
if (!accounts.lpMint.value) {
|
|
418
|
+
accounts.lpMint.value = await getProgramDerivedAddress({
|
|
419
|
+
programAddress:
|
|
420
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX' as Address<'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX'>,
|
|
421
|
+
seeds: [
|
|
422
|
+
getBytesEncoder().encode(
|
|
423
|
+
new Uint8Array([108, 112, 95, 109, 105, 110, 116]),
|
|
424
|
+
),
|
|
425
|
+
getAddressEncoder().encode(
|
|
426
|
+
getAddressFromResolvedInstructionAccount(
|
|
427
|
+
'baseMint',
|
|
428
|
+
accounts.baseMint.value,
|
|
429
|
+
),
|
|
430
|
+
),
|
|
431
|
+
getAddressEncoder().encode(
|
|
432
|
+
getAddressFromResolvedInstructionAccount(
|
|
433
|
+
'quoteMint',
|
|
434
|
+
accounts.quoteMint.value,
|
|
435
|
+
),
|
|
436
|
+
),
|
|
437
|
+
],
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
if (!accounts.dexEventAuthority.value) {
|
|
441
|
+
accounts.dexEventAuthority.value =
|
|
442
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t' as Address<'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t'>;
|
|
443
|
+
}
|
|
444
|
+
if (!accounts.nexusProgram.value) {
|
|
445
|
+
accounts.nexusProgram.value =
|
|
446
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX' as Address<'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX'>;
|
|
447
|
+
}
|
|
448
|
+
if (!accounts.baseTokenProgram.value) {
|
|
449
|
+
accounts.baseTokenProgram.value =
|
|
450
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' as Address<'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'>;
|
|
451
|
+
}
|
|
452
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
453
|
+
accounts.associatedTokenProgram.value =
|
|
454
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>;
|
|
455
|
+
}
|
|
456
|
+
if (!accounts.systemProgram.value) {
|
|
457
|
+
accounts.systemProgram.value =
|
|
458
|
+
'11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
459
|
+
}
|
|
460
|
+
if (!accounts.eventAuthority.value) {
|
|
461
|
+
accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS;
|
|
462
|
+
}
|
|
463
|
+
if (!accounts.program.value) {
|
|
464
|
+
accounts.program.value =
|
|
465
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
469
|
+
return Object.freeze({
|
|
470
|
+
accounts: [
|
|
471
|
+
getAccountMeta('caller', accounts.caller),
|
|
472
|
+
getAccountMeta('bondingCurve', accounts.bondingCurve),
|
|
473
|
+
getAccountMeta('baseMint', accounts.baseMint),
|
|
474
|
+
getAccountMeta('quoteMint', accounts.quoteMint),
|
|
475
|
+
getAccountMeta('baseVault', accounts.baseVault),
|
|
476
|
+
getAccountMeta('quoteVault', accounts.quoteVault),
|
|
477
|
+
getAccountMeta('dexProgram', accounts.dexProgram),
|
|
478
|
+
getAccountMeta('migrationAuthority', accounts.migrationAuthority),
|
|
479
|
+
getAccountMeta('pool', accounts.pool),
|
|
480
|
+
getAccountMeta('lpMint', accounts.lpMint),
|
|
481
|
+
getAccountMeta('poolBaseVault', accounts.poolBaseVault),
|
|
482
|
+
getAccountMeta('poolQuoteVault', accounts.poolQuoteVault),
|
|
483
|
+
getAccountMeta('poolLpAccount', accounts.poolLpAccount),
|
|
484
|
+
getAccountMeta('dexEventAuthority', accounts.dexEventAuthority),
|
|
485
|
+
getAccountMeta('nexusProgram', accounts.nexusProgram),
|
|
486
|
+
getAccountMeta('creatorFeeConfig', accounts.creatorFeeConfig),
|
|
487
|
+
getAccountMeta('baseTokenProgram', accounts.baseTokenProgram),
|
|
488
|
+
getAccountMeta('quoteTokenProgram', accounts.quoteTokenProgram),
|
|
489
|
+
getAccountMeta(
|
|
490
|
+
'associatedTokenProgram',
|
|
491
|
+
accounts.associatedTokenProgram,
|
|
492
|
+
),
|
|
493
|
+
getAccountMeta('systemProgram', accounts.systemProgram),
|
|
494
|
+
getAccountMeta('eventAuthority', accounts.eventAuthority),
|
|
495
|
+
getAccountMeta('program', accounts.program),
|
|
496
|
+
],
|
|
497
|
+
data: getMigrateInstructionDataEncoder().encode({}),
|
|
498
|
+
programAddress,
|
|
499
|
+
} as MigrateInstruction<
|
|
500
|
+
typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
501
|
+
TAccountCaller,
|
|
502
|
+
TAccountBondingCurve,
|
|
503
|
+
TAccountBaseMint,
|
|
504
|
+
TAccountQuoteMint,
|
|
505
|
+
TAccountBaseVault,
|
|
506
|
+
TAccountQuoteVault,
|
|
507
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX',
|
|
508
|
+
'932vp5VTARoqoAKNgLSawfCsAx43jUJ5YURggmXBX6V',
|
|
509
|
+
TAccountPool,
|
|
510
|
+
TAccountLpMint,
|
|
511
|
+
TAccountPoolBaseVault,
|
|
512
|
+
TAccountPoolQuoteVault,
|
|
513
|
+
TAccountPoolLpAccount,
|
|
514
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t',
|
|
515
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX',
|
|
516
|
+
TAccountCreatorFeeConfig,
|
|
517
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
518
|
+
TAccountQuoteTokenProgram,
|
|
519
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
520
|
+
'11111111111111111111111111111111',
|
|
521
|
+
'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
|
|
522
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
|
|
523
|
+
>);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
export type MigrateInput<
|
|
527
|
+
TAccountCaller extends string = string,
|
|
528
|
+
TAccountBondingCurve extends string = string,
|
|
529
|
+
TAccountBaseMint extends string = string,
|
|
530
|
+
TAccountQuoteMint extends string = string,
|
|
531
|
+
TAccountBaseVault extends string = string,
|
|
532
|
+
TAccountQuoteVault extends string = string,
|
|
533
|
+
TAccountPool extends string = string,
|
|
534
|
+
TAccountLpMint extends string = string,
|
|
535
|
+
TAccountPoolBaseVault extends string = string,
|
|
536
|
+
TAccountPoolQuoteVault extends string = string,
|
|
537
|
+
TAccountPoolLpAccount extends string = string,
|
|
538
|
+
TAccountCreatorFeeConfig extends string = string,
|
|
539
|
+
TAccountQuoteTokenProgram extends string = string,
|
|
540
|
+
> = {
|
|
541
|
+
caller: TransactionSigner<TAccountCaller>;
|
|
542
|
+
bondingCurve: Address<TAccountBondingCurve>;
|
|
543
|
+
baseMint: Address<TAccountBaseMint>;
|
|
544
|
+
quoteMint: Address<TAccountQuoteMint>;
|
|
545
|
+
baseVault: Address<TAccountBaseVault>;
|
|
546
|
+
quoteVault: Address<TAccountQuoteVault>;
|
|
547
|
+
pool: Address<TAccountPool>;
|
|
548
|
+
lpMint: Address<TAccountLpMint>;
|
|
549
|
+
poolBaseVault: Address<TAccountPoolBaseVault>;
|
|
550
|
+
poolQuoteVault: Address<TAccountPoolQuoteVault>;
|
|
551
|
+
poolLpAccount: Address<TAccountPoolLpAccount>;
|
|
552
|
+
creatorFeeConfig: Address<TAccountCreatorFeeConfig>;
|
|
553
|
+
quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
|
|
554
|
+
};
|
|
555
|
+
|
|
556
|
+
export function getMigrateInstruction<
|
|
557
|
+
TAccountCaller extends string,
|
|
558
|
+
TAccountBondingCurve extends string,
|
|
559
|
+
TAccountBaseMint extends string,
|
|
560
|
+
TAccountQuoteMint extends string,
|
|
561
|
+
TAccountBaseVault extends string,
|
|
562
|
+
TAccountQuoteVault extends string,
|
|
563
|
+
TAccountPool extends string,
|
|
564
|
+
TAccountLpMint extends string,
|
|
565
|
+
TAccountPoolBaseVault extends string,
|
|
566
|
+
TAccountPoolQuoteVault extends string,
|
|
567
|
+
TAccountPoolLpAccount extends string,
|
|
568
|
+
TAccountCreatorFeeConfig extends string,
|
|
569
|
+
TAccountQuoteTokenProgram extends string,
|
|
570
|
+
>(
|
|
571
|
+
input: MigrateInput<
|
|
572
|
+
TAccountCaller,
|
|
573
|
+
TAccountBondingCurve,
|
|
574
|
+
TAccountBaseMint,
|
|
575
|
+
TAccountQuoteMint,
|
|
576
|
+
TAccountBaseVault,
|
|
577
|
+
TAccountQuoteVault,
|
|
578
|
+
TAccountPool,
|
|
579
|
+
TAccountLpMint,
|
|
580
|
+
TAccountPoolBaseVault,
|
|
581
|
+
TAccountPoolQuoteVault,
|
|
582
|
+
TAccountPoolLpAccount,
|
|
583
|
+
TAccountCreatorFeeConfig,
|
|
584
|
+
TAccountQuoteTokenProgram
|
|
585
|
+
>,
|
|
586
|
+
): MigrateInstruction<
|
|
587
|
+
typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
588
|
+
TAccountCaller,
|
|
589
|
+
TAccountBondingCurve,
|
|
590
|
+
TAccountBaseMint,
|
|
591
|
+
TAccountQuoteMint,
|
|
592
|
+
TAccountBaseVault,
|
|
593
|
+
TAccountQuoteVault,
|
|
594
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX',
|
|
595
|
+
'932vp5VTARoqoAKNgLSawfCsAx43jUJ5YURggmXBX6V',
|
|
596
|
+
TAccountPool,
|
|
597
|
+
TAccountLpMint,
|
|
598
|
+
TAccountPoolBaseVault,
|
|
599
|
+
TAccountPoolQuoteVault,
|
|
600
|
+
TAccountPoolLpAccount,
|
|
601
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t',
|
|
602
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX',
|
|
603
|
+
TAccountCreatorFeeConfig,
|
|
604
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
605
|
+
TAccountQuoteTokenProgram,
|
|
606
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
607
|
+
'11111111111111111111111111111111',
|
|
608
|
+
'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
|
|
609
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
|
|
610
|
+
> {
|
|
611
|
+
// Program address.
|
|
612
|
+
const programAddress = SEND_LAUNCHPAD_PROGRAM_ADDRESS;
|
|
613
|
+
|
|
614
|
+
// Original accounts.
|
|
615
|
+
const originalAccounts = {
|
|
616
|
+
caller: { value: input.caller ?? null, isWritable: true },
|
|
617
|
+
bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
|
|
618
|
+
baseMint: { value: input.baseMint ?? null, isWritable: true },
|
|
619
|
+
quoteMint: { value: input.quoteMint ?? null, isWritable: false },
|
|
620
|
+
baseVault: { value: input.baseVault ?? null, isWritable: true },
|
|
621
|
+
quoteVault: { value: input.quoteVault ?? null, isWritable: true },
|
|
622
|
+
dexProgram: { value: null, isWritable: false },
|
|
623
|
+
migrationAuthority: { value: null, isWritable: false },
|
|
624
|
+
pool: { value: input.pool ?? null, isWritable: true },
|
|
625
|
+
lpMint: { value: input.lpMint ?? null, isWritable: true },
|
|
626
|
+
poolBaseVault: { value: input.poolBaseVault ?? null, isWritable: true },
|
|
627
|
+
poolQuoteVault: {
|
|
628
|
+
value: input.poolQuoteVault ?? null,
|
|
629
|
+
isWritable: true,
|
|
630
|
+
},
|
|
631
|
+
poolLpAccount: { value: input.poolLpAccount ?? null, isWritable: true },
|
|
632
|
+
dexEventAuthority: { value: null, isWritable: false },
|
|
633
|
+
nexusProgram: { value: null, isWritable: false },
|
|
634
|
+
creatorFeeConfig: {
|
|
635
|
+
value: input.creatorFeeConfig ?? null,
|
|
636
|
+
isWritable: false,
|
|
637
|
+
},
|
|
638
|
+
baseTokenProgram: { value: null, isWritable: false },
|
|
639
|
+
quoteTokenProgram: {
|
|
640
|
+
value: input.quoteTokenProgram ?? null,
|
|
641
|
+
isWritable: false,
|
|
642
|
+
},
|
|
643
|
+
associatedTokenProgram: { value: null, isWritable: false },
|
|
644
|
+
systemProgram: { value: null, isWritable: false },
|
|
645
|
+
eventAuthority: { value: null, isWritable: false },
|
|
646
|
+
program: { value: null, isWritable: false },
|
|
647
|
+
};
|
|
648
|
+
const accounts = originalAccounts as Record<
|
|
649
|
+
keyof typeof originalAccounts,
|
|
650
|
+
ResolvedInstructionAccount
|
|
651
|
+
>;
|
|
652
|
+
|
|
653
|
+
// Resolve default values.
|
|
654
|
+
if (!accounts.dexProgram.value) {
|
|
655
|
+
accounts.dexProgram.value =
|
|
656
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX' as Address<'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX'>;
|
|
657
|
+
}
|
|
658
|
+
if (!accounts.migrationAuthority.value) {
|
|
659
|
+
accounts.migrationAuthority.value = MIGRATION_AUTHORITY_PDA_ADDRESS;
|
|
660
|
+
}
|
|
661
|
+
if (!accounts.dexEventAuthority.value) {
|
|
662
|
+
accounts.dexEventAuthority.value =
|
|
663
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t' as Address<'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t'>;
|
|
664
|
+
}
|
|
665
|
+
if (!accounts.nexusProgram.value) {
|
|
666
|
+
accounts.nexusProgram.value =
|
|
667
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX' as Address<'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX'>;
|
|
668
|
+
}
|
|
669
|
+
if (!accounts.baseTokenProgram.value) {
|
|
670
|
+
accounts.baseTokenProgram.value =
|
|
671
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb' as Address<'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb'>;
|
|
672
|
+
}
|
|
673
|
+
if (!accounts.associatedTokenProgram.value) {
|
|
674
|
+
accounts.associatedTokenProgram.value =
|
|
675
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL' as Address<'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'>;
|
|
676
|
+
}
|
|
677
|
+
if (!accounts.systemProgram.value) {
|
|
678
|
+
accounts.systemProgram.value =
|
|
679
|
+
'11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
680
|
+
}
|
|
681
|
+
if (!accounts.eventAuthority.value) {
|
|
682
|
+
accounts.eventAuthority.value = EVENT_AUTHORITY_PDA_ADDRESS;
|
|
683
|
+
}
|
|
684
|
+
if (!accounts.program.value) {
|
|
685
|
+
accounts.program.value =
|
|
686
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
690
|
+
return Object.freeze({
|
|
691
|
+
accounts: [
|
|
692
|
+
getAccountMeta('caller', accounts.caller),
|
|
693
|
+
getAccountMeta('bondingCurve', accounts.bondingCurve),
|
|
694
|
+
getAccountMeta('baseMint', accounts.baseMint),
|
|
695
|
+
getAccountMeta('quoteMint', accounts.quoteMint),
|
|
696
|
+
getAccountMeta('baseVault', accounts.baseVault),
|
|
697
|
+
getAccountMeta('quoteVault', accounts.quoteVault),
|
|
698
|
+
getAccountMeta('dexProgram', accounts.dexProgram),
|
|
699
|
+
getAccountMeta('migrationAuthority', accounts.migrationAuthority),
|
|
700
|
+
getAccountMeta('pool', accounts.pool),
|
|
701
|
+
getAccountMeta('lpMint', accounts.lpMint),
|
|
702
|
+
getAccountMeta('poolBaseVault', accounts.poolBaseVault),
|
|
703
|
+
getAccountMeta('poolQuoteVault', accounts.poolQuoteVault),
|
|
704
|
+
getAccountMeta('poolLpAccount', accounts.poolLpAccount),
|
|
705
|
+
getAccountMeta('dexEventAuthority', accounts.dexEventAuthority),
|
|
706
|
+
getAccountMeta('nexusProgram', accounts.nexusProgram),
|
|
707
|
+
getAccountMeta('creatorFeeConfig', accounts.creatorFeeConfig),
|
|
708
|
+
getAccountMeta('baseTokenProgram', accounts.baseTokenProgram),
|
|
709
|
+
getAccountMeta('quoteTokenProgram', accounts.quoteTokenProgram),
|
|
710
|
+
getAccountMeta(
|
|
711
|
+
'associatedTokenProgram',
|
|
712
|
+
accounts.associatedTokenProgram,
|
|
713
|
+
),
|
|
714
|
+
getAccountMeta('systemProgram', accounts.systemProgram),
|
|
715
|
+
getAccountMeta('eventAuthority', accounts.eventAuthority),
|
|
716
|
+
getAccountMeta('program', accounts.program),
|
|
717
|
+
],
|
|
718
|
+
data: getMigrateInstructionDataEncoder().encode({}),
|
|
719
|
+
programAddress,
|
|
720
|
+
} as MigrateInstruction<
|
|
721
|
+
typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
722
|
+
TAccountCaller,
|
|
723
|
+
TAccountBondingCurve,
|
|
724
|
+
TAccountBaseMint,
|
|
725
|
+
TAccountQuoteMint,
|
|
726
|
+
TAccountBaseVault,
|
|
727
|
+
TAccountQuoteVault,
|
|
728
|
+
'84qj5FPZZdXkQy8mfowyg6RBZ3XKuTds6XS4ZYT1sfDX',
|
|
729
|
+
'932vp5VTARoqoAKNgLSawfCsAx43jUJ5YURggmXBX6V',
|
|
730
|
+
TAccountPool,
|
|
731
|
+
TAccountLpMint,
|
|
732
|
+
TAccountPoolBaseVault,
|
|
733
|
+
TAccountPoolQuoteVault,
|
|
734
|
+
TAccountPoolLpAccount,
|
|
735
|
+
'4pTDYKRFdmxTQYFceGZkzPGd3kb8ShMA9n6XKRaPZn8t',
|
|
736
|
+
'7rrCurqdWFesbzwtYPo95fM8waTtVXgXwCom45x1sfNX',
|
|
737
|
+
TAccountCreatorFeeConfig,
|
|
738
|
+
'TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb',
|
|
739
|
+
TAccountQuoteTokenProgram,
|
|
740
|
+
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL',
|
|
741
|
+
'11111111111111111111111111111111',
|
|
742
|
+
'FJVebqCthxH6JM8vvkJb7yRYA7Emsib1C1vu4ZePSP3T',
|
|
743
|
+
'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'
|
|
744
|
+
>);
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
export type ParsedMigrateInstruction<
|
|
748
|
+
TProgram extends string = typeof SEND_LAUNCHPAD_PROGRAM_ADDRESS,
|
|
749
|
+
TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[],
|
|
750
|
+
> = {
|
|
751
|
+
programAddress: Address<TProgram>;
|
|
752
|
+
accounts: {
|
|
753
|
+
caller: TAccountMetas[0];
|
|
754
|
+
bondingCurve: TAccountMetas[1];
|
|
755
|
+
baseMint: TAccountMetas[2];
|
|
756
|
+
quoteMint: TAccountMetas[3];
|
|
757
|
+
baseVault: TAccountMetas[4];
|
|
758
|
+
quoteVault: TAccountMetas[5];
|
|
759
|
+
dexProgram: TAccountMetas[6];
|
|
760
|
+
migrationAuthority: TAccountMetas[7];
|
|
761
|
+
pool: TAccountMetas[8];
|
|
762
|
+
lpMint: TAccountMetas[9];
|
|
763
|
+
poolBaseVault: TAccountMetas[10];
|
|
764
|
+
poolQuoteVault: TAccountMetas[11];
|
|
765
|
+
poolLpAccount: TAccountMetas[12];
|
|
766
|
+
dexEventAuthority: TAccountMetas[13];
|
|
767
|
+
nexusProgram: TAccountMetas[14];
|
|
768
|
+
creatorFeeConfig: TAccountMetas[15];
|
|
769
|
+
baseTokenProgram: TAccountMetas[16];
|
|
770
|
+
quoteTokenProgram: TAccountMetas[17];
|
|
771
|
+
associatedTokenProgram: TAccountMetas[18];
|
|
772
|
+
systemProgram: TAccountMetas[19];
|
|
773
|
+
eventAuthority: TAccountMetas[20];
|
|
774
|
+
program: TAccountMetas[21];
|
|
775
|
+
};
|
|
776
|
+
data: MigrateInstructionData;
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
export function parseMigrateInstruction<
|
|
780
|
+
TProgram extends string,
|
|
781
|
+
TAccountMetas extends readonly AccountMeta[],
|
|
782
|
+
>(
|
|
783
|
+
instruction: Instruction<TProgram> &
|
|
784
|
+
InstructionWithAccounts<TAccountMetas> &
|
|
785
|
+
InstructionWithData<ReadonlyUint8Array>,
|
|
786
|
+
): ParsedMigrateInstruction<TProgram, TAccountMetas> {
|
|
787
|
+
assertIsInstructionForProgram(instruction, SEND_LAUNCHPAD_PROGRAM_ADDRESS);
|
|
788
|
+
if (!containsBytes(instruction.data, MIGRATE_DISCRIMINATOR, 0)) {
|
|
789
|
+
const error = new Error(
|
|
790
|
+
`parseMigrateInstruction: instruction data does not match the Migrate discriminator`,
|
|
791
|
+
);
|
|
792
|
+
error.name = 'InstructionDiscriminatorMismatchError';
|
|
793
|
+
throw error;
|
|
794
|
+
}
|
|
795
|
+
if (instruction.accounts.length < 22) {
|
|
796
|
+
throw new SolanaError(
|
|
797
|
+
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
798
|
+
{
|
|
799
|
+
actualAccountMetas: instruction.accounts.length,
|
|
800
|
+
expectedAccountMetas: 22,
|
|
801
|
+
},
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
let accountIndex = 0;
|
|
805
|
+
const getNextAccount = () => {
|
|
806
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[
|
|
807
|
+
accountIndex
|
|
808
|
+
]!;
|
|
809
|
+
accountIndex += 1;
|
|
810
|
+
return accountMeta;
|
|
811
|
+
};
|
|
812
|
+
return {
|
|
813
|
+
programAddress: instruction.programAddress,
|
|
814
|
+
accounts: {
|
|
815
|
+
caller: getNextAccount(),
|
|
816
|
+
bondingCurve: getNextAccount(),
|
|
817
|
+
baseMint: getNextAccount(),
|
|
818
|
+
quoteMint: getNextAccount(),
|
|
819
|
+
baseVault: getNextAccount(),
|
|
820
|
+
quoteVault: getNextAccount(),
|
|
821
|
+
dexProgram: getNextAccount(),
|
|
822
|
+
migrationAuthority: getNextAccount(),
|
|
823
|
+
pool: getNextAccount(),
|
|
824
|
+
lpMint: getNextAccount(),
|
|
825
|
+
poolBaseVault: getNextAccount(),
|
|
826
|
+
poolQuoteVault: getNextAccount(),
|
|
827
|
+
poolLpAccount: getNextAccount(),
|
|
828
|
+
dexEventAuthority: getNextAccount(),
|
|
829
|
+
nexusProgram: getNextAccount(),
|
|
830
|
+
creatorFeeConfig: getNextAccount(),
|
|
831
|
+
baseTokenProgram: getNextAccount(),
|
|
832
|
+
quoteTokenProgram: getNextAccount(),
|
|
833
|
+
associatedTokenProgram: getNextAccount(),
|
|
834
|
+
systemProgram: getNextAccount(),
|
|
835
|
+
eventAuthority: getNextAccount(),
|
|
836
|
+
program: getNextAccount(),
|
|
837
|
+
},
|
|
838
|
+
data: getMigrateInstructionDataDecoder().decode(instruction.data),
|
|
839
|
+
};
|
|
840
|
+
}
|