package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
)
const (
ModuleName = "liquidity"
RouterKey = ModuleName
StoreKey = ModuleName
PoolCoinDenomPrefix = "pool"
)
var (
GlobalLiquidityPoolIDKey = []byte("globalLiquidityPoolId")
ParamsKey = []byte{0x01}
PoolKeyPrefix = []byte{0x11}
PoolByReserveAccIndexKeyPrefix = []byte{0x12}
PoolBatchKeyPrefix = []byte{0x22}
PoolBatchDepositMsgStateIndexKeyPrefix = []byte{0x31}
PoolBatchWithdrawMsgStateIndexKeyPrefix = []byte{0x32}
PoolBatchSwapMsgStateIndexKeyPrefix = []byte{0x33}
)
func GetPoolKey(poolID uint64) []byte {
key := make([]byte, 9)
key[0] = PoolKeyPrefix[0]
copy(key[1:], sdk.Uint64ToBigEndian(poolID))
return key
}
func GetPoolByReserveAccIndexKey(reserveAcc sdk.AccAddress) []byte {
return append(PoolByReserveAccIndexKeyPrefix, address.MustLengthPrefix(reserveAcc.Bytes())...)
}
func GetPoolBatchKey(poolID uint64) []byte {
key := make([]byte, 9)
key[0] = PoolBatchKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
return key
}
func GetPoolBatchDepositMsgStatesPrefix(poolID uint64) []byte {
key := make([]byte, 9)
key[0] = PoolBatchDepositMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
return key
}
func GetPoolBatchWithdrawMsgsPrefix(poolID uint64) []byte {
key := make([]byte, 9)
key[0] = PoolBatchWithdrawMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
return key
}
func GetPoolBatchSwapMsgStatesPrefix(poolID uint64) []byte {
key := make([]byte, 9)
key[0] = PoolBatchSwapMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
return key
}
func GetPoolBatchDepositMsgStateIndexKey(poolID, msgIndex uint64) []byte {
key := make([]byte, 17)
key[0] = PoolBatchDepositMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
copy(key[9:17], sdk.Uint64ToBigEndian(msgIndex))
return key
}
func GetPoolBatchWithdrawMsgStateIndexKey(poolID, msgIndex uint64) []byte {
key := make([]byte, 17)
key[0] = PoolBatchWithdrawMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
copy(key[9:17], sdk.Uint64ToBigEndian(msgIndex))
return key
}
func GetPoolBatchSwapMsgStateIndexKey(poolID, msgIndex uint64) []byte {
key := make([]byte, 17)
key[0] = PoolBatchSwapMsgStateIndexKeyPrefix[0]
copy(key[1:9], sdk.Uint64ToBigEndian(poolID))
copy(key[9:17], sdk.Uint64ToBigEndian(msgIndex))
return key
}