@meteora-ag/dlmm 1.0.36-rc.1 → 1.0.36
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/README.md +29 -32
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,35 +204,32 @@ try {
|
|
|
204
204
|
|
|
205
205
|
## DLMM instance functions
|
|
206
206
|
|
|
207
|
-
| Function | Description | Return
|
|
208
|
-
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
|
|
209
|
-
| `refetchStates` | Update onchain state of DLMM instance. It's recommend to call this before interact with the program (Deposit/ Withdraw/ Swap) | `Promise<void>`
|
|
210
|
-
| `getBinArrays` | Retrieves List of Bin Arrays | `Promise<BinArrayAccount[]>`
|
|
211
|
-
| `getBinArrayForSwap` | Retrieves List of Bin Arrays for swap purpose | `Promise<BinArrayAccount[]>`
|
|
212
|
-
| `getFeeInfo` | Retrieves LbPair's fee info including `base fee`, `protocol fee` & `max fee` | `FeeInfo`
|
|
213
|
-
| `getDynamicFee` | Retrieves LbPair's dynamic fee | `Decimal`
|
|
214
|
-
| `getBinsAroundActiveBin` | retrieves a specified number of bins to the left and right of the active bin and returns them along with the active bin ID. | `Promise<{ activeBin: number; bins: BinLiquidity[] }>`
|
|
215
|
-
| `getBinsBetweenMinAndMaxPrice` | Retrieves a list of bins within a specified price | `Promise<{ activeBin: number; bins: BinLiquidity[] }>`
|
|
216
|
-
| `getBinsBetweenLowerAndUpperBound` | retrieves a list of bins between a lower and upper bin ID and returns the active bin ID and the list of bins. | `Promise<{ activeBin: number; bins: BinLiquidity[] }>`
|
|
217
|
-
| `toPricePerLamport` | Converts a real price of bin to lamport price | `string`
|
|
218
|
-
| `fromPricePerLamport` | converts a price per lamport value to a real price of bin | `string`
|
|
219
|
-
| `getActiveBin` | Retrieves the active bin ID and its corresponding price | `Promise<{ binId: number; price: string }>`
|
|
220
|
-
| `getPriceOfBinByBinId` | Get the price of a bin based on its bin ID | `string`
|
|
221
|
-
| `getBinIdFromPrice` | get bin ID based on a given price and a boolean flag indicating whether to round down or up. | `number`
|
|
222
|
-
| `getPositionsByUserAndLbPair` | Retrieves positions by user and LB pair, including active bin and user positions. | `Promise<{ activeBin: { binId: any; price: string; }; userPositions: Array<Position>;}>`
|
|
223
|
-
| `initializePositionAndAddLiquidityByStrategy` | Initializes a position and adds liquidity | `Promise<Transaction\|Transaction[]>`
|
|
224
|
-
| `addLiquidityByStrategy` | Add liquidity to existing position | `Promise<Transaction\|Transaction[]>`
|
|
225
|
-
| `removeLiquidity` | function is used to remove liquidity from a position, with the option to claim rewards and close the position. | `Promise<Transaction\|Transaction[]>`
|
|
226
|
-
| `closePosition` | Closes a position | `Promise<Transaction\|Transaction[]>`
|
|
227
|
-
| `swapQuote` | Quote for a swap | `SwapQuote`
|
|
228
|
-
| `swap` | Swap token within the LbPair | `Promise<Transaction>`
|
|
229
|
-
| `claimLMReward` | Claim rewards for a specific position owned by a specific owner | `Promise<Transaction>`
|
|
230
|
-
| `claimAllLMRewards` | Claim all liquidity mining rewards for a given owner and their positions. | `Promise<Transaction[]>`
|
|
231
|
-
| `claimSwapFee` | Claim swap fees for a specific position owned by a specific owner | `Promise<Transaction>`
|
|
232
|
-
| `claimAllSwapFee` | Claim swap fees for multiple positions owned by a specific owner | `Promise<Transaction>`
|
|
233
|
-
| `claimAllRewards` | Claim swap fees and LM rewards for multiple positions owned by a specific owner | `Promise<Transaction[]>`
|
|
234
|
-
| `syncWithMarketPrice` | Sync the pool current active bin to match nearest market price bin | `Promise<Transaction>`
|
|
235
|
-
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
```
|
|
207
|
+
| Function | Description | Return |
|
|
208
|
+
| --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
209
|
+
| `refetchStates` | Update onchain state of DLMM instance. It's recommend to call this before interact with the program (Deposit/ Withdraw/ Swap) | `Promise<void>` |
|
|
210
|
+
| `getBinArrays` | Retrieves List of Bin Arrays | `Promise<BinArrayAccount[]>` |
|
|
211
|
+
| `getBinArrayForSwap` | Retrieves List of Bin Arrays for swap purpose | `Promise<BinArrayAccount[]>` |
|
|
212
|
+
| `getFeeInfo` | Retrieves LbPair's fee info including `base fee`, `protocol fee` & `max fee` | `FeeInfo` |
|
|
213
|
+
| `getDynamicFee` | Retrieves LbPair's dynamic fee | `Decimal` |
|
|
214
|
+
| `getBinsAroundActiveBin` | retrieves a specified number of bins to the left and right of the active bin and returns them along with the active bin ID. | `Promise<{ activeBin: number; bins: BinLiquidity[] }>` |
|
|
215
|
+
| `getBinsBetweenMinAndMaxPrice` | Retrieves a list of bins within a specified price | `Promise<{ activeBin: number; bins: BinLiquidity[] }>` |
|
|
216
|
+
| `getBinsBetweenLowerAndUpperBound` | retrieves a list of bins between a lower and upper bin ID and returns the active bin ID and the list of bins. | `Promise<{ activeBin: number; bins: BinLiquidity[] }>` |
|
|
217
|
+
| `toPricePerLamport` | Converts a real price of bin to lamport price | `string` |
|
|
218
|
+
| `fromPricePerLamport` | converts a price per lamport value to a real price of bin | `string` |
|
|
219
|
+
| `getActiveBin` | Retrieves the active bin ID and its corresponding price | `Promise<{ binId: number; price: string }>` |
|
|
220
|
+
| `getPriceOfBinByBinId` | Get the price of a bin based on its bin ID | `string` |
|
|
221
|
+
| `getBinIdFromPrice` | get bin ID based on a given price and a boolean flag indicating whether to round down or up. | `number` |
|
|
222
|
+
| `getPositionsByUserAndLbPair` | Retrieves positions by user and LB pair, including active bin and user positions. | `Promise<{ activeBin: { binId: any; price: string; }; userPositions: Array<Position>;}>` |
|
|
223
|
+
| `initializePositionAndAddLiquidityByStrategy` | Initializes a position and adds liquidity | `Promise<Transaction\|Transaction[]>` |
|
|
224
|
+
| `addLiquidityByStrategy` | Add liquidity to existing position | `Promise<Transaction\|Transaction[]>` |
|
|
225
|
+
| `removeLiquidity` | function is used to remove liquidity from a position, with the option to claim rewards and close the position. | `Promise<Transaction\|Transaction[]>` |
|
|
226
|
+
| `closePosition` | Closes a position | `Promise<Transaction\|Transaction[]>` |
|
|
227
|
+
| `swapQuote` | Quote for a swap | `SwapQuote` |
|
|
228
|
+
| `swap` | Swap token within the LbPair | `Promise<Transaction>` |
|
|
229
|
+
| `claimLMReward` | Claim rewards for a specific position owned by a specific owner | `Promise<Transaction>` |
|
|
230
|
+
| `claimAllLMRewards` | Claim all liquidity mining rewards for a given owner and their positions. | `Promise<Transaction[]>` |
|
|
231
|
+
| `claimSwapFee` | Claim swap fees for a specific position owned by a specific owner | `Promise<Transaction>` |
|
|
232
|
+
| `claimAllSwapFee` | Claim swap fees for multiple positions owned by a specific owner | `Promise<Transaction>` |
|
|
233
|
+
| `claimAllRewards` | Claim swap fees and LM rewards for multiple positions owned by a specific owner | `Promise<Transaction[]>` |
|
|
234
|
+
| `syncWithMarketPrice` | Sync the pool current active bin to match nearest market price bin | `Promise<Transaction>` |
|
|
235
|
+
| `getPairPubkeyIfExists` | Get existing pool address given parameter, if not return null | `Promise<PublicKey \| null>` |
|
package/dist/index.d.ts
CHANGED
|
@@ -5131,7 +5131,7 @@ declare class DLMM {
|
|
|
5131
5131
|
* `LbPairAccount` objects.
|
|
5132
5132
|
*/
|
|
5133
5133
|
static getLbPairs(connection: Connection, opt?: Opt): Promise<LbPairAccount[]>;
|
|
5134
|
-
static
|
|
5134
|
+
static getPairPubkeyIfExists(connection: Connection, tokenX: PublicKey, tokenY: PublicKey, binStep: BN, baseFactor: BN, opt?: Opt): Promise<PublicKey>;
|
|
5135
5135
|
/**
|
|
5136
5136
|
* The `create` function is a static method that creates a new instance of the `DLMM` class
|
|
5137
5137
|
* @param {Connection} connection - The `connection` parameter is an instance of the `Connection`
|
package/dist/index.js
CHANGED
|
@@ -6922,7 +6922,7 @@ var DLMM = class {
|
|
|
6922
6922
|
);
|
|
6923
6923
|
return program.account.lbPair.all();
|
|
6924
6924
|
}
|
|
6925
|
-
static async
|
|
6925
|
+
static async getPairPubkeyIfExists(connection, tokenX, tokenY, binStep, baseFactor, opt) {
|
|
6926
6926
|
const cluster = _optionalChain([opt, 'optionalAccess', _21 => _21.cluster]) || "mainnet-beta";
|
|
6927
6927
|
const provider = new (0, _anchor.AnchorProvider)(
|
|
6928
6928
|
connection,
|
|
@@ -6948,14 +6948,12 @@ var DLMM = class {
|
|
|
6948
6948
|
program.programId
|
|
6949
6949
|
);
|
|
6950
6950
|
const account = await program.account.lbPair.fetchNullable(lbPairKey);
|
|
6951
|
-
if (
|
|
6952
|
-
return false;
|
|
6953
|
-
}
|
|
6954
|
-
if (account.parameters.baseFactor === baseFactor.toNumber()) {
|
|
6951
|
+
if (account && account.parameters.baseFactor === baseFactor.toNumber()) {
|
|
6955
6952
|
return lbPairKey;
|
|
6956
6953
|
}
|
|
6957
|
-
|
|
6958
|
-
|
|
6954
|
+
return null;
|
|
6955
|
+
} catch (error) {
|
|
6956
|
+
return null;
|
|
6959
6957
|
}
|
|
6960
6958
|
}
|
|
6961
6959
|
/**
|
|
@@ -7643,7 +7641,7 @@ var DLMM = class {
|
|
|
7643
7641
|
_anchor.AnchorProvider.defaultOptions()
|
|
7644
7642
|
);
|
|
7645
7643
|
const program = new (0, _anchor.Program)(IDL, LBCLMM_PROGRAM_IDS[opt.cluster], provider);
|
|
7646
|
-
const existsPool = await this.
|
|
7644
|
+
const existsPool = await this.getPairPubkeyIfExists(
|
|
7647
7645
|
connection,
|
|
7648
7646
|
tokenX,
|
|
7649
7647
|
tokenY,
|