From f611e01c7fb9ab9d5348250cb0b65e08f3ec651b Mon Sep 17 00:00:00 2001 From: Nicolas Lara Date: Tue, 3 Jan 2023 16:56:37 +0100 Subject: [PATCH] Fix stableswap use of osmomath (#3909) * remove the name of the input parameter so that implementors can use other names * updated osmomath * fixed typo --- go.mod | 2 +- go.sum | 4 ++-- go.work.sum | 3 +-- osmomath/binary_search.go | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 963de50825a..7e1522bc008 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.16 github.com/ory/dockertest/v3 v3.9.1 github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 - github.com/osmosis-labs/osmosis/osmomath v0.0.2 + github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230103093812-a17356c326b8 github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 331132926c0..789b2a04ba7 100644 --- a/go.sum +++ b/go.sum @@ -853,8 +853,8 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e h1:A3by github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20221118211718-545aed73e94e/go.mod h1:rud0OaBIuq3+qOqtwT4SR7Q7iSzRp7w41fjninTjfnQ= github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY= github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI= -github.com/osmosis-labs/osmosis/osmomath v0.0.2 h1:8vTobkYfoRTCJCie+jE7gzXvqUUfoPI4NSvTskoci50= -github.com/osmosis-labs/osmosis/osmomath v0.0.2/go.mod h1:IpoXO7lvmfsBFfQzaqovs541hpqtrnM+GJSZDi/TZtc= +github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230103093812-a17356c326b8 h1:5dJz+/3lt7vqKdbvjLK8ews/EAZ8mPByQJr0zdQ6cuM= +github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230103093812-a17356c326b8/go.mod h1:IpoXO7lvmfsBFfQzaqovs541hpqtrnM+GJSZDi/TZtc= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf h1:FZOlrTSaf/YWokt3+tSSZpcu6zu3dXLhsvhJWkHeBxU= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:T7CCZKYhKWASnv5mRE8u3m0gst3NZ/sU16Brjmv4UPw= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf h1:qcDUVsM6BNuGJ3dfGs3onOPzR0donLgXznqv60HRk+8= diff --git a/go.work.sum b/go.work.sum index 0b2b9ef4906..478c2f53276 100644 --- a/go.work.sum +++ b/go.work.sum @@ -259,9 +259,8 @@ github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xA github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:T7CCZKYhKWASnv5mRE8u3m0gst3NZ/sU16Brjmv4UPw= +github.com/osmosis-labs/osmosis/osmomath v0.0.0-20230103093812-a17356c326b8/go.mod h1:IpoXO7lvmfsBFfQzaqovs541hpqtrnM+GJSZDi/TZtc= github.com/osmosis-labs/osmosis/osmoutils v0.0.2-flexible/go.mod h1:T7CCZKYhKWASnv5mRE8u3m0gst3NZ/sU16Brjmv4UPw= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230101095308-fa4e70e17dbf/go.mod h1:5zNisZDypMTW32EABSuWI/EacHC48590PpSO9QwFzCg= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.3/go.mod h1:bASDMbNQ0vD+2YRsEqlKXg8NiEsJpQ8B8p3nR8kB+hA= github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI= diff --git a/osmomath/binary_search.go b/osmomath/binary_search.go index d43c9dd3b45..dd01573dee0 100644 --- a/osmomath/binary_search.go +++ b/osmomath/binary_search.go @@ -144,7 +144,7 @@ func (e ErrTolerance) CompareBigDec(expected BigDec, actual BigDec) int { // Binary search inputs between [lowerbound, upperbound] to a monotonic increasing function f. // We stop once f(found_input) meets the ErrTolerance constraints. // If we perform more than maxIterations (or equivalently lowerbound = upperbound), we return an error. -func BinarySearch(f func(input sdk.Int) (sdk.Int, error), +func BinarySearch(f func(sdk.Int) (sdk.Int, error), lowerbound sdk.Int, upperbound sdk.Int, targetOutput sdk.Int, @@ -192,7 +192,7 @@ type SdkDec[D any] interface { // // It binary searches on the input range, until it finds an input y s.t. f(y) meets the err tolerance constraints for how close it is to x. // If we perform more than maxIterations (or equivalently lowerbound = upperbound), we return an error. -func BinarySearchBigDec(f func(input BigDec) BigDec, +func BinarySearchBigDec(f func(BigDec) BigDec, lowerbound BigDec, upperbound BigDec, targetOutput BigDec,