pump-trader 1.2.4 → 1.2.5
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/package.json
CHANGED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
|
|
4
|
-
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
5
|
-
import { ASSOCIATED_TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from "@solana/spl-token";
|
|
6
|
-
|
|
7
|
-
import { PumpTrader } from "../index";
|
|
8
|
-
|
|
9
|
-
const SOL_MINT = new PublicKey("So11111111111111111111111111111111111111112");
|
|
10
|
-
const FEE_RECIPIENTS = [
|
|
11
|
-
"62qc2CNXwrYqQScmEdiZFFAnJR262PxWEuNQtxfafNgV",
|
|
12
|
-
"7VtfL8fvgNfhz17qKRMjzQEXgbdpnHHHQRh54R9jP2RJ",
|
|
13
|
-
"7hTckgnGnLQR6sdH7YkqFTAA7VwTfYFaZ6EhEsU3saCX",
|
|
14
|
-
"9rPYyANsfQZw3DnDmKE3YCQF5E8oD89UXoHn9JFEhJUz",
|
|
15
|
-
"AVmoTthdrX6tKt4nDjco2D775W2YK3sDhxPcMmzUAmTY",
|
|
16
|
-
"CebN5WGQ4jvEPvsVU4EoHEpgzq1VV7AbicfhtW4xC9iM",
|
|
17
|
-
"FWsW1xNtWscwNmKv6wVsU1iTzRN6wmmk3MjxRP5tT7hz",
|
|
18
|
-
"G5UZAVbAf46s7cKWoyKu8kYTip9DGTpbLZ2qa9Aq69dP"
|
|
19
|
-
].map((value) => new PublicKey(value));
|
|
20
|
-
|
|
21
|
-
const BUYBACK_FEE_RECIPIENTS = [
|
|
22
|
-
"5YxQFdt3Tr9zJLvkFccqXVUwhdTWJQc1fFg2YPbxvxeD",
|
|
23
|
-
"9M4giFFMxmFGXtc3feFzRai56WbBqehoSeRE5GK7gf7",
|
|
24
|
-
"GXPFM2caqTtQYC2cJ5yJRi9VDkpsYZXzYdwYpGnLmtDL",
|
|
25
|
-
"3BpXnfJaUTiwXnJNe7Ej1rcbzqTTQUvLShZaWazebsVR",
|
|
26
|
-
"5cjcW9wExnJJiqgLjq7DEG75Pm6JBgE1hNv4B2vHXUW6",
|
|
27
|
-
"EHAAiTxcdDwQ3U4bU6YcMsQGaekdzLS3B5SmYo46kJtL",
|
|
28
|
-
"5eHhjP8JaYkz83CWwvGU2uMUXefd3AazWGx4gpcuEEYD",
|
|
29
|
-
"A7hAgCzFw14fejgCp387JUJRMNyz4j89JKnhtKU8piqW"
|
|
30
|
-
].map((value) => new PublicKey(value));
|
|
31
|
-
|
|
32
|
-
function createTrader() {
|
|
33
|
-
return new PumpTrader("http://127.0.0.1:8899", Keypair.generate());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function createPoolInfo(isCashbackCoin: boolean) {
|
|
37
|
-
return {
|
|
38
|
-
pool: Keypair.generate().publicKey,
|
|
39
|
-
poolAuthority: Keypair.generate().publicKey,
|
|
40
|
-
poolKeys: {
|
|
41
|
-
baseMint: Keypair.generate().publicKey,
|
|
42
|
-
quoteMint: SOL_MINT,
|
|
43
|
-
poolBaseTokenAccount: Keypair.generate().publicKey,
|
|
44
|
-
poolQuoteTokenAccount: Keypair.generate().publicKey,
|
|
45
|
-
coinCreator: Keypair.generate().publicKey,
|
|
46
|
-
isCashbackCoin
|
|
47
|
-
},
|
|
48
|
-
globalConfig: {
|
|
49
|
-
address: Keypair.generate().publicKey,
|
|
50
|
-
protocolFeeRecipients: FEE_RECIPIENTS
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
test("bonding buy appends mutable fee recipient after bondingCurveV2", () => {
|
|
56
|
-
const trader = createTrader() as any;
|
|
57
|
-
const bondingCurveV2 = Keypair.generate().publicKey;
|
|
58
|
-
const feeRecipient = FEE_RECIPIENTS[0];
|
|
59
|
-
|
|
60
|
-
const keys = trader.buildBondingBuyKeys({
|
|
61
|
-
global: Keypair.generate().publicKey,
|
|
62
|
-
globalFeeRecipient: Keypair.generate().publicKey,
|
|
63
|
-
mint: Keypair.generate().publicKey,
|
|
64
|
-
bonding: Keypair.generate().publicKey,
|
|
65
|
-
associatedBondingCurve: Keypair.generate().publicKey,
|
|
66
|
-
userAta: Keypair.generate().publicKey,
|
|
67
|
-
wallet: Keypair.generate().publicKey,
|
|
68
|
-
creatorVault: Keypair.generate().publicKey,
|
|
69
|
-
eventAuthority: Keypair.generate().publicKey,
|
|
70
|
-
pumpProgram: Keypair.generate().publicKey,
|
|
71
|
-
globalVolumeAccumulator: Keypair.generate().publicKey,
|
|
72
|
-
userVolumeAccumulator: Keypair.generate().publicKey,
|
|
73
|
-
feeConfig: Keypair.generate().publicKey,
|
|
74
|
-
feeProgram: Keypair.generate().publicKey,
|
|
75
|
-
bondingCurveV2,
|
|
76
|
-
feeRecipient
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
assert.equal(keys.length, 18);
|
|
80
|
-
assert.equal(keys.at(-2).pubkey.toBase58(), bondingCurveV2.toBase58());
|
|
81
|
-
assert.equal(keys.at(-2).isWritable, false);
|
|
82
|
-
assert.equal(keys.at(-1).pubkey.toBase58(), feeRecipient.toBase58());
|
|
83
|
-
assert.equal(keys.at(-1).isWritable, true);
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
test("bonding sell appends mutable fee recipient after optional cashback and bondingCurveV2", () => {
|
|
87
|
-
const trader = createTrader() as any;
|
|
88
|
-
const baseArgs = {
|
|
89
|
-
global: Keypair.generate().publicKey,
|
|
90
|
-
globalFeeRecipient: Keypair.generate().publicKey,
|
|
91
|
-
mint: Keypair.generate().publicKey,
|
|
92
|
-
bonding: Keypair.generate().publicKey,
|
|
93
|
-
associatedBondingCurve: Keypair.generate().publicKey,
|
|
94
|
-
userAta: Keypair.generate().publicKey,
|
|
95
|
-
wallet: Keypair.generate().publicKey,
|
|
96
|
-
creatorVault: Keypair.generate().publicKey,
|
|
97
|
-
eventAuthority: Keypair.generate().publicKey,
|
|
98
|
-
pumpProgram: Keypair.generate().publicKey,
|
|
99
|
-
feeConfig: Keypair.generate().publicKey,
|
|
100
|
-
feeProgram: Keypair.generate().publicKey,
|
|
101
|
-
bondingCurveV2: Keypair.generate().publicKey,
|
|
102
|
-
feeRecipient: FEE_RECIPIENTS[0],
|
|
103
|
-
userVolumeAccumulator: Keypair.generate().publicKey
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const nonCashback = trader.buildBondingSellKeys({
|
|
107
|
-
...baseArgs,
|
|
108
|
-
isCashbackCoin: false
|
|
109
|
-
});
|
|
110
|
-
assert.equal(nonCashback.length, 16);
|
|
111
|
-
assert.equal(nonCashback.at(-2).pubkey.toBase58(), baseArgs.bondingCurveV2.toBase58());
|
|
112
|
-
assert.equal(nonCashback.at(-1).pubkey.toBase58(), baseArgs.feeRecipient.toBase58());
|
|
113
|
-
assert.equal(nonCashback.at(-1).isWritable, true);
|
|
114
|
-
|
|
115
|
-
const cashback = trader.buildBondingSellKeys({
|
|
116
|
-
...baseArgs,
|
|
117
|
-
isCashbackCoin: true
|
|
118
|
-
});
|
|
119
|
-
assert.equal(cashback.length, 17);
|
|
120
|
-
assert.equal(cashback.at(-3).pubkey.toBase58(), baseArgs.userVolumeAccumulator.toBase58());
|
|
121
|
-
assert.equal(cashback.at(-2).pubkey.toBase58(), baseArgs.bondingCurveV2.toBase58());
|
|
122
|
-
assert.equal(cashback.at(-1).pubkey.toBase58(), baseArgs.feeRecipient.toBase58());
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
test("amm buy places poolV2 before fee recipient pair for non-cashback coins", () => {
|
|
126
|
-
const trader = createTrader();
|
|
127
|
-
const poolInfo = createPoolInfo(false);
|
|
128
|
-
const userBaseAta = Keypair.generate().publicKey;
|
|
129
|
-
const userQuoteAta = Keypair.generate().publicKey;
|
|
130
|
-
|
|
131
|
-
const instruction = trader.createAmmBuyInstruction(
|
|
132
|
-
poolInfo as any,
|
|
133
|
-
userBaseAta,
|
|
134
|
-
userQuoteAta,
|
|
135
|
-
1n,
|
|
136
|
-
2n,
|
|
137
|
-
TOKEN_PROGRAM_ID
|
|
138
|
-
);
|
|
139
|
-
|
|
140
|
-
const feeRecipient = BUYBACK_FEE_RECIPIENTS[0];
|
|
141
|
-
const feeRecipientAta = getAssociatedTokenAddressSync(
|
|
142
|
-
SOL_MINT,
|
|
143
|
-
feeRecipient,
|
|
144
|
-
true,
|
|
145
|
-
TOKEN_PROGRAM_ID,
|
|
146
|
-
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
147
|
-
);
|
|
148
|
-
|
|
149
|
-
assert.equal(instruction.keys[9]?.pubkey.toBase58(), poolInfo.globalConfig.protocolFeeRecipients[0].toBase58());
|
|
150
|
-
assert.equal(instruction.keys.length, 26);
|
|
151
|
-
assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
|
|
152
|
-
assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), feeRecipient.toBase58());
|
|
153
|
-
assert.equal(instruction.keys.at(-2)?.isWritable, false);
|
|
154
|
-
assert.equal(instruction.keys.at(-1)?.pubkey.toBase58(), feeRecipientAta.toBase58());
|
|
155
|
-
assert.equal(instruction.keys.at(-1)?.isWritable, true);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
test("amm buy places cashback account before poolV2 and fee recipient tail", () => {
|
|
159
|
-
const trader = createTrader();
|
|
160
|
-
const poolInfo = createPoolInfo(true);
|
|
161
|
-
|
|
162
|
-
const instruction = trader.createAmmBuyInstruction(
|
|
163
|
-
poolInfo as any,
|
|
164
|
-
Keypair.generate().publicKey,
|
|
165
|
-
Keypair.generate().publicKey,
|
|
166
|
-
1n,
|
|
167
|
-
2n,
|
|
168
|
-
TOKEN_PROGRAM_ID
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
assert.equal(instruction.keys.length, 27);
|
|
172
|
-
assert.equal(instruction.keys.at(-3)?.isWritable, false);
|
|
173
|
-
assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), BUYBACK_FEE_RECIPIENTS[0].toBase58());
|
|
174
|
-
assert.equal(instruction.keys.at(-1)?.isWritable, true);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
test("amm sell places poolV2 before fee recipient pair for non-cashback coins", () => {
|
|
178
|
-
const trader = createTrader();
|
|
179
|
-
const poolInfo = createPoolInfo(false);
|
|
180
|
-
|
|
181
|
-
const instruction = trader.createAmmSellInstruction(
|
|
182
|
-
poolInfo as any,
|
|
183
|
-
Keypair.generate().publicKey,
|
|
184
|
-
Keypair.generate().publicKey,
|
|
185
|
-
1n,
|
|
186
|
-
2n,
|
|
187
|
-
TOKEN_PROGRAM_ID
|
|
188
|
-
);
|
|
189
|
-
|
|
190
|
-
assert.equal(instruction.keys.length, 24);
|
|
191
|
-
assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
|
|
192
|
-
assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), BUYBACK_FEE_RECIPIENTS[0].toBase58());
|
|
193
|
-
assert.equal(instruction.keys.at(-1)?.isWritable, true);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
test("amm sell places cashback accounts before poolV2 and fee recipient tail", () => {
|
|
197
|
-
const trader = createTrader();
|
|
198
|
-
const poolInfo = createPoolInfo(true);
|
|
199
|
-
|
|
200
|
-
const instruction = trader.createAmmSellInstruction(
|
|
201
|
-
poolInfo as any,
|
|
202
|
-
Keypair.generate().publicKey,
|
|
203
|
-
Keypair.generate().publicKey,
|
|
204
|
-
1n,
|
|
205
|
-
2n,
|
|
206
|
-
TOKEN_PROGRAM_ID
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
assert.equal(instruction.keys.length, 26);
|
|
210
|
-
assert.equal(instruction.keys.at(-3)?.pubkey.toBase58(), trader.deriveAmmPoolV2(poolInfo.poolKeys.baseMint).toBase58());
|
|
211
|
-
assert.equal(instruction.keys.at(-2)?.pubkey.toBase58(), BUYBACK_FEE_RECIPIENTS[0].toBase58());
|
|
212
|
-
assert.equal(instruction.keys.at(-1)?.pubkey.toBase58(), getAssociatedTokenAddressSync(
|
|
213
|
-
SOL_MINT,
|
|
214
|
-
BUYBACK_FEE_RECIPIENTS[0],
|
|
215
|
-
true,
|
|
216
|
-
TOKEN_PROGRAM_ID,
|
|
217
|
-
ASSOCIATED_TOKEN_PROGRAM_ID
|
|
218
|
-
).toBase58());
|
|
219
|
-
assert.equal(instruction.keys.at(-1)?.isWritable, true);
|
|
220
|
-
});
|