@pump-fun/pump-sdk 1.18.3 → 1.18.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/dist/esm/index.js +40 -21
- package/dist/index.d.mts +2 -8
- package/dist/index.d.ts +2 -8
- package/dist/index.js +40 -21
- package/package.json +2 -2
- package/src/bondingCurve.ts +20 -16
- package/src/fees.ts +89 -79
- package/src/idl/pump.json +0 -4
- package/src/idl/pump.ts +0 -4
- package/src/pda.ts +5 -1
- package/src/sdk.ts +23 -0
package/dist/esm/index.js
CHANGED
|
@@ -740,7 +740,6 @@ var pump_default = {
|
|
|
740
740
|
},
|
|
741
741
|
{
|
|
742
742
|
name: "fee_config",
|
|
743
|
-
optional: true,
|
|
744
743
|
pda: {
|
|
745
744
|
seeds: [
|
|
746
745
|
{
|
|
@@ -804,7 +803,6 @@ var pump_default = {
|
|
|
804
803
|
},
|
|
805
804
|
{
|
|
806
805
|
name: "fee_program",
|
|
807
|
-
optional: true,
|
|
808
806
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
809
807
|
}
|
|
810
808
|
],
|
|
@@ -2569,7 +2567,6 @@ var pump_default = {
|
|
|
2569
2567
|
},
|
|
2570
2568
|
{
|
|
2571
2569
|
name: "fee_config",
|
|
2572
|
-
optional: true,
|
|
2573
2570
|
pda: {
|
|
2574
2571
|
seeds: [
|
|
2575
2572
|
{
|
|
@@ -2633,7 +2630,6 @@ var pump_default = {
|
|
|
2633
2630
|
},
|
|
2634
2631
|
{
|
|
2635
2632
|
name: "fee_program",
|
|
2636
|
-
optional: true,
|
|
2637
2633
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
2638
2634
|
}
|
|
2639
2635
|
],
|
|
@@ -4829,14 +4825,16 @@ function getBuySolAmountFromTokenAmount({
|
|
|
4829
4825
|
virtualTokenReserves: bondingCurve.virtualTokenReserves,
|
|
4830
4826
|
virtualSolReserves: bondingCurve.virtualSolReserves
|
|
4831
4827
|
});
|
|
4832
|
-
return solCost.add(
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4828
|
+
return solCost.add(
|
|
4829
|
+
getFee({
|
|
4830
|
+
global,
|
|
4831
|
+
feeConfig,
|
|
4832
|
+
mintSupply,
|
|
4833
|
+
bondingCurve,
|
|
4834
|
+
amount: solCost,
|
|
4835
|
+
isNewBondingCurve
|
|
4836
|
+
})
|
|
4837
|
+
);
|
|
4840
4838
|
}
|
|
4841
4839
|
function getSellSolAmountFromTokenAmount({
|
|
4842
4840
|
global,
|
|
@@ -4856,14 +4854,16 @@ function getSellSolAmountFromTokenAmount({
|
|
|
4856
4854
|
virtualTokenReserves: bondingCurve.virtualTokenReserves,
|
|
4857
4855
|
virtualSolReserves: bondingCurve.virtualSolReserves
|
|
4858
4856
|
});
|
|
4859
|
-
return solCost.sub(
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4857
|
+
return solCost.sub(
|
|
4858
|
+
getFee({
|
|
4859
|
+
global,
|
|
4860
|
+
feeConfig,
|
|
4861
|
+
mintSupply,
|
|
4862
|
+
bondingCurve,
|
|
4863
|
+
amount: solCost,
|
|
4864
|
+
isNewBondingCurve: false
|
|
4865
|
+
})
|
|
4866
|
+
);
|
|
4867
4867
|
}
|
|
4868
4868
|
function getStaticRandomFeeRecipient() {
|
|
4869
4869
|
const randomIndex = Math.floor(Math.random() * CURRENT_FEE_RECIPIENTS.length);
|
|
@@ -4953,7 +4953,10 @@ function computeFeesBps({
|
|
|
4953
4953
|
creatorFeeBps: global.creatorFeeBasisPoints
|
|
4954
4954
|
};
|
|
4955
4955
|
}
|
|
4956
|
-
function calculateFeeTier({
|
|
4956
|
+
function calculateFeeTier({
|
|
4957
|
+
feeTiers,
|
|
4958
|
+
marketCap
|
|
4959
|
+
}) {
|
|
4957
4960
|
const firstTier = feeTiers[0];
|
|
4958
4961
|
if (marketCap.lt(firstTier.marketCapLamportsThreshold)) {
|
|
4959
4962
|
return firstTier.fees;
|
|
@@ -5104,6 +5107,14 @@ var PumpSdk = class {
|
|
|
5104
5107
|
accountInfo.data
|
|
5105
5108
|
);
|
|
5106
5109
|
}
|
|
5110
|
+
decodeBondingCurveNullable(accountInfo) {
|
|
5111
|
+
try {
|
|
5112
|
+
return this.decodeBondingCurve(accountInfo);
|
|
5113
|
+
} catch (e) {
|
|
5114
|
+
console.warn("Failed to decode bonding curve", e);
|
|
5115
|
+
return null;
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5107
5118
|
decodeGlobalVolumeAccumulator(accountInfo) {
|
|
5108
5119
|
return this.offlinePumpProgram.coder.accounts.decode(
|
|
5109
5120
|
"globalVolumeAccumulator",
|
|
@@ -5116,6 +5127,14 @@ var PumpSdk = class {
|
|
|
5116
5127
|
accountInfo.data
|
|
5117
5128
|
);
|
|
5118
5129
|
}
|
|
5130
|
+
decodeUserVolumeAccumulatorNullable(accountInfo) {
|
|
5131
|
+
try {
|
|
5132
|
+
return this.decodeUserVolumeAccumulator(accountInfo);
|
|
5133
|
+
} catch (e) {
|
|
5134
|
+
console.warn("Failed to decode user volume accumulator", e);
|
|
5135
|
+
return null;
|
|
5136
|
+
}
|
|
5137
|
+
}
|
|
5119
5138
|
async fetchGlobal() {
|
|
5120
5139
|
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
5121
5140
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -749,7 +749,6 @@ type Pump = {
|
|
|
749
749
|
},
|
|
750
750
|
{
|
|
751
751
|
"name": "feeConfig";
|
|
752
|
-
"optional": true;
|
|
753
752
|
"pda": {
|
|
754
753
|
"seeds": [
|
|
755
754
|
{
|
|
@@ -813,7 +812,6 @@ type Pump = {
|
|
|
813
812
|
},
|
|
814
813
|
{
|
|
815
814
|
"name": "feeProgram";
|
|
816
|
-
"optional": true;
|
|
817
815
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
|
|
818
816
|
}
|
|
819
817
|
];
|
|
@@ -2578,7 +2576,6 @@ type Pump = {
|
|
|
2578
2576
|
},
|
|
2579
2577
|
{
|
|
2580
2578
|
"name": "feeConfig";
|
|
2581
|
-
"optional": true;
|
|
2582
2579
|
"pda": {
|
|
2583
2580
|
"seeds": [
|
|
2584
2581
|
{
|
|
@@ -2642,7 +2639,6 @@ type Pump = {
|
|
|
2642
2639
|
},
|
|
2643
2640
|
{
|
|
2644
2641
|
"name": "feeProgram";
|
|
2645
|
-
"optional": true;
|
|
2646
2642
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
|
|
2647
2643
|
}
|
|
2648
2644
|
];
|
|
@@ -5477,7 +5473,6 @@ var instructions = [
|
|
|
5477
5473
|
},
|
|
5478
5474
|
{
|
|
5479
5475
|
name: "fee_config",
|
|
5480
|
-
optional: true,
|
|
5481
5476
|
pda: {
|
|
5482
5477
|
seeds: [
|
|
5483
5478
|
{
|
|
@@ -5541,7 +5536,6 @@ var instructions = [
|
|
|
5541
5536
|
},
|
|
5542
5537
|
{
|
|
5543
5538
|
name: "fee_program",
|
|
5544
|
-
optional: true,
|
|
5545
5539
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
5546
5540
|
}
|
|
5547
5541
|
],
|
|
@@ -7313,7 +7307,6 @@ var instructions = [
|
|
|
7313
7307
|
},
|
|
7314
7308
|
{
|
|
7315
7309
|
name: "fee_config",
|
|
7316
|
-
optional: true,
|
|
7317
7310
|
pda: {
|
|
7318
7311
|
seeds: [
|
|
7319
7312
|
{
|
|
@@ -7377,7 +7370,6 @@ var instructions = [
|
|
|
7377
7370
|
},
|
|
7378
7371
|
{
|
|
7379
7372
|
name: "fee_program",
|
|
7380
|
-
optional: true,
|
|
7381
7373
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
7382
7374
|
}
|
|
7383
7375
|
],
|
|
@@ -9614,8 +9606,10 @@ declare class PumpSdk {
|
|
|
9614
9606
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global;
|
|
9615
9607
|
decodeFeeConfig(accountInfo: AccountInfo<Buffer>): FeeConfig;
|
|
9616
9608
|
decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve;
|
|
9609
|
+
decodeBondingCurveNullable(accountInfo: AccountInfo<Buffer>): BondingCurve | null;
|
|
9617
9610
|
decodeGlobalVolumeAccumulator(accountInfo: AccountInfo<Buffer>): GlobalVolumeAccumulator;
|
|
9618
9611
|
decodeUserVolumeAccumulator(accountInfo: AccountInfo<Buffer>): UserVolumeAccumulator;
|
|
9612
|
+
decodeUserVolumeAccumulatorNullable(accountInfo: AccountInfo<Buffer>): UserVolumeAccumulator | null;
|
|
9619
9613
|
fetchGlobal(): Promise<Global>;
|
|
9620
9614
|
fetchFeeConfig(): Promise<FeeConfig>;
|
|
9621
9615
|
fetchBondingCurve(mint: PublicKeyInitData): Promise<BondingCurve>;
|
package/dist/index.d.ts
CHANGED
|
@@ -749,7 +749,6 @@ type Pump = {
|
|
|
749
749
|
},
|
|
750
750
|
{
|
|
751
751
|
"name": "feeConfig";
|
|
752
|
-
"optional": true;
|
|
753
752
|
"pda": {
|
|
754
753
|
"seeds": [
|
|
755
754
|
{
|
|
@@ -813,7 +812,6 @@ type Pump = {
|
|
|
813
812
|
},
|
|
814
813
|
{
|
|
815
814
|
"name": "feeProgram";
|
|
816
|
-
"optional": true;
|
|
817
815
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
|
|
818
816
|
}
|
|
819
817
|
];
|
|
@@ -2578,7 +2576,6 @@ type Pump = {
|
|
|
2578
2576
|
},
|
|
2579
2577
|
{
|
|
2580
2578
|
"name": "feeConfig";
|
|
2581
|
-
"optional": true;
|
|
2582
2579
|
"pda": {
|
|
2583
2580
|
"seeds": [
|
|
2584
2581
|
{
|
|
@@ -2642,7 +2639,6 @@ type Pump = {
|
|
|
2642
2639
|
},
|
|
2643
2640
|
{
|
|
2644
2641
|
"name": "feeProgram";
|
|
2645
|
-
"optional": true;
|
|
2646
2642
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ";
|
|
2647
2643
|
}
|
|
2648
2644
|
];
|
|
@@ -5477,7 +5473,6 @@ var instructions = [
|
|
|
5477
5473
|
},
|
|
5478
5474
|
{
|
|
5479
5475
|
name: "fee_config",
|
|
5480
|
-
optional: true,
|
|
5481
5476
|
pda: {
|
|
5482
5477
|
seeds: [
|
|
5483
5478
|
{
|
|
@@ -5541,7 +5536,6 @@ var instructions = [
|
|
|
5541
5536
|
},
|
|
5542
5537
|
{
|
|
5543
5538
|
name: "fee_program",
|
|
5544
|
-
optional: true,
|
|
5545
5539
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
5546
5540
|
}
|
|
5547
5541
|
],
|
|
@@ -7313,7 +7307,6 @@ var instructions = [
|
|
|
7313
7307
|
},
|
|
7314
7308
|
{
|
|
7315
7309
|
name: "fee_config",
|
|
7316
|
-
optional: true,
|
|
7317
7310
|
pda: {
|
|
7318
7311
|
seeds: [
|
|
7319
7312
|
{
|
|
@@ -7377,7 +7370,6 @@ var instructions = [
|
|
|
7377
7370
|
},
|
|
7378
7371
|
{
|
|
7379
7372
|
name: "fee_program",
|
|
7380
|
-
optional: true,
|
|
7381
7373
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
7382
7374
|
}
|
|
7383
7375
|
],
|
|
@@ -9614,8 +9606,10 @@ declare class PumpSdk {
|
|
|
9614
9606
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global;
|
|
9615
9607
|
decodeFeeConfig(accountInfo: AccountInfo<Buffer>): FeeConfig;
|
|
9616
9608
|
decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve;
|
|
9609
|
+
decodeBondingCurveNullable(accountInfo: AccountInfo<Buffer>): BondingCurve | null;
|
|
9617
9610
|
decodeGlobalVolumeAccumulator(accountInfo: AccountInfo<Buffer>): GlobalVolumeAccumulator;
|
|
9618
9611
|
decodeUserVolumeAccumulator(accountInfo: AccountInfo<Buffer>): UserVolumeAccumulator;
|
|
9612
|
+
decodeUserVolumeAccumulatorNullable(accountInfo: AccountInfo<Buffer>): UserVolumeAccumulator | null;
|
|
9619
9613
|
fetchGlobal(): Promise<Global>;
|
|
9620
9614
|
fetchFeeConfig(): Promise<FeeConfig>;
|
|
9621
9615
|
fetchBondingCurve(mint: PublicKeyInitData): Promise<BondingCurve>;
|
package/dist/index.js
CHANGED
|
@@ -801,7 +801,6 @@ var pump_default = {
|
|
|
801
801
|
},
|
|
802
802
|
{
|
|
803
803
|
name: "fee_config",
|
|
804
|
-
optional: true,
|
|
805
804
|
pda: {
|
|
806
805
|
seeds: [
|
|
807
806
|
{
|
|
@@ -865,7 +864,6 @@ var pump_default = {
|
|
|
865
864
|
},
|
|
866
865
|
{
|
|
867
866
|
name: "fee_program",
|
|
868
|
-
optional: true,
|
|
869
867
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
870
868
|
}
|
|
871
869
|
],
|
|
@@ -2630,7 +2628,6 @@ var pump_default = {
|
|
|
2630
2628
|
},
|
|
2631
2629
|
{
|
|
2632
2630
|
name: "fee_config",
|
|
2633
|
-
optional: true,
|
|
2634
2631
|
pda: {
|
|
2635
2632
|
seeds: [
|
|
2636
2633
|
{
|
|
@@ -2694,7 +2691,6 @@ var pump_default = {
|
|
|
2694
2691
|
},
|
|
2695
2692
|
{
|
|
2696
2693
|
name: "fee_program",
|
|
2697
|
-
optional: true,
|
|
2698
2694
|
address: "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
2699
2695
|
}
|
|
2700
2696
|
],
|
|
@@ -4890,14 +4886,16 @@ function getBuySolAmountFromTokenAmount({
|
|
|
4890
4886
|
virtualTokenReserves: bondingCurve.virtualTokenReserves,
|
|
4891
4887
|
virtualSolReserves: bondingCurve.virtualSolReserves
|
|
4892
4888
|
});
|
|
4893
|
-
return solCost.add(
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4889
|
+
return solCost.add(
|
|
4890
|
+
getFee({
|
|
4891
|
+
global,
|
|
4892
|
+
feeConfig,
|
|
4893
|
+
mintSupply,
|
|
4894
|
+
bondingCurve,
|
|
4895
|
+
amount: solCost,
|
|
4896
|
+
isNewBondingCurve
|
|
4897
|
+
})
|
|
4898
|
+
);
|
|
4901
4899
|
}
|
|
4902
4900
|
function getSellSolAmountFromTokenAmount({
|
|
4903
4901
|
global,
|
|
@@ -4917,14 +4915,16 @@ function getSellSolAmountFromTokenAmount({
|
|
|
4917
4915
|
virtualTokenReserves: bondingCurve.virtualTokenReserves,
|
|
4918
4916
|
virtualSolReserves: bondingCurve.virtualSolReserves
|
|
4919
4917
|
});
|
|
4920
|
-
return solCost.sub(
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4918
|
+
return solCost.sub(
|
|
4919
|
+
getFee({
|
|
4920
|
+
global,
|
|
4921
|
+
feeConfig,
|
|
4922
|
+
mintSupply,
|
|
4923
|
+
bondingCurve,
|
|
4924
|
+
amount: solCost,
|
|
4925
|
+
isNewBondingCurve: false
|
|
4926
|
+
})
|
|
4927
|
+
);
|
|
4928
4928
|
}
|
|
4929
4929
|
function getStaticRandomFeeRecipient() {
|
|
4930
4930
|
const randomIndex = Math.floor(Math.random() * CURRENT_FEE_RECIPIENTS.length);
|
|
@@ -5014,7 +5014,10 @@ function computeFeesBps({
|
|
|
5014
5014
|
creatorFeeBps: global.creatorFeeBasisPoints
|
|
5015
5015
|
};
|
|
5016
5016
|
}
|
|
5017
|
-
function calculateFeeTier({
|
|
5017
|
+
function calculateFeeTier({
|
|
5018
|
+
feeTiers,
|
|
5019
|
+
marketCap
|
|
5020
|
+
}) {
|
|
5018
5021
|
const firstTier = feeTiers[0];
|
|
5019
5022
|
if (marketCap.lt(firstTier.marketCapLamportsThreshold)) {
|
|
5020
5023
|
return firstTier.fees;
|
|
@@ -5157,6 +5160,14 @@ var PumpSdk = class {
|
|
|
5157
5160
|
accountInfo.data
|
|
5158
5161
|
);
|
|
5159
5162
|
}
|
|
5163
|
+
decodeBondingCurveNullable(accountInfo) {
|
|
5164
|
+
try {
|
|
5165
|
+
return this.decodeBondingCurve(accountInfo);
|
|
5166
|
+
} catch (e) {
|
|
5167
|
+
console.warn("Failed to decode bonding curve", e);
|
|
5168
|
+
return null;
|
|
5169
|
+
}
|
|
5170
|
+
}
|
|
5160
5171
|
decodeGlobalVolumeAccumulator(accountInfo) {
|
|
5161
5172
|
return this.offlinePumpProgram.coder.accounts.decode(
|
|
5162
5173
|
"globalVolumeAccumulator",
|
|
@@ -5169,6 +5180,14 @@ var PumpSdk = class {
|
|
|
5169
5180
|
accountInfo.data
|
|
5170
5181
|
);
|
|
5171
5182
|
}
|
|
5183
|
+
decodeUserVolumeAccumulatorNullable(accountInfo) {
|
|
5184
|
+
try {
|
|
5185
|
+
return this.decodeUserVolumeAccumulator(accountInfo);
|
|
5186
|
+
} catch (e) {
|
|
5187
|
+
console.warn("Failed to decode user volume accumulator", e);
|
|
5188
|
+
return null;
|
|
5189
|
+
}
|
|
5190
|
+
}
|
|
5172
5191
|
async fetchGlobal() {
|
|
5173
5192
|
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
5174
5193
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pump-fun/pump-sdk",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.5",
|
|
4
4
|
"description": "Pump Bonding Curve SDK",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/pump-fun/pump-sdk#readme",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@coral-xyz/anchor": "^0.31.1",
|
|
42
|
-
"@pump-fun/pump-swap-sdk": "^1.7.
|
|
42
|
+
"@pump-fun/pump-swap-sdk": "^1.7.2",
|
|
43
43
|
"@solana/spl-token": "^0.4.13",
|
|
44
44
|
"@solana/web3.js": "^1.98.2",
|
|
45
45
|
"bn.js": "^5.2.2",
|
package/src/bondingCurve.ts
CHANGED
|
@@ -152,14 +152,16 @@ export function getBuySolAmountFromTokenAmount({
|
|
|
152
152
|
virtualSolReserves: bondingCurve.virtualSolReserves,
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
return solCost.add(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
return solCost.add(
|
|
156
|
+
getFee({
|
|
157
|
+
global,
|
|
158
|
+
feeConfig,
|
|
159
|
+
mintSupply,
|
|
160
|
+
bondingCurve,
|
|
161
|
+
amount: solCost,
|
|
162
|
+
isNewBondingCurve,
|
|
163
|
+
}),
|
|
164
|
+
);
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
export function getSellSolAmountFromTokenAmount({
|
|
@@ -190,14 +192,16 @@ export function getSellSolAmountFromTokenAmount({
|
|
|
190
192
|
virtualSolReserves: bondingCurve.virtualSolReserves,
|
|
191
193
|
});
|
|
192
194
|
|
|
193
|
-
return solCost.sub(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
195
|
+
return solCost.sub(
|
|
196
|
+
getFee({
|
|
197
|
+
global,
|
|
198
|
+
feeConfig,
|
|
199
|
+
mintSupply,
|
|
200
|
+
bondingCurve,
|
|
201
|
+
amount: solCost,
|
|
202
|
+
isNewBondingCurve: false,
|
|
203
|
+
}),
|
|
204
|
+
);
|
|
201
205
|
}
|
|
202
206
|
|
|
203
207
|
export function getStaticRandomFeeRecipient(): PublicKey {
|
package/src/fees.ts
CHANGED
|
@@ -4,115 +4,125 @@ import { FeeConfig, Global, Fees, BondingCurve, FeeTier } from "./state";
|
|
|
4
4
|
import { bondingCurveMarketCap } from "./bondingCurve";
|
|
5
5
|
|
|
6
6
|
export interface CalculatedFeesBps {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
protocolFeeBps: BN;
|
|
8
|
+
creatorFeeBps: BN;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export interface CalculatedFees {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
protocolFee: BN;
|
|
13
|
+
creatorFee: BN;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function createFeeConfigFromGlobalConfig(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
export function createFeeConfigFromGlobalConfig(
|
|
17
|
+
globalConfig: Global,
|
|
18
|
+
): FeeConfig {
|
|
19
|
+
let fees: Fees = {
|
|
20
|
+
lpFeeBps: new BN(0), // unused for pump
|
|
21
|
+
protocolFeeBps: globalConfig.feeBasisPoints,
|
|
22
|
+
creatorFeeBps: globalConfig.creatorFeeBasisPoints,
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
admin: globalConfig.authority,
|
|
26
|
+
flatFees: fees,
|
|
27
|
+
feeTiers: [
|
|
28
|
+
{
|
|
29
|
+
marketCapLamportsThreshold: new BN(0), // unused for pump
|
|
30
|
+
fees,
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export function getFee({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
global,
|
|
38
|
+
feeConfig,
|
|
39
|
+
mintSupply,
|
|
40
|
+
bondingCurve,
|
|
41
|
+
amount,
|
|
42
|
+
isNewBondingCurve,
|
|
41
43
|
}: {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
global: Global;
|
|
45
|
+
feeConfig: FeeConfig | null;
|
|
46
|
+
mintSupply: BN;
|
|
47
|
+
bondingCurve: BondingCurve;
|
|
48
|
+
amount: BN;
|
|
49
|
+
isNewBondingCurve: boolean;
|
|
48
50
|
}) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
global,
|
|
52
|
-
feeConfig,
|
|
53
|
-
mintSupply,
|
|
54
|
-
virtualSolReserves,
|
|
55
|
-
virtualTokenReserves,
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
return fee(amount, protocolFeeBps).add(
|
|
59
|
-
isNewBondingCurve || !PublicKey.default.equals(bondingCurve.creator) ? fee(amount, creatorFeeBps) : new BN(0)
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function computeFeesBps({
|
|
51
|
+
const { virtualSolReserves, virtualTokenReserves } = bondingCurve;
|
|
52
|
+
const { protocolFeeBps, creatorFeeBps } = computeFeesBps({
|
|
64
53
|
global,
|
|
65
54
|
feeConfig,
|
|
66
55
|
mintSupply,
|
|
67
56
|
virtualSolReserves,
|
|
68
57
|
virtualTokenReserves,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return fee(amount, protocolFeeBps).add(
|
|
61
|
+
isNewBondingCurve || !PublicKey.default.equals(bondingCurve.creator)
|
|
62
|
+
? fee(amount, creatorFeeBps)
|
|
63
|
+
: new BN(0),
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function computeFeesBps({
|
|
68
|
+
global,
|
|
69
|
+
feeConfig,
|
|
70
|
+
mintSupply,
|
|
71
|
+
virtualSolReserves,
|
|
72
|
+
virtualTokenReserves,
|
|
69
73
|
}: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
global: Global;
|
|
75
|
+
feeConfig: FeeConfig | null;
|
|
76
|
+
mintSupply: BN;
|
|
77
|
+
virtualSolReserves: BN;
|
|
78
|
+
virtualTokenReserves: BN;
|
|
75
79
|
}): CalculatedFeesBps {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
if (feeConfig != null) {
|
|
81
|
+
const marketCap = bondingCurveMarketCap({
|
|
82
|
+
mintSupply,
|
|
83
|
+
virtualSolReserves,
|
|
84
|
+
virtualTokenReserves,
|
|
85
|
+
});
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
return calculateFeeTier({
|
|
88
|
+
feeTiers: feeConfig.feeTiers,
|
|
89
|
+
marketCap,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
88
92
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
return {
|
|
94
|
+
protocolFeeBps: global.feeBasisPoints,
|
|
95
|
+
creatorFeeBps: global.creatorFeeBasisPoints,
|
|
96
|
+
};
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
/// rust reference: pump-fees-math::calculate_fee_tier()
|
|
96
|
-
export function calculateFeeTier({
|
|
97
|
-
|
|
100
|
+
export function calculateFeeTier({
|
|
101
|
+
feeTiers,
|
|
102
|
+
marketCap,
|
|
103
|
+
}: {
|
|
104
|
+
feeTiers: FeeTier[];
|
|
105
|
+
marketCap: BN;
|
|
106
|
+
}): Fees {
|
|
107
|
+
const firstTier = feeTiers[0];
|
|
98
108
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
109
|
+
if (marketCap.lt(firstTier.marketCapLamportsThreshold)) {
|
|
110
|
+
return firstTier.fees;
|
|
111
|
+
}
|
|
102
112
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
113
|
+
for (const tier of feeTiers.slice().reverse()) {
|
|
114
|
+
if (marketCap.gte(tier.marketCapLamportsThreshold)) {
|
|
115
|
+
return tier.fees;
|
|
107
116
|
}
|
|
117
|
+
}
|
|
108
118
|
|
|
109
|
-
|
|
119
|
+
return firstTier.fees;
|
|
110
120
|
}
|
|
111
121
|
|
|
112
122
|
function fee(amount: BN, feeBasisPoints: BN): BN {
|
|
113
|
-
|
|
123
|
+
return ceilDiv(amount.mul(feeBasisPoints), new BN(10_000));
|
|
114
124
|
}
|
|
115
125
|
|
|
116
126
|
function ceilDiv(a: BN, b: BN): BN {
|
|
117
|
-
|
|
127
|
+
return a.add(b.subn(1)).div(b);
|
|
118
128
|
}
|
package/src/idl/pump.json
CHANGED
|
@@ -739,7 +739,6 @@
|
|
|
739
739
|
},
|
|
740
740
|
{
|
|
741
741
|
"name": "fee_config",
|
|
742
|
-
"optional": true,
|
|
743
742
|
"pda": {
|
|
744
743
|
"seeds": [
|
|
745
744
|
{
|
|
@@ -803,7 +802,6 @@
|
|
|
803
802
|
},
|
|
804
803
|
{
|
|
805
804
|
"name": "fee_program",
|
|
806
|
-
"optional": true,
|
|
807
805
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
808
806
|
}
|
|
809
807
|
],
|
|
@@ -2568,7 +2566,6 @@
|
|
|
2568
2566
|
},
|
|
2569
2567
|
{
|
|
2570
2568
|
"name": "fee_config",
|
|
2571
|
-
"optional": true,
|
|
2572
2569
|
"pda": {
|
|
2573
2570
|
"seeds": [
|
|
2574
2571
|
{
|
|
@@ -2632,7 +2629,6 @@
|
|
|
2632
2629
|
},
|
|
2633
2630
|
{
|
|
2634
2631
|
"name": "fee_program",
|
|
2635
|
-
"optional": true,
|
|
2636
2632
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
2637
2633
|
}
|
|
2638
2634
|
],
|
package/src/idl/pump.ts
CHANGED
|
@@ -745,7 +745,6 @@ export type Pump = {
|
|
|
745
745
|
},
|
|
746
746
|
{
|
|
747
747
|
"name": "feeConfig",
|
|
748
|
-
"optional": true,
|
|
749
748
|
"pda": {
|
|
750
749
|
"seeds": [
|
|
751
750
|
{
|
|
@@ -809,7 +808,6 @@ export type Pump = {
|
|
|
809
808
|
},
|
|
810
809
|
{
|
|
811
810
|
"name": "feeProgram",
|
|
812
|
-
"optional": true,
|
|
813
811
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
814
812
|
}
|
|
815
813
|
],
|
|
@@ -2574,7 +2572,6 @@ export type Pump = {
|
|
|
2574
2572
|
},
|
|
2575
2573
|
{
|
|
2576
2574
|
"name": "feeConfig",
|
|
2577
|
-
"optional": true,
|
|
2578
2575
|
"pda": {
|
|
2579
2576
|
"seeds": [
|
|
2580
2577
|
{
|
|
@@ -2638,7 +2635,6 @@ export type Pump = {
|
|
|
2638
2635
|
},
|
|
2639
2636
|
{
|
|
2640
2637
|
"name": "feeProgram",
|
|
2641
|
-
"optional": true,
|
|
2642
2638
|
"address": "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
|
|
2643
2639
|
}
|
|
2644
2640
|
],
|
package/src/pda.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { PublicKey, PublicKeyInitData } from "@solana/web3.js";
|
|
2
2
|
import { NATIVE_MINT } from "@solana/spl-token";
|
|
3
3
|
import { poolPda } from "@pump-fun/pump-swap-sdk";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
PUMP_AMM_PROGRAM_ID,
|
|
6
|
+
PUMP_FEE_PROGRAM_ID,
|
|
7
|
+
PUMP_PROGRAM_ID,
|
|
8
|
+
} from "./sdk";
|
|
5
9
|
|
|
6
10
|
export function globalPda(): PublicKey {
|
|
7
11
|
const [globalPda] = PublicKey.findProgramAddressSync(
|
package/src/sdk.ts
CHANGED
|
@@ -104,6 +104,17 @@ export class PumpSdk {
|
|
|
104
104
|
);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
decodeBondingCurveNullable(
|
|
108
|
+
accountInfo: AccountInfo<Buffer>,
|
|
109
|
+
): BondingCurve | null {
|
|
110
|
+
try {
|
|
111
|
+
return this.decodeBondingCurve(accountInfo);
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.warn("Failed to decode bonding curve", e);
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
107
118
|
decodeGlobalVolumeAccumulator(
|
|
108
119
|
accountInfo: AccountInfo<Buffer>,
|
|
109
120
|
): GlobalVolumeAccumulator {
|
|
@@ -121,6 +132,18 @@ export class PumpSdk {
|
|
|
121
132
|
accountInfo.data,
|
|
122
133
|
);
|
|
123
134
|
}
|
|
135
|
+
|
|
136
|
+
decodeUserVolumeAccumulatorNullable(
|
|
137
|
+
accountInfo: AccountInfo<Buffer>,
|
|
138
|
+
): UserVolumeAccumulator | null {
|
|
139
|
+
try {
|
|
140
|
+
return this.decodeUserVolumeAccumulator(accountInfo);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
console.warn("Failed to decode user volume accumulator", e);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
124
147
|
async fetchGlobal(): Promise<Global> {
|
|
125
148
|
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
126
149
|
}
|