@pump-fun/pump-sdk 1.3.4 → 1.3.5-devnet.1
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/esm/index.js +1 -1
- package/dist/index.d.mts +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +37 -27
- package/package.json +3 -1
- package/src/bondingCurve.spec.ts +1 -1
- package/src/bondingCurve.ts +1 -1
- package/src/state.ts +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2632,8 +2632,8 @@ var pump_default = {
|
|
|
2632
2632
|
};
|
|
2633
2633
|
|
|
2634
2634
|
// src/bondingCurve.ts
|
|
2635
|
-
import { BN } from "@coral-xyz/anchor";
|
|
2636
2635
|
import { PublicKey } from "@solana/web3.js";
|
|
2636
|
+
import BN from "bn.js";
|
|
2637
2637
|
function getFee(global, bondingCurve, amount, newCoin) {
|
|
2638
2638
|
return computeFee(amount, global.feeBasisPoints).add(
|
|
2639
2639
|
newCoin || !PublicKey.default.equals(bondingCurve.creator) ? computeFee(amount, global.creatorFeeBasisPoints) : new BN(0)
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import { PublicKey, PublicKeyInitData, Connection, AccountInfo, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { Program, BN as BN$1 } from '@coral-xyz/anchor';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -5666,14 +5667,14 @@ declare class PumpSdk {
|
|
|
5666
5667
|
fetchGlobal(): Promise<Global>;
|
|
5667
5668
|
fetchBondingCurve(mint: PublicKeyInitData): Promise<BondingCurve>;
|
|
5668
5669
|
createInstruction(mint: PublicKey, name: string, symbol: string, uri: string, creator: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5669
|
-
buyInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, bondingCurve: BondingCurve, mint: PublicKey, user: PublicKey, amount: BN, solAmount: BN, slippage: number, newCoinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5670
|
-
sellInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, mint: PublicKey, user: PublicKey, amount: BN, solAmount: BN, slippage: number): Promise<TransactionInstruction[]>;
|
|
5670
|
+
buyInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, bondingCurve: BondingCurve, mint: PublicKey, user: PublicKey, amount: BN$1, solAmount: BN$1, slippage: number, newCoinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5671
|
+
sellInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, mint: PublicKey, user: PublicKey, amount: BN$1, solAmount: BN$1, slippage: number): Promise<TransactionInstruction[]>;
|
|
5671
5672
|
fixExistingBondingCurve(mint: PublicKey, bondingCurveAccountInfo: AccountInfo<Buffer> | null, user: PublicKey): Promise<TransactionInstruction[]>;
|
|
5672
5673
|
private withFixBondingCurve;
|
|
5673
5674
|
extendAccount(account: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5674
5675
|
migrateInstruction(mint: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5675
5676
|
collectCoinCreatorFeeInstructions(coinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5676
|
-
getCreatorVaultBalance(creator: PublicKey): Promise<BN>;
|
|
5677
|
+
getCreatorVaultBalance(creator: PublicKey): Promise<BN$1>;
|
|
5677
5678
|
}
|
|
5678
5679
|
|
|
5679
5680
|
export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getPumpProgram, getSellSolAmountFromTokenAmount, globalPda, pump as pumpIdl, pumpPoolAuthorityPda };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import BN from 'bn.js';
|
|
2
2
|
import { PublicKey, PublicKeyInitData, Connection, AccountInfo, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import { Program, BN as BN$1 } from '@coral-xyz/anchor';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Program IDL in camelCase format in order to be used in JS/TS.
|
|
@@ -5666,14 +5667,14 @@ declare class PumpSdk {
|
|
|
5666
5667
|
fetchGlobal(): Promise<Global>;
|
|
5667
5668
|
fetchBondingCurve(mint: PublicKeyInitData): Promise<BondingCurve>;
|
|
5668
5669
|
createInstruction(mint: PublicKey, name: string, symbol: string, uri: string, creator: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5669
|
-
buyInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, bondingCurve: BondingCurve, mint: PublicKey, user: PublicKey, amount: BN, solAmount: BN, slippage: number, newCoinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5670
|
-
sellInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, mint: PublicKey, user: PublicKey, amount: BN, solAmount: BN, slippage: number): Promise<TransactionInstruction[]>;
|
|
5670
|
+
buyInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, bondingCurve: BondingCurve, mint: PublicKey, user: PublicKey, amount: BN$1, solAmount: BN$1, slippage: number, newCoinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5671
|
+
sellInstructions(global: Global, bondingCurveAccountInfo: AccountInfo<Buffer> | null, mint: PublicKey, user: PublicKey, amount: BN$1, solAmount: BN$1, slippage: number): Promise<TransactionInstruction[]>;
|
|
5671
5672
|
fixExistingBondingCurve(mint: PublicKey, bondingCurveAccountInfo: AccountInfo<Buffer> | null, user: PublicKey): Promise<TransactionInstruction[]>;
|
|
5672
5673
|
private withFixBondingCurve;
|
|
5673
5674
|
extendAccount(account: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5674
5675
|
migrateInstruction(mint: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
5675
5676
|
collectCoinCreatorFeeInstructions(coinCreator: PublicKey): Promise<TransactionInstruction[]>;
|
|
5676
|
-
getCreatorVaultBalance(creator: PublicKey): Promise<BN>;
|
|
5677
|
+
getCreatorVaultBalance(creator: PublicKey): Promise<BN$1>;
|
|
5677
5678
|
}
|
|
5678
5679
|
|
|
5679
5680
|
export { BONDING_CURVE_NEW_SIZE, type BondingCurve, CANONICAL_POOL_INDEX, type Global, PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID, type Pump, PumpSdk, bondingCurvePda, canonicalPumpPoolPda, creatorVaultPda, getBuySolAmountFromTokenAmount, getBuyTokenAmountFromSolAmount, getPumpProgram, getSellSolAmountFromTokenAmount, globalPda, pump as pumpIdl, pumpPoolAuthorityPda };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
@@ -2672,50 +2682,50 @@ var pump_default = {
|
|
|
2672
2682
|
};
|
|
2673
2683
|
|
|
2674
2684
|
// src/bondingCurve.ts
|
|
2675
|
-
var import_anchor = require("@coral-xyz/anchor");
|
|
2676
2685
|
var import_web3 = require("@solana/web3.js");
|
|
2686
|
+
var import_bn = __toESM(require("bn.js"));
|
|
2677
2687
|
function getFee(global, bondingCurve, amount, newCoin) {
|
|
2678
2688
|
return computeFee(amount, global.feeBasisPoints).add(
|
|
2679
|
-
newCoin || !import_web3.PublicKey.default.equals(bondingCurve.creator) ? computeFee(amount, global.creatorFeeBasisPoints) : new
|
|
2689
|
+
newCoin || !import_web3.PublicKey.default.equals(bondingCurve.creator) ? computeFee(amount, global.creatorFeeBasisPoints) : new import_bn.default(0)
|
|
2680
2690
|
);
|
|
2681
2691
|
}
|
|
2682
2692
|
function computeFee(amount, feeBasisPoints) {
|
|
2683
|
-
return ceilDiv(amount.mul(feeBasisPoints), new
|
|
2693
|
+
return ceilDiv(amount.mul(feeBasisPoints), new import_bn.default(1e4));
|
|
2684
2694
|
}
|
|
2685
2695
|
function ceilDiv(a, b) {
|
|
2686
2696
|
return a.add(b.subn(1)).div(b);
|
|
2687
2697
|
}
|
|
2688
2698
|
function getBuyTokenAmountFromSolAmount(global, bondingCurve, amount, newCoin) {
|
|
2689
|
-
if (amount.eq(new
|
|
2690
|
-
return new
|
|
2699
|
+
if (amount.eq(new import_bn.default(0))) {
|
|
2700
|
+
return new import_bn.default(0);
|
|
2691
2701
|
}
|
|
2692
|
-
if (bondingCurve.virtualTokenReserves.eq(new
|
|
2693
|
-
return new
|
|
2702
|
+
if (bondingCurve.virtualTokenReserves.eq(new import_bn.default(0))) {
|
|
2703
|
+
return new import_bn.default(0);
|
|
2694
2704
|
}
|
|
2695
2705
|
const totalFeeBasisPoints = global.feeBasisPoints.add(
|
|
2696
|
-
newCoin || !import_web3.PublicKey.default.equals(bondingCurve.creator) ? global.creatorFeeBasisPoints : new
|
|
2706
|
+
newCoin || !import_web3.PublicKey.default.equals(bondingCurve.creator) ? global.creatorFeeBasisPoints : new import_bn.default(0)
|
|
2697
2707
|
);
|
|
2698
2708
|
const inputAmount = amount.muln(1e4).div(totalFeeBasisPoints.addn(1e4));
|
|
2699
2709
|
const tokensReceived = inputAmount.mul(bondingCurve.virtualTokenReserves).div(bondingCurve.virtualSolReserves.add(inputAmount));
|
|
2700
|
-
return
|
|
2710
|
+
return import_bn.default.min(tokensReceived, bondingCurve.realTokenReserves);
|
|
2701
2711
|
}
|
|
2702
2712
|
function getBuySolAmountFromTokenAmount(global, bondingCurve, amount, newCoin) {
|
|
2703
|
-
if (amount.eq(new
|
|
2704
|
-
return new
|
|
2713
|
+
if (amount.eq(new import_bn.default(0))) {
|
|
2714
|
+
return new import_bn.default(0);
|
|
2705
2715
|
}
|
|
2706
|
-
if (bondingCurve.virtualTokenReserves.eq(new
|
|
2707
|
-
return new
|
|
2716
|
+
if (bondingCurve.virtualTokenReserves.eq(new import_bn.default(0))) {
|
|
2717
|
+
return new import_bn.default(0);
|
|
2708
2718
|
}
|
|
2709
|
-
const minAmount =
|
|
2710
|
-
const solCost = minAmount.mul(bondingCurve.virtualSolReserves).div(bondingCurve.virtualTokenReserves.sub(minAmount)).add(new
|
|
2719
|
+
const minAmount = import_bn.default.min(amount, bondingCurve.realTokenReserves);
|
|
2720
|
+
const solCost = minAmount.mul(bondingCurve.virtualSolReserves).div(bondingCurve.virtualTokenReserves.sub(minAmount)).add(new import_bn.default(1));
|
|
2711
2721
|
return solCost.add(getFee(global, bondingCurve, solCost, newCoin));
|
|
2712
2722
|
}
|
|
2713
2723
|
function getSellSolAmountFromTokenAmount(global, bondingCurve, amount) {
|
|
2714
|
-
if (amount.eq(new
|
|
2715
|
-
return new
|
|
2724
|
+
if (amount.eq(new import_bn.default(0))) {
|
|
2725
|
+
return new import_bn.default(0);
|
|
2716
2726
|
}
|
|
2717
|
-
if (bondingCurve.virtualTokenReserves.eq(new
|
|
2718
|
-
return new
|
|
2727
|
+
if (bondingCurve.virtualTokenReserves.eq(new import_bn.default(0))) {
|
|
2728
|
+
return new import_bn.default(0);
|
|
2719
2729
|
}
|
|
2720
2730
|
const solCost = amount.mul(bondingCurve.virtualSolReserves).div(bondingCurve.virtualTokenReserves.add(amount));
|
|
2721
2731
|
return solCost.sub(getFee(global, bondingCurve, solCost, false));
|
|
@@ -2765,16 +2775,16 @@ function canonicalPumpPoolPda(pumpProgramId, pumpAmmProgramId, mint) {
|
|
|
2765
2775
|
}
|
|
2766
2776
|
|
|
2767
2777
|
// src/sdk.ts
|
|
2768
|
-
var
|
|
2778
|
+
var import_anchor = require("@coral-xyz/anchor");
|
|
2769
2779
|
var import_pump_swap_sdk2 = require("@pump-fun/pump-swap-sdk");
|
|
2770
2780
|
var import_spl_token2 = require("@solana/spl-token");
|
|
2771
2781
|
var import_web33 = require("@solana/web3.js");
|
|
2772
2782
|
function getPumpProgram(connection, programId) {
|
|
2773
2783
|
const pumpIdlAddressOverride = { ...pump_default };
|
|
2774
2784
|
pumpIdlAddressOverride.address = programId.toString();
|
|
2775
|
-
return new
|
|
2785
|
+
return new import_anchor.Program(
|
|
2776
2786
|
pumpIdlAddressOverride,
|
|
2777
|
-
new
|
|
2787
|
+
new import_anchor.AnchorProvider(connection, null, {})
|
|
2778
2788
|
);
|
|
2779
2789
|
}
|
|
2780
2790
|
var PUMP_PROGRAM_ID = new import_web33.PublicKey(
|
|
@@ -2864,7 +2874,7 @@ var PumpSdk = class {
|
|
|
2864
2874
|
await this.pumpProgram.methods.buy(
|
|
2865
2875
|
amount,
|
|
2866
2876
|
solAmount.add(
|
|
2867
|
-
solAmount.mul(new
|
|
2877
|
+
solAmount.mul(new import_anchor.BN(Math.floor(slippage * 10))).div(new import_anchor.BN(1e3))
|
|
2868
2878
|
)
|
|
2869
2879
|
).accountsPartial({
|
|
2870
2880
|
feeRecipient: getFeeRecipient(global),
|
|
@@ -2890,7 +2900,7 @@ var PumpSdk = class {
|
|
|
2890
2900
|
await this.pumpProgram.methods.sell(
|
|
2891
2901
|
amount,
|
|
2892
2902
|
solAmount.sub(
|
|
2893
|
-
solAmount.mul(new
|
|
2903
|
+
solAmount.mul(new import_anchor.BN(Math.floor(slippage * 10))).div(new import_anchor.BN(1e3))
|
|
2894
2904
|
)
|
|
2895
2905
|
).accountsPartial({
|
|
2896
2906
|
feeRecipient: getFeeRecipient(global),
|
|
@@ -2943,15 +2953,15 @@ var PumpSdk = class {
|
|
|
2943
2953
|
const creatorVault = this.creatorVaultPda(creator);
|
|
2944
2954
|
const accountInfo = await this.connection.getAccountInfo(creatorVault);
|
|
2945
2955
|
if (accountInfo === null) {
|
|
2946
|
-
return new
|
|
2956
|
+
return new import_anchor.BN(0);
|
|
2947
2957
|
}
|
|
2948
2958
|
const rentExemptionLamports = await this.connection.getMinimumBalanceForRentExemption(
|
|
2949
2959
|
accountInfo.data.length
|
|
2950
2960
|
);
|
|
2951
2961
|
if (accountInfo.lamports < rentExemptionLamports) {
|
|
2952
|
-
return new
|
|
2962
|
+
return new import_anchor.BN(0);
|
|
2953
2963
|
}
|
|
2954
|
-
return new
|
|
2964
|
+
return new import_anchor.BN(accountInfo.lamports - rentExemptionLamports);
|
|
2955
2965
|
}
|
|
2956
2966
|
};
|
|
2957
2967
|
function getFeeRecipient(global) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pump-fun/pump-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5-devnet.1",
|
|
4
4
|
"description": "Pump Bonding Curve SDK",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/pump-fun/pump-sdk#readme",
|
|
@@ -42,10 +42,12 @@
|
|
|
42
42
|
"@pump-fun/pump-swap-sdk": "^0.0.1-beta.29",
|
|
43
43
|
"@solana/spl-token": "^0.4.13",
|
|
44
44
|
"@solana/web3.js": "^1.98.2",
|
|
45
|
+
"bn.js": "^5.2.2",
|
|
45
46
|
"undici-types": "^6.20.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@semantic-release/git": "^10.0.1",
|
|
50
|
+
"@types/bn.js": "^5.1.6",
|
|
49
51
|
"@types/jest": "^29.5.14",
|
|
50
52
|
"@types/node": "^20.0.0",
|
|
51
53
|
"cz-conventional-changelog": "^3.3.0",
|
package/src/bondingCurve.spec.ts
CHANGED
package/src/bondingCurve.ts
CHANGED
package/src/state.ts
CHANGED