Skip to content

Commit

Permalink
modify the param TobinTaxList to IlliquidTobinTaxList
Browse files Browse the repository at this point in the history
  • Loading branch information
Yun committed Dec 3, 2019
1 parent 437ae1d commit cac1012
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions x/market/internal/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ func (k Keeper) TobinTax(ctx sdk.Context) (res sdk.Dec) {
return
}

// TobinTaxList is a list of tax rates on all spot conversions of the specific Terra into another Terra
// IlliquidTobinTaxList is the exceptions that have to pay a higher tobin tax due to illiquidity
// TobinTax will be used for the denoms which are not in the list
func (k Keeper) TobinTaxList(ctx sdk.Context) (res types.TobinTaxList) {
k.paramSpace.Get(ctx, types.ParmamStoreKeyTobinTaxList, &res)
func (k Keeper) IlliquidTobinTaxList(ctx sdk.Context) (res types.TobinTaxList) {
k.paramSpace.Get(ctx, types.ParmamStoreKeyIlliquidTobinTaxList, &res)
return
}

Expand Down
4 changes: 2 additions & 2 deletions x/market/internal/keeper/swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ func (k Keeper) ComputeSwap(ctx sdk.Context, offerCoin sdk.Coin, askDenom string
// Apply only tobin tax without constant product spread
if offerCoin.Denom != core.MicroLunaDenom && askDenom != core.MicroLunaDenom {
spread = k.TobinTax(ctx)
tobinTaxList := k.TobinTaxList(ctx)
illiquidTobinTaxList := k.IlliquidTobinTaxList(ctx)

// Apply highest tobin tax for the denoms in the swap operation
for _, tobinTax := range tobinTaxList {
for _, tobinTax := range illiquidTobinTaxList {
if tobinTax.Denom == offerCoin.Denom ||
tobinTax.Denom == askDenom {
if tobinTax.TaxRate.GT(spread) {
Expand Down
4 changes: 2 additions & 2 deletions x/market/internal/keeper/swap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestComputeInternalSwap(t *testing.T) {
require.Error(t, err)
}

func TestTobinTaxListParams(t *testing.T) {
func TestIlliquidTobinTaxListParams(t *testing.T) {
input := CreateTestInput(t)

// Set Oracle Price
Expand All @@ -96,7 +96,7 @@ func TestTobinTaxListParams(t *testing.T) {
// Case 1: tobin tax 2% due to umnt denom
params := input.MarketKeeper.GetParams(input.Ctx)
params.TobinTax = sdk.NewDecWithPrec(25, 4)
params.TobinTaxList = types.TobinTaxList{
params.IlliquidTobinTaxList = types.TobinTaxList{
types.TobinTax{
Denom: core.MicroSDRDenom,
TaxRate: sdk.NewDecWithPrec(25, 4),
Expand Down
42 changes: 21 additions & 21 deletions x/market/internal/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ var (
ParamStoreKeyMinSpread = []byte("minspread")
// Tobin tax
ParmamStoreKeyTobinTax = []byte("tobintax")
// Tobin tax list
ParmamStoreKeyTobinTaxList = []byte("tobintaxlist")
// Illiquid tobin tax list
ParmamStoreKeyIlliquidTobinTaxList = []byte("illiquidtobintaxlist")
)

// Default parameter values
var (
DefaultBasePool = sdk.NewDec(250000 * core.MicroUnit) // 250,000sdr = 250,000,000,000usdr
DefaultPoolRecoveryPeriod = core.BlocksPerDay // 14,400
DefaultMinSpread = sdk.NewDecWithPrec(2, 2) // 2%
DefaultTobinTax = sdk.NewDecWithPrec(25, 4) // 0.25%
DefaultTobinTaxList = TobinTaxList{
DefaultBasePool = sdk.NewDec(250000 * core.MicroUnit) // 250,000sdr = 250,000,000,000usdr
DefaultPoolRecoveryPeriod = core.BlocksPerDay // 14,400
DefaultMinSpread = sdk.NewDecWithPrec(2, 2) // 2%
DefaultTobinTax = sdk.NewDecWithPrec(25, 4) // 0.25%
DefaultIlliquidTobinTaxList = TobinTaxList{
{
Denom: core.MicroMNTDenom,
TaxRate: sdk.NewDecWithPrec(2, 2), // 2%
Expand All @@ -44,21 +44,21 @@ var _ subspace.ParamSet = &Params{}

// Params market parameters
type Params struct {
PoolRecoveryPeriod int64 `json:"pool_recovery_period" yaml:"pool_recovery_period"`
BasePool sdk.Dec `json:"base_pool" yaml:"base_pool"`
MinSpread sdk.Dec `json:"min_spread" yaml:"min_spread"`
TobinTax sdk.Dec `json:"tobin_tax" yaml:"tobin_tax"`
TobinTaxList TobinTaxList `json:"tobin_tax_list" yaml:"tobin_tax_list"`
PoolRecoveryPeriod int64 `json:"pool_recovery_period" yaml:"pool_recovery_period"`
BasePool sdk.Dec `json:"base_pool" yaml:"base_pool"`
MinSpread sdk.Dec `json:"min_spread" yaml:"min_spread"`
TobinTax sdk.Dec `json:"tobin_tax" yaml:"tobin_tax"`
IlliquidTobinTaxList TobinTaxList `json:"illiquid_tobin_tax_list" yaml:"illiquid_tobin_tax_list"`
}

// DefaultParams creates default market module parameters
func DefaultParams() Params {
return Params{
BasePool: DefaultBasePool,
PoolRecoveryPeriod: DefaultPoolRecoveryPeriod,
MinSpread: DefaultMinSpread,
TobinTax: DefaultTobinTax,
TobinTaxList: DefaultTobinTaxList,
BasePool: DefaultBasePool,
PoolRecoveryPeriod: DefaultPoolRecoveryPeriod,
MinSpread: DefaultMinSpread,
TobinTax: DefaultTobinTax,
IlliquidTobinTaxList: DefaultIlliquidTobinTaxList,
}
}

Expand All @@ -76,7 +76,7 @@ func (params Params) Validate() error {
if params.TobinTax.IsNegative() || params.TobinTax.GT(sdk.OneDec()) {
return fmt.Errorf("tobin tax should be a value between [0,1], is %s", params.TobinTax)
}
for _, val := range params.TobinTaxList {
for _, val := range params.IlliquidTobinTaxList {
if val.TaxRate.IsNegative() || val.TaxRate.GT(sdk.OneDec()) {
return fmt.Errorf("tobin tax should be a value between [0,1], is %s", val)
}
Expand All @@ -94,7 +94,7 @@ func (params *Params) ParamSetPairs() subspace.ParamSetPairs {
{Key: ParamStoreKeyPoolRecoveryPeriod, Value: &params.PoolRecoveryPeriod},
{Key: ParamStoreKeyMinSpread, Value: &params.MinSpread},
{Key: ParmamStoreKeyTobinTax, Value: &params.TobinTax},
{Key: ParmamStoreKeyTobinTaxList, Value: &params.TobinTaxList},
{Key: ParmamStoreKeyIlliquidTobinTaxList, Value: &params.IlliquidTobinTaxList},
}
}

Expand All @@ -105,6 +105,6 @@ func (params Params) String() string {
PoolRecoveryPeriod: %d
MinSpread: %s
TobinTax: %s
TobinTaxList: %s
`, params.BasePool, params.PoolRecoveryPeriod, params.MinSpread, params.TobinTax, params.TobinTaxList)
IlliquidTobinTaxList: %s
`, params.BasePool, params.PoolRecoveryPeriod, params.MinSpread, params.TobinTax, params.IlliquidTobinTaxList)
}

0 comments on commit cac1012

Please sign in to comment.