Skip to content

Commit

Permalink
fix: getResourcePrices Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mindrunner committed Mar 20, 2024
1 parent 49ccb7a commit beeee93
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/lib/check-r4-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/check-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { checkR4Transactions } from './check-r4-transactions'
export const checkTransactions = async (): Promise<void> => {
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)}`)
Expand Down
4 changes: 2 additions & 2 deletions src/lib/get-price.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Big> => {
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)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/refill-strategy/full-refill-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ export const fullRefillStrategy: RefillStrategy = shipStakingInfos =>
return {
shipStakingInfo,
amount,
price: await getPrice(amount)
price: getPrice(amount)
} as FleetRefill
}))
2 changes: 1 addition & 1 deletion src/lib/refill-strategy/optimal-refill-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const optimalRefillStrategy: RefillStrategy = async (shipStakingInfos) =>
return {
shipStakingInfo,
amount,
price: await getPrice(amount)
price: getPrice(amount)
} as FleetRefill
}))
}
2 changes: 1 addition & 1 deletion src/lib/stock-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const stockResources = async (): Promise<void> => {
}

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)
Expand Down

0 comments on commit beeee93

Please sign in to comment.