diff --git a/sponsor_manager/sponsor_balance_repository.go b/sponsor_manager/sponsor_balance_repository.go index dd2adfee..15c8416a 100644 --- a/sponsor_manager/sponsor_balance_repository.go +++ b/sponsor_manager/sponsor_balance_repository.go @@ -11,6 +11,7 @@ type UserSponsorBalanceDBModel struct { model.BaseData PayUserId string `gorm:"type:varchar(255);index" json:"pay_user_id"` AvailableBalance BigFloat `gorm:"type:numeric(30,18)" json:"available_balance"` + SponsoredBalance BigFloat `gorm:"type:numeric(30,18)" json:"sponsored_balance"` LockBalance BigFloat `gorm:"type:numeric(30,18)" json:"lock_balance"` Source string `gorm:"type:varchar(255)" json:"source"` SponsorAddress string `gorm:"type:varchar(255)" json:"sponsor_address"` diff --git a/sponsor_manager/sponsor_service.go b/sponsor_manager/sponsor_service.go index 009d001c..92f25a45 100644 --- a/sponsor_manager/sponsor_service.go +++ b/sponsor_manager/sponsor_service.go @@ -109,12 +109,13 @@ func ReleaseBalanceWithActualCost(userId string, userOpHash []byte, return nil, err } balanceModel, err := findUserSponsor(changeModel.PayUserId, changeModel.IsTestNet) - + //TODO 10% Fee lockBalance := changeModel.Amount balanceModel.LockBalance = BigFloat{new(big.Float).Sub(balanceModel.LockBalance.Float, lockBalance.Float)} refundBalance := new(big.Float).Sub(lockBalance.Float, actualGasCost) balanceModel.AvailableBalance = BigFloat{new(big.Float).Add(balanceModel.AvailableBalance.Float, refundBalance)} + balanceModel.SponsoredBalance = BigFloat{new(big.Float).Add(balanceModel.SponsoredBalance.Float, actualGasCost)} err = utils.DBTransactional(relayDB, func() error { if updateErr := relayDB.Model(&UserSponsorBalanceDBModel{}). Model(&UserSponsorBalanceDBModel{}).