修改充值流程,扣除networkFee后再转账
This commit is contained in:
parent
508574b816
commit
9799a86817
@ -10,6 +10,7 @@ import { reportPayResult } from 'service/game.svr'
|
||||
import { PriceSvr } from 'service/price.svr'
|
||||
import { OrderCacheSvr } from 'service/ordercache.svr'
|
||||
import { GasSvr } from 'service/gas.svr'
|
||||
import { parse } from 'dotenv'
|
||||
|
||||
let errorRes = function (msg: string) {
|
||||
logger.info(`error res: ${msg}`)
|
||||
@ -188,6 +189,13 @@ class AlchemyOutController extends BaseController {
|
||||
}
|
||||
record.cryptoAmount =
|
||||
record.network.toLowerCase() === 'agor' && record.crypto.toLowerCase() === 'agor' ? '0.001' : cryptoAmount
|
||||
let gas = await new GasSvr().estimateGas({ crypto, network: 'ARBITRUM' })
|
||||
gas = gas * 0.0000000001
|
||||
// 20230718 沟通, cryptoAmount包含了gas费, 需要减去后再发送
|
||||
let networkFee = gas
|
||||
let price = await new PriceSvr().fetchPrice({ crypto: 'ETH', network: 'ARBITRUM', fiat: 'USD' })
|
||||
networkFee = (networkFee * parseFloat(price)) / parseFloat(cryptoPrice)
|
||||
record.cryptoSend = (parseFloat(cryptoAmount) - networkFee).toFixed(10)
|
||||
record.cryptoPrice = cryptoPrice
|
||||
record.usdtAdmount = usdtAmount
|
||||
await record.save()
|
||||
|
@ -54,9 +54,12 @@ export class PayRecordClass extends BaseModule {
|
||||
// 法币数量
|
||||
@prop()
|
||||
public fiatAmount?: string
|
||||
// 加密货币数量, 实际转账金额
|
||||
// 加密货币数量,
|
||||
@prop()
|
||||
public cryptoAmount?: string
|
||||
// 实际转账金额
|
||||
@prop()
|
||||
public cryptoSend?: string
|
||||
|
||||
// 开始创建记录时, 估算的可获取加密货币数量
|
||||
@prop()
|
||||
|
@ -58,7 +58,7 @@ export class TransferQueue {
|
||||
contract: address,
|
||||
to: task.address,
|
||||
from: wallet,
|
||||
amount: task.cryptoAmount,
|
||||
amount: task.cryptoSend,
|
||||
$inc: { version: 1 },
|
||||
},
|
||||
)
|
||||
@ -73,7 +73,7 @@ export class TransferQueue {
|
||||
type: 3,
|
||||
},
|
||||
]
|
||||
if (token === 'agor') {
|
||||
if (token === 'agor' || token === 'eth') {
|
||||
datas = [
|
||||
{
|
||||
from: record.from,
|
||||
|
Loading…
x
Reference in New Issue
Block a user