Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
eeb62e5
- market module rework
StrathCole Aug 18, 2025
3aefa20
- whitespace
StrathCole Aug 19, 2025
513e66d
Merge branch 'main' into feat/mm-implementation
StrathCole Aug 19, 2025
ae860d8
- cleaning
StrathCole Aug 19, 2025
86f6584
Merge branch 'main' into mm-main
StrathCole Aug 19, 2025
9052c82
Merge branch 'mm-main' into feat/mm-implementation
StrathCole Aug 19, 2025
9f484de
- add meta denom to whitelist on upgrade and in ballot
StrathCole Aug 19, 2025
f484578
- governance parameter for market swap fee distribution (Burn/CP/OP)
StrathCole Aug 19, 2025
de031c7
WIP: sdk 0.50
StrathCole Sep 8, 2025
a4bbfcd
temp file
StrathCole Sep 8, 2025
2d32c0d
WIP migration to SDK 0.50
StrathCole Sep 10, 2025
1705f50
fi
StrathCole Sep 12, 2025
6a63c31
- several fixes
StrathCole Sep 13, 2025
c322844
- fix params space
StrathCole Sep 13, 2025
442608b
fix missing code from migration
StrathCole Sep 13, 2025
478c9df
- readd modules to simulation modules
StrathCole Sep 13, 2025
18cebf6
update e2e to account for reverse charge tax
StrathCole Sep 13, 2025
0be2e4f
fix further reverse charge issues in e2e
StrathCole Sep 13, 2025
45182dd
fix further e2e reverse charge calculations
StrathCole Sep 13, 2025
8784d6e
fix further e2e reverse charge
StrathCole Sep 13, 2025
3d9c6d6
fix receive amount in e2e
StrathCole Sep 13, 2025
acae70a
- update ictests
StrathCole Sep 13, 2025
acf4ffb
fix dependencies ictest
StrathCole Sep 13, 2025
cc3f51e
fix dependencies in ictest
StrathCole Sep 13, 2025
ca54c7a
fix in gas amount, docker lint and tax handling
StrathCole Sep 13, 2025
1564a2b
fix test assert in ibc transfer ictest
StrathCole Sep 13, 2025
98de403
- adjust ic test for gas/tax handling
StrathCole Sep 13, 2025
91134fd
- remove expedited_voting_period from start-node script (not yet avai…
StrathCole Sep 13, 2025
9188bf5
- add comment to clarify temporary folder usage
StrathCole Sep 13, 2025
6c13869
change upgrade height in test
StrathCole Sep 13, 2025
ffb9bcf
update to wasmvm 3, wasmd 0.61, cosmos-sdk 0.53, ibc v10
StrathCole Sep 14, 2025
b6ec263
- update dependencies
StrathCole Sep 14, 2025
6e62d22
fix ibc client
StrathCole Sep 14, 2025
0d9da1d
rename file to correct name
StrathCole Sep 14, 2025
699bd44
ics validator test fix
StrathCole Sep 14, 2025
d3a71a6
- clean up ictest for validators
StrathCole Sep 15, 2025
1cabdf4
- add common flags to autocli
StrathCole Sep 15, 2025
d332866
pfm and ibcv2 tests
StrathCole Sep 16, 2025
06483ff
Merge pull request #56 from StrathCole/strath/next-gen-plus
kien6034 Oct 5, 2025
ae1f6ea
bump wasmd
hoank101 Oct 5, 2025
cabc2fb
fix createValMsg
hoank101 Oct 5, 2025
de7f29a
refactor and update github action (#67)
hoank101 Oct 11, 2025
92f7855
fix ci (#70)
TropicalDog17 Oct 18, 2025
9dc72a8
- several fixes
StrathCole Oct 26, 2025
4c40df8
Merge branch 'main' of https://github.com/orbitorg/core into sdk53-ibcv2
hoank101 Nov 8, 2025
339eaae
update query handler
hoank101 Nov 8, 2025
1e2cf9e
fix lint
hoank101 Nov 8, 2025
5102ffd
Merge branch 'sdk53-ibcv2' into feat/mm-implementation
StrathCole Nov 17, 2025
c981034
- adjust MM2.0 code to sdk 0.53
StrathCole Nov 17, 2025
a6f79bb
- tidy
StrathCole Nov 17, 2025
7715855
Merge branch 'main' into feat/mm-implementation
StrathCole Nov 17, 2025
0c1f11b
Merge branch 'main' into feat/mm-implementation
StrathCole Nov 17, 2025
59ee2e9
- linting
StrathCole Nov 18, 2025
97f2d07
- change version to v4
StrathCole Feb 20, 2026
15b019c
change version to v4
StrathCole Feb 20, 2026
5d20148
Merge branch 'main' into feat/mm-implementation
StrathCole Feb 20, 2026
8707605
- fixes from merge
StrathCole Feb 20, 2026
f6abb0f
Merge branch 'main' into feat/mm-implementation
StrathCole Apr 22, 2026
f6ec19d
Merge branch 'main' into feat/mm-implementation
StrathCole May 27, 2026
20ca482
fix fee test to expect panic
StrathCole May 27, 2026
846cd1a
lint
StrathCole May 27, 2026
8afe857
fixes from copilot review
StrathCole May 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
v13_1 "github.com/classic-terra/core/v4/app/upgrades/v13_1"
v14_1 "github.com/classic-terra/core/v4/app/upgrades/v14_1"
v14_2 "github.com/classic-terra/core/v4/app/upgrades/v14_2"
v15 "github.com/classic-terra/core/v4/app/upgrades/v15"
v2 "github.com/classic-terra/core/v4/app/upgrades/v2"
v3 "github.com/classic-terra/core/v4/app/upgrades/v3"
v4 "github.com/classic-terra/core/v4/app/upgrades/v4"
Expand Down Expand Up @@ -107,6 +108,7 @@ var (
v13_1.Upgrade,
v14_1.Upgrade,
v14_2.Upgrade,
v15.Upgrade,
}

// Forks defines forks to be applied to the network
Expand Down
5 changes: 4 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,11 @@ func NewAppKeepers(
appKeepers.MarketKeeper = marketkeeper.NewKeeper(
appCodec, appKeepers.keys[markettypes.StoreKey],
appKeepers.GetSubspace(markettypes.ModuleName),
appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.OracleKeeper,
appKeepers.AccountKeeper, appKeepers.BankKeeper, appKeepers.OracleKeeper, appKeepers.DistrKeeper,
)
// Set market hooks on oracle keeper to track tally events for TWAP and freshness
appKeepers.OracleKeeper.SetMarketHooks(&appKeepers.MarketKeeper)

appKeepers.TreasuryKeeper = treasurykeeper.NewKeeper(
appCodec, appKeepers.keys[treasurytypes.StoreKey],
appKeepers.GetSubspace(treasurytypes.ModuleName),
Expand Down
33 changes: 18 additions & 15 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,27 @@ var (
)
// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil, // just added to enable align fee
treasurytypes.BurnModuleName: {authtypes.Burner},
minttypes.ModuleName: {authtypes.Minter},
markettypes.ModuleName: {authtypes.Minter, authtypes.Burner},
oracletypes.ModuleName: nil,
distrtypes.ModuleName: nil,
treasurytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
authtypes.FeeCollectorName: nil, // just added to enable align fee
treasurytypes.BurnModuleName: {authtypes.Burner},
minttypes.ModuleName: {authtypes.Minter},
markettypes.ModuleName: {authtypes.Burner},
markettypes.AccumulatorModuleName: nil,
oracletypes.ModuleName: nil,
distrtypes.ModuleName: nil,
treasurytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking},
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
icatypes.ModuleName: nil,
wasmtypes.ModuleName: {authtypes.Burner},
}
// module accounts that are allowed to receive tokens
allowedReceivingModAcc = map[string]bool{
oracletypes.ModuleName: true,
treasurytypes.BurnModuleName: true,
oracletypes.ModuleName: true,
treasurytypes.BurnModuleName: true,
markettypes.ModuleName: true,
markettypes.AccumulatorModuleName: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maccPerms registers AccumulatorModuleName for new chains (via InitChainer), but for an existing chain upgrading, the account doesn't exist in the auth store. The upgrade handler must create it

}
)

Expand Down
14 changes: 14 additions & 0 deletions app/upgrades/v15/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package v15

import (
store "cosmossdk.io/store/types"
"github.com/classic-terra/core/v4/app/upgrades"
)

const UpgradeName = "v15"

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateV15UpgradeHandler,
StoreUpgrades: store.StoreUpgrades{}, // no store upgrades
}
49 changes: 49 additions & 0 deletions app/upgrades/v15/upgrades.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package v15

import (
"context"

sdkmath "cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/classic-terra/core/v4/app/keepers"
"github.com/classic-terra/core/v4/app/upgrades"
oracletypes "github.com/classic-terra/core/v4/x/oracle/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)

func CreateV15UpgradeHandler(
mm *module.Manager,
cfg module.Configurator,
_ upgrades.BaseAppParamManager,
k *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {
return func(ctx context.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
sdkCtx := sdk.UnwrapSDKContext(ctx)

// Initialize/ensure allowed swap denoms for market: restrict to uusd by default.
k.MarketKeeper.SetAllowedSwapDenoms([]string{"uusd"})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should initialized TaxRedirectRate k.TreasuryKeeper.SetTaxRedirectRate(sdkCtx, sdkmath.LegacyZeroDec()),

// Ensure UST meta denom (oracle-only) is present in oracle vote targets.
// Existing chains won't pick up DefaultParams changes automatically, so patch params here.
params := k.OracleKeeper.GetParams(sdkCtx)
hasMeta := false
for _, d := range params.Whitelist {
if d.Name == oracletypes.MetaUSDDenom {
hasMeta = true
break
}
}
if !hasMeta {
params.Whitelist = append(params.Whitelist, oracletypes.Denom{
Name: oracletypes.MetaUSDDenom,
TobinTax: sdkmath.LegacyZeroDec(),
})
k.OracleKeeper.SetParams(sdkCtx, params)
// Set TobinTax immediately so it becomes a vote target without waiting a full period
k.OracleKeeper.SetTobinTax(sdkCtx, oracletypes.MetaUSDDenom, sdkmath.LegacyZeroDec())
}

return mm.RunMigrations(ctx, cfg, fromVM)
}
}
119 changes: 72 additions & 47 deletions custom/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,8 @@ func (s *AnteTestSuite) TestTaxExemption() {
// Set burn split rate to 50%
// oracle split to 0% (oracle split is covered in another test)
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
// Ensure no redirect for this focused test
tk.SetTaxRedirectRate(s.ctx, sdkmath.LegacyZeroDec())
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)

s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand Down Expand Up @@ -1170,6 +1172,8 @@ func (s *AnteTestSuite) TestTaxExemptionWithMultipleDenoms() {

// Set burn split rate to 50%
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
// Disable market redirect in this test suite to keep legacy expectations
tk.SetTaxRedirectRate(s.ctx, sdkmath.LegacyZeroDec())
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)

s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand Down Expand Up @@ -1346,6 +1350,8 @@ func (s *AnteTestSuite) TestTaxExemptionWithGasPriceEnabled() {

// Set burn split rate to 50%
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
// Disable market redirect so fees/taxes remain at FeeCollector per legacy expectations
tk.SetTaxRedirectRate(s.ctx, sdkmath.LegacyZeroDec())
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)

s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand Down Expand Up @@ -1415,32 +1421,42 @@ func (s *AnteTestSuite) TestTaxExemptionWithGasPriceEnabled() {
}
}

// go test -v -run ^TestAnteTestSuite/TestBurnSplitTax$ github.com/classic-terra/core/v4/custom/auth/ante
func (s *AnteTestSuite) TestBurnSplitTax() {
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 10% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0.1% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 10% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0.1% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 10% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0.1% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 10% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0.1% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 2)) // 0.1% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 2)) // 0% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(1, 1)) // 0.1% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(1, 2)) // 0% distribute, 100% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(-1, 1), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1)) // -10% distribute - invalid rate
require := s.Require()

// No market redirect
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 100% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 10% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 0.1% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 0% distribute, 0% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 100% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 10% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 0.1% distribute, 50% to oracle
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyZeroDec()) // 0% distribute, 50% to oracle
// With market redirect at 50%
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 50% redirect
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 1), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 10% distribute, 50% redirect
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 2), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0.1% distribute, 50% redirect
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(0, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 0% distribute, 50% redirect
// With oracle 100% and market 50% (redirect applies to remainder after oracle)
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyOneDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyNewDecWithPrec(5, 1)) // 100% distribute, 100% to oracle, 50% market of remainder (0)
// Extreme: market 100%
s.runBurnSplitTaxTest(sdkmath.LegacyNewDecWithPrec(1, 0), sdkmath.LegacyZeroDec(), sdkmath.LegacyNewDecWithPrec(5, 1), sdkmath.LegacyOneDec()) // 100% distribute, 100% redirect

