pump-trader 1.0.8 → 1.0.9
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.d.ts +1 -0
- package/dist/index.js +8 -4
- package/index.js +12 -7
- package/index.ts +12 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -158,6 +158,7 @@ export declare class PumpTrader {
|
|
|
158
158
|
protocolFeeRecipients: PublicKey[];
|
|
159
159
|
};
|
|
160
160
|
getAmmPoolReserves(poolKeys: any): Promise<PoolReserves>;
|
|
161
|
+
deriveAmmPoolV2(baseMint: PublicKey): PublicKey;
|
|
161
162
|
createAmmBuyInstruction(poolInfo: PoolInfo, userBaseAta: PublicKey, userQuoteAta: PublicKey, baseAmountOut: bigint, maxQuoteAmountIn: bigint, tokenProgramId: PublicKey): TransactionInstruction;
|
|
162
163
|
createAmmSellInstruction(poolInfo: PoolInfo, userBaseAta: PublicKey, userQuoteAta: PublicKey, baseAmountIn: bigint, minQuoteAmountOut: bigint, tokenProgramId: PublicKey): TransactionInstruction;
|
|
163
164
|
confirmTransactionWithPolling(signature: string, lastValidBlockHeight: number, maxAttempts?: number, delayMs?: number): Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -750,11 +750,13 @@ class PumpTrader {
|
|
|
750
750
|
quoteDecimals: quoteInfo.value.decimals
|
|
751
751
|
};
|
|
752
752
|
}
|
|
753
|
+
deriveAmmPoolV2(baseMint) {
|
|
754
|
+
return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("pool-v2"), baseMint.toBuffer()], PROGRAM_IDS.PUMP_AMM)[0];
|
|
755
|
+
}
|
|
753
756
|
/* ---------- AMM 指令构建 ---------- */
|
|
754
757
|
createAmmBuyInstruction(poolInfo, userBaseAta, userQuoteAta, baseAmountOut, maxQuoteAmountIn, tokenProgramId) {
|
|
755
758
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
756
|
-
const
|
|
757
|
-
const [bondingCurveV2] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("bonding-curve-v2"), bondingCurveV2Mint.toBuffer()], PROGRAM_IDS.PUMP);
|
|
759
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
758
760
|
const [eventAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("__event_authority")], PROGRAM_IDS.PUMP_AMM);
|
|
759
761
|
const [coinCreatorVaultAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("creator_vault"), poolKeys.coinCreator.toBuffer()], PROGRAM_IDS.PUMP_AMM);
|
|
760
762
|
const coinCreatorVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, coinCreatorVaultAuthority, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
@@ -789,7 +791,7 @@ class PumpTrader {
|
|
|
789
791
|
{ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
|
|
790
792
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
791
793
|
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
792
|
-
{ pubkey:
|
|
794
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
793
795
|
],
|
|
794
796
|
data: Buffer.concat([
|
|
795
797
|
DISCRIMINATORS.BUY,
|
|
@@ -802,6 +804,7 @@ class PumpTrader {
|
|
|
802
804
|
}
|
|
803
805
|
createAmmSellInstruction(poolInfo, userBaseAta, userQuoteAta, baseAmountIn, minQuoteAmountOut, tokenProgramId) {
|
|
804
806
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
807
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
805
808
|
const [eventAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("__event_authority")], PROGRAM_IDS.PUMP_AMM);
|
|
806
809
|
const [coinCreatorVaultAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("creator_vault"), poolKeys.coinCreator.toBuffer()], PROGRAM_IDS.PUMP_AMM);
|
|
807
810
|
const coinCreatorVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(SOL_MINT, coinCreatorVaultAuthority, true, spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID);
|
|
@@ -831,7 +834,8 @@ class PumpTrader {
|
|
|
831
834
|
{ pubkey: coinCreatorVaultAta, isSigner: false, isWritable: true },
|
|
832
835
|
{ pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
|
|
833
836
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
834
|
-
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false }
|
|
837
|
+
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
838
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
835
839
|
],
|
|
836
840
|
data: Buffer.concat([
|
|
837
841
|
DISCRIMINATORS.SELL,
|
package/index.js
CHANGED
|
@@ -1066,15 +1066,18 @@ export class PumpTrader {
|
|
|
1066
1066
|
};
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
|
+
deriveAmmPoolV2(baseMint) {
|
|
1070
|
+
return PublicKey.findProgramAddressSync(
|
|
1071
|
+
[Buffer.from("pool-v2"), baseMint.toBuffer()],
|
|
1072
|
+
PROGRAM_IDS.PUMP_AMM
|
|
1073
|
+
)[0];
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1069
1076
|
/* ---------- AMM 指令构建 ---------- */
|
|
1070
1077
|
|
|
1071
1078
|
createAmmBuyInstruction(poolInfo, userBaseAta, userQuoteAta, baseAmountOut, maxQuoteAmountIn, tokenProgramId) {
|
|
1072
1079
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
1073
|
-
const
|
|
1074
|
-
const [bondingCurveV2] = PublicKey.findProgramAddressSync(
|
|
1075
|
-
[Buffer.from("bonding-curve-v2"), bondingCurveV2Mint.toBuffer()],
|
|
1076
|
-
PROGRAM_IDS.PUMP
|
|
1077
|
-
);
|
|
1080
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
1078
1081
|
|
|
1079
1082
|
const [eventAuthority] = PublicKey.findProgramAddressSync(
|
|
1080
1083
|
[Buffer.from("__event_authority")],
|
|
@@ -1144,7 +1147,7 @@ export class PumpTrader {
|
|
|
1144
1147
|
{ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
|
|
1145
1148
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
1146
1149
|
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
1147
|
-
{ pubkey:
|
|
1150
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
1148
1151
|
],
|
|
1149
1152
|
data: Buffer.concat([
|
|
1150
1153
|
DISCRIMINATORS.BUY,
|
|
@@ -1157,6 +1160,7 @@ export class PumpTrader {
|
|
|
1157
1160
|
|
|
1158
1161
|
createAmmSellInstruction(poolInfo, userBaseAta, userQuoteAta, baseAmountIn, minQuoteAmountOut, tokenProgramId) {
|
|
1159
1162
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
1163
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
1160
1164
|
|
|
1161
1165
|
const [eventAuthority] = PublicKey.findProgramAddressSync(
|
|
1162
1166
|
[Buffer.from("__event_authority")],
|
|
@@ -1213,7 +1217,8 @@ export class PumpTrader {
|
|
|
1213
1217
|
{ pubkey: coinCreatorVaultAta, isSigner: false, isWritable: true },
|
|
1214
1218
|
{ pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
|
|
1215
1219
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
1216
|
-
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false }
|
|
1220
|
+
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
1221
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
1217
1222
|
],
|
|
1218
1223
|
data: Buffer.concat([
|
|
1219
1224
|
DISCRIMINATORS.SELL,
|
package/index.ts
CHANGED
|
@@ -1172,6 +1172,13 @@ export class PumpTrader {
|
|
|
1172
1172
|
};
|
|
1173
1173
|
}
|
|
1174
1174
|
|
|
1175
|
+
deriveAmmPoolV2(baseMint: PublicKey): PublicKey {
|
|
1176
|
+
return PublicKey.findProgramAddressSync(
|
|
1177
|
+
[Buffer.from("pool-v2"), baseMint.toBuffer()],
|
|
1178
|
+
PROGRAM_IDS.PUMP_AMM
|
|
1179
|
+
)[0];
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1175
1182
|
/* ---------- AMM 指令构建 ---------- */
|
|
1176
1183
|
|
|
1177
1184
|
createAmmBuyInstruction(
|
|
@@ -1183,11 +1190,7 @@ export class PumpTrader {
|
|
|
1183
1190
|
tokenProgramId: PublicKey
|
|
1184
1191
|
): TransactionInstruction {
|
|
1185
1192
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
1186
|
-
const
|
|
1187
|
-
const [bondingCurveV2] = PublicKey.findProgramAddressSync(
|
|
1188
|
-
[Buffer.from("bonding-curve-v2"), bondingCurveV2Mint.toBuffer()],
|
|
1189
|
-
PROGRAM_IDS.PUMP
|
|
1190
|
-
);
|
|
1193
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
1191
1194
|
|
|
1192
1195
|
const [eventAuthority] = PublicKey.findProgramAddressSync(
|
|
1193
1196
|
[Buffer.from("__event_authority")],
|
|
@@ -1257,7 +1260,7 @@ export class PumpTrader {
|
|
|
1257
1260
|
{ pubkey: userVolumeAccumulator, isSigner: false, isWritable: true },
|
|
1258
1261
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
1259
1262
|
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
1260
|
-
{ pubkey:
|
|
1263
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
1261
1264
|
],
|
|
1262
1265
|
data: Buffer.concat([
|
|
1263
1266
|
DISCRIMINATORS.BUY,
|
|
@@ -1278,6 +1281,7 @@ export class PumpTrader {
|
|
|
1278
1281
|
tokenProgramId: PublicKey
|
|
1279
1282
|
): TransactionInstruction {
|
|
1280
1283
|
const { pool, poolKeys, globalConfig } = poolInfo;
|
|
1284
|
+
const poolV2 = this.deriveAmmPoolV2(poolKeys.baseMint);
|
|
1281
1285
|
|
|
1282
1286
|
const [eventAuthority] = PublicKey.findProgramAddressSync(
|
|
1283
1287
|
[Buffer.from("__event_authority")],
|
|
@@ -1334,7 +1338,8 @@ export class PumpTrader {
|
|
|
1334
1338
|
{ pubkey: coinCreatorVaultAta, isSigner: false, isWritable: true },
|
|
1335
1339
|
{ pubkey: coinCreatorVaultAuthority, isSigner: false, isWritable: false },
|
|
1336
1340
|
{ pubkey: feeConfig, isSigner: false, isWritable: false },
|
|
1337
|
-
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false }
|
|
1341
|
+
{ pubkey: PROGRAM_IDS.FEE, isSigner: false, isWritable: false },
|
|
1342
|
+
{ pubkey: poolV2, isSigner: false, isWritable: false }
|
|
1338
1343
|
],
|
|
1339
1344
|
data: Buffer.concat([
|
|
1340
1345
|
DISCRIMINATORS.SELL,
|