@reflectmoney/stable.ts 2.8.4 → 2.9.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/dist/helpers/drift/accounts/index.d.ts +10 -0
- package/dist/helpers/drift/accounts/index.js +26 -0
- package/dist/helpers/drift/accounts/spotMarket.d.ts +541 -0
- package/dist/helpers/drift/accounts/spotMarket.js +213 -0
- package/dist/helpers/drift/accounts/user.d.ts +193 -0
- package/dist/helpers/drift/accounts/user.js +147 -0
- package/dist/helpers/drift/accounts/userStats.d.ts +165 -0
- package/dist/helpers/drift/accounts/userStats.js +137 -0
- package/dist/helpers/drift/index.d.ts +10 -0
- package/dist/helpers/drift/index.js +26 -0
- package/dist/helpers/drift/mappers.d.ts +14 -0
- package/dist/helpers/drift/mappers.js +137 -0
- package/dist/helpers/drift/types/aMM.d.ts +656 -0
- package/dist/helpers/drift/types/aMM.js +199 -0
- package/dist/helpers/drift/types/addAmmConstituentMappingDatum.d.ts +21 -0
- package/dist/helpers/drift/types/addAmmConstituentMappingDatum.js +30 -0
- package/dist/helpers/drift/types/ammCacheFixed.d.ts +17 -0
- package/dist/helpers/drift/types/ammCacheFixed.js +30 -0
- package/dist/helpers/drift/types/ammConstituentDatum.d.ts +27 -0
- package/dist/helpers/drift/types/ammConstituentDatum.js +34 -0
- package/dist/helpers/drift/types/ammConstituentMappingFixed.d.ts +18 -0
- package/dist/helpers/drift/types/ammConstituentMappingFixed.js +32 -0
- package/dist/helpers/drift/types/assetTier.d.ts +19 -0
- package/dist/helpers/drift/types/assetTier.js +31 -0
- package/dist/helpers/drift/types/assetType.d.ts +16 -0
- package/dist/helpers/drift/types/assetType.js +28 -0
- package/dist/helpers/drift/types/builderInfo.d.ts +17 -0
- package/dist/helpers/drift/types/builderInfo.js +30 -0
- package/dist/helpers/drift/types/cacheInfo.d.ts +59 -0
- package/dist/helpers/drift/types/cacheInfo.js +66 -0
- package/dist/helpers/drift/types/constituentCorrelationsFixed.d.ts +19 -0
- package/dist/helpers/drift/types/constituentCorrelationsFixed.js +32 -0
- package/dist/helpers/drift/types/constituentLpOperation.d.ts +17 -0
- package/dist/helpers/drift/types/constituentLpOperation.js +29 -0
- package/dist/helpers/drift/types/constituentSpotBalance.d.ts +48 -0
- package/dist/helpers/drift/types/constituentSpotBalance.js +35 -0
- package/dist/helpers/drift/types/constituentStatus.d.ts +16 -0
- package/dist/helpers/drift/types/constituentStatus.js +28 -0
- package/dist/helpers/drift/types/constituentTargetBaseFixed.d.ts +19 -0
- package/dist/helpers/drift/types/constituentTargetBaseFixed.js +32 -0
- package/dist/helpers/drift/types/contractTier.d.ts +20 -0
- package/dist/helpers/drift/types/contractTier.js +32 -0
- package/dist/helpers/drift/types/contractType.d.ts +17 -0
- package/dist/helpers/drift/types/contractType.js +29 -0
- package/dist/helpers/drift/types/depositDirection.d.ts +16 -0
- package/dist/helpers/drift/types/depositDirection.js +28 -0
- package/dist/helpers/drift/types/depositExplanation.d.ts +19 -0
- package/dist/helpers/drift/types/depositExplanation.js +31 -0
- package/dist/helpers/drift/types/driftAction.d.ts +29 -0
- package/dist/helpers/drift/types/driftAction.js +41 -0
- package/dist/helpers/drift/types/exchangeStatus.d.ts +22 -0
- package/dist/helpers/drift/types/exchangeStatus.js +34 -0
- package/dist/helpers/drift/types/featureBitFlags.d.ts +18 -0
- package/dist/helpers/drift/types/featureBitFlags.js +30 -0
- package/dist/helpers/drift/types/feeStructure.d.ts +24 -0
- package/dist/helpers/drift/types/feeStructure.js +33 -0
- package/dist/helpers/drift/types/feeTier.d.ts +22 -0
- package/dist/helpers/drift/types/feeTier.js +40 -0
- package/dist/helpers/drift/types/fillMode.d.ts +29 -0
- package/dist/helpers/drift/types/fillMode.js +52 -0
- package/dist/helpers/drift/types/fuelOverflowStatus.d.ts +15 -0
- package/dist/helpers/drift/types/fuelOverflowStatus.js +27 -0
- package/dist/helpers/drift/types/historicalIndexData.d.ts +35 -0
- package/dist/helpers/drift/types/historicalIndexData.js +34 -0
- package/dist/helpers/drift/types/historicalOracleData.d.ts +39 -0
- package/dist/helpers/drift/types/historicalOracleData.js +36 -0
- package/dist/helpers/drift/types/ifRebalanceConfigParams.d.ts +31 -0
- package/dist/helpers/drift/types/ifRebalanceConfigParams.js +40 -0
- package/dist/helpers/drift/types/index.d.ts +114 -0
- package/dist/helpers/drift/types/index.js +130 -0
- package/dist/helpers/drift/types/insuranceClaim.d.ts +63 -0
- package/dist/helpers/drift/types/insuranceClaim.js +34 -0
- package/dist/helpers/drift/types/insuranceFund.d.ts +33 -0
- package/dist/helpers/drift/types/insuranceFund.js +42 -0
- package/dist/helpers/drift/types/insuranceFundOperation.d.ts +18 -0
- package/dist/helpers/drift/types/insuranceFundOperation.js +30 -0
- package/dist/helpers/drift/types/lPAction.d.ts +18 -0
- package/dist/helpers/drift/types/lPAction.js +30 -0
- package/dist/helpers/drift/types/liquidateBorrowForPerpPnlRecord.d.ts +27 -0
- package/dist/helpers/drift/types/liquidateBorrowForPerpPnlRecord.js +36 -0
- package/dist/helpers/drift/types/liquidatePerpPnlForDepositRecord.d.ts +27 -0
- package/dist/helpers/drift/types/liquidatePerpPnlForDepositRecord.js +36 -0
- package/dist/helpers/drift/types/liquidatePerpRecord.d.ts +41 -0
- package/dist/helpers/drift/types/liquidatePerpRecord.js +44 -0
- package/dist/helpers/drift/types/liquidateSpotRecord.d.ts +33 -0
- package/dist/helpers/drift/types/liquidateSpotRecord.js +38 -0
- package/dist/helpers/drift/types/liquidationBitFlag.d.ts +15 -0
- package/dist/helpers/drift/types/liquidationBitFlag.js +27 -0
- package/dist/helpers/drift/types/liquidationMultiplierType.d.ts +16 -0
- package/dist/helpers/drift/types/liquidationMultiplierType.js +28 -0
- package/dist/helpers/drift/types/liquidationType.d.ts +20 -0
- package/dist/helpers/drift/types/liquidationType.js +32 -0
- package/dist/helpers/drift/types/logMode.d.ts +19 -0
- package/dist/helpers/drift/types/logMode.js +31 -0
- package/dist/helpers/drift/types/lpPoolFeatureBitFlags.d.ts +17 -0
- package/dist/helpers/drift/types/lpPoolFeatureBitFlags.js +29 -0
- package/dist/helpers/drift/types/lpStatus.d.ts +17 -0
- package/dist/helpers/drift/types/lpStatus.js +29 -0
- package/dist/helpers/drift/types/marginCalculationMode.d.ts +29 -0
- package/dist/helpers/drift/types/marginCalculationMode.js +55 -0
- package/dist/helpers/drift/types/marginMode.d.ts +17 -0
- package/dist/helpers/drift/types/marginMode.js +29 -0
- package/dist/helpers/drift/types/marginRequirementType.d.ts +17 -0
- package/dist/helpers/drift/types/marginRequirementType.js +29 -0
- package/dist/helpers/drift/types/marketIdentifier.d.ts +20 -0
- package/dist/helpers/drift/types/marketIdentifier.js +29 -0
- package/dist/helpers/drift/types/marketStatus.d.ts +23 -0
- package/dist/helpers/drift/types/marketStatus.js +35 -0
- package/dist/helpers/drift/types/marketType.d.ts +16 -0
- package/dist/helpers/drift/types/marketType.js +28 -0
- package/dist/helpers/drift/types/modifyOrderId.d.ts +24 -0
- package/dist/helpers/drift/types/modifyOrderId.js +50 -0
- package/dist/helpers/drift/types/modifyOrderParams.d.ts +44 -0
- package/dist/helpers/drift/types/modifyOrderParams.js +53 -0
- package/dist/helpers/drift/types/modifyOrderPolicy.d.ts +16 -0
- package/dist/helpers/drift/types/modifyOrderPolicy.js +28 -0
- package/dist/helpers/drift/types/oracleGuardRails.d.ts +20 -0
- package/dist/helpers/drift/types/oracleGuardRails.js +29 -0
- package/dist/helpers/drift/types/oracleSource.d.ts +30 -0
- package/dist/helpers/drift/types/oracleSource.js +42 -0
- package/dist/helpers/drift/types/oracleValidity.d.ts +39 -0
- package/dist/helpers/drift/types/oracleValidity.js +60 -0
- package/dist/helpers/drift/types/order.d.ts +178 -0
- package/dist/helpers/drift/types/order.js +77 -0
- package/dist/helpers/drift/types/orderAction.d.ts +19 -0
- package/dist/helpers/drift/types/orderAction.js +31 -0
- package/dist/helpers/drift/types/orderActionExplanation.d.ts +35 -0
- package/dist/helpers/drift/types/orderActionExplanation.js +47 -0
- package/dist/helpers/drift/types/orderBitFlag.d.ts +20 -0
- package/dist/helpers/drift/types/orderBitFlag.js +32 -0
- package/dist/helpers/drift/types/orderFillerRewardStructure.d.ts +21 -0
- package/dist/helpers/drift/types/orderFillerRewardStructure.js +30 -0
- package/dist/helpers/drift/types/orderParams.d.ts +50 -0
- package/dist/helpers/drift/types/orderParams.js +59 -0
- package/dist/helpers/drift/types/orderParamsBitFlag.d.ts +16 -0
- package/dist/helpers/drift/types/orderParamsBitFlag.js +28 -0
- package/dist/helpers/drift/types/orderStatus.d.ts +18 -0
- package/dist/helpers/drift/types/orderStatus.js +30 -0
- package/dist/helpers/drift/types/orderTriggerCondition.d.ts +18 -0
- package/dist/helpers/drift/types/orderTriggerCondition.js +30 -0
- package/dist/helpers/drift/types/orderType.d.ts +19 -0
- package/dist/helpers/drift/types/orderType.js +31 -0
- package/dist/helpers/drift/types/perpBankruptcyRecord.d.ts +27 -0
- package/dist/helpers/drift/types/perpBankruptcyRecord.js +36 -0
- package/dist/helpers/drift/types/perpFulfillmentMethod.d.ts +30 -0
- package/dist/helpers/drift/types/perpFulfillmentMethod.js +72 -0
- package/dist/helpers/drift/types/perpLpOperation.d.ts +16 -0
- package/dist/helpers/drift/types/perpLpOperation.js +28 -0
- package/dist/helpers/drift/types/perpOperation.d.ts +22 -0
- package/dist/helpers/drift/types/perpOperation.js +34 -0
- package/dist/helpers/drift/types/perpPosition.d.ts +149 -0
- package/dist/helpers/drift/types/perpPosition.js +56 -0
- package/dist/helpers/drift/types/placeAndTakeOrderSuccessCondition.d.ts +16 -0
- package/dist/helpers/drift/types/placeAndTakeOrderSuccessCondition.js +28 -0
- package/dist/helpers/drift/types/poolBalance.d.ts +33 -0
- package/dist/helpers/drift/types/poolBalance.js +30 -0
- package/dist/helpers/drift/types/positionDirection.d.ts +16 -0
- package/dist/helpers/drift/types/positionDirection.js +28 -0
- package/dist/helpers/drift/types/positionFlag.d.ts +17 -0
- package/dist/helpers/drift/types/positionFlag.js +29 -0
- package/dist/helpers/drift/types/positionUpdateType.d.ts +19 -0
- package/dist/helpers/drift/types/positionUpdateType.js +31 -0
- package/dist/helpers/drift/types/postOnlyParam.d.ts +18 -0
- package/dist/helpers/drift/types/postOnlyParam.js +30 -0
- package/dist/helpers/drift/types/prelaunchOracleParams.d.ts +21 -0
- package/dist/helpers/drift/types/prelaunchOracleParams.js +30 -0
- package/dist/helpers/drift/types/priceDivergenceGuardRails.d.ts +19 -0
- package/dist/helpers/drift/types/priceDivergenceGuardRails.js +28 -0
- package/dist/helpers/drift/types/referrerStatus.d.ts +17 -0
- package/dist/helpers/drift/types/referrerStatus.js +29 -0
- package/dist/helpers/drift/types/revenueShareEscrowFixed.d.ts +21 -0
- package/dist/helpers/drift/types/revenueShareEscrowFixed.js +38 -0
- package/dist/helpers/drift/types/revenueShareOrder.d.ts +80 -0
- package/dist/helpers/drift/types/revenueShareOrder.js +45 -0
- package/dist/helpers/drift/types/revenueShareOrderBitFlag.d.ts +18 -0
- package/dist/helpers/drift/types/revenueShareOrderBitFlag.js +30 -0
- package/dist/helpers/drift/types/settlePnlExplanation.d.ts +16 -0
- package/dist/helpers/drift/types/settlePnlExplanation.js +28 -0
- package/dist/helpers/drift/types/settlePnlMode.d.ts +16 -0
- package/dist/helpers/drift/types/settlePnlMode.js +28 -0
- package/dist/helpers/drift/types/settlementDirection.d.ts +17 -0
- package/dist/helpers/drift/types/settlementDirection.js +29 -0
- package/dist/helpers/drift/types/signatureVerificationError.d.ts +26 -0
- package/dist/helpers/drift/types/signatureVerificationError.js +38 -0
- package/dist/helpers/drift/types/signedMsgOrderId.d.ts +23 -0
- package/dist/helpers/drift/types/signedMsgOrderId.js +32 -0
- package/dist/helpers/drift/types/signedMsgOrderParamsDelegateMessage.d.ts +36 -0
- package/dist/helpers/drift/types/signedMsgOrderParamsDelegateMessage.js +57 -0
- package/dist/helpers/drift/types/signedMsgOrderParamsMessage.d.ts +36 -0
- package/dist/helpers/drift/types/signedMsgOrderParamsMessage.js +57 -0
- package/dist/helpers/drift/types/signedMsgTriggerOrderParams.d.ts +19 -0
- package/dist/helpers/drift/types/signedMsgTriggerOrderParams.js +28 -0
- package/dist/helpers/drift/types/signedMsgUserOrdersFixed.d.ts +17 -0
- package/dist/helpers/drift/types/signedMsgUserOrdersFixed.js +30 -0
- package/dist/helpers/drift/types/spotBalanceType.d.ts +16 -0
- package/dist/helpers/drift/types/spotBalanceType.js +28 -0
- package/dist/helpers/drift/types/spotBankruptcyRecord.d.ts +23 -0
- package/dist/helpers/drift/types/spotBankruptcyRecord.js +32 -0
- package/dist/helpers/drift/types/spotFulfillmentConfigStatus.d.ts +16 -0
- package/dist/helpers/drift/types/spotFulfillmentConfigStatus.js +28 -0
- package/dist/helpers/drift/types/spotFulfillmentMethod.d.ts +23 -0
- package/dist/helpers/drift/types/spotFulfillmentMethod.js +48 -0
- package/dist/helpers/drift/types/spotFulfillmentType.d.ts +18 -0
- package/dist/helpers/drift/types/spotFulfillmentType.js +30 -0
- package/dist/helpers/drift/types/spotOperation.d.ts +19 -0
- package/dist/helpers/drift/types/spotOperation.js +31 -0
- package/dist/helpers/drift/types/spotPosition.d.ts +72 -0
- package/dist/helpers/drift/types/spotPosition.js +41 -0
- package/dist/helpers/drift/types/stakeAction.d.ts +21 -0
- package/dist/helpers/drift/types/stakeAction.js +33 -0
- package/dist/helpers/drift/types/swapDirection.d.ts +16 -0
- package/dist/helpers/drift/types/swapDirection.js +28 -0
- package/dist/helpers/drift/types/swapReduceOnly.d.ts +16 -0
- package/dist/helpers/drift/types/swapReduceOnly.js +28 -0
- package/dist/helpers/drift/types/targetsDatum.d.ts +25 -0
- package/dist/helpers/drift/types/targetsDatum.js +34 -0
- package/dist/helpers/drift/types/tokenProgramFlag.d.ts +16 -0
- package/dist/helpers/drift/types/tokenProgramFlag.js +28 -0
- package/dist/helpers/drift/types/twapPeriod.d.ts +16 -0
- package/dist/helpers/drift/types/twapPeriod.js +28 -0
- package/dist/helpers/drift/types/userFees.d.ts +75 -0
- package/dist/helpers/drift/types/userFees.js +36 -0
- package/dist/helpers/drift/types/userStatsPausedOperations.d.ts +17 -0
- package/dist/helpers/drift/types/userStatsPausedOperations.js +29 -0
- package/dist/helpers/drift/types/userStatus.d.ts +19 -0
- package/dist/helpers/drift/types/userStatus.js +31 -0
- package/dist/helpers/drift/types/validityGuardRails.d.ts +23 -0
- package/dist/helpers/drift/types/validityGuardRails.js +32 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +17 -0
- package/dist/stablecoins/UsdcPlusStablecoin.d.ts +2 -1
- package/dist/stablecoins/UsdcPlusStablecoin.js +19 -23
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
import { fetchEncodedAccount, fetchEncodedAccounts, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from "@solana/kit";
|
|
9
|
+
import { type UserFees, type UserFeesArgs } from "../types";
|
|
10
|
+
export declare const USER_STATS_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
|
|
11
|
+
export declare function getUserStatsDiscriminatorBytes(): ReadonlyUint8Array;
|
|
12
|
+
export type UserStats = {
|
|
13
|
+
discriminator: ReadonlyUint8Array;
|
|
14
|
+
/** The authority for all of a users sub accounts */
|
|
15
|
+
authority: Address;
|
|
16
|
+
/** The address that referred this user */
|
|
17
|
+
referrer: Address;
|
|
18
|
+
/** Stats on the fees paid by the user */
|
|
19
|
+
fees: UserFees;
|
|
20
|
+
/**
|
|
21
|
+
* The timestamp of the next epoch
|
|
22
|
+
* Epoch is used to limit referrer rewards earned in single epoch
|
|
23
|
+
*/
|
|
24
|
+
nextEpochTs: bigint;
|
|
25
|
+
/**
|
|
26
|
+
* Rolling 30day maker volume for user
|
|
27
|
+
* precision: QUOTE_PRECISION
|
|
28
|
+
*/
|
|
29
|
+
makerVolume30d: bigint;
|
|
30
|
+
/**
|
|
31
|
+
* Rolling 30day taker volume for user
|
|
32
|
+
* precision: QUOTE_PRECISION
|
|
33
|
+
*/
|
|
34
|
+
takerVolume30d: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Rolling 30day filler volume for user
|
|
37
|
+
* precision: QUOTE_PRECISION
|
|
38
|
+
*/
|
|
39
|
+
fillerVolume30d: bigint;
|
|
40
|
+
/** last time the maker volume was updated */
|
|
41
|
+
lastMakerVolume30dTs: bigint;
|
|
42
|
+
/** last time the taker volume was updated */
|
|
43
|
+
lastTakerVolume30dTs: bigint;
|
|
44
|
+
/** last time the filler volume was updated */
|
|
45
|
+
lastFillerVolume30dTs: bigint;
|
|
46
|
+
/** The amount of tokens staked in the quote spot markets if */
|
|
47
|
+
ifStakedQuoteAssetAmount: bigint;
|
|
48
|
+
/** The current number of sub accounts */
|
|
49
|
+
numberOfSubAccounts: number;
|
|
50
|
+
/**
|
|
51
|
+
* The number of sub accounts created. Can be greater than the number of sub accounts if user
|
|
52
|
+
* has deleted sub accounts
|
|
53
|
+
*/
|
|
54
|
+
numberOfSubAccountsCreated: number;
|
|
55
|
+
/**
|
|
56
|
+
* Flags for referrer status:
|
|
57
|
+
* First bit (LSB): 1 if user is a referrer, 0 otherwise
|
|
58
|
+
* Second bit: 1 if user was referred, 0 otherwise
|
|
59
|
+
*/
|
|
60
|
+
referrerStatus: number;
|
|
61
|
+
disableUpdatePerpBidAskTwap: number;
|
|
62
|
+
pausedOperations: number;
|
|
63
|
+
/** whether the user has a FuelOverflow account */
|
|
64
|
+
fuelOverflowStatus: number;
|
|
65
|
+
/** accumulated fuel for token amounts of insurance */
|
|
66
|
+
fuelInsurance: number;
|
|
67
|
+
/** accumulated fuel for notional of deposits */
|
|
68
|
+
fuelDeposits: number;
|
|
69
|
+
/** accumulate fuel bonus for notional of borrows */
|
|
70
|
+
fuelBorrows: number;
|
|
71
|
+
/** accumulated fuel for perp open interest */
|
|
72
|
+
fuelPositions: number;
|
|
73
|
+
/** accumulate fuel bonus for taker volume */
|
|
74
|
+
fuelTaker: number;
|
|
75
|
+
/** accumulate fuel bonus for maker volume */
|
|
76
|
+
fuelMaker: number;
|
|
77
|
+
/** The amount of tokens staked in the governance spot markets if */
|
|
78
|
+
ifStakedGovTokenAmount: bigint;
|
|
79
|
+
/** last unix ts user stats data was used to update if fuel (u32 to save space) */
|
|
80
|
+
lastFuelIfBonusUpdateTs: number;
|
|
81
|
+
padding: ReadonlyUint8Array;
|
|
82
|
+
};
|
|
83
|
+
export type UserStatsArgs = {
|
|
84
|
+
/** The authority for all of a users sub accounts */
|
|
85
|
+
authority: Address;
|
|
86
|
+
/** The address that referred this user */
|
|
87
|
+
referrer: Address;
|
|
88
|
+
/** Stats on the fees paid by the user */
|
|
89
|
+
fees: UserFeesArgs;
|
|
90
|
+
/**
|
|
91
|
+
* The timestamp of the next epoch
|
|
92
|
+
* Epoch is used to limit referrer rewards earned in single epoch
|
|
93
|
+
*/
|
|
94
|
+
nextEpochTs: number | bigint;
|
|
95
|
+
/**
|
|
96
|
+
* Rolling 30day maker volume for user
|
|
97
|
+
* precision: QUOTE_PRECISION
|
|
98
|
+
*/
|
|
99
|
+
makerVolume30d: number | bigint;
|
|
100
|
+
/**
|
|
101
|
+
* Rolling 30day taker volume for user
|
|
102
|
+
* precision: QUOTE_PRECISION
|
|
103
|
+
*/
|
|
104
|
+
takerVolume30d: number | bigint;
|
|
105
|
+
/**
|
|
106
|
+
* Rolling 30day filler volume for user
|
|
107
|
+
* precision: QUOTE_PRECISION
|
|
108
|
+
*/
|
|
109
|
+
fillerVolume30d: number | bigint;
|
|
110
|
+
/** last time the maker volume was updated */
|
|
111
|
+
lastMakerVolume30dTs: number | bigint;
|
|
112
|
+
/** last time the taker volume was updated */
|
|
113
|
+
lastTakerVolume30dTs: number | bigint;
|
|
114
|
+
/** last time the filler volume was updated */
|
|
115
|
+
lastFillerVolume30dTs: number | bigint;
|
|
116
|
+
/** The amount of tokens staked in the quote spot markets if */
|
|
117
|
+
ifStakedQuoteAssetAmount: number | bigint;
|
|
118
|
+
/** The current number of sub accounts */
|
|
119
|
+
numberOfSubAccounts: number;
|
|
120
|
+
/**
|
|
121
|
+
* The number of sub accounts created. Can be greater than the number of sub accounts if user
|
|
122
|
+
* has deleted sub accounts
|
|
123
|
+
*/
|
|
124
|
+
numberOfSubAccountsCreated: number;
|
|
125
|
+
/**
|
|
126
|
+
* Flags for referrer status:
|
|
127
|
+
* First bit (LSB): 1 if user is a referrer, 0 otherwise
|
|
128
|
+
* Second bit: 1 if user was referred, 0 otherwise
|
|
129
|
+
*/
|
|
130
|
+
referrerStatus: number;
|
|
131
|
+
disableUpdatePerpBidAskTwap: number;
|
|
132
|
+
pausedOperations: number;
|
|
133
|
+
/** whether the user has a FuelOverflow account */
|
|
134
|
+
fuelOverflowStatus: number;
|
|
135
|
+
/** accumulated fuel for token amounts of insurance */
|
|
136
|
+
fuelInsurance: number;
|
|
137
|
+
/** accumulated fuel for notional of deposits */
|
|
138
|
+
fuelDeposits: number;
|
|
139
|
+
/** accumulate fuel bonus for notional of borrows */
|
|
140
|
+
fuelBorrows: number;
|
|
141
|
+
/** accumulated fuel for perp open interest */
|
|
142
|
+
fuelPositions: number;
|
|
143
|
+
/** accumulate fuel bonus for taker volume */
|
|
144
|
+
fuelTaker: number;
|
|
145
|
+
/** accumulate fuel bonus for maker volume */
|
|
146
|
+
fuelMaker: number;
|
|
147
|
+
/** The amount of tokens staked in the governance spot markets if */
|
|
148
|
+
ifStakedGovTokenAmount: number | bigint;
|
|
149
|
+
/** last unix ts user stats data was used to update if fuel (u32 to save space) */
|
|
150
|
+
lastFuelIfBonusUpdateTs: number;
|
|
151
|
+
padding: ReadonlyUint8Array;
|
|
152
|
+
};
|
|
153
|
+
/** Gets the encoder for {@link UserStatsArgs} account data. */
|
|
154
|
+
export declare function getUserStatsEncoder(): FixedSizeEncoder<UserStatsArgs>;
|
|
155
|
+
/** Gets the decoder for {@link UserStats} account data. */
|
|
156
|
+
export declare function getUserStatsDecoder(): FixedSizeDecoder<UserStats>;
|
|
157
|
+
/** Gets the codec for {@link UserStats} account data. */
|
|
158
|
+
export declare function getUserStatsCodec(): FixedSizeCodec<UserStatsArgs, UserStats>;
|
|
159
|
+
export declare function decodeUserStats<TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>): Account<UserStats, TAddress>;
|
|
160
|
+
export declare function decodeUserStats<TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>): MaybeAccount<UserStats, TAddress>;
|
|
161
|
+
export declare function fetchUserStats<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<Account<UserStats, TAddress>>;
|
|
162
|
+
export declare function fetchMaybeUserStats<TAddress extends string = string>(rpc: Parameters<typeof fetchEncodedAccount>[0], address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<UserStats, TAddress>>;
|
|
163
|
+
export declare function fetchAllUserStats(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<Account<UserStats>[]>;
|
|
164
|
+
export declare function fetchAllMaybeUserStats(rpc: Parameters<typeof fetchEncodedAccounts>[0], addresses: Array<Address>, config?: FetchAccountsConfig): Promise<MaybeAccount<UserStats>[]>;
|
|
165
|
+
export declare function getUserStatsSize(): number;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
4
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
5
|
+
* to add features, then rerun Codama to update it.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/codama-idl/codama
|
|
8
|
+
*/
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.USER_STATS_DISCRIMINATOR = void 0;
|
|
20
|
+
exports.getUserStatsDiscriminatorBytes = getUserStatsDiscriminatorBytes;
|
|
21
|
+
exports.getUserStatsEncoder = getUserStatsEncoder;
|
|
22
|
+
exports.getUserStatsDecoder = getUserStatsDecoder;
|
|
23
|
+
exports.getUserStatsCodec = getUserStatsCodec;
|
|
24
|
+
exports.decodeUserStats = decodeUserStats;
|
|
25
|
+
exports.fetchUserStats = fetchUserStats;
|
|
26
|
+
exports.fetchMaybeUserStats = fetchMaybeUserStats;
|
|
27
|
+
exports.fetchAllUserStats = fetchAllUserStats;
|
|
28
|
+
exports.fetchAllMaybeUserStats = fetchAllMaybeUserStats;
|
|
29
|
+
exports.getUserStatsSize = getUserStatsSize;
|
|
30
|
+
const kit_1 = require("@solana/kit");
|
|
31
|
+
const types_1 = require("../types");
|
|
32
|
+
exports.USER_STATS_DISCRIMINATOR = new Uint8Array([
|
|
33
|
+
176, 223, 136, 27, 122, 79, 32, 227,
|
|
34
|
+
]);
|
|
35
|
+
function getUserStatsDiscriminatorBytes() {
|
|
36
|
+
return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.USER_STATS_DISCRIMINATOR);
|
|
37
|
+
}
|
|
38
|
+
/** Gets the encoder for {@link UserStatsArgs} account data. */
|
|
39
|
+
function getUserStatsEncoder() {
|
|
40
|
+
return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
|
|
41
|
+
["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
|
|
42
|
+
["authority", (0, kit_1.getAddressEncoder)()],
|
|
43
|
+
["referrer", (0, kit_1.getAddressEncoder)()],
|
|
44
|
+
["fees", (0, types_1.getUserFeesEncoder)()],
|
|
45
|
+
["nextEpochTs", (0, kit_1.getI64Encoder)()],
|
|
46
|
+
["makerVolume30d", (0, kit_1.getU64Encoder)()],
|
|
47
|
+
["takerVolume30d", (0, kit_1.getU64Encoder)()],
|
|
48
|
+
["fillerVolume30d", (0, kit_1.getU64Encoder)()],
|
|
49
|
+
["lastMakerVolume30dTs", (0, kit_1.getI64Encoder)()],
|
|
50
|
+
["lastTakerVolume30dTs", (0, kit_1.getI64Encoder)()],
|
|
51
|
+
["lastFillerVolume30dTs", (0, kit_1.getI64Encoder)()],
|
|
52
|
+
["ifStakedQuoteAssetAmount", (0, kit_1.getU64Encoder)()],
|
|
53
|
+
["numberOfSubAccounts", (0, kit_1.getU16Encoder)()],
|
|
54
|
+
["numberOfSubAccountsCreated", (0, kit_1.getU16Encoder)()],
|
|
55
|
+
["referrerStatus", (0, kit_1.getU8Encoder)()],
|
|
56
|
+
["disableUpdatePerpBidAskTwap", (0, kit_1.getU8Encoder)()],
|
|
57
|
+
["pausedOperations", (0, kit_1.getU8Encoder)()],
|
|
58
|
+
["fuelOverflowStatus", (0, kit_1.getU8Encoder)()],
|
|
59
|
+
["fuelInsurance", (0, kit_1.getU32Encoder)()],
|
|
60
|
+
["fuelDeposits", (0, kit_1.getU32Encoder)()],
|
|
61
|
+
["fuelBorrows", (0, kit_1.getU32Encoder)()],
|
|
62
|
+
["fuelPositions", (0, kit_1.getU32Encoder)()],
|
|
63
|
+
["fuelTaker", (0, kit_1.getU32Encoder)()],
|
|
64
|
+
["fuelMaker", (0, kit_1.getU32Encoder)()],
|
|
65
|
+
["ifStakedGovTokenAmount", (0, kit_1.getU64Encoder)()],
|
|
66
|
+
["lastFuelIfBonusUpdateTs", (0, kit_1.getU32Encoder)()],
|
|
67
|
+
["padding", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 12)],
|
|
68
|
+
]), (value) => (Object.assign(Object.assign({}, value), { discriminator: exports.USER_STATS_DISCRIMINATOR })));
|
|
69
|
+
}
|
|
70
|
+
/** Gets the decoder for {@link UserStats} account data. */
|
|
71
|
+
function getUserStatsDecoder() {
|
|
72
|
+
return (0, kit_1.getStructDecoder)([
|
|
73
|
+
["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
|
|
74
|
+
["authority", (0, kit_1.getAddressDecoder)()],
|
|
75
|
+
["referrer", (0, kit_1.getAddressDecoder)()],
|
|
76
|
+
["fees", (0, types_1.getUserFeesDecoder)()],
|
|
77
|
+
["nextEpochTs", (0, kit_1.getI64Decoder)()],
|
|
78
|
+
["makerVolume30d", (0, kit_1.getU64Decoder)()],
|
|
79
|
+
["takerVolume30d", (0, kit_1.getU64Decoder)()],
|
|
80
|
+
["fillerVolume30d", (0, kit_1.getU64Decoder)()],
|
|
81
|
+
["lastMakerVolume30dTs", (0, kit_1.getI64Decoder)()],
|
|
82
|
+
["lastTakerVolume30dTs", (0, kit_1.getI64Decoder)()],
|
|
83
|
+
["lastFillerVolume30dTs", (0, kit_1.getI64Decoder)()],
|
|
84
|
+
["ifStakedQuoteAssetAmount", (0, kit_1.getU64Decoder)()],
|
|
85
|
+
["numberOfSubAccounts", (0, kit_1.getU16Decoder)()],
|
|
86
|
+
["numberOfSubAccountsCreated", (0, kit_1.getU16Decoder)()],
|
|
87
|
+
["referrerStatus", (0, kit_1.getU8Decoder)()],
|
|
88
|
+
["disableUpdatePerpBidAskTwap", (0, kit_1.getU8Decoder)()],
|
|
89
|
+
["pausedOperations", (0, kit_1.getU8Decoder)()],
|
|
90
|
+
["fuelOverflowStatus", (0, kit_1.getU8Decoder)()],
|
|
91
|
+
["fuelInsurance", (0, kit_1.getU32Decoder)()],
|
|
92
|
+
["fuelDeposits", (0, kit_1.getU32Decoder)()],
|
|
93
|
+
["fuelBorrows", (0, kit_1.getU32Decoder)()],
|
|
94
|
+
["fuelPositions", (0, kit_1.getU32Decoder)()],
|
|
95
|
+
["fuelTaker", (0, kit_1.getU32Decoder)()],
|
|
96
|
+
["fuelMaker", (0, kit_1.getU32Decoder)()],
|
|
97
|
+
["ifStakedGovTokenAmount", (0, kit_1.getU64Decoder)()],
|
|
98
|
+
["lastFuelIfBonusUpdateTs", (0, kit_1.getU32Decoder)()],
|
|
99
|
+
["padding", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 12)],
|
|
100
|
+
]);
|
|
101
|
+
}
|
|
102
|
+
/** Gets the codec for {@link UserStats} account data. */
|
|
103
|
+
function getUserStatsCodec() {
|
|
104
|
+
return (0, kit_1.combineCodec)(getUserStatsEncoder(), getUserStatsDecoder());
|
|
105
|
+
}
|
|
106
|
+
function decodeUserStats(encodedAccount) {
|
|
107
|
+
return (0, kit_1.decodeAccount)(encodedAccount, getUserStatsDecoder());
|
|
108
|
+
}
|
|
109
|
+
function fetchUserStats(rpc, address, config) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const maybeAccount = yield fetchMaybeUserStats(rpc, address, config);
|
|
112
|
+
(0, kit_1.assertAccountExists)(maybeAccount);
|
|
113
|
+
return maybeAccount;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function fetchMaybeUserStats(rpc, address, config) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
const maybeAccount = yield (0, kit_1.fetchEncodedAccount)(rpc, address, config);
|
|
119
|
+
return decodeUserStats(maybeAccount);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function fetchAllUserStats(rpc, addresses, config) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const maybeAccounts = yield fetchAllMaybeUserStats(rpc, addresses, config);
|
|
125
|
+
(0, kit_1.assertAccountsExist)(maybeAccounts);
|
|
126
|
+
return maybeAccounts;
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function fetchAllMaybeUserStats(rpc, addresses, config) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
const maybeAccounts = yield (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
|
|
132
|
+
return maybeAccounts.map((maybeAccount) => decodeUserStats(maybeAccount));
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function getUserStatsSize() {
|
|
136
|
+
return 240;
|
|
137
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
export * from "./accounts/index";
|
|
9
|
+
export * from "./types";
|
|
10
|
+
export * from "./mappers";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
4
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
5
|
+
* to add features, then rerun Codama to update it.
|
|
6
|
+
*
|
|
7
|
+
* @see https://github.com/codama-idl/codama
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
__exportStar(require("./accounts/index"), exports);
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./mappers"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SpotMarketAccount, SpotBalanceType as DriftSpotBalanceType } from "@drift-labs/sdk";
|
|
2
|
+
import { SpotMarket } from "./accounts/spotMarket";
|
|
3
|
+
import { SpotBalanceType } from "./types/spotBalanceType";
|
|
4
|
+
/**
|
|
5
|
+
* Maps a SpotMarket from the Codama SDK to SpotMarketAccount expected by @drift-labs/sdk.
|
|
6
|
+
* This is needed because the two SDKs use different types:
|
|
7
|
+
* - Codama SDK uses bigint for large numbers
|
|
8
|
+
* - @drift-labs/sdk uses BN (bn.js)
|
|
9
|
+
*/
|
|
10
|
+
export declare function mapSpotMarket(spotMarket: SpotMarket): SpotMarketAccount;
|
|
11
|
+
/**
|
|
12
|
+
* Maps SpotBalanceType from Codama SDK enum to @drift-labs/sdk format.
|
|
13
|
+
*/
|
|
14
|
+
export declare function mapSpotBalanceType(balanceType: SpotBalanceType): DriftSpotBalanceType;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.mapSpotMarket = mapSpotMarket;
|
|
7
|
+
exports.mapSpotBalanceType = mapSpotBalanceType;
|
|
8
|
+
const sdk_1 = require("@drift-labs/sdk");
|
|
9
|
+
const spotBalanceType_1 = require("./types/spotBalanceType");
|
|
10
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
11
|
+
const bn_js_1 = __importDefault(require("bn.js"));
|
|
12
|
+
/**
|
|
13
|
+
* Maps a SpotMarket from the Codama SDK to SpotMarketAccount expected by @drift-labs/sdk.
|
|
14
|
+
* This is needed because the two SDKs use different types:
|
|
15
|
+
* - Codama SDK uses bigint for large numbers
|
|
16
|
+
* - @drift-labs/sdk uses BN (bn.js)
|
|
17
|
+
*/
|
|
18
|
+
function mapSpotMarket(spotMarket) {
|
|
19
|
+
return {
|
|
20
|
+
status: mapMarketStatus(spotMarket.status),
|
|
21
|
+
assetTier: mapAssetTier(spotMarket.assetTier),
|
|
22
|
+
name: Array.from(spotMarket.name),
|
|
23
|
+
marketIndex: spotMarket.marketIndex,
|
|
24
|
+
pubkey: new web3_js_1.PublicKey(spotMarket.pubkey),
|
|
25
|
+
mint: new web3_js_1.PublicKey(spotMarket.mint),
|
|
26
|
+
vault: new web3_js_1.PublicKey(spotMarket.vault),
|
|
27
|
+
oracle: new web3_js_1.PublicKey(spotMarket.oracle),
|
|
28
|
+
oracleSource: mapOracleSource(spotMarket.oracleSource),
|
|
29
|
+
historicalOracleData: {
|
|
30
|
+
lastOraclePrice: new bn_js_1.default(spotMarket.historicalOracleData.lastOraclePrice.toString()),
|
|
31
|
+
lastOracleDelay: new bn_js_1.default(spotMarket.historicalOracleData.lastOracleDelay.toString()),
|
|
32
|
+
lastOracleConf: new bn_js_1.default(spotMarket.historicalOracleData.lastOracleConf.toString()),
|
|
33
|
+
lastOraclePriceTwap: new bn_js_1.default(spotMarket.historicalOracleData.lastOraclePriceTwap.toString()),
|
|
34
|
+
lastOraclePriceTwap5Min: new bn_js_1.default(spotMarket.historicalOracleData.lastOraclePriceTwap5min.toString()),
|
|
35
|
+
lastOraclePriceTwapTs: new bn_js_1.default(spotMarket.historicalOracleData.lastOraclePriceTwapTs.toString()),
|
|
36
|
+
},
|
|
37
|
+
historicalIndexData: {
|
|
38
|
+
lastIndexBidPrice: new bn_js_1.default(spotMarket.historicalIndexData.lastIndexBidPrice.toString()),
|
|
39
|
+
lastIndexAskPrice: new bn_js_1.default(spotMarket.historicalIndexData.lastIndexAskPrice.toString()),
|
|
40
|
+
lastIndexPriceTwap: new bn_js_1.default(spotMarket.historicalIndexData.lastIndexPriceTwap.toString()),
|
|
41
|
+
lastIndexPriceTwap5Min: new bn_js_1.default(spotMarket.historicalIndexData.lastIndexPriceTwap5min.toString()),
|
|
42
|
+
lastIndexPriceTwapTs: new bn_js_1.default(spotMarket.historicalIndexData.lastIndexPriceTwapTs.toString()),
|
|
43
|
+
},
|
|
44
|
+
insuranceFund: {
|
|
45
|
+
vault: new web3_js_1.PublicKey(spotMarket.insuranceFund.vault),
|
|
46
|
+
totalShares: new bn_js_1.default(spotMarket.insuranceFund.totalShares.toString()),
|
|
47
|
+
userShares: new bn_js_1.default(spotMarket.insuranceFund.userShares.toString()),
|
|
48
|
+
sharesBase: new bn_js_1.default(spotMarket.insuranceFund.sharesBase.toString()),
|
|
49
|
+
unstakingPeriod: new bn_js_1.default(spotMarket.insuranceFund.unstakingPeriod.toString()),
|
|
50
|
+
lastRevenueSettleTs: new bn_js_1.default(spotMarket.insuranceFund.lastRevenueSettleTs.toString()),
|
|
51
|
+
revenueSettlePeriod: new bn_js_1.default(spotMarket.insuranceFund.revenueSettlePeriod.toString()),
|
|
52
|
+
totalFactor: spotMarket.insuranceFund.totalFactor,
|
|
53
|
+
userFactor: spotMarket.insuranceFund.userFactor,
|
|
54
|
+
},
|
|
55
|
+
revenuePool: {
|
|
56
|
+
scaledBalance: new bn_js_1.default(spotMarket.revenuePool.scaledBalance.toString()),
|
|
57
|
+
marketIndex: spotMarket.revenuePool.marketIndex,
|
|
58
|
+
},
|
|
59
|
+
ifLiquidationFee: spotMarket.ifLiquidationFee,
|
|
60
|
+
decimals: spotMarket.decimals,
|
|
61
|
+
optimalUtilization: spotMarket.optimalUtilization,
|
|
62
|
+
optimalBorrowRate: spotMarket.optimalBorrowRate,
|
|
63
|
+
maxBorrowRate: spotMarket.maxBorrowRate,
|
|
64
|
+
cumulativeDepositInterest: new bn_js_1.default(spotMarket.cumulativeDepositInterest.toString()),
|
|
65
|
+
cumulativeBorrowInterest: new bn_js_1.default(spotMarket.cumulativeBorrowInterest.toString()),
|
|
66
|
+
totalSocialLoss: new bn_js_1.default(spotMarket.totalSocialLoss.toString()),
|
|
67
|
+
totalQuoteSocialLoss: new bn_js_1.default(spotMarket.totalQuoteSocialLoss.toString()),
|
|
68
|
+
depositBalance: new bn_js_1.default(spotMarket.depositBalance.toString()),
|
|
69
|
+
borrowBalance: new bn_js_1.default(spotMarket.borrowBalance.toString()),
|
|
70
|
+
maxTokenDeposits: new bn_js_1.default(spotMarket.maxTokenDeposits.toString()),
|
|
71
|
+
lastInterestTs: new bn_js_1.default(spotMarket.lastInterestTs.toString()),
|
|
72
|
+
lastTwapTs: new bn_js_1.default(spotMarket.lastTwapTs.toString()),
|
|
73
|
+
initialAssetWeight: spotMarket.initialAssetWeight,
|
|
74
|
+
maintenanceAssetWeight: spotMarket.maintenanceAssetWeight,
|
|
75
|
+
initialLiabilityWeight: spotMarket.initialLiabilityWeight,
|
|
76
|
+
maintenanceLiabilityWeight: spotMarket.maintenanceLiabilityWeight,
|
|
77
|
+
liquidatorFee: spotMarket.liquidatorFee,
|
|
78
|
+
imfFactor: spotMarket.imfFactor,
|
|
79
|
+
scaleInitialAssetWeightStart: new bn_js_1.default(spotMarket.scaleInitialAssetWeightStart.toString()),
|
|
80
|
+
withdrawGuardThreshold: new bn_js_1.default(spotMarket.withdrawGuardThreshold.toString()),
|
|
81
|
+
depositTokenTwap: new bn_js_1.default(spotMarket.depositTokenTwap.toString()),
|
|
82
|
+
borrowTokenTwap: new bn_js_1.default(spotMarket.borrowTokenTwap.toString()),
|
|
83
|
+
utilizationTwap: new bn_js_1.default(spotMarket.utilizationTwap.toString()),
|
|
84
|
+
nextDepositRecordId: new bn_js_1.default(spotMarket.nextDepositRecordId.toString()),
|
|
85
|
+
orderStepSize: new bn_js_1.default(spotMarket.orderStepSize.toString()),
|
|
86
|
+
orderTickSize: new bn_js_1.default(spotMarket.orderTickSize.toString()),
|
|
87
|
+
minOrderSize: new bn_js_1.default(spotMarket.minOrderSize.toString()),
|
|
88
|
+
maxPositionSize: new bn_js_1.default(spotMarket.maxPositionSize.toString()),
|
|
89
|
+
nextFillRecordId: new bn_js_1.default(spotMarket.nextFillRecordId.toString()),
|
|
90
|
+
spotFeePool: {
|
|
91
|
+
scaledBalance: new bn_js_1.default(spotMarket.spotFeePool.scaledBalance.toString()),
|
|
92
|
+
marketIndex: spotMarket.spotFeePool.marketIndex,
|
|
93
|
+
},
|
|
94
|
+
totalSpotFee: new bn_js_1.default(spotMarket.totalSpotFee.toString()),
|
|
95
|
+
totalSwapFee: new bn_js_1.default(spotMarket.totalSwapFee.toString()),
|
|
96
|
+
flashLoanAmount: new bn_js_1.default(spotMarket.flashLoanAmount.toString()),
|
|
97
|
+
flashLoanInitialTokenAmount: new bn_js_1.default(spotMarket.flashLoanInitialTokenAmount.toString()),
|
|
98
|
+
ordersEnabled: spotMarket.ordersEnabled,
|
|
99
|
+
pausedOperations: spotMarket.pausedOperations,
|
|
100
|
+
ifPausedOperations: spotMarket.ifPausedOperations,
|
|
101
|
+
maxTokenBorrowsFraction: spotMarket.maxTokenBorrowsFraction,
|
|
102
|
+
minBorrowRate: spotMarket.minBorrowRate,
|
|
103
|
+
fuelBoostDeposits: spotMarket.fuelBoostDeposits,
|
|
104
|
+
fuelBoostBorrows: spotMarket.fuelBoostBorrows,
|
|
105
|
+
fuelBoostTaker: spotMarket.fuelBoostTaker,
|
|
106
|
+
fuelBoostMaker: spotMarket.fuelBoostMaker,
|
|
107
|
+
fuelBoostInsurance: spotMarket.fuelBoostInsurance,
|
|
108
|
+
tokenProgramFlag: spotMarket.tokenProgramFlag,
|
|
109
|
+
poolId: spotMarket.poolId,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Maps SpotBalanceType from Codama SDK enum to @drift-labs/sdk format.
|
|
114
|
+
*/
|
|
115
|
+
function mapSpotBalanceType(balanceType) {
|
|
116
|
+
switch (balanceType) {
|
|
117
|
+
case spotBalanceType_1.SpotBalanceType.Deposit:
|
|
118
|
+
return sdk_1.SpotBalanceType.DEPOSIT;
|
|
119
|
+
case spotBalanceType_1.SpotBalanceType.Borrow:
|
|
120
|
+
return sdk_1.SpotBalanceType.BORROW;
|
|
121
|
+
default:
|
|
122
|
+
throw new Error(`Unknown SpotBalanceType: ${balanceType}`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Helper functions for mapping enum types
|
|
126
|
+
function mapMarketStatus(status) {
|
|
127
|
+
// The status object format matches between SDKs
|
|
128
|
+
return status;
|
|
129
|
+
}
|
|
130
|
+
function mapAssetTier(assetTier) {
|
|
131
|
+
// The assetTier object format matches between SDKs
|
|
132
|
+
return assetTier;
|
|
133
|
+
}
|
|
134
|
+
function mapOracleSource(oracleSource) {
|
|
135
|
+
// The oracleSource object format matches between SDKs
|
|
136
|
+
return oracleSource;
|
|
137
|
+
}
|