forked from crescent-network/crescent
/
util.go
39 lines (32 loc) 路 1.29 KB
/
util.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package types
import (
"strconv"
"strings"
sdk "github.com/cosmos/cosmos-sdk/types"
farmingtypes "github.com/jesse-pinkman-cre/crescent/x/farming/types"
)
const (
PayingReserveAddressPrefix string = "PayingReserveAddress"
WithdrawnRewardsReserveAddressPrefix string = "WithdrawnRewardsReserveAddress"
ModuleAddressNameSplitter string = "|"
// The module uses the address type of 32 bytes length, but it can always be changed depending on Cosmos SDK's direction.
ReserveAddressType = farmingtypes.AddressType32Bytes
)
// PayingReserveAddress creates the paying reserve address in the form of sdk.AccAddress
// with the given pool id.
func PayingReserveAddress(poolId uint64) sdk.AccAddress {
return farmingtypes.DeriveAddress(
ReserveAddressType,
ModuleName,
strings.Join([]string{PayingReserveAddressPrefix, strconv.FormatUint(poolId, 10)}, ModuleAddressNameSplitter),
)
}
// WithdrawnRewardsReserveAddress creates the withdrawn rewards reserve address in the form of sdk.AccAddress
// with the given pool id.
func WithdrawnRewardsReserveAddress(poolId uint64) sdk.AccAddress {
return farmingtypes.DeriveAddress(
ReserveAddressType,
ModuleName,
strings.Join([]string{WithdrawnRewardsReserveAddressPrefix, strconv.FormatUint(poolId, 10)}, ModuleAddressNameSplitter),
)
}