@velocity-exchange/sdk 0.9.0 → 0.10.0
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/browser/adminClient.d.ts +2 -2
- package/lib/browser/adminClient.js +3 -11
- package/lib/browser/equityFloorManager.d.ts +9 -5
- package/lib/browser/equityFloorManager.js +9 -5
- package/lib/browser/idl/velocity.d.ts +2 -1
- package/lib/browser/idl/velocity.json +2 -1
- package/lib/browser/index.d.ts +2 -0
- package/lib/browser/index.js +3 -0
- package/lib/browser/jupiter/jupiterClient.d.ts +31 -27
- package/lib/browser/jupiter/jupiterClient.js +61 -35
- package/lib/browser/math/margin.d.ts +12 -10
- package/lib/browser/math/margin.js +16 -14
- package/lib/browser/math/superStake.d.ts +9 -9
- package/lib/browser/math/superStake.js +8 -8
- package/lib/browser/swap/UnifiedSwapClient.d.ts +38 -76
- package/lib/browser/swap/UnifiedSwapClient.js +46 -117
- package/lib/browser/swap/routeInstructions.d.ts +19 -0
- package/lib/browser/swap/routeInstructions.js +43 -0
- package/lib/browser/swap/types.d.ts +196 -0
- package/lib/browser/swap/types.js +88 -0
- package/lib/browser/titan/titanClient.d.ts +32 -68
- package/lib/browser/titan/titanClient.js +128 -102
- package/lib/browser/user.d.ts +16 -18
- package/lib/browser/user.js +24 -26
- package/lib/browser/velocityClient.d.ts +83 -101
- package/lib/browser/velocityClient.js +152 -289
- package/lib/node/adminClient.d.ts +2 -2
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +3 -11
- package/lib/node/equityFloorManager.d.ts +9 -5
- package/lib/node/equityFloorManager.d.ts.map +1 -1
- package/lib/node/equityFloorManager.js +9 -5
- package/lib/node/idl/velocity.d.ts +2 -1
- package/lib/node/idl/velocity.d.ts.map +1 -1
- package/lib/node/idl/velocity.json +2 -1
- package/lib/node/index.d.ts +2 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +3 -0
- package/lib/node/jupiter/jupiterClient.d.ts +31 -27
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.js +61 -35
- package/lib/node/math/margin.d.ts +12 -10
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/margin.js +16 -14
- package/lib/node/math/superStake.d.ts +9 -9
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/superStake.js +8 -8
- package/lib/node/swap/UnifiedSwapClient.d.ts +38 -76
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +46 -117
- package/lib/node/swap/routeInstructions.d.ts +20 -0
- package/lib/node/swap/routeInstructions.d.ts.map +1 -0
- package/lib/node/swap/routeInstructions.js +43 -0
- package/lib/node/swap/types.d.ts +197 -0
- package/lib/node/swap/types.d.ts.map +1 -0
- package/lib/node/swap/types.js +88 -0
- package/lib/node/titan/titanClient.d.ts +32 -68
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.js +128 -102
- package/lib/node/user.d.ts +16 -18
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/user.js +24 -26
- package/lib/node/velocityClient.d.ts +83 -101
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/lib/node/velocityClient.js +152 -289
- package/package.json +1 -1
|
@@ -24130,7 +24130,8 @@
|
|
|
24130
24130
|
{
|
|
24131
24131
|
"name": "equity_floor",
|
|
24132
24132
|
"docs": [
|
|
24133
|
-
"Minimum account equity (
|
|
24133
|
+
"Minimum account net equity (unweighted assets plus perp pnl minus",
|
|
24134
|
+
"spot liabilities, see `calculate_user_equity`). Below this the",
|
|
24134
24135
|
"permissionless breaker can trip. Risk-increasing orders, fills,",
|
|
24135
24136
|
"withdrawals and deposit transfers must clear `equity_floor +",
|
|
24136
24137
|
"equity_floor_buffer`. Settable only by the warm/cold admin; 0 disables",
|
package/lib/node/index.d.ts
CHANGED
|
@@ -65,6 +65,8 @@ export * from './events/parse';
|
|
|
65
65
|
export * from './events/pollingLogProvider';
|
|
66
66
|
export * from './jupiter/jupiterClient';
|
|
67
67
|
export * from './swap/UnifiedSwapClient';
|
|
68
|
+
export * from './swap/types';
|
|
69
|
+
export * from './swap/routeInstructions';
|
|
68
70
|
export * from './math/auction';
|
|
69
71
|
export * from './math/builder';
|
|
70
72
|
export * from './math/spotMarket';
|
package/lib/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,EAAE,EAAE,MAAM,qBAAqB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,IAAI,MAAM,qBAAqB,CAAC;AAEvC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,SAAS,CAAC;AACxB,cAAc,kBAAkB,CAAC;AACjC,cAAc,qDAAqD,CAAC;AACpE,cAAc,yDAAyD,CAAC;AACxE,OAAO,EAAE,4BAA4B,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,iCAAiC,EAAE,MAAM,8CAA8C,CAAC;AACjG,OAAO,EAAE,qCAAqC,EAAE,MAAM,kDAAkD,CAAC;AACzG,OAAO,EAAE,oCAAoC,EAAE,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAAE,0CAA0C,EAAE,MAAM,uDAAuD,CAAC;AACnH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iCAAiC,CAAC;AAChD,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,kCAAkC,EAAE,MAAM,+CAA+C,CAAC;AACnG,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AAC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AAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,iCAAiC,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,uCAAuC,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,4CAA4C,CAAC;AAC3D,cAAc,aAAa,CAAC;AAC5B,cAAc,iCAAiC,CAAC;AAChD,cAAc,QAAQ,CAAC;AAEvB,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC"}
|
package/lib/node/index.js
CHANGED
|
@@ -96,6 +96,9 @@ __exportStar(require("./events/pollingLogProvider"), exports);
|
|
|
96
96
|
__exportStar(require("./jupiter/jupiterClient"), exports);
|
|
97
97
|
// Primary swap client interface - use this for all swap operations
|
|
98
98
|
__exportStar(require("./swap/UnifiedSwapClient"), exports);
|
|
99
|
+
// The SwapProvider contract both providers implement, and the shared route filter
|
|
100
|
+
__exportStar(require("./swap/types"), exports);
|
|
101
|
+
__exportStar(require("./swap/routeInstructions"), exports);
|
|
99
102
|
__exportStar(require("./math/auction"), exports);
|
|
100
103
|
__exportStar(require("./math/builder"), exports);
|
|
101
104
|
__exportStar(require("./math/spotMarket"), exports);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AddressLookupTableAccount, Connection, PublicKey, TransactionInstruction, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
2
|
-
import {
|
|
3
|
-
import { SwapMode } from '../swap/UnifiedSwapClient';
|
|
2
|
+
import { GetRouteInstructionsParams, SwapMode, SwapProvider, SwapQuote, SwapQuoteParams, SwapRouteInstructions } from '../swap/types';
|
|
4
3
|
export interface MarketInfo {
|
|
5
4
|
id: string;
|
|
6
5
|
inAmount: number;
|
|
@@ -207,14 +206,17 @@ export interface QuoteResponse {
|
|
|
207
206
|
*/
|
|
208
207
|
errorCode?: string;
|
|
209
208
|
}
|
|
209
|
+
/** A Jupiter quote plus the payload {@link JupiterClient.getRouteInstructions} needs. */
|
|
210
|
+
export type JupiterSwapQuote = QuoteResponse & SwapQuote;
|
|
210
211
|
export declare const RECOMMENDED_JUPITER_API_VERSION = "/v1";
|
|
211
212
|
/** @deprecated Use RECOMMENDED_JUPITER_API instead. lite-api.jup.ag requires migration to api.jup.ag with API key. */
|
|
212
213
|
export declare const LEGACY_JUPITER_API = "https://lite-api.jup.ag/swap";
|
|
213
214
|
export declare const RECOMMENDED_JUPITER_API = "https://api.jup.ag/swap";
|
|
214
|
-
export declare class JupiterClient {
|
|
215
|
+
export declare class JupiterClient implements SwapProvider {
|
|
216
|
+
readonly providerName: "jupiter";
|
|
215
217
|
url: string;
|
|
216
218
|
connection: Connection;
|
|
217
|
-
|
|
219
|
+
lookupTableCache: Map<string, AddressLookupTableAccount>;
|
|
218
220
|
private apiKey?;
|
|
219
221
|
/**
|
|
220
222
|
* Create a Jupiter client
|
|
@@ -240,31 +242,34 @@ export declare class JupiterClient {
|
|
|
240
242
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
241
243
|
* @param onlyDirectRoutes whether to only return direct routes
|
|
242
244
|
*/
|
|
243
|
-
getQuote({ inputMint, outputMint, amount, maxAccounts,
|
|
244
|
-
slippageBps, swapMode, onlyDirectRoutes, excludeDexes, autoSlippage, maxAutoSlippageBps, usdEstimate, }: {
|
|
245
|
-
inputMint: PublicKey;
|
|
246
|
-
outputMint: PublicKey;
|
|
247
|
-
amount: BN;
|
|
248
|
-
maxAccounts?: number;
|
|
249
|
-
slippageBps?: number;
|
|
250
|
-
swapMode?: SwapMode;
|
|
251
|
-
onlyDirectRoutes?: boolean;
|
|
252
|
-
excludeDexes?: string[];
|
|
253
|
-
autoSlippage?: boolean;
|
|
254
|
-
maxAutoSlippageBps?: number;
|
|
255
|
-
usdEstimate?: number;
|
|
256
|
-
}): Promise<QuoteResponse>;
|
|
245
|
+
getQuote({ inputMint, outputMint, amount, maxAccounts, slippageBps, swapMode, onlyDirectRoutes, excludeDexes, autoSlippage, maxAutoSlippageBps, usdEstimate, }: SwapQuoteParams): Promise<JupiterSwapQuote>;
|
|
257
246
|
/**
|
|
258
247
|
* Get a swap transaction for quote
|
|
259
|
-
* @param
|
|
248
|
+
* @param quote quote to perform swap, from {@link getQuote}
|
|
260
249
|
* @param userPublicKey the signer's wallet public key
|
|
261
|
-
*
|
|
250
|
+
*
|
|
251
|
+
* Always builds at the quote's own slippage — the price the caller was
|
|
252
|
+
* shown. Re-quote to change it rather than overriding it here.
|
|
262
253
|
*/
|
|
263
|
-
getSwap({ quote, userPublicKey,
|
|
264
|
-
quote: QuoteResponse;
|
|
254
|
+
getSwap({ quote, userPublicKey, }: {
|
|
255
|
+
quote: QuoteResponse | JupiterSwapQuote;
|
|
265
256
|
userPublicKey: PublicKey;
|
|
266
|
-
slippageBps?: number;
|
|
267
257
|
}): Promise<VersionedTransaction>;
|
|
258
|
+
/**
|
|
259
|
+
* The standalone transaction Jupiter's `/swap` endpoint returns, setup and
|
|
260
|
+
* teardown included.
|
|
261
|
+
* @throws If the quote came from a different provider or a different wallet.
|
|
262
|
+
*/
|
|
263
|
+
getSwapTransaction({ quote, userPublicKey, }: GetRouteInstructionsParams): Promise<VersionedTransaction>;
|
|
264
|
+
/**
|
|
265
|
+
* Builds the route instructions for a quote returned by {@link getQuote}.
|
|
266
|
+
*
|
|
267
|
+
* The quote carries its own route payload, so this reads no client state
|
|
268
|
+
* and two quotes in flight can never be confused for one another. The swap
|
|
269
|
+
* is built at the slippage the quote was priced at — re-quote to change it.
|
|
270
|
+
* @throws If the quote came from a different provider or a different wallet.
|
|
271
|
+
*/
|
|
272
|
+
getRouteInstructions({ quote, userPublicKey, }: GetRouteInstructionsParams): Promise<SwapRouteInstructions>;
|
|
268
273
|
/**
|
|
269
274
|
* Get the transaction message and lookup tables for a transaction
|
|
270
275
|
* @param transaction
|
|
@@ -277,10 +282,9 @@ export declare class JupiterClient {
|
|
|
277
282
|
}>;
|
|
278
283
|
getLookupTable(accountKey: PublicKey): Promise<AddressLookupTableAccount | undefined>;
|
|
279
284
|
/**
|
|
280
|
-
*
|
|
281
|
-
* @
|
|
282
|
-
*
|
|
283
|
-
* @param outputMint the output mint
|
|
285
|
+
* Strips the setup/teardown Jupiter wraps around its route.
|
|
286
|
+
* @deprecated Use {@link getRouteInstructions}, which quotes and filters in
|
|
287
|
+
* one step. Kept for callers holding a decompiled message of their own.
|
|
284
288
|
*/
|
|
285
289
|
getJupiterInstructions({ transactionMessage, inputMint, outputMint, }: {
|
|
286
290
|
transactionMessage: TransactionMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupiterClient.d.ts","sourceRoot":"","sources":["../../../src/jupiter/jupiterClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EACzB,UAAU,EACV,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"jupiterClient.d.ts","sourceRoot":"","sources":["../../../src/jupiter/jupiterClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EACzB,UAAU,EACV,SAAS,EACT,sBAAsB,EACtB,kBAAkB,EAClB,oBAAoB,EACpB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAEN,0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B,OAAO,CAAC,yBAAyB,GAAG,SAAS,CAAC;IAqBjD;;;;OAIG;IACI,sBAAsB,CAAC,EAC7B,kBAAkB,EAClB,SAAS,EACT,UAAU,GACV,EAAE;QACF,kBAAkB,EAAE,kBAAkB,CAAC;QACvC,SAAS,EAAE,SAAS,CAAC;QACrB,UAAU,EAAE,SAAS,CAAC;KACtB,GAAG,sBAAsB,EAAE;CAO5B"}
|
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.JupiterClient = exports.RECOMMENDED_JUPITER_API = exports.LEGACY_JUPITER_API = exports.RECOMMENDED_JUPITER_API_VERSION = void 0;
|
|
7
7
|
const web3_js_1 = require("@solana/web3.js");
|
|
8
8
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
9
|
+
const routeInstructions_1 = require("../swap/routeInstructions");
|
|
10
|
+
const types_1 = require("../swap/types");
|
|
9
11
|
exports.RECOMMENDED_JUPITER_API_VERSION = '/v1';
|
|
10
12
|
/** @deprecated Use RECOMMENDED_JUPITER_API instead. lite-api.jup.ag requires migration to api.jup.ag with API key. */
|
|
11
13
|
exports.LEGACY_JUPITER_API = 'https://lite-api.jup.ag/swap';
|
|
@@ -18,7 +20,8 @@ class JupiterClient {
|
|
|
18
20
|
* @param apiKey - API key for Jupiter API. Required for api.jup.ag (free tier available at https://portal.jup.ag)
|
|
19
21
|
*/
|
|
20
22
|
constructor({ connection, url, apiKey, }) {
|
|
21
|
-
this.
|
|
23
|
+
this.providerName = 'jupiter';
|
|
24
|
+
this.lookupTableCache = new Map();
|
|
22
25
|
this.connection = connection;
|
|
23
26
|
this.url = url !== null && url !== void 0 ? url : exports.RECOMMENDED_JUPITER_API;
|
|
24
27
|
this.apiKey = apiKey;
|
|
@@ -45,8 +48,7 @@ class JupiterClient {
|
|
|
45
48
|
* @param swapMode the swap mode (ExactIn or ExactOut)
|
|
46
49
|
* @param onlyDirectRoutes whether to only return direct routes
|
|
47
50
|
*/
|
|
48
|
-
async getQuote({ inputMint, outputMint, amount, maxAccounts =
|
|
49
|
-
slippageBps = 50, swapMode = 'ExactIn', onlyDirectRoutes = false, excludeDexes, autoSlippage = false, maxAutoSlippageBps, usdEstimate, }) {
|
|
51
|
+
async getQuote({ inputMint, outputMint, amount, maxAccounts = types_1.DEFAULT_SWAP_MAX_ACCOUNTS, slippageBps = 50, swapMode = 'ExactIn', onlyDirectRoutes = false, excludeDexes, autoSlippage = false, maxAutoSlippageBps, usdEstimate, }) {
|
|
50
52
|
var _a;
|
|
51
53
|
if (autoSlippage && maxAutoSlippageBps === undefined) {
|
|
52
54
|
throw new Error('JupiterClient.getQuote: maxAutoSlippageBps is required when autoSlippage is enabled');
|
|
@@ -94,19 +96,25 @@ class JupiterClient {
|
|
|
94
96
|
if (!quote.inputMint || !quote.outputMint || !quote.outAmount) {
|
|
95
97
|
throw new Error('Jupiter quote failed: response is missing route fields');
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
// Jupiter's /swap endpoint takes the quote body back verbatim, so the
|
|
100
|
+
// quote is its own route payload.
|
|
101
|
+
return (0, types_1.buildSwapQuote)(quote, { provider: 'jupiter', quote });
|
|
98
102
|
}
|
|
99
103
|
/**
|
|
100
104
|
* Get a swap transaction for quote
|
|
101
|
-
* @param
|
|
105
|
+
* @param quote quote to perform swap, from {@link getQuote}
|
|
102
106
|
* @param userPublicKey the signer's wallet public key
|
|
103
|
-
*
|
|
107
|
+
*
|
|
108
|
+
* Always builds at the quote's own slippage — the price the caller was
|
|
109
|
+
* shown. Re-quote to change it rather than overriding it here.
|
|
104
110
|
*/
|
|
105
|
-
async getSwap({ quote, userPublicKey,
|
|
111
|
+
async getSwap({ quote, userPublicKey, }) {
|
|
106
112
|
var _a;
|
|
107
113
|
if (!quote) {
|
|
108
114
|
throw new Error('Jupiter swap quote not provided. Please try again.');
|
|
109
115
|
}
|
|
116
|
+
// `providerRoute` is our own wrapper, not part of Jupiter's quote body.
|
|
117
|
+
const { providerRoute: _providerRoute, ...quoteResponse } = quote;
|
|
110
118
|
const apiVersionParam = this.url === exports.RECOMMENDED_JUPITER_API || this.url === exports.LEGACY_JUPITER_API
|
|
111
119
|
? exports.RECOMMENDED_JUPITER_API_VERSION
|
|
112
120
|
: '';
|
|
@@ -114,9 +122,9 @@ class JupiterClient {
|
|
|
114
122
|
method: 'POST',
|
|
115
123
|
headers: this.getHeaders('application/json'),
|
|
116
124
|
body: JSON.stringify({
|
|
117
|
-
quoteResponse
|
|
125
|
+
quoteResponse,
|
|
118
126
|
userPublicKey,
|
|
119
|
-
slippageBps,
|
|
127
|
+
slippageBps: quoteResponse.slippageBps,
|
|
120
128
|
}),
|
|
121
129
|
})).json();
|
|
122
130
|
if (!('swapTransaction' in resp)) {
|
|
@@ -131,6 +139,41 @@ class JupiterClient {
|
|
|
131
139
|
throw new Error('Something went wrong with creating the Jupiter swap transaction. Please try again.');
|
|
132
140
|
}
|
|
133
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The standalone transaction Jupiter's `/swap` endpoint returns, setup and
|
|
144
|
+
* teardown included.
|
|
145
|
+
* @throws If the quote came from a different provider or a different wallet.
|
|
146
|
+
*/
|
|
147
|
+
async getSwapTransaction({ quote, userPublicKey, }) {
|
|
148
|
+
const jupiterQuote = (0, types_1.expectProviderRoute)(quote, 'jupiter', userPublicKey)
|
|
149
|
+
.quote;
|
|
150
|
+
return this.getSwap({ quote: jupiterQuote, userPublicKey });
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Builds the route instructions for a quote returned by {@link getQuote}.
|
|
154
|
+
*
|
|
155
|
+
* The quote carries its own route payload, so this reads no client state
|
|
156
|
+
* and two quotes in flight can never be confused for one another. The swap
|
|
157
|
+
* is built at the slippage the quote was priced at — re-quote to change it.
|
|
158
|
+
* @throws If the quote came from a different provider or a different wallet.
|
|
159
|
+
*/
|
|
160
|
+
async getRouteInstructions({ quote, userPublicKey, }) {
|
|
161
|
+
const jupiterQuote = (0, types_1.expectProviderRoute)(quote, 'jupiter', userPublicKey)
|
|
162
|
+
.quote;
|
|
163
|
+
const transaction = await this.getSwap({
|
|
164
|
+
quote: jupiterQuote,
|
|
165
|
+
userPublicKey,
|
|
166
|
+
});
|
|
167
|
+
const { transactionMessage, lookupTables } = await this.getTransactionMessageAndLookupTables({ transaction });
|
|
168
|
+
return {
|
|
169
|
+
instructions: (0, routeInstructions_1.filterRouteInstructions)({
|
|
170
|
+
instructions: transactionMessage.instructions,
|
|
171
|
+
inputMint: new web3_js_1.PublicKey(quote.inputMint),
|
|
172
|
+
outputMint: new web3_js_1.PublicKey(quote.outputMint),
|
|
173
|
+
}),
|
|
174
|
+
lookupTables,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
134
177
|
/**
|
|
135
178
|
* Get the transaction message and lookup tables for a transaction
|
|
136
179
|
* @param transaction
|
|
@@ -149,7 +192,7 @@ class JupiterClient {
|
|
|
149
192
|
};
|
|
150
193
|
}
|
|
151
194
|
async getLookupTable(accountKey) {
|
|
152
|
-
const cached = this.
|
|
195
|
+
const cached = this.lookupTableCache.get(accountKey.toString());
|
|
153
196
|
if (cached !== undefined) {
|
|
154
197
|
return cached;
|
|
155
198
|
}
|
|
@@ -159,36 +202,19 @@ class JupiterClient {
|
|
|
159
202
|
}
|
|
160
203
|
// Populate the cache — without this every route re-fetches the same tables,
|
|
161
204
|
// which is a large share of the RPC calls a swap makes.
|
|
162
|
-
this.
|
|
205
|
+
this.lookupTableCache.set(accountKey.toString(), lookupTable);
|
|
163
206
|
return lookupTable;
|
|
164
207
|
}
|
|
165
208
|
/**
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
*
|
|
169
|
-
* @param outputMint the output mint
|
|
209
|
+
* Strips the setup/teardown Jupiter wraps around its route.
|
|
210
|
+
* @deprecated Use {@link getRouteInstructions}, which quotes and filters in
|
|
211
|
+
* one step. Kept for callers holding a decompiled message of their own.
|
|
170
212
|
*/
|
|
171
213
|
getJupiterInstructions({ transactionMessage, inputMint, outputMint, }) {
|
|
172
|
-
return
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
if (instruction.programId.toString() ===
|
|
178
|
-
'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA') {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
if (instruction.programId.toString() === '11111111111111111111111111111111') {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
if (instruction.programId.toString() ===
|
|
185
|
-
'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL') {
|
|
186
|
-
const mint = instruction.keys[3].pubkey;
|
|
187
|
-
if (mint.equals(inputMint) || mint.equals(outputMint)) {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
214
|
+
return (0, routeInstructions_1.filterRouteInstructions)({
|
|
215
|
+
instructions: transactionMessage.instructions,
|
|
216
|
+
inputMint,
|
|
217
|
+
outputMint,
|
|
192
218
|
});
|
|
193
219
|
}
|
|
194
220
|
}
|
|
@@ -104,13 +104,14 @@ export declare function calculateCollateralDepositRequiredForTrade(velocityClien
|
|
|
104
104
|
* Minimal equity floor to carry along with a quote transfer of `amount` out
|
|
105
105
|
* of a subaccount so the debited side ends at/above its buffered floor
|
|
106
106
|
* (`equityFloor + equityFloorBuffer`): the first
|
|
107
|
-
* `
|
|
107
|
+
* `netEquity - (floor + buffer)` of the transfer carries no floor, the
|
|
108
108
|
* remainder carries floor one-for-one, capped at the floor the subaccount
|
|
109
|
-
* actually holds.
|
|
110
|
-
*
|
|
111
|
-
*
|
|
109
|
+
* actually holds. `netEquity` is `User.getNetUsdValue()`, the metric the
|
|
110
|
+
* onchain floor checks use. Returns zero when no floor is set. The result
|
|
111
|
+
* never exceeds `amount`, so a credited side that met its own buffered floor
|
|
112
|
+
* before the transfer still meets it after. All values QUOTE_PRECISION.
|
|
112
113
|
*/
|
|
113
|
-
export declare function calculateEquityFloorAutoDelta(amount: BN,
|
|
114
|
+
export declare function calculateEquityFloorAutoDelta(amount: BN, netEquity: BN, equityFloor: BN, equityFloorBuffer: BN): BN;
|
|
114
115
|
/**
|
|
115
116
|
* Severity of a subaccount's equity relative to its floor, most to least
|
|
116
117
|
* severe. `breached`: below the floor, the permissionless breaker can trip.
|
|
@@ -120,10 +121,11 @@ export declare function calculateEquityFloorAutoDelta(amount: BN, totalCollatera
|
|
|
120
121
|
*/
|
|
121
122
|
export type EquityFloorLevel = 'breached' | 'critical' | 'warning' | 'healthy' | 'disabled';
|
|
122
123
|
/**
|
|
123
|
-
* Classifies `
|
|
124
|
-
* `EquityFloorManager` and the equity-floor guard bot
|
|
125
|
-
* levels. `warningBufferMultiple` scales the warning
|
|
126
|
-
* floor (default 2: warn inside `floor + 2 * buffer`).
|
|
124
|
+
* Classifies `netEquity` (`User.getNetUsdValue()`) against the floor
|
|
125
|
+
* thresholds. Used by the `EquityFloorManager` and the equity-floor guard bot
|
|
126
|
+
* so both report the same levels. `warningBufferMultiple` scales the warning
|
|
127
|
+
* threshold above the floor (default 2: warn inside `floor + 2 * buffer`).
|
|
128
|
+
* All QUOTE_PRECISION.
|
|
127
129
|
*/
|
|
128
|
-
export declare function getEquityFloorLevel(
|
|
130
|
+
export declare function getEquityFloorLevel(netEquity: BN, equityFloor: BN, equityFloorBuffer: BN, warningBufferMultiple?: number): EquityFloorLevel;
|
|
129
131
|
//# sourceMappingURL=margin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"margin.d.ts","sourceRoot":"","sources":["../../../src/math/margin.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CA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ollateralDepositR
|
|
|
214
214
|
* Minimal equity floor to carry along with a quote transfer of `amount` out
|
|
215
215
|
* of a subaccount so the debited side ends at/above its buffered floor
|
|
216
216
|
* (`equityFloor + equityFloorBuffer`): the first
|
|
217
|
-
* `
|
|
217
|
+
* `netEquity - (floor + buffer)` of the transfer carries no floor, the
|
|
218
218
|
* remainder carries floor one-for-one, capped at the floor the subaccount
|
|
219
|
-
* actually holds.
|
|
220
|
-
*
|
|
221
|
-
*
|
|
219
|
+
* actually holds. `netEquity` is `User.getNetUsdValue()`, the metric the
|
|
220
|
+
* onchain floor checks use. Returns zero when no floor is set. The result
|
|
221
|
+
* never exceeds `amount`, so a credited side that met its own buffered floor
|
|
222
|
+
* before the transfer still meets it after. All values QUOTE_PRECISION.
|
|
222
223
|
*/
|
|
223
|
-
function calculateEquityFloorAutoDelta(amount,
|
|
224
|
+
function calculateEquityFloorAutoDelta(amount, netEquity, equityFloor, equityFloorBuffer) {
|
|
224
225
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
225
226
|
return numericConstants_1.ZERO;
|
|
226
227
|
}
|
|
227
|
-
const excess = anchor_1.BN.max(
|
|
228
|
+
const excess = anchor_1.BN.max(netEquity.sub(equityFloor.add(equityFloorBuffer)), numericConstants_1.ZERO);
|
|
228
229
|
return anchor_1.BN.min(anchor_1.BN.max(amount.sub(excess), numericConstants_1.ZERO), equityFloor);
|
|
229
230
|
}
|
|
230
231
|
exports.calculateEquityFloorAutoDelta = calculateEquityFloorAutoDelta;
|
|
231
232
|
/**
|
|
232
|
-
* Classifies `
|
|
233
|
-
* `EquityFloorManager` and the equity-floor guard bot
|
|
234
|
-
* levels. `warningBufferMultiple` scales the warning
|
|
235
|
-
* floor (default 2: warn inside `floor + 2 * buffer`).
|
|
233
|
+
* Classifies `netEquity` (`User.getNetUsdValue()`) against the floor
|
|
234
|
+
* thresholds. Used by the `EquityFloorManager` and the equity-floor guard bot
|
|
235
|
+
* so both report the same levels. `warningBufferMultiple` scales the warning
|
|
236
|
+
* threshold above the floor (default 2: warn inside `floor + 2 * buffer`).
|
|
237
|
+
* All QUOTE_PRECISION.
|
|
236
238
|
*/
|
|
237
|
-
function getEquityFloorLevel(
|
|
239
|
+
function getEquityFloorLevel(netEquity, equityFloor, equityFloorBuffer, warningBufferMultiple = 2) {
|
|
238
240
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
239
241
|
return 'disabled';
|
|
240
242
|
}
|
|
241
|
-
if (
|
|
243
|
+
if (netEquity.lt(equityFloor)) {
|
|
242
244
|
return 'breached';
|
|
243
245
|
}
|
|
244
|
-
if (
|
|
246
|
+
if (netEquity.lt(equityFloor.add(equityFloorBuffer))) {
|
|
245
247
|
return 'critical';
|
|
246
248
|
}
|
|
247
|
-
if (
|
|
249
|
+
if (netEquity.lt(equityFloor.add(equityFloorBuffer.muln(warningBufferMultiple)))) {
|
|
248
250
|
return 'warning';
|
|
249
251
|
}
|
|
250
252
|
return 'healthy';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AddressLookupTableAccount, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
-
import { JupiterClient,
|
|
2
|
+
import { JupiterClient, JupiterSwapQuote } from '../jupiter/jupiterClient';
|
|
3
3
|
import { VelocityClient } from '../velocityClient';
|
|
4
4
|
import { BN } from '../isomorphic/anchor';
|
|
5
5
|
import { User } from '../user';
|
|
@@ -61,7 +61,7 @@ export declare function fetchBSolVelocityEmissions(): Promise<fetch.Response>;
|
|
|
61
61
|
* @param {boolean} [params.forceMarinade] - Force the direct Marinade stake path over a Jupiter
|
|
62
62
|
* swap even if Jupiter would be cheaper (market index 2 only)
|
|
63
63
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
64
|
-
* @param {
|
|
64
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse instead of
|
|
65
65
|
* fetching a fresh one
|
|
66
66
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
67
67
|
* method: 'jupiter' | 'marinade'; price?: number }>} The instructions to submit, any address
|
|
@@ -78,7 +78,7 @@ export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClie
|
|
|
78
78
|
userAccountPublicKey?: PublicKey;
|
|
79
79
|
forceMarinade?: boolean;
|
|
80
80
|
onlyDirectRoutes?: boolean;
|
|
81
|
-
jupiterQuote?:
|
|
81
|
+
jupiterQuote?: JupiterSwapQuote;
|
|
82
82
|
}): Promise<{
|
|
83
83
|
ixs: TransactionInstruction[];
|
|
84
84
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -100,7 +100,7 @@ export declare function findBestSuperStakeIxs({ marketIndex, amount, jupiterClie
|
|
|
100
100
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
101
101
|
* @param {boolean} [params.forceMarinade] - Force the Marinade path regardless of Jupiter pricing
|
|
102
102
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
103
|
-
* @param {
|
|
103
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
104
104
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
105
105
|
* method: 'jupiter' | 'marinade'; price: number }>} The chosen route's instructions, required
|
|
106
106
|
* lookup tables, the method used, and the mSOL/SOL price used for the decision
|
|
@@ -113,7 +113,7 @@ export declare function findBestMSolSuperStakeIxs({ amount, jupiterClient, veloc
|
|
|
113
113
|
userAccountPublicKey?: PublicKey;
|
|
114
114
|
forceMarinade?: boolean;
|
|
115
115
|
onlyDirectRoutes?: boolean;
|
|
116
|
-
jupiterQuote?:
|
|
116
|
+
jupiterQuote?: JupiterSwapQuote;
|
|
117
117
|
}): Promise<{
|
|
118
118
|
ixs: TransactionInstruction[];
|
|
119
119
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -130,7 +130,7 @@ export declare function findBestMSolSuperStakeIxs({ amount, jupiterClient, veloc
|
|
|
130
130
|
* @param {VelocityClient} params.velocityClient - Velocity client
|
|
131
131
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
132
132
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
133
|
-
* @param {
|
|
133
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
134
134
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
135
135
|
* method: 'jupiter' | 'marinade'; price?: number }>} Always resolves with `method: 'jupiter'`
|
|
136
136
|
*/
|
|
@@ -140,7 +140,7 @@ export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, ve
|
|
|
140
140
|
velocityClient: VelocityClient;
|
|
141
141
|
userAccountPublicKey?: PublicKey;
|
|
142
142
|
onlyDirectRoutes?: boolean;
|
|
143
|
-
jupiterQuote?:
|
|
143
|
+
jupiterQuote?: JupiterSwapQuote;
|
|
144
144
|
}): Promise<{
|
|
145
145
|
ixs: TransactionInstruction[];
|
|
146
146
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -161,7 +161,7 @@ export declare function findBestJitoSolSuperStakeIxs({ amount, jupiterClient, ve
|
|
|
161
161
|
* @param {VelocityClient} params.velocityClient - Velocity client
|
|
162
162
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
163
163
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
164
|
-
* @param {
|
|
164
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
165
165
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
166
166
|
* method: 'jupiter' | 'marinade' }>} Always resolves with `method: 'jupiter'`
|
|
167
167
|
*/
|
|
@@ -173,7 +173,7 @@ export declare function findBestLstSuperStakeIxs({ amount, jupiterClient, veloci
|
|
|
173
173
|
velocityClient: VelocityClient;
|
|
174
174
|
userAccountPublicKey?: PublicKey;
|
|
175
175
|
onlyDirectRoutes?: boolean;
|
|
176
|
-
jupiterQuote?:
|
|
176
|
+
jupiterQuote?: JupiterSwapQuote;
|
|
177
177
|
}): Promise<{
|
|
178
178
|
ixs: TransactionInstruction[];
|
|
179
179
|
lookupTables: AddressLookupTableAccount[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"superStake.d.ts","sourceRoot":"","sources":["../../../src/math/superStake.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EAEzB,SAAS,EACT,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"superStake.d.ts","sourceRoot":"","sources":["../../../src/math/superStake.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,yBAAyB,EAEzB,SAAS,EACT,sBAAsB,EACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,EAAE,EAAE,MAAM,sBAAsB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAa,MAAM,UAAU,CAAC;AAEpD,OAAO,KAAK,MAAM,YAAY,CAAC;AAG/B,kGAAkG;AAClG,MAAM,MAAM,uBAAuB,GAAG;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QACP,UAAU,EAAE;YACX,WAAW,EAAE,MAAM,CAAC;YACpB,WAAW,EAAE,MAAM,CAAC;SACpB,CAAC;QACF,GAAG,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MA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elocityEmissions;
|
|
|
49
49
|
* @param {boolean} [params.forceMarinade] - Force the direct Marinade stake path over a Jupiter
|
|
50
50
|
* swap even if Jupiter would be cheaper (market index 2 only)
|
|
51
51
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
52
|
-
* @param {
|
|
52
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse instead of
|
|
53
53
|
* fetching a fresh one
|
|
54
54
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
55
55
|
* method: 'jupiter' | 'marinade'; price?: number }>} The instructions to submit, any address
|
|
@@ -112,7 +112,7 @@ exports.findBestSuperStakeIxs = findBestSuperStakeIxs;
|
|
|
112
112
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
113
113
|
* @param {boolean} [params.forceMarinade] - Force the Marinade path regardless of Jupiter pricing
|
|
114
114
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
115
|
-
* @param {
|
|
115
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
116
116
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
117
117
|
* method: 'jupiter' | 'marinade'; price: number }>} The chosen route's instructions, required
|
|
118
118
|
* lookup tables, the method used, and the mSOL/SOL price used for the decision
|
|
@@ -155,10 +155,10 @@ async function findBestMSolSuperStakeIxs({ amount, jupiterClient, velocityClient
|
|
|
155
155
|
};
|
|
156
156
|
}
|
|
157
157
|
else {
|
|
158
|
-
const { ixs, lookupTables } = await velocityClient.
|
|
158
|
+
const { ixs, lookupTables } = await velocityClient.getProviderSwapIx({
|
|
159
159
|
inMarketIndex: 1,
|
|
160
160
|
outMarketIndex: 2,
|
|
161
|
-
jupiterClient,
|
|
161
|
+
swapProvider: jupiterClient,
|
|
162
162
|
amount,
|
|
163
163
|
userAccountPublicKey,
|
|
164
164
|
onlyDirectRoutes,
|
|
@@ -183,7 +183,7 @@ exports.findBestMSolSuperStakeIxs = findBestMSolSuperStakeIxs;
|
|
|
183
183
|
* @param {VelocityClient} params.velocityClient - Velocity client
|
|
184
184
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
185
185
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
186
|
-
* @param {
|
|
186
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
187
187
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
188
188
|
* method: 'jupiter' | 'marinade'; price?: number }>} Always resolves with `method: 'jupiter'`
|
|
189
189
|
*/
|
|
@@ -214,15 +214,15 @@ exports.findBestJitoSolSuperStakeIxs = findBestJitoSolSuperStakeIxs;
|
|
|
214
214
|
* @param {VelocityClient} params.velocityClient - Velocity client
|
|
215
215
|
* @param {PublicKey} [params.userAccountPublicKey] - The target sub-account
|
|
216
216
|
* @param {boolean} [params.onlyDirectRoutes] - Restrict Jupiter routing to direct swaps only
|
|
217
|
-
* @param {
|
|
217
|
+
* @param {JupiterSwapQuote} [params.jupiterQuote] - A pre-fetched Jupiter quote to reuse
|
|
218
218
|
* @return {Promise<{ ixs: TransactionInstruction[]; lookupTables: AddressLookupTableAccount[];
|
|
219
219
|
* method: 'jupiter' | 'marinade' }>} Always resolves with `method: 'jupiter'`
|
|
220
220
|
*/
|
|
221
221
|
async function findBestLstSuperStakeIxs({ amount, jupiterClient, velocityClient, userAccountPublicKey, onlyDirectRoutes, lstMarketIndex, jupiterQuote, }) {
|
|
222
|
-
const { ixs, lookupTables } = await velocityClient.
|
|
222
|
+
const { ixs, lookupTables } = await velocityClient.getProviderSwapIx({
|
|
223
223
|
inMarketIndex: 1,
|
|
224
224
|
outMarketIndex: lstMarketIndex,
|
|
225
|
-
jupiterClient,
|
|
225
|
+
swapProvider: jupiterClient,
|
|
226
226
|
amount,
|
|
227
227
|
userAccountPublicKey,
|
|
228
228
|
onlyDirectRoutes,
|