From 9200c73698e40e2f239803ee9b0763169606eb64 Mon Sep 17 00:00:00 2001 From: Lukas deConantsesznak Date: Fri, 13 Dec 2024 13:46:03 -0700 Subject: [PATCH] fix: formatting --- common-ts/src/EnvironmentConstants.ts | 12 ++++++++---- common-ts/src/common-ui-utils/order.ts | 12 ++++++------ common-ts/src/serializableTypes.ts | 12 ++++++------ common-ts/src/types/MarketId.ts | 5 +---- common-ts/src/types/UIMarket.ts | 5 +---- common-ts/src/utils/equalityChecks.ts | 2 +- common-ts/src/utils/index.ts | 6 +++--- .../src/utils/priority-fees/PriorityFeeStrategies.ts | 2 +- common-ts/src/utils/superstake.ts | 2 +- react/src/actions/driftActions.ts | 5 +++-- react/src/components/Tables/BodyCellWrapper.tsx | 4 ++-- react/src/components/Tables/TableRowWrapper.tsx | 10 +++++++--- .../charts/useGroupHistoricalPricesByAverage.ts | 4 ++-- .../src/hooks/oraclePrice/useSyncOraclePriceStore.ts | 2 +- .../hooks/priorityFees/usePriorityFeesPollingRate.ts | 2 +- react/src/hooks/useCurrentRpc.tsx | 4 ++-- react/src/hooks/useInitializeConnection.tsx | 2 +- react/src/hooks/useRpcLatencies.tsx | 10 +++++----- .../src/stores/priorityFee/useHeliusPriorityFees.ts | 8 ++++---- 19 files changed, 56 insertions(+), 53 deletions(-) diff --git a/common-ts/src/EnvironmentConstants.ts b/common-ts/src/EnvironmentConstants.ts index 9ee5d45f..31e30915 100644 --- a/common-ts/src/EnvironmentConstants.ts +++ b/common-ts/src/EnvironmentConstants.ts @@ -10,14 +10,18 @@ export const EnvironmentConstants = { dev: [ { label: 'Helius', - value: 'https://detailed-sharleen-fast-devnet.helius-rpc.com/', - wsValue: 'wss://detailed-sharleen-fast-devnet.helius-rpc.com/', + value: + 'https://devnet.helius-rpc.com/?api-key=f6657e98-1af2-4fac-bc58-18f5667b10c9', + wsValue: + 'wss://devnet.helius-rpc.com/?api-key=f6657e98-1af2-4fac-bc58-18f5667b10c9', allowAdditionalConnection: true, }, { label: 'RPC Pool', - value: 'https://drift-drift-a827.devnet.rpcpool.com', - wsValue: 'wss://drift-drift-a827.devnet.rpcpool.com/whirligig', + value: + 'https://devnet.helius-rpc.com/?api-key=f6657e98-1af2-4fac-bc58-18f5667b10c9', + wsValue: + 'wss://devnet.helius-rpc.com/?api-key=f6657e98-1af2-4fac-bc58-18f5667b10c9', allowAdditionalConnection: false, }, ] as RpcEndpoint[], diff --git a/common-ts/src/common-ui-utils/order.ts b/common-ts/src/common-ui-utils/order.ts index 0ed6f15a..e256f258 100644 --- a/common-ts/src/common-ui-utils/order.ts +++ b/common-ts/src/common-ui-utils/order.ts @@ -35,8 +35,8 @@ export const getOrderLabelFromOrderDetails = ( ? 'Trigger Market' : UI_ORDER_TYPES.stopMarket.label : matchEnum(orderDetails.direction, PositionDirection.SHORT) - ? UI_ORDER_TYPES.takeProfitMarket.label - : UI_ORDER_TYPES.stopMarket.label; + ? UI_ORDER_TYPES.takeProfitMarket.label + : UI_ORDER_TYPES.stopMarket.label; } else { return matchEnum( orderDetails.existingPositionDirection, @@ -46,8 +46,8 @@ export const getOrderLabelFromOrderDetails = ( ? 'Trigger Market' : UI_ORDER_TYPES.takeProfitMarket.label : matchEnum(orderDetails.direction, PositionDirection.SHORT) - ? UI_ORDER_TYPES.stopMarket.label - : UI_ORDER_TYPES.takeProfitMarket.label; + ? UI_ORDER_TYPES.stopMarket.label + : UI_ORDER_TYPES.takeProfitMarket.label; } } @@ -68,8 +68,8 @@ export const getOrderLabelFromOrderDetails = ( ) ? UI_ORDER_TYPES.stopLimit.label : matchEnum(orderDetails.direction, PositionDirection.SHORT) - ? 'Stop Limit' - : UI_ORDER_TYPES.takeProfitLimit.label; + ? 'Stop Limit' + : UI_ORDER_TYPES.takeProfitLimit.label; } } diff --git a/common-ts/src/serializableTypes.ts b/common-ts/src/serializableTypes.ts index 7433969d..b52c4e86 100644 --- a/common-ts/src/serializableTypes.ts +++ b/common-ts/src/serializableTypes.ts @@ -104,7 +104,7 @@ const QuoteBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, QUOTE_PRECISION_EXP - ) + ) : undefined; const QuoteBigNumSerializeAndDeserializeFns = { Serialize: QuoteBigNumSerializationFn, @@ -123,7 +123,7 @@ const PctBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, PERCENTAGE_PRECISION_EXP - ) + ) : undefined; const PctBigNumSerializeAndDeserializeFns = { @@ -142,7 +142,7 @@ const BaseBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, BASE_PRECISION_EXP - ) + ) : undefined; const BaseBigNumSerializeAndDeserializeFns = { Serialize: BaseBigNumSerializationFn, @@ -160,7 +160,7 @@ const PriceBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, PRICE_PRECISION_EXP - ) + ) : undefined; const PriceBigNumSerializeAndDeserializeFns = { Serialize: PriceBigNumSerializationFn, @@ -178,7 +178,7 @@ const FundingRateBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, PRICE_PRECISION_EXP - ) + ) : undefined; const FundingRateBigNumSerializeAndDeserializeFns = { Serialize: FundingRateBigNumSerializationFn, @@ -196,7 +196,7 @@ const BankCumulativeInterestBigNumDeserializationFn = (val: string) => ? BigNum.from( typeof val === 'string' ? val.replace('.', '') : val, PRICE_PRECISION_EXP - ) + ) : undefined; const BankCumulativeInterestBigNumSerializeAndDeserializeFns = { Serialize: BankCumulativeInterestBigNumSerializationFn, diff --git a/common-ts/src/types/MarketId.ts b/common-ts/src/types/MarketId.ts index edff9e70..4fb5b76c 100644 --- a/common-ts/src/types/MarketId.ts +++ b/common-ts/src/types/MarketId.ts @@ -6,10 +6,7 @@ import { Opaque } from '.'; export type MarketKey = Opaque<'MarketKey', string>; export class MarketId { - constructor( - readonly marketIndex: number, - readonly marketType: MarketType - ) {} + constructor(readonly marketIndex: number, readonly marketType: MarketType) {} static createPerpMarket(marketIndex: number) { return new MarketId(marketIndex, MarketType.PERP); diff --git a/common-ts/src/types/UIMarket.ts b/common-ts/src/types/UIMarket.ts index d356fddc..e6179f09 100644 --- a/common-ts/src/types/UIMarket.ts +++ b/common-ts/src/types/UIMarket.ts @@ -14,10 +14,7 @@ export class UIMarket { readonly market: SpotMarketConfig | PerpMarketConfig; readonly marketId: MarketId; - constructor( - readonly marketIndex: number, - readonly marketType: MarketType - ) { + constructor(readonly marketIndex: number, readonly marketType: MarketType) { const marketId = new MarketId(marketIndex, marketType); const markets = marketId.isPerp ? Config.perpMarketsLookup diff --git a/common-ts/src/utils/equalityChecks.ts b/common-ts/src/utils/equalityChecks.ts index 61319528..27abd927 100644 --- a/common-ts/src/utils/equalityChecks.ts +++ b/common-ts/src/utils/equalityChecks.ts @@ -11,7 +11,7 @@ export type PropertyType = export type PropertyAndType = [ property: KeyOfObject, type: PropertyType, - customEqualityFn?: (a: any, b: any) => boolean, + customEqualityFn?: (a: any, b: any) => boolean ]; const arePropertiesEqual = ( diff --git a/common-ts/src/utils/index.ts b/common-ts/src/utils/index.ts index 2b0cb1ba..f84c0fd8 100644 --- a/common-ts/src/utils/index.ts +++ b/common-ts/src/utils/index.ts @@ -157,8 +157,8 @@ const getChronologicalValueForOrderAction = (action: OrderAction) => { return matchEnum(action, OrderAction.PLACE) ? 0 : matchEnum(action, OrderAction.FILL) - ? 1 - : 2; + ? 1 + : 2; }; /** @@ -786,7 +786,7 @@ const syncGetIfStakingVaultApr = ( const userRevenueFactor = spotMarket.insuranceFund.totalFactor > 0 ? spotMarket.insuranceFund.userFactor / - spotMarket.insuranceFund.totalFactor + spotMarket.insuranceFund.totalFactor : 0; const revPoolTokensNum = BigNum.from( diff --git a/common-ts/src/utils/priority-fees/PriorityFeeStrategies.ts b/common-ts/src/utils/priority-fees/PriorityFeeStrategies.ts index 32f843dd..138b0e61 100644 --- a/common-ts/src/utils/priority-fees/PriorityFeeStrategies.ts +++ b/common-ts/src/utils/priority-fees/PriorityFeeStrategies.ts @@ -51,7 +51,7 @@ const movingWindowTargetPercentileStrategy = ( const pFee = shouldSplitWithBelow ? (allRecentSamplesAscendingSorted[targetPercentileIndex] + allRecentSamplesAscendingSorted[targetPercentileIndex - 1]) / - 2 + 2 : allRecentSamplesAscendingSorted[targetPercentileIndex]; LAST_SEEN_SLOT_IN_SAMPLES = Math.max( diff --git a/common-ts/src/utils/superstake.ts b/common-ts/src/utils/superstake.ts index 3ed20951..292798c0 100644 --- a/common-ts/src/utils/superstake.ts +++ b/common-ts/src/utils/superstake.ts @@ -110,7 +110,7 @@ const getSuperstakeEstimatedApr = ({ includeBorrowRateDelta ? new BN( Math.min(solAmount * LAMPORTS_PER_SOL, Number.MAX_SAFE_INTEGER) - ).neg() + ).neg() : ZERO ), PERCENTAGE_PRECISION_EXP diff --git a/react/src/actions/driftActions.ts b/react/src/actions/driftActions.ts index 87a2a7e0..422f566d 100644 --- a/react/src/actions/driftActions.ts +++ b/react/src/actions/driftActions.ts @@ -197,8 +197,9 @@ const createDriftActions = ( ) => { // This method seems pretty slow, is there a better way? // Nothing else I've tried is working... - const userAccounts = - await driftClient.getUserAccountsForAuthority(authority); + const userAccounts = await driftClient.getUserAccountsForAuthority( + authority + ); await Promise.all( userAccounts.map((account) => diff --git a/react/src/components/Tables/BodyCellWrapper.tsx b/react/src/components/Tables/BodyCellWrapper.tsx index 7392c76f..3bcf2fe0 100644 --- a/react/src/components/Tables/BodyCellWrapper.tsx +++ b/react/src/components/Tables/BodyCellWrapper.tsx @@ -40,8 +40,8 @@ export const BodyCellWrapper = ({ alignCenter ? 'items-center' : alignRight - ? 'items-end' - : 'items-start', + ? 'items-end' + : 'items-start', flexCol ? 'flex-col' : 'flex-row', innerClassName )} diff --git a/react/src/components/Tables/TableRowWrapper.tsx b/react/src/components/Tables/TableRowWrapper.tsx index 15de927a..815a828a 100644 --- a/react/src/components/Tables/TableRowWrapper.tsx +++ b/react/src/components/Tables/TableRowWrapper.tsx @@ -22,8 +22,8 @@ export const TableRowWrapper = ({ const borderClass = noBorder ? '' : strongBottomBorder - ? 'border-b-3 border-container-border' - : 'border-b border-container-border'; + ? 'border-b-3 border-container-border' + : 'border-b border-container-border'; const topBorderClass = topBorder ? 'border-t border-container-border' : ''; const lastChildClass = lastChildNoBorder ? 'last:border-b-0' : ''; @@ -33,7 +33,11 @@ export const TableRowWrapper = ({ className={twMerge( 'grid auto-rows-auto grid-flow-row [&>*]:text-left [&>*]:items-left [&>*]:justify-self-start', '[&>*]:text-left [&>*]:items-left [&>*]:justify-self-start first-of-type:[&>]:pl-4', - `[&>*]:last:pr-4 [&>*]:last:text-left [&>*]:last:items-left ${lastColumnJustify ? `[&>*]:last:justify-self-${lastColumnJustify}` : '[&>*]:last:justify-self-end'}`, + `[&>*]:last:pr-4 [&>*]:last:text-left [&>*]:last:items-left ${ + lastColumnJustify + ? `[&>*]:last:justify-self-${lastColumnJustify}` + : '[&>*]:last:justify-self-end' + }`, borderClass, topBorderClass, lastChildClass, diff --git a/react/src/hooks/charts/useGroupHistoricalPricesByAverage.ts b/react/src/hooks/charts/useGroupHistoricalPricesByAverage.ts index fcdfe096..bf3536f2 100644 --- a/react/src/hooks/charts/useGroupHistoricalPricesByAverage.ts +++ b/react/src/hooks/charts/useGroupHistoricalPricesByAverage.ts @@ -32,8 +32,8 @@ const groupHistoricalPricesByAverage = ( duration === HistoricalTokenPriceDuration.ONE_DAY ? 3 // 15 mins interval : duration === HistoricalTokenPriceDuration.ONE_WEEK - ? 2 // 2 hours interval - : 8; // 8 hours interval + ? 2 // 2 hours interval + : 8; // 8 hours interval // if the time of the first price is not at the start of the interval, e.g. XX:05 // we reduce the group size for the first interval, e.g. average of XX:05, XX:10 diff --git a/react/src/hooks/oraclePrice/useSyncOraclePriceStore.ts b/react/src/hooks/oraclePrice/useSyncOraclePriceStore.ts index 561c82b4..0369d41a 100644 --- a/react/src/hooks/oraclePrice/useSyncOraclePriceStore.ts +++ b/react/src/hooks/oraclePrice/useSyncOraclePriceStore.ts @@ -162,7 +162,7 @@ export const useSyncOraclePriceStore = ( ? BigNum.from( oraclePriceData.maxPrice, PRICE_PRECISION_EXP - ).toNum() + ).toNum() : undefined, }, rawPriceData: oraclePriceData, diff --git a/react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts b/react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts index f0ebfad4..28905deb 100644 --- a/react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts +++ b/react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts @@ -10,7 +10,7 @@ export const usePriorityFeesPollingRate = () => { const pollingFrequencyMs = isPriorityFeeStoreReady ? basePollingRateMs * - Math.max(pollingMultiplier, priorityFeePollingMultiplier) + Math.max(pollingMultiplier, priorityFeePollingMultiplier) : 1000; // poll more frequently until priority fee store is ready return pollingFrequencyMs; diff --git a/react/src/hooks/useCurrentRpc.tsx b/react/src/hooks/useCurrentRpc.tsx index f8cffe4d..81dd0a76 100644 --- a/react/src/hooks/useCurrentRpc.tsx +++ b/react/src/hooks/useCurrentRpc.tsx @@ -27,14 +27,14 @@ const _useCurrentRpc = () => { return [dedupedRpc, setSavedRpc] as [ RpcEndpoint, - (savedRpc: RpcEndpoint) => void, + (savedRpc: RpcEndpoint) => void ]; }; export const useCurrentRpc = singletonHook( [DEFAULT_MAINNET_RPC, () => {}] as [ RpcEndpoint, - (savedRpc: RpcEndpoint) => void, + (savedRpc: RpcEndpoint) => void ], _useCurrentRpc ); diff --git a/react/src/hooks/useInitializeConnection.tsx b/react/src/hooks/useInitializeConnection.tsx index 7b431229..774012b8 100644 --- a/react/src/hooks/useInitializeConnection.tsx +++ b/react/src/hooks/useInitializeConnection.tsx @@ -20,7 +20,7 @@ const useInitializeConnection = ( label: 'RPC Override', value: Env.rpcOverride, allowAdditionalConnection: false, - } + } : currentRpc; if (Env.isDev) { diff --git a/react/src/hooks/useRpcLatencies.tsx b/react/src/hooks/useRpcLatencies.tsx index c2e1a8da..b6808c5a 100644 --- a/react/src/hooks/useRpcLatencies.tsx +++ b/react/src/hooks/useRpcLatencies.tsx @@ -38,11 +38,11 @@ const useRpcLatencies = (rpcOptions: RpcEndpoint[]) => { const lastFiveLatencies = !rpc.latency ? [] : avgLatencies?.[rpc.value]?.lastFiveLatencies - ? [ - rpc.latency, - ...(avgLatencies?.[rpc.value]?.lastFiveLatencies || []), - ].slice(0, 5) - : [rpc.latency]; + ? [ + rpc.latency, + ...(avgLatencies?.[rpc.value]?.lastFiveLatencies || []), + ].slice(0, 5) + : [rpc.latency]; const avg = Math.ceil(average(lastFiveLatencies)); newLatencies[rpc.value] = { avg, lastFiveLatencies }; }); diff --git a/react/src/stores/priorityFee/useHeliusPriorityFees.ts b/react/src/stores/priorityFee/useHeliusPriorityFees.ts index 2e5dd2ff..0920e1c1 100644 --- a/react/src/stores/priorityFee/useHeliusPriorityFees.ts +++ b/react/src/stores/priorityFee/useHeliusPriorityFees.ts @@ -59,10 +59,10 @@ const getHeliusPriorityFeeEstimate = async ( targetPercentile > 75 ? 'veryHigh' : targetPercentile > 50 - ? 'high' - : targetPercentile > 25 - ? 'medium' - : 'low'; + ? 'high' + : targetPercentile > 25 + ? 'medium' + : 'low'; return result?.result?.priorityFeeLevels?.[resultToUse]; } catch (e) {