-
Notifications
You must be signed in to change notification settings - Fork 117
/
types.go
executable file
·57 lines (44 loc) · 2.11 KB
/
types.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
func (p Pool) Validate() bool {
if !p.ExternalAsset.Validate() {
return false
}
return true
}
// NewPool returns a new Pool
func NewPool(externalAsset *Asset, nativeAssetBalance, externalAssetBalance, poolUnits sdk.Uint) Pool {
pool := Pool{ExternalAsset: externalAsset,
NativeAssetBalance: nativeAssetBalance,
ExternalAssetBalance: externalAssetBalance,
PoolUnits: poolUnits}
return pool
}
type Pools []Pool
type LiquidityProviders []LiquidityProvider
func (l LiquidityProvider) Validate() bool {
if !l.Asset.Validate() {
return false
}
return true
}
// NewLiquidityProvider returns a new LiquidityProvider
func NewLiquidityProvider(asset *Asset, liquidityProviderUnits sdk.Uint, liquidityProviderAddress sdk.AccAddress) LiquidityProvider {
return LiquidityProvider{Asset: asset, LiquidityProviderUnits: liquidityProviderUnits, LiquidityProviderAddress: liquidityProviderAddress.String()}
}
// ----------------------------------------------------------------------------
// Client Types
func NewLiquidityProviderResponse(liquidityProvider LiquidityProvider, height int64, nativeBalance string, externalBalance string) LiquidityProviderRes {
return LiquidityProviderRes{LiquidityProvider: &liquidityProvider, Height: height, NativeAssetBalance: nativeBalance, ExternalAssetBalance: externalBalance}
}
func NewLiquidityProviderDataResponse(liquidityProviderData []*LiquidityProviderData, height int64) LiquidityProviderDataRes {
return LiquidityProviderDataRes{LiquidityProviderData: liquidityProviderData, Height: height}
}
func NewLiquidityProviderData(liquidityProvider LiquidityProvider, nativeBalance string, externalBalance string) LiquidityProviderData {
return LiquidityProviderData{LiquidityProvider: &liquidityProvider, NativeAssetBalance: nativeBalance, ExternalAssetBalance: externalBalance}
}
func NewPmtpParamsResponse(params *PmtpParams, pmtpRateParams PmtpRateParams, pmtpEpoch PmtpEpoch, height int64) PmtpParamsRes {
return PmtpParamsRes{Params: params, PmtpRateParams: &pmtpRateParams, PmtpEpoch: &pmtpEpoch, Height: height}
}