From beeee93f7d5ab6657425d7efb5f38a683e5eb5b1 Mon Sep 17 00:00:00 2001 From: lukas Date: Wed, 20 Mar 2024 01:00:12 +0100 Subject: [PATCH] fix: getResourcePrices Sync --- src/lib/check-r4-transactions.ts | 2 +- src/lib/check-transactions.ts | 2 +- src/lib/get-price.ts | 4 ++-- src/lib/refill-strategy/full-refill-strategy.ts | 2 +- src/lib/refill-strategy/optimal-refill-strategy.ts | 2 +- src/lib/stock-resources.ts | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/check-r4-transactions.ts b/src/lib/check-r4-transactions.ts index c87f8552..6b02dde2 100644 --- a/src/lib/check-r4-transactions.ts +++ b/src/lib/check-r4-transactions.ts @@ -74,7 +74,7 @@ export const checkR4Transactions = async ( amounts[resourceName] = Big(originalAmount) // eslint-disable-next-line no-await-in-loop - const price = await getPrice(amounts, prices) + const price = getPrice(amounts, prices) // eslint-disable-next-line max-depth if (sender === keyPair.publicKey.toString()) { diff --git a/src/lib/check-transactions.ts b/src/lib/check-transactions.ts index b9026e8d..099a8b48 100644 --- a/src/lib/check-transactions.ts +++ b/src/lib/check-transactions.ts @@ -13,7 +13,7 @@ import { checkR4Transactions } from './check-r4-transactions' export const checkTransactions = async (): Promise => { await initOrderBook() const atlasBalance = await getBalanceAtlas(keyPair.publicKey) - const prices = await getResourcePrices() + const prices = getResourcePrices() const resources = await getResourceBalances(keyPair.publicKey) logger.info(`ATLAS balance: ${atlasBalance.toFixed(AD)}`) diff --git a/src/lib/get-price.ts b/src/lib/get-price.ts index 184a29e6..0616bf88 100644 --- a/src/lib/get-price.ts +++ b/src/lib/get-price.ts @@ -3,8 +3,8 @@ import Big from 'big.js' import { Amounts } from '../service/fleet/const' import { getResourcePrices } from '../service/gm' -export const getPrice = async (amount: Amounts, price?: Amounts): Promise => { - const p: Amounts = price ? price : await getResourcePrices() +export const getPrice = (amount: Amounts, price?: Amounts): Big => { + const p: Amounts = price ? price : getResourcePrices() const totalFuelPrice = amount.fuel.mul(p.fuel) const totalFoodPrice = amount.food.mul(p.food) const totalAmmoPrice = amount.ammo.mul(p.ammo) diff --git a/src/lib/refill-strategy/full-refill-strategy.ts b/src/lib/refill-strategy/full-refill-strategy.ts index 6d6a2eb7..b1c5d9a1 100644 --- a/src/lib/refill-strategy/full-refill-strategy.ts +++ b/src/lib/refill-strategy/full-refill-strategy.ts @@ -33,6 +33,6 @@ export const fullRefillStrategy: RefillStrategy = shipStakingInfos => return { shipStakingInfo, amount, - price: await getPrice(amount) + price: getPrice(amount) } as FleetRefill })) diff --git a/src/lib/refill-strategy/optimal-refill-strategy.ts b/src/lib/refill-strategy/optimal-refill-strategy.ts index c3715793..2a1f7718 100644 --- a/src/lib/refill-strategy/optimal-refill-strategy.ts +++ b/src/lib/refill-strategy/optimal-refill-strategy.ts @@ -62,7 +62,7 @@ export const optimalRefillStrategy: RefillStrategy = async (shipStakingInfos) => return { shipStakingInfo, amount, - price: await getPrice(amount) + price: getPrice(amount) } as FleetRefill })) } diff --git a/src/lib/stock-resources.ts b/src/lib/stock-resources.ts index 8766c670..da0b4a44 100644 --- a/src/lib/stock-resources.ts +++ b/src/lib/stock-resources.ts @@ -174,7 +174,7 @@ export const stockResources = async (): Promise => { } if (amount.food.gt(0) || amount.ammo.gt(0) || amount.fuel.gt(0) || amount.tool.gt(0)) { - const price = await getResourcePrices() + const price = getResourcePrices() const totalFuelPrice = amount.fuel.mul(price.fuel) const totalFoodPrice = amount.food.mul(price.food) const totalAmmoPrice = amount.ammo.mul(price.ammo)