1
This commit is contained in:
parent
9775c0da00
commit
f992504030
@ -6,6 +6,7 @@ import (
|
||||
"sync"
|
||||
"strings"
|
||||
"main/constant"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
type vip struct {
|
||||
@ -84,6 +85,15 @@ func (this *vip) AddEx(accountAddress string, val string, idx int64, valField st
|
||||
return true
|
||||
}
|
||||
|
||||
/*
|
||||
Deposit amount his_amount 衰减,最后的存覆盖之前的
|
||||
Withdraw 所有
|
||||
|
||||
按时间排序处理事件的先后顺序
|
||||
|
||||
通过Vester.sol的remainingEsToken方法获取, 如果要本地计算的话, 那就取每次Deposit事件的时间和amount, 加上先前的转换的余额, 再按total * (now - deposit_time) / (365 * 24 * 2600)
|
||||
*/
|
||||
|
||||
func (this *vip) RecalcEsCecConvert(accountAddress string) error {
|
||||
accountAddress = strings.ToLower(accountAddress)
|
||||
err , ds := f5.GetGoStyleDb().NewOrmSelect(
|
||||
@ -124,5 +134,21 @@ func (this *vip) RecalcEsCecConvert(accountAddress string) error {
|
||||
q5.Sort(matchDeposits, func (a *vesterDepositWithdrawPo, b *vesterDepositWithdrawPo) bool {
|
||||
return a.chainTimestamp < b.chainTimestamp
|
||||
})
|
||||
var lastDeposit *vesterDepositWithdrawPo
|
||||
nowTime := q5.ToInt32(f5.GetApp().GetRealSeconds())
|
||||
bnTotal := new(big.Int)
|
||||
for _, val := range matchDeposits {
|
||||
if lastDeposit != nil {
|
||||
if nowTime > lastDeposit.chainTimestamp {
|
||||
bnPassTime := new(big.Int).SetInt64(int64(nowTime - lastDeposit.chainTimestamp))
|
||||
bnTotalTime := new(big.Int).SetInt64(int64(365 * 24 * 2600))
|
||||
bnRate := bnPassTime.Div(bnPassTime, bnTotalTime)
|
||||
bnTotal.Mul(bnTotal, bnRate)
|
||||
}
|
||||
}
|
||||
bnAmount, _ := new(big.Int).SetString(val.depositAmount, 10)
|
||||
bnTotal = bnAmount.Add(bnAmount, bnTotal)
|
||||
lastDeposit = val
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -11,14 +11,6 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
/*
|
||||
Deposit amount his_amount 衰减,最后的存覆盖之前的
|
||||
Withdraw 所有
|
||||
|
||||
按时间排序处理事件的先后顺序
|
||||
|
||||
通过Vester.sol的remainingEsToken方法获取, 如果要本地计算的话, 那就取每次Deposit事件的时间和amount, 加上先前的转换的余额, 再按total * (now - deposit_time) / (365 * 24 * 2600)
|
||||
*/
|
||||
type vester struct {
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user