From 0c8eb08e3f8a087af0dd2c8dc6e229cd0cfda868 Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Wed, 2 Aug 2023 14:28:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ETH(arbitrum)=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/alchemy.controller.ts | 2 +- src/controllers/alchemyout.controller.ts | 2 +- src/queue/transfer.queue.ts | 4 +++- src/service/alchemy.svr.ts | 3 ++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/controllers/alchemy.controller.ts b/src/controllers/alchemy.controller.ts index b08d02a..2306942 100644 --- a/src/controllers/alchemy.controller.ts +++ b/src/controllers/alchemy.controller.ts @@ -135,7 +135,7 @@ class AlchemyController extends BaseController { @router('get /pay/alchemy/can_i_buy_treasury') async canIBuyEth(req, res) { let user = req.user - let crypto = 'ETH' + let crypto = process.env.CF_ETH_NAME let today = new Date() today.setHours(0, 0, 0, 0) let count = await PayRecord.countDocuments({ diff --git a/src/controllers/alchemyout.controller.ts b/src/controllers/alchemyout.controller.ts index 5abb8a8..6f1db3a 100644 --- a/src/controllers/alchemyout.controller.ts +++ b/src/controllers/alchemyout.controller.ts @@ -111,7 +111,7 @@ class AlchemyOutController extends BaseController { } let price = await new PriceSvr().fetchPrice({ crypto: 'ETH', network: 'ARBITRUM', fiat: 'USD' }) let priceToSend = '0.1' - if (crypto.toLowerCase() === 'eth') { + if (crypto.toLowerCase() === 'eth' || crypto.toLowerCase() === process.env.CF_ETH_NAME.toLowerCase()) { priceToSend = price + '' } // 20230717 沟通, gas费需要换算成目标货币 diff --git a/src/queue/transfer.queue.ts b/src/queue/transfer.queue.ts index 982bdef..9a6402c 100644 --- a/src/queue/transfer.queue.ts +++ b/src/queue/transfer.queue.ts @@ -44,6 +44,8 @@ export class TransferQueue { let address if (token === 'agor') { address = 'eth' + } else if (token === 'eth') { + address = 'eth' } else { let env = task.env ? task.env.toLowerCase() : 'dev' address = chainCfg.tokens[`${token}_${env}`] @@ -73,7 +75,7 @@ export class TransferQueue { type: 3, }, ] - if (token === 'agor' || token === 'eth') { + if (token === 'agor' || token === 'eth' || token === process.env.CF_ETH_NAME.toLowerCase()) { datas = [ { from: record.from, diff --git a/src/service/alchemy.svr.ts b/src/service/alchemy.svr.ts index 33cf4f2..0dfdcba 100644 --- a/src/service/alchemy.svr.ts +++ b/src/service/alchemy.svr.ts @@ -231,7 +231,8 @@ export async function queryFiat() { * @returns */ export async function calcNetworkFee(crypto: string, cryptoPrice: string, ethPrice?: string) { - let gasLimit = await new GasSvr().estimateGas({ crypto, network: 'ARBITRUM' }) + let tmp = crypto.toLowerCase() === process.env.CF_ETH_NAME.toLowerCase() ? 'ETH' : crypto + let gasLimit = await new GasSvr().estimateGas({ crypto: tmp, network: 'ARBITRUM' }) // let gas = gas * 0.0000000001 const gasPriceArb = '100,000,000' // arbitrum one 上gasprice固定为0.1Gwei let eth = toBigInt(gasLimit) * toBigInt(gasPriceArb)