mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-11-10 18:15:19 +00:00
8744d3210c
* panic on export if prev accrual time not set * on export if interest factor not set, set to 1.0 * fix prev accrual time in cdp export * panic on export if prev accrual time not set * export hard reward denom accumulation times * init genesis starts usdx reward indexes at 0.0 * update incentive migration * update incentive tests
220 lines
7.5 KiB
Go
220 lines
7.5 KiB
Go
package incentive_test
|
|
|
|
import (
|
|
"time"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/kava-labs/kava/app"
|
|
"github.com/kava-labs/kava/x/cdp"
|
|
"github.com/kava-labs/kava/x/incentive"
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
|
"github.com/kava-labs/kava/x/pricefeed"
|
|
)
|
|
|
|
func NewCDPGenStateMulti() app.GenesisState {
|
|
cdpGenesis := cdp.GenesisState{
|
|
Params: cdp.Params{
|
|
GlobalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000),
|
|
SurplusAuctionThreshold: cdp.DefaultSurplusThreshold,
|
|
SurplusAuctionLot: cdp.DefaultSurplusLot,
|
|
DebtAuctionThreshold: cdp.DefaultDebtThreshold,
|
|
DebtAuctionLot: cdp.DefaultDebtLot,
|
|
CollateralParams: cdp.CollateralParams{
|
|
{
|
|
Denom: "xrp",
|
|
Type: "xrp-a",
|
|
LiquidationRatio: sdk.MustNewDecFromStr("2.0"),
|
|
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
|
StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr
|
|
LiquidationPenalty: d("0.05"),
|
|
AuctionSize: i(7000000000),
|
|
Prefix: 0x20,
|
|
SpotMarketID: "xrp:usd",
|
|
LiquidationMarketID: "xrp:usd",
|
|
ConversionFactor: i(6),
|
|
},
|
|
{
|
|
Denom: "btc",
|
|
Type: "btc-a",
|
|
LiquidationRatio: sdk.MustNewDecFromStr("1.5"),
|
|
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
|
StabilityFee: sdk.MustNewDecFromStr("1.000000000782997609"), // %2.5 apr
|
|
LiquidationPenalty: d("0.025"),
|
|
AuctionSize: i(10000000),
|
|
Prefix: 0x21,
|
|
SpotMarketID: "btc:usd",
|
|
LiquidationMarketID: "btc:usd",
|
|
ConversionFactor: i(8),
|
|
},
|
|
{
|
|
Denom: "bnb",
|
|
Type: "bnb-a",
|
|
LiquidationRatio: sdk.MustNewDecFromStr("1.5"),
|
|
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
|
StabilityFee: sdk.MustNewDecFromStr("1.000000001547125958"), // %5 apr
|
|
LiquidationPenalty: d("0.05"),
|
|
AuctionSize: i(50000000000),
|
|
Prefix: 0x22,
|
|
SpotMarketID: "bnb:usd",
|
|
LiquidationMarketID: "bnb:usd",
|
|
ConversionFactor: i(8),
|
|
},
|
|
{
|
|
Denom: "busd",
|
|
Type: "busd-a",
|
|
LiquidationRatio: d("1.01"),
|
|
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
|
StabilityFee: sdk.OneDec(), // %0 apr
|
|
LiquidationPenalty: d("0.05"),
|
|
AuctionSize: i(10000000000),
|
|
Prefix: 0x23,
|
|
SpotMarketID: "busd:usd",
|
|
LiquidationMarketID: "busd:usd",
|
|
ConversionFactor: i(8),
|
|
},
|
|
},
|
|
DebtParam: cdp.DebtParam{
|
|
Denom: "usdx",
|
|
ReferenceAsset: "usd",
|
|
ConversionFactor: i(6),
|
|
DebtFloor: i(10000000),
|
|
},
|
|
},
|
|
StartingCdpID: cdp.DefaultCdpStartingID,
|
|
DebtDenom: cdp.DefaultDebtDenom,
|
|
GovDenom: cdp.DefaultGovDenom,
|
|
CDPs: cdp.CDPs{},
|
|
PreviousAccumulationTimes: cdp.GenesisAccumulationTimes{
|
|
cdp.NewGenesisAccumulationTime("btc-a", time.Time{}, sdk.OneDec()),
|
|
cdp.NewGenesisAccumulationTime("xrp-a", time.Time{}, sdk.OneDec()),
|
|
cdp.NewGenesisAccumulationTime("busd-a", time.Time{}, sdk.OneDec()),
|
|
cdp.NewGenesisAccumulationTime("bnb-a", time.Time{}, sdk.OneDec()),
|
|
},
|
|
TotalPrincipals: cdp.GenesisTotalPrincipals{
|
|
cdp.NewGenesisTotalPrincipal("btc-a", sdk.ZeroInt()),
|
|
cdp.NewGenesisTotalPrincipal("xrp-a", sdk.ZeroInt()),
|
|
cdp.NewGenesisTotalPrincipal("busd-a", sdk.ZeroInt()),
|
|
cdp.NewGenesisTotalPrincipal("bnb-a", sdk.ZeroInt()),
|
|
},
|
|
}
|
|
return app.GenesisState{cdp.ModuleName: cdp.ModuleCdc.MustMarshalJSON(cdpGenesis)}
|
|
}
|
|
|
|
func NewPricefeedGenStateMulti() app.GenesisState {
|
|
pfGenesis := pricefeed.GenesisState{
|
|
Params: pricefeed.Params{
|
|
Markets: []pricefeed.Market{
|
|
{MarketID: "btc:usd", BaseAsset: "btc", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
{MarketID: "xrp:usd", BaseAsset: "xrp", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
{MarketID: "bnb:usd", BaseAsset: "bnb", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
{MarketID: "busd:usd", BaseAsset: "busd", QuoteAsset: "usd", Oracles: []sdk.AccAddress{}, Active: true},
|
|
},
|
|
},
|
|
PostedPrices: []pricefeed.PostedPrice{
|
|
{
|
|
MarketID: "btc:usd",
|
|
OracleAddress: sdk.AccAddress{},
|
|
Price: sdk.MustNewDecFromStr("8000.00"),
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
},
|
|
{
|
|
MarketID: "xrp:usd",
|
|
OracleAddress: sdk.AccAddress{},
|
|
Price: sdk.MustNewDecFromStr("0.25"),
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
},
|
|
{
|
|
MarketID: "bnb:usd",
|
|
OracleAddress: sdk.AccAddress{},
|
|
Price: sdk.MustNewDecFromStr("17.25"),
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
},
|
|
{
|
|
MarketID: "busd:usd",
|
|
OracleAddress: sdk.AccAddress{},
|
|
Price: sdk.OneDec(),
|
|
Expiry: time.Now().Add(1 * time.Hour),
|
|
},
|
|
},
|
|
}
|
|
return app.GenesisState{pricefeed.ModuleName: pricefeed.ModuleCdc.MustMarshalJSON(pfGenesis)}
|
|
}
|
|
|
|
func NewIncentiveGenState(previousAccumTime, endTime time.Time, rewardPeriods ...incentive.RewardPeriod) app.GenesisState {
|
|
var accumulationTimes incentive.GenesisAccumulationTimes
|
|
for _, rp := range rewardPeriods {
|
|
accumulationTimes = append(
|
|
accumulationTimes,
|
|
incentive.NewGenesisAccumulationTime(
|
|
rp.CollateralType,
|
|
previousAccumTime,
|
|
),
|
|
)
|
|
}
|
|
genesis := incentive.NewGenesisState(
|
|
incentive.NewParams(
|
|
rewardPeriods,
|
|
types.MultiRewardPeriods{},
|
|
types.MultiRewardPeriods{},
|
|
types.RewardPeriods{},
|
|
incentive.Multipliers{
|
|
incentive.NewMultiplier(incentive.Small, 1, d("0.25")),
|
|
incentive.NewMultiplier(incentive.Large, 12, d("1.0")),
|
|
},
|
|
endTime,
|
|
),
|
|
accumulationTimes,
|
|
accumulationTimes,
|
|
accumulationTimes,
|
|
incentive.DefaultGenesisAccumulationTimes,
|
|
incentive.DefaultUSDXClaims,
|
|
incentive.DefaultHardClaims,
|
|
)
|
|
return app.GenesisState{incentive.ModuleName: incentive.ModuleCdc.MustMarshalJSON(genesis)}
|
|
}
|
|
|
|
func NewCDPGenStateHighInterest() app.GenesisState {
|
|
cdpGenesis := cdp.GenesisState{
|
|
Params: cdp.Params{
|
|
GlobalDebtLimit: sdk.NewInt64Coin("usdx", 2000000000000),
|
|
SurplusAuctionThreshold: cdp.DefaultSurplusThreshold,
|
|
SurplusAuctionLot: cdp.DefaultSurplusLot,
|
|
DebtAuctionThreshold: cdp.DefaultDebtThreshold,
|
|
DebtAuctionLot: cdp.DefaultDebtLot,
|
|
CollateralParams: cdp.CollateralParams{
|
|
{
|
|
Denom: "bnb",
|
|
Type: "bnb-a",
|
|
LiquidationRatio: sdk.MustNewDecFromStr("1.5"),
|
|
DebtLimit: sdk.NewInt64Coin("usdx", 500000000000),
|
|
StabilityFee: sdk.MustNewDecFromStr("1.000000051034942716"), // 500% APR
|
|
LiquidationPenalty: d("0.05"),
|
|
AuctionSize: i(50000000000),
|
|
Prefix: 0x22,
|
|
SpotMarketID: "bnb:usd",
|
|
LiquidationMarketID: "bnb:usd",
|
|
ConversionFactor: i(8),
|
|
},
|
|
},
|
|
DebtParam: cdp.DebtParam{
|
|
Denom: "usdx",
|
|
ReferenceAsset: "usd",
|
|
ConversionFactor: i(6),
|
|
DebtFloor: i(10000000),
|
|
},
|
|
},
|
|
StartingCdpID: cdp.DefaultCdpStartingID,
|
|
DebtDenom: cdp.DefaultDebtDenom,
|
|
GovDenom: cdp.DefaultGovDenom,
|
|
CDPs: cdp.CDPs{},
|
|
PreviousAccumulationTimes: cdp.GenesisAccumulationTimes{
|
|
cdp.NewGenesisAccumulationTime("bnb-a", time.Time{}, sdk.OneDec()),
|
|
},
|
|
TotalPrincipals: cdp.GenesisTotalPrincipals{
|
|
cdp.NewGenesisTotalPrincipal("bnb-a", sdk.ZeroInt()),
|
|
},
|
|
}
|
|
return app.GenesisState{cdp.ModuleName: cdp.ModuleCdc.MustMarshalJSON(cdpGenesis)}
|
|
}
|