11package trading_rewards_test
22
33import (
4- sdkmath "cosmossdk.io/math"
5- "github.com/cosmos/gogoproto/proto"
6- "github.com/dydxprotocol/v4-chain/protocol/app/flags"
74 "math/big"
85 "testing"
96 "time"
107
8+ sdkmath "cosmossdk.io/math"
9+ "github.com/cosmos/gogoproto/proto"
10+ "github.com/dydxprotocol/v4-chain/protocol/app/flags"
11+
1112 "github.com/cometbft/cometbft/types"
1213 sdk "github.com/cosmos/cosmos-sdk/types"
1314 authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
@@ -229,20 +230,20 @@ func TestTradingRewards(t *testing.T) {
229230 },
230231 {
231232 AccAddress : RewardsTreasuryAccAddress ,
232- // Total of ~5.06 full coins have vested, which is less than calculated
233- // rewards (~5.5 full coins) . So all reward tokens were distributed .
233+ // Total of ~5.06 full coins have vested, calculated rewards are
234+ // ~1.99 full coins. So remaining rewards are ~3.07 full coins .
234235 Balance : big_testutil .MustFirst (new (big.Int ).SetString (
235- "0 " ,
236+ "3077645653924902967 " ,
236237 10 ,
237238 )),
238239 },
239240 {
240241 AccAddress : constants .AliceAccAddress ,
241- // starting balance + ~5.06 full coins rewards
242+ // starting balance + ~1.99 full coins rewards
242243 Balance : new (big.Int ).Add (
243244 TestAccountStartingTokenBalance ,
244245 big_testutil .MustFirst (new (big.Int ).SetString (
245- "5068012730847979890 " ,
246+ "1990367076923076923 " ,
246247 10 ,
247248 )),
248249 ),
@@ -258,7 +259,7 @@ func TestTradingRewards(t *testing.T) {
258259 TradingRewards : []* indexerevents.AddressTradingReward {
259260 {
260261 Owner : constants .AliceAccAddress .String (),
261- DenomAmount : dtypes .NewIntFromUint64 (5068012730847979890 ),
262+ DenomAmount : dtypes .NewIntFromUint64 (1990367076923076923 ),
262263 },
263264 },
264265 },
@@ -277,10 +278,10 @@ func TestTradingRewards(t *testing.T) {
277278 },
278279 {
279280 AccAddress : RewardsTreasuryAccAddress ,
280- // ~25.34 full coins. Note this is exactly 10x the amount vested per block,
281+ // balance + ~25.34 full coins. Note this is exactly 10x the amount vested per block,
281282 // since 10 blocks has passed since the last check.
282283 Balance : big_testutil .MustFirst (new (big.Int ).SetString (
283- "25340063654239899450 " ,
284+ "28417709308164802417 " ,
284285 10 ,
285286 )),
286287 },
@@ -300,23 +301,23 @@ func TestTradingRewards(t *testing.T) {
300301 {
301302 AccAddress : constants .BobAccAddress ,
302303 // Starting balance: 500000000000000000000000
303- // Total rewards = (TakerFee - TakerVolume * MaxMakerRebate) * 0.99
304- // = ($28003 * 0.05% - $28003 * 0.011%) * 0.99
305- // = ($14.0015 - $3.08033) 0.99 = $10.8119583
306- // Reward tokens = $10.8119583 / $1.95 = 5.544594 full coins
304+ // Total rewards = (TakerFee - TakerVolume * MaxMakerRebate - (takerFee * MaxPossibleTakerFeeRevShare) ) * 0.99
305+ // = ($28003 * 0.05% - $28003 * 0.011% - $28003 * 0.05% * 0.5 ) * 0.99
306+ // = ($14.0015 - $3.08033 - $7.00075 ) 0.99 = $3.8812158
307+ // Reward tokens = $3.8812158 / $1.95 = 1.9903670769 full coins
307308 Balance : new (big.Int ).Add (
308309 TestAccountStartingTokenBalance ,
309310 big_testutil .MustFirst (new (big.Int ).SetString (
310- "5544594000000000000 " ,
311+ "1990367076923076923 " ,
311312 10 ,
312313 )),
313314 ),
314315 },
315316 {
316317 AccAddress : RewardsTreasuryAccAddress ,
317- // 25.34 + 2.534 - 5.544594 ~= 22.329 full coins
318+ // balance + 25.34 + 2.534 - 1.9903670769 ~= 22.329 full coins
318319 Balance : big_testutil .MustFirst (new (big.Int ).SetString (
319- "22329476019663889395 " ,
320+ "28961348596665715439 " ,
320321 10 ,
321322 )),
322323 },
@@ -326,7 +327,7 @@ func TestTradingRewards(t *testing.T) {
326327 TradingRewards : []* indexerevents.AddressTradingReward {
327328 {
328329 Owner : constants .BobAccAddress .String (),
329- DenomAmount : dtypes .NewIntFromUint64 (5544594000000000000 ),
330+ DenomAmount : dtypes .NewIntFromUint64 (1990367076923076923 ),
330331 },
331332 },
332333 },
@@ -482,8 +483,8 @@ func TestTradingRewards(t *testing.T) {
482483 // - Carl and Dave: $12.519
483484 // Total rewards tokens distributed: ~25.34 (less than the value of net fees)
484485 // Entitled reward tokens:
485- // - Alice and Bob: 8.0539
486- // - Carl and Dave: 4.616
486+ // - Alice and Bob: 3.98073
487+ // - Carl and Dave: 2.28156
487488 ExpectedBalances : []expectedBalance {
488489 {
489490 AccAddress : RewardsVesterAccAddress ,
@@ -495,9 +496,9 @@ func TestTradingRewards(t *testing.T) {
495496 },
496497 {
497498 AccAddress : RewardsTreasuryAccAddress ,
498- // All vested rewards were distributed, only rounding dusts left.
499+ // 12.52458 full coins distributed, ~12.815 full coins remaining
499500 Balance : big_testutil .MustFirst (new (big.Int ).SetString (
500- "2 " ,
501+ "12815456885009130222 " ,
501502 10 ,
502503 )),
503504 },
@@ -506,7 +507,7 @@ func TestTradingRewards(t *testing.T) {
506507 Balance : new (big.Int ).Add (
507508 TestAccountStartingTokenBalance ,
508509 big_testutil .MustFirst (new (big.Int ).SetString (
509- "8053910091363583686 " ,
510+ "3980734153846153845 " ,
510511 10 ,
511512 )),
512513 ),
@@ -516,7 +517,7 @@ func TestTradingRewards(t *testing.T) {
516517 Balance : new (big.Int ).Add (
517518 TestAccountStartingTokenBalance ,
518519 big_testutil .MustFirst (new (big.Int ).SetString (
519- "8053910091363583686 " ,
520+ "3980734153846153845 " ,
520521 10 ,
521522 )),
522523 ),
@@ -526,7 +527,7 @@ func TestTradingRewards(t *testing.T) {
526527 Balance : new (big.Int ).Add (
527528 TestAccountStartingTokenBalance ,
528529 big_testutil .MustFirst (new (big.Int ).SetString (
529- "4616121735756366038 " ,
530+ "2281569230769230769 " ,
530531 10 ,
531532 )),
532533 ),
@@ -536,7 +537,7 @@ func TestTradingRewards(t *testing.T) {
536537 Balance : new (big.Int ).Add (
537538 TestAccountStartingTokenBalance ,
538539 big_testutil .MustFirst (new (big.Int ).SetString (
539- "4616121735756366038 " ,
540+ "2281569230769230769 " ,
540541 10 ,
541542 )),
542543 ),
@@ -547,19 +548,19 @@ func TestTradingRewards(t *testing.T) {
547548 TradingRewards : []* indexerevents.AddressTradingReward {
548549 {
549550 Owner : constants .BobAccAddress .String (),
550- DenomAmount : dtypes .NewIntFromUint64 (8053910091363583686 ),
551+ DenomAmount : dtypes .NewIntFromUint64 (3980734153846153845 ),
551552 },
552553 {
553554 Owner : constants .AliceAccAddress .String (),
554- DenomAmount : dtypes .NewIntFromUint64 (8053910091363583686 ),
555+ DenomAmount : dtypes .NewIntFromUint64 (3980734153846153845 ),
555556 },
556557 {
557558 Owner : constants .CarlAccAddress .String (),
558- DenomAmount : dtypes .NewIntFromUint64 (4616121735756366038 ),
559+ DenomAmount : dtypes .NewIntFromUint64 (2281569230769230769 ),
559560 },
560561 {
561562 Owner : constants .DaveAccAddress .String (),
562- DenomAmount : dtypes .NewIntFromUint64 (4616121735756366038 ),
563+ DenomAmount : dtypes .NewIntFromUint64 (2281569230769230769 ),
563564 },
564565 },
565566 },
0 commit comments