@send-fun/sdk 1.1.0 → 2.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/README.md +8 -9
- package/dist/index.cjs +777 -433
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +678 -217
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +678 -217
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +777 -433
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/dex/generated/accounts/globalConfig.ts +39 -2
- package/src/dex/generated/accounts/pool.ts +60 -9
- package/src/dex/generated/accounts/rewardAccrual.ts +39 -2
- package/src/dex/generated/errors/sendDex.ts +16 -8
- package/src/dex/generated/events/creatorClaimEvent.ts +3 -2
- package/src/dex/generated/events/poolCreateEvent.ts +8 -2
- package/src/dex/generated/events/tokenCreateEvent.ts +8 -9
- package/src/dex/generated/events/tradeEvent.ts +9 -2
- package/src/dex/generated/index.ts +1 -0
- package/src/dex/generated/instructions/claimCreatorFees.ts +21 -5
- package/src/{nexus → dex}/generated/pdas/creatorFeeConfig.ts +6 -6
- package/src/dex/generated/pdas/index.ts +1 -0
- package/src/dex/generated/plugins/sendDex.ts +3 -0
- package/src/dex/generated/shared/index.ts +52 -0
- package/src/dex/trade.ts +12 -13
- package/src/launchpad/create.ts +13 -38
- package/src/launchpad/generated/accounts/bondingCurve.ts +62 -9
- package/src/launchpad/generated/accounts/globalConfig.ts +39 -2
- package/src/launchpad/generated/accounts/rewardAccrual.ts +39 -2
- package/src/launchpad/generated/errors/sendLaunchpad.ts +12 -4
- package/src/launchpad/generated/events/completeEvent.ts +3 -2
- package/src/launchpad/generated/events/creatorClaimEvent.ts +3 -2
- package/src/launchpad/generated/events/migrateEvent.ts +3 -2
- package/src/launchpad/generated/events/tokenCreateEvent.ts +10 -9
- package/src/launchpad/generated/events/tradeEvent.ts +9 -2
- package/src/launchpad/generated/index.ts +1 -0
- package/src/launchpad/generated/instructions/claimCreatorFees.ts +17 -4
- package/src/launchpad/generated/instructions/createToken.ts +32 -50
- package/src/launchpad/generated/instructions/migrate.ts +79 -12
- package/src/launchpad/generated/pdas/creatorFeeConfig.ts +39 -0
- package/src/launchpad/generated/pdas/index.ts +1 -0
- package/src/launchpad/generated/plugins/sendLaunchpad.ts +3 -0
- package/src/launchpad/generated/shared/index.ts +52 -0
- package/src/launchpad/migrate.ts +7 -4
- package/src/launchpad/trade.ts +15 -15
- package/src/math/amm.ts +40 -33
- package/src/math/fee-decay.ts +3 -2
- package/src/math/fees.ts +4 -2
- package/src/math/internal.ts +1 -1
- package/src/nexus/fee-helpers.ts +10 -5
- package/src/nexus/generated/accounts/altRegistry.ts +41 -2
- package/src/nexus/generated/accounts/feePreset.ts +43 -4
- package/src/nexus/generated/accounts/globalConfig.ts +39 -2
- package/src/nexus/generated/accounts/index.ts +0 -1
- package/src/nexus/generated/accounts/partnerConfig.ts +48 -5
- package/src/nexus/generated/accounts/partnerMetadata.ts +39 -2
- package/src/nexus/generated/accounts/rewardState.ts +41 -2
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +0 -5
- package/src/nexus/generated/accounts/stakingConfig.ts +39 -2
- package/src/nexus/generated/accounts/userRewardDebt.ts +42 -5
- package/src/nexus/generated/accounts/userStakePosition.ts +42 -5
- package/src/nexus/generated/errors/sendNexus.ts +12 -4
- package/src/nexus/generated/index.ts +1 -0
- package/src/nexus/generated/pdas/index.ts +0 -1
- package/src/nexus/generated/plugins/sendNexus.ts +0 -35
- package/src/nexus/generated/shared/index.ts +52 -0
- package/src/nexus/generated/types/dexFees.ts +4 -4
- package/src/nexus/generated/types/index.ts +0 -1
- package/src/nexus/generated/types/launchpadFees.ts +4 -4
- package/src/nexus/staking.ts +45 -41
- package/src/platform.ts +2 -2
- package/src/transfer-fee.ts +19 -17
- package/src/utils/chunk.ts +1 -1
- package/src/utils/index.ts +2 -5
- package/src/utils/mint-info.ts +8 -7
- package/src/utils/partner.ts +1 -1
- package/src/utils/pda.ts +1 -1
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +0 -200
- package/src/nexus/generated/types/callerType.ts +0 -38
- package/src/utils/creator-hash.ts +0 -57
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
type ReadonlyUint8Array,
|
|
43
43
|
} from '@solana/kit';
|
|
44
44
|
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
45
|
+
import { accountIsCreated } from '../shared/index.js';
|
|
45
46
|
|
|
46
47
|
export const REWARD_ACCRUAL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
47
48
|
158, 244, 116, 30, 227, 132, 105, 182,
|
|
@@ -109,9 +110,25 @@ export function getRewardAccrualCodec(): FixedSizeCodec<
|
|
|
109
110
|
return combineCodec(getRewardAccrualEncoder(), getRewardAccrualDecoder());
|
|
110
111
|
}
|
|
111
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Decodes a `RewardAccrual` account, throwing when another program owns it or its discriminator
|
|
115
|
+
* does not match.
|
|
116
|
+
*
|
|
117
|
+
* Unlike {@link fetchMaybeRewardAccrual}, this throws for an address that only holds lamports rather
|
|
118
|
+
* than returning the non-existing variant: an account passed as existing must never come back as that
|
|
119
|
+
* variant typed as an `Account`. Apply {@link accountIsCreated} first to accounts fetched another way.
|
|
120
|
+
*/
|
|
112
121
|
export function decodeRewardAccrual<TAddress extends string = string>(
|
|
113
122
|
encodedAccount: EncodedAccount<TAddress>,
|
|
114
123
|
): Account<RewardAccrual, TAddress>;
|
|
124
|
+
/**
|
|
125
|
+
* Decodes a `RewardAccrual` account, throwing when another program owns it or its discriminator
|
|
126
|
+
* does not match.
|
|
127
|
+
*
|
|
128
|
+
* Unlike {@link fetchMaybeRewardAccrual}, this throws for an address that only holds lamports rather
|
|
129
|
+
* than returning the non-existing variant: an account passed as existing must never come back as that
|
|
130
|
+
* variant typed as an `Account`. Apply {@link accountIsCreated} first to accounts fetched another way.
|
|
131
|
+
*/
|
|
115
132
|
export function decodeRewardAccrual<TAddress extends string = string>(
|
|
116
133
|
encodedAccount: MaybeEncodedAccount<TAddress>,
|
|
117
134
|
): MaybeAccount<RewardAccrual, TAddress>;
|
|
@@ -142,6 +159,7 @@ export function decodeRewardAccrual<TAddress extends string = string>(
|
|
|
142
159
|
);
|
|
143
160
|
}
|
|
144
161
|
|
|
162
|
+
/** Fetches a `RewardAccrual` account, throwing when it does not exist or only holds lamports. */
|
|
145
163
|
export async function fetchRewardAccrual<TAddress extends string = string>(
|
|
146
164
|
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
147
165
|
address: Address<TAddress>,
|
|
@@ -152,15 +170,25 @@ export async function fetchRewardAccrual<TAddress extends string = string>(
|
|
|
152
170
|
return maybeAccount;
|
|
153
171
|
}
|
|
154
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Fetches a `RewardAccrual` account, or the non-existing variant when the address holds no
|
|
175
|
+
* account or only lamports (see {@link accountIsCreated}).
|
|
176
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
177
|
+
*/
|
|
155
178
|
export async function fetchMaybeRewardAccrual<TAddress extends string = string>(
|
|
156
179
|
rpc: Parameters<typeof fetchEncodedAccount>[0],
|
|
157
180
|
address: Address<TAddress>,
|
|
158
181
|
config?: FetchAccountConfig,
|
|
159
182
|
): Promise<MaybeAccount<RewardAccrual, TAddress>> {
|
|
160
183
|
const maybeAccount = await fetchEncodedAccount(rpc, address, config);
|
|
161
|
-
return decodeRewardAccrual(
|
|
184
|
+
return decodeRewardAccrual(
|
|
185
|
+
accountIsCreated(maybeAccount)
|
|
186
|
+
? maybeAccount
|
|
187
|
+
: { address, exists: false },
|
|
188
|
+
);
|
|
162
189
|
}
|
|
163
190
|
|
|
191
|
+
/** Fetches `RewardAccrual` accounts, throwing when any does not exist or only holds lamports. */
|
|
164
192
|
export async function fetchAllRewardAccrual(
|
|
165
193
|
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
166
194
|
addresses: Array<Address>,
|
|
@@ -175,6 +203,11 @@ export async function fetchAllRewardAccrual(
|
|
|
175
203
|
return maybeAccounts;
|
|
176
204
|
}
|
|
177
205
|
|
|
206
|
+
/**
|
|
207
|
+
* Fetches `RewardAccrual` accounts, with the non-existing variant for each address that holds
|
|
208
|
+
* no account or only lamports (see {@link accountIsCreated}).
|
|
209
|
+
* {@link decodeRewardAccrual} throws for a lamports-only account instead.
|
|
210
|
+
*/
|
|
178
211
|
export async function fetchAllMaybeRewardAccrual(
|
|
179
212
|
rpc: Parameters<typeof fetchEncodedAccounts>[0],
|
|
180
213
|
addresses: Array<Address>,
|
|
@@ -182,7 +215,11 @@ export async function fetchAllMaybeRewardAccrual(
|
|
|
182
215
|
): Promise<MaybeAccount<RewardAccrual>[]> {
|
|
183
216
|
const maybeAccounts = await fetchEncodedAccounts(rpc, addresses, config);
|
|
184
217
|
return maybeAccounts.map((maybeAccount) =>
|
|
185
|
-
decodeRewardAccrual(
|
|
218
|
+
decodeRewardAccrual(
|
|
219
|
+
accountIsCreated(maybeAccount)
|
|
220
|
+
? maybeAccount
|
|
221
|
+
: { address: maybeAccount.address, exists: false },
|
|
222
|
+
),
|
|
186
223
|
);
|
|
187
224
|
}
|
|
188
225
|
|
|
@@ -70,12 +70,16 @@ export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 0x1b61; // 70
|
|
|
70
70
|
export const SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 0x1b62; // 7010
|
|
71
71
|
/** NothingToClaim: Nothing to claim */
|
|
72
72
|
export const SEND_LAUNCHPAD_ERROR__NOTHING_TO_CLAIM = 0x1b63; // 7011
|
|
73
|
-
/**
|
|
74
|
-
export const
|
|
73
|
+
/** Unused7012: Unused */
|
|
74
|
+
export const SEND_LAUNCHPAD_ERROR__UNUSED7012 = 0x1b64; // 7012
|
|
75
75
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
76
76
|
export const SEND_LAUNCHPAD_ERROR__QUOTE_MINT_PRICE_UNSET = 0x1b65; // 7013
|
|
77
77
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
78
78
|
export const SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 0x1b66; // 7014
|
|
79
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
80
|
+
export const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH = 0x1b67; // 7015
|
|
81
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
82
|
+
export const SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 0x1b68; // 7016
|
|
79
83
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
80
84
|
export const SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY = 0x1bbc; // 7100
|
|
81
85
|
/** InvalidAmount: Invalid amount */
|
|
@@ -86,6 +90,8 @@ export type SendLaunchpadError =
|
|
|
86
90
|
| typeof SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW
|
|
87
91
|
| typeof SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND
|
|
88
92
|
| typeof SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY
|
|
93
|
+
| typeof SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED
|
|
94
|
+
| typeof SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH
|
|
89
95
|
| typeof SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE
|
|
90
96
|
| typeof SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE
|
|
91
97
|
| typeof SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY
|
|
@@ -93,7 +99,6 @@ export type SendLaunchpadError =
|
|
|
93
99
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY
|
|
94
100
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT
|
|
95
101
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_COIN_CREATOR
|
|
96
|
-
| typeof SEND_LAUNCHPAD_ERROR__INVALID_CREATOR_ID
|
|
97
102
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT
|
|
98
103
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED
|
|
99
104
|
| typeof SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT
|
|
@@ -111,6 +116,7 @@ export type SendLaunchpadError =
|
|
|
111
116
|
| typeof SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED
|
|
112
117
|
| typeof SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE
|
|
113
118
|
| typeof SEND_LAUNCHPAD_ERROR__UNAUTHORIZED
|
|
119
|
+
| typeof SEND_LAUNCHPAD_ERROR__UNUSED7012
|
|
114
120
|
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID
|
|
115
121
|
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY
|
|
116
122
|
| typeof SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT
|
|
@@ -121,6 +127,8 @@ export const sendLaunchpadErrorMessages: Record<SendLaunchpadError, string> = {
|
|
|
121
127
|
[SEND_LAUNCHPAD_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
122
128
|
[SEND_LAUNCHPAD_ERROR__BASE_MINT_NOT_FOUND]: `Base mint not found`,
|
|
123
129
|
[SEND_LAUNCHPAD_ERROR__BLOCKED_BY_HELD_SUPPLY]: `Blocked by held supply`,
|
|
130
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
131
|
+
[SEND_LAUNCHPAD_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
124
132
|
[SEND_LAUNCHPAD_ERROR__CURVE_IS_LIVE]: `Curve is live`,
|
|
125
133
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
126
134
|
[SEND_LAUNCHPAD_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
@@ -128,7 +136,6 @@ export const sendLaunchpadErrorMessages: Record<SendLaunchpadError, string> = {
|
|
|
128
136
|
[SEND_LAUNCHPAD_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
129
137
|
[SEND_LAUNCHPAD_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
130
138
|
[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
139
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_ACCOUNT]: `Invalid Pyth price account`,
|
|
133
140
|
[SEND_LAUNCHPAD_ERROR__INVALID_PYTH_FEED]: `Invalid Pyth feed ID`,
|
|
134
141
|
[SEND_LAUNCHPAD_ERROR__INVALID_QUOTE_MINT]: `Invalid quote mint`,
|
|
@@ -146,6 +153,7 @@ export const sendLaunchpadErrorMessages: Record<SendLaunchpadError, string> = {
|
|
|
146
153
|
[SEND_LAUNCHPAD_ERROR__TOKEN_CREATION_DISABLED]: `Token creation is disabled`,
|
|
147
154
|
[SEND_LAUNCHPAD_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
148
155
|
[SEND_LAUNCHPAD_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
156
|
+
[SEND_LAUNCHPAD_ERROR__UNUSED7012]: `Unused`,
|
|
149
157
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
150
158
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
151
159
|
[SEND_LAUNCHPAD_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT]: `User token account mint does not match the trade`,
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
containsBytes,
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getAddressDecoder,
|
|
13
|
+
getArrayDecoder,
|
|
13
14
|
getBooleanDecoder,
|
|
14
15
|
getBytesEncoder,
|
|
15
16
|
getI64Decoder,
|
|
@@ -37,7 +38,7 @@ export type CompleteEvent = {
|
|
|
37
38
|
baseMint: Address;
|
|
38
39
|
quoteMint: Address;
|
|
39
40
|
coinCreator: Address;
|
|
40
|
-
|
|
41
|
+
padding0: Array<bigint>;
|
|
41
42
|
platformConfig: Address;
|
|
42
43
|
curvePartner: Address;
|
|
43
44
|
isPartner: boolean;
|
|
@@ -53,7 +54,7 @@ export function getCompleteEventDecoder(): FixedSizeDecoder<CompleteEvent> {
|
|
|
53
54
|
['baseMint', getAddressDecoder()],
|
|
54
55
|
['quoteMint', getAddressDecoder()],
|
|
55
56
|
['coinCreator', getAddressDecoder()],
|
|
56
|
-
['
|
|
57
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
57
58
|
['platformConfig', getAddressDecoder()],
|
|
58
59
|
['curvePartner', getAddressDecoder()],
|
|
59
60
|
['isPartner', getBooleanDecoder()],
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
containsBytes,
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getAddressDecoder,
|
|
13
|
+
getArrayDecoder,
|
|
13
14
|
getBytesEncoder,
|
|
14
15
|
getI64Decoder,
|
|
15
16
|
getStructDecoder,
|
|
@@ -36,7 +37,7 @@ export type CreatorClaimEvent = {
|
|
|
36
37
|
quoteMint: Address;
|
|
37
38
|
platformConfig: Address;
|
|
38
39
|
coinCreator: Address;
|
|
39
|
-
|
|
40
|
+
padding0: Array<bigint>;
|
|
40
41
|
claimer: Address;
|
|
41
42
|
destinationOwner: Address;
|
|
42
43
|
amount: bigint;
|
|
@@ -55,7 +56,7 @@ export function getCreatorClaimEventDecoder(): FixedSizeDecoder<CreatorClaimEven
|
|
|
55
56
|
['quoteMint', getAddressDecoder()],
|
|
56
57
|
['platformConfig', getAddressDecoder()],
|
|
57
58
|
['coinCreator', getAddressDecoder()],
|
|
58
|
-
['
|
|
59
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
59
60
|
['claimer', getAddressDecoder()],
|
|
60
61
|
['destinationOwner', getAddressDecoder()],
|
|
61
62
|
['amount', getU64Decoder()],
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
containsBytes,
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getAddressDecoder,
|
|
13
|
+
getArrayDecoder,
|
|
13
14
|
getBytesEncoder,
|
|
14
15
|
getI64Decoder,
|
|
15
16
|
getStructDecoder,
|
|
@@ -37,7 +38,7 @@ export type MigrateEvent = {
|
|
|
37
38
|
quoteMint: Address;
|
|
38
39
|
pool: Address;
|
|
39
40
|
coinCreator: Address;
|
|
40
|
-
|
|
41
|
+
padding0: Array<bigint>;
|
|
41
42
|
platformConfig: Address;
|
|
42
43
|
baseAmount: bigint;
|
|
43
44
|
quoteAmount: bigint;
|
|
@@ -54,7 +55,7 @@ export function getMigrateEventDecoder(): FixedSizeDecoder<MigrateEvent> {
|
|
|
54
55
|
['quoteMint', getAddressDecoder()],
|
|
55
56
|
['pool', getAddressDecoder()],
|
|
56
57
|
['coinCreator', getAddressDecoder()],
|
|
57
|
-
['
|
|
58
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
58
59
|
['platformConfig', getAddressDecoder()],
|
|
59
60
|
['baseAmount', getU64Decoder()],
|
|
60
61
|
['quoteAmount', getU64Decoder()],
|
|
@@ -11,10 +11,12 @@ import {
|
|
|
11
11
|
containsBytes,
|
|
12
12
|
fixEncoderSize,
|
|
13
13
|
getAddressDecoder,
|
|
14
|
+
getArrayDecoder,
|
|
14
15
|
getBooleanDecoder,
|
|
15
16
|
getBytesEncoder,
|
|
16
17
|
getI64Decoder,
|
|
17
18
|
getStructDecoder,
|
|
19
|
+
getU16Decoder,
|
|
18
20
|
getU32Decoder,
|
|
19
21
|
getU64Decoder,
|
|
20
22
|
getU8Decoder,
|
|
@@ -46,9 +48,7 @@ export type TokenCreateEvent = {
|
|
|
46
48
|
quoteMint: Address;
|
|
47
49
|
quoteDecimals: number;
|
|
48
50
|
coinCreator: Address;
|
|
49
|
-
|
|
50
|
-
creatorId: string;
|
|
51
|
-
creatorFeeConfig: Address;
|
|
51
|
+
padding0: Array<bigint>;
|
|
52
52
|
platformConfig: Address;
|
|
53
53
|
name: string;
|
|
54
54
|
symbol: string;
|
|
@@ -61,6 +61,9 @@ export type TokenCreateEvent = {
|
|
|
61
61
|
realBaseReserves: bigint;
|
|
62
62
|
realQuoteReserves: bigint;
|
|
63
63
|
timestamp: bigint;
|
|
64
|
+
creatorFeeMode: number;
|
|
65
|
+
creatorFeeBps: number;
|
|
66
|
+
dexCreatorFeeBps: number;
|
|
64
67
|
};
|
|
65
68
|
|
|
66
69
|
let getTokenCreateEventDecoderCache: Decoder<TokenCreateEvent> | undefined;
|
|
@@ -77,12 +80,7 @@ export function getTokenCreateEventDecoder(): Decoder<TokenCreateEvent> {
|
|
|
77
80
|
['quoteMint', getAddressDecoder()],
|
|
78
81
|
['quoteDecimals', getU8Decoder()],
|
|
79
82
|
['coinCreator', getAddressDecoder()],
|
|
80
|
-
[
|
|
81
|
-
'creatorPlatform',
|
|
82
|
-
addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder()),
|
|
83
|
-
],
|
|
84
|
-
['creatorId', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
85
|
-
['creatorFeeConfig', getAddressDecoder()],
|
|
83
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 5 })],
|
|
86
84
|
['platformConfig', getAddressDecoder()],
|
|
87
85
|
['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
88
86
|
['symbol', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
@@ -95,6 +93,9 @@ export function getTokenCreateEventDecoder(): Decoder<TokenCreateEvent> {
|
|
|
95
93
|
['realBaseReserves', getU64Decoder()],
|
|
96
94
|
['realQuoteReserves', getU64Decoder()],
|
|
97
95
|
['timestamp', getI64Decoder()],
|
|
96
|
+
['creatorFeeMode', getU8Decoder()],
|
|
97
|
+
['creatorFeeBps', getU16Decoder()],
|
|
98
|
+
['dexCreatorFeeBps', getU16Decoder()],
|
|
98
99
|
]));
|
|
99
100
|
}
|
|
100
101
|
|
|
@@ -10,11 +10,14 @@ import {
|
|
|
10
10
|
containsBytes,
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getAddressDecoder,
|
|
13
|
+
getArrayDecoder,
|
|
13
14
|
getBooleanDecoder,
|
|
14
15
|
getBytesEncoder,
|
|
15
16
|
getI64Decoder,
|
|
16
17
|
getStructDecoder,
|
|
18
|
+
getU16Decoder,
|
|
17
19
|
getU64Decoder,
|
|
20
|
+
getU8Decoder,
|
|
18
21
|
type Address,
|
|
19
22
|
type FixedSizeDecoder,
|
|
20
23
|
type ReadonlyUint8Array,
|
|
@@ -42,7 +45,7 @@ export type TradeEvent = {
|
|
|
42
45
|
quoteMint: Address;
|
|
43
46
|
user: Address;
|
|
44
47
|
coinCreator: Address;
|
|
45
|
-
|
|
48
|
+
padding0: Array<bigint>;
|
|
46
49
|
platformConfig: Address;
|
|
47
50
|
baseAmount: bigint;
|
|
48
51
|
quoteAmountGross: bigint;
|
|
@@ -59,6 +62,8 @@ export type TradeEvent = {
|
|
|
59
62
|
realBaseReserves: bigint;
|
|
60
63
|
realQuoteReserves: bigint;
|
|
61
64
|
timestamp: bigint;
|
|
65
|
+
creatorFeeMode: number;
|
|
66
|
+
creatorFeeBps: number;
|
|
62
67
|
};
|
|
63
68
|
|
|
64
69
|
let getTradeEventDecoderCache: FixedSizeDecoder<TradeEvent> | undefined;
|
|
@@ -70,7 +75,7 @@ export function getTradeEventDecoder(): FixedSizeDecoder<TradeEvent> {
|
|
|
70
75
|
['quoteMint', getAddressDecoder()],
|
|
71
76
|
['user', getAddressDecoder()],
|
|
72
77
|
['coinCreator', getAddressDecoder()],
|
|
73
|
-
['
|
|
78
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
74
79
|
['platformConfig', getAddressDecoder()],
|
|
75
80
|
['baseAmount', getU64Decoder()],
|
|
76
81
|
['quoteAmountGross', getU64Decoder()],
|
|
@@ -87,6 +92,8 @@ export function getTradeEventDecoder(): FixedSizeDecoder<TradeEvent> {
|
|
|
87
92
|
['realBaseReserves', getU64Decoder()],
|
|
88
93
|
['realQuoteReserves', getU64Decoder()],
|
|
89
94
|
['timestamp', getI64Decoder()],
|
|
95
|
+
['creatorFeeMode', getU8Decoder()],
|
|
96
|
+
['creatorFeeBps', getU16Decoder()],
|
|
90
97
|
]));
|
|
91
98
|
}
|
|
92
99
|
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
EVENT_AUTHORITY_PDA_ADDRESS,
|
|
47
47
|
findBondingCurvePda,
|
|
48
|
+
findCreatorFeeConfigPda,
|
|
48
49
|
} from '../pdas/index.js';
|
|
49
50
|
import { SEND_LAUNCHPAD_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
50
51
|
|
|
@@ -96,7 +97,7 @@ export type ClaimCreatorFeesInstruction<
|
|
|
96
97
|
? WritableAccount<TAccountBondingCurve>
|
|
97
98
|
: TAccountBondingCurve,
|
|
98
99
|
TAccountCreatorFeeConfig extends string
|
|
99
|
-
?
|
|
100
|
+
? WritableAccount<TAccountCreatorFeeConfig>
|
|
100
101
|
: TAccountCreatorFeeConfig,
|
|
101
102
|
TAccountNexusGlobalConfig extends string
|
|
102
103
|
? ReadonlyAccount<TAccountNexusGlobalConfig>
|
|
@@ -184,7 +185,7 @@ export type ClaimCreatorFeesAsyncInput<
|
|
|
184
185
|
claimer: TransactionSigner<TAccountClaimer>;
|
|
185
186
|
payer: TransactionSigner<TAccountPayer>;
|
|
186
187
|
bondingCurve?: Address<TAccountBondingCurve>;
|
|
187
|
-
creatorFeeConfig
|
|
188
|
+
creatorFeeConfig?: Address<TAccountCreatorFeeConfig>;
|
|
188
189
|
baseMint: Address<TAccountBaseMint>;
|
|
189
190
|
quoteMint: Address<TAccountQuoteMint>;
|
|
190
191
|
quoteVault?: Address<TAccountQuoteVault>;
|
|
@@ -247,7 +248,7 @@ export async function getClaimCreatorFeesInstructionAsync<
|
|
|
247
248
|
bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
|
|
248
249
|
creatorFeeConfig: {
|
|
249
250
|
value: input.creatorFeeConfig ?? null,
|
|
250
|
-
isWritable:
|
|
251
|
+
isWritable: true,
|
|
251
252
|
},
|
|
252
253
|
nexusGlobalConfig: { value: null, isWritable: false },
|
|
253
254
|
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
@@ -285,6 +286,18 @@ export async function getClaimCreatorFeesInstructionAsync<
|
|
|
285
286
|
),
|
|
286
287
|
});
|
|
287
288
|
}
|
|
289
|
+
if (!accounts.creatorFeeConfig.value) {
|
|
290
|
+
accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
291
|
+
baseMint: getAddressFromResolvedInstructionAccount(
|
|
292
|
+
'baseMint',
|
|
293
|
+
accounts.baseMint.value,
|
|
294
|
+
),
|
|
295
|
+
quoteMint: getAddressFromResolvedInstructionAccount(
|
|
296
|
+
'quoteMint',
|
|
297
|
+
accounts.quoteMint.value,
|
|
298
|
+
),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
288
301
|
if (!accounts.nexusGlobalConfig.value) {
|
|
289
302
|
accounts.nexusGlobalConfig.value =
|
|
290
303
|
'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr' as Address<'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr'>;
|
|
@@ -477,7 +490,7 @@ export function getClaimCreatorFeesInstruction<
|
|
|
477
490
|
bondingCurve: { value: input.bondingCurve ?? null, isWritable: true },
|
|
478
491
|
creatorFeeConfig: {
|
|
479
492
|
value: input.creatorFeeConfig ?? null,
|
|
480
|
-
isWritable:
|
|
493
|
+
isWritable: true,
|
|
481
494
|
},
|
|
482
495
|
nexusGlobalConfig: { value: null, isWritable: false },
|
|
483
496
|
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
@@ -22,8 +22,12 @@ import {
|
|
|
22
22
|
getProgramDerivedAddress,
|
|
23
23
|
getStructDecoder,
|
|
24
24
|
getStructEncoder,
|
|
25
|
+
getU16Decoder,
|
|
26
|
+
getU16Encoder,
|
|
25
27
|
getU32Decoder,
|
|
26
28
|
getU32Encoder,
|
|
29
|
+
getU8Decoder,
|
|
30
|
+
getU8Encoder,
|
|
27
31
|
getUtf8Decoder,
|
|
28
32
|
getUtf8Encoder,
|
|
29
33
|
SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS,
|
|
@@ -54,6 +58,7 @@ import {
|
|
|
54
58
|
import {
|
|
55
59
|
EVENT_AUTHORITY_PDA_ADDRESS,
|
|
56
60
|
findBondingCurvePda,
|
|
61
|
+
findCreatorFeeConfigPda,
|
|
57
62
|
findRewardAccrualPda,
|
|
58
63
|
GLOBAL_CONFIG_PDA_ADDRESS,
|
|
59
64
|
WSOL_REWARD_ACCRUAL_PDA_ADDRESS,
|
|
@@ -212,22 +217,22 @@ export type CreateTokenInstruction<
|
|
|
212
217
|
export type CreateTokenInstructionData = {
|
|
213
218
|
discriminator: ReadonlyUint8Array;
|
|
214
219
|
platformConfig: Address;
|
|
215
|
-
creatorPlatform: string;
|
|
216
|
-
creatorId: string;
|
|
217
|
-
creatorHash: Address;
|
|
218
220
|
name: string;
|
|
219
221
|
symbol: string;
|
|
220
222
|
uri: string;
|
|
223
|
+
creatorFeeMode: number;
|
|
224
|
+
creatorFeeBps: number;
|
|
225
|
+
dexCreatorFeeBps: number;
|
|
221
226
|
};
|
|
222
227
|
|
|
223
228
|
export type CreateTokenInstructionDataArgs = {
|
|
224
229
|
platformConfig: Address;
|
|
225
|
-
creatorPlatform: string;
|
|
226
|
-
creatorId: string;
|
|
227
|
-
creatorHash: Address;
|
|
228
230
|
name: string;
|
|
229
231
|
symbol: string;
|
|
230
232
|
uri: string;
|
|
233
|
+
creatorFeeMode: number;
|
|
234
|
+
creatorFeeBps: number;
|
|
235
|
+
dexCreatorFeeBps: number;
|
|
231
236
|
};
|
|
232
237
|
|
|
233
238
|
export function getCreateTokenInstructionDataEncoder(): Encoder<CreateTokenInstructionDataArgs> {
|
|
@@ -235,18 +240,12 @@ export function getCreateTokenInstructionDataEncoder(): Encoder<CreateTokenInstr
|
|
|
235
240
|
getStructEncoder([
|
|
236
241
|
['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
|
|
237
242
|
['platformConfig', getAddressEncoder()],
|
|
238
|
-
[
|
|
239
|
-
'creatorPlatform',
|
|
240
|
-
addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()),
|
|
241
|
-
],
|
|
242
|
-
[
|
|
243
|
-
'creatorId',
|
|
244
|
-
addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder()),
|
|
245
|
-
],
|
|
246
|
-
['creatorHash', getAddressEncoder()],
|
|
247
243
|
['name', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
248
244
|
['symbol', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
249
245
|
['uri', addEncoderSizePrefix(getUtf8Encoder(), getU32Encoder())],
|
|
246
|
+
['creatorFeeMode', getU8Encoder()],
|
|
247
|
+
['creatorFeeBps', getU16Encoder()],
|
|
248
|
+
['dexCreatorFeeBps', getU16Encoder()],
|
|
250
249
|
]),
|
|
251
250
|
(value) => ({ ...value, discriminator: CREATE_TOKEN_DISCRIMINATOR }),
|
|
252
251
|
);
|
|
@@ -256,15 +255,12 @@ export function getCreateTokenInstructionDataDecoder(): Decoder<CreateTokenInstr
|
|
|
256
255
|
return getStructDecoder([
|
|
257
256
|
['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
|
|
258
257
|
['platformConfig', getAddressDecoder()],
|
|
259
|
-
[
|
|
260
|
-
'creatorPlatform',
|
|
261
|
-
addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder()),
|
|
262
|
-
],
|
|
263
|
-
['creatorId', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
264
|
-
['creatorHash', getAddressDecoder()],
|
|
265
258
|
['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
266
259
|
['symbol', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
267
260
|
['uri', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
261
|
+
['creatorFeeMode', getU8Decoder()],
|
|
262
|
+
['creatorFeeBps', getU16Decoder()],
|
|
263
|
+
['dexCreatorFeeBps', getU16Decoder()],
|
|
268
264
|
]);
|
|
269
265
|
}
|
|
270
266
|
|
|
@@ -314,12 +310,12 @@ export type CreateTokenAsyncInput<
|
|
|
314
310
|
stakingVault?: Address<TAccountStakingVault>;
|
|
315
311
|
quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
|
|
316
312
|
platformConfig: CreateTokenInstructionDataArgs['platformConfig'];
|
|
317
|
-
creatorPlatform: CreateTokenInstructionDataArgs['creatorPlatform'];
|
|
318
|
-
creatorId: CreateTokenInstructionDataArgs['creatorId'];
|
|
319
|
-
creatorHash: CreateTokenInstructionDataArgs['creatorHash'];
|
|
320
313
|
name: CreateTokenInstructionDataArgs['name'];
|
|
321
314
|
symbol: CreateTokenInstructionDataArgs['symbol'];
|
|
322
315
|
uri: CreateTokenInstructionDataArgs['uri'];
|
|
316
|
+
creatorFeeMode: CreateTokenInstructionDataArgs['creatorFeeMode'];
|
|
317
|
+
creatorFeeBps: CreateTokenInstructionDataArgs['creatorFeeBps'];
|
|
318
|
+
dexCreatorFeeBps: CreateTokenInstructionDataArgs['dexCreatorFeeBps'];
|
|
323
319
|
};
|
|
324
320
|
|
|
325
321
|
export async function getCreateTokenInstructionAsync<
|
|
@@ -517,29 +513,15 @@ export async function getCreateTokenInstructionAsync<
|
|
|
517
513
|
});
|
|
518
514
|
}
|
|
519
515
|
if (!accounts.creatorFeeConfig.value) {
|
|
520
|
-
accounts.creatorFeeConfig.value = await
|
|
521
|
-
|
|
522
|
-
'
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
),
|
|
530
|
-
getAddressEncoder().encode(
|
|
531
|
-
getNonNullResolvedInstructionInput(
|
|
532
|
-
'creatorHash',
|
|
533
|
-
args.creatorHash,
|
|
534
|
-
),
|
|
535
|
-
),
|
|
536
|
-
getAddressEncoder().encode(
|
|
537
|
-
getAddressFromResolvedInstructionAccount(
|
|
538
|
-
'quoteMint',
|
|
539
|
-
accounts.quoteMint.value,
|
|
540
|
-
),
|
|
541
|
-
),
|
|
542
|
-
],
|
|
516
|
+
accounts.creatorFeeConfig.value = await findCreatorFeeConfigPda({
|
|
517
|
+
baseMint: getAddressFromResolvedInstructionAccount(
|
|
518
|
+
'baseMint',
|
|
519
|
+
accounts.baseMint.value,
|
|
520
|
+
),
|
|
521
|
+
quoteMint: getAddressFromResolvedInstructionAccount(
|
|
522
|
+
'quoteMint',
|
|
523
|
+
accounts.quoteMint.value,
|
|
524
|
+
),
|
|
543
525
|
});
|
|
544
526
|
}
|
|
545
527
|
if (!accounts.nexusProgram.value) {
|
|
@@ -780,12 +762,12 @@ export type CreateTokenInput<
|
|
|
780
762
|
stakingVault: Address<TAccountStakingVault>;
|
|
781
763
|
quoteTokenProgram: Address<TAccountQuoteTokenProgram>;
|
|
782
764
|
platformConfig: CreateTokenInstructionDataArgs['platformConfig'];
|
|
783
|
-
creatorPlatform: CreateTokenInstructionDataArgs['creatorPlatform'];
|
|
784
|
-
creatorId: CreateTokenInstructionDataArgs['creatorId'];
|
|
785
|
-
creatorHash: CreateTokenInstructionDataArgs['creatorHash'];
|
|
786
765
|
name: CreateTokenInstructionDataArgs['name'];
|
|
787
766
|
symbol: CreateTokenInstructionDataArgs['symbol'];
|
|
788
767
|
uri: CreateTokenInstructionDataArgs['uri'];
|
|
768
|
+
creatorFeeMode: CreateTokenInstructionDataArgs['creatorFeeMode'];
|
|
769
|
+
creatorFeeBps: CreateTokenInstructionDataArgs['creatorFeeBps'];
|
|
770
|
+
dexCreatorFeeBps: CreateTokenInstructionDataArgs['dexCreatorFeeBps'];
|
|
789
771
|
};
|
|
790
772
|
|
|
791
773
|
export function getCreateTokenInstruction<
|