@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
package/lib/browser/user.js
CHANGED
|
@@ -897,19 +897,20 @@ class User {
|
|
|
897
897
|
return marginCalc.totalCollateral;
|
|
898
898
|
}
|
|
899
899
|
/**
|
|
900
|
-
* True when the account has an admin-set `equityFloor` and its
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
*
|
|
906
|
-
|
|
907
|
-
|
|
900
|
+
* True when the account has an admin-set `equityFloor` and its net equity
|
|
901
|
+
* (`getNetUsdValue`: unweighted assets and perp PnL minus unweighted spot
|
|
902
|
+
* liabilities, at live oracle prices) is below it. This is the trip
|
|
903
|
+
* threshold of the permissionless `tripEquityFloorBreaker`; action gating
|
|
904
|
+
* happens at `equityFloor + equityFloorBuffer` (see
|
|
905
|
+
* `isBelowBufferedEquityFloor`). Mirrors `User::is_below_equity_floor`
|
|
906
|
+
* onchain.
|
|
907
|
+
*/
|
|
908
|
+
isBelowEquityFloor() {
|
|
908
909
|
const equityFloor = this.getUserAccountOrThrow().equityFloor;
|
|
909
910
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
910
911
|
return false;
|
|
911
912
|
}
|
|
912
|
-
return this.
|
|
913
|
+
return this.getNetUsdValue().lt(equityFloor);
|
|
913
914
|
}
|
|
914
915
|
/**
|
|
915
916
|
* The equity required by risk-increasing actions:
|
|
@@ -922,48 +923,45 @@ class User {
|
|
|
922
923
|
return userAccount.equityFloor.add(userAccount.equityFloorBuffer);
|
|
923
924
|
}
|
|
924
925
|
/**
|
|
925
|
-
* True when the account has an admin-set `equityFloor` and its
|
|
926
|
-
*
|
|
927
|
-
* the program rejects risk-increasing order placement and fills,
|
|
926
|
+
* True when the account has an admin-set `equityFloor` and its net equity
|
|
927
|
+
* (`getNetUsdValue`) is below `equityFloor + equityFloorBuffer`. While
|
|
928
|
+
* below, the program rejects risk-increasing order placement and fills,
|
|
928
929
|
* withdrawals, and transfers out of the account (`EquityBelowFloor`);
|
|
929
930
|
* reduce-only activity stays allowed. Mirrors
|
|
930
931
|
* `User::is_below_buffered_equity_floor` on-chain.
|
|
931
|
-
* @param strict Use TWAP-bounded oracle pricing, matching the withdraw path. Defaults to false.
|
|
932
932
|
*/
|
|
933
|
-
isBelowBufferedEquityFloor(
|
|
933
|
+
isBelowBufferedEquityFloor() {
|
|
934
934
|
const equityFloor = this.getUserAccountOrThrow().equityFloor;
|
|
935
935
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
936
936
|
return false;
|
|
937
937
|
}
|
|
938
|
-
return this.
|
|
938
|
+
return this.getNetUsdValue().lt(this.getBufferedEquityFloor());
|
|
939
939
|
}
|
|
940
940
|
/**
|
|
941
|
-
*
|
|
941
|
+
* Net equity (`getNetUsdValue`) in excess of the admin-set `equityFloor`,
|
|
942
942
|
* floored at zero (QUOTE_PRECISION). Unbounded (`null`) when no floor is set.
|
|
943
943
|
* This is headroom above the trip threshold; headroom above the level
|
|
944
944
|
* risk-increasing actions must clear is `getEquityAboveBufferedFloor`.
|
|
945
|
-
* @param strict Use TWAP-bounded oracle pricing. Defaults to false.
|
|
946
945
|
*/
|
|
947
|
-
getEquityAboveFloor(
|
|
946
|
+
getEquityAboveFloor() {
|
|
948
947
|
const equityFloor = this.getUserAccountOrThrow().equityFloor;
|
|
949
948
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
950
949
|
return null;
|
|
951
950
|
}
|
|
952
|
-
return anchor_1.BN.max(this.
|
|
951
|
+
return anchor_1.BN.max(this.getNetUsdValue().sub(equityFloor), numericConstants_1.ZERO);
|
|
953
952
|
}
|
|
954
953
|
/**
|
|
955
|
-
*
|
|
954
|
+
* Net equity (`getNetUsdValue`) in excess of `equityFloor +
|
|
956
955
|
* equityFloorBuffer`, floored at zero (QUOTE_PRECISION). Unbounded
|
|
957
956
|
* (`null`) when no floor is set. When this reaches zero, risk-increasing
|
|
958
957
|
* actions start rejecting.
|
|
959
|
-
* @param strict Use TWAP-bounded oracle pricing. Defaults to false.
|
|
960
958
|
*/
|
|
961
|
-
getEquityAboveBufferedFloor(
|
|
959
|
+
getEquityAboveBufferedFloor() {
|
|
962
960
|
const equityFloor = this.getUserAccountOrThrow().equityFloor;
|
|
963
961
|
if (equityFloor.lte(numericConstants_1.ZERO)) {
|
|
964
962
|
return null;
|
|
965
963
|
}
|
|
966
|
-
return anchor_1.BN.max(this.
|
|
964
|
+
return anchor_1.BN.max(this.getNetUsdValue().sub(this.getBufferedEquityFloor()), numericConstants_1.ZERO);
|
|
967
965
|
}
|
|
968
966
|
/**
|
|
969
967
|
* Builds the liquidation-buffer map to pass into margin calculations while
|
|
@@ -2429,9 +2427,9 @@ class User {
|
|
|
2429
2427
|
const spotMarket = this.velocityClient.getSpotMarketAccountOrThrow(marketIndex);
|
|
2430
2428
|
// eslint-disable-next-line prefer-const
|
|
2431
2429
|
let { borrowLimit, withdrawLimit } = (0, spotBalance_2.calculateWithdrawLimit)(spotMarket, nowTs);
|
|
2432
|
-
// the withdraw path enforces the equity floor on post-withdraw
|
|
2433
|
-
//
|
|
2434
|
-
const equityAboveFloor = this.getEquityAboveFloor(
|
|
2430
|
+
// the withdraw path enforces the equity floor on post-withdraw net
|
|
2431
|
+
// equity, so equity above the floor caps free collateral here
|
|
2432
|
+
const equityAboveFloor = this.getEquityAboveFloor();
|
|
2435
2433
|
if (equityAboveFloor !== null && equityAboveFloor.eq(numericConstants_1.ZERO)) {
|
|
2436
2434
|
return numericConstants_1.ZERO;
|
|
2437
2435
|
}
|
|
@@ -30,8 +30,8 @@ import { User } from './user';
|
|
|
30
30
|
import { UserSubscriptionConfig } from './userConfig';
|
|
31
31
|
import { VelocityEnv, VelocityProgram } from './config';
|
|
32
32
|
import { UserStats } from './userStats';
|
|
33
|
-
import { JupiterClient,
|
|
34
|
-
import { SwapMode,
|
|
33
|
+
import { JupiterClient, JupiterSwapQuote } from './jupiter/jupiterClient';
|
|
34
|
+
import { SwapMode, SwapProvider, SwapQuote } from './swap/types';
|
|
35
35
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
36
36
|
import { TxHandler } from './tx/txHandler';
|
|
37
37
|
import { SignedMsgOrderParams } from './types';
|
|
@@ -39,7 +39,6 @@ import { TakerInfo } from './types';
|
|
|
39
39
|
import { ConstituentMap } from './constituentMap/constituentMap';
|
|
40
40
|
import { RevenueShareEscrowMap } from './userMap/revenueShareEscrowMap';
|
|
41
41
|
import { TitanClient } from './titan/titanClient';
|
|
42
|
-
import { UnifiedSwapClient } from './swap/UnifiedSwapClient';
|
|
43
42
|
/**
|
|
44
43
|
* Union type for swap clients (Titan and Jupiter) - Legacy type
|
|
45
44
|
* @deprecated Use UnifiedSwapClient class instead
|
|
@@ -1573,16 +1572,19 @@ export declare class VelocityClient {
|
|
|
1573
1572
|
* @param fromSubAccountId - Sub-account id to debit.
|
|
1574
1573
|
* @param toSubAccountId - Sub-account id to credit.
|
|
1575
1574
|
* @param equityFloorDelta - Equity floor (QUOTE_PRECISION) to move from the debited to the credited
|
|
1576
|
-
* sub-account along with the funds, keeping the sum of floors constant.
|
|
1575
|
+
* sub-account along with the funds, keeping the sum of floors constant. A proportional share of
|
|
1576
|
+
* the debited side's `equityFloorBuffer` travels with the floor (rounded up on the debited side,
|
|
1577
|
+
* so shedding the whole floor also sheds the whole buffer; no orphan buffer is left on a
|
|
1578
|
+
* check-disabled sub-account), keeping the sum of buffers constant too. The debited side must not
|
|
1577
1579
|
* already be below the floor being reduced (a below-floor sub-account cannot shed floor to defuse a
|
|
1578
|
-
* pending equity-breaker trip), must stay at/above its reduced floor plus its
|
|
1579
|
-
* and the credited side's
|
|
1580
|
-
* its
|
|
1580
|
+
* pending equity-breaker trip), must stay at/above its reduced floor plus its reduced buffer,
|
|
1581
|
+
* and the credited side's net equity (after the transfer lands) must back its increased floor plus
|
|
1582
|
+
* its increased buffer, else the transfer reverts with `InvalidEquityFloorTransfer`. Pass `'auto'`
|
|
1581
1583
|
* (quote market only) to move the minimal floor needed for the debited side to stay at/above its
|
|
1582
|
-
* buffered floor: `max(0, amount - max(0,
|
|
1584
|
+
* buffered floor: `max(0, amount - max(0, netEquity - (floor + buffer)))`, capped at the debited
|
|
1583
1585
|
* side's floor (see `calculateEquityFloorAutoDelta`). The auto delta never exceeds `amount`, so the
|
|
1584
1586
|
* credited side stays backed whenever it was before. Client-side pricing can differ slightly from
|
|
1585
|
-
* the
|
|
1587
|
+
* the onchain check at the exact boundary; retry with an explicit padded delta if an
|
|
1586
1588
|
* `'auto'` transfer reverts. Defaults to zero.
|
|
1587
1589
|
* @param txParams - Optional compute-unit/priority-fee overrides for the transaction.
|
|
1588
1590
|
* @returns The transaction signature.
|
|
@@ -2305,34 +2307,32 @@ export declare class VelocityClient {
|
|
|
2305
2307
|
* instructions in a single transaction, so the swap is settled directly against the user's
|
|
2306
2308
|
* deposits/vault balances rather than the wallet's own token accounts. Sends and confirms the
|
|
2307
2309
|
* transaction.
|
|
2308
|
-
* @param swapClient -
|
|
2309
|
-
* `
|
|
2310
|
-
* @param jupiterClient - @deprecated Use `swapClient` instead.
|
|
2311
|
-
* not
|
|
2310
|
+
* @param swapClient - Provider used to quote the swap and build its route: a
|
|
2311
|
+
* `UnifiedSwapClient`, or a `TitanClient`/`JupiterClient` directly. See `getProviderSwapIx`.
|
|
2312
|
+
* @param jupiterClient - @deprecated Use `swapClient` instead. Used only when `swapClient` is
|
|
2313
|
+
* not passed.
|
|
2312
2314
|
* @param outMarketIndex - Spot market index of the token being bought.
|
|
2313
2315
|
* @param inMarketIndex - Spot market index of the token being sold.
|
|
2314
2316
|
* @param outAssociatedTokenAccount - Token account to receive the bought token; created
|
|
2315
2317
|
* idempotently if omitted.
|
|
2316
2318
|
* @param inAssociatedTokenAccount - Token account to source the sold token from; created
|
|
2317
2319
|
* idempotently if omitted.
|
|
2318
|
-
* @param amount - Amount of the "in" token (or "out" token when
|
|
2319
|
-
* which case this is the desired output amount), in the token's own mint
|
|
2320
|
-
* fixed protocol precision.
|
|
2320
|
+
* @param amount - Amount of the "in" token (or "out" token when the effective mode is
|
|
2321
|
+
* `ExactOut`, in which case this is the desired output amount), in the token's own mint
|
|
2322
|
+
* decimals — not a fixed protocol precision.
|
|
2321
2323
|
* @param slippageBps - Max slippage in basis points passed to the swap provider's routing API.
|
|
2322
|
-
* @param swapMode - `ExactIn` (default) or `ExactOut`.
|
|
2324
|
+
* @param swapMode - `ExactIn` (default) or `ExactOut`. Ignored when `quote` is passed — the
|
|
2325
|
+
* quote's own mode wins.
|
|
2323
2326
|
* @param reduceOnly - Whether the in/out token's position on the velocity account must reduce
|
|
2324
2327
|
* (not flip sign); enforced by `endSwap` after the swap completes.
|
|
2325
|
-
* @param
|
|
2326
|
-
*
|
|
2328
|
+
* @param quote - Pre-fetched quote (skips an extra round-trip to the swap provider). Must be
|
|
2329
|
+
* for this pair and this `amount`.
|
|
2327
2330
|
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
2328
|
-
* @throws If neither `swapClient` nor `jupiterClient` is provided
|
|
2329
|
-
* recognized client type.
|
|
2331
|
+
* @throws If neither `swapClient` nor `jupiterClient` is provided.
|
|
2330
2332
|
* @returns The transaction signature.
|
|
2331
2333
|
*/
|
|
2332
|
-
swap({ swapClient,
|
|
2333
|
-
swapClient?:
|
|
2334
|
-
/** @deprecated Use swapClient instead. Legacy parameter for backward compatibility */
|
|
2335
|
-
jupiterClient?: JupiterClient;
|
|
2334
|
+
swap({ swapClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, quote, onlyDirectRoutes, }: {
|
|
2335
|
+
swapClient?: SwapProvider;
|
|
2336
2336
|
outMarketIndex: number;
|
|
2337
2337
|
inMarketIndex: number;
|
|
2338
2338
|
outAssociatedTokenAccount?: PublicKey;
|
|
@@ -2343,49 +2343,59 @@ export declare class VelocityClient {
|
|
|
2343
2343
|
reduceOnly?: SwapReduceOnly;
|
|
2344
2344
|
txParams?: TxParams;
|
|
2345
2345
|
onlyDirectRoutes?: boolean;
|
|
2346
|
-
|
|
2347
|
-
quote?: QuoteResponse;
|
|
2348
|
-
};
|
|
2349
|
-
quote?: UnifiedQuoteResponse;
|
|
2346
|
+
quote?: SwapQuote;
|
|
2350
2347
|
}): Promise<TransactionSignature>;
|
|
2351
2348
|
/**
|
|
2352
|
-
*
|
|
2353
|
-
*
|
|
2354
|
-
*
|
|
2355
|
-
*
|
|
2356
|
-
* created in the same transaction and not yet resolvable via `getUserAccountPublicKey`).
|
|
2357
|
-
* @returns `ixs` — instruction list (ATA creation, `beginSwap`, Titan swap instructions,
|
|
2358
|
-
* `endSwap`, in order) and `lookupTables` needed to fit it in a versioned transaction.
|
|
2349
|
+
* Throws unless a quote swaps exactly the pair the `beginSwap`/`endSwap` pair is being built
|
|
2350
|
+
* for. A mismatched quote routes and executes normally, but deposits its output into a token
|
|
2351
|
+
* account `endSwap` isn't watching, so it reverts with `InvalidSwap: amount_out must be
|
|
2352
|
+
* greater than 0` only after the funds have already moved.
|
|
2359
2353
|
*/
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
outAssociatedTokenAccount?: PublicKey;
|
|
2365
|
-
inAssociatedTokenAccount?: PublicKey;
|
|
2366
|
-
amount: BN;
|
|
2367
|
-
slippageBps?: number;
|
|
2368
|
-
swapMode?: string;
|
|
2369
|
-
onlyDirectRoutes?: boolean;
|
|
2370
|
-
reduceOnly?: SwapReduceOnly;
|
|
2371
|
-
userAccountPublicKey?: PublicKey;
|
|
2372
|
-
}): Promise<{
|
|
2373
|
-
ixs: TransactionInstruction[];
|
|
2374
|
-
lookupTables: AddressLookupTableAccount[];
|
|
2375
|
-
}>;
|
|
2354
|
+
protected assertQuoteMatchesMarkets(quote: {
|
|
2355
|
+
inputMint: string;
|
|
2356
|
+
outputMint: string;
|
|
2357
|
+
}, inMarket: SpotMarketAccount, outMarket: SpotMarketAccount): void;
|
|
2376
2358
|
/**
|
|
2377
|
-
*
|
|
2378
|
-
*
|
|
2379
|
-
*
|
|
2380
|
-
|
|
2359
|
+
* Throws unless a quote is for the size the caller asked to swap. `beginSwap` releases funds
|
|
2360
|
+
* sized off the quote, so a quote for a different size moves the wrong amount out of the user's
|
|
2361
|
+
* deposits.
|
|
2362
|
+
*/
|
|
2363
|
+
private assertQuoteMatchesAmount;
|
|
2364
|
+
/**
|
|
2365
|
+
* Resolves the wallet's associated token account for a spot market, plus the instruction that
|
|
2366
|
+
* creates it when it doesn't exist yet.
|
|
2367
|
+
*/
|
|
2368
|
+
private getOrCreateSwapTokenAccount;
|
|
2369
|
+
/**
|
|
2370
|
+
* Builds the instruction list for a swap routed through any `SwapProvider` (Jupiter, Titan, or
|
|
2371
|
+
* a `UnifiedSwapClient` wrapping either): creates any missing associated token accounts and
|
|
2372
|
+
* wraps the provider's routing instructions between `beginSwap`/`endSwap`.
|
|
2373
|
+
* @param swapProvider - Provider that quotes the swap and builds its route instructions.
|
|
2374
|
+
* @param outMarketIndex - Spot market index of the token being bought.
|
|
2375
|
+
* @param inMarketIndex - Spot market index of the token being sold.
|
|
2376
|
+
* @param outAssociatedTokenAccount - Token account to receive the bought token; created
|
|
2377
|
+
* idempotently if omitted.
|
|
2378
|
+
* @param inAssociatedTokenAccount - Token account to source the sold token from; created
|
|
2379
|
+
* idempotently if omitted.
|
|
2380
|
+
* @param amount - Amount in the "in" token's mint decimals, or the "out" token's when the
|
|
2381
|
+
* effective mode is `ExactOut`.
|
|
2382
|
+
* @param slippageBps - Max slippage in basis points; only used when a quote has to be fetched.
|
|
2383
|
+
* @param swapMode - `ExactIn` (default) or `ExactOut`. The mode a quote is fetched at; the
|
|
2384
|
+
* resulting quote's own mode is what sizes the swap, so it is ignored when `quote` is passed.
|
|
2385
|
+
* @param onlyDirectRoutes - Restricts a fetched quote to single-hop routes.
|
|
2386
|
+
* @param maxAccounts - Account budget for a fetched route.
|
|
2387
|
+
* @param reduceOnly - Which side must not increase in magnitude; enforced by `endSwap`.
|
|
2388
|
+
* @param quote - Pre-fetched quote. Authoritative when passed: its `swapMode` is the effective
|
|
2389
|
+
* mode, and it must be for this pair and this `amount`.
|
|
2381
2390
|
* @param userAccountPublicKey - Optional user account override (e.g. when the account is being
|
|
2382
|
-
* created in the same transaction).
|
|
2383
|
-
* @throws If
|
|
2384
|
-
*
|
|
2385
|
-
* `
|
|
2391
|
+
* created in the same transaction and not yet resolvable via `getUserAccountPublicKey`).
|
|
2392
|
+
* @throws If the quote — passed in or freshly fetched — is for a different pair or a different
|
|
2393
|
+
* size than the swap being built.
|
|
2394
|
+
* @returns `ixs` — ATA creation, `beginSwap`, the route's instructions, `endSwap`, in order —
|
|
2395
|
+
* and the `lookupTables` needed to fit them in a versioned transaction.
|
|
2386
2396
|
*/
|
|
2387
|
-
|
|
2388
|
-
|
|
2397
|
+
getProviderSwapIx({ swapProvider, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, maxAccounts, reduceOnly, quote, userAccountPublicKey, }: {
|
|
2398
|
+
swapProvider: SwapProvider;
|
|
2389
2399
|
outMarketIndex: number;
|
|
2390
2400
|
inMarketIndex: number;
|
|
2391
2401
|
outAssociatedTokenAccount?: PublicKey;
|
|
@@ -2394,8 +2404,9 @@ export declare class VelocityClient {
|
|
|
2394
2404
|
slippageBps?: number;
|
|
2395
2405
|
swapMode?: SwapMode;
|
|
2396
2406
|
onlyDirectRoutes?: boolean;
|
|
2397
|
-
|
|
2407
|
+
maxAccounts?: number;
|
|
2398
2408
|
reduceOnly?: SwapReduceOnly;
|
|
2409
|
+
quote?: SwapQuote;
|
|
2399
2410
|
userAccountPublicKey?: PublicKey;
|
|
2400
2411
|
}): Promise<{
|
|
2401
2412
|
ixs: TransactionInstruction[];
|
|
@@ -2435,37 +2446,6 @@ export declare class VelocityClient {
|
|
|
2435
2446
|
beginSwapIx: TransactionInstruction;
|
|
2436
2447
|
endSwapIx: TransactionInstruction;
|
|
2437
2448
|
}>;
|
|
2438
|
-
/**
|
|
2439
|
-
* Builds the instruction list for a swap routed through a `UnifiedSwapClient` (the current
|
|
2440
|
-
* preferred swap path). Creates any missing associated token accounts and wraps the client's
|
|
2441
|
-
* routing instructions between `beginSwap`/`endSwap`. See `swap` for parameter semantics;
|
|
2442
|
-
* `amount` is in the "in" token's mint decimals (or "out" token's decimals when `swapMode` is
|
|
2443
|
-
* `ExactOut`).
|
|
2444
|
-
* @param userAccountPublicKey - Optional user account override (e.g. when the account is being
|
|
2445
|
-
* created in the same transaction).
|
|
2446
|
-
* @returns `ixs` — instruction list (ATA creation, `beginSwap`, routed swap instructions,
|
|
2447
|
-
* `endSwap`, in order) and `lookupTables` needed to fit it in a versioned transaction.
|
|
2448
|
-
*/
|
|
2449
|
-
getSwapIxV2({ swapClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, reduceOnly, quote, v6, userAccountPublicKey, }: {
|
|
2450
|
-
swapClient: UnifiedSwapClient;
|
|
2451
|
-
outMarketIndex: number;
|
|
2452
|
-
inMarketIndex: number;
|
|
2453
|
-
outAssociatedTokenAccount?: PublicKey;
|
|
2454
|
-
inAssociatedTokenAccount?: PublicKey;
|
|
2455
|
-
amount: BN;
|
|
2456
|
-
slippageBps?: number;
|
|
2457
|
-
swapMode?: SwapMode;
|
|
2458
|
-
onlyDirectRoutes?: boolean;
|
|
2459
|
-
reduceOnly?: SwapReduceOnly;
|
|
2460
|
-
quote?: UnifiedQuoteResponse;
|
|
2461
|
-
v6?: {
|
|
2462
|
-
quote?: QuoteResponse;
|
|
2463
|
-
};
|
|
2464
|
-
userAccountPublicKey?: PublicKey;
|
|
2465
|
-
}): Promise<{
|
|
2466
|
-
ixs: TransactionInstruction[];
|
|
2467
|
-
lookupTables: AddressLookupTableAccount[];
|
|
2468
|
-
}>;
|
|
2469
2449
|
/**
|
|
2470
2450
|
* Converts a portion of the user's deposited wSOL (spot market index 1) into mSOL (spot market
|
|
2471
2451
|
* index 2) by staking it with Marinade Finance, then swapping the resulting mSOL back into the
|
|
@@ -2534,11 +2514,12 @@ export declare class VelocityClient {
|
|
|
2534
2514
|
getForceCancelOrdersIx(userAccountPublicKey: PublicKey, userAccount: UserAccount, fillerPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
2535
2515
|
/**
|
|
2536
2516
|
* Keeper instruction: trips the authority-wide equity floor breaker. Proves on-chain that the
|
|
2537
|
-
* given subaccount's
|
|
2538
|
-
* `SufficientCollateral` otherwise,
|
|
2539
|
-
*
|
|
2540
|
-
*
|
|
2541
|
-
*
|
|
2517
|
+
* given subaccount's net equity (unweighted assets and perp PnL minus spot liabilities) is below
|
|
2518
|
+
* its `equityFloor` (reverts with `SufficientCollateral` otherwise, if no floor is set, or with
|
|
2519
|
+
* `InvalidOracle` if any of the subaccount's oracles is invalid) and sets `equityBreakerTripped`
|
|
2520
|
+
* on the authority's `UserStats` — every subaccount of the authority then rejects risk-increasing
|
|
2521
|
+
* fills, withdrawals and transfers out until the warm admin calls `resetEquityFloorBreaker`.
|
|
2522
|
+
* Permissionless — any signer may trip it; the equity calculation is the proof.
|
|
2542
2523
|
* @param userAccountPublicKey - Public key of the breached subaccount's user account.
|
|
2543
2524
|
* @param user - Decoded user account of the breached subaccount.
|
|
2544
2525
|
* @param txParams - Optional compute-unit/priority-fee overrides.
|
|
@@ -3326,7 +3307,8 @@ export declare class VelocityClient {
|
|
|
3326
3307
|
* @param userAccountPublicKey - Public key of the user account being liquidated.
|
|
3327
3308
|
* @param liquidatorSubAccountId - Liquidator's sub-account to credit; defaults to the active sub-account.
|
|
3328
3309
|
* @param maxAccounts - Caps the number of accounts Jupiter's route may use.
|
|
3329
|
-
* @throws If no quote can be fetched and `quote` was not supplied
|
|
3310
|
+
* @throws If no quote can be fetched and `quote` was not supplied, or if the quote — passed in or
|
|
3311
|
+
* freshly fetched — is for a different pair or a different size than the swap being built.
|
|
3330
3312
|
* @returns The ordered instructions (pre-instructions, `beginSwap`, Jupiter swap, `endSwap`) and
|
|
3331
3313
|
* any address lookup tables the Jupiter route requires.
|
|
3332
3314
|
*/
|
|
@@ -3340,7 +3322,7 @@ export declare class VelocityClient {
|
|
|
3340
3322
|
slippageBps?: number;
|
|
3341
3323
|
swapMode?: SwapMode;
|
|
3342
3324
|
onlyDirectRoutes?: boolean;
|
|
3343
|
-
quote?:
|
|
3325
|
+
quote?: JupiterSwapQuote;
|
|
3344
3326
|
userAccount: UserAccount;
|
|
3345
3327
|
userAccountPublicKey: PublicKey;
|
|
3346
3328
|
liquidatorSubAccountId?: number;
|