@raydium-io/raydium-sdk-v2 0.1.20-alpha → 0.1.22-alpha
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/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/raydium/account/account.d.ts +1 -1
- package/lib/raydium/clmm/clmm.d.ts +1 -1
- package/lib/raydium/clmm/index.d.ts +1 -1
- package/lib/raydium/cpmm/cpmm.d.ts +1 -1
- package/lib/raydium/farm/farm.d.ts +1 -1
- package/lib/raydium/ido/ido.d.ts +1 -1
- package/lib/raydium/ido/index.d.ts +1 -1
- package/lib/raydium/index.d.ts +1 -1
- package/lib/raydium/index.js +1 -1
- package/lib/raydium/index.js.map +1 -1
- package/lib/raydium/index.mjs +1 -1
- package/lib/raydium/index.mjs.map +1 -1
- package/lib/raydium/liquidity/liquidity.d.ts +1 -1
- package/lib/raydium/marketV2/createMarket.d.ts +1 -1
- package/lib/raydium/marketV2/index.d.ts +1 -1
- package/lib/raydium/moduleBase.d.ts +1 -1
- package/lib/raydium/raydium.d.ts +1 -1
- package/lib/raydium/raydium.js +1 -1
- package/lib/raydium/raydium.js.map +1 -1
- package/lib/raydium/raydium.mjs +1 -1
- package/lib/raydium/raydium.mjs.map +1 -1
- package/lib/raydium/token/token.d.ts +1 -1
- package/lib/raydium/tradeV2/index.js.map +1 -1
- package/lib/raydium/tradeV2/index.mjs.map +1 -1
- package/lib/raydium/tradeV2/trade.d.ts +1 -1
- package/lib/raydium/tradeV2/trade.js +1 -1
- package/lib/raydium/tradeV2/trade.js.map +1 -1
- package/lib/raydium/tradeV2/trade.mjs +1 -1
- package/lib/raydium/tradeV2/trade.mjs.map +1 -1
- package/lib/raydium/utils1216/index.d.ts +1 -1
- package/lib/raydium/utils1216/utils1216.d.ts +1 -1
- package/lib/{raydium-48a3a05a.d.ts → raydium-c9108dcc.d.ts} +6 -2
- package/package.json +1 -1
- package/src/raydium/tradeV2/trade.ts +21 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-
|
|
1
|
+
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-c9108dcc.js';
|
|
2
2
|
import '@solana/web3.js';
|
|
3
3
|
import '../../api/api.js';
|
|
4
4
|
import 'axios';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../../marshmallow/index.js';
|
|
2
2
|
import '@solana/web3.js';
|
|
3
3
|
import 'bn.js';
|
|
4
|
-
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-
|
|
4
|
+
export { S as SHOW_INFO, d as canClaimErrorType, U as default } from '../../raydium-c9108dcc.js';
|
|
5
5
|
import '../../marshmallow/buffer-layout.js';
|
|
6
6
|
import '../../api/api.js';
|
|
7
7
|
import 'axios';
|
|
@@ -314,9 +314,13 @@ declare class TradeV2 extends ModuleBase {
|
|
|
314
314
|
routeProgram: PublicKey;
|
|
315
315
|
computeBudgetConfig?: ComputeBudgetConfig;
|
|
316
316
|
}): Promise<MakeMultiTxData<T>>;
|
|
317
|
-
fetchRoutePoolBasicInfo(
|
|
318
|
-
|
|
317
|
+
fetchRoutePoolBasicInfo(programIds?: {
|
|
318
|
+
amm: PublicKey;
|
|
319
|
+
clmm: PublicKey;
|
|
320
|
+
cpmm: PublicKey;
|
|
321
|
+
}): Promise<{
|
|
319
322
|
ammPools: BasicPoolInfo[];
|
|
323
|
+
clmmPools: BasicPoolInfo[];
|
|
320
324
|
cpmmPools: BasicPoolInfo[];
|
|
321
325
|
}>;
|
|
322
326
|
getAllRoute({ inputMint, outputMint, clmmPools, ammPools, cpmmPools, }: {
|
package/package.json
CHANGED
|
@@ -191,6 +191,7 @@ export default class TradeV2 extends ModuleBase {
|
|
|
191
191
|
const amountIn = swapInfo.amountIn;
|
|
192
192
|
const amountOut = swapInfo.amountOut;
|
|
193
193
|
const useSolBalance = amountIn.amount.token.mint.equals(WSOLMint);
|
|
194
|
+
const isOutputSol = amountOut.amount.token.mint.equals(WSOLMint);
|
|
194
195
|
const inputMint = amountIn.amount.token.mint;
|
|
195
196
|
const outputMint = amountOut.amount.token.mint;
|
|
196
197
|
|
|
@@ -222,6 +223,20 @@ export default class TradeV2 extends ModuleBase {
|
|
|
222
223
|
amountOut.amount.token.isToken2022 ? TOKEN_2022_PROGRAM_ID : TOKEN_PROGRAM_ID,
|
|
223
224
|
);
|
|
224
225
|
|
|
226
|
+
if (isOutputSol) {
|
|
227
|
+
txBuilder.addInstruction({
|
|
228
|
+
endInstructions: [
|
|
229
|
+
closeAccountInstruction({
|
|
230
|
+
owner: this.scope.ownerPubKey,
|
|
231
|
+
payer: this.scope.ownerPubKey,
|
|
232
|
+
tokenAccount: destinationAcc,
|
|
233
|
+
programId: TOKEN_PROGRAM_ID,
|
|
234
|
+
}),
|
|
235
|
+
],
|
|
236
|
+
endInstructionTypes: [InstructionType.CloseAccount],
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
225
240
|
let routeTokenAcc: PublicKey | undefined = undefined;
|
|
226
241
|
if (swapInfo.routeType === "route") {
|
|
227
242
|
const middleMint = swapInfo.middleToken;
|
|
@@ -290,12 +305,13 @@ export default class TradeV2 extends ModuleBase {
|
|
|
290
305
|
}
|
|
291
306
|
|
|
292
307
|
// get all amm/clmm/cpmm pools data only with id and mint
|
|
293
|
-
public async fetchRoutePoolBasicInfo(): Promise<{
|
|
294
|
-
clmmPools: BasicPoolInfo[];
|
|
308
|
+
public async fetchRoutePoolBasicInfo(programIds?: { amm: PublicKey; clmm: PublicKey; cpmm: PublicKey }): Promise<{
|
|
295
309
|
ammPools: BasicPoolInfo[];
|
|
310
|
+
clmmPools: BasicPoolInfo[];
|
|
296
311
|
cpmmPools: BasicPoolInfo[];
|
|
297
312
|
}> {
|
|
298
|
-
const
|
|
313
|
+
const { amm = AMM_V4, clmm = CLMM_PROGRAM_ID, cpmm = CREATE_CPMM_POOL_PROGRAM } = programIds || {};
|
|
314
|
+
const ammPoolsData = await this.scope.connection.getProgramAccounts(amm, {
|
|
299
315
|
dataSlice: { offset: liquidityStateV4Layout.offsetOf("baseMint"), length: 64 },
|
|
300
316
|
});
|
|
301
317
|
|
|
@@ -308,7 +324,7 @@ export default class TradeV2 extends ModuleBase {
|
|
|
308
324
|
}));
|
|
309
325
|
|
|
310
326
|
const layout = struct([publicKey("mintA"), publicKey("mintB")]);
|
|
311
|
-
const clmmPoolsData = await this.scope.connection.getProgramAccounts(
|
|
327
|
+
const clmmPoolsData = await this.scope.connection.getProgramAccounts(clmm, {
|
|
312
328
|
filters: [{ dataSize: PoolInfoLayout.span }],
|
|
313
329
|
dataSlice: { offset: PoolInfoLayout.offsetOf("mintA"), length: 64 },
|
|
314
330
|
});
|
|
@@ -323,7 +339,7 @@ export default class TradeV2 extends ModuleBase {
|
|
|
323
339
|
};
|
|
324
340
|
});
|
|
325
341
|
|
|
326
|
-
const cpmmPools = await this.scope.connection.getProgramAccounts(
|
|
342
|
+
const cpmmPools = await this.scope.connection.getProgramAccounts(cpmm, {
|
|
327
343
|
dataSlice: { offset: CpmmPoolInfoLayout.offsetOf("mintA"), length: 64 },
|
|
328
344
|
});
|
|
329
345
|
|