Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/store conf #140

Merged
merged 10 commits into from
Feb 19, 2023
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
2 changes: 1 addition & 1 deletion ocean-client/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class contexTimer {
return 15000 * 60 - (Date.now() - this.start)
} //on AWS max. 15 min execution time
}
process.env.VAULTMAXI_LOGID = process.env.VAULTMAXI_LOGID ?? 'on ' + os.hostname()

const myArgs = process.argv.slice(2)
var event = undefined
if (!(myArgs.length > 0 && myArgs[0] == 'run')) event = { overrideSettings: undefined, checkSetup: true }
Expand Down
17 changes: 17 additions & 0 deletions ocean-client/src/utils/store_config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { ProgramStateConverter, ProgramStateInformation } from './program-state-converter'
import { IReinvestSettings } from './reinvestor'
import { IStore, StoredSettings } from './store'
import fs from 'fs'
import { IStoreMaxi, StoredMaxiSettings } from './store_aws_maxi'
import { LogLevel, logLevelFromParam, TelegramSettings } from './telegram'
import os from 'os'

// handle Parameter in local config on Linux and Windows
export class StoreConfig implements IStoreMaxi {
Expand Down Expand Up @@ -60,6 +63,11 @@ export class StoreConfig implements IStoreMaxi {
}

async fetchSettings(): Promise<StoredMaxiSettings> {
let logId: string | undefined
if (this.config.logId != "") {
logId = this.config.logId
}
this.settings.logId = process.env.VAULTMAXI_LOGID ?? logId ?? 'on ' + os.hostname()
this.settings.chatId = this.config.chatId
this.settings.token = this.config.token
this.settings.logChatId = this.config.logChatId
Expand All @@ -75,15 +83,20 @@ export class StoreConfig implements IStoreMaxi {
this.settings.LMPair = lmPair
this.settings.mainCollateralAsset = this.config.mainCollateralAsset
this.settings.reinvestThreshold = this.config.reinvestThreshold
this.settings.reinvestPattern = this.config.reinvestPattern
this.settings.stableCoinArbBatchSize = this.config.stableArbBatchSize ?? -1
this.settings.stateInformation = ProgramStateConverter.fromValue(this.GetFirstLine(this.statefile))
let seedList = this.GetFirstLine(this.config.seedfile).replace(/[ ,]+/g, ' ')
this.settings.seed = seedList?.trim().split(' ') ?? []
this.settings.autoDonationPercentOfReinvest = this.config.AutoDonationPercent
this.settings.oceanUrl = this.config.oceanUrl
this.settings.logLevel = logLevelFromParam(this.config.logLevel)
return this.settings
}
}

class ConfigFile {
logId: string = ''
chatId: string = ''
token: string = ''
logChatId: string = ''
Expand All @@ -97,5 +110,9 @@ class ConfigFile {
LMPair: string | undefined
mainCollateralAsset: string = 'DFI'
reinvestThreshold: number | undefined = 0
reinvestPattern: string = ''
stableArbBatchSize: number | undefined = -1
AutoDonationPercent: number = 0
oceanUrl: string = ''
logLevel: string = 'INFO'
}