@send-fun/sdk 1.2.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/dist/index.cjs +281 -365
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +125 -166
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +125 -166
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +281 -365
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/dex/generated/accounts/pool.ts +19 -7
- 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/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/launchpad/create.ts +9 -34
- package/src/launchpad/generated/accounts/bondingCurve.ts +23 -7
- 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/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/migrate.ts +7 -4
- package/src/nexus/fee-helpers.ts +8 -5
- package/src/nexus/generated/accounts/feePreset.ts +2 -2
- package/src/nexus/generated/accounts/index.ts +0 -1
- package/src/nexus/generated/accounts/partnerConfig.ts +9 -3
- package/src/nexus/generated/accounts/sendNexus.accounts.ts +0 -5
- package/src/nexus/generated/accounts/userRewardDebt.ts +3 -3
- package/src/nexus/generated/accounts/userStakePosition.ts +3 -3
- package/src/nexus/generated/errors/sendNexus.ts +12 -4
- package/src/nexus/generated/pdas/index.ts +0 -1
- package/src/nexus/generated/plugins/sendNexus.ts +0 -35
- 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/utils/index.ts +0 -5
- package/src/nexus/generated/accounts/creatorFeeConfig.ts +0 -237
- package/src/nexus/generated/types/callerType.ts +0 -38
- package/src/utils/creator-hash.ts +0 -60
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@send-fun/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Kit-native TypeScript SDK for send.fun",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dex",
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@solana-program/token-2022": "^0.9.0",
|
|
47
47
|
"@solana/kit": "6.10.0",
|
|
48
|
-
"@types/node": "^24.
|
|
49
|
-
"@typescript/native
|
|
50
|
-
"oxfmt": "^0.
|
|
48
|
+
"@types/node": "^24.13.6",
|
|
49
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
50
|
+
"oxfmt": "^0.70.0",
|
|
51
51
|
"tsdown": "^0.23.0",
|
|
52
|
-
"tsx": "^4.
|
|
53
|
-
"typescript": "
|
|
52
|
+
"tsx": "^4.23.15",
|
|
53
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@solana/kit": "^6.10.0 || ^7.0.0 || ^8.0.0"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"format": "oxfmt --write",
|
|
66
66
|
"format:check": "oxfmt --check",
|
|
67
67
|
"test": "tsx --test 'tests/**/*.test.ts'",
|
|
68
|
-
"typecheck": "
|
|
68
|
+
"typecheck": "tsc && tsc -p compat/tsconfig.json"
|
|
69
69
|
},
|
|
70
70
|
"types": "./dist/index.d.cts"
|
|
71
71
|
}
|
|
@@ -18,12 +18,16 @@ import {
|
|
|
18
18
|
fixEncoderSize,
|
|
19
19
|
getAddressDecoder,
|
|
20
20
|
getAddressEncoder,
|
|
21
|
+
getArrayDecoder,
|
|
22
|
+
getArrayEncoder,
|
|
21
23
|
getBytesDecoder,
|
|
22
24
|
getBytesEncoder,
|
|
23
25
|
getI64Decoder,
|
|
24
26
|
getI64Encoder,
|
|
25
27
|
getStructDecoder,
|
|
26
28
|
getStructEncoder,
|
|
29
|
+
getU16Decoder,
|
|
30
|
+
getU16Encoder,
|
|
27
31
|
getU64Decoder,
|
|
28
32
|
getU64Encoder,
|
|
29
33
|
getU8Decoder,
|
|
@@ -68,7 +72,7 @@ export type Pool = {
|
|
|
68
72
|
quoteMint: Address;
|
|
69
73
|
quoteDecimals: number;
|
|
70
74
|
coinCreator: Address;
|
|
71
|
-
|
|
75
|
+
padding0: Array<bigint>;
|
|
72
76
|
baseVault: Address;
|
|
73
77
|
quoteVault: Address;
|
|
74
78
|
lpMint: Address;
|
|
@@ -80,6 +84,8 @@ export type Pool = {
|
|
|
80
84
|
protocolOwed: bigint;
|
|
81
85
|
creatorOwed: bigint;
|
|
82
86
|
platformConfig: Address;
|
|
87
|
+
creatorFeeMode: number;
|
|
88
|
+
creatorFeeBps: number;
|
|
83
89
|
reserved: ReadonlyUint8Array;
|
|
84
90
|
};
|
|
85
91
|
|
|
@@ -92,7 +98,7 @@ export type PoolArgs = {
|
|
|
92
98
|
quoteMint: Address;
|
|
93
99
|
quoteDecimals: number;
|
|
94
100
|
coinCreator: Address;
|
|
95
|
-
|
|
101
|
+
padding0: Array<number | bigint>;
|
|
96
102
|
baseVault: Address;
|
|
97
103
|
quoteVault: Address;
|
|
98
104
|
lpMint: Address;
|
|
@@ -104,6 +110,8 @@ export type PoolArgs = {
|
|
|
104
110
|
protocolOwed: number | bigint;
|
|
105
111
|
creatorOwed: number | bigint;
|
|
106
112
|
platformConfig: Address;
|
|
113
|
+
creatorFeeMode: number;
|
|
114
|
+
creatorFeeBps: number;
|
|
107
115
|
reserved: ReadonlyUint8Array;
|
|
108
116
|
};
|
|
109
117
|
|
|
@@ -120,7 +128,7 @@ export function getPoolEncoder(): FixedSizeEncoder<PoolArgs> {
|
|
|
120
128
|
['quoteMint', getAddressEncoder()],
|
|
121
129
|
['quoteDecimals', getU8Encoder()],
|
|
122
130
|
['coinCreator', getAddressEncoder()],
|
|
123
|
-
['
|
|
131
|
+
['padding0', getArrayEncoder(getU64Encoder(), { size: 4 })],
|
|
124
132
|
['baseVault', getAddressEncoder()],
|
|
125
133
|
['quoteVault', getAddressEncoder()],
|
|
126
134
|
['lpMint', getAddressEncoder()],
|
|
@@ -132,7 +140,9 @@ export function getPoolEncoder(): FixedSizeEncoder<PoolArgs> {
|
|
|
132
140
|
['protocolOwed', getU64Encoder()],
|
|
133
141
|
['creatorOwed', getU64Encoder()],
|
|
134
142
|
['platformConfig', getAddressEncoder()],
|
|
135
|
-
['
|
|
143
|
+
['creatorFeeMode', getU8Encoder()],
|
|
144
|
+
['creatorFeeBps', getU16Encoder()],
|
|
145
|
+
['reserved', fixEncoderSize(getBytesEncoder(), 256)],
|
|
136
146
|
]),
|
|
137
147
|
(value) => ({ ...value, discriminator: POOL_DISCRIMINATOR }),
|
|
138
148
|
);
|
|
@@ -150,7 +160,7 @@ export function getPoolDecoder(): FixedSizeDecoder<Pool> {
|
|
|
150
160
|
['quoteMint', getAddressDecoder()],
|
|
151
161
|
['quoteDecimals', getU8Decoder()],
|
|
152
162
|
['coinCreator', getAddressDecoder()],
|
|
153
|
-
['
|
|
163
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
154
164
|
['baseVault', getAddressDecoder()],
|
|
155
165
|
['quoteVault', getAddressDecoder()],
|
|
156
166
|
['lpMint', getAddressDecoder()],
|
|
@@ -162,7 +172,9 @@ export function getPoolDecoder(): FixedSizeDecoder<Pool> {
|
|
|
162
172
|
['protocolOwed', getU64Decoder()],
|
|
163
173
|
['creatorOwed', getU64Decoder()],
|
|
164
174
|
['platformConfig', getAddressDecoder()],
|
|
165
|
-
['
|
|
175
|
+
['creatorFeeMode', getU8Decoder()],
|
|
176
|
+
['creatorFeeBps', getU16Decoder()],
|
|
177
|
+
['reserved', fixDecoderSize(getBytesDecoder(), 256)],
|
|
166
178
|
]);
|
|
167
179
|
}
|
|
168
180
|
|
|
@@ -279,5 +291,5 @@ export async function fetchAllMaybePool(
|
|
|
279
291
|
}
|
|
280
292
|
|
|
281
293
|
export function getPoolSize(): number {
|
|
282
|
-
return
|
|
294
|
+
return 584;
|
|
283
295
|
}
|
|
@@ -36,8 +36,8 @@ export const SEND_DEX_ERROR__INVALID_POOL_BALANCE = 0x1778; // 6008
|
|
|
36
36
|
export const SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE = 0x1779; // 6009
|
|
37
37
|
/** InvalidAuthority: Invalid authority */
|
|
38
38
|
export const SEND_DEX_ERROR__INVALID_AUTHORITY = 0x177a; // 6010
|
|
39
|
-
/**
|
|
40
|
-
export const
|
|
39
|
+
/** InvalidCoinCreator: Invalid coin creator */
|
|
40
|
+
export const SEND_DEX_ERROR__INVALID_COIN_CREATOR = 0x177b; // 6011
|
|
41
41
|
/** InvalidPlatformConfig: Platform config cannot be the default address */
|
|
42
42
|
export const SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG = 0x177c; // 6012
|
|
43
43
|
/** ProgramPaused: Program is paused */
|
|
@@ -64,12 +64,16 @@ export const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT = 0x1b61; // 7009
|
|
|
64
64
|
export const SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY = 0x1b62; // 7010
|
|
65
65
|
/** NothingToClaim: Nothing to claim */
|
|
66
66
|
export const SEND_DEX_ERROR__NOTHING_TO_CLAIM = 0x1b63; // 7011
|
|
67
|
-
/**
|
|
68
|
-
export const
|
|
67
|
+
/** Unused7012: Unused */
|
|
68
|
+
export const SEND_DEX_ERROR__UNUSED7012 = 0x1b64; // 7012
|
|
69
69
|
/** QuoteMintPriceUnset: Quote mint has no USDC price on its nexus reward state */
|
|
70
70
|
export const SEND_DEX_ERROR__QUOTE_MINT_PRICE_UNSET = 0x1b65; // 7013
|
|
71
71
|
/** TransferFeeNotSettleable: Token-2022 transfer fee schedule cannot settle the exact amount */
|
|
72
72
|
export const SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE = 0x1b66; // 7014
|
|
73
|
+
/** CreatorFeeTooHigh: Creator fee exceeds the partner's maximum */
|
|
74
|
+
export const SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH = 0x1b67; // 7015
|
|
75
|
+
/** CreatorFeeModeNotAllowed: Creator fee mode is not allowed by the partner config */
|
|
76
|
+
export const SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED = 0x1b68; // 7016
|
|
73
77
|
/** InsufficientLiquidity: Insufficient liquidity */
|
|
74
78
|
export const SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY = 0x1bbc; // 7100
|
|
75
79
|
/** InvalidAmount: Invalid amount */
|
|
@@ -77,14 +81,15 @@ export const SEND_DEX_ERROR__INVALID_AMOUNT = 0x1bbd; // 7101
|
|
|
77
81
|
|
|
78
82
|
export type SendDexError =
|
|
79
83
|
| typeof SEND_DEX_ERROR__ARITHMETIC_OVERFLOW
|
|
84
|
+
| typeof SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED
|
|
85
|
+
| typeof SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH
|
|
80
86
|
| typeof SEND_DEX_ERROR__INSUFFICIENT_BALANCE
|
|
81
87
|
| typeof SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY
|
|
82
88
|
| typeof SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE
|
|
83
89
|
| typeof SEND_DEX_ERROR__INVALID_AMOUNT
|
|
84
90
|
| typeof SEND_DEX_ERROR__INVALID_AUTHORITY
|
|
85
91
|
| typeof SEND_DEX_ERROR__INVALID_BASE_MINT
|
|
86
|
-
| typeof
|
|
87
|
-
| typeof SEND_DEX_ERROR__INVALID_CREATOR_ID
|
|
92
|
+
| typeof SEND_DEX_ERROR__INVALID_COIN_CREATOR
|
|
88
93
|
| typeof SEND_DEX_ERROR__INVALID_DEPOSIT
|
|
89
94
|
| typeof SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG
|
|
90
95
|
| typeof SEND_DEX_ERROR__INVALID_POOL_BALANCE
|
|
@@ -102,6 +107,7 @@ export type SendDexError =
|
|
|
102
107
|
| typeof SEND_DEX_ERROR__TEXT_TOO_LONG
|
|
103
108
|
| typeof SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE
|
|
104
109
|
| typeof SEND_DEX_ERROR__UNAUTHORIZED
|
|
110
|
+
| typeof SEND_DEX_ERROR__UNUSED7012
|
|
105
111
|
| typeof SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID
|
|
106
112
|
| typeof SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY
|
|
107
113
|
| typeof SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_MINT
|
|
@@ -109,14 +115,15 @@ export type SendDexError =
|
|
|
109
115
|
|
|
110
116
|
export const sendDexErrorMessages: Record<SendDexError, string> = {
|
|
111
117
|
[SEND_DEX_ERROR__ARITHMETIC_OVERFLOW]: `Arithmetic overflow`,
|
|
118
|
+
[SEND_DEX_ERROR__CREATOR_FEE_MODE_NOT_ALLOWED]: `Creator fee mode is not allowed by the partner config`,
|
|
119
|
+
[SEND_DEX_ERROR__CREATOR_FEE_TOO_HIGH]: `Creator fee exceeds the partner's maximum`,
|
|
112
120
|
[SEND_DEX_ERROR__INSUFFICIENT_BALANCE]: `Insufficient balance in source account`,
|
|
113
121
|
[SEND_DEX_ERROR__INSUFFICIENT_LIQUIDITY]: `Insufficient liquidity`,
|
|
114
122
|
[SEND_DEX_ERROR__INSUFFICIENT_POOL_BALANCE]: `Insufficient pool balance`,
|
|
115
123
|
[SEND_DEX_ERROR__INVALID_AMOUNT]: `Invalid amount`,
|
|
116
124
|
[SEND_DEX_ERROR__INVALID_AUTHORITY]: `Invalid authority`,
|
|
117
125
|
[SEND_DEX_ERROR__INVALID_BASE_MINT]: `Invalid base mint`,
|
|
118
|
-
[
|
|
119
|
-
[SEND_DEX_ERROR__INVALID_CREATOR_ID]: `Creator identity is not a decodable wallet address`,
|
|
126
|
+
[SEND_DEX_ERROR__INVALID_COIN_CREATOR]: `Invalid coin creator`,
|
|
120
127
|
[SEND_DEX_ERROR__INVALID_DEPOSIT]: `Invalid deposit`,
|
|
121
128
|
[SEND_DEX_ERROR__INVALID_PLATFORM_CONFIG]: `Platform config cannot be the default address`,
|
|
122
129
|
[SEND_DEX_ERROR__INVALID_POOL_BALANCE]: `Invalid pool balance`,
|
|
@@ -134,6 +141,7 @@ export const sendDexErrorMessages: Record<SendDexError, string> = {
|
|
|
134
141
|
[SEND_DEX_ERROR__TEXT_TOO_LONG]: `Text too long`,
|
|
135
142
|
[SEND_DEX_ERROR__TRANSFER_FEE_NOT_SETTLEABLE]: `Token-2022 transfer fee schedule cannot settle the exact amount`,
|
|
136
143
|
[SEND_DEX_ERROR__UNAUTHORIZED]: `Unauthorized`,
|
|
144
|
+
[SEND_DEX_ERROR__UNUSED7012]: `Unused`,
|
|
137
145
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_INVALID]: `User token account is not an initialized token account`,
|
|
138
146
|
[SEND_DEX_ERROR__USER_TOKEN_ACCOUNT_WRONG_AUTHORITY]: `User token account is not owned by the trading user`,
|
|
139
147
|
[SEND_DEX_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
|
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,9 +10,11 @@ import {
|
|
|
10
10
|
containsBytes,
|
|
11
11
|
fixEncoderSize,
|
|
12
12
|
getAddressDecoder,
|
|
13
|
+
getArrayDecoder,
|
|
13
14
|
getBytesEncoder,
|
|
14
15
|
getI64Decoder,
|
|
15
16
|
getStructDecoder,
|
|
17
|
+
getU16Decoder,
|
|
16
18
|
getU64Decoder,
|
|
17
19
|
getU8Decoder,
|
|
18
20
|
type Address,
|
|
@@ -38,7 +40,7 @@ export type PoolCreateEvent = {
|
|
|
38
40
|
quoteMint: Address;
|
|
39
41
|
quoteDecimals: number;
|
|
40
42
|
coinCreator: Address;
|
|
41
|
-
|
|
43
|
+
padding0: Array<bigint>;
|
|
42
44
|
platformConfig: Address;
|
|
43
45
|
baseVault: Address;
|
|
44
46
|
quoteVault: Address;
|
|
@@ -47,6 +49,8 @@ export type PoolCreateEvent = {
|
|
|
47
49
|
baseReserves: bigint;
|
|
48
50
|
quoteReserves: bigint;
|
|
49
51
|
timestamp: bigint;
|
|
52
|
+
creatorFeeMode: number;
|
|
53
|
+
creatorFeeBps: number;
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
let getPoolCreateEventDecoderCache:
|
|
@@ -61,7 +65,7 @@ export function getPoolCreateEventDecoder(): FixedSizeDecoder<PoolCreateEvent> {
|
|
|
61
65
|
['quoteMint', getAddressDecoder()],
|
|
62
66
|
['quoteDecimals', getU8Decoder()],
|
|
63
67
|
['coinCreator', getAddressDecoder()],
|
|
64
|
-
['
|
|
68
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
65
69
|
['platformConfig', getAddressDecoder()],
|
|
66
70
|
['baseVault', getAddressDecoder()],
|
|
67
71
|
['quoteVault', getAddressDecoder()],
|
|
@@ -70,6 +74,8 @@ export function getPoolCreateEventDecoder(): FixedSizeDecoder<PoolCreateEvent> {
|
|
|
70
74
|
['baseReserves', getU64Decoder()],
|
|
71
75
|
['quoteReserves', getU64Decoder()],
|
|
72
76
|
['timestamp', getI64Decoder()],
|
|
77
|
+
['creatorFeeMode', getU8Decoder()],
|
|
78
|
+
['creatorFeeBps', getU16Decoder()],
|
|
73
79
|
]));
|
|
74
80
|
}
|
|
75
81
|
|
|
@@ -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,
|
|
@@ -43,9 +45,7 @@ export type TokenCreateEvent = {
|
|
|
43
45
|
quoteMint: Address;
|
|
44
46
|
quoteDecimals: number;
|
|
45
47
|
coinCreator: Address;
|
|
46
|
-
|
|
47
|
-
creatorId: string;
|
|
48
|
-
creatorFeeConfig: Address;
|
|
48
|
+
padding0: Array<bigint>;
|
|
49
49
|
platformConfig: Address;
|
|
50
50
|
name: string;
|
|
51
51
|
symbol: string;
|
|
@@ -56,6 +56,8 @@ export type TokenCreateEvent = {
|
|
|
56
56
|
baseReserves: bigint;
|
|
57
57
|
quoteReserves: bigint;
|
|
58
58
|
timestamp: bigint;
|
|
59
|
+
creatorFeeMode: number;
|
|
60
|
+
creatorFeeBps: number;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
63
|
let getTokenCreateEventDecoderCache: Decoder<TokenCreateEvent> | undefined;
|
|
@@ -69,12 +71,7 @@ export function getTokenCreateEventDecoder(): Decoder<TokenCreateEvent> {
|
|
|
69
71
|
['quoteMint', getAddressDecoder()],
|
|
70
72
|
['quoteDecimals', getU8Decoder()],
|
|
71
73
|
['coinCreator', getAddressDecoder()],
|
|
72
|
-
[
|
|
73
|
-
'creatorPlatform',
|
|
74
|
-
addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder()),
|
|
75
|
-
],
|
|
76
|
-
['creatorId', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
77
|
-
['creatorFeeConfig', getAddressDecoder()],
|
|
74
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 5 })],
|
|
78
75
|
['platformConfig', getAddressDecoder()],
|
|
79
76
|
['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
80
77
|
['symbol', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
|
|
@@ -85,6 +82,8 @@ export function getTokenCreateEventDecoder(): Decoder<TokenCreateEvent> {
|
|
|
85
82
|
['baseReserves', getU64Decoder()],
|
|
86
83
|
['quoteReserves', getU64Decoder()],
|
|
87
84
|
['timestamp', getI64Decoder()],
|
|
85
|
+
['creatorFeeMode', getU8Decoder()],
|
|
86
|
+
['creatorFeeBps', getU16Decoder()],
|
|
88
87
|
]));
|
|
89
88
|
}
|
|
90
89
|
|
|
@@ -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;
|
|
@@ -58,6 +61,8 @@ export type TradeEvent = {
|
|
|
58
61
|
baseReserves: bigint;
|
|
59
62
|
quoteReserves: bigint;
|
|
60
63
|
timestamp: bigint;
|
|
64
|
+
creatorFeeMode: number;
|
|
65
|
+
creatorFeeBps: number;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
let getTradeEventDecoderCache: FixedSizeDecoder<TradeEvent> | undefined;
|
|
@@ -69,7 +74,7 @@ export function getTradeEventDecoder(): FixedSizeDecoder<TradeEvent> {
|
|
|
69
74
|
['quoteMint', getAddressDecoder()],
|
|
70
75
|
['user', getAddressDecoder()],
|
|
71
76
|
['coinCreator', getAddressDecoder()],
|
|
72
|
-
['
|
|
77
|
+
['padding0', getArrayDecoder(getU64Decoder(), { size: 4 })],
|
|
73
78
|
['platformConfig', getAddressDecoder()],
|
|
74
79
|
['baseAmount', getU64Decoder()],
|
|
75
80
|
['quoteAmountGross', getU64Decoder()],
|
|
@@ -85,6 +90,8 @@ export function getTradeEventDecoder(): FixedSizeDecoder<TradeEvent> {
|
|
|
85
90
|
['baseReserves', getU64Decoder()],
|
|
86
91
|
['quoteReserves', getU64Decoder()],
|
|
87
92
|
['timestamp', getI64Decoder()],
|
|
93
|
+
['creatorFeeMode', getU8Decoder()],
|
|
94
|
+
['creatorFeeBps', getU16Decoder()],
|
|
88
95
|
]));
|
|
89
96
|
}
|
|
90
97
|
|
|
@@ -42,7 +42,11 @@ import {
|
|
|
42
42
|
getAddressFromResolvedInstructionAccount,
|
|
43
43
|
type ResolvedInstructionAccount,
|
|
44
44
|
} from '@solana/kit/program-client-core';
|
|
45
|
-
import {
|
|
45
|
+
import {
|
|
46
|
+
EVENT_AUTHORITY_PDA_ADDRESS,
|
|
47
|
+
findCreatorFeeConfigPda,
|
|
48
|
+
findPoolPda,
|
|
49
|
+
} from '../pdas/index.js';
|
|
46
50
|
import { SEND_DEX_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
47
51
|
|
|
48
52
|
export const CLAIM_CREATOR_FEES_DISCRIMINATOR: ReadonlyUint8Array =
|
|
@@ -93,7 +97,7 @@ export type ClaimCreatorFeesInstruction<
|
|
|
93
97
|
? WritableAccount<TAccountPool>
|
|
94
98
|
: TAccountPool,
|
|
95
99
|
TAccountCreatorFeeConfig extends string
|
|
96
|
-
?
|
|
100
|
+
? WritableAccount<TAccountCreatorFeeConfig>
|
|
97
101
|
: TAccountCreatorFeeConfig,
|
|
98
102
|
TAccountNexusGlobalConfig extends string
|
|
99
103
|
? ReadonlyAccount<TAccountNexusGlobalConfig>
|
|
@@ -181,7 +185,7 @@ export type ClaimCreatorFeesAsyncInput<
|
|
|
181
185
|
claimer: TransactionSigner<TAccountClaimer>;
|
|
182
186
|
payer: TransactionSigner<TAccountPayer>;
|
|
183
187
|
pool?: Address<TAccountPool>;
|
|
184
|
-
creatorFeeConfig
|
|
188
|
+
creatorFeeConfig?: Address<TAccountCreatorFeeConfig>;
|
|
185
189
|
baseMint: Address<TAccountBaseMint>;
|
|
186
190
|
quoteMint: Address<TAccountQuoteMint>;
|
|
187
191
|
quoteVault?: Address<TAccountQuoteVault>;
|
|
@@ -244,7 +248,7 @@ export async function getClaimCreatorFeesInstructionAsync<
|
|
|
244
248
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
245
249
|
creatorFeeConfig: {
|
|
246
250
|
value: input.creatorFeeConfig ?? null,
|
|
247
|
-
isWritable:
|
|
251
|
+
isWritable: true,
|
|
248
252
|
},
|
|
249
253
|
nexusGlobalConfig: { value: null, isWritable: false },
|
|
250
254
|
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
@@ -282,6 +286,18 @@ export async function getClaimCreatorFeesInstructionAsync<
|
|
|
282
286
|
),
|
|
283
287
|
});
|
|
284
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
|
+
}
|
|
285
301
|
if (!accounts.nexusGlobalConfig.value) {
|
|
286
302
|
accounts.nexusGlobalConfig.value =
|
|
287
303
|
'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr' as Address<'3bycfBeRULfXYqcg3DmiYFBjv6mMVidMuqKdFZJTGdNr'>;
|
|
@@ -474,7 +490,7 @@ export function getClaimCreatorFeesInstruction<
|
|
|
474
490
|
pool: { value: input.pool ?? null, isWritable: true },
|
|
475
491
|
creatorFeeConfig: {
|
|
476
492
|
value: input.creatorFeeConfig ?? null,
|
|
477
|
-
isWritable:
|
|
493
|
+
isWritable: true,
|
|
478
494
|
},
|
|
479
495
|
nexusGlobalConfig: { value: null, isWritable: false },
|
|
480
496
|
baseMint: { value: input.baseMint ?? null, isWritable: false },
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
type Address,
|
|
14
14
|
type ProgramDerivedAddress,
|
|
15
15
|
} from '@solana/kit';
|
|
16
|
-
import {
|
|
16
|
+
import { SEND_DEX_PROGRAM_ADDRESS } from '../programs/index.js';
|
|
17
17
|
|
|
18
18
|
export type CreatorFeeConfigSeeds = {
|
|
19
|
-
|
|
19
|
+
baseMint: Address;
|
|
20
20
|
quoteMint: Address;
|
|
21
21
|
};
|
|
22
22
|
|
|
@@ -24,15 +24,15 @@ export async function findCreatorFeeConfigPda(
|
|
|
24
24
|
seeds: CreatorFeeConfigSeeds,
|
|
25
25
|
): Promise<ProgramDerivedAddress> {
|
|
26
26
|
return await getProgramDerivedAddress({
|
|
27
|
-
programAddress:
|
|
27
|
+
programAddress: SEND_DEX_PROGRAM_ADDRESS,
|
|
28
28
|
seeds: [
|
|
29
29
|
getBytesEncoder().encode(
|
|
30
30
|
new Uint8Array([
|
|
31
|
-
99, 114, 101, 97, 116, 111, 114, 95, 102, 101, 101, 95,
|
|
32
|
-
|
|
31
|
+
99, 114, 101, 97, 116, 111, 114, 95, 102, 101, 101, 95, 99,
|
|
32
|
+
111, 110, 102, 105, 103,
|
|
33
33
|
]),
|
|
34
34
|
),
|
|
35
|
-
getAddressEncoder().encode(seeds.
|
|
35
|
+
getAddressEncoder().encode(seeds.baseMint),
|
|
36
36
|
getAddressEncoder().encode(seeds.quoteMint),
|
|
37
37
|
],
|
|
38
38
|
});
|
|
@@ -70,6 +70,7 @@ import {
|
|
|
70
70
|
type SellExactOutAsyncInput,
|
|
71
71
|
} from '../instructions/index.js';
|
|
72
72
|
import {
|
|
73
|
+
findCreatorFeeConfigPda,
|
|
73
74
|
findEventAuthorityPda,
|
|
74
75
|
findGlobalConfigPda,
|
|
75
76
|
findLpMintPda,
|
|
@@ -135,6 +136,7 @@ export type SendDexPluginInstructions = {
|
|
|
135
136
|
export type SendDexPluginPdas = {
|
|
136
137
|
pool: typeof findPoolPda;
|
|
137
138
|
eventAuthority: typeof findEventAuthorityPda;
|
|
139
|
+
creatorFeeConfig: typeof findCreatorFeeConfigPda;
|
|
138
140
|
rewardAccrual: typeof findRewardAccrualPda;
|
|
139
141
|
globalConfig: typeof findGlobalConfigPda;
|
|
140
142
|
lpMint: typeof findLpMintPda;
|
|
@@ -266,6 +268,7 @@ export function sendDexProgram() {
|
|
|
266
268
|
pdas: {
|
|
267
269
|
pool: findPoolPda,
|
|
268
270
|
eventAuthority: findEventAuthorityPda,
|
|
271
|
+
creatorFeeConfig: findCreatorFeeConfigPda,
|
|
269
272
|
rewardAccrual: findRewardAccrualPda,
|
|
270
273
|
globalConfig: findGlobalConfigPda,
|
|
271
274
|
lpMint: findLpMintPda,
|
package/src/launchpad/create.ts
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
import type { Address, Instruction, TransactionSigner } from '@solana/kit';
|
|
2
2
|
import type { MintFee, TradeQuote } from '../math/amm.js';
|
|
3
3
|
import type { PartnerInput } from '../utils/partner.js';
|
|
4
|
-
import { creatorHashFromId } from '../utils/creator-hash.js';
|
|
5
|
-
import { findCreatorFeeConfigPda } from '../nexus/generated/pdas/creatorFeeConfig.js';
|
|
6
4
|
import { getCreateTokenInstructionAsync } from './generated/instructions/createToken.js';
|
|
7
5
|
import { buyExactIn } from './trade.js';
|
|
8
6
|
|
|
9
7
|
export interface CreateTokenParams {
|
|
10
8
|
user: TransactionSigner;
|
|
11
9
|
payer?: TransactionSigner;
|
|
10
|
+
/** The wallet that claims the creator fees. */
|
|
12
11
|
coinCreator: Address;
|
|
13
12
|
baseMint: TransactionSigner;
|
|
14
13
|
quoteMint: Address;
|
|
15
14
|
name: string;
|
|
16
15
|
symbol: string;
|
|
17
16
|
uri: string;
|
|
18
|
-
/** An enabled nexus auth platform, for example "wallet", of at most 32 bytes. It is hashed
|
|
19
|
-
* with `creatorId` into the creator fee identity. It is not `platformConfig`. */
|
|
20
|
-
creatorPlatform: string;
|
|
21
|
-
creatorId: string;
|
|
22
17
|
partner: PartnerInput;
|
|
23
18
|
platformConfig: Address;
|
|
24
19
|
quoteTokenProgram: Address;
|
|
20
|
+
creatorFeeMode: number;
|
|
21
|
+
creatorFeeBps: number;
|
|
22
|
+
/** The creator fee of the pool after migration, in bps. */
|
|
23
|
+
dexCreatorFeeBps: number;
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export interface CreateAndBuyParams extends CreateTokenParams {
|
|
@@ -41,51 +40,28 @@ export interface CreateAndBuyParams extends CreateTokenParams {
|
|
|
41
40
|
export async function buildCreateTokenInstruction(
|
|
42
41
|
params: CreateTokenParams,
|
|
43
42
|
): Promise<Instruction> {
|
|
44
|
-
return buildCreateTokenInstructionWithHash(
|
|
45
|
-
params,
|
|
46
|
-
await creatorHashFromId(params.creatorPlatform, params.creatorId),
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async function buildCreateTokenInstructionWithHash(
|
|
51
|
-
params: CreateTokenParams,
|
|
52
|
-
creatorHash: Address,
|
|
53
|
-
): Promise<Instruction> {
|
|
54
|
-
const [creatorFeeConfig] = await findCreatorFeeConfigPda({
|
|
55
|
-
creatorHash,
|
|
56
|
-
quoteMint: params.quoteMint,
|
|
57
|
-
});
|
|
58
|
-
// `user` pays the creation fee in native SOL. The generated client fills in the WSOL staking vault.
|
|
59
43
|
return getCreateTokenInstructionAsync({
|
|
60
44
|
user: params.user,
|
|
61
45
|
payer: params.payer ?? params.user,
|
|
62
46
|
coinCreator: params.coinCreator,
|
|
63
47
|
baseMint: params.baseMint,
|
|
64
48
|
quoteMint: params.quoteMint,
|
|
65
|
-
creatorFeeConfig,
|
|
66
49
|
partner: params.partner,
|
|
67
50
|
platformConfig: params.platformConfig,
|
|
68
51
|
quoteTokenProgram: params.quoteTokenProgram,
|
|
69
|
-
creatorPlatform: params.creatorPlatform,
|
|
70
|
-
creatorId: params.creatorId,
|
|
71
|
-
creatorHash,
|
|
72
52
|
name: params.name,
|
|
73
53
|
symbol: params.symbol,
|
|
74
54
|
uri: params.uri,
|
|
55
|
+
creatorFeeMode: params.creatorFeeMode,
|
|
56
|
+
creatorFeeBps: params.creatorFeeBps,
|
|
57
|
+
dexCreatorFeeBps: params.dexCreatorFeeBps,
|
|
75
58
|
});
|
|
76
59
|
}
|
|
77
60
|
|
|
78
61
|
export async function buildCreateAndBuyInstructions(
|
|
79
62
|
params: CreateAndBuyParams,
|
|
80
63
|
): Promise<{ instructions: Instruction[]; quote?: TradeQuote }> {
|
|
81
|
-
const
|
|
82
|
-
params.creatorPlatform,
|
|
83
|
-
params.creatorId,
|
|
84
|
-
);
|
|
85
|
-
const createIx = await buildCreateTokenInstructionWithHash(
|
|
86
|
-
params,
|
|
87
|
-
creatorHash,
|
|
88
|
-
);
|
|
64
|
+
const createIx = await buildCreateTokenInstruction(params);
|
|
89
65
|
const instructions: Instruction[] = [createIx];
|
|
90
66
|
let quote: TradeQuote | undefined;
|
|
91
67
|
|
|
@@ -98,7 +74,6 @@ export async function buildCreateAndBuyInstructions(
|
|
|
98
74
|
virtualQuoteReserves: params.initialVirtualQuoteReserves,
|
|
99
75
|
virtualBaseReserves: params.initialVirtualBaseReserves,
|
|
100
76
|
realBaseReserves: params.initialRealBaseReserves,
|
|
101
|
-
// `create_token` sets the curve's `platformConfig` to this key.
|
|
102
77
|
platformConfig: params.platformConfig,
|
|
103
78
|
feeBps: params.feeBps,
|
|
104
79
|
slippageBps: params.slippageBps,
|