Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cherry-yl-sh committed Jun 6, 2024
1 parent 0bc2ba2 commit e679ad7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions sponsor_manager/sponsor_balance_repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion sponsor_manager/sponsor_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}).
Expand Down

0 comments on commit e679ad7

Please sign in to comment.