增加ETH(arbitrum)的支持

This commit is contained in:
CounterFire2023 2023-08-02 14:28:21 +08:00
parent a4e2cb14cd
commit 0c8eb08e3f
4 changed files with 7 additions and 4 deletions

View File

@ -135,7 +135,7 @@ class AlchemyController extends BaseController {
@router('get /pay/alchemy/can_i_buy_treasury') @router('get /pay/alchemy/can_i_buy_treasury')
async canIBuyEth(req, res) { async canIBuyEth(req, res) {
let user = req.user let user = req.user
let crypto = 'ETH' let crypto = process.env.CF_ETH_NAME
let today = new Date() let today = new Date()
today.setHours(0, 0, 0, 0) today.setHours(0, 0, 0, 0)
let count = await PayRecord.countDocuments({ let count = await PayRecord.countDocuments({

View File

@ -111,7 +111,7 @@ class AlchemyOutController extends BaseController {
} }
let price = await new PriceSvr().fetchPrice({ crypto: 'ETH', network: 'ARBITRUM', fiat: 'USD' }) let price = await new PriceSvr().fetchPrice({ crypto: 'ETH', network: 'ARBITRUM', fiat: 'USD' })
let priceToSend = '0.1' let priceToSend = '0.1'
if (crypto.toLowerCase() === 'eth') { if (crypto.toLowerCase() === 'eth' || crypto.toLowerCase() === process.env.CF_ETH_NAME.toLowerCase()) {
priceToSend = price + '' priceToSend = price + ''
} }
// 20230717 沟通, gas费需要换算成目标货币 // 20230717 沟通, gas费需要换算成目标货币

View File

@ -44,6 +44,8 @@ export class TransferQueue {
let address let address
if (token === 'agor') { if (token === 'agor') {
address = 'eth' address = 'eth'
} else if (token === 'eth') {
address = 'eth'
} else { } else {
let env = task.env ? task.env.toLowerCase() : 'dev' let env = task.env ? task.env.toLowerCase() : 'dev'
address = chainCfg.tokens[`${token}_${env}`] address = chainCfg.tokens[`${token}_${env}`]
@ -73,7 +75,7 @@ export class TransferQueue {
type: 3, type: 3,
}, },
] ]
if (token === 'agor' || token === 'eth') { if (token === 'agor' || token === 'eth' || token === process.env.CF_ETH_NAME.toLowerCase()) {
datas = [ datas = [
{ {
from: record.from, from: record.from,

View File

@ -231,7 +231,8 @@ export async function queryFiat() {
* @returns * @returns
*/ */
export async function calcNetworkFee(crypto: string, cryptoPrice: string, ethPrice?: string) { 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 // let gas = gas * 0.0000000001
const gasPriceArb = '100,000,000' // arbitrum one 上gasprice固定为0.1Gwei const gasPriceArb = '100,000,000' // arbitrum one 上gasprice固定为0.1Gwei
let eth = toBigInt(gasLimit) * toBigInt(gasPriceArb) let eth = toBigInt(gasLimit) * toBigInt(gasPriceArb)