1
This commit is contained in:
parent
7f288800e2
commit
b9066d9939
@ -2,21 +2,25 @@
|
||||
{
|
||||
"name": "Ethereum",
|
||||
"contract_address": "0xe9E96d1aad82562b7588F03f49aD34186f996478",
|
||||
"decimals": 18,
|
||||
"current_price": 3371.1
|
||||
},
|
||||
{
|
||||
"name": "USDC",
|
||||
"contract_address": "0x3b2d8a1931736fc321c24864bceee981b11c3c57",
|
||||
"decimals": 6,
|
||||
"current_price": 0.999334
|
||||
},
|
||||
{
|
||||
"name": "Immutable",
|
||||
"contract_address": "0x1ccca691501174b4a623ceda58cc8f1a76dc3439",
|
||||
"decimals": 18,
|
||||
"current_price": 1.54
|
||||
},
|
||||
{
|
||||
"name": "NATIVE",
|
||||
"contract_address": "0xFd42bfb03212dA7e1A4608a44d7658641D99CF34",
|
||||
"current_price": 1.54
|
||||
"decimals": 18,
|
||||
"current_price": 3371.1
|
||||
}
|
||||
]
|
||||
|
@ -99,6 +99,7 @@ type BcCurrency struct {
|
||||
name string
|
||||
contract_address string
|
||||
current_price float64
|
||||
decimals int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
@ -492,6 +493,14 @@ func (this *BcCurrency) HasCurrentPrice() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
func (this *BcCurrency) GetDecimals() int32 {
|
||||
return this.decimals
|
||||
}
|
||||
|
||||
func (this *BcCurrency) HasDecimals() bool {
|
||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||
}
|
||||
|
||||
func (this *RankSeason) GetId() int32 {
|
||||
return this.id
|
||||
}
|
||||
@ -628,6 +637,7 @@ func (this *BcCurrency) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.contract_address, "contract_address", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.current_price, "current_price", &this._flags1_, 4, kv)
|
||||
f5.ReadMetaTableField(&this.decimals, "decimals", &this._flags1_, 5, kv)
|
||||
}
|
||||
|
||||
func (this *RankSeason) LoadFromKv(kv map[string]interface{}) {
|
||||
|
@ -82,6 +82,7 @@ message BcCurrency
|
||||
optional string name = 1;
|
||||
optional string contract_address = 3;
|
||||
optional double current_price = 4;
|
||||
optional int32 decimals = 5;
|
||||
}
|
||||
|
||||
message RankSeason
|
||||
|
@ -53,11 +53,22 @@ func (this *bcCurrency) ExchangeUSD(amount string, itemType string, contractAddr
|
||||
if !ok {
|
||||
return 0, "0"
|
||||
}
|
||||
bnDecimal := big.NewInt(DECIMALS)
|
||||
//bnDecimal := big.NewInt(DECIMALS)
|
||||
bnDecimalEx := big.NewInt(100000000000000000)
|
||||
{
|
||||
usdcMeta := mt.Table.BcCurrency.GetByName(jccommon.BC_CURRENCY_NAME_USDC)
|
||||
if usdcMeta != nil && strings.ToLower(usdcMeta.GetContractAddress()) == contractAddress {
|
||||
bnDecimalEx = big.NewInt(100000)
|
||||
}
|
||||
}
|
||||
//if itemType == jccommon.BC_CURRENCY_NAME_USDC {
|
||||
//bnDecimalEx = big.NewInt(100000)
|
||||
//}
|
||||
bnPrice := big.NewInt(0)
|
||||
bnRate := big.NewInt(rate)
|
||||
bnPrice.Mul(bnAmount, bnRate)
|
||||
bnPrice.Div(bnPrice, bnDecimal)
|
||||
//bnPrice.Mul(bnPrice, bnDecimal)
|
||||
bnPrice.Div(bnPrice, bnDecimalEx)
|
||||
return rate, bnPrice.String()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user