Skip to content

Commit

Permalink
Bonus value and max referrals are made to be configurable. (#78)
Browse files Browse the repository at this point in the history
Bonus value and max referrals are made to be configurable.
  • Loading branch information
ice-myles authored Aug 13, 2024
1 parent 25e3d89 commit 20946be
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ news: &news
urlUpload: https://storage.bunnycdn.com/ice-staging/news
urlDownload: https://ice-staging.b-cdn.net/news
notifications: &notifications
welcomeBonusV2Amount: 500
maxReferralsCount: 200
defaultReferralName: sunwaves
deeplinkScheme: staging.ice.app
pingCooldown: 1m
Expand Down
2 changes: 2 additions & 0 deletions notifications/.testdata/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ logger:
encoder: console
level: info
notifications: &notifications
welcomeBonusV2Amount: 500
maxReferralsCount: 200
tenantName: BogusName
deeplinkScheme: staging.ice.app
pingCooldown: 1m
Expand Down
4 changes: 3 additions & 1 deletion notifications/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,8 @@ type (
Hour int `yaml:"hour"`
Minutes int `yaml:"minutes"`
} `yaml:"weeklyStats"`
Development bool `yaml:"development"`
MaxReferralsCount int64 `yaml:"maxReferralsCount" mapstructure:"maxReferralsCount"`
WelcomeBonusV2Amount float64 `yaml:"welcomeBonusV2Amount" mapstructure:"welcomeBonusV2Amount"`
Development bool `yaml:"development"`
}
)
10 changes: 5 additions & 5 deletions notifications/notification_type_new_referral.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (r *repository) getNewReferralCoinAmount(ctx context.Context, referredBy st
if err != nil {
log.Error(errors.Wrapf(err, "failed to tokenomics.GetInternalID for referredBy: %v", referredBy))

return uint64(tokenomics.WelcomeBonusV2Amount)
return uint64(r.cfg.WelcomeBonusV2Amount)
}
state, err := storagev3.Get[struct {
model.UserIDField
Expand All @@ -204,14 +204,14 @@ func (r *repository) getNewReferralCoinAmount(ctx context.Context, referredBy st
}
log.Error(errors.Wrapf(err, "failed to get PreStakingBonus for freezerInternalID:%v referredBy:%v", freezerInternalID, referredBy))

return uint64(tokenomics.WelcomeBonusV2Amount)
return uint64(r.cfg.WelcomeBonusV2Amount)
}
if state[0].BalanceT1WelcomeBonusPending >= 200*tokenomics.WelcomeBonusV2Amount {
if state[0].BalanceT1WelcomeBonusPending >= float64(r.cfg.MaxReferralsCount)*r.cfg.WelcomeBonusV2Amount {
return 0
}
if state[0].PreStakingBonus == 0 {
return uint64(tokenomics.WelcomeBonusV2Amount)
return uint64(r.cfg.WelcomeBonusV2Amount)
}

return uint64((state[0].PreStakingBonus + 100.0) * tokenomics.WelcomeBonusV2Amount / 100.0) //nolint:gomnd,mnd // Nope.
return uint64((state[0].PreStakingBonus + 100.0) * r.cfg.WelcomeBonusV2Amount / 100.0) //nolint:gomnd,mnd // Nope.
}
5 changes: 2 additions & 3 deletions notifications/telegram_notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/pkg/errors"

"github.com/ice-blockchain/eskimo/users"
"github.com/ice-blockchain/freezer/tokenomics"
"github.com/ice-blockchain/wintr/log"
"github.com/ice-blockchain/wintr/notifications/telegram"
"github.com/ice-blockchain/wintr/time"
Expand Down Expand Up @@ -271,12 +270,12 @@ func (r *repository) handleTelegramUpdates(
}
if upd.Message.From.Username == "" && upd.Message.Text == string(StartTelegramCommand) {
body = tmpl.getAltBody(users.JSON{
"WelcomeBonus": tokenomics.WelcomeBonusV2Amount,
"WelcomeBonus": r.cfg.WelcomeBonusV2Amount,
})
} else {
body = tmpl.getBody(users.JSON{
"Username": upd.Message.From.Username,
"WelcomeBonus": tokenomics.WelcomeBonusV2Amount,
"WelcomeBonus": r.cfg.WelcomeBonusV2Amount,
})
}
id := strconv.FormatInt(upd.Message.From.ID, 10)
Expand Down

0 comments on commit 20946be

Please sign in to comment.