-
Notifications
You must be signed in to change notification settings - Fork 30
/
utils.go
36 lines (29 loc) · 1.04 KB
/
utils.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
package types
import (
"fmt"
"strings"
"github.com/tendermint/tendermint/crypto"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// GetReservePoolAddr returns the poor address for the provided provided liquidity denomination.
func GetReservePoolAddr(uniDenom string) sdk.AccAddress {
return sdk.AccAddress(crypto.AddressHash([]byte(uniDenom)))
}
// GetTokenPairByDenom return the token pair for the provided denominations
func GetTokenPairByDenom(inputDenom, outputDenom string) string {
return fmt.Sprintf("%s-%s", outputDenom, inputDenom)
}
// GetUniDenomFromDenom returns the uni denom for the provided denomination.
func GetUniDenomFromDenom(denom string) (string, error) {
if denom == StandardDenom {
return "", ErrMustStandardDenom
}
return fmt.Sprintf(FormatUniDenom, denom), nil
}
// GetCoinDenomFromUniDenom returns the token denom by uni denom
func GetCoinDenomFromUniDenom(uniDenom string) (string, error) {
if err := ValidateUniDenom(uniDenom); err != nil {
return "", err
}
return strings.TrimPrefix(uniDenom, FormatUniABSPrefix), nil
}