@pump-fun/pump-sdk 1.9.2-devnet.2 → 1.9.3-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 +46 -69
- package/dist/index.d.mts +14 -16
- package/dist/index.d.ts +14 -16
- package/dist/index.js +46 -69
- package/package.json +1 -1
- package/src/pda.ts +16 -31
- package/src/sdk.ts +37 -68
package/dist/esm/index.js
CHANGED
|
@@ -4338,11 +4338,9 @@ function currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator, curren
|
|
|
4338
4338
|
}
|
|
4339
4339
|
|
|
4340
4340
|
// src/sdk.ts
|
|
4341
|
-
function getPumpProgram(connection
|
|
4342
|
-
const pumpIdlAddressOverride = { ...pump_default };
|
|
4343
|
-
pumpIdlAddressOverride.address = programId.toString();
|
|
4341
|
+
function getPumpProgram(connection) {
|
|
4344
4342
|
return new Program(
|
|
4345
|
-
|
|
4343
|
+
pump_default,
|
|
4346
4344
|
new AnchorProvider(connection, null, {})
|
|
4347
4345
|
);
|
|
4348
4346
|
}
|
|
@@ -4357,47 +4355,16 @@ var PUMP_TOKEN_MINT = new PublicKey2(
|
|
|
4357
4355
|
"pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
|
|
4358
4356
|
);
|
|
4359
4357
|
var PumpSdk = class {
|
|
4360
|
-
constructor(connection
|
|
4358
|
+
constructor(connection) {
|
|
4361
4359
|
this.connection = connection;
|
|
4362
|
-
this.pumpProgram = getPumpProgram(connection
|
|
4363
|
-
this.offlinePumpProgram = getPumpProgram(
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
);
|
|
4367
|
-
this.pumpAmmSdk = new PumpAmmSdk(connection, pumpAmmProgramId.toBase58());
|
|
4368
|
-
this.pumpAmmAdminSdk = new PumpAmmAdminSdk(
|
|
4369
|
-
connection,
|
|
4370
|
-
pumpAmmProgramId.toBase58()
|
|
4371
|
-
);
|
|
4360
|
+
this.pumpProgram = getPumpProgram(connection);
|
|
4361
|
+
this.offlinePumpProgram = getPumpProgram(null);
|
|
4362
|
+
this.pumpAmmSdk = new PumpAmmSdk(connection);
|
|
4363
|
+
this.pumpAmmAdminSdk = new PumpAmmAdminSdk(connection);
|
|
4372
4364
|
}
|
|
4373
4365
|
programId() {
|
|
4374
4366
|
return this.offlinePumpProgram.programId;
|
|
4375
4367
|
}
|
|
4376
|
-
globalPda() {
|
|
4377
|
-
return globalPda(this.offlinePumpProgram.programId);
|
|
4378
|
-
}
|
|
4379
|
-
bondingCurvePda(mint) {
|
|
4380
|
-
return bondingCurvePda(this.offlinePumpProgram.programId, mint);
|
|
4381
|
-
}
|
|
4382
|
-
creatorVaultPda(creator) {
|
|
4383
|
-
return creatorVaultPda(this.offlinePumpProgram.programId, creator);
|
|
4384
|
-
}
|
|
4385
|
-
pumpPoolAuthorityPda(mint) {
|
|
4386
|
-
return pumpPoolAuthorityPda(mint, this.offlinePumpProgram.programId);
|
|
4387
|
-
}
|
|
4388
|
-
canonicalPumpPoolPda(mint) {
|
|
4389
|
-
return canonicalPumpPoolPda(
|
|
4390
|
-
this.offlinePumpProgram.programId,
|
|
4391
|
-
this.pumpAmmSdk.programId(),
|
|
4392
|
-
mint
|
|
4393
|
-
);
|
|
4394
|
-
}
|
|
4395
|
-
globalVolumeAccumulatorPda() {
|
|
4396
|
-
return globalVolumeAccumulatorPda(this.offlinePumpProgram.programId);
|
|
4397
|
-
}
|
|
4398
|
-
userVolumeAccumulatorPda(user) {
|
|
4399
|
-
return userVolumeAccumulatorPda(user, this.offlinePumpProgram.programId);
|
|
4400
|
-
}
|
|
4401
4368
|
decodeGlobal(accountInfo) {
|
|
4402
4369
|
return this.offlinePumpProgram.coder.accounts.decode(
|
|
4403
4370
|
"global",
|
|
@@ -4423,16 +4390,16 @@ var PumpSdk = class {
|
|
|
4423
4390
|
);
|
|
4424
4391
|
}
|
|
4425
4392
|
async fetchGlobal() {
|
|
4426
|
-
return await this.pumpProgram.account.global.fetch(
|
|
4393
|
+
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
4427
4394
|
}
|
|
4428
4395
|
async fetchBondingCurve(mint) {
|
|
4429
4396
|
return await this.pumpProgram.account.bondingCurve.fetch(
|
|
4430
|
-
|
|
4397
|
+
bondingCurvePda(mint)
|
|
4431
4398
|
);
|
|
4432
4399
|
}
|
|
4433
4400
|
async fetchBuyState(mint, user) {
|
|
4434
4401
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
|
|
4435
|
-
|
|
4402
|
+
bondingCurvePda(mint),
|
|
4436
4403
|
getAssociatedTokenAddressSync(mint, user, true)
|
|
4437
4404
|
]);
|
|
4438
4405
|
if (!bondingCurveAccountInfo) {
|
|
@@ -4445,7 +4412,7 @@ var PumpSdk = class {
|
|
|
4445
4412
|
}
|
|
4446
4413
|
async fetchSellState(mint, user) {
|
|
4447
4414
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
|
|
4448
|
-
|
|
4415
|
+
bondingCurvePda(mint),
|
|
4449
4416
|
getAssociatedTokenAddressSync(mint, user, true)
|
|
4450
4417
|
]);
|
|
4451
4418
|
if (!bondingCurveAccountInfo) {
|
|
@@ -4463,12 +4430,12 @@ var PumpSdk = class {
|
|
|
4463
4430
|
}
|
|
4464
4431
|
async fetchGlobalVolumeAccumulator() {
|
|
4465
4432
|
return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
|
|
4466
|
-
|
|
4433
|
+
globalVolumeAccumulatorPda()[0]
|
|
4467
4434
|
);
|
|
4468
4435
|
}
|
|
4469
4436
|
async fetchUserVolumeAccumulator(user) {
|
|
4470
4437
|
return await this.pumpProgram.account.userVolumeAccumulator.fetch(
|
|
4471
|
-
|
|
4438
|
+
userVolumeAccumulatorPda(user)[0]
|
|
4472
4439
|
);
|
|
4473
4440
|
}
|
|
4474
4441
|
async createInstruction({
|
|
@@ -4499,7 +4466,7 @@ var PumpSdk = class {
|
|
|
4499
4466
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
4500
4467
|
instructions.push(
|
|
4501
4468
|
await this.extendAccountInstruction({
|
|
4502
|
-
account:
|
|
4469
|
+
account: bondingCurvePda(mint),
|
|
4503
4470
|
user
|
|
4504
4471
|
})
|
|
4505
4472
|
);
|
|
@@ -4544,7 +4511,7 @@ var PumpSdk = class {
|
|
|
4544
4511
|
return [
|
|
4545
4512
|
await this.createInstruction({ mint, name, symbol, uri, creator, user }),
|
|
4546
4513
|
await this.extendAccountInstruction({
|
|
4547
|
-
account:
|
|
4514
|
+
account: bondingCurvePda(mint),
|
|
4548
4515
|
user
|
|
4549
4516
|
}),
|
|
4550
4517
|
createAssociatedTokenAccountIdempotentInstruction(
|
|
@@ -4585,7 +4552,7 @@ var PumpSdk = class {
|
|
|
4585
4552
|
mint,
|
|
4586
4553
|
associatedUser,
|
|
4587
4554
|
user,
|
|
4588
|
-
creatorVault:
|
|
4555
|
+
creatorVault: creatorVaultPda(creator)
|
|
4589
4556
|
}).instruction();
|
|
4590
4557
|
}
|
|
4591
4558
|
async sellInstructions({
|
|
@@ -4602,7 +4569,7 @@ var PumpSdk = class {
|
|
|
4602
4569
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
4603
4570
|
instructions.push(
|
|
4604
4571
|
await this.extendAccountInstruction({
|
|
4605
|
-
account:
|
|
4572
|
+
account: bondingCurvePda(mint),
|
|
4606
4573
|
user
|
|
4607
4574
|
})
|
|
4608
4575
|
);
|
|
@@ -4618,7 +4585,7 @@ var PumpSdk = class {
|
|
|
4618
4585
|
mint,
|
|
4619
4586
|
associatedUser: getAssociatedTokenAddressSync(mint, user, true),
|
|
4620
4587
|
user,
|
|
4621
|
-
creatorVault:
|
|
4588
|
+
creatorVault: creatorVaultPda(bondingCurve.creator)
|
|
4622
4589
|
}).instruction()
|
|
4623
4590
|
);
|
|
4624
4591
|
return instructions;
|
|
@@ -4689,7 +4656,7 @@ var PumpSdk = class {
|
|
|
4689
4656
|
];
|
|
4690
4657
|
}
|
|
4691
4658
|
async getCreatorVaultBalance(creator) {
|
|
4692
|
-
const creatorVault =
|
|
4659
|
+
const creatorVault = creatorVaultPda(creator);
|
|
4693
4660
|
const accountInfo = await this.connection.getAccountInfo(creatorVault);
|
|
4694
4661
|
if (accountInfo === null) {
|
|
4695
4662
|
return new BN3(0);
|
|
@@ -4825,6 +4792,16 @@ var PumpSdk = class {
|
|
|
4825
4792
|
await this.pumpAmmSdk.syncUserVolumeAccumulator(user)
|
|
4826
4793
|
];
|
|
4827
4794
|
}
|
|
4795
|
+
async setCreator({
|
|
4796
|
+
mint,
|
|
4797
|
+
setCreatorAuthority,
|
|
4798
|
+
creator
|
|
4799
|
+
}) {
|
|
4800
|
+
return await this.offlinePumpProgram.methods.setCreator(creator).accountsPartial({
|
|
4801
|
+
mint,
|
|
4802
|
+
setCreatorAuthority
|
|
4803
|
+
}).instruction();
|
|
4804
|
+
}
|
|
4828
4805
|
};
|
|
4829
4806
|
function getFeeRecipient(global) {
|
|
4830
4807
|
const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
|
|
@@ -4832,54 +4809,54 @@ function getFeeRecipient(global) {
|
|
|
4832
4809
|
}
|
|
4833
4810
|
|
|
4834
4811
|
// src/pda.ts
|
|
4835
|
-
function globalPda(
|
|
4812
|
+
function globalPda() {
|
|
4836
4813
|
const [globalPda2] = PublicKey3.findProgramAddressSync(
|
|
4837
4814
|
[Buffer.from("global")],
|
|
4838
|
-
|
|
4815
|
+
PUMP_PROGRAM_ID
|
|
4839
4816
|
);
|
|
4840
4817
|
return globalPda2;
|
|
4841
4818
|
}
|
|
4842
|
-
function bondingCurvePda(
|
|
4819
|
+
function bondingCurvePda(mint) {
|
|
4843
4820
|
const [bondingCurvePda2] = PublicKey3.findProgramAddressSync(
|
|
4844
4821
|
[Buffer.from("bonding-curve"), new PublicKey3(mint).toBuffer()],
|
|
4845
|
-
|
|
4822
|
+
PUMP_PROGRAM_ID
|
|
4846
4823
|
);
|
|
4847
4824
|
return bondingCurvePda2;
|
|
4848
4825
|
}
|
|
4849
|
-
function creatorVaultPda(
|
|
4826
|
+
function creatorVaultPda(creator) {
|
|
4850
4827
|
const [creatorVault] = PublicKey3.findProgramAddressSync(
|
|
4851
4828
|
[Buffer.from("creator-vault"), creator.toBuffer()],
|
|
4852
|
-
|
|
4829
|
+
PUMP_PROGRAM_ID
|
|
4853
4830
|
);
|
|
4854
4831
|
return creatorVault;
|
|
4855
4832
|
}
|
|
4856
|
-
function
|
|
4833
|
+
function pumpPoolAuthorityPda2(mint) {
|
|
4857
4834
|
return PublicKey3.findProgramAddressSync(
|
|
4858
4835
|
[Buffer.from("pool-authority"), mint.toBuffer()],
|
|
4859
|
-
|
|
4836
|
+
PUMP_PROGRAM_ID
|
|
4860
4837
|
);
|
|
4861
4838
|
}
|
|
4862
4839
|
var CANONICAL_POOL_INDEX = 0;
|
|
4863
|
-
function
|
|
4864
|
-
const [pumpPoolAuthority] =
|
|
4840
|
+
function canonicalPumpPoolPda2(mint) {
|
|
4841
|
+
const [pumpPoolAuthority] = pumpPoolAuthorityPda2(mint);
|
|
4865
4842
|
return poolPda(
|
|
4866
4843
|
CANONICAL_POOL_INDEX,
|
|
4867
4844
|
pumpPoolAuthority,
|
|
4868
4845
|
mint,
|
|
4869
4846
|
NATIVE_MINT2,
|
|
4870
|
-
|
|
4847
|
+
PUMP_AMM_PROGRAM_ID
|
|
4871
4848
|
);
|
|
4872
4849
|
}
|
|
4873
|
-
function globalVolumeAccumulatorPda(
|
|
4850
|
+
function globalVolumeAccumulatorPda() {
|
|
4874
4851
|
return PublicKey3.findProgramAddressSync(
|
|
4875
4852
|
[Buffer.from("global_volume_accumulator")],
|
|
4876
|
-
|
|
4853
|
+
PUMP_PROGRAM_ID
|
|
4877
4854
|
);
|
|
4878
4855
|
}
|
|
4879
|
-
function userVolumeAccumulatorPda(user
|
|
4856
|
+
function userVolumeAccumulatorPda(user) {
|
|
4880
4857
|
return PublicKey3.findProgramAddressSync(
|
|
4881
4858
|
[Buffer.from("user_volume_accumulator"), user.toBuffer()],
|
|
4882
|
-
|
|
4859
|
+
PUMP_PROGRAM_ID
|
|
4883
4860
|
);
|
|
4884
4861
|
}
|
|
4885
4862
|
export {
|
|
@@ -4889,7 +4866,7 @@ export {
|
|
|
4889
4866
|
PUMP_PROGRAM_ID,
|
|
4890
4867
|
PumpSdk,
|
|
4891
4868
|
bondingCurvePda,
|
|
4892
|
-
canonicalPumpPoolPda,
|
|
4869
|
+
canonicalPumpPoolPda2 as canonicalPumpPoolPda,
|
|
4893
4870
|
creatorVaultPda,
|
|
4894
4871
|
currentDayTokens,
|
|
4895
4872
|
getBuySolAmountFromTokenAmount,
|
|
@@ -4900,7 +4877,7 @@ export {
|
|
|
4900
4877
|
globalVolumeAccumulatorPda,
|
|
4901
4878
|
newBondingCurve,
|
|
4902
4879
|
pump_default as pumpIdl,
|
|
4903
|
-
pumpPoolAuthorityPda,
|
|
4880
|
+
pumpPoolAuthorityPda2 as pumpPoolAuthorityPda,
|
|
4904
4881
|
totalUnclaimedTokens,
|
|
4905
4882
|
userVolumeAccumulatorPda
|
|
4906
4883
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -8440,16 +8440,16 @@ declare function getBuyTokenAmountFromSolAmount(global: Global, bondingCurve: Bo
|
|
|
8440
8440
|
declare function getBuySolAmountFromTokenAmount(global: Global, bondingCurve: BondingCurve | null, amount: BN): BN;
|
|
8441
8441
|
declare function getSellSolAmountFromTokenAmount(global: Global, bondingCurve: BondingCurve, amount: BN): BN;
|
|
8442
8442
|
|
|
8443
|
-
declare function globalPda(
|
|
8444
|
-
declare function bondingCurvePda(
|
|
8445
|
-
declare function creatorVaultPda(
|
|
8446
|
-
declare function pumpPoolAuthorityPda(mint: PublicKey
|
|
8443
|
+
declare function globalPda(): PublicKey;
|
|
8444
|
+
declare function bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
8445
|
+
declare function creatorVaultPda(creator: PublicKey): PublicKey;
|
|
8446
|
+
declare function pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number];
|
|
8447
8447
|
declare const CANONICAL_POOL_INDEX = 0;
|
|
8448
|
-
declare function canonicalPumpPoolPda(
|
|
8449
|
-
declare function globalVolumeAccumulatorPda(
|
|
8450
|
-
declare function userVolumeAccumulatorPda(user: PublicKey
|
|
8448
|
+
declare function canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number];
|
|
8449
|
+
declare function globalVolumeAccumulatorPda(): [PublicKey, number];
|
|
8450
|
+
declare function userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number];
|
|
8451
8451
|
|
|
8452
|
-
declare function getPumpProgram(connection: Connection
|
|
8452
|
+
declare function getPumpProgram(connection: Connection): Program<Pump>;
|
|
8453
8453
|
declare const PUMP_PROGRAM_ID: PublicKey;
|
|
8454
8454
|
declare const PUMP_AMM_PROGRAM_ID: PublicKey;
|
|
8455
8455
|
declare const BONDING_CURVE_NEW_SIZE = 150;
|
|
@@ -8459,15 +8459,8 @@ declare class PumpSdk {
|
|
|
8459
8459
|
private readonly offlinePumpProgram;
|
|
8460
8460
|
private readonly pumpAmmSdk;
|
|
8461
8461
|
private readonly pumpAmmAdminSdk;
|
|
8462
|
-
constructor(connection: Connection
|
|
8462
|
+
constructor(connection: Connection);
|
|
8463
8463
|
programId(): PublicKey;
|
|
8464
|
-
globalPda(): PublicKey;
|
|
8465
|
-
bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
8466
|
-
creatorVaultPda(creator: PublicKey): PublicKey;
|
|
8467
|
-
pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number];
|
|
8468
|
-
canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number];
|
|
8469
|
-
globalVolumeAccumulatorPda(): [PublicKey, number];
|
|
8470
|
-
userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number];
|
|
8471
8464
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global;
|
|
8472
8465
|
decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve;
|
|
8473
8466
|
decodeGlobalVolumeAccumulator(accountInfo: AccountInfo<Buffer>): GlobalVolumeAccumulator;
|
|
@@ -8548,6 +8541,11 @@ declare class PumpSdk {
|
|
|
8548
8541
|
getCurrentDayTokensBothPrograms(user: PublicKey): Promise<BN>;
|
|
8549
8542
|
syncUserVolumeAccumulator(user: PublicKey): Promise<TransactionInstruction>;
|
|
8550
8543
|
syncUserVolumeAccumulatorBothPrograms(user: PublicKey): Promise<TransactionInstruction[]>;
|
|
8544
|
+
setCreator({ mint, setCreatorAuthority, creator, }: {
|
|
8545
|
+
mint: PublicKey;
|
|
8546
|
+
setCreatorAuthority: PublicKey;
|
|
8547
|
+
creator: PublicKey;
|
|
8548
|
+
}): Promise<TransactionInstruction>;
|
|
8551
8549
|
}
|
|
8552
8550
|
|
|
8553
8551
|
declare function totalUnclaimedTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
|
package/dist/index.d.ts
CHANGED
|
@@ -8440,16 +8440,16 @@ declare function getBuyTokenAmountFromSolAmount(global: Global, bondingCurve: Bo
|
|
|
8440
8440
|
declare function getBuySolAmountFromTokenAmount(global: Global, bondingCurve: BondingCurve | null, amount: BN): BN;
|
|
8441
8441
|
declare function getSellSolAmountFromTokenAmount(global: Global, bondingCurve: BondingCurve, amount: BN): BN;
|
|
8442
8442
|
|
|
8443
|
-
declare function globalPda(
|
|
8444
|
-
declare function bondingCurvePda(
|
|
8445
|
-
declare function creatorVaultPda(
|
|
8446
|
-
declare function pumpPoolAuthorityPda(mint: PublicKey
|
|
8443
|
+
declare function globalPda(): PublicKey;
|
|
8444
|
+
declare function bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
8445
|
+
declare function creatorVaultPda(creator: PublicKey): PublicKey;
|
|
8446
|
+
declare function pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number];
|
|
8447
8447
|
declare const CANONICAL_POOL_INDEX = 0;
|
|
8448
|
-
declare function canonicalPumpPoolPda(
|
|
8449
|
-
declare function globalVolumeAccumulatorPda(
|
|
8450
|
-
declare function userVolumeAccumulatorPda(user: PublicKey
|
|
8448
|
+
declare function canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number];
|
|
8449
|
+
declare function globalVolumeAccumulatorPda(): [PublicKey, number];
|
|
8450
|
+
declare function userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number];
|
|
8451
8451
|
|
|
8452
|
-
declare function getPumpProgram(connection: Connection
|
|
8452
|
+
declare function getPumpProgram(connection: Connection): Program<Pump>;
|
|
8453
8453
|
declare const PUMP_PROGRAM_ID: PublicKey;
|
|
8454
8454
|
declare const PUMP_AMM_PROGRAM_ID: PublicKey;
|
|
8455
8455
|
declare const BONDING_CURVE_NEW_SIZE = 150;
|
|
@@ -8459,15 +8459,8 @@ declare class PumpSdk {
|
|
|
8459
8459
|
private readonly offlinePumpProgram;
|
|
8460
8460
|
private readonly pumpAmmSdk;
|
|
8461
8461
|
private readonly pumpAmmAdminSdk;
|
|
8462
|
-
constructor(connection: Connection
|
|
8462
|
+
constructor(connection: Connection);
|
|
8463
8463
|
programId(): PublicKey;
|
|
8464
|
-
globalPda(): PublicKey;
|
|
8465
|
-
bondingCurvePda(mint: PublicKeyInitData): PublicKey;
|
|
8466
|
-
creatorVaultPda(creator: PublicKey): PublicKey;
|
|
8467
|
-
pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number];
|
|
8468
|
-
canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number];
|
|
8469
|
-
globalVolumeAccumulatorPda(): [PublicKey, number];
|
|
8470
|
-
userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number];
|
|
8471
8464
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global;
|
|
8472
8465
|
decodeBondingCurve(accountInfo: AccountInfo<Buffer>): BondingCurve;
|
|
8473
8466
|
decodeGlobalVolumeAccumulator(accountInfo: AccountInfo<Buffer>): GlobalVolumeAccumulator;
|
|
@@ -8548,6 +8541,11 @@ declare class PumpSdk {
|
|
|
8548
8541
|
getCurrentDayTokensBothPrograms(user: PublicKey): Promise<BN>;
|
|
8549
8542
|
syncUserVolumeAccumulator(user: PublicKey): Promise<TransactionInstruction>;
|
|
8550
8543
|
syncUserVolumeAccumulatorBothPrograms(user: PublicKey): Promise<TransactionInstruction[]>;
|
|
8544
|
+
setCreator({ mint, setCreatorAuthority, creator, }: {
|
|
8545
|
+
mint: PublicKey;
|
|
8546
|
+
setCreatorAuthority: PublicKey;
|
|
8547
|
+
creator: PublicKey;
|
|
8548
|
+
}): Promise<TransactionInstruction>;
|
|
8551
8549
|
}
|
|
8552
8550
|
|
|
8553
8551
|
declare function totalUnclaimedTokens(globalVolumeAccumulator: GlobalVolumeAccumulator, userVolumeAccumulator: UserVolumeAccumulator, currentTimestamp?: number): BN;
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ __export(index_exports, {
|
|
|
36
36
|
PUMP_PROGRAM_ID: () => PUMP_PROGRAM_ID,
|
|
37
37
|
PumpSdk: () => PumpSdk,
|
|
38
38
|
bondingCurvePda: () => bondingCurvePda,
|
|
39
|
-
canonicalPumpPoolPda: () =>
|
|
39
|
+
canonicalPumpPoolPda: () => canonicalPumpPoolPda2,
|
|
40
40
|
creatorVaultPda: () => creatorVaultPda,
|
|
41
41
|
currentDayTokens: () => currentDayTokens,
|
|
42
42
|
getBuySolAmountFromTokenAmount: () => getBuySolAmountFromTokenAmount,
|
|
@@ -47,7 +47,7 @@ __export(index_exports, {
|
|
|
47
47
|
globalVolumeAccumulatorPda: () => globalVolumeAccumulatorPda,
|
|
48
48
|
newBondingCurve: () => newBondingCurve,
|
|
49
49
|
pumpIdl: () => pump_default,
|
|
50
|
-
pumpPoolAuthorityPda: () =>
|
|
50
|
+
pumpPoolAuthorityPda: () => pumpPoolAuthorityPda2,
|
|
51
51
|
totalUnclaimedTokens: () => totalUnclaimedTokens,
|
|
52
52
|
userVolumeAccumulatorPda: () => userVolumeAccumulatorPda
|
|
53
53
|
});
|
|
@@ -4385,11 +4385,9 @@ function currentDayTokens(globalVolumeAccumulator, userVolumeAccumulator, curren
|
|
|
4385
4385
|
}
|
|
4386
4386
|
|
|
4387
4387
|
// src/sdk.ts
|
|
4388
|
-
function getPumpProgram(connection
|
|
4389
|
-
const pumpIdlAddressOverride = { ...pump_default };
|
|
4390
|
-
pumpIdlAddressOverride.address = programId.toString();
|
|
4388
|
+
function getPumpProgram(connection) {
|
|
4391
4389
|
return new import_anchor.Program(
|
|
4392
|
-
|
|
4390
|
+
pump_default,
|
|
4393
4391
|
new import_anchor.AnchorProvider(connection, null, {})
|
|
4394
4392
|
);
|
|
4395
4393
|
}
|
|
@@ -4404,47 +4402,16 @@ var PUMP_TOKEN_MINT = new import_web32.PublicKey(
|
|
|
4404
4402
|
"pumpCmXqMfrsAkQ5r49WcJnRayYRqmXz6ae8H7H9Dfn"
|
|
4405
4403
|
);
|
|
4406
4404
|
var PumpSdk = class {
|
|
4407
|
-
constructor(connection
|
|
4405
|
+
constructor(connection) {
|
|
4408
4406
|
this.connection = connection;
|
|
4409
|
-
this.pumpProgram = getPumpProgram(connection
|
|
4410
|
-
this.offlinePumpProgram = getPumpProgram(
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
);
|
|
4414
|
-
this.pumpAmmSdk = new import_pump_swap_sdk.PumpAmmSdk(connection, pumpAmmProgramId.toBase58());
|
|
4415
|
-
this.pumpAmmAdminSdk = new import_pump_swap_sdk.PumpAmmAdminSdk(
|
|
4416
|
-
connection,
|
|
4417
|
-
pumpAmmProgramId.toBase58()
|
|
4418
|
-
);
|
|
4407
|
+
this.pumpProgram = getPumpProgram(connection);
|
|
4408
|
+
this.offlinePumpProgram = getPumpProgram(null);
|
|
4409
|
+
this.pumpAmmSdk = new import_pump_swap_sdk.PumpAmmSdk(connection);
|
|
4410
|
+
this.pumpAmmAdminSdk = new import_pump_swap_sdk.PumpAmmAdminSdk(connection);
|
|
4419
4411
|
}
|
|
4420
4412
|
programId() {
|
|
4421
4413
|
return this.offlinePumpProgram.programId;
|
|
4422
4414
|
}
|
|
4423
|
-
globalPda() {
|
|
4424
|
-
return globalPda(this.offlinePumpProgram.programId);
|
|
4425
|
-
}
|
|
4426
|
-
bondingCurvePda(mint) {
|
|
4427
|
-
return bondingCurvePda(this.offlinePumpProgram.programId, mint);
|
|
4428
|
-
}
|
|
4429
|
-
creatorVaultPda(creator) {
|
|
4430
|
-
return creatorVaultPda(this.offlinePumpProgram.programId, creator);
|
|
4431
|
-
}
|
|
4432
|
-
pumpPoolAuthorityPda(mint) {
|
|
4433
|
-
return pumpPoolAuthorityPda(mint, this.offlinePumpProgram.programId);
|
|
4434
|
-
}
|
|
4435
|
-
canonicalPumpPoolPda(mint) {
|
|
4436
|
-
return canonicalPumpPoolPda(
|
|
4437
|
-
this.offlinePumpProgram.programId,
|
|
4438
|
-
this.pumpAmmSdk.programId(),
|
|
4439
|
-
mint
|
|
4440
|
-
);
|
|
4441
|
-
}
|
|
4442
|
-
globalVolumeAccumulatorPda() {
|
|
4443
|
-
return globalVolumeAccumulatorPda(this.offlinePumpProgram.programId);
|
|
4444
|
-
}
|
|
4445
|
-
userVolumeAccumulatorPda(user) {
|
|
4446
|
-
return userVolumeAccumulatorPda(user, this.offlinePumpProgram.programId);
|
|
4447
|
-
}
|
|
4448
4415
|
decodeGlobal(accountInfo) {
|
|
4449
4416
|
return this.offlinePumpProgram.coder.accounts.decode(
|
|
4450
4417
|
"global",
|
|
@@ -4470,16 +4437,16 @@ var PumpSdk = class {
|
|
|
4470
4437
|
);
|
|
4471
4438
|
}
|
|
4472
4439
|
async fetchGlobal() {
|
|
4473
|
-
return await this.pumpProgram.account.global.fetch(
|
|
4440
|
+
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
4474
4441
|
}
|
|
4475
4442
|
async fetchBondingCurve(mint) {
|
|
4476
4443
|
return await this.pumpProgram.account.bondingCurve.fetch(
|
|
4477
|
-
|
|
4444
|
+
bondingCurvePda(mint)
|
|
4478
4445
|
);
|
|
4479
4446
|
}
|
|
4480
4447
|
async fetchBuyState(mint, user) {
|
|
4481
4448
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
|
|
4482
|
-
|
|
4449
|
+
bondingCurvePda(mint),
|
|
4483
4450
|
(0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
|
|
4484
4451
|
]);
|
|
4485
4452
|
if (!bondingCurveAccountInfo) {
|
|
@@ -4492,7 +4459,7 @@ var PumpSdk = class {
|
|
|
4492
4459
|
}
|
|
4493
4460
|
async fetchSellState(mint, user) {
|
|
4494
4461
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] = await this.connection.getMultipleAccountsInfo([
|
|
4495
|
-
|
|
4462
|
+
bondingCurvePda(mint),
|
|
4496
4463
|
(0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true)
|
|
4497
4464
|
]);
|
|
4498
4465
|
if (!bondingCurveAccountInfo) {
|
|
@@ -4510,12 +4477,12 @@ var PumpSdk = class {
|
|
|
4510
4477
|
}
|
|
4511
4478
|
async fetchGlobalVolumeAccumulator() {
|
|
4512
4479
|
return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
|
|
4513
|
-
|
|
4480
|
+
globalVolumeAccumulatorPda()[0]
|
|
4514
4481
|
);
|
|
4515
4482
|
}
|
|
4516
4483
|
async fetchUserVolumeAccumulator(user) {
|
|
4517
4484
|
return await this.pumpProgram.account.userVolumeAccumulator.fetch(
|
|
4518
|
-
|
|
4485
|
+
userVolumeAccumulatorPda(user)[0]
|
|
4519
4486
|
);
|
|
4520
4487
|
}
|
|
4521
4488
|
async createInstruction({
|
|
@@ -4546,7 +4513,7 @@ var PumpSdk = class {
|
|
|
4546
4513
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
4547
4514
|
instructions.push(
|
|
4548
4515
|
await this.extendAccountInstruction({
|
|
4549
|
-
account:
|
|
4516
|
+
account: bondingCurvePda(mint),
|
|
4550
4517
|
user
|
|
4551
4518
|
})
|
|
4552
4519
|
);
|
|
@@ -4591,7 +4558,7 @@ var PumpSdk = class {
|
|
|
4591
4558
|
return [
|
|
4592
4559
|
await this.createInstruction({ mint, name, symbol, uri, creator, user }),
|
|
4593
4560
|
await this.extendAccountInstruction({
|
|
4594
|
-
account:
|
|
4561
|
+
account: bondingCurvePda(mint),
|
|
4595
4562
|
user
|
|
4596
4563
|
}),
|
|
4597
4564
|
(0, import_spl_token.createAssociatedTokenAccountIdempotentInstruction)(
|
|
@@ -4632,7 +4599,7 @@ var PumpSdk = class {
|
|
|
4632
4599
|
mint,
|
|
4633
4600
|
associatedUser,
|
|
4634
4601
|
user,
|
|
4635
|
-
creatorVault:
|
|
4602
|
+
creatorVault: creatorVaultPda(creator)
|
|
4636
4603
|
}).instruction();
|
|
4637
4604
|
}
|
|
4638
4605
|
async sellInstructions({
|
|
@@ -4649,7 +4616,7 @@ var PumpSdk = class {
|
|
|
4649
4616
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
4650
4617
|
instructions.push(
|
|
4651
4618
|
await this.extendAccountInstruction({
|
|
4652
|
-
account:
|
|
4619
|
+
account: bondingCurvePda(mint),
|
|
4653
4620
|
user
|
|
4654
4621
|
})
|
|
4655
4622
|
);
|
|
@@ -4665,7 +4632,7 @@ var PumpSdk = class {
|
|
|
4665
4632
|
mint,
|
|
4666
4633
|
associatedUser: (0, import_spl_token.getAssociatedTokenAddressSync)(mint, user, true),
|
|
4667
4634
|
user,
|
|
4668
|
-
creatorVault:
|
|
4635
|
+
creatorVault: creatorVaultPda(bondingCurve.creator)
|
|
4669
4636
|
}).instruction()
|
|
4670
4637
|
);
|
|
4671
4638
|
return instructions;
|
|
@@ -4736,7 +4703,7 @@ var PumpSdk = class {
|
|
|
4736
4703
|
];
|
|
4737
4704
|
}
|
|
4738
4705
|
async getCreatorVaultBalance(creator) {
|
|
4739
|
-
const creatorVault =
|
|
4706
|
+
const creatorVault = creatorVaultPda(creator);
|
|
4740
4707
|
const accountInfo = await this.connection.getAccountInfo(creatorVault);
|
|
4741
4708
|
if (accountInfo === null) {
|
|
4742
4709
|
return new import_bn3.default(0);
|
|
@@ -4872,6 +4839,16 @@ var PumpSdk = class {
|
|
|
4872
4839
|
await this.pumpAmmSdk.syncUserVolumeAccumulator(user)
|
|
4873
4840
|
];
|
|
4874
4841
|
}
|
|
4842
|
+
async setCreator({
|
|
4843
|
+
mint,
|
|
4844
|
+
setCreatorAuthority,
|
|
4845
|
+
creator
|
|
4846
|
+
}) {
|
|
4847
|
+
return await this.offlinePumpProgram.methods.setCreator(creator).accountsPartial({
|
|
4848
|
+
mint,
|
|
4849
|
+
setCreatorAuthority
|
|
4850
|
+
}).instruction();
|
|
4851
|
+
}
|
|
4875
4852
|
};
|
|
4876
4853
|
function getFeeRecipient(global) {
|
|
4877
4854
|
const feeRecipients = [global.feeRecipient, ...global.feeRecipients];
|
|
@@ -4879,53 +4856,53 @@ function getFeeRecipient(global) {
|
|
|
4879
4856
|
}
|
|
4880
4857
|
|
|
4881
4858
|
// src/pda.ts
|
|
4882
|
-
function globalPda(
|
|
4859
|
+
function globalPda() {
|
|
4883
4860
|
const [globalPda2] = import_web33.PublicKey.findProgramAddressSync(
|
|
4884
4861
|
[Buffer.from("global")],
|
|
4885
|
-
|
|
4862
|
+
PUMP_PROGRAM_ID
|
|
4886
4863
|
);
|
|
4887
4864
|
return globalPda2;
|
|
4888
4865
|
}
|
|
4889
|
-
function bondingCurvePda(
|
|
4866
|
+
function bondingCurvePda(mint) {
|
|
4890
4867
|
const [bondingCurvePda2] = import_web33.PublicKey.findProgramAddressSync(
|
|
4891
4868
|
[Buffer.from("bonding-curve"), new import_web33.PublicKey(mint).toBuffer()],
|
|
4892
|
-
|
|
4869
|
+
PUMP_PROGRAM_ID
|
|
4893
4870
|
);
|
|
4894
4871
|
return bondingCurvePda2;
|
|
4895
4872
|
}
|
|
4896
|
-
function creatorVaultPda(
|
|
4873
|
+
function creatorVaultPda(creator) {
|
|
4897
4874
|
const [creatorVault] = import_web33.PublicKey.findProgramAddressSync(
|
|
4898
4875
|
[Buffer.from("creator-vault"), creator.toBuffer()],
|
|
4899
|
-
|
|
4876
|
+
PUMP_PROGRAM_ID
|
|
4900
4877
|
);
|
|
4901
4878
|
return creatorVault;
|
|
4902
4879
|
}
|
|
4903
|
-
function
|
|
4880
|
+
function pumpPoolAuthorityPda2(mint) {
|
|
4904
4881
|
return import_web33.PublicKey.findProgramAddressSync(
|
|
4905
4882
|
[Buffer.from("pool-authority"), mint.toBuffer()],
|
|
4906
|
-
|
|
4883
|
+
PUMP_PROGRAM_ID
|
|
4907
4884
|
);
|
|
4908
4885
|
}
|
|
4909
4886
|
var CANONICAL_POOL_INDEX = 0;
|
|
4910
|
-
function
|
|
4911
|
-
const [pumpPoolAuthority] =
|
|
4887
|
+
function canonicalPumpPoolPda2(mint) {
|
|
4888
|
+
const [pumpPoolAuthority] = pumpPoolAuthorityPda2(mint);
|
|
4912
4889
|
return (0, import_pump_swap_sdk2.poolPda)(
|
|
4913
4890
|
CANONICAL_POOL_INDEX,
|
|
4914
4891
|
pumpPoolAuthority,
|
|
4915
4892
|
mint,
|
|
4916
4893
|
import_spl_token2.NATIVE_MINT,
|
|
4917
|
-
|
|
4894
|
+
PUMP_AMM_PROGRAM_ID
|
|
4918
4895
|
);
|
|
4919
4896
|
}
|
|
4920
|
-
function globalVolumeAccumulatorPda(
|
|
4897
|
+
function globalVolumeAccumulatorPda() {
|
|
4921
4898
|
return import_web33.PublicKey.findProgramAddressSync(
|
|
4922
4899
|
[Buffer.from("global_volume_accumulator")],
|
|
4923
|
-
|
|
4900
|
+
PUMP_PROGRAM_ID
|
|
4924
4901
|
);
|
|
4925
4902
|
}
|
|
4926
|
-
function userVolumeAccumulatorPda(user
|
|
4903
|
+
function userVolumeAccumulatorPda(user) {
|
|
4927
4904
|
return import_web33.PublicKey.findProgramAddressSync(
|
|
4928
4905
|
[Buffer.from("user_volume_accumulator"), user.toBuffer()],
|
|
4929
|
-
|
|
4906
|
+
PUMP_PROGRAM_ID
|
|
4930
4907
|
);
|
|
4931
4908
|
}
|
package/package.json
CHANGED
package/src/pda.ts
CHANGED
|
@@ -1,78 +1,63 @@
|
|
|
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 { PUMP_PROGRAM_ID } from "./sdk";
|
|
4
|
+
import { PUMP_AMM_PROGRAM_ID, PUMP_PROGRAM_ID } from "./sdk";
|
|
5
5
|
|
|
6
|
-
export function globalPda(
|
|
6
|
+
export function globalPda(): PublicKey {
|
|
7
7
|
const [globalPda] = PublicKey.findProgramAddressSync(
|
|
8
8
|
[Buffer.from("global")],
|
|
9
|
-
|
|
9
|
+
PUMP_PROGRAM_ID,
|
|
10
10
|
);
|
|
11
11
|
return globalPda;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export function bondingCurvePda(
|
|
15
|
-
programId: PublicKey,
|
|
16
|
-
mint: PublicKeyInitData,
|
|
17
|
-
): PublicKey {
|
|
14
|
+
export function bondingCurvePda(mint: PublicKeyInitData): PublicKey {
|
|
18
15
|
const [bondingCurvePda] = PublicKey.findProgramAddressSync(
|
|
19
16
|
[Buffer.from("bonding-curve"), new PublicKey(mint).toBuffer()],
|
|
20
|
-
|
|
17
|
+
PUMP_PROGRAM_ID,
|
|
21
18
|
);
|
|
22
19
|
return bondingCurvePda;
|
|
23
20
|
}
|
|
24
21
|
|
|
25
|
-
export function creatorVaultPda(
|
|
22
|
+
export function creatorVaultPda(creator: PublicKey) {
|
|
26
23
|
const [creatorVault] = PublicKey.findProgramAddressSync(
|
|
27
24
|
[Buffer.from("creator-vault"), creator.toBuffer()],
|
|
28
|
-
|
|
25
|
+
PUMP_PROGRAM_ID,
|
|
29
26
|
);
|
|
30
27
|
return creatorVault;
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
export function pumpPoolAuthorityPda(
|
|
34
|
-
mint: PublicKey,
|
|
35
|
-
pumpProgramId: PublicKey,
|
|
36
|
-
): [PublicKey, number] {
|
|
30
|
+
export function pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number] {
|
|
37
31
|
return PublicKey.findProgramAddressSync(
|
|
38
32
|
[Buffer.from("pool-authority"), mint.toBuffer()],
|
|
39
|
-
|
|
33
|
+
PUMP_PROGRAM_ID,
|
|
40
34
|
);
|
|
41
35
|
}
|
|
42
36
|
|
|
43
37
|
export const CANONICAL_POOL_INDEX = 0;
|
|
44
38
|
|
|
45
|
-
export function canonicalPumpPoolPda(
|
|
46
|
-
|
|
47
|
-
pumpAmmProgramId: PublicKey,
|
|
48
|
-
mint: PublicKey,
|
|
49
|
-
): [PublicKey, number] {
|
|
50
|
-
const [pumpPoolAuthority] = pumpPoolAuthorityPda(mint, pumpProgramId);
|
|
39
|
+
export function canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number] {
|
|
40
|
+
const [pumpPoolAuthority] = pumpPoolAuthorityPda(mint);
|
|
51
41
|
|
|
52
42
|
return poolPda(
|
|
53
43
|
CANONICAL_POOL_INDEX,
|
|
54
44
|
pumpPoolAuthority,
|
|
55
45
|
mint,
|
|
56
46
|
NATIVE_MINT,
|
|
57
|
-
|
|
47
|
+
PUMP_AMM_PROGRAM_ID,
|
|
58
48
|
);
|
|
59
49
|
}
|
|
60
50
|
|
|
61
|
-
export function globalVolumeAccumulatorPda(
|
|
62
|
-
programId: PublicKey = PUMP_PROGRAM_ID,
|
|
63
|
-
): [PublicKey, number] {
|
|
51
|
+
export function globalVolumeAccumulatorPda(): [PublicKey, number] {
|
|
64
52
|
return PublicKey.findProgramAddressSync(
|
|
65
53
|
[Buffer.from("global_volume_accumulator")],
|
|
66
|
-
|
|
54
|
+
PUMP_PROGRAM_ID,
|
|
67
55
|
);
|
|
68
56
|
}
|
|
69
57
|
|
|
70
|
-
export function userVolumeAccumulatorPda(
|
|
71
|
-
user: PublicKey,
|
|
72
|
-
programId: PublicKey = PUMP_PROGRAM_ID,
|
|
73
|
-
): [PublicKey, number] {
|
|
58
|
+
export function userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number] {
|
|
74
59
|
return PublicKey.findProgramAddressSync(
|
|
75
60
|
[Buffer.from("user_volume_accumulator"), user.toBuffer()],
|
|
76
|
-
|
|
61
|
+
PUMP_PROGRAM_ID,
|
|
77
62
|
);
|
|
78
63
|
}
|
package/src/sdk.ts
CHANGED
|
@@ -35,16 +35,9 @@ import {
|
|
|
35
35
|
} from "./state";
|
|
36
36
|
import { currentDayTokens, totalUnclaimedTokens } from "./tokenIncentives";
|
|
37
37
|
|
|
38
|
-
export function getPumpProgram(
|
|
39
|
-
connection: Connection,
|
|
40
|
-
programId: PublicKey,
|
|
41
|
-
): Program<Pump> {
|
|
42
|
-
const pumpIdlAddressOverride = { ...pumpIdl };
|
|
43
|
-
|
|
44
|
-
pumpIdlAddressOverride.address = programId.toString();
|
|
45
|
-
|
|
38
|
+
export function getPumpProgram(connection: Connection): Program<Pump> {
|
|
46
39
|
return new Program(
|
|
47
|
-
|
|
40
|
+
pumpIdl as Pump,
|
|
48
41
|
new AnchorProvider(connection, null as any, {}),
|
|
49
42
|
);
|
|
50
43
|
}
|
|
@@ -70,62 +63,20 @@ export class PumpSdk {
|
|
|
70
63
|
private readonly pumpAmmSdk: PumpAmmSdk;
|
|
71
64
|
private readonly pumpAmmAdminSdk: PumpAmmAdminSdk;
|
|
72
65
|
|
|
73
|
-
constructor(
|
|
74
|
-
connection: Connection,
|
|
75
|
-
pumpProgramId: PublicKey = PUMP_PROGRAM_ID,
|
|
76
|
-
pumpAmmProgramId: PublicKey = PUMP_AMM_PROGRAM_ID,
|
|
77
|
-
) {
|
|
66
|
+
constructor(connection: Connection) {
|
|
78
67
|
this.connection = connection;
|
|
79
68
|
|
|
80
|
-
this.pumpProgram = getPumpProgram(connection
|
|
81
|
-
this.offlinePumpProgram = getPumpProgram(
|
|
82
|
-
null as any as Connection,
|
|
83
|
-
pumpProgramId,
|
|
84
|
-
);
|
|
69
|
+
this.pumpProgram = getPumpProgram(connection);
|
|
70
|
+
this.offlinePumpProgram = getPumpProgram(null as any as Connection);
|
|
85
71
|
|
|
86
|
-
this.pumpAmmSdk = new PumpAmmSdk(connection
|
|
87
|
-
this.pumpAmmAdminSdk = new PumpAmmAdminSdk(
|
|
88
|
-
connection,
|
|
89
|
-
pumpAmmProgramId.toBase58(),
|
|
90
|
-
);
|
|
72
|
+
this.pumpAmmSdk = new PumpAmmSdk(connection);
|
|
73
|
+
this.pumpAmmAdminSdk = new PumpAmmAdminSdk(connection);
|
|
91
74
|
}
|
|
92
75
|
|
|
93
76
|
programId(): PublicKey {
|
|
94
77
|
return this.offlinePumpProgram.programId;
|
|
95
78
|
}
|
|
96
79
|
|
|
97
|
-
globalPda() {
|
|
98
|
-
return globalPda(this.offlinePumpProgram.programId);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
bondingCurvePda(mint: PublicKeyInitData): PublicKey {
|
|
102
|
-
return bondingCurvePda(this.offlinePumpProgram.programId, mint);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
creatorVaultPda(creator: PublicKey) {
|
|
106
|
-
return creatorVaultPda(this.offlinePumpProgram.programId, creator);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
pumpPoolAuthorityPda(mint: PublicKey): [PublicKey, number] {
|
|
110
|
-
return pumpPoolAuthorityPda(mint, this.offlinePumpProgram.programId);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
canonicalPumpPoolPda(mint: PublicKey): [PublicKey, number] {
|
|
114
|
-
return canonicalPumpPoolPda(
|
|
115
|
-
this.offlinePumpProgram.programId,
|
|
116
|
-
this.pumpAmmSdk.programId(),
|
|
117
|
-
mint,
|
|
118
|
-
);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
globalVolumeAccumulatorPda(): [PublicKey, number] {
|
|
122
|
-
return globalVolumeAccumulatorPda(this.offlinePumpProgram.programId);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
userVolumeAccumulatorPda(user: PublicKey): [PublicKey, number] {
|
|
126
|
-
return userVolumeAccumulatorPda(user, this.offlinePumpProgram.programId);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
80
|
decodeGlobal(accountInfo: AccountInfo<Buffer>): Global {
|
|
130
81
|
return this.offlinePumpProgram.coder.accounts.decode<Global>(
|
|
131
82
|
"global",
|
|
@@ -158,19 +109,19 @@ export class PumpSdk {
|
|
|
158
109
|
);
|
|
159
110
|
}
|
|
160
111
|
async fetchGlobal(): Promise<Global> {
|
|
161
|
-
return await this.pumpProgram.account.global.fetch(
|
|
112
|
+
return await this.pumpProgram.account.global.fetch(globalPda());
|
|
162
113
|
}
|
|
163
114
|
|
|
164
115
|
async fetchBondingCurve(mint: PublicKeyInitData): Promise<BondingCurve> {
|
|
165
116
|
return await this.pumpProgram.account.bondingCurve.fetch(
|
|
166
|
-
|
|
117
|
+
bondingCurvePda(mint),
|
|
167
118
|
);
|
|
168
119
|
}
|
|
169
120
|
|
|
170
121
|
async fetchBuyState(mint: PublicKey, user: PublicKey) {
|
|
171
122
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] =
|
|
172
123
|
await this.connection.getMultipleAccountsInfo([
|
|
173
|
-
|
|
124
|
+
bondingCurvePda(mint),
|
|
174
125
|
getAssociatedTokenAddressSync(mint, user, true),
|
|
175
126
|
]);
|
|
176
127
|
|
|
@@ -187,7 +138,7 @@ export class PumpSdk {
|
|
|
187
138
|
async fetchSellState(mint: PublicKey, user: PublicKey) {
|
|
188
139
|
const [bondingCurveAccountInfo, associatedUserAccountInfo] =
|
|
189
140
|
await this.connection.getMultipleAccountsInfo([
|
|
190
|
-
|
|
141
|
+
bondingCurvePda(mint),
|
|
191
142
|
getAssociatedTokenAddressSync(mint, user, true),
|
|
192
143
|
]);
|
|
193
144
|
|
|
@@ -209,7 +160,7 @@ export class PumpSdk {
|
|
|
209
160
|
|
|
210
161
|
async fetchGlobalVolumeAccumulator(): Promise<GlobalVolumeAccumulator> {
|
|
211
162
|
return await this.pumpProgram.account.globalVolumeAccumulator.fetch(
|
|
212
|
-
|
|
163
|
+
globalVolumeAccumulatorPda()[0],
|
|
213
164
|
);
|
|
214
165
|
}
|
|
215
166
|
|
|
@@ -217,7 +168,7 @@ export class PumpSdk {
|
|
|
217
168
|
user: PublicKey,
|
|
218
169
|
): Promise<UserVolumeAccumulator> {
|
|
219
170
|
return await this.pumpProgram.account.userVolumeAccumulator.fetch(
|
|
220
|
-
|
|
171
|
+
userVolumeAccumulatorPda(user)[0],
|
|
221
172
|
);
|
|
222
173
|
}
|
|
223
174
|
|
|
@@ -271,7 +222,7 @@ export class PumpSdk {
|
|
|
271
222
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
272
223
|
instructions.push(
|
|
273
224
|
await this.extendAccountInstruction({
|
|
274
|
-
account:
|
|
225
|
+
account: bondingCurvePda(mint),
|
|
275
226
|
user,
|
|
276
227
|
}),
|
|
277
228
|
);
|
|
@@ -331,7 +282,7 @@ export class PumpSdk {
|
|
|
331
282
|
return [
|
|
332
283
|
await this.createInstruction({ mint, name, symbol, uri, creator, user }),
|
|
333
284
|
await this.extendAccountInstruction({
|
|
334
|
-
account:
|
|
285
|
+
account: bondingCurvePda(mint),
|
|
335
286
|
user,
|
|
336
287
|
}),
|
|
337
288
|
createAssociatedTokenAccountIdempotentInstruction(
|
|
@@ -384,7 +335,7 @@ export class PumpSdk {
|
|
|
384
335
|
mint,
|
|
385
336
|
associatedUser,
|
|
386
337
|
user,
|
|
387
|
-
creatorVault:
|
|
338
|
+
creatorVault: creatorVaultPda(creator),
|
|
388
339
|
})
|
|
389
340
|
.instruction();
|
|
390
341
|
}
|
|
@@ -413,7 +364,7 @@ export class PumpSdk {
|
|
|
413
364
|
if (bondingCurveAccountInfo.data.length < BONDING_CURVE_NEW_SIZE) {
|
|
414
365
|
instructions.push(
|
|
415
366
|
await this.extendAccountInstruction({
|
|
416
|
-
account:
|
|
367
|
+
account: bondingCurvePda(mint),
|
|
417
368
|
user,
|
|
418
369
|
}),
|
|
419
370
|
);
|
|
@@ -432,7 +383,7 @@ export class PumpSdk {
|
|
|
432
383
|
mint,
|
|
433
384
|
associatedUser: getAssociatedTokenAddressSync(mint, user, true),
|
|
434
385
|
user,
|
|
435
|
-
creatorVault:
|
|
386
|
+
creatorVault: creatorVaultPda(bondingCurve.creator),
|
|
436
387
|
})
|
|
437
388
|
.instruction(),
|
|
438
389
|
);
|
|
@@ -540,7 +491,7 @@ export class PumpSdk {
|
|
|
540
491
|
}
|
|
541
492
|
|
|
542
493
|
async getCreatorVaultBalance(creator: PublicKey): Promise<BN> {
|
|
543
|
-
const creatorVault =
|
|
494
|
+
const creatorVault = creatorVaultPda(creator);
|
|
544
495
|
const accountInfo = await this.connection.getAccountInfo(creatorVault);
|
|
545
496
|
|
|
546
497
|
if (accountInfo === null) {
|
|
@@ -745,6 +696,24 @@ export class PumpSdk {
|
|
|
745
696
|
await this.pumpAmmSdk.syncUserVolumeAccumulator(user),
|
|
746
697
|
];
|
|
747
698
|
}
|
|
699
|
+
|
|
700
|
+
async setCreator({
|
|
701
|
+
mint,
|
|
702
|
+
setCreatorAuthority,
|
|
703
|
+
creator,
|
|
704
|
+
}: {
|
|
705
|
+
mint: PublicKey;
|
|
706
|
+
setCreatorAuthority: PublicKey;
|
|
707
|
+
creator: PublicKey;
|
|
708
|
+
}): Promise<TransactionInstruction> {
|
|
709
|
+
return await this.offlinePumpProgram.methods
|
|
710
|
+
.setCreator(creator)
|
|
711
|
+
.accountsPartial({
|
|
712
|
+
mint,
|
|
713
|
+
setCreatorAuthority,
|
|
714
|
+
})
|
|
715
|
+
.instruction();
|
|
716
|
+
}
|
|
748
717
|
}
|
|
749
718
|
|
|
750
719
|
function getFeeRecipient(global: Global): PublicKey {
|