Skip to content

Commit

Permalink
refactor(wasmbindings): remove gamm and twap bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn committed Dec 16, 2022
1 parent 3095a7d commit 2d8ff60
Show file tree
Hide file tree
Showing 19 changed files with 7 additions and 2,031 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,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 @@ -369,7 +369,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...)
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

0 comments on commit 2d8ff60

Please sign in to comment.