@meteora-ag/cp-amm-sdk 1.0.1-rc.8 → 1.0.1-rc.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.mts CHANGED
@@ -6419,7 +6419,14 @@ declare class CpAmm {
6419
6419
  publicKey: PublicKey;
6420
6420
  account: PositionState;
6421
6421
  }>>;
6422
- getPositionsByUser(user: PublicKey): Promise<any[]>;
6422
+ getUserPositionByPool(pool: PublicKey, user: PublicKey): Promise<Array<{
6423
+ publicKey: PublicKey;
6424
+ account: PositionState;
6425
+ }>>;
6426
+ getPositionsByUser(user: PublicKey): Promise<Array<{
6427
+ publicKey: PublicKey;
6428
+ account: PositionState;
6429
+ }>>;
6423
6430
  getQuote(params: GetQuoteParams): Promise<{
6424
6431
  swapInAmount: BN;
6425
6432
  swapOutAmount: BN;
package/dist/index.d.ts CHANGED
@@ -6419,7 +6419,14 @@ declare class CpAmm {
6419
6419
  publicKey: PublicKey;
6420
6420
  account: PositionState;
6421
6421
  }>>;
6422
- getPositionsByUser(user: PublicKey): Promise<any[]>;
6422
+ getUserPositionByPool(pool: PublicKey, user: PublicKey): Promise<Array<{
6423
+ publicKey: PublicKey;
6424
+ account: PositionState;
6425
+ }>>;
6426
+ getPositionsByUser(user: PublicKey): Promise<Array<{
6427
+ publicKey: PublicKey;
6428
+ account: PositionState;
6429
+ }>>;
6423
6430
  getQuote(params: GetQuoteParams): Promise<{
6424
6431
  swapInAmount: BN;
6425
6432
  swapOutAmount: BN;
package/dist/index.js CHANGED
@@ -6803,6 +6803,16 @@ var getPriceImpact = (amount, amountWithoutSlippage) => {
6803
6803
  return new (0, _decimaljs2.default)(diff.toString()).div(new (0, _decimaljs2.default)(amountWithoutSlippage.toString())).mul(100).toNumber();
6804
6804
  };
6805
6805
 
6806
+ // src/utils/accountFilters.ts
6807
+ var positionByPoolFilter = (pool) => {
6808
+ return {
6809
+ memcmp: {
6810
+ bytes: pool.toBase58(),
6811
+ offset: 8
6812
+ }
6813
+ };
6814
+ };
6815
+
6806
6816
  // src/CpAmm.ts
6807
6817
  var CpAmm = class {
6808
6818
  constructor(connection) {
@@ -6898,6 +6908,27 @@ var CpAmm = class {
6898
6908
  return poolAccounts;
6899
6909
  });
6900
6910
  }
6911
+ getUserPositionByPool(pool, user) {
6912
+ return __async(this, null, function* () {
6913
+ const positions = yield this._program.account.position.all([
6914
+ positionByPoolFilter(pool)
6915
+ ]);
6916
+ const result = [];
6917
+ for (const position of positions) {
6918
+ const largesTokenAccount = yield this._program.provider.connection.getTokenLargestAccounts(
6919
+ position.account.nftMint
6920
+ );
6921
+ const accountInfo = yield this._program.provider.connection.getParsedAccountInfo(
6922
+ largesTokenAccount.value[0].address
6923
+ );
6924
+ const owner = new (0, _web3js.PublicKey)(accountInfo.value.data.parsed.info.owner);
6925
+ if (owner.equals(user)) {
6926
+ result.push(position);
6927
+ }
6928
+ }
6929
+ return result;
6930
+ });
6931
+ }
6901
6932
  getPositionsByUser(user) {
6902
6933
  return __async(this, null, function* () {
6903
6934
  const positions = yield this._program.account.position.all();