mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-27 08:45:19 +00:00
4e6f6d1e9c
* spike: incentive/types * spike: incentive/types tests * spike: incentive/types/expected_keepers.go * spike: incentive/keeper * spike: incentive/keeper tests * spike: incentive/sims and incentive/sims tests * spike: incentive/module * spike: incentive/module tests * spike: hard/types * spike: hard/types hooks * spike: hard/types * spike: hard/keeper basics * spike: hard/keeper hooks * integrate hard/keeper/borrow.go * integrate hard/keeper/deposit.go * integrate hard/keeper/liquidation.go * integrate hard/keeper/withdraw.go * integrate hard/keeper/repay.go * spike: hard/sims * spike: hard/sims tests * spike: hard/client * spike: hard/module * integrate app.go * spike: x/hard/keeper compile tests * incentive/keeper test clean up * validate usdx incentive types in genesis * refactoring & fix deposit test * fix liquidaton tests * fix incentive tests for hard supply rewards * fix hard genesis tests * update incentive genesis state and params * update cdp rewards accumulation * update app init order and begin blocker order Co-authored-by: karzak <kjydavis3@gmail.com>
84 lines
3.1 KiB
Go
84 lines
3.1 KiB
Go
package simulation
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/tendermint/tendermint/libs/kv"
|
|
|
|
"github.com/kava-labs/kava/x/incentive/types"
|
|
)
|
|
|
|
// DecodeStore unmarshals the KVPair's Value to the module's corresponding type
|
|
func DecodeStore(cdc *codec.Codec, kvA, kvB kv.Pair) string {
|
|
switch {
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.USDXMintingClaimKeyPrefix):
|
|
var claimA, claimB types.USDXMintingClaim
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &claimA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &claimB)
|
|
return fmt.Sprintf("%v\n%v", claimA, claimB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.PreviousUSDXMintingRewardAccrualTimeKeyPrefix):
|
|
var timeA, timeB time.Time
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
|
return fmt.Sprintf("%s\n%s", timeA, timeB)
|
|
|
|
case bytes.Equal(kvA.Key[:1], types.USDXMintingRewardFactorKeyPrefix):
|
|
var factorA, factorB sdk.Dec
|
|
cdc.MustUnmarshalBinaryBare(kvA.Value, &factorA)
|
|
cdc.MustUnmarshalBinaryBare(kvB.Value, &factorB)
|
|
return fmt.Sprintf("%s\n%s", factorA, factorB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.HardLiquidityClaimKeyPrefix):
|
|
// var claimA, claimB types.HardLiquidityProviderClaim
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &claimA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &claimB)
|
|
// return fmt.Sprintf("%v\n%v", claimA, claimB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.PreviousHardSupplyRewardAccrualTimeKeyPrefix):
|
|
// var timeA, timeB time.Time
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
|
// return fmt.Sprintf("%s\n%s", timeA, timeB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.HardSupplyRewardFactorKeyPrefix):
|
|
// var factorA, factorB sdk.Dec
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &factorA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &factorB)
|
|
// return fmt.Sprintf("%s\n%s", factorA, factorB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.PreviousHardBorrowRewardAccrualTimeKeyPrefix):
|
|
// var timeA, timeB time.Time
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
|
// return fmt.Sprintf("%s\n%s", timeA, timeB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.HardSupplyRewardFactorKeyPrefix):
|
|
// var factorA, factorB sdk.Dec
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &factorA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &factorB)
|
|
// return fmt.Sprintf("%s\n%s", factorA, factorB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.PreviousHardDelegatorRewardAccrualTimeKeyPrefix):
|
|
// var timeA, timeB time.Time
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &timeA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &timeB)
|
|
// return fmt.Sprintf("%s\n%s", timeA, timeB)
|
|
|
|
// case bytes.Equal(kvA.Key[:1], types.HardDelegatorRewardFactorKeyPrefix):
|
|
// var factorA, factorB sdk.Dec
|
|
// cdc.MustUnmarshalBinaryBare(kvA.Value, &factorA)
|
|
// cdc.MustUnmarshalBinaryBare(kvB.Value, &factorB)
|
|
// return fmt.Sprintf("%s\n%s", factorA, factorB)
|
|
|
|
default:
|
|
panic(fmt.Sprintf("invalid %s key prefix %X", types.ModuleName, kvA.Key[:1]))
|
|
}
|
|
}
|