-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
58 lines (48 loc) · 1.73 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
58
package v0_15
import (
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
const (
// ModuleName name that will be used throughout the module
ModuleName = "swap"
)
// GenesisState is the state that must be provided at genesis.
type GenesisState struct {
Params Params `json:"params" yaml:"params"`
PoolRecords `json:"pool_records" yaml:"pool_records"`
ShareRecords `json:"share_records" yaml:"share_records"`
}
// Params are governance parameters for the swap module
type Params struct {
AllowedPools AllowedPools `json:"allowed_pools" yaml:"allowed_pools"`
SwapFee sdk.Dec `json:"swap_fee" yaml:"swap_fee"`
}
// PoolRecords is a slice of PoolRecord
type PoolRecords []PoolRecord
// PoolRecord represents the state of a liquidity pool
// and is used to store the state of a denominated pool
type PoolRecord struct {
// primary key
PoolID string `json:"pool_id" yaml:"pool_id"`
ReservesA sdk.Coin `json:"reserves_a" yaml:"reserves_a"`
ReservesB sdk.Coin `json:"reserves_b" yaml:"reserves_b"`
TotalShares sdkmath.Int `json:"total_shares" yaml:"total_shares"`
}
// ShareRecords is a slice of ShareRecord
type ShareRecords []ShareRecord
// ShareRecord stores the shares owned for a depositor and pool
type ShareRecord struct {
// primary key
Depositor sdk.AccAddress `json:"depositor" yaml:"depositor"`
// secondary / sort key
PoolID string `json:"pool_id" yaml:"pool_id"`
SharesOwned sdkmath.Int `json:"shares_owned" yaml:"shares_owned"`
}
// AllowedPools is a slice of AllowedPool
type AllowedPools []AllowedPool
// AllowedPool defines a tradable pool
type AllowedPool struct {
TokenA string `json:"token_a" yaml:"token_a"`
TokenB string `json:"token_b" yaml:"token_b"`
}