forked from osmosis-labs/osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.go
73 lines (62 loc) · 2.18 KB
/
query.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
package wasmbindings
import (
wasmvmtypes "github.com/CosmWasm/wasmvm/types"
)
// OsmosisQuery contains osmosis custom queries.
// See https://github.com/osmosis-labs/osmosis-bindings/blob/main/packages/bindings/src/query.rs
type OsmosisQuery struct {
/// Given a subdenom minted by a contract via `OsmosisMsg::MintTokens`,
/// returns the full denom as used by `BankMsg::Send`.
FullDenom *FullDenom `json:"full_denom,omitempty"`
/// For a given pool ID, list all tokens traded on it with current liquidity (spot).
/// As well as the total number of LP shares and their denom.
PoolState *PoolState `json:"pool_state,omitempty"`
/// Return current spot price swapping In for Out on given pool ID.
/// Warning: this can easily be manipulated via sandwich attacks, do not use as price oracle.
/// We will add TWAP for more robust price feed.
SpotPrice *SpotPrice `json:"spot_price,omitempty"`
/// Return current spot price swapping In for Out on given pool ID.
EstimateSwap *EstimateSwap `json:"estimate_swap,omitempty"`
}
type FullDenom struct {
CreatorAddr string `json:"creator_addr"`
Subdenom string `json:"subdenom"`
}
type PoolState struct {
PoolId uint64 `json:"id"`
}
type SpotPrice struct {
Swap Swap `json:"swap"`
WithSwapFee bool `json:"with_swap_fee"`
}
type EstimateSwap struct {
Sender string `json:"sender"`
First Swap `json:"first"`
Route []Step `json:"route"`
Amount SwapAmount `json:"amount"`
}
func (e *EstimateSwap) ToSwapMsg() *SwapMsg {
return &SwapMsg{
First: e.First,
Route: e.Route,
Amount: e.Amount.Unlimited(),
}
}
type FullDenomResponse struct {
Denom string `json:"denom"`
}
type PoolStateResponse struct {
/// The various assets that be swapped. Including current liquidity.
Assets []wasmvmtypes.Coin `json:"assets"`
/// The number of LP shares and their amount
Shares wasmvmtypes.Coin `json:"shares"`
}
type SpotPriceResponse struct {
/// How many output we would get for 1 input
Price string `json:"price"`
}
type EstimatePriceResponse struct {
// If you query with SwapAmount::Input, this is SwapAmount::Output.
// If you query with SwapAmount::Output, this is SwapAmount::Input.
Amount SwapAmount `json:"swap_amount"`
}