Skip to content
This repository has been archived by the owner on Aug 15, 2023. It is now read-only.

fix: eslint issues #110

Merged
merged 4 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@ dealer-check-code:
yarn dealer eslint-check
yarn dealer build

dealer-watch-compile:
$(BIN_DIR)/tsc -p ./dealer/tsconfig-build.json --watch --noEmit --skipLibCheck

dealer-unit-in-ci:
. ./.envrc && yarn dealer ci:test:unit
6 changes: 6 additions & 0 deletions dealer/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../eslintrc.base.json",
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }]
}
}
35 changes: 17 additions & 18 deletions dealer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,47 +31,46 @@
},
"dependencies": {
"@apollo/client": "^3.5.8",
"@galoymoney/client": "^0.1.10",
"@galoymoney/client": "0.1.21",
"@grpc/grpc-js": "^1.5.3",
"@opentelemetry/api": "^1.0.2",
"@opentelemetry/core": "^1.0.0",
"@opentelemetry/exporter-jaeger": "^1.0.0",
"@opentelemetry/instrumentation": "^0.27.0",
"@opentelemetry/instrumentation-graphql": "^0.27.3",
"@opentelemetry/instrumentation-grpc": "^0.27.0",
"@opentelemetry/instrumentation-http": "^0.27.0",
"@opentelemetry/instrumentation-ioredis": "^0.27.0",
"@opentelemetry/instrumentation-pg": "^0.28.0",
"@opentelemetry/instrumentation": "^0.30.0",
"@opentelemetry/instrumentation-graphql": "^0.29.0",
"@opentelemetry/instrumentation-grpc": "^0.30.0",
"@opentelemetry/instrumentation-http": "^0.30.0",
"@opentelemetry/instrumentation-ioredis": "^0.30.0",
"@opentelemetry/instrumentation-pg": "^0.30.0",
"@opentelemetry/resources": "^1.0.0",
"@opentelemetry/sdk-trace-base": "^1.0.0",
"@opentelemetry/sdk-trace-node": "^1.0.0",
"@opentelemetry/semantic-conventions": "^1.0.0",
"@profusion/apollo-validation-directives": "^2.1.5",
"apollo-server-errors": "^2.5.0",
"apollo-server-express": "^2.25.2",
"apollo-server-errors": "^3.3.1",
"apollo-server-express": "^3.9.0",
"black-scholes-model": "^1.0.10",
"ccxt": "^1.78.5",
"csv-parse": "^4.16.0",
"dateformat": "^4.5.1",
"dotenv": "^10.0.0",
"cross-fetch": "^3.1.5",
"csv-parse": "^5.2.2",
"dotenv": "^16.0.1",
"express": "^4.17.1",
"google-protobuf": "^3.19.4",
"graphql": "^15.5.1",
"graphql": "^16.5.0",
"graphql-middleware": "^6.1.3",
"graphql-tools": "^8.1.0",
"humps": "^2.0.1",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"node-cron": "^3.0.0",
"node-fetch": "^2.6.1",
"node-fetch": "^3.2.6",
"node-pg-migrate": "^6.0.0",
"pg": "^8.7.1",
"pg-promise": "^10.11.0",
"pino": "^7.0.0-rc.1",
"pino-http": "^5.6.0",
"prom-client": "^13.2.0",
"pino": "^8.1.0",
"pino-http": "^8.1.1",
"prom-client": "^14.0.1",
"ts-md5": "^1.2.10",
"typescript": "^4.5.5",
"uuid": "^8.3.2"
}
}
1 change: 1 addition & 0 deletions dealer/src/Dealer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pino from "pino"

import { yamlConfig } from "./config"
import { Result } from "./Result"
import { btc2sat, roundBtc } from "./utils"
Expand Down
9 changes: 5 additions & 4 deletions dealer/src/DealerRemoteWallet.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ErrorLevel, Result } from "./Result"
import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import "cross-fetch/polyfill" // The Apollo client depends on fetch
import {
ApolloClient,
NormalizedCacheObject,
createHttpLink,
gql,
InMemoryCache,
} from "@apollo/client/core"
import fetch from "node-fetch"
import { pino } from "pino"

