@meteora-ag/dlmm 1.7.2 → 1.7.3
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.ts +1 -1
- package/dist/index.js +46 -49
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -49
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -14125,7 +14125,7 @@ var DLMM = class {
|
|
|
14125
14125
|
return program.account.lbPair.all();
|
|
14126
14126
|
}
|
|
14127
14127
|
/**
|
|
14128
|
-
* Retrieves the public key of a LB pair if it exists.
|
|
14128
|
+
* Retrieves the public key of a LB pair if it exists. This function expect the RPC have getProgramAccounts RPC method enabled.
|
|
14129
14129
|
* @param connection The connection to the Solana cluster.
|
|
14130
14130
|
* @param tokenX The mint address of token X.
|
|
14131
14131
|
* @param tokenY The mint address of token Y.
|
|
@@ -14137,57 +14137,54 @@ var DLMM = class {
|
|
|
14137
14137
|
*/
|
|
14138
14138
|
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, baseFeePowerFactor, opt) {
|
|
14139
14139
|
const program = createProgram(connection, opt);
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14140
|
+
const [lbPair2Key] = deriveLbPair2(
|
|
14141
|
+
tokenX,
|
|
14142
|
+
tokenY,
|
|
14143
|
+
binStep,
|
|
14144
|
+
baseFactor,
|
|
14145
|
+
program.programId
|
|
14146
|
+
);
|
|
14147
|
+
const account2 = await program.account.lbPair.fetchNullable(lbPair2Key);
|
|
14148
|
+
if (account2 && account2.parameters.baseFeePowerFactor == baseFeePowerFactor.toNumber()) {
|
|
14149
|
+
return lbPair2Key;
|
|
14150
|
+
}
|
|
14151
|
+
const [lbPairKey] = deriveLbPair(
|
|
14152
|
+
tokenX,
|
|
14153
|
+
tokenY,
|
|
14154
|
+
binStep,
|
|
14155
|
+
program.programId
|
|
14156
|
+
);
|
|
14157
|
+
const account = await program.account.lbPair.fetchNullable(lbPairKey);
|
|
14158
|
+
if (account && account.parameters.baseFactor === baseFactor.toNumber() && account.parameters.baseFeePowerFactor === baseFeePowerFactor.toNumber()) {
|
|
14159
|
+
return lbPairKey;
|
|
14160
|
+
}
|
|
14161
|
+
const presetParametersWithIndex = await program.account.presetParameter2.all([
|
|
14162
|
+
presetParameter2BinStepFilter(binStep),
|
|
14163
|
+
presetParameter2BaseFactorFilter(baseFactor),
|
|
14164
|
+
presetParameter2BaseFeePowerFactor(baseFeePowerFactor)
|
|
14165
|
+
]);
|
|
14166
|
+
if (presetParametersWithIndex.length > 0) {
|
|
14167
|
+
const possibleLbPairKeys = presetParametersWithIndex.map((account3) => {
|
|
14168
|
+
return deriveLbPairWithPresetParamWithIndexKey(
|
|
14169
|
+
account3.publicKey,
|
|
14170
|
+
tokenX,
|
|
14171
|
+
tokenY,
|
|
14172
|
+
program.programId
|
|
14173
|
+
)[0];
|
|
14174
|
+
});
|
|
14175
|
+
const accounts = await chunkedGetMultipleAccountInfos(
|
|
14176
|
+
program.provider.connection,
|
|
14177
|
+
possibleLbPairKeys
|
|
14156
14178
|
);
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
presetParameter2BinStepFilter(binStep),
|
|
14163
|
-
presetParameter2BaseFactorFilter(baseFactor),
|
|
14164
|
-
presetParameter2BaseFeePowerFactor(baseFeePowerFactor)
|
|
14165
|
-
]);
|
|
14166
|
-
if (presetParametersWithIndex.length > 0) {
|
|
14167
|
-
const possibleLbPairKeys = presetParametersWithIndex.map((account3) => {
|
|
14168
|
-
return deriveLbPairWithPresetParamWithIndexKey(
|
|
14169
|
-
account3.publicKey,
|
|
14170
|
-
tokenX,
|
|
14171
|
-
tokenY,
|
|
14172
|
-
program.programId
|
|
14173
|
-
)[0];
|
|
14174
|
-
});
|
|
14175
|
-
const accounts = await chunkedGetMultipleAccountInfos(
|
|
14176
|
-
program.provider.connection,
|
|
14177
|
-
possibleLbPairKeys
|
|
14178
|
-
);
|
|
14179
|
-
for (let i = 0; i < possibleLbPairKeys.length; i++) {
|
|
14180
|
-
const pairKey = possibleLbPairKeys[i];
|
|
14181
|
-
const account3 = accounts[i];
|
|
14182
|
-
if (account3) {
|
|
14183
|
-
return pairKey;
|
|
14184
|
-
}
|
|
14179
|
+
for (let i = 0; i < possibleLbPairKeys.length; i++) {
|
|
14180
|
+
const pairKey = possibleLbPairKeys[i];
|
|
14181
|
+
const account3 = accounts[i];
|
|
14182
|
+
if (account3) {
|
|
14183
|
+
return pairKey;
|
|
14185
14184
|
}
|
|
14186
14185
|
}
|
|
14187
|
-
return null;
|
|
14188
|
-
} catch (error) {
|
|
14189
|
-
return null;
|
|
14190
14186
|
}
|
|
14187
|
+
return null;
|
|
14191
14188
|
}
|
|
14192
14189
|
static async getCustomizablePermissionlessLbPairIfExists(connection, tokenX, tokenY, opt) {
|
|
14193
14190
|
const program = createProgram(connection, opt);
|
|
@@ -15141,7 +15138,7 @@ var DLMM = class {
|
|
|
15141
15138
|
tokenY,
|
|
15142
15139
|
new BN21(presetParameterState.binStep),
|
|
15143
15140
|
new BN21(presetParameterState.baseFactor),
|
|
15144
|
-
new BN21(presetParameterState.
|
|
15141
|
+
new BN21(presetParameterState.baseFeePowerFactor),
|
|
15145
15142
|
{
|
|
15146
15143
|
cluster: opt?.cluster,
|
|
15147
15144
|
programId: opt?.programId
|