2021-06-08 15:19:12 +00:00
<!--
order: 2
-->
# State
## Parameters and Genesis State
`Parameters` define the governance parameters and default behavior of the swap module.
```go
// 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"`
}
// AllowedPool defines a tradable pool
type AllowedPool struct {
TokenA string `json:"token_a" yaml:"token_a"`
TokenB string `json:"token_b" yaml:"token_b"`
}
// AllowedPools is a slice of AllowedPool
type AllowedPools []AllowedPool
```
`GenesisState` defines the state that must be persisted when the blockchain stops/restarts in order for the normal function of the swap module to resume.
```go
// GenesisState is the state that must be provided at genesis.
type GenesisState struct {
2021-07-15 22:34:16 +00:00
Params Params `json:"params" yaml:"params"`
PoolRecords `json:"pool_records" yaml:"pool_records"`
ShareRecords `json:"share_records" yaml:"share_records"`
2021-06-08 15:19:12 +00:00
}
2021-07-15 22:34:16 +00:00
// 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"`
2023-04-05 23:21:59 +00:00
TotalShares sdkmath.Int `json:"total_shares" yaml:"total_shares"`
2021-07-15 22:34:16 +00:00
}
// PoolRecords is a slice of PoolRecord
type PoolRecords []PoolRecord
// 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"`
2023-04-05 23:21:59 +00:00
SharesOwned sdkmath.Int `json:"shares_owned" yaml:"shares_owned"`
2021-07-15 22:34:16 +00:00
}
// ShareRecords is a slice of ShareRecord
type ShareRecords []ShareRecord
2021-06-08 15:19:12 +00:00
```