-
Notifications
You must be signed in to change notification settings - Fork 568
/
store_model.go
103 lines (81 loc) · 2.94 KB
/
store_model.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package model
import (
"encoding/json"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/v20/x/cosmwasmpool/types"
poolmanagertypes "github.com/osmosis-labs/osmosis/v20/x/poolmanager/types"
)
var (
// NOTE:
// CosmWasmPool represents the data serialized into state for each CW pool.
//
// CW Pool has 2 pool models:
// - CosmWasmPool which is a proto-generated store model used for serialization into state.
// - Pool struct that encapsulates the CosmWasmPool and wasmKeeper for calling the contract.
//
// CosmWasmPool implements the poolmanager.PoolI interface but it panics on all methods.
// The reason is that access to wasmKeeper is required to call the contract.
//
// Instead, all interactions and poolmanager.PoolI methods are to be performed
// on the Pool struct. The reason why we cannot have a Pool struct only is
// because it cannot be serialized into state due to having a non-serializable wasmKeeper field.
_ poolmanagertypes.PoolI = &CosmWasmPool{}
_ types.CosmWasmExtension = &CosmWasmPool{}
)
// String returns the json marshalled string of the pool
func (p CosmWasmPool) String() string {
out, err := json.Marshal(p)
if err != nil {
panic(err)
}
return string(out)
}
// poolmanager.PoolI interface implementation
func (p CosmWasmPool) GetAddress() sdk.AccAddress {
return sdk.MustAccAddressFromBech32(p.ContractAddress)
}
func (p CosmWasmPool) GetId() uint64 {
return p.PoolId
}
func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) osmomath.Dec {
panic("CosmWasmPool.GetSpreadFactor not implemented")
}
func (p CosmWasmPool) GetExitFee(ctx sdk.Context) osmomath.Dec {
panic("CosmWasmPool.GetExitFee not implemented")
}
func (p CosmWasmPool) IsActive(ctx sdk.Context) bool {
panic("CosmWasmPool.IsActive not implemented")
}
func (p CosmWasmPool) SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (osmomath.BigDec, error) {
panic("CosmWasmPool.SpotPrice not implemented")
}
func (p CosmWasmPool) GetType() poolmanagertypes.PoolType {
return poolmanagertypes.CosmWasm
}
func (p CosmWasmPool) GetTotalPoolLiquidity(ctx sdk.Context) sdk.Coins {
panic("CosmWasmPool.GetTotalPoolLiquidity not implemented")
}
// types.CosmWasmExtension interface implementation
func (p CosmWasmPool) GetCodeId() uint64 {
return p.CodeId
}
func (p CosmWasmPool) GetInstantiateMsg() []byte {
return p.InstantiateMsg
}
func (p CosmWasmPool) GetContractAddress() string {
return p.ContractAddress
}
func (p *CosmWasmPool) SetContractAddress(contractAddress string) {
p.ContractAddress = contractAddress
}
func (p CosmWasmPool) GetStoreModel() poolmanagertypes.PoolI {
return &p
}
func (p CosmWasmPool) SetWasmKeeper(wasmKeeper types.WasmKeeper) {
panic("CosmWasmPool.SetWasmKeeeper not implemented")
}
// GetPoolDenoms implements types.PoolI.
func (p *CosmWasmPool) GetPoolDenoms(ctx sdk.Context) []string {
panic("CosmWasmPool.GetPoolDenoms not implemented")
}