Skip to content

Commit

Permalink
chore: lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fr0ntenddev committed Feb 25, 2023
1 parent c8202eb commit 55a260e
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 52 deletions.
3 changes: 2 additions & 1 deletion cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

import { getRedisClient } from './redis-utils/get-client'
import { RedisStore } from './store/redis-store'
import { currentTimestamp, CacheResponse } from './utils'
import type { CacheResponse } from './utils'
import { currentTimestamp } from './utils'

interface Options {
cacheSeconds: number
Expand Down
13 changes: 7 additions & 6 deletions scripts/aggregated/market-movement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,19 +212,20 @@ export async function getMarketMovement(

const vaultGlp = fsGlp_balanceOf_juniorVault + fsGlp_balanceOf_batchingManager

// (poolAmount - reserveAmount) + (shortSize / averagePrice)
const wethTokenWeight =
(wethPoolAmount - wethReservedAmounts) + (wethShortSizes / wethShortAveragePrice);
wethPoolAmount - wethReservedAmounts + wethShortSizes / wethShortAveragePrice

const wbtcTokenWeight =
(wbtcPoolAmount - wbtcReservedAmounts) + (wbtcShortSizes / wbtcShortAveragePrice);
wbtcPoolAmount - wbtcReservedAmounts + wbtcShortSizes / wbtcShortAveragePrice

const linkTokenWeight = linkPoolAmount
const uniTokenWeight = uniPoolAmount

const wethCurrentToken = (wethTokenWeight * vaultGlp / totalGLPSupply)
const wbtcCurrentToken = (wbtcTokenWeight * vaultGlp / totalGLPSupply)
const linkCurrentToken = (linkTokenWeight * vaultGlp / totalGLPSupply)
const uniCurrentToken = (uniTokenWeight * vaultGlp / totalGLPSupply)
const wethCurrentToken = (wethTokenWeight * vaultGlp) / totalGLPSupply
const wbtcCurrentToken = (wbtcTokenWeight * vaultGlp) / totalGLPSupply
const linkCurrentToken = (linkTokenWeight * vaultGlp) / totalGLPSupply
const uniCurrentToken = (uniTokenWeight * vaultGlp) / totalGLPSupply

return {
blockNumber: blockNumber,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults, tokens } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { DepositTokenEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxBatchingManager'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function depositToken(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { NetworkName } from '@ragetrade/sdk'
import { ethers } from 'ethers'

import { gmxProtocol } from '@ragetrade/sdk'
import { ethers } from 'ethers'

import { getLogs } from '../../../../../utils'
import { GET_LOGS_INTERVAL, getStartBlock, oneInFiftyBlocks } from './common'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { NetworkName } from '@ragetrade/sdk'
import { ethers } from 'ethers'

import { gmxProtocol } from '@ragetrade/sdk'
import { ethers } from 'ethers'

import { getLogs } from '../../../../../utils'
import { GET_LOGS_INTERVAL, getStartBlock, oneInFiftyBlocks } from './common'
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/junior-vault/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { DepositEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxJuniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function deposit(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/junior-vault/glp-swapped.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { GlpSwappedEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxJuniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function glpSwapped(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/junior-vault/rebalanced.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { RebalancedEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/interfaces/IDnGmxJuniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function rebalanced(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { RewardsHarvestedEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxJuniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function rewardsHarvested(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/junior-vault/withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { WithdrawEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxJuniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function withdraw(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/senior-vault/deposit.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { DepositEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxSeniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function deposit(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
5 changes: 2 additions & 3 deletions scripts/aggregated/util/events/senior-vault/withdraw.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults } from '@ragetrade/sdk'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

import type { WithdrawEvent } from '@ragetrade/sdk/dist/typechain/delta-neutral-gmx-vaults/contracts/vaults/DnGmxSeniorVault'
import type { ethers } from 'ethers'

import { ErrorWithStatusCode, getLogs } from '../../../../../utils'

export async function withdraw(
networkName: NetworkName,
provider: ethers.providers.Provider,
Expand Down
1 change: 0 additions & 1 deletion scripts/runner/per-interval-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { formatEther } from 'ethers/lib/utils'

import { getProviderAggregate } from '../../providers'
import { getLogs } from '../../utils'

import { parallelize } from '../aggregated/util/parallelize'

perInterval('arbmain').then((v) => console.log(JSON.stringify(v)))
Expand Down
4 changes: 2 additions & 2 deletions scripts/runner/per-interval-6.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { deltaNeutralGmxVaults, NetworkName } from '@ragetrade/sdk'
import { gmxProtocol, tokens } from '@ragetrade/sdk'
import type { NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults, gmxProtocol, tokens } from '@ragetrade/sdk'
import type { ethers } from 'ethers'
import { BigNumber } from 'ethers'
import { formatEther, formatUnits } from 'ethers/lib/utils'
Expand Down
1 change: 0 additions & 1 deletion scripts/runner/per-interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { getProviderAggregate } from '../../providers'
import { getLogs } from '../../utils'
import { juniorVault } from '../aggregated/util/events'
import { price } from '../aggregated/util/helpers'

import { parallelize } from '../aggregated/util/parallelize'
// import { juniorVault } from "./aggregated/util/events";
// import { getLogsInLoop, price } from "./util/helpers";
Expand Down
4 changes: 2 additions & 2 deletions scripts/v2/dn-gmx-vault-apy/borrow-rate.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'isomorphic-unfetch'

import { aave, NetworkName } from '@ragetrade/sdk'
import { deltaNeutralGmxVaults, typechain } from '@ragetrade/sdk'
import type { NetworkName } from '@ragetrade/sdk'
import { aave, deltaNeutralGmxVaults, typechain } from '@ragetrade/sdk'
import { formatUnits } from 'ethers/lib/utils'

import { getProvider } from '../../../providers'
Expand Down
11 changes: 5 additions & 6 deletions scripts/v2/dn-gmx-vault-apy/trader-pnl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'isomorphic-unfetch'

import type { NetworkName } from '@ragetrade/sdk'
import { fetchJson } from 'ethers/lib/utils'

import type {
Expand All @@ -8,7 +9,6 @@ import type {
VaultInfoResult
} from '../../aggregated'
import { combineStatsData } from '../../aggregated/util/combineStatsData'
import { NetworkName } from '@ragetrade/sdk'

export const getTraderPnl = async (networkName: NetworkName) => {
const { result: glpPnl }: { result: GlobalGlpPnlResult } = await fetchJson({
Expand Down Expand Up @@ -44,12 +44,11 @@ export const getTraderPnl = async (networkName: NetworkName) => {
}
)

const data = vaultInfo.data
.map((entry) => {
const foundDay = combined.find((d) => d.Day === entry.timestamp)
const data = vaultInfo.data.map((entry) => {
const foundDay = combined.find((d) => d.Day === entry.timestamp)

return (foundDay?.totalTraderPnL || 0) / entry.juniorVaultInfo.vaultMarketValue
})
return (foundDay?.totalTraderPnL || 0) / entry.juniorVaultInfo.vaultMarketValue
})

const dataSum = data
.filter((num) => !Number.isNaN(num) && Number.isFinite(num))
Expand Down
3 changes: 1 addition & 2 deletions store/redis-store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Debugger from 'debug'
import type { Redis } from 'ioredis'

import { isCacheExpired, isCacheResponse, years } from '../utils'
import { BaseStore } from './base-store'

import type { Redis } from 'ioredis'

const debug = Debugger('apis:redis-store')

export class RedisStore extends BaseStore {
Expand Down
9 changes: 6 additions & 3 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ import {
getNetworkName as getNetworkNameSdk,
getVaultName as getVaultNameSdk
} from '@ragetrade/sdk'
import type {
TypedEvent,
TypedEventFilter
} from '@ragetrade/sdk/dist/typechain/core/common'
import type { BigNumber, EventFilter } from 'ethers'
import { ethers } from 'ethers'
import { fetchJson, getAddress, isAddress } from 'ethers/lib/utils'
Expand All @@ -13,7 +17,6 @@ import type { Request } from 'express'
import createError from 'http-errors'

import { ENV } from './env'
import { TypedEvent, TypedEventFilter } from '@ragetrade/sdk/dist/typechain/core/common'

export const secs = 1
export const mins = 60
Expand Down Expand Up @@ -295,7 +298,7 @@ export async function getLogs(
_fetchedBlock = _toBlock
// next getLogs query range

let newToBlock = Math.min(
const newToBlock = Math.min(
toBlock,
_toBlock + 2 * roundNumber(_toBlock - _fromBlock + 1)
)
Expand All @@ -304,7 +307,7 @@ export async function getLogs(
} catch (e: any) {
if (typeof e?.message === 'string') {
// if error message contains a block range, use that as the new toBlock
let [, fromBlockStr, toBlockStr] = e.message.match(
const [, fromBlockStr, toBlockStr] = e.message.match(
/\[(0x[0-9a-fA-F]+), (0x[0-9a-fA-F]+)\]/
)
console.log('match', fromBlockStr, toBlockStr)
Expand Down

0 comments on commit 55a260e

Please sign in to comment.