@velocity-exchange/sdk 0.2.0 → 0.2.2
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/CHANGELOG.md +7 -44
- package/lib/browser/adminClient.d.ts +0 -1
- package/lib/browser/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/browser/bankrun/bankrunConnection.js +23 -1
- package/lib/browser/constants/numericConstants.d.ts +2 -1
- package/lib/browser/constants/numericConstants.js +8 -4
- package/lib/browser/constants/spotMarkets.d.ts +0 -1
- package/lib/browser/core/VelocityCore.d.ts +0 -1
- package/lib/browser/core/instructions/deposit.d.ts +0 -1
- package/lib/browser/core/instructions/withdraw.d.ts +0 -1
- package/lib/browser/dlob/DLOB.d.ts +0 -1
- package/lib/browser/dlob/DLOBNode.d.ts +0 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/browser/dlob/NodeList.d.ts +0 -1
- package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
- package/lib/browser/events/eventList.d.ts +3 -3
- package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
- package/lib/browser/events/pollingLogProvider.d.ts +1 -1
- package/lib/browser/events/txEventCache.d.ts +3 -3
- package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
- package/lib/browser/factory/bigNum.d.ts +0 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/browser/jupiter/jupiterClient.d.ts +0 -1
- package/lib/browser/marginCalculation.d.ts +0 -1
- package/lib/browser/marinade/index.d.ts +2 -3
- package/lib/browser/marinade/index.js +5 -0
- package/lib/browser/math/amm.d.ts +0 -1
- package/lib/browser/math/auction.d.ts +0 -1
- package/lib/browser/math/conversion.d.ts +0 -1
- package/lib/browser/math/funding.d.ts +0 -1
- package/lib/browser/math/insurance.d.ts +0 -1
- package/lib/browser/math/liquidation.d.ts +0 -1
- package/lib/browser/math/margin.d.ts +0 -1
- package/lib/browser/math/market.d.ts +0 -1
- package/lib/browser/math/oracles.d.ts +0 -1
- package/lib/browser/math/orders.d.ts +0 -1
- package/lib/browser/math/position.d.ts +1 -2
- package/lib/browser/math/repeg.d.ts +0 -1
- package/lib/browser/math/spotBalance.d.ts +0 -1
- package/lib/browser/math/spotMarket.d.ts +0 -1
- package/lib/browser/math/spotPosition.d.ts +0 -1
- package/lib/browser/math/state.d.ts +0 -1
- package/lib/browser/math/superStake.d.ts +0 -1
- package/lib/browser/math/trade.d.ts +2 -3
- package/lib/browser/math/utils.d.ts +0 -1
- package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
- package/lib/browser/oracles/pythClient.d.ts +0 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
- package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/browser/oracles/types.d.ts +0 -1
- package/lib/browser/oracles/utils.d.ts +0 -1
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/browser/titan/titanClient.d.ts +0 -1
- package/lib/browser/tokenFaucet.d.ts +0 -1
- package/lib/browser/tx/txHandler.d.ts +2 -2
- package/lib/browser/types.d.ts +2 -3
- package/lib/browser/user.d.ts +0 -1
- package/lib/browser/velocityClient.d.ts +1 -2
- package/lib/node/adminClient.d.ts +0 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +23 -1
- package/lib/node/constants/numericConstants.d.ts +2 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +8 -4
- package/lib/node/constants/spotMarkets.d.ts +0 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.d.ts +0 -1
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.d.ts +0 -1
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.d.ts +0 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.d.ts +0 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.d.ts +0 -1
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.d.ts +0 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts +0 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/factory/bigNum.d.ts +0 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts +0 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/marginCalculation.d.ts +0 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marinade/index.d.ts +2 -3
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +5 -0
- package/lib/node/math/amm.d.ts +0 -1
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/auction.d.ts +0 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/conversion.d.ts +0 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +0 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/insurance.d.ts +0 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/liquidation.d.ts +0 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/margin.d.ts +0 -1
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/market.d.ts +0 -1
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/oracles.d.ts +0 -1
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/orders.d.ts +0 -1
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/position.d.ts +0 -1
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/repeg.d.ts +0 -1
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/spotBalance.d.ts +0 -1
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotMarket.d.ts +0 -1
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotPosition.d.ts +0 -1
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -1
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/superStake.d.ts +0 -1
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/trade.d.ts +0 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/utils.d.ts +0 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.d.ts +0 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts +0 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/types.d.ts +0 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +0 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.d.ts +0 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +0 -1
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/types.d.ts +0 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +0 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/velocityClient.d.ts +0 -1
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/package.json +16 -11
- package/src/bankrun/bankrunConnection.ts +27 -1
- package/src/constants/numericConstants.ts +6 -2
- package/src/index.ts +5 -1
- package/src/marinade/index.ts +11 -2
- package/src/userMap/referrerMap.ts +1 -1
- package/src/userMap/revenueShareEscrowMap.ts +2 -2
- package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
- package/tests/amm/test.ts +162 -95
- package/tests/decode/userAccountBufferStrings.ts +100 -100
- package/tests/dlob/helpers.ts +156 -172
- package/tests/dlob/test.ts +155 -106
- package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
- package/tests/user/getMarginCalculation.ts +1 -1
- package/tests/user/helpers.ts +3 -4
- package/tests/user/marginCalculations.test.ts +2 -2
- package/tests/user/test.ts +3 -3
- package/tsconfig.browser.json +3 -1
- package/tsconfig.json +20 -2
- package/.yarn/install-state.gz +0 -0
- package/VERSION +0 -1
- package/bun.lock +0 -1907
- package/scripts/updateVersion.js +0 -28
- package/tests/decode/phoenix.ts +0 -71
package/CHANGELOG.md
CHANGED
|
@@ -1,50 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @velocity-exchange/sdk
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.2.2
|
|
4
4
|
|
|
5
|
+
### Patch Changes
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
- [#97](https://github.com/drift-labs/protocol-v2-shadow/pull/97) [`022a949`](https://github.com/drift-labs/protocol-v2-shadow/commit/022a949cb1802171ca57a61260f86c8908f94f34) Thanks [@ChewingGlass](https://github.com/ChewingGlass)! - Re-export `PriceUpdateAccount` from the package root and declare `@types/node` as a devDependency (fixes the SDK build under isolated installs). Enables downstream apps (dlob-server, keeper-bots-v2) to consume the velocity SDK without reaching into subpaths.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
* funding bias spread multiplier ([d7eb00c](https://github.com/drift-labs/protocol-v2-shadow/commit/d7eb00caa82b351f515b65dc4a7315a969059d91))
|
|
10
|
-
* withdraw guard threshold to have a notional limit ([be33e8e](https://github.com/drift-labs/protocol-v2-shadow/commit/be33e8ed48cc319846d0896e435ed61050fc6a86))
|
|
9
|
+
## 0.2.1
|
|
11
10
|
|
|
11
|
+
### Patch Changes
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* enable strict mode in SDK and fix initial strict errors ([#74](https://github.com/drift-labs/protocol-v2-shadow/issues/74)) ([5e045d8](https://github.com/drift-labs/protocol-v2-shadow/commit/5e045d8a7ca3a599420d3583975ddaab610a780e))
|
|
16
|
-
* fix remaining strict errors and enable strict mode in SDK ([#78](https://github.com/drift-labs/protocol-v2-shadow/issues/78)) ([1fb7c07](https://github.com/drift-labs/protocol-v2-shadow/commit/1fb7c07ad95b696ecd09605358d86df3ef5d1102))
|
|
17
|
-
|
|
18
|
-
## [0.1.0](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.5...sdk-v0.1.0) (2026-06-11)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
### Features
|
|
22
|
-
|
|
23
|
-
* add builder codes on non swift ([#68](https://github.com/drift-labs/protocol-v2-shadow/issues/68)) ([2df4034](https://github.com/drift-labs/protocol-v2-shadow/commit/2df4034b2162f0df060b21453a16566f9de24f4f))
|
|
24
|
-
* add transfer deposit by delegate ([16386ca](https://github.com/drift-labs/protocol-v2-shadow/commit/16386cad98a2a48d9a8a249ff75c9ce646e9fcac))
|
|
25
|
-
* decouple AMM from rest of codebase ([84aba6d](https://github.com/drift-labs/protocol-v2-shadow/commit/84aba6d0c17ef97069185d82b74671bde6619919))
|
|
26
|
-
* rebrand drift to velocity ([9c330b1](https://github.com/drift-labs/protocol-v2-shadow/commit/9c330b17cda7170482cc8b75ad3d1b3c137a8d32))
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
### Bug Fixes
|
|
30
|
-
|
|
31
|
-
* resolve eslint unused-var and prettier formatting failures ([a3a1e3e](https://github.com/drift-labs/protocol-v2-shadow/commit/a3a1e3e1cbf68f35a7c39ea335927d0136c5bce1))
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
### Refactors
|
|
35
|
-
|
|
36
|
-
* gather vAMM and hedge into a single VLP module ([905edc3](https://github.com/drift-labs/protocol-v2-shadow/commit/905edc338b453a1ce0ebb4dd9a13be97c66aa66d))
|
|
37
|
-
|
|
38
|
-
## [0.0.5](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.4...sdk-v0.0.5) (2026-05-28)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Refactors
|
|
42
|
-
|
|
43
|
-
* increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
|
|
44
|
-
|
|
45
|
-
## [0.0.4](https://github.com/drift-labs/protocol-v2-shadow/compare/sdk-v0.0.3...sdk-v0.0.4) (2026-05-28)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Refactors
|
|
49
|
-
|
|
50
|
-
* increase oracle_price_offset to i64 ([#51](https://github.com/drift-labs/protocol-v2-shadow/issues/51)) ([d04039a](https://github.com/drift-labs/protocol-v2-shadow/commit/d04039a22b2ff37d05afd8fe271b9913d66689e1))
|
|
13
|
+
- [`4fd7462`](https://github.com/drift-labs/protocol-v2-shadow/commit/4fd7462bfa3c55e31e3457b1b65f519cf052a6fa) Thanks [@ChewingGlass](https://github.com/ChewingGlass)! - Testing new changelog based package publishing flow
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="bn.js" />
|
|
4
3
|
import { AccountInfo, Keypair, PublicKey, Transaction, RpcResponseAndContext, Commitment, TransactionSignature, SignatureStatusConfig, SignatureStatus, GetVersionedTransactionConfig, GetTransactionConfig, VersionedTransaction, SimulateTransactionConfig, SimulatedTransactionResponse, TransactionError, SignatureResultCallback, Connection as SolanaConnection, Blockhash, LogsFilter, LogsCallback, AccountChangeCallback, AddressLookupTableAccount } from '@solana/web3.js';
|
|
5
4
|
import { ProgramTestContext, BanksClient } from 'solana-bankrun';
|
|
6
5
|
import { BankrunProvider } from 'anchor-bankrun';
|
|
@@ -44,6 +43,8 @@ export declare class BankrunConnection {
|
|
|
44
43
|
getSlot(): Promise<bigint>;
|
|
45
44
|
toConnection(): SolanaConnection;
|
|
46
45
|
getTokenAccount(publicKey: PublicKey): Promise<Account>;
|
|
46
|
+
getTokenAccountBalance(publicKey: PublicKey, _commitment?: Commitment): Promise<Account>;
|
|
47
|
+
getBalance(publicKey: PublicKey): Promise<bigint>;
|
|
47
48
|
getMultipleAccountsInfo(publicKeys: PublicKey[], _commitmentOrConfig?: Commitment): Promise<(AccountInfo<Buffer> | null)[]>;
|
|
48
49
|
getAccountInfo(publicKey: PublicKey): Promise<null | AccountInfo<Buffer>>;
|
|
49
50
|
getAccountInfoAndContext(publicKey: PublicKey, _commitment?: Commitment): Promise<RpcResponseAndContext<null | AccountInfo<Buffer>>>;
|
|
@@ -106,6 +106,17 @@ class BankrunConnection {
|
|
|
106
106
|
}
|
|
107
107
|
return (0, spl_token_1.unpackAccount)(publicKey, info, info.owner);
|
|
108
108
|
}
|
|
109
|
+
// Mirrors the drift-vaults bankrun helper: returns the decoded SPL token
|
|
110
|
+
// Account (with .amount), not web3.js's { value: { amount } } shape. The
|
|
111
|
+
// vaults tests read `.amount` off the result directly.
|
|
112
|
+
async getTokenAccountBalance(publicKey, _commitment) {
|
|
113
|
+
return this.getTokenAccount(publicKey);
|
|
114
|
+
}
|
|
115
|
+
// SOL lamport balance, straight off the BanksClient. Returns a bigint like
|
|
116
|
+
// the drift-vaults bankrun helper (callers wrap with Number()).
|
|
117
|
+
async getBalance(publicKey) {
|
|
118
|
+
return this._banksClient.getBalance(publicKey);
|
|
119
|
+
}
|
|
109
120
|
async getMultipleAccountsInfo(publicKeys, _commitmentOrConfig) {
|
|
110
121
|
const accountInfos = [];
|
|
111
122
|
for (const publicKey of publicKeys) {
|
|
@@ -124,7 +135,18 @@ class BankrunConnection {
|
|
|
124
135
|
async sendRawTransaction(rawTransaction,
|
|
125
136
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
126
137
|
_options) {
|
|
127
|
-
|
|
138
|
+
// Raw bytes may encode either a legacy or a versioned (v0) transaction.
|
|
139
|
+
// sendTransaction handles both, but they must be deserialized with the
|
|
140
|
+
// matching type: legacy parses with Transaction.from, versioned needs
|
|
141
|
+
// VersionedTransaction.deserialize. Versioned-tx clients (e.g. the vaults
|
|
142
|
+
// VaultClient) always send v0, so fall back when the legacy parse throws.
|
|
143
|
+
let tx;
|
|
144
|
+
try {
|
|
145
|
+
tx = web3_js_1.Transaction.from(rawTransaction);
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
tx = web3_js_1.VersionedTransaction.deserialize(rawTransaction);
|
|
149
|
+
}
|
|
128
150
|
const signature = await this.sendTransaction(tx);
|
|
129
151
|
return signature;
|
|
130
152
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { BN } from '../isomorphic/anchor';
|
|
3
2
|
export declare const ZERO: BN;
|
|
4
3
|
export declare const ONE: BN;
|
|
@@ -13,6 +12,7 @@ export declare const NINE: BN;
|
|
|
13
12
|
export declare const TEN: BN;
|
|
14
13
|
export declare const TEN_THOUSAND: BN;
|
|
15
14
|
export declare const BN_MAX: BN;
|
|
15
|
+
export declare const TEN_MILLION: BN;
|
|
16
16
|
export declare const MAX_LEVERAGE: BN;
|
|
17
17
|
export declare const MAX_LEVERAGE_ORDER_SIZE: BN;
|
|
18
18
|
export declare const PERCENTAGE_PRECISION_EXP: BN;
|
|
@@ -68,4 +68,5 @@ export declare const IDLE_TIME_SLOTS = 9000;
|
|
|
68
68
|
export declare const SLOT_TIME_ESTIMATE_MS = 400;
|
|
69
69
|
export declare const DUST_POSITION_SIZE: BN;
|
|
70
70
|
export declare const GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
71
|
+
export declare const MAX_I64: BN;
|
|
71
72
|
export declare const MIN_I64: BN;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.MIN_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_CLAMP_DENOMINATOR = exports.FUNDING_RATE_OFFSET_PERCENTAGE = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = void 0;
|
|
3
|
+
exports.MARGIN_PRECISION = exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_DIV_PEG = exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.BASE_PRECISION_EXP = exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION = exports.PEG_PRECISION = exports.FUNDING_RATE_BUFFER_PRECISION = exports.FUNDING_RATE_PRECISION = exports.PRICE_PRECISION = exports.QUOTE_PRECISION = exports.LIQUIDATION_FEE_PRECISION = exports.SPOT_MARKET_IMF_PRECISION = exports.SPOT_MARKET_IMF_PRECISION_EXP = exports.SPOT_MARKET_BALANCE_PRECISION = exports.SPOT_MARKET_BALANCE_PRECISION_EXP = exports.SPOT_MARKET_WEIGHT_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION_EXP = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP = exports.PEG_PRECISION_EXP = exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP = exports.FUNDING_RATE_BUFFER_PRECISION_EXP = exports.QUOTE_PRECISION_EXP = exports.CONCENTRATION_PRECISION = exports.PERCENTAGE_PRECISION = exports.PERCENTAGE_PRECISION_EXP = exports.MAX_LEVERAGE_ORDER_SIZE = exports.MAX_LEVERAGE = exports.TEN_MILLION = exports.BN_MAX = exports.TEN_THOUSAND = exports.TEN = exports.NINE = exports.EIGHT = exports.SEVEN = exports.SIX = exports.FIVE = exports.FOUR = exports.THREE = exports.TWO = exports.ONE = exports.ZERO = void 0;
|
|
4
|
+
exports.MIN_I64 = exports.MAX_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_CLAMP_DENOMINATOR = exports.FUNDING_RATE_OFFSET_PERCENTAGE = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = void 0;
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const anchor_1 = require("../isomorphic/anchor");
|
|
7
|
-
const bigNum_1 = require("../factory/bigNum");
|
|
8
7
|
exports.ZERO = new anchor_1.BN(0);
|
|
9
8
|
exports.ONE = new anchor_1.BN(1);
|
|
10
9
|
exports.TWO = new anchor_1.BN(2);
|
|
@@ -18,6 +17,7 @@ exports.NINE = new anchor_1.BN(9);
|
|
|
18
17
|
exports.TEN = new anchor_1.BN(10);
|
|
19
18
|
exports.TEN_THOUSAND = new anchor_1.BN(10000);
|
|
20
19
|
exports.BN_MAX = new anchor_1.BN(Number.MAX_SAFE_INTEGER);
|
|
20
|
+
exports.TEN_MILLION = exports.TEN_THOUSAND.mul(exports.TEN_THOUSAND);
|
|
21
21
|
exports.MAX_LEVERAGE = new anchor_1.BN(5);
|
|
22
22
|
exports.MAX_LEVERAGE_ORDER_SIZE = new anchor_1.BN('18446744073709551615');
|
|
23
23
|
exports.PERCENTAGE_PRECISION_EXP = new anchor_1.BN(6);
|
|
@@ -74,4 +74,8 @@ exports.SLOT_TIME_ESTIMATE_MS = 400;
|
|
|
74
74
|
exports.DUST_POSITION_SIZE = exports.QUOTE_PRECISION.divn(100); // Dust position is any position smaller than 1c
|
|
75
75
|
exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
76
76
|
// integer constants
|
|
77
|
-
|
|
77
|
+
// Built with `BN` directly (not `BigNum.fromPrint`) to avoid a module-load
|
|
78
|
+
// circular dependency: `bigNum.ts` imports `ZERO` from this file, so importing
|
|
79
|
+
// `bigNum.ts` first leaves `BigNum` undefined while this module body evaluates.
|
|
80
|
+
exports.MAX_I64 = new anchor_1.BN('9223372036854775807');
|
|
81
|
+
exports.MIN_I64 = new anchor_1.BN('-9223372036854775808');
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
/// <reference types="bn.js" />
|
|
4
3
|
import type { AccountMeta, Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
5
4
|
import * as pdas from '../addresses/pda';
|
|
6
5
|
import * as constants from '../constants';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EventType, EventMap, EventSubscriptionOrderDirection, SortFn } from './types';
|
|
2
2
|
declare class Node<Type extends EventType, Event extends EventMap[Type]> {
|
|
3
3
|
event: Event;
|
|
4
|
-
next?: Node<Type, Event
|
|
5
|
-
prev?: Node<Type, Event
|
|
6
|
-
constructor(event: Event, next?: Node<Type, Event
|
|
4
|
+
next?: Node<Type, Event> | undefined;
|
|
5
|
+
prev?: Node<Type, Event> | undefined;
|
|
6
|
+
constructor(event: Event, next?: Node<Type, Event> | undefined, prev?: Node<Type, Event> | undefined);
|
|
7
7
|
}
|
|
8
8
|
export declare class EventList<Type extends EventType> {
|
|
9
9
|
eventType: Type;
|
|
@@ -13,7 +13,7 @@ export declare class EventsServerLogProvider implements LogProvider {
|
|
|
13
13
|
private timeoutId?;
|
|
14
14
|
private reconnectAttempts;
|
|
15
15
|
eventEmitter: EventEmitter;
|
|
16
|
-
constructor(url: string, eventTypes: EventType[], userAccount?: string);
|
|
16
|
+
constructor(url: string, eventTypes: EventType[], userAccount?: string | undefined);
|
|
17
17
|
isSubscribed(): boolean;
|
|
18
18
|
subscribe(callback: logProviderCallback): Promise<boolean>;
|
|
19
19
|
unsubscribe(external?: boolean): Promise<boolean>;
|
|
@@ -10,7 +10,7 @@ export declare class PollingLogProvider implements LogProvider {
|
|
|
10
10
|
private mostRecentSeenTx?;
|
|
11
11
|
private mutex;
|
|
12
12
|
private firstFetch;
|
|
13
|
-
constructor(connection: Connection, address: PublicKey, commitment: Commitment, frequency?: number, batchSize?: number);
|
|
13
|
+
constructor(connection: Connection, address: PublicKey, commitment: Commitment, frequency?: number, batchSize?: number | undefined);
|
|
14
14
|
subscribe(callback: logProviderCallback, skipHistory?: boolean): Promise<boolean>;
|
|
15
15
|
isSubscribed(): boolean;
|
|
16
16
|
unsubscribe(): Promise<boolean>;
|
|
@@ -2,9 +2,9 @@ import { WrappedEvent, EventType } from './types';
|
|
|
2
2
|
declare class Node {
|
|
3
3
|
key: string;
|
|
4
4
|
value: WrappedEvent<EventType>[];
|
|
5
|
-
next?: Node;
|
|
6
|
-
prev?: Node;
|
|
7
|
-
constructor(key: string, value: WrappedEvent<EventType>[], next?: Node, prev?: Node);
|
|
5
|
+
next?: Node | undefined;
|
|
6
|
+
prev?: Node | undefined;
|
|
7
|
+
constructor(key: string, value: WrappedEvent<EventType>[], next?: Node | undefined, prev?: Node | undefined);
|
|
8
8
|
}
|
|
9
9
|
export declare class TxEventCache {
|
|
10
10
|
maxTx: number;
|
|
@@ -15,7 +15,7 @@ export declare class WebSocketLogProvider implements LogProvider {
|
|
|
15
15
|
private reconnectAttempts;
|
|
16
16
|
eventEmitter?: EventEmitter;
|
|
17
17
|
private callback?;
|
|
18
|
-
constructor(connection: Connection, address: PublicKey, commitment: Commitment, resubTimeoutMs?: number);
|
|
18
|
+
constructor(connection: Connection, address: PublicKey, commitment: Commitment, resubTimeoutMs?: number | undefined);
|
|
19
19
|
subscribe(callback: logProviderCallback): Promise<boolean>;
|
|
20
20
|
setSubscription(callback: logProviderCallback): void;
|
|
21
21
|
isSubscribed(): boolean;
|
package/lib/browser/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export * from './accounts/types';
|
|
|
43
43
|
export * from './addresses/pda';
|
|
44
44
|
export * from './adminClient';
|
|
45
45
|
export * from './assert/assert';
|
|
46
|
-
export { PythLazerSubscriber, type PythLazerPriceFeedArray } from './pyth';
|
|
46
|
+
export { PythLazerSubscriber, type PythLazerPriceFeedArray, type PriceUpdateAccount, } from './pyth';
|
|
47
47
|
export * from './testClient';
|
|
48
48
|
export * from './user';
|
|
49
49
|
export * from './userConfig';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { AddressLookupTableAccount, Connection, PublicKey, TransactionInstruction, TransactionMessage, VersionedTransaction } from '@solana/web3.js';
|
|
3
2
|
import { BN } from '../isomorphic/anchor';
|
|
4
3
|
import { SwapMode } from '../swap/UnifiedSwapClient';
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { AnchorProvider, BN, Program } from '../isomorphic/anchor29';
|
|
1
|
+
import { BN, Program } from '../isomorphic/anchor29';
|
|
3
2
|
import { MarinadeFinance } from './types';
|
|
4
3
|
import { PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
5
|
-
export declare function getMarinadeFinanceProgram(provider:
|
|
4
|
+
export declare function getMarinadeFinanceProgram(provider: unknown): Program<MarinadeFinance>;
|
|
6
5
|
export declare function getMarinadeDepositIx({ program, amount, mSOLAccount, transferFrom, }: {
|
|
7
6
|
amount: BN;
|
|
8
7
|
mSOLAccount: PublicKey;
|
|
@@ -6,6 +6,11 @@ const types_1 = require("./types");
|
|
|
6
6
|
const web3_js_1 = require("@solana/web3.js");
|
|
7
7
|
const spl_token_1 = require("@solana/spl-token");
|
|
8
8
|
const marinadeFinanceProgramId = new web3_js_1.PublicKey('MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD');
|
|
9
|
+
// The Marinade SDK is built against anchor 0.29 (3-arg `new Program`), so the
|
|
10
|
+
// provider is typed against the anchor29 shim. Callers hold an anchor 1.0
|
|
11
|
+
// AnchorProvider, which is runtime-compatible but nominally distinct — accept it
|
|
12
|
+
// loosely and narrow at the construction boundary rather than leaking the cast to
|
|
13
|
+
// every call site.
|
|
9
14
|
function getMarinadeFinanceProgram(provider) {
|
|
10
15
|
return new anchor29_1.Program(types_1.IDL, marinadeFinanceProgramId, provider);
|
|
11
16
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { BN } from '../isomorphic/anchor';
|
|
3
2
|
export declare function calculateBaseAssetAmountToCoverMarginShortage(marginShortage: BN, marginRatio: number, liquidationFee: number, ifLiquidationFee: number, oraclePrice: BN, quoteOraclePrice: BN): BN | undefined;
|
|
4
3
|
export declare function calculateLiabilityTransferToCoverMarginShortage(marginShortage: BN, assetWeight: number, assetLiquidationMultiplier: number, liabilityWeight: number, liabilityLiquidationMultiplier: number, liabilityDecimals: number, liabilityPrice: BN, ifLiquidationFee: number): BN | undefined;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { BN } from '../isomorphic/anchor';
|
|
3
2
|
import { MMOraclePriceData, OraclePriceData } from '../oracles/types';
|
|
4
3
|
import { PerpMarketAccount, PositionDirection, PerpPosition, SpotMarketAccount } from '../types';
|
|
@@ -20,7 +19,7 @@ export declare function calculateBaseAssetValue(market: PerpMarketAccount, userP
|
|
|
20
19
|
* @param oraclePriceData
|
|
21
20
|
* @returns BaseAssetAmount : Precision QUOTE_PRECISION
|
|
22
21
|
*/
|
|
23
|
-
export declare function calculatePositionPNL(market: PerpMarketAccount, perpPosition: PerpPosition, withFunding: boolean, oraclePriceData: Pick<OraclePriceData, 'price'>): BN;
|
|
22
|
+
export declare function calculatePositionPNL(market: PerpMarketAccount, perpPosition: PerpPosition, withFunding: boolean | undefined, oraclePriceData: Pick<OraclePriceData, 'price'>): BN;
|
|
24
23
|
export declare function calculateClaimablePnl(market: PerpMarketAccount, spotMarket: SpotMarketAccount, perpPosition: PerpPosition, oraclePriceData: Pick<OraclePriceData, 'price'>): BN;
|
|
25
24
|
/**
|
|
26
25
|
* Returns total fees and funding pnl for a position
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { PerpMarketAccount, PositionDirection, UserStatsAccount } from '../types';
|
|
3
2
|
import { BN } from '../isomorphic/anchor';
|
|
4
3
|
import { AssetType } from './amm';
|
|
@@ -27,7 +26,7 @@ export type PriceImpactUnit = 'entryPrice' | 'maxPrice' | 'priceDelta' | 'priceD
|
|
|
27
26
|
*
|
|
28
27
|
* 'newPrice' => the price of the asset after the trade : Precision PRICE_PRECISION
|
|
29
28
|
*/
|
|
30
|
-
export declare function calculateTradeSlippage(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN, BN];
|
|
29
|
+
export declare function calculateTradeSlippage(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType | undefined, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN, BN];
|
|
31
30
|
/**
|
|
32
31
|
* Calculates acquired amounts for trade executed
|
|
33
32
|
* @param direction
|
|
@@ -39,7 +38,7 @@ export declare function calculateTradeSlippage(direction: PositionDirection, amo
|
|
|
39
38
|
* | 'acquiredBase' => positive/negative change in user's base : BN AMM_RESERVE_PRECISION
|
|
40
39
|
* | 'acquiredQuote' => positive/negative change in user's quote : BN TODO-PRECISION
|
|
41
40
|
*/
|
|
42
|
-
export declare function calculateTradeAcquiredAmounts(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN];
|
|
41
|
+
export declare function calculateTradeAcquiredAmounts(direction: PositionDirection, amount: BN, market: PerpMarketAccount, inputAssetType: AssetType | undefined, mmOraclePriceData: MMOraclePriceData, useSpread?: boolean, latestSlot?: BN): [BN, BN, BN];
|
|
43
42
|
/**
|
|
44
43
|
* calculateTargetPriceTrade
|
|
45
44
|
* simple function for finding arbitraging trades
|
|
@@ -5,5 +5,5 @@ import { VelocityProgram } from '../config';
|
|
|
5
5
|
export declare class OracleClientCache {
|
|
6
6
|
cache: Map<string, OracleClient>;
|
|
7
7
|
constructor();
|
|
8
|
-
get(oracleSource: OracleSource, connection: Connection, program: VelocityProgram): OracleClient;
|
|
8
|
+
get(oracleSource: OracleSource, connection: Connection, program: VelocityProgram): OracleClient | undefined;
|
|
9
9
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
import { Connection, PublicKey, TransactionMessage, AddressLookupTableAccount, VersionedTransaction, TransactionInstruction } from '@solana/web3.js';
|
|
3
2
|
import { BN } from '../isomorphic/anchor';
|
|
4
3
|
import { JupiterClient } from '../jupiter/jupiterClient';
|
|
@@ -73,7 +73,7 @@ export declare class TxHandler {
|
|
|
73
73
|
getLatestBlockhashForTransaction(): Promise<Readonly<{
|
|
74
74
|
blockhash: string;
|
|
75
75
|
lastValidBlockHeight: number;
|
|
76
|
-
}
|
|
76
|
+
}> | undefined>;
|
|
77
77
|
/**
|
|
78
78
|
* Resolves a usable recent blockhash, preferring a caller-provided one and
|
|
79
79
|
* otherwise fetching the latest. Throws if no blockhash can be obtained,
|
|
@@ -115,7 +115,7 @@ export declare class TxHandler {
|
|
|
115
115
|
*/
|
|
116
116
|
buildBulkTransactions(props: Omit<TxBuildingProps, 'instructions'> & {
|
|
117
117
|
instructions: (TransactionInstruction | TransactionInstruction[])[];
|
|
118
|
-
}): Promise<(Transaction | VersionedTransaction)[]>;
|
|
118
|
+
}): Promise<(Transaction | VersionedTransaction | undefined)[]>;
|
|
119
119
|
/**
|
|
120
120
|
*
|
|
121
121
|
* @param instructions
|
package/lib/browser/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="bn.js" />
|
|
2
1
|
/// <reference types="node" />
|
|
3
2
|
/// <reference types="node" />
|
|
4
3
|
/**
|
|
@@ -428,8 +427,8 @@ export declare class SettlePnlMode {
|
|
|
428
427
|
mustSettle: {};
|
|
429
428
|
};
|
|
430
429
|
}
|
|
431
|
-
export declare function isVariant(object: unknown, type: string):
|
|
432
|
-
export declare function isOneOfVariant(object: unknown, types: string[]):
|
|
430
|
+
export declare function isVariant(object: unknown, type: string): boolean;
|
|
431
|
+
export declare function isOneOfVariant(object: unknown, types: string[]): boolean;
|
|
433
432
|
export declare function getVariant(object: unknown): string;
|
|
434
433
|
export declare enum TradeSide {
|
|
435
434
|
None = 0,
|