// Validation: invalid burn split must panic during treasury param validation.
s.Run("invalid burn split", func() {
s.SetupTest(true)
tk := s.app.TreasuryKeeper
tParams := tk.GetParams(s.ctx)
tParams.BurnTaxSplit = sdkmath.LegacyNewDecWithPrec(-1, 1)

require.Panics(func() {
tk.SetParams(s.ctx, tParams)
})
})
}

func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, oracleSplitRate sdkmath.LegacyDec, communityTax sdkmath.LegacyDec) {
func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, oracleSplitRate sdkmath.LegacyDec, communityTax sdkmath.LegacyDec, marketRedirectRate sdkmath.LegacyDec) {
s.SetupTest(true) // setup
require := s.Require()
s.txBuilder = s.clientCtx.TxConfig.NewTxBuilder()
Expand All @@ -1456,9 +1472,12 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, ora
antehandler := sdk.ChainAnteDecorators(mfd)
postHandler := sdk.ChainPostDecorators(pd)

// Set burn split tax
tk.SetBurnSplitRate(s.ctx, burnSplitRate)
tk.SetOracleSplitRate(s.ctx, oracleSplitRate)
// Set burn split, oracle split and market redirect atomically
tParams := tk.GetParams(s.ctx)
tParams.BurnTaxSplit = burnSplitRate
tParams.OracleSplit = oracleSplitRate
tParams.TaxRedirectRate = marketRedirectRate
tk.SetParams(s.ctx, tParams)

// Set community tax
dkParams, err := dk.Params.Get(s.ctx)
Expand Down Expand Up @@ -1497,45 +1516,54 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, ora
// Set IsCheckTx to true
s.ctx = s.ctx.WithIsCheckTx(true)

// feeCollector := ak.GetModuleAccount(s.ctx, authtypes.FeeCollectorName)

// amountFeeBefore := bk.GetAllBalances(s.ctx, feeCollector.GetAddress())

totalSupplyBefore, _, err := bk.GetPaginatedTotalSupply(s.ctx, &query.PageRequest{})
require.NoError(err)
/*fmt.Printf(
"Before: TotalSupply %v, FeeCollector %v\n",
totalSupplyBefore,
amountFeeBefore,
)*/

// send tx to BurnTaxFeeDecorator antehandler
newCtx, err := antehandler(s.ctx, tx, false)
require.NoError(err)
_, err = postHandler(newCtx, tx, false, true)
require.NoError(err)

// Read post-handler state from execution context
s.ctx = newCtx

// burn the burn account
tk.BurnCoinsFromBurnAccount(s.ctx)

feeCollectorAfter := bk.GetAllBalances(s.ctx, ak.GetModuleAddress(authtypes.FeeCollectorName))
oracleAfter := bk.GetAllBalances(s.ctx, ak.GetModuleAddress(oracletypes.ModuleName))
marketAfter := bk.GetAllBalances(s.ctx, ak.GetModuleAddress(markettypes.AccumulatorModuleName))
taxes, _ := ante.FilterMsgAndComputeTax(s.ctx, te, tk, th, false, msg)
feePool, _ := dk.FeePool.Get(s.ctx)
communityPoolAfter, _ := feePool.CommunityPool.TruncateDecimal()
if communityPoolAfter.IsZero() {
communityPoolAfter = sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, sdkmath.ZeroInt()))
}

