Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(wasmbindings): remove gamm and twap bindings #3766

Merged
merged 2 commits into from
Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### API breaks

* [#3763](https://github.com/osmosis-labs/osmosis/pull/3763) Move binary search and error tolerance code from `osmoutils` into `osmomath`
* [#376x](https://github.com/osmosis-labs/osmosis/pull/3763) Remove Osmosis gamm and twap `bindings` that were previously supported as custom wasm plugins.

### Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
// if we want to allow any custom callbacks
supportedFeatures := "iterator,staking,stargate,osmosis,cosmwasm_1_1"

wasmOpts = append(owasm.RegisterCustomPlugins(appKeepers.GAMMKeeper, appKeepers.BankKeeper, appKeepers.TwapKeeper, appKeepers.TokenFactoryKeeper), wasmOpts...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bank definitely still needs to be there. TokenFactory is moving to general bindings as well, so I think we should keep that for now.

ACK for gamm + twap

wasmOpts = append(owasm.RegisterCustomPlugins(appKeepers.BankKeeper, appKeepers.TokenFactoryKeeper), wasmOpts...)
wasmOpts = append(owasm.RegisterStargateQueries(*bApp.GRPCQueryRouter(), appCodec), wasmOpts...)

wasmKeeper := wasm.NewKeeper(
Expand Down
8 changes: 0 additions & 8 deletions wasmbinding/bindings/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ type OsmosisMsg struct {
/// that they are the admin of.
/// Currently, the burn from address must be the admin contract.
BurnTokens *BurnTokens `json:"burn_tokens,omitempty"`
/// Swap over one or more pools
Swap *SwapMsg `json:"swap,omitempty"`
}

// CreateDenom creates a new factory denom, of denomination:
Expand Down Expand Up @@ -48,9 +46,3 @@ type BurnTokens struct {
// BurnFromAddress must be set to "" for now.
BurnFromAddress string `json:"burn_from_address"`
}

type SwapMsg struct {
First Swap `json:"first"`
Route []Step `json:"route"`
Amount SwapAmountWithLimit `json:"amount"`
}
8 changes: 0 additions & 8 deletions wasmbinding/bindings/pool.go

This file was deleted.

73 changes: 0 additions & 73 deletions wasmbinding/bindings/query.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,11 @@
package bindings

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"`
/// Returns the admin of a denom, if the denom is a Token Factory denom.
DenomAdmin *DenomAdmin `json:"denom_admin,omitempty"`
}
Expand All @@ -36,66 +23,6 @@ type DenomAdminResponse struct {
Admin string `json:"admin"`
}

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"`
}

type ArithmeticTwap struct {
PoolId uint64 `json:"id"`
QuoteAssetDenom string `json:"quote_asset_denom"`
BaseAssetDenom string `json:"base_asset_denom"`
// NOTE: StartTime is expected to be in Unix time milliseconds.
StartTime int64 `json:"start_time"`
// NOTE: EndTime is expected to be in Unix time milliseconds.
EndTime int64 `json:"end_time"`
}

type ArithmeticTwapToNow struct {
PoolId uint64 `json:"id"`
QuoteAssetDenom string `json:"quote_asset_denom"`
BaseAssetDenom string `json:"base_asset_denom"`
// NOTE: StartTime is expected to be in Unix time milliseconds.
StartTime int64 `json:"start_time"`
}

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"`
}
74 changes: 0 additions & 74 deletions wasmbinding/bindings/types.go

This file was deleted.

179 changes: 0 additions & 179 deletions wasmbinding/bindings/types_test.go

This file was deleted.

Loading