Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasDeco committed Dec 13, 2024
1 parent 279453b commit 9200c73
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 53 deletions.
12 changes: 8 additions & 4 deletions common-ts/src/EnvironmentConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[],
Expand Down
12 changes: 6 additions & 6 deletions common-ts/src/common-ui-utils/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}
}

Expand All @@ -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;
}
}

Expand Down
12 changes: 6 additions & 6 deletions common-ts/src/serializableTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const QuoteBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
QUOTE_PRECISION_EXP
)
)
: undefined;
const QuoteBigNumSerializeAndDeserializeFns = {
Serialize: QuoteBigNumSerializationFn,
Expand All @@ -123,7 +123,7 @@ const PctBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
PERCENTAGE_PRECISION_EXP
)
)
: undefined;

const PctBigNumSerializeAndDeserializeFns = {
Expand All @@ -142,7 +142,7 @@ const BaseBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
BASE_PRECISION_EXP
)
)
: undefined;
const BaseBigNumSerializeAndDeserializeFns = {
Serialize: BaseBigNumSerializationFn,
Expand All @@ -160,7 +160,7 @@ const PriceBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
PRICE_PRECISION_EXP
)
)
: undefined;
const PriceBigNumSerializeAndDeserializeFns = {
Serialize: PriceBigNumSerializationFn,
Expand All @@ -178,7 +178,7 @@ const FundingRateBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
PRICE_PRECISION_EXP
)
)
: undefined;
const FundingRateBigNumSerializeAndDeserializeFns = {
Serialize: FundingRateBigNumSerializationFn,
Expand All @@ -196,7 +196,7 @@ const BankCumulativeInterestBigNumDeserializationFn = (val: string) =>
? BigNum.from(
typeof val === 'string' ? val.replace('.', '') : val,
PRICE_PRECISION_EXP
)
)
: undefined;
const BankCumulativeInterestBigNumSerializeAndDeserializeFns = {
Serialize: BankCumulativeInterestBigNumSerializationFn,
Expand Down
5 changes: 1 addition & 4 deletions common-ts/src/types/MarketId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 1 addition & 4 deletions common-ts/src/types/UIMarket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion common-ts/src/utils/equalityChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type PropertyType =
export type PropertyAndType<KeyOfObject> = [
property: KeyOfObject,
type: PropertyType,
customEqualityFn?: (a: any, b: any) => boolean,
customEqualityFn?: (a: any, b: any) => boolean
];

const arePropertiesEqual = (
Expand Down
6 changes: 3 additions & 3 deletions common-ts/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ const getChronologicalValueForOrderAction = (action: OrderAction) => {
return matchEnum(action, OrderAction.PLACE)
? 0
: matchEnum(action, OrderAction.FILL)
? 1
: 2;
? 1
: 2;
};

/**
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion common-ts/src/utils/priority-fees/PriorityFeeStrategies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion common-ts/src/utils/superstake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions react/src/actions/driftActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) =>
Expand Down
4 changes: 2 additions & 2 deletions react/src/components/Tables/BodyCellWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
)}
Expand Down
10 changes: 7 additions & 3 deletions react/src/components/Tables/TableRowWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '';
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions react/src/hooks/charts/useGroupHistoricalPricesByAverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion react/src/hooks/oraclePrice/useSyncOraclePriceStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const useSyncOraclePriceStore = (
? BigNum.from(
oraclePriceData.maxPrice,
PRICE_PRECISION_EXP
).toNum()
).toNum()
: undefined,
},
rawPriceData: oraclePriceData,
Expand Down
2 changes: 1 addition & 1 deletion react/src/hooks/priorityFees/usePriorityFeesPollingRate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions react/src/hooks/useCurrentRpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
2 changes: 1 addition & 1 deletion react/src/hooks/useInitializeConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const useInitializeConnection = (
label: 'RPC Override',
value: Env.rpcOverride,
allowAdditionalConnection: false,
}
}
: currentRpc;

if (Env.isDev) {
Expand Down
10 changes: 5 additions & 5 deletions react/src/hooks/useRpcLatencies.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
});
Expand Down
8 changes: 4 additions & 4 deletions react/src/stores/priorityFee/useHeliusPriorityFees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9200c73

Please sign in to comment.