// burnTax := sdk.NewDecCoinsFromCoins(taxes...)
// in the burn tax split function, coins and not deccoins are used, which leads to rounding differences
// when comparing to the test with very small numbers, accordingly all deccoin calculations are changed to coins
burnTax := taxes
// Always remove market redirect from burn amount if applicable
if marketRedirectRate.IsPositive() {
fullTaxForBurn := taxes.AmountOf(core.MicroSDRDenom)
redirected := marketRedirectRate.MulInt(fullTaxForBurn).RoundInt()
if redirected.IsPositive() {
burnTax = burnTax.Sub(sdk.NewCoin(core.MicroSDRDenom, redirected))
}
}

if burnSplitRate.IsPositive() {
distributionDeltaCoins := burnSplitRate.MulInt(burnTax.AmountOf(core.MicroSDRDenom)).RoundInt()
applyCommunityTax := communityTax.Mul(oracleSplitRate.Quo(communityTax.Mul(oracleSplitRate).Sub(communityTax).Add(sdkmath.LegacyOneDec())))
// Market redirect is applied FIRST from the full tax
fullTax := taxes.AmountOf(core.MicroSDRDenom)
expectedMarketCoins := marketRedirectRate.MulInt(fullTax).RoundInt()
postMarketTax := fullTax.Sub(expectedMarketCoins)

// Distribution portion is taken from post-market base
distributionDeltaCoins := burnSplitRate.MulInt(postMarketTax).RoundInt()

// Community tax adjustment (same formula as keeper)
applyCommunityTax := communityTax.Mul(
oracleSplitRate.Quo(communityTax.Mul(oracleSplitRate).Add(sdkmath.LegacyOneDec()).Sub(communityTax)),
)
expectedCommunityCoins := applyCommunityTax.MulInt(distributionDeltaCoins).RoundInt()
distributionDeltaCoins = distributionDeltaCoins.Sub(expectedCommunityCoins)

Expand All @@ -1546,8 +1574,11 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, ora
// fmt.Printf("-- sendCoins %+v, BurnTax %+v, BurnSplitRate %+v, OracleSplitRate %+v, CommunityTax %+v, CTaxApplied %+v, OracleCoins %+v, DistrCoins %+v\n", sendCoins.AmountOf(core.MicroSDRDenom), taxRate, burnSplitRate, oracleSplitRate, communityTax, applyCommunityTax, expectedOracleCoins, expectedDistrCoins)
require.Equal(feeCollectorAfter, sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, expectedDistrCoins)))
require.Equal(oracleAfter, sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, expectedOracleCoins)))
require.Equal(marketAfter, sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, expectedMarketCoins)))
require.Equal(communityPoolAfter, sdk.NewCoins(sdk.NewCoin(core.MicroSDRDenom, expectedCommunityCoins)))
burnTax = burnTax.Sub(sdk.NewCoin(core.MicroSDRDenom, distributionDeltaCoins)).Sub(sdk.NewCoin(core.MicroSDRDenom, expectedCommunityCoins))
burnTax = burnTax.
Sub(sdk.NewCoin(core.MicroSDRDenom, distributionDeltaCoins)).
Sub(sdk.NewCoin(core.MicroSDRDenom, expectedCommunityCoins))
}

// check tax proceeds
Expand Down Expand Up @@ -1577,12 +1608,6 @@ func (s *AnteTestSuite) runBurnSplitTaxTest(burnSplitRate sdkmath.LegacyDec, ora
burnTax,
)
}

/*fmt.Printf(
"After: TotalSupply %v, FeeCollector %v\n",
totalSupplyAfter,
feeCollectorAfter,
)*/
}

// go test -v -run ^TestAnteTestSuite/TestEnsureIBCUntaxed$ github.com/classic-terra/core/v4/custom/auth/ante
Expand Down
Loading
Loading