@meteora-ag/cp-amm-sdk 1.0.1-rc.7 → 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 +20 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +70 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6176,6 +6176,7 @@ var cp_amm_default = {
|
|
|
6176
6176
|
|
|
6177
6177
|
// src/CpAmm.ts
|
|
6178
6178
|
import {
|
|
6179
|
+
PublicKey as PublicKey5,
|
|
6179
6180
|
SystemProgram as SystemProgram2
|
|
6180
6181
|
} from "@solana/web3.js";
|
|
6181
6182
|
|
|
@@ -6802,6 +6803,16 @@ var getPriceImpact = (amount, amountWithoutSlippage) => {
|
|
|
6802
6803
|
return new Decimal2(diff.toString()).div(new Decimal2(amountWithoutSlippage.toString())).mul(100).toNumber();
|
|
6803
6804
|
};
|
|
6804
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
|
+
|
|
6805
6816
|
// src/CpAmm.ts
|
|
6806
6817
|
var CpAmm = class {
|
|
6807
6818
|
constructor(connection) {
|
|
@@ -6879,6 +6890,65 @@ var CpAmm = class {
|
|
|
6879
6890
|
return positionState;
|
|
6880
6891
|
});
|
|
6881
6892
|
}
|
|
6893
|
+
getAllConfigs() {
|
|
6894
|
+
return __async(this, null, function* () {
|
|
6895
|
+
const configAccounts = yield this._program.account.config.all();
|
|
6896
|
+
return configAccounts;
|
|
6897
|
+
});
|
|
6898
|
+
}
|
|
6899
|
+
getAllPools() {
|
|
6900
|
+
return __async(this, null, function* () {
|
|
6901
|
+
const poolAccounts = yield this._program.account.pool.all();
|
|
6902
|
+
return poolAccounts;
|
|
6903
|
+
});
|
|
6904
|
+
}
|
|
6905
|
+
getAllPositions() {
|
|
6906
|
+
return __async(this, null, function* () {
|
|
6907
|
+
const poolAccounts = yield this._program.account.position.all();
|
|
6908
|
+
return poolAccounts;
|
|
6909
|
+
});
|
|
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 PublicKey5(accountInfo.value.data.parsed.info.owner);
|
|
6925
|
+
if (owner.equals(user)) {
|
|
6926
|
+
result.push(position);
|
|
6927
|
+
}
|
|
6928
|
+
}
|
|
6929
|
+
return result;
|
|
6930
|
+
});
|
|
6931
|
+
}
|
|
6932
|
+
getPositionsByUser(user) {
|
|
6933
|
+
return __async(this, null, function* () {
|
|
6934
|
+
const positions = yield this._program.account.position.all();
|
|
6935
|
+
const positionNftMints = positions.map((item) => item.account.nftMint);
|
|
6936
|
+
const result = [];
|
|
6937
|
+
for (const position of positions) {
|
|
6938
|
+
const largesTokenAccount = yield this._program.provider.connection.getTokenLargestAccounts(
|
|
6939
|
+
positionNftMints[0]
|
|
6940
|
+
);
|
|
6941
|
+
const accountInfo = yield this._program.provider.connection.getParsedAccountInfo(
|
|
6942
|
+
largesTokenAccount.value[0].address
|
|
6943
|
+
);
|
|
6944
|
+
const owner = new PublicKey5(accountInfo.value.data.parsed.info.owner);
|
|
6945
|
+
if (owner.equals(user)) {
|
|
6946
|
+
result.push(position);
|
|
6947
|
+
}
|
|
6948
|
+
}
|
|
6949
|
+
return result;
|
|
6950
|
+
});
|
|
6951
|
+
}
|
|
6882
6952
|
getQuote(params) {
|
|
6883
6953
|
return __async(this, null, function* () {
|
|
6884
6954
|
var _a;
|