This commit is contained in:
aozhiwei 2024-08-23 16:58:14 +08:00
parent f7395cc45c
commit 993bc9bbe7
3 changed files with 15 additions and 7 deletions

View File

@ -2,11 +2,11 @@
{
"currency_name": "USDC",
"contract_name": "BEUSDC",
"currency_decimal": 6
"currency_decimal": 18
},
{
"currency_name": "USDT",
"contract_name": "BEUSDT",
"currency_decimal": 6
"currency_decimal": 18
}
]

View File

@ -25,6 +25,7 @@ const (
RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100
RECHARGE_CURRENCY_MAX_DECIMAL = 6
RECHARGE_CURRENCY_MAX_BUY_NUM = 9999
BNB_RECHARGE_CURRENCY_MAX_DECIMAL = 18
)
const (

View File

@ -43,14 +43,21 @@ func (this *Currency) GetContract() *Contract {
return this.contract
}
func (this *Currency) check() {
func (this *Currency) check(netId int32) {
if this.GetCurrencyDecimal() <= 0 {
panic("Currency currency_decimal <= 0")
return
}
if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL {
panic("Currency exchange_rate > uplimit")
return
if netId == 56 || netId == 97 {
if this.GetCurrencyDecimal() != constant.BNB_RECHARGE_CURRENCY_MAX_DECIMAL {
panic("Currency exchange_rate > uplimit")
return
}
} else {
if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL {
panic("Currency exchange_rate > uplimit")
return
}
}
}
@ -109,7 +116,7 @@ func (this *CurrencyTable) Load() {
for _, currencyCfg := range currencysCfg {
p := new(Currency)
p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal)
p.check()
p.check(netId)
currencysMeta := this.GetByNetId(netId)
if currencysMeta == nil {
currencysMeta = new(q5.ConcurrentMap[string, *Currency])