import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import { ErrorLevel, Result } from "./Result"
import { cents2usd, sat2btc } from "./utils"
import {
addAttributesToCurrentSpan,
Expand Down Expand Up @@ -82,7 +83,7 @@ export class DealerRemoteWallet implements GaloyWallet {

constructor(logger: pino.Logger) {
const GRAPHQL_URI = process.env["GRAPHQL_URI"]
const httpLink = createHttpLink({ uri: GRAPHQL_URI, fetch })
const httpLink = createHttpLink({ uri: GRAPHQL_URI })
const cache = new InMemoryCache(IN_MEMORY_CACHE_CONFIG)
this.client = new ApolloClient({ link: httpLink, cache: cache })
this.logger = logger.child({ class: DealerRemoteWallet.name })
Expand Down
4 changes: 2 additions & 2 deletions dealer/src/DealerRemoteWalletV2.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "cross-fetch/polyfill" // The Apollo client depends on fetch
import {
ApolloClient,
NormalizedCacheObject,
Expand All @@ -7,7 +8,6 @@ import {
gql,
} from "@apollo/client/core"
import { setContext } from "@apollo/client/link/context"
import fetch from "node-fetch"
import { pino } from "pino"

import { QUERIES, MUTATIONS } from "@galoymoney/client"
Expand Down Expand Up @@ -47,7 +47,7 @@ export class DealerRemoteWalletV2 implements GaloyWallet {

constructor(logger: pino.Logger) {
const GRAPHQL_URI = process.env["GRAPHQL_URI"]
this.httpLink = createHttpLink({ uri: GRAPHQL_URI, fetch })
this.httpLink = createHttpLink({ uri: GRAPHQL_URI })
const cache = new InMemoryCache()
this.client = new ApolloClient({ link: this.httpLink, cache: cache })
this.logger = logger.child({ class: DealerRemoteWalletV2.name })
Expand Down
9 changes: 5 additions & 4 deletions dealer/src/DealerSimulatedWallet.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { ErrorLevel, Result } from "./Result"
import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import "cross-fetch/polyfill" // The Apollo client depends on fetch
import {
ApolloClient,
NormalizedCacheObject,
createHttpLink,
gql,
InMemoryCache,
} from "@apollo/client/core"
import fetch from "node-fetch"
import { pino } from "pino"

import { GaloyWallet, WalletsBalances } from "./GaloyWalletTypes"
import { ErrorLevel, Result } from "./Result"
import { cents2usd, sat2btc } from "./utils"
import {
addAttributesToCurrentSpan,
Expand Down Expand Up @@ -82,7 +83,7 @@ export class DealerSimulatedWallet implements GaloyWallet {

constructor(logger: pino.Logger) {
const GRAPHQL_URI = process.env["GRAPHQL_URI"]
const httpLink = createHttpLink({ uri: GRAPHQL_URI, fetch })
const httpLink = createHttpLink({ uri: GRAPHQL_URI })
const cache = new InMemoryCache(IN_MEMORY_CACHE_CONFIG)
this.client = new ApolloClient({ link: httpLink, cache: cache })
this.logger = logger.child({ class: DealerSimulatedWallet.name })
Expand Down
11 changes: 7 additions & 4 deletions dealer/src/ExchangeBase.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import ccxt, { ExchangeId } from "ccxt"

import pino from "pino"

import {
FetchDepositAddressResult,
WithdrawParameters,
Expand Down Expand Up @@ -33,9 +37,8 @@ import {
GetFundingRateHistoryResult,
} from "./ExchangeTradingType"
import { ErrorLevel, Result } from "./Result"
import ccxt, { ExchangeId } from "ccxt"
import { ExchangeConfiguration, Headers } from "./ExchangeConfiguration"
import pino from "pino"

import {
addAttributesToCurrentSpan,
asyncRunInSpan,
Expand Down Expand Up @@ -161,7 +164,7 @@ export abstract class ExchangeBase {
}

private async fetchDepositsAllPages(args: FetchDepositsParameters) {
return await asyncRunInSpan(
return asyncRunInSpan(
"app.exchangeBase.fetchDepositsAllPages",
{
[SemanticAttributes.CODE_FUNCTION]: "fetchDepositsAllPages",
Expand Down Expand Up @@ -342,7 +345,7 @@ export abstract class ExchangeBase {
}

private async fetchWithdrawalsAllPages(args: FetchWithdrawalsParameters) {
return await asyncRunInSpan(
return asyncRunInSpan(
"app.exchangeBase.fetchWithdrawalsAllPages",
{
[SemanticAttributes.CODE_FUNCTION]: "fetchWithdrawalsAllPages",
Expand Down
1 change: 1 addition & 0 deletions dealer/src/ExchangeTradingType.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Params } from "ccxt"

import { FundingRate, Transaction } from "./database/models"

export enum TradeCurrency {
Expand Down
11 changes: 7 additions & 4 deletions dealer/src/OkexExchange.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import assert from "assert"

import pino from "pino"

import {
GetAccountAndPositionRiskResult,
GetInstrumentDetailsResult,
Expand All @@ -16,7 +20,6 @@ import {
GetFundingRateHistoryResult,
GetFundingRateHistoryParameters,
} from "./ExchangeTradingType"
import assert from "assert"
import { ExchangeBase } from "./ExchangeBase"
import {
ExchangeConfiguration,
Expand All @@ -25,7 +28,7 @@ import {
} from "./ExchangeConfiguration"
import { OkexExchangeConfiguration } from "./OkexExchangeConfiguration"
import { ErrorLevel, Result } from "./Result"
import pino from "pino"

import { ExchangeNames, FundingRate, Transaction } from "./database/models"
import { sleep } from "./utils"
import {
Expand Down Expand Up @@ -642,7 +645,7 @@ export class OkexExchange extends ExchangeBase {

try {
if (apiResponse?.data) {
for (const rawTransaction of apiResponse?.data) {
for (const rawTransaction of apiResponse.data) {
const transaction: Transaction = {
balance: Number(rawTransaction.bal),
balanceChange: Number(rawTransaction.balChg),
Expand Down Expand Up @@ -834,7 +837,7 @@ export class OkexExchange extends ExchangeBase {

try {
if (apiResponse?.data) {
for (const rawFundingRate of apiResponse?.data) {
for (const rawFundingRate of apiResponse.data) {
const fundingRate: FundingRate = {
fundingRate: Number(rawFundingRate.fundingRate),
instrumentId: rawFundingRate.instId,
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/OkexExchangeConfiguration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import assert from "assert"

import {
FetchDepositAddressResult,
WithdrawParameters,
Expand All @@ -17,7 +19,6 @@ import {
FetchWithdrawalsParameters,
TransferParameters,
} from "./ExchangeTradingType"
import assert from "assert"
import {
ExchangeConfiguration,
SupportedExchange,
Expand Down
15 changes: 10 additions & 5 deletions dealer/src/OkexPerpetualSwapStrategy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import pino from "pino"

import { floorBtc, roundBtc, sleep } from "./utils"
import { yamlConfig } from "./config"
import { ErrorLevel, Result } from "./Result"
Expand Down Expand Up @@ -32,7 +34,6 @@ import {
DestinationAddressType,
} from "./OkexExchangeConfiguration"
import { AccountTypeToId, OkexExchange } from "./OkexExchange"
import pino from "pino"

import {
ExternalTransfer,
Expand Down Expand Up @@ -149,17 +150,17 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
}

public async getDerivativeMarketInfo(): Promise<Result<FetchTickerResult>> {
return await this.exchange.fetchTicker(SupportedInstrument.OKEX_PERPETUAL_SWAP)
return this.exchange.fetchTicker(SupportedInstrument.OKEX_PERPETUAL_SWAP)
}

public async getFundingAccountBalance(): Promise<
Result<FetchFundingAccountBalanceResult>
> {
return await this.exchange.fetchFundingAccountBalance()
return this.exchange.fetchFundingAccountBalance()
}

public async fetchExchangeStatus(): Promise<Result<boolean>> {
return await this.exchange.fetchExchangeStatus()
return this.exchange.fetchExchangeStatus()
}

public async fetchTransactionHistory(
Expand Down Expand Up @@ -573,7 +574,11 @@ export class OkexPerpetualSwapStrategy implements HedgingStrategy {
withdrawArgs.quantity,
)
this.logger.debug(
{ withdrawOnChainAddress, transferSizeInBtc: withdrawArgs.quantity, bookingResult },
{
withdrawOnChainAddress,
transferSizeInBtc: withdrawArgs.quantity,
bookingResult,
},
"withdrawBookKeepingCallback() returned: {bookingResult}",
)
if (!bookingResult.ok) {
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/app/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { wrapAsyncToRunInSpan } from "../services/tracing"

// import * as DealerMod from "../Dealer"
import * as schedulerMod from "./scheduler"
import * as exporterMod from "../servers/exporter/exporter"
import * as priceServiceMod from "../servers/price"

import { baseLogger } from "../services/logger"

import * as schedulerMod from "./scheduler"
const logger = baseLogger.child({ module: "wrapper" })

const allFunctions = {
Expand Down
3 changes: 2 additions & 1 deletion dealer/src/app/scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { baseLogger } from "../services/logger"
import cron from "node-cron"

import { baseLogger } from "../services/logger"
import { Dealer } from "../Dealer"
import { recordExceptionInCurrentSpan, wrapAsyncToRunInSpan } from "../services/tracing"
import { ErrorLevel } from "../Result"
Expand Down
4 changes: 2 additions & 2 deletions dealer/src/app/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { baseLogger } from "../services/logger"
// import { scheduler } from "./scheduler"
// import { priceService } from "../servers/price"

import { exporter, scheduler, priceService } from "."

import {
addAttributesToCurrentSpan,
SemanticAttributes,
wrapAsyncToRunInSpan,
} from "../services/tracing"

import { exporter, scheduler, priceService } from "."

const logger = baseLogger.child({ module: "cron" })

const options = {
Expand Down
Loading