@drift-labs/sdk 0.2.0-master.4 → 0.2.0-master.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -27
- package/lib/accounts/bulkAccountLoader.d.ts +2 -0
- package/lib/accounts/bulkAccountLoader.js +36 -29
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/accounts/bulkUserSubscription.d.ts +2 -2
- package/lib/accounts/bulkUserSubscription.js +0 -1
- package/lib/accounts/fetch.d.ts +2 -1
- package/lib/accounts/fetch.js +9 -1
- package/lib/accounts/{pollingClearingHouseAccountSubscriber.d.ts → pollingDriftClientAccountSubscriber.d.ts} +20 -25
- package/lib/accounts/{pollingClearingHouseAccountSubscriber.js → pollingDriftClientAccountSubscriber.js} +45 -49
- package/lib/accounts/{pollingOracleSubscriber.d.ts → pollingOracleAccountSubscriber.d.ts} +2 -2
- package/lib/accounts/{pollingOracleSubscriber.js → pollingOracleAccountSubscriber.js} +3 -3
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +1 -1
- package/lib/accounts/pollingUserAccountSubscriber.js +5 -11
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +107 -0
- package/lib/accounts/types.d.ts +26 -15
- package/lib/accounts/webSocketDriftClientAccountSubscriber.d.ts +49 -0
- package/lib/accounts/{webSocketClearingHouseAccountSubscriber.js → webSocketDriftClientAccountSubscriber.js} +47 -45
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
- package/lib/addresses/marketAddresses.d.ts +1 -3
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.d.ts +15 -9
- package/lib/addresses/pda.js +73 -35
- package/lib/adminClient.d.ts +65 -0
- package/lib/adminClient.js +637 -0
- package/lib/config.d.ts +9 -9
- package/lib/config.js +25 -21
- package/lib/constants/numericConstants.d.ts +30 -12
- package/lib/constants/numericConstants.js +41 -21
- package/lib/constants/perpMarkets.d.ts +18 -0
- package/lib/constants/{markets.js → perpMarkets.js} +7 -7
- package/lib/constants/spotMarkets.d.ts +19 -0
- package/lib/constants/spotMarkets.js +53 -0
- package/lib/dlob/DLOB.d.ts +82 -0
- package/lib/dlob/DLOB.js +694 -0
- package/lib/dlob/DLOBNode.d.ts +54 -0
- package/lib/dlob/DLOBNode.js +77 -0
- package/lib/dlob/NodeList.d.ts +27 -0
- package/lib/dlob/NodeList.js +144 -0
- package/lib/driftClient.d.ts +234 -0
- package/lib/driftClient.js +2108 -0
- package/lib/{clearingHouseConfig.d.ts → driftClientConfig.d.ts} +9 -9
- package/lib/{clearingHouseConfig.js → driftClientConfig.js} +0 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +5 -2
- package/lib/events/eventSubscriber.js +25 -11
- package/lib/events/fetchLogs.d.ts +13 -2
- package/lib/events/fetchLogs.js +40 -12
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +7 -3
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +11 -3
- package/lib/events/types.js +8 -0
- package/lib/events/webSocketLogProvider.js +1 -1
- package/lib/examples/makeTradeExample.js +30 -18
- package/lib/factory/bigNum.d.ts +8 -4
- package/lib/factory/bigNum.js +109 -19
- package/lib/idl/drift.json +8386 -0
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +30 -13
- package/lib/index.js +30 -13
- package/lib/math/amm.d.ts +9 -6
- package/lib/math/amm.js +91 -38
- package/lib/math/conversion.js +1 -1
- package/lib/math/exchangeStatus.d.ts +4 -0
- package/lib/math/exchangeStatus.js +18 -0
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +23 -21
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +11 -0
- package/lib/math/margin.js +82 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +70 -10
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +16 -6
- package/lib/math/orders.js +97 -17
- package/lib/math/position.d.ts +27 -13
- package/lib/math/position.js +92 -36
- package/lib/math/repeg.js +17 -8
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +192 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +6 -0
- package/lib/math/spotPosition.js +23 -0
- package/lib/math/trade.d.ts +10 -10
- package/lib/math/trade.js +27 -31
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/orderParams.d.ts +4 -4
- package/lib/orderParams.js +12 -4
- package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/serum/serumSubscriber.d.ts +27 -0
- package/lib/serum/serumSubscriber.js +56 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/{clearingHouseUserConfig.js → serum/types.js} +0 -0
- package/lib/slot/SlotSubscriber.d.ts +7 -0
- package/lib/slot/SlotSubscriber.js +3 -0
- package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
- package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +13 -4
- package/lib/tx/types.d.ts +1 -1
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +688 -216
- package/lib/types.js +153 -24
- package/lib/user.d.ts +228 -0
- package/lib/user.js +959 -0
- package/lib/userConfig.d.ts +14 -0
- package/lib/userConfig.js +2 -0
- package/lib/userMap/userMap.d.ts +41 -0
- package/lib/userMap/userMap.js +85 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/lib/userName.d.ts +1 -0
- package/lib/userName.js +3 -2
- package/lib/userStats.d.ts +18 -0
- package/lib/userStats.js +49 -0
- package/lib/userStatsConfig.d.ts +14 -0
- package/lib/userStatsConfig.js +2 -0
- package/lib/util/computeUnits.js +1 -1
- package/lib/util/getTokenAddress.d.ts +2 -0
- package/lib/util/getTokenAddress.js +9 -0
- package/package.json +11 -4
- package/src/accounts/bulkAccountLoader.ts +44 -34
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +2 -3
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/{pollingClearingHouseAccountSubscriber.ts → pollingDriftClientAccountSubscriber.ts} +65 -75
- package/src/accounts/{pollingOracleSubscriber.ts → pollingOracleAccountSubscriber.ts} +2 -2
- package/src/accounts/pollingUserAccountSubscriber.ts +5 -12
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +166 -0
- package/src/accounts/types.ts +35 -15
- package/src/accounts/{webSocketClearingHouseAccountSubscriber.ts → webSocketDriftClientAccountSubscriber.ts} +78 -73
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +3 -4
- package/src/addresses/pda.ts +105 -33
- package/src/adminClient.ts +1207 -0
- package/src/assert/assert.js +9 -0
- package/src/config.ts +37 -31
- package/src/constants/numericConstants.ts +58 -24
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +73 -0
- package/src/dlob/DLOB.ts +1120 -0
- package/src/dlob/DLOBNode.ts +155 -0
- package/src/dlob/NodeList.ts +195 -0
- package/src/driftClient.ts +3594 -0
- package/src/{clearingHouseConfig.ts → driftClientConfig.ts} +9 -8
- package/src/events/eventList.js +77 -0
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +36 -14
- package/src/events/fetchLogs.ts +55 -13
- package/src/events/pollingLogProvider.ts +11 -3
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +27 -2
- package/src/events/webSocketLogProvider.ts +1 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/examples/makeTradeExample.ts +44 -28
- package/src/factory/bigNum.ts +150 -22
- package/src/idl/drift.json +8386 -0
- package/src/idl/pyth.json +98 -2
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +30 -13
- package/src/math/amm.ts +161 -48
- package/src/math/conversion.ts +2 -2
- package/src/math/exchangeStatus.ts +31 -0
- package/src/math/funding.ts +41 -31
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +133 -0
- package/src/math/market.ts +143 -14
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +168 -26
- package/src/math/position.ts +136 -58
- package/src/math/repeg.ts +19 -9
- package/src/math/spotBalance.ts +319 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +33 -37
- package/src/oracles/pythClient.ts +2 -2
- package/src/oracles/quoteAssetOracleClient.ts +2 -2
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/orderParams.ts +16 -8
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +99 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/token/index.js +38 -0
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.js +2 -0
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +17 -0
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +650 -189
- package/src/user.ts +1599 -0
- package/src/{clearingHouseUserConfig.ts → userConfig.ts} +5 -5
- package/src/userMap/userMap.ts +124 -0
- package/src/userMap/userStatsMap.ts +108 -0
- package/src/userName.ts +2 -1
- package/src/userStats.ts +75 -0
- package/src/userStatsConfig.ts +18 -0
- package/src/util/computeUnits.js +21 -11
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/getTokenAddress.ts +18 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +46 -11
- package/tests/dlob/helpers.ts +620 -0
- package/tests/dlob/test.ts +4586 -0
- package/yarn-error.log +3160 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +0 -49
- package/lib/admin.d.ts +0 -44
- package/lib/admin.js +0 -433
- package/lib/clearingHouse.d.ts +0 -133
- package/lib/clearingHouse.js +0 -931
- package/lib/clearingHouseUser.d.ts +0 -187
- package/lib/clearingHouseUser.js +0 -643
- package/lib/clearingHouseUserConfig.d.ts +0 -14
- package/lib/constants/banks.d.ts +0 -16
- package/lib/constants/banks.js +0 -34
- package/lib/constants/markets.d.ts +0 -19
- package/lib/idl/clearing_house.json +0 -3998
- package/lib/math/bankBalance.d.ts +0 -9
- package/lib/math/bankBalance.js +0 -75
- package/lib/math/state.d.ts +0 -8
- package/lib/math/state.js +0 -15
- package/lib/orders.d.ts +0 -8
- package/lib/orders.js +0 -134
- package/src/admin.ts +0 -722
- package/src/clearingHouse.ts +0 -1451
- package/src/clearingHouseUser.ts +0 -989
- package/src/constants/banks.ts +0 -43
- package/src/idl/clearing_house.json +0 -3998
- package/src/math/bankBalance.ts +0 -112
- package/src/math/state.ts +0 -14
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/orders.ts +0 -244
- package/src/util/computeUnits.js.map +0 -1
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="bn.js" />
|
|
3
|
-
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { EventEmitter } from 'events';
|
|
5
|
-
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
6
|
-
import { ClearingHouse } from './clearingHouse';
|
|
7
|
-
import { MarginCategory, Order, UserAccount, UserPosition } from './types';
|
|
8
|
-
import { UserAccountSubscriber, UserAccountEvents, DataAndSlot } from './accounts/types';
|
|
9
|
-
import { PositionDirection, BN } from '.';
|
|
10
|
-
import { OraclePriceData } from './oracles/types';
|
|
11
|
-
import { ClearingHouseUserConfig } from './clearingHouseUserConfig';
|
|
12
|
-
export declare class ClearingHouseUser {
|
|
13
|
-
clearingHouse: ClearingHouse;
|
|
14
|
-
userAccountPublicKey: PublicKey;
|
|
15
|
-
accountSubscriber: UserAccountSubscriber;
|
|
16
|
-
_isSubscribed: boolean;
|
|
17
|
-
eventEmitter: StrictEventEmitter<EventEmitter, UserAccountEvents>;
|
|
18
|
-
get isSubscribed(): boolean;
|
|
19
|
-
set isSubscribed(val: boolean);
|
|
20
|
-
constructor(config: ClearingHouseUserConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Subscribe to ClearingHouseUser state accounts
|
|
23
|
-
* @returns SusbcriptionSuccess result
|
|
24
|
-
*/
|
|
25
|
-
subscribe(): Promise<boolean>;
|
|
26
|
-
/**
|
|
27
|
-
* Forces the accountSubscriber to fetch account updates from rpc
|
|
28
|
-
*/
|
|
29
|
-
fetchAccounts(): Promise<void>;
|
|
30
|
-
unsubscribe(): Promise<void>;
|
|
31
|
-
getUserAccount(): UserAccount;
|
|
32
|
-
getUserAccountAndSlot(): DataAndSlot<UserAccount> | undefined;
|
|
33
|
-
/**
|
|
34
|
-
* Gets the user's current position for a given market. If the user has no position returns undefined
|
|
35
|
-
* @param marketIndex
|
|
36
|
-
* @returns userPosition
|
|
37
|
-
*/
|
|
38
|
-
getUserPosition(marketIndex: BN): UserPosition | undefined;
|
|
39
|
-
getEmptyPosition(marketIndex: BN): UserPosition;
|
|
40
|
-
/**
|
|
41
|
-
* @param orderId
|
|
42
|
-
* @returns Order
|
|
43
|
-
*/
|
|
44
|
-
getOrder(orderId: BN): Order | undefined;
|
|
45
|
-
/**
|
|
46
|
-
* @param userOrderId
|
|
47
|
-
* @returns Order
|
|
48
|
-
*/
|
|
49
|
-
getOrderByUserOrderId(userOrderId: number): Order | undefined;
|
|
50
|
-
getUserAccountPublicKey(): PublicKey;
|
|
51
|
-
exists(): Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* calculates Buying Power = FC * MAX_LEVERAGE
|
|
54
|
-
* @returns : Precision QUOTE_PRECISION
|
|
55
|
-
*/
|
|
56
|
-
getBuyingPower(marketIndex: BN | number): BN;
|
|
57
|
-
/**
|
|
58
|
-
* calculates Free Collateral = Total collateral - initial margin requirement
|
|
59
|
-
* @returns : Precision QUOTE_PRECISION
|
|
60
|
-
*/
|
|
61
|
-
getFreeCollateral(): BN;
|
|
62
|
-
getInitialMarginRequirement(): BN;
|
|
63
|
-
/**
|
|
64
|
-
* @returns The partial margin requirement in USDC. : QUOTE_PRECISION
|
|
65
|
-
*/
|
|
66
|
-
getPartialMarginRequirement(): BN;
|
|
67
|
-
/**
|
|
68
|
-
* calculates unrealized position price pnl
|
|
69
|
-
* @returns : Precision QUOTE_PRECISION
|
|
70
|
-
*/
|
|
71
|
-
getUnrealizedPNL(withFunding?: boolean, marketIndex?: BN): BN;
|
|
72
|
-
/**
|
|
73
|
-
* calculates unrealized position price pnl
|
|
74
|
-
* @returns : Precision QUOTE_PRECISION
|
|
75
|
-
*/
|
|
76
|
-
getUnsettledPNL(marketIndex?: BN): BN;
|
|
77
|
-
/**
|
|
78
|
-
* calculates unrealized funding payment pnl
|
|
79
|
-
* @returns : Precision QUOTE_PRECISION
|
|
80
|
-
*/
|
|
81
|
-
getUnrealizedFundingPNL(marketIndex?: BN): BN;
|
|
82
|
-
getTotalLiability(): BN;
|
|
83
|
-
getCollateralValue(bankIndex?: BN): BN;
|
|
84
|
-
/**
|
|
85
|
-
* calculates TotalCollateral: collateral + unrealized pnl
|
|
86
|
-
* TODO: rename to total equity (for perpetuals swaps)
|
|
87
|
-
* @returns : Precision QUOTE_PRECISION
|
|
88
|
-
*/
|
|
89
|
-
getTotalCollateral(): BN;
|
|
90
|
-
/**
|
|
91
|
-
* calculates sum of position value across all positions
|
|
92
|
-
* @returns : Precision QUOTE_PRECISION
|
|
93
|
-
*/
|
|
94
|
-
getTotalPositionValue(): BN;
|
|
95
|
-
/**
|
|
96
|
-
* calculates position value from closing 100%
|
|
97
|
-
* @returns : Precision QUOTE_PRECISION
|
|
98
|
-
*/
|
|
99
|
-
getPositionValue(marketIndex: BN, oraclePriceData: OraclePriceData): BN;
|
|
100
|
-
getPositionSide(currentPosition: Pick<UserPosition, 'baseAssetAmount'>): PositionDirection | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* calculates average exit price for closing 100% of position
|
|
103
|
-
* @returns : Precision MARK_PRICE_PRECISION
|
|
104
|
-
*/
|
|
105
|
-
getPositionEstimatedExitPriceAndPnl(position: UserPosition, amountToClose?: BN): [BN, BN];
|
|
106
|
-
/**
|
|
107
|
-
* calculates current user leverage across all positions
|
|
108
|
-
* @returns : Precision TEN_THOUSAND
|
|
109
|
-
*/
|
|
110
|
-
getLeverage(): BN;
|
|
111
|
-
/**
|
|
112
|
-
* calculates max allowable leverage exceeding hitting requirement category
|
|
113
|
-
* @params category {Initial, Partial, Maintenance}
|
|
114
|
-
* @returns : Precision TEN_THOUSAND
|
|
115
|
-
*/
|
|
116
|
-
getMaxLeverage(marketIndex: BN | number, category?: MarginCategory): BN;
|
|
117
|
-
/**
|
|
118
|
-
* calculates margin ratio: total collateral / |total position value|
|
|
119
|
-
* @returns : Precision TEN_THOUSAND
|
|
120
|
-
*/
|
|
121
|
-
getMarginRatio(): BN;
|
|
122
|
-
canBeLiquidated(): [boolean, BN];
|
|
123
|
-
/**
|
|
124
|
-
* Checks if any user position cumulative funding differs from respective market cumulative funding
|
|
125
|
-
* @returns
|
|
126
|
-
*/
|
|
127
|
-
needsToSettleFundingPayment(): boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Calculate the liquidation price of a position, with optional parameter to calculate the liquidation price after a trade
|
|
130
|
-
* @param marketPosition
|
|
131
|
-
* @param positionBaseSizeChange // change in position size to calculate liquidation price for : Precision 10^13
|
|
132
|
-
* @param partial
|
|
133
|
-
* @returns Precision : MARK_PRICE_PRECISION
|
|
134
|
-
*/
|
|
135
|
-
liquidationPrice(marketPosition: Pick<UserPosition, 'marketIndex'>, positionBaseSizeChange?: BN, partial?: boolean): BN;
|
|
136
|
-
/**
|
|
137
|
-
* Calculates the estimated liquidation price for a position after closing a quote amount of the position.
|
|
138
|
-
* @param positionMarketIndex
|
|
139
|
-
* @param closeQuoteAmount
|
|
140
|
-
* @returns : Precision MARK_PRICE_PRECISION
|
|
141
|
-
*/
|
|
142
|
-
liquidationPriceAfterClose(positionMarketIndex: BN, closeQuoteAmount: BN): BN;
|
|
143
|
-
/**
|
|
144
|
-
* Get the maximum trade size for a given market, taking into account the user's current leverage, positions, collateral, etc.
|
|
145
|
-
*
|
|
146
|
-
* To Calculate Max Quote Available:
|
|
147
|
-
*
|
|
148
|
-
* Case 1: SameSide
|
|
149
|
-
* => Remaining quote to get to maxLeverage
|
|
150
|
-
*
|
|
151
|
-
* Case 2: NOT SameSide && currentLeverage <= maxLeverage
|
|
152
|
-
* => Current opposite position x2 + remaining to get to maxLeverage
|
|
153
|
-
*
|
|
154
|
-
* Case 3: NOT SameSide && currentLeverage > maxLeverage && otherPositions - currentPosition > maxLeverage
|
|
155
|
-
* => strictly reduce current position size
|
|
156
|
-
*
|
|
157
|
-
* Case 4: NOT SameSide && currentLeverage > maxLeverage && otherPositions - currentPosition < maxLeverage
|
|
158
|
-
* => current position + remaining to get to maxLeverage
|
|
159
|
-
*
|
|
160
|
-
* @param targetMarketIndex
|
|
161
|
-
* @param tradeSide
|
|
162
|
-
* @returns tradeSizeAllowed : Precision QUOTE_PRECISION
|
|
163
|
-
*/
|
|
164
|
-
getMaxTradeSizeUSDC(targetMarketIndex: BN, tradeSide: PositionDirection): BN;
|
|
165
|
-
/**
|
|
166
|
-
* Returns the leverage ratio for the account after adding (or subtracting) the given quote size to the given position
|
|
167
|
-
* @param targetMarketIndex
|
|
168
|
-
* @param positionMarketIndex
|
|
169
|
-
* @param tradeQuoteAmount
|
|
170
|
-
* @returns leverageRatio : Precision TEN_THOUSAND
|
|
171
|
-
*/
|
|
172
|
-
accountLeverageRatioAfterTrade(targetMarketIndex: BN, tradeQuoteAmount: BN, tradeSide: PositionDirection): BN;
|
|
173
|
-
/**
|
|
174
|
-
* Calculates how much fee will be taken for a given sized trade
|
|
175
|
-
* @param quoteAmount
|
|
176
|
-
* @returns feeForQuote : Precision QUOTE_PRECISION
|
|
177
|
-
*/
|
|
178
|
-
calculateFeeForQuoteAmount(quoteAmount: BN): BN;
|
|
179
|
-
/**
|
|
180
|
-
* Get the total position value, excluding any position coming from the given target market
|
|
181
|
-
* @param marketToIgnore
|
|
182
|
-
* @returns positionValue : Precision QUOTE_PRECISION
|
|
183
|
-
*/
|
|
184
|
-
private getTotalPositionValueExcludingMarket;
|
|
185
|
-
private getOracleDataForMarket;
|
|
186
|
-
private getOracleDataForBank;
|
|
187
|
-
}
|