From 4eb859489539ad9ed2b509b091955329bda3b80b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 11 Aug 2023 10:15:11 -0500 Subject: [PATCH 01/83] add taker fee determination and extraction --- go.mod | 2 + go.sum | 28 +- .../osmosis/poolmanager/v1beta1/genesis.proto | 24 + x/poolmanager/router.go | 88 +++- x/poolmanager/types/genesis.pb.go | 426 ++++++++++++++++-- x/poolmanager/types/params.go | 17 +- x/poolmanager/types/routes.go | 2 + 7 files changed, 525 insertions(+), 62 deletions(-) diff --git a/go.mod b/go.mod index 996b22cc319..73908d89e3a 100644 --- a/go.mod +++ b/go.mod @@ -50,6 +50,7 @@ require ( github.com/Djarvur/go-err113 v0.1.0 // indirect github.com/alingse/asasalint v0.0.11 // indirect github.com/benbjohnson/clock v1.3.0 // indirect + github.com/bytedance/sonic v1.10.0 // indirect github.com/cosmos/gogoproto v1.4.6 // indirect github.com/cosmos/iavl v0.19.5 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect @@ -57,6 +58,7 @@ require ( github.com/docker/distribution v2.8.2+incompatible // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/gogo/gateway v1.1.0 // indirect github.com/google/btree v1.1.2 // indirect github.com/junk1tm/musttag v0.5.0 // indirect diff --git a/go.sum b/go.sum index f63f8c4e5b4..ddfd71b4c84 100644 --- a/go.sum +++ b/go.sum @@ -189,6 +189,10 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f github.com/butuzov/ireturn v0.1.1 h1:QvrO2QF2+/Cx1WA/vETCIYBKtRjc30vesdoPUNo1EbY= github.com/butuzov/ireturn v0.1.1/go.mod h1:Wh6Zl3IMtTpaIKbmwzqi6olnM9ptYQxxVacMsOEFPoc= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/bytedance/sonic v1.10.0-rc/go.mod h1:ElCzW+ufi8qKqNW0FY314xriJhyJhuoJ3gFZdAHF7NM= +github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +github.com/bytedance/sonic v1.10.0/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -209,6 +213,12 @@ github.com/charithe/durationcheck v0.0.10/go.mod h1:bCWXb7gYRysD1CU3C+u4ceO49LoG github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 h1:W9o46d2kbNL06lq7UNDPV0zYLzkrde/bjIqO02eoll0= github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8/go.mod h1:gakxgyXaaPkxvLw1XQxNGK4I37ys9iBRzNUx/B7pUCo= github.com/checkpoint-restore/go-criu/v5 v5.3.0/go.mod h1:E/eQpaFtUKGOOSEBZgmKAcn+zUUwWxqcaKZlF54wK8E= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk= +github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0= +github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d/go.mod h1:8EPpVsBuRksnlj1mLy4AWzRNQYxauNi62uWcE3to6eA= +github.com/chenzhuoyu/iasm v0.9.0 h1:9fhXjVzq5hUy2gkhhgHl95zG2cEAhw9OSGs8toWWAwo= +github.com/chenzhuoyu/iasm v0.9.0/go.mod h1:Xjy2NpN3h7aUqeqM+woSuuvxmIe6+DDsiNLIrkAmYog= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -377,7 +387,7 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= -github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= +github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= @@ -444,6 +454,7 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -743,9 +754,13 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -942,16 +957,10 @@ github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:Ylmch 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.3-dev.0.20230804142026-a81cfe3ddde7 h1:NTR4zfrPMP4pJ5T60zyZumBAnTWmTAQX/JSZLGrM9jI= github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230804142026-a81cfe3ddde7/go.mod h1:UlftwozB+QObT3o0YfkuuyL9fsVdgoWt0dm6J7MLYnU= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230505120443-447d8f14811f h1:eXazuLCKEjXTlciPaSJqtNdSVE+CCiyhgC32p1b30qs= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230505120443-447d8f14811f/go.mod h1:QeqmptMwAREnUtUTL6KbPRY+zjejIZrj3rRz4RScfyM= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae h1:I1Cy+GpTPWbVi0lBw9+bS1w42YfQjvXNK9bW4YbHhcs= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5 h1:j4ifxomFROGROHalqWwX7VPDgxOPotMB1GiAWdb03i4= github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5/go.mod h1:Pl8Nzx6O6ow/+aqfMoMSz4hX+zz6RrnDYsooptECGxM= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304/go.mod h1:yPWoJTj5RKrXKUChAicp+G/4Ni/uVEpp27mi/FF/L9c= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230505120443-447d8f14811f h1:GHbnqUSwOiNanFy+4TtOxT1MG+SeYXRn8ilVTlXOUxg= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230505120443-447d8f14811f/go.mod h1:bm9OrnwxpsZjScIPvMhhzMU97Fh4JktGH+PtircEVbw= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5 h1:clEegVniz0zTTBXKfg2oymKa63IYUxcrVXM+LtsvCpA= github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5/go.mod h1:sR0lpev9mcm9/9RY50T1og3UC3WpZAsINh/OmgrmFlg= github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 h1:X747cZYdnqc/+RV48iPVeGprpVb/fUWSaKGsZUWrdbg= @@ -1217,6 +1226,8 @@ github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+ github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= +github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= @@ -1306,6 +1317,8 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60= go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1845,6 +1858,7 @@ mvdan.cc/unparam v0.0.0-20221223090309-7455f1af531d/go.mod h1:IeHQjmn6TOD+e4Z3RF nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 3c4233c60be..9e6f798247c 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -17,6 +17,20 @@ message Params { (gogoproto.moretags) = "yaml:\"pool_creation_fee\"", (gogoproto.nullable) = false ]; + string default_taker_fee = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customname) = "DefaultTakerFee", + (gogoproto.nullable) = false + ]; + string stableswap_taker_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customname) = "StableswapTakerFee", + (gogoproto.nullable) = false + ]; + repeated CustomPoolTakerFee trading_pair_taker_fee = 4 [ + (gogoproto.customname) = "CustomPoolTakerFee", + (gogoproto.nullable) = false + ]; } // GenesisState defines the poolmanager module's genesis state. @@ -28,3 +42,13 @@ message GenesisState { // pool_routes is the container of the mappings from pool id to pool type. repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ]; } + +// CustomPoolTakerFee defines a custom taker fee for a specific pool. +message CustomPoolTakerFee { + uint64 pool_id = 1 [ (gogoproto.customname) = "PoolId" ]; + string taker_fee = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index e6e5587f889..926c82fdfca 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -9,7 +9,9 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils" appparams "github.com/osmosis-labs/osmosis/v17/app/params" + cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" + txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" ) // 1 << 256 - 1 where 256 is the max bit length defined for sdk.Int @@ -40,24 +42,6 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } - // In this loop (isOsmoRoutedMultihop), we check if: - // - the routeStep is of length 2 - // - routeStep 1 and routeStep 2 don't trade via the same pool - // - routeStep 1 contains uosmo - // - both routeStep 1 and routeStep 2 are incentivized pools - // - // If all of the above is true, then we collect the additive and max fee between the - // two pools to later calculate the following: - // total_spread_factor = max(spread_factor1, spread_factor2) - // fee_per_pool = total_spread_factor * ((pool_fee) / (spread_factor1 + spread_factor2)) - if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenOutDenom, tokenIn.Denom) { - isMultiHopRouted = true - routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) - if err != nil { - return sdk.Int{}, err - } - } - // Iterate through the route and execute a series of swaps through each pool. for i, routeStep := range route { // To prevent the multihop swap from being interrupted prematurely, we keep @@ -92,7 +76,15 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) + takerFee := k.determineTakerFee(ctx, pool) + totalFees := spreadFactor.Add(takerFee) + + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, totalFees) + if err != nil { + return sdk.Int{}, err + } + + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) if err != nil { return sdk.Int{}, err } @@ -204,9 +196,16 @@ func (k Keeper) SwapExactAmountIn( } spreadFactor := pool.GetSpreadFactor(ctx) + takerFee := k.determineTakerFee(ctx, pool) + totalFees := spreadFactor.Add(takerFee) // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, spreadFactor) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, totalFees) + if err != nil { + return sdk.Int{}, err + } + + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) if err != nil { return sdk.Int{}, err } @@ -259,6 +258,8 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } spreadFactor := poolI.GetSpreadFactor(ctx) + takerFee := k.determineTakerFee(ctx, poolI) + totalFees := spreadFactor.Add(takerFee) // If we determined the routeStep is an osmo multi-hop and both route are incentivized, // we modify the swap fee accordingly. @@ -266,7 +267,7 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, spreadFactor) + tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, totalFees) if err != nil { return sdk.Int{}, err } @@ -377,11 +378,20 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) + takerFee := k.determineTakerFee(ctx, pool) + totalFees := spreadFactor.Add(takerFee) + + _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, totalFees) if swapErr != nil { return sdk.Int{}, swapErr } + tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) + if err != nil { + return sdk.Int{}, err + } + // Sets the final amount of tokens that need to be input into the first pool. Even though this is the final return value for the // whole method and will not change after the first iteration, we still iterate through the rest of the pools to execute their respective // swaps. @@ -741,3 +751,37 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { totalLiquidity := totalGammLiquidity.Add(totalConcentratedLiquidity...).Add(totalCosmwasmLiquidity...) return totalLiquidity, nil } + +// determineTakerFee takes in a pool and determines the taker fee based on the pool type. +// If the pool is a stableswap pool, the stableswap taker fee is returned. +// If the poolId exists in the custom pool taker fee list, the custom taker fee is returned. +func (k Keeper) determineTakerFee(ctx sdk.Context, pool types.PoolI) sdk.Dec { + poolManagerParams := k.GetParams(ctx) + poolId := pool.GetId() + if pool.GetType() == types.Stableswap { + return poolManagerParams.StableswapTakerFee + } + for _, tradingPair := range poolManagerParams.CustomPoolTakerFee { + if poolId == tradingPair.PoolId { + return tradingPair.TakerFee + } + } + return poolManagerParams.DefaultTakerFee +} + +func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, tokenIn sdk.Coin) error { + relevantPoolAddress := sdk.AccAddress{} + feeCollectorName := txfeestypes.FeeCollectorName + if pool.GetType() == types.Concentrated { + concentratedTypePool, ok := pool.(cltypes.ConcentratedPoolExtension) + if !ok { + return fmt.Errorf("pool %d is not a concentrated pool", pool.GetId()) + } + relevantPoolAddress = concentratedTypePool.GetSpreadRewardsAddress() + } else { + relevantPoolAddress = pool.GetAddress() + } + testCoin := sdk.Coins{} + k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, feeCollectorName, testCoin) + return nil +} diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 2dbc926ffcf..394a280e64e 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -30,7 +30,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the poolmanager module type Params struct { - PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` + PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` + DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` + StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` + CustomPoolTakerFee []CustomPoolTakerFee `protobuf:"bytes,4,rep,name=trading_pair_taker_fee,json=tradingPairTakerFee,proto3" json:"trading_pair_taker_fee"` } func (m *Params) Reset() { *m = Params{} } @@ -73,6 +76,13 @@ func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } +func (m *Params) GetCustomPoolTakerFee() []CustomPoolTakerFee { + if m != nil { + return m.CustomPoolTakerFee + } + return nil +} + // GenesisState defines the poolmanager module's genesis state. type GenesisState struct { // the next_pool_id @@ -137,9 +147,56 @@ func (m *GenesisState) GetPoolRoutes() []ModuleRoute { return nil } +// CustomPoolTakerFee defines a custom taker fee for a specific pool. +type CustomPoolTakerFee struct { + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` +} + +func (m *CustomPoolTakerFee) Reset() { *m = CustomPoolTakerFee{} } +func (m *CustomPoolTakerFee) String() string { return proto.CompactTextString(m) } +func (*CustomPoolTakerFee) ProtoMessage() {} +func (*CustomPoolTakerFee) Descriptor() ([]byte, []int) { + return fileDescriptor_aa099d9fbdf68b35, []int{2} +} +func (m *CustomPoolTakerFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CustomPoolTakerFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CustomPoolTakerFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *CustomPoolTakerFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_CustomPoolTakerFee.Merge(m, src) +} +func (m *CustomPoolTakerFee) XXX_Size() int { + return m.Size() +} +func (m *CustomPoolTakerFee) XXX_DiscardUnknown() { + xxx_messageInfo_CustomPoolTakerFee.DiscardUnknown(m) +} + +var xxx_messageInfo_CustomPoolTakerFee proto.InternalMessageInfo + +func (m *CustomPoolTakerFee) GetPoolId() uint64 { + if m != nil { + return m.PoolId + } + return 0 +} + func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") + proto.RegisterType((*CustomPoolTakerFee)(nil), "osmosis.poolmanager.v1beta1.CustomPoolTakerFee") } func init() { @@ -147,34 +204,44 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 421 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0xb1, 0x6e, 0xd4, 0x40, - 0x10, 0xf5, 0x92, 0xe8, 0x8a, 0xbd, 0x48, 0x08, 0x8b, 0xc2, 0x09, 0x92, 0xcf, 0x32, 0x8d, 0x29, - 0xb2, 0xab, 0x0b, 0x45, 0x24, 0x3a, 0x2e, 0x12, 0x08, 0x09, 0x44, 0x30, 0x1d, 0x8d, 0xb5, 0xb6, - 0x27, 0xc6, 0xc2, 0xf6, 0x58, 0xde, 0x75, 0x94, 0xfb, 0x0b, 0x24, 0x7a, 0x3e, 0x80, 0xef, 0xa0, - 0x48, 0x79, 0x25, 0xd5, 0x81, 0xee, 0xfe, 0x80, 0x2f, 0x40, 0xbb, 0x5e, 0xa3, 0x83, 0x48, 0x57, - 0xd9, 0xb3, 0xf3, 0xde, 0x9b, 0x79, 0x6f, 0xe8, 0x13, 0x94, 0x35, 0xca, 0x52, 0xf2, 0x16, 0xb1, - 0xaa, 0x45, 0x23, 0x0a, 0xe8, 0xf8, 0xf5, 0x3c, 0x05, 0x25, 0xe6, 0xbc, 0x80, 0x06, 0x64, 0x29, - 0x59, 0xdb, 0xa1, 0x42, 0xf7, 0x91, 0x85, 0xb2, 0x1d, 0x28,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, - 0xb7, 0x4b, 0xc4, 0xea, 0x55, 0xee, 0x3e, 0xa7, 0x93, 0xd6, 0x58, 0xf2, 0xee, 0x05, 0x24, 0x9a, - 0x9e, 0x3d, 0x66, 0x7b, 0xae, 0xc7, 0x06, 0xf7, 0x8b, 0x43, 0x6d, 0x23, 0xb6, 0x44, 0xf7, 0x2d, - 0x9d, 0x1a, 0x7d, 0x13, 0x95, 0xf4, 0x0e, 0x4c, 0x08, 0xd1, 0x5e, 0x9d, 0x37, 0x26, 0xdc, 0x58, - 0x13, 0xac, 0x18, 0xd5, 0x30, 0xf3, 0x20, 0x17, 0xef, 0x6e, 0x37, 0x3e, 0x59, 0x6d, 0x7c, 0xf2, - 0x6b, 0xe3, 0x93, 0xcf, 0x5b, 0xdf, 0x59, 0x6d, 0x7d, 0xe7, 0xc7, 0xd6, 0x77, 0x3e, 0x9c, 0xef, - 0x64, 0x63, 0xf5, 0x4f, 0x2b, 0x91, 0xca, 0xb1, 0xe0, 0xd7, 0xf3, 0x73, 0x7e, 0xf3, 0xcf, 0x3d, - 0x4d, 0x60, 0xe9, 0xc4, 0x5c, 0xf0, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x2d, 0x2d, 0xaa, - 0x10, 0xc7, 0x02, 0x00, 0x00, + // 592 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x8e, 0xff, 0x46, 0xf9, 0xe9, 0xb6, 0x52, 0xa8, 0xa9, 0x50, 0x1a, 0x24, 0x3b, 0x72, 0x25, + 0x14, 0x0e, 0xb5, 0x95, 0x72, 0xa8, 0xc4, 0xad, 0x4e, 0x54, 0x84, 0x04, 0x22, 0xb8, 0x9c, 0xb8, + 0x58, 0xeb, 0x78, 0x62, 0xac, 0xda, 0x5e, 0xcb, 0xbb, 0x0e, 0xcd, 0x8d, 0x23,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 0x37, 0x85, 0xde, 0x9a, 0xe2, 0x38, 0x7a, 0x66, 0xac, 0x31, 0x18, 0xdf, + 0x7e, 0xe9, 0xdd, 0x20, 0x64, 0xef, 0x73, 0xcf, 0x1c, 0x91, 0x58, 0xda, 0x95, 0x9f, 0x23, 0xea, + 0x5f, 0x58, 0x6c, 0x9a, 0x02, 0x15, 0x64, 0xd4, 0x69, 0x72, 0x7c, 0x5f, 0xc2, 0xcf, 0x00, 0xd4, + 0x18, 0xed, 0xf9, 0x30, 0xc6, 0x79, 0xc4, 0x5c, 0x86, 0x2f, 0x20, 0x13, 0x4d, 0xfd, 0xd7, 0x51, + 0xba, 0xdb, 0xf6, 0x29, 0x57, 0xfe, 0x59, 0xe8, 0x8f, 0xff, 0x81, 0x7d, 0x00, 0xa3, 0x59, 0xa1, + 0x37, 0x07, 0x25, 0xd5, 0x5b, 0xce, 0x74, 0x06, 0xe0, 0x34, 0xfd, 0xd5, 0x80, 0x3a, 0x41, 0xfb, + 0x94, 0x61, 0x2f, 0x02, 0xfa, 0x01, 0xa7, 0x4b, 0x8a, 0x5b, 0x42, 0x71, 0x70, 0x67, 0x45, 0xf5, + 0x7c, 0xc1, 0xb6, 0x10, 0x55, 0xe9, 0x5a, 0x4c, 0xfd, 0xa8, 0xa0, 0x87, 0x2c, 0xc3, 0x7e, 0x98, + 0x04, 0x6e, 0x8a, 0xc3, 0x6c, 0x49, 0xba, 0x2e, 0x26, 0x60, 0x99, 0x1b, 0x56, 0xd0, 0xec, 0xe7, + 0x94, 0x91, 0x78, 0x48, 0x48, 0x54, 0x31, 0xda, 0x6d, 0xde, 0x2b, 0xef, 0x60, 0x3d, 0xe7, 0x3c, + 0x90, 0x52, 0x43, 0x1c, 0x66, 0x55, 0xd0, 0xf8, 0xae, 0xa0, 0xdd, 0xe7, 0xe5, 0xd6, 0x9f, 0x33, + 0xcc, 0x40, 0xed, 0xa0, 0xdd, 0x04, 0x2e, 0x99, 0x2b, 0x46, 0x1a, 0xfa, 0x2d, 0xa5, 0xa3, 0x74, + 0xeb, 0x0e, 0xe2, 0x31, 0xce, 0xf6, 0xc2, 0x57, 0x4f, 0x51, 0x23, 0x15, 0xcb, 0x23, 0x26, 0xb2, + 0x73, 0x7c, 0xb8, 0xb1, 0xc9, 0x72, 0xcf, 0xec, 0x3a, 0x6f, 0xcc, 0x91, 0x40, 0xf5, 0x35, 0xda, + 0x11, 0xfc, 0x62, 0x29, 0x69, 0x6b, 0x4b, 0x98, 0xed, 0x6e, 0xe4, 0x79, 0x25, 0xd6, 0xd8, 0xe1, + 0x00, 0x49, 0x86, 0x78, 0x99, 0x08, 0x50, 0xe3, 0xab, 0x82, 0xfe, 0x62, 0x59, 0x3d, 0x44, 0xff, + 0xaf, 0xf8, 0xb0, 0xd1, 0xac, 0xd0, 0x1b, 0xa5, 0x0f, 0xa7, 0x91, 0x96, 0x7e, 0x5c, 0xb4, 0x7d, + 0x7b, 0xc9, 0xec, 0xbb, 0x8d, 0xfc, 0xa6, 0xd0, 0xef, 0x97, 0x87, 0xb0, 0x20, 0x32, 0x9c, 0x7b, + 0xac, 0x1a, 0xca, 0x9b, 0xab, 0x99, 0xa6, 0x5c, 0xcf, 0x34, 0xe5, 0xf7, 0x4c, 0x53, 0x3e, 0xcf, + 0xb5, 0xda, 0xf5, 0x5c, 0xab, 0xfd, 0x98, 0x6b, 0xb5, 0x77, 0x27, 0x4b, 0xfc, 0xd2, 0xfc, 0x51, + 0x84, 0x3d, 0x5a, 0x3d, 0xac, 0x49, 0xef, 0xc4, 0xba, 0x5c, 0x39, 0x6b, 0x21, 0xea, 0x35, 0xc4, + 0x21, 0x3f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x34, 0xdd, 0x86, 0x4c, 0xce, 0x04, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -197,6 +264,40 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CustomPoolTakerFee) > 0 { + for iNdEx := len(m.CustomPoolTakerFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.CustomPoolTakerFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } + { + size := m.StableswapTakerFee.Size() + i -= size + if _, err := m.StableswapTakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.DefaultTakerFee.Size() + i -= size + if _, err := m.DefaultTakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 if len(m.PoolCreationFee) > 0 { for iNdEx := len(m.PoolCreationFee) - 1; iNdEx >= 0; iNdEx-- { { @@ -266,6 +367,44 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *CustomPoolTakerFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *CustomPoolTakerFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CustomPoolTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if m.PoolId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.PoolId)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -289,6 +428,16 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.DefaultTakerFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.StableswapTakerFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.CustomPoolTakerFee) > 0 { + for _, e := range m.CustomPoolTakerFee { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -312,6 +461,20 @@ func (m *GenesisState) Size() (n int) { return n } +func (m *CustomPoolTakerFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.PoolId != 0 { + n += 1 + sovGenesis(uint64(m.PoolId)) + } + l = m.TakerFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -381,6 +544,108 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultTakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DefaultTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StableswapTakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StableswapTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CustomPoolTakerFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CustomPoolTakerFee = append(m.CustomPoolTakerFee, CustomPoolTakerFee{}) + if err := m.CustomPoolTakerFee[len(m.CustomPoolTakerFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -538,6 +803,109 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } +func (m *CustomPoolTakerFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: CustomPoolTakerFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CustomPoolTakerFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) + } + m.PoolId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PoolId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index f9a433281c4..8d72ddadabb 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -11,7 +11,10 @@ import ( // Parameter store keys. var ( - KeyPoolCreationFee = []byte("PoolCreationFee") + KeyPoolCreationFee = []byte("PoolCreationFee") + KeyDefaultTakerFee = []byte("DefaultTakerFee") + KeyStableswapTakerFee = []byte("StableswapTakerFee") + KeyTradingPairTakerFee = []byte("TradingPairTakerFee") ) // ParamTable for gamm module. @@ -19,16 +22,22 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(poolCreationFee sdk.Coins) Params { +func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, customPoolTakerFee []CustomPoolTakerFee) Params { return Params{ - PoolCreationFee: poolCreationFee, + PoolCreationFee: poolCreationFee, + DefaultTakerFee: defaultTakerFee, + StableswapTakerFee: stableswapTakerFee, + CustomPoolTakerFee: customPoolTakerFee, } } // DefaultParams are the default poolmanager module parameters. func DefaultParams() Params { return Params{ - PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO + PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO + DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% + StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% + CustomPoolTakerFee: []CustomPoolTakerFee{}, } } diff --git a/x/poolmanager/types/routes.go b/x/poolmanager/types/routes.go index a69d5e4b016..7f1ef9590f1 100644 --- a/x/poolmanager/types/routes.go +++ b/x/poolmanager/types/routes.go @@ -23,6 +23,8 @@ type AccountI interface { type BankI interface { SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error } // CommunityPoolI defines the contract needed to be fulfilled for distribution keeper. From 12dccfa28b57aa7c0b7749f6b73fa592e4540b62 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 11 Aug 2023 10:49:47 -0500 Subject: [PATCH 02/83] remove osmo multi hop logic --- app/upgrades/v15/upgrades.go | 3 +- x/poolmanager/export_test.go | 10 - x/poolmanager/router.go | 115 +------ x/poolmanager/router_test.go | 639 ++++------------------------------- 4 files changed, 70 insertions(+), 697 deletions(-) diff --git a/app/upgrades/v15/upgrades.go b/app/upgrades/v15/upgrades.go index 7e050a47974..3ef449028e7 100644 --- a/app/upgrades/v15/upgrades.go +++ b/app/upgrades/v15/upgrades.go @@ -37,7 +37,8 @@ func CreateUpgradeHandler( keepers *keepers.AppKeepers, ) upgradetypes.UpgradeHandler { return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { - poolmanagerParams := poolmanagertypes.NewParams(keepers.GAMMKeeper.GetParams(ctx).PoolCreationFee) + poolmanagerParams := keepers.PoolManagerKeeper.GetParams(ctx) + poolmanagerParams.PoolCreationFee = keepers.GAMMKeeper.GetParams(ctx).PoolCreationFee keepers.PoolManagerKeeper.SetParams(ctx, poolmanagerParams) keepers.PacketForwardKeeper.SetParams(ctx, packetforwardtypes.DefaultParams()) diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index 2b22169c302..c35a9318ee5 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -12,12 +12,6 @@ func (k Keeper) GetNextPoolIdAndIncrement(ctx sdk.Context) uint64 { return k.getNextPoolIdAndIncrement(ctx) } -func (k Keeper) GetOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route types.MultihopRoute) ( - totalPathSpreadFactor sdk.Dec, sumOfSpreadFactors sdk.Dec, err error, -) { - return k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, route) -} - // SetPoolRoutesUnsafe sets the given routes to the poolmanager keeper // to allow routing from a pool type to a certain swap module. // For example, balancer -> gamm. @@ -42,10 +36,6 @@ func (k Keeper) ValidateCreatedPool(ctx sdk.Context, poolId uint64, pool types.P return k.validateCreatedPool(ctx, poolId, pool) } -func (k Keeper) IsOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { - return k.isOsmoRoutedMultihop(ctx, route, inDenom, outDenom) -} - func (k Keeper) CreateMultihopExpectedSwapOuts( ctx sdk.Context, route []types.SwapAmountOutRoute, diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 926c82fdfca..22528ddf37a 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -8,7 +8,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/osmoutils" - appparams "github.com/osmosis-labs/osmosis/v17/app/params" cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" @@ -218,12 +217,6 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( route []types.SwapAmountInRoute, tokenIn sdk.Coin, ) (tokenOutAmount sdk.Int, err error) { - var ( - isMultiHopRouted bool - routeSpreadFactor sdk.Dec - sumOfSpreadFactors sdk.Dec - ) - // recover from panic defer func() { if r := recover(); r != nil { @@ -237,14 +230,6 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( return sdk.Int{}, err } - if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenOutDenom, tokenIn.Denom) { - isMultiHopRouted = true - routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) - if err != nil { - return sdk.Int{}, err - } - } - for _, routeStep := range route { swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) if err != nil { @@ -261,12 +246,6 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( takerFee := k.determineTakerFee(ctx, poolI) totalFees := spreadFactor.Add(takerFee) - // If we determined the routeStep is an osmo multi-hop and both route are incentivized, - // we modify the swap fee accordingly. - if isMultiHopRouted { - spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) - } - tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, totalFees) if err != nil { return sdk.Int{}, err @@ -309,30 +288,8 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } }() - // In this loop (isOsmoRoutedMultihop), we check if: - // - the routeStep is of length 2 - // - routeStep 1 and routeStep 2 don't trade via the same pool - // - routeStep 1 contains uosmo - // - both routeStep 1 and routeStep 2 are incentivized pools - // - // if all of the above is true, then we collect the additive and max fee between the two pools to later calculate the following: - // total_spread_factor = total_spread_factor = max(spread_factor1, spread_factor2) - // fee_per_pool = total_spread_factor * ((pool_fee) / (spread_factor1 + spread_factor2)) var insExpected []sdk.Int - isMultiHopRouted = k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenInDenom, tokenOut.Denom) - - // Determine what the estimated input would be for each pool along the multi-hop routeStep - // if we determined the routeStep is an osmo multi-hop and both route are incentivized, - // we utilize a separate function that calculates the discounted swap fees - if isMultiHopRouted { - routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) - if err != nil { - return sdk.Int{}, err - } - insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, routeSpreadFactor, sumOfSpreadFactors) - } else { - insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) - } + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) if err != nil { return sdk.Int{}, err @@ -529,14 +486,6 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( return sdk.Int{}, err } - if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenInDenom, tokenOut.Denom) { - isMultiHopRouted = true - routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) - if err != nil { - return sdk.Int{}, err - } - } - // Determine what the estimated input would be for each pool along the multi-hop route // if we determined the route is an osmo multi-hop and both routes are incentivized, // we utilize a separate function that calculates the discounted spread factors @@ -592,63 +541,6 @@ func (k Keeper) AllPools( return sortedPools, nil } -// IsOsmoRoutedMultihop determines if a multi-hop swap involves OSMO, as one of the intermediary tokens. -func (k Keeper) isOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { - if route.Length() != 2 { - return false - } - intemediateDenoms := route.IntermediateDenoms() - if len(intemediateDenoms) != 1 || intemediateDenoms[0] != appparams.BaseCoinUnit { - return false - } - if inDenom == outDenom { - return false - } - poolIds := route.PoolIds() - if poolIds[0] == poolIds[1] { - return false - } - - route0Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[0]) - route1Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[1]) - - return route0Incentivized && route1Incentivized -} - -// getOsmoRoutedMultihopTotalSpreadFactor calculates and returns the average swap fee and the sum of swap fees for -// a given route. For the former, it sets a lower bound of the highest swap fee pool in the route to ensure total -// swap fees for a route are never more than halved. -func (k Keeper) getOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route types.MultihopRoute) ( - totalPathSpreadFactor sdk.Dec, sumOfSpreadFactors sdk.Dec, err error, -) { - additiveSpreadFactor := sdk.ZeroDec() - maxSpreadFactor := sdk.ZeroDec() - - for _, poolId := range route.PoolIds() { - swapModule, err := k.GetPoolModule(ctx, poolId) - if err != nil { - return sdk.Dec{}, sdk.Dec{}, err - } - - pool, poolErr := swapModule.GetPool(ctx, poolId) - if poolErr != nil { - return sdk.Dec{}, sdk.Dec{}, poolErr - } - SpreadFactor := pool.GetSpreadFactor(ctx) - additiveSpreadFactor = additiveSpreadFactor.Add(SpreadFactor) - maxSpreadFactor = sdk.MaxDec(maxSpreadFactor, SpreadFactor) - } - - // We divide by 2 to get the average since OSMO-routed multihops always have exactly 2 pools. - averageSpreadFactor := additiveSpreadFactor.QuoInt64(2) - - // We take the max here as a guardrail to ensure that there is a lowerbound on the swap fee for the - // whole route equivalent to the highest fee pool - routeSpreadFactor := sdk.MaxDec(maxSpreadFactor, averageSpreadFactor) - - return routeSpreadFactor, additiveSpreadFactor, nil -} - // createMultihopExpectedSwapOuts defines the output denom and output amount for the last pool in // the routeStep of pools the caller is intending to hop through in a fixed-output multihop tx. It estimates the input // amount for this last pool and then chains that input as the output of the previous pool in the routeStep, repeating @@ -770,7 +662,7 @@ func (k Keeper) determineTakerFee(ctx sdk.Context, pool types.PoolI) sdk.Dec { } func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, tokenIn sdk.Coin) error { - relevantPoolAddress := sdk.AccAddress{} + var relevantPoolAddress sdk.AccAddress feeCollectorName := txfeestypes.FeeCollectorName if pool.GetType() == types.Concentrated { concentratedTypePool, ok := pool.(cltypes.ConcentratedPoolExtension) @@ -782,6 +674,5 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke relevantPoolAddress = pool.GetAddress() } testCoin := sdk.Coins{} - k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, feeCollectorName, testCoin) - return nil + return k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, feeCollectorName, testCoin) } diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index b2904e3f7aa..164f25d2864 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -362,17 +362,16 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { // - fee reduction is applied correctly func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { tests := []struct { - name string - poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec - poolType []types.PoolType - routes []types.SwapAmountInRoute - incentivizedGauges []uint64 - tokenIn sdk.Coin - tokenOutMinAmount sdk.Int - spreadFactor sdk.Dec - expectError bool - expectReducedFeeApplied bool + name string + poolCoins []sdk.Coins + poolSpreadFactor []sdk.Dec + poolType []types.PoolType + routes []types.SwapAmountInRoute + incentivizedGauges []uint64 + tokenIn sdk.Coin + tokenOutMinAmount sdk.Int + spreadFactor sdk.Dec + expectError bool }{ { name: "One route: Swap - [foo -> bar], 1 percent fee", @@ -410,52 +409,6 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), }, - { - name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - routes: []types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: baz, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: true, - }, - { - name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, - routes: []types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: baz, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: true, - }, { name: "Three routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", poolCoins: []sdk.Coins{ @@ -479,10 +432,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: false, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), }, { name: "Two routes: Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", @@ -504,35 +456,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: false, - }, - { - name: "Two routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), - sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), - sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - routes: []types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: baz, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: true, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), }, { name: "Three routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", @@ -560,10 +486,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), - expectReducedFeeApplied: false, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), }, { name: "[Concentrated] One route: Swap - [foo -> bar], 1 percent fee", @@ -675,7 +600,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcInAmountAsSeparatePoolSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenIn) + expectedMultihopTokenOutAmount := s.calcInAmountAsSeparatePoolSwaps(tc.routes, tc.tokenIn) // execute the swap multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenIn, tc.tokenOutMinAmount) @@ -694,17 +619,16 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { // - fee reduction is applied correctly func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { tests := []struct { - name string - poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec - poolType []types.PoolType - routes []types.SwapAmountOutRoute - incentivizedGauges []uint64 - tokenOut sdk.Coin - tokenInMaxAmount sdk.Int - spreadFactor sdk.Dec - expectError bool - expectReducedFeeApplied bool + name string + poolCoins []sdk.Coins + poolSpreadFactor []sdk.Dec + poolType []types.PoolType + routes []types.SwapAmountOutRoute + incentivizedGauges []uint64 + tokenOut sdk.Coin + tokenInMaxAmount sdk.Int + spreadFactor sdk.Dec + expectError bool }{ { name: "One route: Swap - [foo -> bar], 1 percent fee", @@ -743,52 +667,6 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { tokenInMaxAmount: sdk.NewInt(90000000), tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), }, - { - name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - routes: []types.SwapAmountOutRoute{ - { - PoolId: 1, - TokenInDenom: foo, - }, - { - PoolId: 2, - TokenInDenom: uosmo, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - expectReducedFeeApplied: true, - }, - { - name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, - routes: []types.SwapAmountOutRoute{ - { - PoolId: 1, - TokenInDenom: foo, - }, - { - PoolId: 2, - TokenInDenom: uosmo, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - expectReducedFeeApplied: true, - }, { name: "Three routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", poolCoins: []sdk.Coins{ @@ -812,10 +690,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), - expectReducedFeeApplied: false, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), }, { name: "Two routes: Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", @@ -837,35 +714,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), - expectReducedFeeApplied: false, - }, - { - name: "Two routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", - poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), - sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), - sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. - }, - poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - routes: []types.SwapAmountOutRoute{ - { - PoolId: 1, - TokenInDenom: foo, - }, - { - PoolId: 2, - TokenInDenom: uosmo, - }, - }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), - expectReducedFeeApplied: true, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), }, { name: "Three routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", @@ -893,10 +744,9 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), - expectReducedFeeApplied: false, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), }, { name: "[Cosmwasm] One route: Swap - [foo -> bar], 1 percent fee", @@ -967,7 +817,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcOutAmountAsSeparateSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenOut) + expectedMultihopTokenOutAmount := s.calcOutAmountAsSeparateSwaps(tc.routes, tc.tokenOut) // execute the swap multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenInMaxAmount, tc.tokenOut) // compare the expected tokenOut to the actual tokenOut @@ -1354,107 +1204,49 @@ func (s *KeeperTestSuite) makeGaugesIncentivized(incentivizedGauges []uint64) { s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, distInfo) } -func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(osmoFeeReduced bool, routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() - if osmoFeeReduced { - // extract route from swap - route := types.SwapAmountOutRoutes(routes) - // utilizing the extracted route, determine the routeSpreadFactor and sumOfspreadFactors - // these two variables are used to calculate the overall swap fee utilizing the following formula - // spreadFactor = routeSpreadFactor * ((pool_fee) / (sumOfspreadFactors)) - routeSpreadFactor, sumOfSpreadFactors, err := s.App.PoolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, route) + nextTokenOut := tokenOut + for i := len(routes) - 1; i >= 0; i-- { + hop := routes[i] + hopPool, err := s.App.PoolManagerKeeper.GetPool(cacheCtx, hop.PoolId) s.Require().NoError(err) - nextTokenOut := tokenOut - for i := len(routes) - 1; i >= 0; i-- { - hop := routes[i] - // extract the current pool's swap fee - hopPool, err := s.App.GAMMKeeper.GetPoolAndPoke(cacheCtx, hop.PoolId) - s.Require().NoError(err) - currentPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) - // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee - spreadFactor := routeSpreadFactor.Mul((currentPoolSpreadFactor.Quo(sumOfSpreadFactors))) - - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) - s.Require().NoError(err) + updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) - // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, spreadFactor) - s.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) - } - return nextTokenOut - } else { - nextTokenOut := tokenOut - for i := len(routes) - 1; i >= 0; i-- { - hop := routes[i] - hopPool, err := s.App.PoolManagerKeeper.GetPool(cacheCtx, hop.PoolId) - s.Require().NoError(err) - updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) - - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) - s.Require().NoError(err) + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + s.Require().NoError(err) - tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) - s.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) - } - return nextTokenOut + tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) + s.Require().NoError(err) + nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) } + return nextTokenOut } // calcInAmountAsSeparatePoolSwaps calculates the output amount of a series of swaps on PoolManager pools while factoring in reduces swap fee changes. // If its GAMM pool functions directly to ensure the poolmanager functions route to the correct modules. It it's CL pool functions directly to ensure the // poolmanager functions route to the correct modules. -func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() - if osmoFeeReduced { - // extract route from swap - route := types.SwapAmountInRoutes(routes) - // utilizing the extracted route, determine the routeSpreadFactor and sumOfSpreadFactors - // these two variables are used to calculate the overall swap fee utilizing the following formula - // spreadFactor = routeSpreadFactor * ((pool_fee) / (sumOfSpreadFactors)) - routeSpreadFactor, sumOfSpreadFactors, err := s.App.PoolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, route) + nextTokenIn := tokenIn + for _, hop := range routes { + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) - nextTokenIn := tokenIn - - for _, hop := range routes { - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) - s.Require().NoError(err) - - pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) - s.Require().NoError(err) - // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee - spreadFactor := routeSpreadFactor.Mul(pool.GetSpreadFactor(cacheCtx).Quo(sumOfSpreadFactors)) - - // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) - s.Require().NoError(err) - - nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) - } - return nextTokenIn - } else { - nextTokenIn := tokenIn - for _, hop := range routes { - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) - s.Require().NoError(err) - - pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) - s.Require().NoError(err) + pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) + s.Require().NoError(err) - // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee - spreadFactor := pool.GetSpreadFactor(cacheCtx) + // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee + spreadFactor := pool.GetSpreadFactor(cacheCtx) - // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) - s.Require().NoError(err) + // we then do individual swaps until we reach the end of the swap route + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + s.Require().NoError(err) - nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) + nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) - } - return nextTokenIn } + return nextTokenIn } // TODO: abstract SwapAgainstBalancerPool and SwapAgainstConcentratedPool @@ -2295,307 +2087,6 @@ func (s *KeeperTestSuite) TestGetTotalPoolLiquidity() { } } -func (s *KeeperTestSuite) TestIsOsmoRoutedMultihop() { - tests := map[string]struct { - route types.MultihopRoute - balancerPoolCoins []sdk.Coins - concentratedPoolDenoms [][]string - incentivizedGauges []uint64 - inDenom string - outDenom string - expectIsRouted bool - }{ - "happy path: osmo routed (balancer)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - balancerPoolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. - }, - // Note that we incentivize all candidate gauges for the sake of test readability. - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - inDenom: foo, - outDenom: bar, - - expectIsRouted: true, - }, - "happy path: osmo routed (balancer, only one active gauge for each pool)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - balancerPoolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. - }, - incentivizedGauges: []uint64{1, 4}, - inDenom: foo, - outDenom: bar, - - expectIsRouted: true, - }, - "osmo routed (concentrated)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - concentratedPoolDenoms: [][]string{ - {foo, uosmo}, // pool 1. - {uosmo, baz}, // pool 2. - }, - incentivizedGauges: []uint64{1, 2}, - inDenom: foo, - outDenom: bar, - - expectIsRouted: true, - }, - "osmo routed (mixed concentrated and balancer)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - concentratedPoolDenoms: [][]string{ - {foo, uosmo}, // pool 1. - }, - balancerPoolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. - }, - - incentivizedGauges: []uint64{1, 2}, - inDenom: foo, - outDenom: bar, - - expectIsRouted: true, - }, - "not osmo routed (single pool)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: bar, - }, - }), - inDenom: foo, - outDenom: bar, - - expectIsRouted: false, - }, - "not osmo routed (two pools)": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: bar, - }, - { - PoolId: 2, - TokenOutDenom: baz, - }, - }), - inDenom: foo, - outDenom: baz, - - expectIsRouted: false, - }, - } - - for name, tc := range tests { - s.Run(name, func() { - s.SetupTest() - poolManagerKeeper := s.App.PoolManagerKeeper - - // Create pools to route through - if tc.concentratedPoolDenoms != nil { - s.CreateConcentratedPoolsAndFullRangePosition(tc.concentratedPoolDenoms) - } - - if tc.balancerPoolCoins != nil { - s.createBalancerPoolsFromCoins(tc.balancerPoolCoins) - } - - // If test specifies incentivized gauges, set them here - if len(tc.incentivizedGauges) > 0 { - s.makeGaugesIncentivized(tc.incentivizedGauges) - } - - // System under test - isRouted := poolManagerKeeper.IsOsmoRoutedMultihop(s.Ctx, tc.route, tc.inDenom, tc.outDenom) - - // Check output - s.Require().Equal(tc.expectIsRouted, isRouted) - }) - } -} - -// TestGetOsmoRoutedMultihopTotalSpreadFactor tests the GetOsmoRoutedMultihopTotalSpreadFactor function -func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { - tests := map[string]struct { - route types.MultihopRoute - balancerPoolCoins []sdk.Coins - concentratedPoolDenoms [][]string - poolFees []sdk.Dec - - expectedRouteFee sdk.Dec - expectedTotalFee sdk.Dec - expectedError error - }{ - "happy path: balancer route": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - balancerPoolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. - sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. - }, - - expectedRouteFee: defaultPoolSpreadFactor, - expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), - }, - "concentrated route": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - concentratedPoolDenoms: [][]string{ - {foo, uosmo}, // pool 1. - {uosmo, baz}, // pool 2. - }, - - expectedRouteFee: defaultPoolSpreadFactor, - expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), - }, - "mixed concentrated and balancer route": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - concentratedPoolDenoms: [][]string{ - {foo, uosmo}, // pool 1. - }, - balancerPoolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. - }, - - expectedRouteFee: defaultPoolSpreadFactor, - expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), - }, - "edge case: average fee is lower than highest pool fee": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - // Note that pool 2 has 5x the swap fee of pool 1 - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor.Mul(sdk.NewDec(5))}, - concentratedPoolDenoms: [][]string{ - {foo, uosmo}, // pool 1. - {uosmo, baz}, // pool 2. - }, - - expectedRouteFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(5)), - expectedTotalFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(6)), - }, - "error: pool does not exist": { - route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ - { - PoolId: 1, - TokenOutDenom: uosmo, - }, - { - PoolId: 2, - TokenOutDenom: bar, - }, - }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, - - expectedError: types.FailedToFindRouteError{PoolId: 1}, - }, - } - - for name, tc := range tests { - s.Run(name, func() { - s.SetupTest() - poolManagerKeeper := s.App.PoolManagerKeeper - - // Create pools for test route - if tc.concentratedPoolDenoms != nil { - s.CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(tc.concentratedPoolDenoms, tc.poolFees) - } - - if tc.balancerPoolCoins != nil { - s.createBalancerPoolsFromCoinsWithSpreadFactor(tc.balancerPoolCoins, tc.poolFees) - } - - // System under test - routeFee, totalFee, err := poolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, tc.route) - - // Assertions - if tc.expectedError != nil { - s.Require().Error(err) - s.Require().Equal(tc.expectedError.Error(), err.Error()) - s.Require().Equal(sdk.Dec{}, routeFee) - s.Require().Equal(sdk.Dec{}, totalFee) - return - } - - s.Require().NoError(err) - s.Require().Equal(tc.expectedRouteFee, routeFee) - s.Require().Equal(tc.expectedTotalFee, totalFee) - }) - } -} - func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { tests := map[string]struct { route []types.SwapAmountOutRoute From e857cc97df79b16ca3bb45a87086ba0b41cff5ed Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 13 Aug 2023 19:13:57 -0500 Subject: [PATCH 03/83] route to both community pool and staking rewards --- app/keepers/keepers.go | 2 + app/modules.go | 49 +- .../osmosis/poolmanager/v1beta1/genesis.proto | 39 ++ tests/cl-genesis-positions/go.mod | 47 +- tests/cl-genesis-positions/go.sum | 80 +-- x/poolmanager/export_test.go | 9 - x/poolmanager/router.go | 210 +++++-- x/poolmanager/router_test.go | 6 +- x/poolmanager/types/expected_keepers.go | 108 ++++ x/poolmanager/types/genesis.pb.go | 539 ++++++++++++++++-- x/poolmanager/types/params.go | 182 +++++- x/poolmanager/types/routes.go | 103 ---- x/txfees/keeper/feedecorator.go | 6 +- x/txfees/keeper/feedecorator_test.go | 2 +- x/txfees/keeper/hooks.go | 81 ++- x/txfees/keeper/hooks_test.go | 4 +- x/txfees/keeper/keeper.go | 6 + x/txfees/types/expected_keepers.go | 20 + x/txfees/types/keys.go | 6 +- 19 files changed, 1174 insertions(+), 325 deletions(-) create mode 100644 x/poolmanager/types/expected_keepers.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 93a45b47ff3..9de6cc62cc1 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -375,6 +375,8 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.keys[txfeestypes.StoreKey], appKeepers.PoolManagerKeeper, appKeepers.GAMMKeeper, + appKeepers.ProtoRevKeeper, + appKeepers.DistrKeeper, ) appKeepers.TxFeesKeeper = &txFeesKeeper diff --git a/app/modules.go b/app/modules.go index 75ccd2de33f..59e946114ff 100644 --- a/app/modules.go +++ b/app/modules.go @@ -98,30 +98,31 @@ import ( // moduleAccountPermissions defines module account permissions // TODO: Having to input nil's here is unacceptable, we need a way to automatically derive this. var moduleAccountPermissions = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - ibchookstypes.ModuleName: nil, - icatypes.ModuleName: nil, - icqtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - minttypes.DeveloperVestingModuleAcctName: nil, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - poolincentivestypes.ModuleName: nil, - superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - txfeestypes.ModuleName: nil, - txfeestypes.NonNativeFeeCollectorName: nil, - wasm.ModuleName: {authtypes.Burner}, - tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - valsetpreftypes.ModuleName: {authtypes.Staking}, - poolmanagertypes.ModuleName: nil, - cosmwasmpooltypes.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + ibchookstypes.ModuleName: nil, + icatypes.ModuleName: nil, + icqtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + minttypes.DeveloperVestingModuleAcctName: nil, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + poolincentivestypes.ModuleName: nil, + superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + txfeestypes.ModuleName: nil, + txfeestypes.NonNativeFeeCollectorForStakingRewardsName: nil, + txfeestypes.NonNativeFeeCollectorForCommunityPoolName: nil, + wasm.ModuleName: {authtypes.Burner}, + tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + valsetpreftypes.ModuleName: {authtypes.Staking}, + poolmanagertypes.ModuleName: nil, + cosmwasmpooltypes.ModuleName: nil, } // appModules return modules to initialize module manager. diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 9e6f798247c..a020645c2e3 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -31,6 +31,30 @@ message Params { (gogoproto.customname) = "CustomPoolTakerFee", (gogoproto.nullable) = false ]; + TakerFeeDistributionPercentage osmo_taker_fee_distribution = 5 [ + (gogoproto.customname) = "OsmoTakerFeeDistribution", + (gogoproto.nullable) = false + ]; + TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 6 [ + (gogoproto.customname) = "NonOsmoTakerFeeDistribution", + (gogoproto.nullable) = false + ]; + // authorized_quote_denoms is a list of quote denoms that can be used as + // token1 when creating a concentrated pool. We limit the quote assets to a + // small set for the purposes of having convinient price increments stemming + // from tick to price conversion. These increments are in a human readable + // magnitude only for token1 as a quote. For limit orders in the future, this + // will be a desirable property in terms of UX as to allow users to set limit + // orders at prices in terms of token1 (quote asset) that are easy to reason + // about. + repeated string authorized_quote_denoms = 7 + [ (gogoproto.moretags) = "yaml:\"authorized_quote_denoms\"" ]; + // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that + // taker fees that are not whitelisted will be swapped to when being sent to + // the community pool. + string community_pool_denom_to_swap_non_whitelisted_assets_to = 8 + [ (gogoproto.moretags) = + "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; } // GenesisState defines the poolmanager module's genesis state. @@ -51,4 +75,19 @@ message CustomPoolTakerFee { (gogoproto.moretags) = "yaml:\"taker_fee\"", (gogoproto.nullable) = false ]; +} + +// TakerFeeDistributionPercentage defines what percent of the taker fee category +// gets distributed to the available categories. +message TakerFeeDistributionPercentage { + string staking_rewards = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"staking_rewards\"", + (gogoproto.nullable) = false + ]; + string community_pool = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"community_pool\"", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/tests/cl-genesis-positions/go.mod b/tests/cl-genesis-positions/go.mod index df094db4eea..a5ebd81a35f 100644 --- a/tests/cl-genesis-positions/go.mod +++ b/tests/cl-genesis-positions/go.mod @@ -3,17 +3,17 @@ module cl-get-positions-subgraph go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.3 + github.com/cosmos/cosmos-sdk v0.47.4 github.com/ignite/cli v0.23.0 - github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230621002052-afb82fbaa312 - github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230623115558-38aaab07d343 + github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230804142026-a81cfe3ddde7 + github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5 github.com/tendermint/tendermint v0.37.0-rc1 ) -require github.com/osmosis-labs/osmosis/v16 v16.0.0-20230630175215-d5fcd089a71c +require github.com/osmosis-labs/osmosis/v17 v17.0.0-20230811221421-2e3f19d86dd4 require ( - cosmossdk.io/errors v1.0.0-beta.7 // indirect + cosmossdk.io/errors v1.0.0 // indirect filippo.io/edwards25519 v1.0.0-rc.1 // indirect github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/99designs/keyring v1.2.1 // indirect @@ -26,11 +26,11 @@ require ( github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/blang/semver v3.5.1+incompatible // indirect github.com/btcsuite/btcd v0.22.3 // indirect + github.com/bytedance/sonic v1.9.1 // indirect github.com/cenkalti/backoff v2.2.1+incompatible // indirect github.com/cenkalti/backoff/v4 v4.1.3 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/confio/ics23/go v0.9.0 // indirect github.com/cosmos/btcutil v1.0.5 // indirect @@ -39,7 +39,8 @@ require ( github.com/cosmos/gogoproto v1.4.6 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.5 // indirect - github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860 // indirect + github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.0.0-20230803185752-97c9635dd74a // indirect + github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230803151532-5c60ac789ef7 // indirect github.com/cosmos/ibc-go/v4 v4.3.1 // indirect github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect @@ -53,15 +54,17 @@ require ( github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/felixge/httpsnoop v1.0.2 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect github.com/go-logfmt/logfmt v0.5.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect github.com/gogo/protobuf v1.3.3 // indirect - github.com/golang/glog v1.1.0 // indirect + github.com/golang/glog v1.1.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect @@ -82,12 +85,12 @@ require ( github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect - github.com/iancoleman/orderedmap v0.2.0 // indirect + github.com/iancoleman/orderedmap v0.3.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect github.com/klauspost/compress v1.15.11 // indirect - github.com/klauspost/cpuid/v2 v2.2.5 // indirect + github.com/leodido/go-urn v1.2.4 // indirect github.com/lib/pq v1.10.7 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -100,7 +103,7 @@ require ( github.com/mtibben/percent v0.2.1 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 // indirect - github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230602130523-f9a94d8bbd10 // indirect + github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.9.1 // indirect @@ -121,7 +124,6 @@ require ( github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/viper v1.16.0 // indirect - github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.5 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect @@ -130,23 +132,24 @@ require ( github.com/tendermint/go-amino v0.16.0 // indirect github.com/tendermint/tm-db v0.6.8-0.20220506192307-f628bb5dc95b // indirect github.com/tidwall/btree v1.6.0 // indirect - github.com/ugorji/go/codec v1.2.11 // indirect github.com/zondax/hid v0.9.1 // indirect github.com/zondax/ledger-go v0.14.1 // indirect go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/arch v0.3.0 // indirect - golang.org/x/crypto v0.9.0 // indirect + golang.org/x/crypto v0.11.0 // indirect golang.org/x/exp v0.0.0-20230131160201-f062dba9d201 // indirect golang.org/x/mod v0.10.0 // indirect - golang.org/x/net v0.10.0 // indirect + golang.org/x/net v0.12.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.8.0 // indirect - golang.org/x/term v0.8.0 // indirect - golang.org/x/text v0.9.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.55.0 // indirect - google.golang.org/protobuf v1.30.0 // indirect + golang.org/x/sys v0.10.0 // indirect + golang.org/x/term v0.10.0 // indirect + golang.org/x/text v0.11.0 // indirect + google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 // indirect + google.golang.org/grpc v1.56.2 // indirect + google.golang.org/protobuf v1.31.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/tests/cl-genesis-positions/go.sum b/tests/cl-genesis-positions/go.sum index 19b91e77932..91db2de6be9 100644 --- a/tests/cl-genesis-positions/go.sum +++ b/tests/cl-genesis-positions/go.sum @@ -38,8 +38,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= -cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= -cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= +cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= @@ -148,6 +148,7 @@ github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46f github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= github.com/bytedance/sonic v1.9.1 h1:6iJ6NqdoxCDr6mbY8h18oSO+cShGSMRGCEo7F2h0x8s= +github.com/bytedance/sonic v1.9.1/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U= github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= @@ -204,8 +205,10 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.4 h1:t82sN+Y0WeqxDLJRSpNd8YFX5URIrT+p8n6oJbJ2Dok= github.com/cosmos/iavl v0.19.4/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860 h1:25/KpA4WJqdFjKFsa3VEL0ctWRovkEsqIn2phCAi9v0= -github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230524151648-c02fa46c2860/go.mod h1:X/dLZ6QxTImzno7qvD6huLhh6ZZBcRt2URn4YCLcXFY= +github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.0.0-20230803185752-97c9635dd74a h1:FKEtbHE+kULYf6ghxa3FvEfyR7BNde0940gAyuWborE= +github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.0.0-20230803185752-97c9635dd74a/go.mod h1:Mn/jr9pIYr1ofFuptLEi9N6MjcshTT0cpoOY4ln1DeA= +github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230803151532-5c60ac789ef7 h1:q6OzbGXmWRbMedDejhuctDbb3M6fWyJg3DY3bzJbYVs= +github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.0.0-20230803151532-5c60ac789ef7/go.mod h1:X/dLZ6QxTImzno7qvD6huLhh6ZZBcRt2URn4YCLcXFY= github.com/cosmos/ibc-go/v4 v4.3.1 h1:xbg0CaCdxK3lvgGvSaI91ROOLd7s30UqEcexH6Ba4Ys= github.com/cosmos/ibc-go/v4 v4.3.1/go.mod h1:89E+K9CxpkS/etLEcG026jPM/RSnVMcfesvRYp/0aKI= github.com/cosmos/interchain-accounts v0.2.6 h1:TV2M2g1/Rb9MCNw1YePdBKE0rcEczNj1RGHT+2iRYas= @@ -291,6 +294,7 @@ github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4 github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= +github.com/gabriel-vasile/mimetype v1.4.2/go.mod h1:zApsH/mKG4w07erKIaJPFiX0Tsq9BFQgN3qGY5GnNgA= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= @@ -326,9 +330,9 @@ github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTM github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= +github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.14.0 h1:vgvQWe3XCz3gIeFDm/HnTIbj6UGmg/+t63MyGU2n5js= -github.com/go-playground/validator/v10 v10.14.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= @@ -340,6 +344,7 @@ github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo= github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= +github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= @@ -350,8 +355,8 @@ github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzw github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.0 h1:/d3pCKDPWNnvIWe0vVUpNP32qc8U3PDVxySP/y360qE= -github.com/golang/glog v1.1.0/go.mod h1:pfYeQZ3JWZoXTV5sFc986z3HTpwQs9At6P4ImfuP3NQ= +github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw= +github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -505,8 +510,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= -github.com/iancoleman/orderedmap v0.2.0 h1:sq1N/TFpYH++aViPcaKjys3bDClUEU7s5B+z6jq8pNA= -github.com/iancoleman/orderedmap v0.2.0/go.mod h1:N0Wam8K1arqPXNWjMo21EXnBPOPp36vB07FNRdD2geA= +github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= +github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= @@ -565,10 +570,10 @@ github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c= github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5 h1:2U0HzY8BJ8hVwDKIzp7y4voR9CX/nvcfymLmg2UiOio= github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= -github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -588,6 +593,7 @@ github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= +github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw= github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -705,16 +711,16 @@ github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnh github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 h1:oUhTd/4OcubK8u8GN36GdppGYGglCOLGUy5FiFsEk8M= github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6/go.mod h1:9KGhMg+7ZWgZ50Wa/x8w/jN19O0TSqYLlqUj+2wwxLU= -github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230621002052-afb82fbaa312 h1:7Y/948riUlpIfFSAUIx0rmRy3B+Mdk6alHwOa8lTNXY= -github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230621002052-afb82fbaa312/go.mod h1:JTym95/bqrSnG5MPcXr1YDhv43JdCeo3p+iDbazoX68= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230623115558-38aaab07d343 h1:7V2b3+mSnLnK0Px+Dl3vnxAQgk4SV8e9ohfJ/tKsq0M= -github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230623115558-38aaab07d343/go.mod h1:FqFOfj9+e5S1I7hR3baGUHrqje3g32EOHAXoOf7R00M= -github.com/osmosis-labs/osmosis/v16 v16.0.0-20230630175215-d5fcd089a71c h1:ZtqSK9+wQ3qNLlgCFyXn4ife04LXYQz9vfZ4j/agRcQ= -github.com/osmosis-labs/osmosis/v16 v16.0.0-20230630175215-d5fcd089a71c/go.mod h1:bkS/L9o/y1HSMViWzByzCNZtlulks9dpchOXFWM28g4= +github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230804142026-a81cfe3ddde7 h1:NTR4zfrPMP4pJ5T60zyZumBAnTWmTAQX/JSZLGrM9jI= +github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230804142026-a81cfe3ddde7/go.mod h1:UlftwozB+QObT3o0YfkuuyL9fsVdgoWt0dm6J7MLYnU= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5 h1:j4ifxomFROGROHalqWwX7VPDgxOPotMB1GiAWdb03i4= +github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5/go.mod h1:Pl8Nzx6O6ow/+aqfMoMSz4hX+zz6RrnDYsooptECGxM= +github.com/osmosis-labs/osmosis/v17 v17.0.0-20230811221421-2e3f19d86dd4 h1:EMbnmbZSJ1znKoN8Z4bwQxDN/Iq/n14KlH2QjzqeMSg= +github.com/osmosis-labs/osmosis/v17 v17.0.0-20230811221421-2e3f19d86dd4/go.mod h1:lw/ztTxBFpFj8ZuJrCYRL+b7LPy13A/tDflPVYCM0xM= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo= github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304/go.mod h1:yPWoJTj5RKrXKUChAicp+G/4Ni/uVEpp27mi/FF/L9c= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230602130523-f9a94d8bbd10 h1:XrES5AHZMZ/Y78boW35PTignkhN9h8VvJ1sP8EJDIu8= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230602130523-f9a94d8bbd10/go.mod h1:Ln6CKcXg/CJLSBE6Fd96/MIKPyA4iHuQTKSbl9q7vYo= +github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5 h1:clEegVniz0zTTBXKfg2oymKa63IYUxcrVXM+LtsvCpA= +github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5/go.mod h1:sR0lpev9mcm9/9RY50T1og3UC3WpZAsINh/OmgrmFlg= github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 h1:X747cZYdnqc/+RV48iPVeGprpVb/fUWSaKGsZUWrdbg= github.com/osmosis-labs/wasmd v0.31.0-osmo-v16/go.mod h1:Rf8zW/GgBQyFRRB4s62VQHWA6sTlMFSjoDQQpoq64iI= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= @@ -851,8 +857,6 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.5 h1:KKUqeGhVBK38+1LwThC8IeIcsJZ6COX5kvhiJroFqCM= -github.com/strangelove-ventures/packet-forward-middleware/v4 v4.0.5/go.mod h1:4zAtg449/JISRmf+sbmqolqSLP+QJBh+EtWkWtt/AKE= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= @@ -871,6 +875,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= @@ -907,11 +912,11 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= +github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= -github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= @@ -982,8 +987,8 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g= -golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0= +golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= +golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -1077,8 +1082,8 @@ golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= +golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1178,14 +1183,13 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= +golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= +golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1195,8 +1199,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= +golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1342,8 +1346,12 @@ google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e h1:xIXmWJ303kJCuogpj0bHq+dcjcZHU+XFyc1I0Yl9cRg= +google.golang.org/genproto v0.0.0-20230726155614-23370e0ffb3e/go.mod h1:0ggbjUrZYpy1q+ANUS30SEoGZ53cdfwtbuG7Ptgy108= +google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130 h1:XVeBY8d/FaK4848myy41HBqnDwvxeV3zMZhwN1TvAMU= +google.golang.org/genproto/googleapis/api v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:mPBs5jNgx2GuQGvFwUvVKqtn6HsUw9nP64BedgvqEsQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130 h1:2FZP5XuJY9zQyGM5N0rtovnoXjiMUEIUMvw0m9wlpLc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230706204954-ccb25ca9f130/go.mod h1:8mL13HKkDa+IuJ8yruA3ci0q+0vsUz4m//+ottjwS5o= google.golang.org/grpc v1.33.2 h1:EQyQC3sa8M+p6Ulc8yy9SWSS2GVwyRc83gAbG8lrl4o= google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= @@ -1358,8 +1366,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng= -google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= +google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index c35a9318ee5..3c45f22ab2e 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -43,12 +43,3 @@ func (k Keeper) CreateMultihopExpectedSwapOuts( ) ([]sdk.Int, error) { return k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } - -func (k Keeper) CreateOsmoMultihopExpectedSwapOuts( - ctx sdk.Context, - route []types.SwapAmountOutRoute, - tokenOut sdk.Coin, - cumulativeRouteSwapFee, sumOfSwapFees sdk.Dec, -) ([]sdk.Int, error) { - return k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, cumulativeRouteSwapFee, sumOfSwapFees) -} diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 22528ddf37a..97bc65be304 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -7,6 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + appparams "github.com/osmosis-labs/osmosis/v17/app/params" + "github.com/osmosis-labs/osmosis/osmoutils" cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" @@ -35,6 +37,8 @@ func (k Keeper) RouteExactAmountIn( sumOfSpreadFactors sdk.Dec ) + poolManagerParams := k.GetParams(ctx) + // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountInRoutes(route) if err := routeStep.Validate(); err != nil { @@ -75,7 +79,7 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - takerFee := k.determineTakerFee(ctx, pool) + takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) totalFees := spreadFactor.Add(takerFee) tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, totalFees) @@ -83,7 +87,7 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) if err != nil { return sdk.Int{}, err } @@ -194,8 +198,10 @@ func (k Keeper) SwapExactAmountIn( return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } + poolManagerParams := k.GetParams(ctx) + spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, pool) + takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) totalFees := spreadFactor.Add(takerFee) // routeStep to the pool-specific SwapExactAmountIn implementation. @@ -204,7 +210,45 @@ func (k Keeper) SwapExactAmountIn( return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) + if err != nil { + return sdk.Int{}, err + } + + return tokenOutAmount, nil +} + +func (k Keeper) SwapExactAmountInNoTakerFee( + ctx sdk.Context, + sender sdk.AccAddress, + poolId uint64, + tokenIn sdk.Coin, + tokenOutDenom string, + tokenOutMinAmount sdk.Int, +) (tokenOutAmount sdk.Int, err error) { + // Get the pool-specific module implementation to ensure that + // swaps are routed to the pool type corresponding to pool ID's pool. + swapModule, err := k.GetPoolModule(ctx, poolId) + if err != nil { + return sdk.Int{}, err + } + + // Get pool as a general pool type. Note that the underlying function used + // still varies with the pool type. + pool, poolErr := swapModule.GetPool(ctx, poolId) + if poolErr != nil { + return sdk.Int{}, poolErr + } + + // Check if pool has swaps enabled. + if !pool.IsActive(ctx) { + return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) + } + + spreadFactor := pool.GetSpreadFactor(ctx) + + // routeStep to the pool-specific SwapExactAmountIn implementation. + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -225,6 +269,8 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } }() + poolManagerParams := k.GetParams(ctx) + routeStep := types.SwapAmountInRoutes(route) if err := routeStep.Validate(); err != nil { return sdk.Int{}, err @@ -243,7 +289,7 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, poolI) + takerFee := k.determineTakerFee(ctx, poolI, poolManagerParams) totalFees := spreadFactor.Add(takerFee) tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, totalFees) @@ -281,6 +327,8 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, return sdk.Int{}, err } + poolManagerParams := k.GetParams(ctx) + defer func() { if r := recover(); r != nil { tokenInAmount = sdk.Int{} @@ -335,7 +383,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - takerFee := k.determineTakerFee(ctx, pool) + takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) totalFees := spreadFactor.Add(takerFee) _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, totalFees) @@ -344,7 +392,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn) + err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) if err != nil { return sdk.Int{}, err } @@ -470,7 +518,6 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( route []types.SwapAmountOutRoute, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { - isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} var insExpected []sdk.Int // recover from panic @@ -487,13 +534,7 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( } // Determine what the estimated input would be for each pool along the multi-hop route - // if we determined the route is an osmo multi-hop and both routes are incentivized, - // we utilize a separate function that calculates the discounted spread factors - if isMultiHopRouted { - insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, routeSpreadFactor, sumOfSpreadFactors) - } else { - insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) - } + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) if err != nil { return sdk.Int{}, err } @@ -577,40 +618,6 @@ func (k Keeper) createMultihopExpectedSwapOuts( return insExpected, nil } -// createOsmoMultihopExpectedSwapOuts does the same as createMultihopExpectedSwapOuts, however discounts the swap fee. -func (k Keeper) createOsmoMultihopExpectedSwapOuts( - ctx sdk.Context, - route []types.SwapAmountOutRoute, - tokenOut sdk.Coin, - cumulativeRouteSpreadFactor, sumOfSpreadFactors sdk.Dec, -) ([]sdk.Int, error) { - insExpected := make([]sdk.Int, len(route)) - for i := len(route) - 1; i >= 0; i-- { - routeStep := route[i] - - swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) - if err != nil { - return nil, err - } - - poolI, err := swapModule.GetPool(ctx, routeStep.PoolId) - if err != nil { - return nil, err - } - - spreadFactor := poolI.GetSpreadFactor(ctx) - tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors)))) - if err != nil { - return nil, err - } - - insExpected[i] = tokenIn.Amount - tokenOut = tokenIn - } - - return insExpected, nil -} - // GetTotalPoolLiquidity gets the total liquidity for a given poolId. func (k Keeper) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) { swapModule, err := k.GetPoolModule(ctx, poolId) @@ -647,32 +654,119 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { // determineTakerFee takes in a pool and determines the taker fee based on the pool type. // If the pool is a stableswap pool, the stableswap taker fee is returned. // If the poolId exists in the custom pool taker fee list, the custom taker fee is returned. -func (k Keeper) determineTakerFee(ctx sdk.Context, pool types.PoolI) sdk.Dec { - poolManagerParams := k.GetParams(ctx) +func (k Keeper) determineTakerFee(ctx sdk.Context, pool types.PoolI, poolManagerParams types.Params) sdk.Dec { poolId := pool.GetId() - if pool.GetType() == types.Stableswap { - return poolManagerParams.StableswapTakerFee - } + + // First, we check if the poolId exists in the custom pool taker fee list. + // This supersedes any other taker fee parameter. for _, tradingPair := range poolManagerParams.CustomPoolTakerFee { if poolId == tradingPair.PoolId { return tradingPair.TakerFee } } + // If the pool is a stableswap pool, the stableswap taker fee is returned. + if pool.GetType() == types.Stableswap { + return poolManagerParams.StableswapTakerFee + } + + // Otherwise, the default taker fee is returned. return poolManagerParams.DefaultTakerFee } -func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, tokenIn sdk.Coin) error { +// extractTakerFeeToFeePool takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. +// Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we +// pull directly from the pool and not the user's account. +func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params) error { var relevantPoolAddress sdk.AccAddress - feeCollectorName := txfeestypes.FeeCollectorName + nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName + nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName + baseDenom := appparams.BaseCoinUnit + if pool.GetType() == types.Concentrated { + // If the pool being swapped from is a concentrated pool, the fee is sent from the spread rewards address concentratedTypePool, ok := pool.(cltypes.ConcentratedPoolExtension) if !ok { return fmt.Errorf("pool %d is not a concentrated pool", pool.GetId()) } relevantPoolAddress = concentratedTypePool.GetSpreadRewardsAddress() } else { + // If the pool being swapped from is not a concentrated pool, the fee is sent from the pool address relevantPoolAddress = pool.GetAddress() } - testCoin := sdk.Coins{} - return k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, feeCollectorName, testCoin) + + // Take the taker fee from the input token and send it to the fee pool module account + takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.TruncateInt()) + + // We determine the distributution of the taker fee based on its denom + // If the denom is the base denom: + if takerFeeCoin.Denom == baseDenom { + // Community Pool: + if poolManagerParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + // Osmo community pool funds is a direct send + osmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.CommunityPool) + osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, relevantPoolAddress) + if err != nil { + return err + } + } + // Staking Rewards: + if poolManagerParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) + // We could stream these rewards via the fee collector account, but this is decision to be made by governance. + osmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.StakingRewards) + osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToStakingRewardsDec.TruncateInt())) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) + if err != nil { + return err + } + } + + // If the denom is not the base denom: + } else { + // Community Pool: + if poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + denomIsWhitelisted := isDenomWhitelisted(takerFeeCoin.Denom, poolManagerParams.AuthorizedQuoteDenoms) + // If the non osmo denom is a whitelisted quote asset, we send to the community pool + if denomIsWhitelisted { + nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, relevantPoolAddress) + if err != nil { + return err + } + } else { + // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. + // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. + nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) + if err != nil { + return err + } + } + } + // Staking Rewards: + if poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + // Non Osmo staking rewards are sent to the non native fee pool module account + nonOsmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards) + nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToStakingRewardsDec.TruncateInt())) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) + if err != nil { + return err + } + } + } + + return nil +} + +func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { + for _, authorizedQuoteDenom := range authorizedQuoteDenoms { + if denom == authorizedQuoteDenom { + return true + } + } + return false } diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 164f25d2864..ba3445b0bb9 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -2212,11 +2212,7 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { var actualSwapOuts []sdk.Int var err error - if !tc.sumOfSpreadFactors.IsNil() && !tc.cumulativeRouteSpreadFactor.IsNil() { - actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateOsmoMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut, tc.cumulativeRouteSpreadFactor, tc.sumOfSpreadFactors) - } else { - actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut) - } + actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut) if tc.expectedError { suite.Require().Error(err) } else { diff --git a/x/poolmanager/types/expected_keepers.go b/x/poolmanager/types/expected_keepers.go new file mode 100644 index 00000000000..f993cec0719 --- /dev/null +++ b/x/poolmanager/types/expected_keepers.go @@ -0,0 +1,108 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +// AccountI defines the account contract that must be fulfilled when +// creating a x/gamm keeper. +type AccountI interface { + GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI + NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI + GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI + SetAccount(ctx sdk.Context, acc authtypes.AccountI) +} + +// BankI defines the banking contract that must be fulfilled when +// creating a x/gamm keeper. +type BankI interface { + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error +} + +// CommunityPoolI defines the contract needed to be fulfilled for distribution keeper. +type CommunityPoolI interface { + FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error +} + +// PoolModuleI is the interface that must be fulfillled by the module +// storing and containing the pools. +type PoolModuleI interface { + InitializePool(ctx sdk.Context, pool PoolI, creatorAddress sdk.AccAddress) error + + GetPool(ctx sdk.Context, poolId uint64) (PoolI, error) + + GetPools(ctx sdk.Context) ([]PoolI, error) + + GetPoolDenoms(ctx sdk.Context, poolId uint64) (denoms []string, err error) + + CalculateSpotPrice( + ctx sdk.Context, + poolId uint64, + quoteAssetDenom string, + baseAssetDenom string, + ) (price sdk.Dec, err error) + + SwapExactAmountIn( + ctx sdk.Context, + sender sdk.AccAddress, + pool PoolI, + tokenIn sdk.Coin, + tokenOutDenom string, + tokenOutMinAmount sdk.Int, + spreadFactor sdk.Dec, + ) (sdk.Int, error) + // CalcOutAmtGivenIn calculates the amount of tokenOut given tokenIn and the pool's current state. + // Returns error if the given pool is not a CFMM pool. Returns error on internal calculations. + CalcOutAmtGivenIn( + ctx sdk.Context, + poolI PoolI, + tokenIn sdk.Coin, + tokenOutDenom string, + spreadFactor sdk.Dec, + ) (tokenOut sdk.Coin, err error) + + SwapExactAmountOut( + ctx sdk.Context, + sender sdk.AccAddress, + pool PoolI, + tokenInDenom string, + tokenInMaxAmount sdk.Int, + tokenOut sdk.Coin, + spreadFactor sdk.Dec, + ) (tokenInAmount sdk.Int, err error) + // CalcInAmtGivenOut calculates the amount of tokenIn given tokenOut and the pool's current state. + // Returns error if the given pool is not a CFMM pool. Returns error on internal calculations. + CalcInAmtGivenOut( + ctx sdk.Context, + poolI PoolI, + tokenOut sdk.Coin, + tokenInDenom string, + spreadFactor sdk.Dec, + ) (tokenIn sdk.Coin, err error) + + // GetTotalPoolLiquidity returns the coins in the pool owned by all LPs + GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) + + // ValidatePermissionlessPoolCreationEnabled returns nil if permissionless pool creation in the module is enabled. + // Otherwise, returns an error. + ValidatePermissionlessPoolCreationEnabled(ctx sdk.Context) error + + // GetTotalLiquidity returns the total liquidity of all the pools in the module. + GetTotalLiquidity(ctx sdk.Context) (sdk.Coins, error) +} + +type PoolIncentivesKeeperI interface { + IsPoolIncentivized(ctx sdk.Context, poolId uint64) bool +} + +type MultihopRoute interface { + Length() int + PoolIds() []uint64 + IntermediateDenoms() []string +} diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 394a280e64e..1d5dbaf1408 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -30,10 +30,25 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the poolmanager module type Params struct { - PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` - DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` - StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` - CustomPoolTakerFee []CustomPoolTakerFee `protobuf:"bytes,4,rep,name=trading_pair_taker_fee,json=tradingPairTakerFee,proto3" json:"trading_pair_taker_fee"` + PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` + DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` + StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` + CustomPoolTakerFee []CustomPoolTakerFee `protobuf:"bytes,4,rep,name=trading_pair_taker_fee,json=tradingPairTakerFee,proto3" json:"trading_pair_taker_fee"` + OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,5,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` + NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,6,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` + // authorized_quote_denoms is a list of quote denoms that can be used as + // token1 when creating a concentrated pool. We limit the quote assets to a + // small set for the purposes of having convinient price increments stemming + // from tick to price conversion. These increments are in a human readable + // magnitude only for token1 as a quote. For limit orders in the future, this + // will be a desirable property in terms of UX as to allow users to set limit + // orders at prices in terms of token1 (quote asset) that are easy to reason + // about. + AuthorizedQuoteDenoms []string `protobuf:"bytes,7,rep,name=authorized_quote_denoms,json=authorizedQuoteDenoms,proto3" json:"authorized_quote_denoms,omitempty" yaml:"authorized_quote_denoms"` + // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that + // taker fees that are not whitelisted will be swapped to when being sent to + // the community pool. + CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,8,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` } func (m *Params) Reset() { *m = Params{} } @@ -83,6 +98,34 @@ func (m *Params) GetCustomPoolTakerFee() []CustomPoolTakerFee { return nil } +func (m *Params) GetOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { + if m != nil { + return m.OsmoTakerFeeDistribution + } + return TakerFeeDistributionPercentage{} +} + +func (m *Params) GetNonOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { + if m != nil { + return m.NonOsmoTakerFeeDistribution + } + return TakerFeeDistributionPercentage{} +} + +func (m *Params) GetAuthorizedQuoteDenoms() []string { + if m != nil { + return m.AuthorizedQuoteDenoms + } + return nil +} + +func (m *Params) GetCommunityPoolDenomToSwapNonWhitelistedAssetsTo() string { + if m != nil { + return m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo + } + return "" +} + // GenesisState defines the poolmanager module's genesis state. type GenesisState struct { // the next_pool_id @@ -193,10 +236,51 @@ func (m *CustomPoolTakerFee) GetPoolId() uint64 { return 0 } +// TakerFeeDistributionPercentage defines what percent of the taker fee category +// gets distributed to the available categories. +type TakerFeeDistributionPercentage struct { + StakingRewards github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=staking_rewards,json=stakingRewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"staking_rewards" yaml:"staking_rewards"` + CommunityPool github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=community_pool,json=communityPool,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_pool" yaml:"community_pool"` +} + +func (m *TakerFeeDistributionPercentage) Reset() { *m = TakerFeeDistributionPercentage{} } +func (m *TakerFeeDistributionPercentage) String() string { return proto.CompactTextString(m) } +func (*TakerFeeDistributionPercentage) ProtoMessage() {} +func (*TakerFeeDistributionPercentage) Descriptor() ([]byte, []int) { + return fileDescriptor_aa099d9fbdf68b35, []int{3} +} +func (m *TakerFeeDistributionPercentage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TakerFeeDistributionPercentage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TakerFeeDistributionPercentage.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TakerFeeDistributionPercentage) XXX_Merge(src proto.Message) { + xxx_messageInfo_TakerFeeDistributionPercentage.Merge(m, src) +} +func (m *TakerFeeDistributionPercentage) XXX_Size() int { + return m.Size() +} +func (m *TakerFeeDistributionPercentage) XXX_DiscardUnknown() { + xxx_messageInfo_TakerFeeDistributionPercentage.DiscardUnknown(m) +} + +var xxx_messageInfo_TakerFeeDistributionPercentage proto.InternalMessageInfo + func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") proto.RegisterType((*CustomPoolTakerFee)(nil), "osmosis.poolmanager.v1beta1.CustomPoolTakerFee") + proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") } func init() { @@ -204,44 +288,61 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 592 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xc1, 0x6e, 0xd3, 0x4c, - 0x10, 0x8e, 0xff, 0x46, 0xf9, 0xe9, 0xb6, 0x52, 0xa8, 0xa9, 0x50, 0x1a, 0x24, 0x3b, 0x72, 0x25, - 0x14, 0x0e, 0xb5, 0x95, 0x72, 0xa8, 0xc4, 0xad, 0x4e, 0x54, 0x84, 0x04, 0x22, 0xb8, 0x9c, 0xb8, - 0x58, 0xeb, 0x78, 0x62, 0xac, 0xda, 0x5e, 0xcb, 0xbb, 0x0e, 0xcd, 0x8d, 0x23, 0x47, 0x24, 0x6e, - 0x3c, 0x02, 0xcf, 0xc1, 0xa1, 0xc7, 0x1e, 0x11, 0x07, 0x83, 0x92, 0x37, 0xe8, 0x13, 0xa0, 0x5d, - 0xaf, 0xa3, 0xa4, 0x41, 0x11, 0x3d, 0xd9, 0x3b, 0x33, 0xdf, 0xf7, 0xcd, 0xa7, 0x99, 0x41, 0x4f, - 0x08, 0x8d, 0x09, 0x0d, 0xa9, 0x95, 0x12, 0x12, 0xc5, 0x38, 0xc1, 0x01, 0x64, 0xd6, 0xa4, 0xe7, - 0x01, 0xc3, 0x3d, 0x2b, 0x80, 0x04, 0x68, 0x48, 0xcd, 0x34, 0x23, 0x8c, 0xa8, 0x8f, 0x64, 0xa9, - 0xb9, 0x54, 0x6a, 0xca, 0xd2, 0xf6, 0x7e, 0x40, 0x02, 0x22, 0xea, 0x2c, 0xfe, 0x57, 0x42, 0xda, - 0x07, 0x01, 0x21, 0x41, 0x04, 0x96, 0x78, 0x79, 0xf9, 0xd8, 0xc2, 0xc9, 0xb4, 0x4a, 0x8d, 0x04, - 0x9d, 0x5b, 0x62, 0xca, 0x87, 0x4c, 0x69, 0xb7, 0x51, 0x7e, 0x9e, 0x61, 0x16, 0x92, 0xa4, 0xca, - 0x97, 0xd5, 0x96, 0x87, 0x29, 0x2c, 0x7a, 0x1d, 0x91, 0xb0, 0xca, 0x9b, 0x9b, 0x3c, 0xc5, 0xc4, - 0xcf, 0x23, 0x70, 0x33, 0x92, 0x33, 0x28, 0xeb, 0x8d, 0x4f, 0x75, 0xd4, 0x18, 0xe2, 0x0c, 0xc7, - 0x54, 0xfd, 0xa2, 0xa0, 0x3d, 0x8e, 0x72, 0x47, 0x19, 0x08, 0x49, 0x77, 0x0c, 0xd0, 0x52, 0x3a, - 0x5b, 0xdd, 0x9d, 0xe3, 0x03, 0x53, 0x76, 0xc9, 0x75, 0x2b, 0xe3, 0x66, 0x9f, 0x84, 0x89, 0xfd, - 0xf2, 0xaa, 0xd0, 0x6b, 0x37, 0x85, 0xde, 0x9a, 0xe2, 0x38, 0x7a, 0x66, 0xac, 0x31, 0x18, 0xdf, - 0x7e, 0xe9, 0xdd, 0x20, 0x64, 0xef, 0x73, 0xcf, 0x1c, 0x91, 0x58, 0xda, 0x95, 0x9f, 0x23, 0xea, - 0x5f, 0x58, 0x6c, 0x9a, 0x02, 0x15, 0x64, 0xd4, 0x69, 0x72, 0x7c, 0x5f, 0xc2, 0xcf, 0x00, 0xd4, - 0x18, 0xed, 0xf9, 0x30, 0xc6, 0x79, 0xc4, 0x5c, 0x86, 0x2f, 0x20, 0x13, 0x4d, 0xfd, 0xd7, 0x51, - 0xba, 0xdb, 0xf6, 0x29, 0x57, 0xfe, 0x59, 0xe8, 0x8f, 0xff, 0x81, 0x7d, 0x00, 0xa3, 0x59, 0xa1, - 0x37, 0x07, 0x25, 0xd5, 0x5b, 0xce, 0x74, 0x06, 0xe0, 0x34, 0xfd, 0xd5, 0x80, 0x3a, 0x41, 0xfb, - 0x94, 0x61, 0x2f, 0x02, 0xfa, 0x01, 0xa7, 0x4b, 0x8a, 0x5b, 0x42, 0x71,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 0x9b, 0xab, 0x99, 0xa6, 0x5c, 0xcf, 0x34, 0xe5, 0xf7, 0x4c, 0x53, 0x3e, 0xcf, - 0xb5, 0xda, 0xf5, 0x5c, 0xab, 0xfd, 0x98, 0x6b, 0xb5, 0x77, 0x27, 0x4b, 0xfc, 0xd2, 0xfc, 0x51, - 0x84, 0x3d, 0x5a, 0x3d, 0xac, 0x49, 0xef, 0xc4, 0xba, 0x5c, 0x39, 0x6b, 0x21, 0xea, 0x35, 0xc4, - 0x21, 0x3f, 0xfd, 0x13, 0x00, 0x00, 0xff, 0xff, 0x34, 0xdd, 0x86, 0x4c, 0xce, 0x04, 0x00, 0x00, + // 862 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, + 0x14, 0x8f, 0x9b, 0xb0, 0x4d, 0x26, 0xa5, 0xa1, 0xa6, 0x2d, 0x6e, 0x22, 0xd9, 0x2b, 0x47, 0x42, + 0xcb, 0xa1, 0xb6, 0x12, 0x24, 0x2a, 0x81, 0x38, 0xc4, 0x59, 0xb5, 0x20, 0x41, 0x9b, 0x3a, 0x91, + 0x90, 0x7a, 0xb1, 0x66, 0xd7, 0x2f, 0x8e, 0x15, 0x7b, 0xde, 0xd6, 0x33, 0x4e, 0x1a, 0x4e, 0x48, + 0x7c, 0x01, 0x24, 0x6e, 0x88, 0x33, 0x07, 0x6e, 0x7c, 0x07, 0x0e, 0x3d, 0xf6, 0x88, 0x38, 0x2c, + 0xd5, 0xe6, 0x1b, 0xe4, 0x13, 0xa0, 0xf9, 0xb3, 0x9b, 0xdd, 0xfc, 0x59, 0xb1, 0xf4, 0x94, 0xcc, + 0x7b, 0xef, 0xf7, 0xe7, 0xed, 0xbc, 0x79, 0x26, 0x9f, 0x20, 0x2f, 0x91, 0xe7, 0x3c, 0xec, 0x21, + 0x16, 0x25, 0x65, 0x34, 0x83, 0x2a,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0xc9, 0x4f, + 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x90, 0x40, 0xdc, 0x2c, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -264,6 +365,42 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) > 0 { + i -= len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo))) + i-- + dAtA[i] = 0x42 + } + if len(m.AuthorizedQuoteDenoms) > 0 { + for iNdEx := len(m.AuthorizedQuoteDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AuthorizedQuoteDenoms[iNdEx]) + copy(dAtA[i:], m.AuthorizedQuoteDenoms[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AuthorizedQuoteDenoms[iNdEx]))) + i-- + dAtA[i] = 0x3a + } + } + { + size, err := m.NonOsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + { + size, err := m.OsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a if len(m.CustomPoolTakerFee) > 0 { for iNdEx := len(m.CustomPoolTakerFee) - 1; iNdEx >= 0; iNdEx-- { { @@ -405,6 +542,49 @@ func (m *CustomPoolTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TakerFeeDistributionPercentage) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TakerFeeDistributionPercentage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TakerFeeDistributionPercentage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.CommunityPool.Size() + i -= size + if _, err := m.CommunityPool.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.StakingRewards.Size() + i -= size + if _, err := m.StakingRewards.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -438,6 +618,20 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + l = m.OsmoTakerFeeDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.NonOsmoTakerFeeDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.AuthorizedQuoteDenoms) > 0 { + for _, s := range m.AuthorizedQuoteDenoms { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -475,6 +669,19 @@ func (m *CustomPoolTakerFee) Size() (n int) { return n } +func (m *TakerFeeDistributionPercentage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingRewards.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.CommunityPool.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -646,6 +853,136 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmoTakerFeeDistribution", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.OsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NonOsmoTakerFeeDistribution", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.NonOsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedQuoteDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AuthorizedQuoteDenoms = append(m.AuthorizedQuoteDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -906,6 +1243,124 @@ func (m *CustomPoolTakerFee) Unmarshal(dAtA []byte) error { } return nil } +func (m *TakerFeeDistributionPercentage) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TakerFeeDistributionPercentage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TakerFeeDistributionPercentage: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingRewards", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StakingRewards.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPool", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.CommunityPool.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 8d72ddadabb..2bbf40acb8f 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -11,10 +11,14 @@ import ( // Parameter store keys. var ( - KeyPoolCreationFee = []byte("PoolCreationFee") - KeyDefaultTakerFee = []byte("DefaultTakerFee") - KeyStableswapTakerFee = []byte("StableswapTakerFee") - KeyTradingPairTakerFee = []byte("TradingPairTakerFee") + KeyPoolCreationFee = []byte("PoolCreationFee") + KeyDefaultTakerFee = []byte("DefaultTakerFee") + KeyStableswapTakerFee = []byte("StableswapTakerFee") + KeyCustomPoolTakerFee = []byte("CustomPoolTakerFee") + KeyOsmoTakerFeeDistribution = []byte("OsmoTakerFeeDistribution") + KeyNonOsmoTakerFeeDistribution = []byte("NonOsmoTakerFeeDistribution") + KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") + KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo = []byte("CommunityPoolDenomToSwapNonWhitelistedAssetsTo") ) // ParamTable for gamm module. @@ -22,12 +26,16 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, customPoolTakerFee []CustomPoolTakerFee) Params { +func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, customPoolTakerFee []CustomPoolTakerFee, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { return Params{ - PoolCreationFee: poolCreationFee, - DefaultTakerFee: defaultTakerFee, - StableswapTakerFee: stableswapTakerFee, - CustomPoolTakerFee: customPoolTakerFee, + PoolCreationFee: poolCreationFee, + DefaultTakerFee: defaultTakerFee, + StableswapTakerFee: stableswapTakerFee, + CustomPoolTakerFee: customPoolTakerFee, + OsmoTakerFeeDistribution: osmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, + AuthorizedQuoteDenoms: authorizedQuoteDenoms, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: communityPoolDenomToSwapNonWhitelistedAssetsTo, } } @@ -38,6 +46,21 @@ func DefaultParams() Params { DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% CustomPoolTakerFee: []CustomPoolTakerFee{}, + OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("1"), // 100% + CommunityPool: sdk.MustNewDecFromStr("0"), // 0% + }, + NonOsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("0.67"), // 67% + CommunityPool: sdk.MustNewDecFromStr("0.33"), // 33% + }, + AuthorizedQuoteDenoms: []string{ + "uosmo", + "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM + "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", // DAI + "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC + }, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC } } @@ -46,6 +69,27 @@ func (p Params) Validate() error { if err := validatePoolCreationFee(p.PoolCreationFee); err != nil { return err } + if err := validateDefaultTakerFee(p.DefaultTakerFee); err != nil { + return err + } + if err := validateStableswapTakerFee(p.StableswapTakerFee); err != nil { + return err + } + if err := validateCustomPoolTakerFee(p.CustomPoolTakerFee); err != nil { + return err + } + if err := validateTakerFeeDistribution(p.OsmoTakerFeeDistribution); err != nil { + return err + } + if err := validateTakerFeeDistribution(p.NonOsmoTakerFeeDistribution); err != nil { + return err + } + if err := validateAuthorizedQuoteDenoms(p.AuthorizedQuoteDenoms); err != nil { + return err + } + if err := validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo); err != nil { + return err + } return nil } @@ -54,6 +98,13 @@ func (p Params) Validate() error { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), + paramtypes.NewParamSetPair(KeyDefaultTakerFee, &p.DefaultTakerFee, validateDefaultTakerFee), + paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.StableswapTakerFee, validateStableswapTakerFee), + paramtypes.NewParamSetPair(KeyCustomPoolTakerFee, &p.CustomPoolTakerFee, validateCustomPoolTakerFee), + paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.OsmoTakerFeeDistribution, validateTakerFeeDistribution), + paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), + paramtypes.NewParamSetPair(KeyAuthorizedQuoteDenoms, &p.AuthorizedQuoteDenoms, validateAuthorizedQuoteDenoms), + paramtypes.NewParamSetPair(KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo, &p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo, validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo), } } @@ -69,3 +120,116 @@ func validatePoolCreationFee(i interface{}) error { return nil } + +func validateDefaultTakerFee(i interface{}) error { + // Convert the given parameter to sdk.Dec. + defaultTakerFee, ok := i.(sdk.Dec) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // Ensure that the passed in discount rate is between 0 and 1. + if defaultTakerFee.IsNegative() || defaultTakerFee.GT(sdk.OneDec()) { + return fmt.Errorf("invalid default taker fee: %s", defaultTakerFee) + } + + return nil +} + +func validateStableswapTakerFee(i interface{}) error { + // Convert the given parameter to sdk.Dec. + stableswapTakerFee, ok := i.(sdk.Dec) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // Ensure that the passed in discount rate is between 0 and 1. + if stableswapTakerFee.IsNegative() || stableswapTakerFee.GT(sdk.OneDec()) { + return fmt.Errorf("invalid stableswap taker fee: %s", stableswapTakerFee) + } + + return nil +} + +func validateCustomPoolTakerFee(i interface{}) error { + // Convert the given parameter to sdk.Dec. + customPoolTakerFee, ok := i.([]CustomPoolTakerFee) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + for _, customPoolTakerFee := range customPoolTakerFee { + if customPoolTakerFee.PoolId <= 0 { + return fmt.Errorf("invalid pool ID: %d", customPoolTakerFee.PoolId) + } + if customPoolTakerFee.TakerFee.IsNegative() || customPoolTakerFee.TakerFee.GT(sdk.OneDec()) { + return fmt.Errorf("invalid taker fee: %s", customPoolTakerFee.TakerFee) + } + } + + return nil +} + +func validateTakerFeeDistribution(i interface{}) error { + // Convert the given parameter to sdk.Dec. + takerFeeDistribution, ok := i.(TakerFeeDistributionPercentage) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if takerFeeDistribution.StakingRewards.IsNegative() || takerFeeDistribution.StakingRewards.GT(sdk.OneDec()) { + return fmt.Errorf("invalid staking rewards distribution: %s", takerFeeDistribution.StakingRewards) + } + if takerFeeDistribution.CommunityPool.IsNegative() || takerFeeDistribution.CommunityPool.GT(sdk.OneDec()) { + return fmt.Errorf("invalid community pool distribution: %s", takerFeeDistribution.CommunityPool) + } + + return nil +} + +// validateAuthorizedQuoteDenoms validates a slice of authorized quote denoms. +// +// Parameters: +// - i: The parameter to validate. +// +// Returns: +// - An error if given type is not string slice. +// - An error if given slice is empty. +// - An error if any of the denoms are invalid. +func validateAuthorizedQuoteDenoms(i interface{}) error { + authorizedQuoteDenoms, ok := i.([]string) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if len(authorizedQuoteDenoms) == 0 { + return fmt.Errorf("authorized quote denoms cannot be empty") + } + + for _, denom := range authorizedQuoteDenoms { + if err := sdk.ValidateDenom(denom); err != nil { + return err + } + } + + return nil +} + +func validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(i interface{}) error { + communityPoolDenomToSwapNonWhitelistedAssetsTo, ok := i.(string) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if err := sdk.ValidateDenom(communityPoolDenomToSwapNonWhitelistedAssetsTo); err != nil { + return err + } + + return nil +} diff --git a/x/poolmanager/types/routes.go b/x/poolmanager/types/routes.go index 7f1ef9590f1..b45ed915c60 100644 --- a/x/poolmanager/types/routes.go +++ b/x/poolmanager/types/routes.go @@ -4,111 +4,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/osmosis-labs/osmosis/osmoutils" - - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) -// AccountI defines the account contract that must be fulfilled when -// creating a x/gamm keeper. -type AccountI interface { - GetModuleAccount(ctx sdk.Context, moduleName string) authtypes.ModuleAccountI - NewAccount(sdk.Context, authtypes.AccountI) authtypes.AccountI - GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI - SetAccount(ctx sdk.Context, acc authtypes.AccountI) -} - -// BankI defines the banking contract that must be fulfilled when -// creating a x/gamm keeper. -type BankI interface { - SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error - SetDenomMetaData(ctx sdk.Context, denomMetaData banktypes.Metadata) - GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error -} - -// CommunityPoolI defines the contract needed to be fulfilled for distribution keeper. -type CommunityPoolI interface { - FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error -} - -// PoolModuleI is the interface that must be fulfillled by the module -// storing and containing the pools. -type PoolModuleI interface { - InitializePool(ctx sdk.Context, pool PoolI, creatorAddress sdk.AccAddress) error - - GetPool(ctx sdk.Context, poolId uint64) (PoolI, error) - - GetPools(ctx sdk.Context) ([]PoolI, error) - - GetPoolDenoms(ctx sdk.Context, poolId uint64) (denoms []string, err error) - - CalculateSpotPrice( - ctx sdk.Context, - poolId uint64, - quoteAssetDenom string, - baseAssetDenom string, - ) (price sdk.Dec, err error) - - SwapExactAmountIn( - ctx sdk.Context, - sender sdk.AccAddress, - pool PoolI, - tokenIn sdk.Coin, - tokenOutDenom string, - tokenOutMinAmount sdk.Int, - spreadFactor sdk.Dec, - ) (sdk.Int, error) - // CalcOutAmtGivenIn calculates the amount of tokenOut given tokenIn and the pool's current state. - // Returns error if the given pool is not a CFMM pool. Returns error on internal calculations. - CalcOutAmtGivenIn( - ctx sdk.Context, - poolI PoolI, - tokenIn sdk.Coin, - tokenOutDenom string, - spreadFactor sdk.Dec, - ) (tokenOut sdk.Coin, err error) - - SwapExactAmountOut( - ctx sdk.Context, - sender sdk.AccAddress, - pool PoolI, - tokenInDenom string, - tokenInMaxAmount sdk.Int, - tokenOut sdk.Coin, - spreadFactor sdk.Dec, - ) (tokenInAmount sdk.Int, err error) - // CalcInAmtGivenOut calculates the amount of tokenIn given tokenOut and the pool's current state. - // Returns error if the given pool is not a CFMM pool. Returns error on internal calculations. - CalcInAmtGivenOut( - ctx sdk.Context, - poolI PoolI, - tokenOut sdk.Coin, - tokenInDenom string, - spreadFactor sdk.Dec, - ) (tokenIn sdk.Coin, err error) - - // GetTotalPoolLiquidity returns the coins in the pool owned by all LPs - GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) - - // ValidatePermissionlessPoolCreationEnabled returns nil if permissionless pool creation in the module is enabled. - // Otherwise, returns an error. - ValidatePermissionlessPoolCreationEnabled(ctx sdk.Context) error - - // GetTotalLiquidity returns the total liquidity of all the pools in the module. - GetTotalLiquidity(ctx sdk.Context) (sdk.Coins, error) -} - -type PoolIncentivesKeeperI interface { - IsPoolIncentivized(ctx sdk.Context, poolId uint64) bool -} - -type MultihopRoute interface { - Length() int - PoolIds() []uint64 - IntermediateDenoms() []string -} - type SwapAmountInRoutes []SwapAmountInRoute func (routes SwapAmountInRoutes) Validate() error { diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index 57c8ac59b00..b10a4db8582 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -180,8 +180,8 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } // checks to make sure a separate module account has been set to collect fees not in base token - if addrNonNativeFee := dfd.ak.GetModuleAddress(types.NonNativeFeeCollectorName); addrNonNativeFee == nil { - return ctx, fmt.Errorf("non native fee collector module account (%s) has not been set", types.NonNativeFeeCollectorName) + if addrNonNativeFee := dfd.ak.GetModuleAddress(types.NonNativeFeeCollectorForStakingRewardsName); addrNonNativeFee == nil { + return ctx, fmt.Errorf("non native fee collector module account (%s) has not been set", types.NonNativeFeeCollectorForStakingRewardsName) } // fee can be in any denom (checked for validity later) @@ -249,7 +249,7 @@ func DeductFees(txFeesKeeper types.TxFeesKeeper, bankKeeper types.BankKeeper, ct } } else { // sends to NonNativeFeeCollectorName module account - err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.NonNativeFeeCollectorName, fees) + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.NonNativeFeeCollectorForStakingRewardsName, fees) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index fbbb1ec015d..c10905c5703 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -208,7 +208,7 @@ func (s *KeeperTestSuite) TestFeeDecorator() { if !tc.txFee.IsZero() { moduleName := types.FeeCollectorName if tc.txFee[0].Denom != baseDenom { - moduleName = types.NonNativeFeeCollectorName + moduleName = types.NonNativeFeeCollectorForStakingRewardsName } moduleAddr := s.App.AccountKeeper.GetModuleAddress(moduleName) s.Require().Equal(tc.txFee[0], s.App.BankKeeper.GetBalance(s.Ctx, moduleAddr, tc.txFee[0].Denom), tc.name) diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index ecb84f527aa..25ad6995745 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -14,19 +14,30 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN // at the end of each epoch, swap all non-OSMO fees into OSMO and transfer to fee module account func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - nonNativeFeeAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorName) baseDenom, _ := k.GetBaseDenom(ctx) - feeTokens := k.GetFeeTokens(ctx) - for _, feetoken := range feeTokens { - if feetoken.Denom == baseDenom { + nonNativeFeeCollectorForStakingRewardsAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) + nonNativeFeeCollectorForStakingRewardsBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForStakingRewardsAddr) + + // Non-native fee collector for staking rewards get swapped entirely into base denom. + for _, coin := range nonNativeFeeCollectorForStakingRewardsBalance { + if coin.Denom == baseDenom { continue } - coinBalance := k.bankKeeper.GetBalance(ctx, nonNativeFeeAddr, feetoken.Denom) + + coinBalance := k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, coin.Denom) if coinBalance.Amount.IsZero() { continue } + poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, baseDenom, coin.Denom) + if err != nil { + // The pool route either doesn't exist or is disabled in protorev. + // It will just accrue in the non-native fee collector account. + // Skip this denom and move on to the next one. + continue + } + // Do the swap of this fee token denom to base denom. _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { // We allow full slippage. Theres not really an effective way to bound slippage until TWAP's land, @@ -34,16 +45,68 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // The only thing that could be done is a costly griefing attack to reduce the amount of osmo given as tx fees. // However the idea of the txfees FeeToken gating is that the pool is sufficiently liquid for that base token. minAmountOut := sdk.ZeroInt() - _, err := k.poolManager.SwapExactAmountIn(cacheCtx, nonNativeFeeAddr, feetoken.PoolID, coinBalance, baseDenom, minAmountOut) + + // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that + // are accruing from the taker fee itself. + _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, baseDenom, minAmountOut) return err }) } - // Get all of the txfee payout denom in the module account - baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeAddr, baseDenom)) + // Now that the rewards have been swapped, transfer any base denom existing in the non-native fee collector to the fee collector (indirectly distributing to stakers) + baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, baseDenom)) + _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) + return err + }) + + // Non-native fee collector for community pool get swapped entirely into denom specified in the pool manager params. + + poolManagerParams := k.poolManager.GetParams(ctx) + denomToSwapTo := poolManagerParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo + + nonNativeFeeCollectorForCommunityPoolAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForCommunityPoolName) + nonNativeFeeCollectorForCommunityPoolBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForCommunityPoolAddr) + + // Only non whitelisted assets should exist here since we do direct community pool funds when calculating the taker fee if + // the input is a whitelisted asset. + for _, coin := range nonNativeFeeCollectorForCommunityPoolBalance { + if coin.Denom == denomToSwapTo { + continue + } + + coinBalance := k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForCommunityPoolAddr, coin.Denom) + if coinBalance.Amount.IsZero() { + continue + } + + poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, denomToSwapTo, coin.Denom) + if err != nil { + // The pool route either doesn't exist or is disabled in protorev. + // It will just accrue in the non-native fee collector account. + // Skip this denom and move on to the next one. + continue + } + + // Do the swap of this fee token denom to base denom. + _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { + // We allow full slippage. Theres not really an effective way to bound slippage until TWAP's land, + // but even then the point is a bit moot. + // The only thing that could be done is a costly griefing attack to reduce the amount of osmo given as tx fees. + // However the idea of the txfees FeeToken gating is that the pool is sufficiently liquid for that base token. + minAmountOut := sdk.ZeroInt() + + // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that + // are accruing from the taker fee itself. + _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForCommunityPoolAddr, poolId, coinBalance, denomToSwapTo, minAmountOut) + return err + }) + } + // Now that the non whitelisted assets have been swapped, fund the community pool with the denom we swapped to. + denomToSwapToCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForCommunityPoolAddr, denomToSwapTo)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorName, txfeestypes.FeeCollectorName, baseDenomCoins) + err := k.distributionKeeper.FundCommunityPool(ctx, denomToSwapToCoins, nonNativeFeeCollectorForCommunityPoolAddr) return err }) diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index 865a12611e5..f584e71c573 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -91,12 +91,12 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { _, _, addr0 := testdata.KeyTestPubAddr() err = simapp.FundAccount(s.App.BankKeeper, s.Ctx, addr0, sdk.Coins{coin}) s.NoError(err) - err = s.App.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, addr0, types.NonNativeFeeCollectorName, sdk.Coins{coin}) + err = s.App.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, addr0, types.NonNativeFeeCollectorForStakingRewardsName, sdk.Coins{coin}) s.NoError(err) } // checks the balance of the non-native denom in module account - moduleAddrNonNativeFee := s.App.AccountKeeper.GetModuleAddress(types.NonNativeFeeCollectorName) + moduleAddrNonNativeFee := s.App.AccountKeeper.GetModuleAddress(types.NonNativeFeeCollectorForStakingRewardsName) s.Equal(s.App.BankKeeper.GetAllBalances(s.Ctx, moduleAddrNonNativeFee), tc.coins) // End of epoch, so all the non-osmo fee amount should be swapped to osmo and transfer to fee module account diff --git a/x/txfees/keeper/keeper.go b/x/txfees/keeper/keeper.go index 37e27872407..37399ce3c97 100644 --- a/x/txfees/keeper/keeper.go +++ b/x/txfees/keeper/keeper.go @@ -18,6 +18,8 @@ type Keeper struct { bankKeeper types.BankKeeper poolManager types.PoolManager spotPriceCalculator types.SpotPriceCalculator + protorevKeeper types.ProtorevKeeper + distributionKeeper types.DistributionKeeper } var _ types.TxFeesKeeper = (*Keeper)(nil) @@ -28,6 +30,8 @@ func NewKeeper( storeKey sdk.StoreKey, poolManager types.PoolManager, spotPriceCalculator types.SpotPriceCalculator, + protorevKeeper types.ProtorevKeeper, + distributionKeeper types.DistributionKeeper, ) Keeper { return Keeper{ accountKeeper: accountKeeper, @@ -35,6 +39,8 @@ func NewKeeper( storeKey: storeKey, poolManager: poolManager, spotPriceCalculator: spotPriceCalculator, + protorevKeeper: protorevKeeper, + distributionKeeper: distributionKeeper, } } diff --git a/x/txfees/types/expected_keepers.go b/x/txfees/types/expected_keepers.go index 22f1dae4752..0086aa0ac08 100644 --- a/x/txfees/types/expected_keepers.go +++ b/x/txfees/types/expected_keepers.go @@ -30,6 +30,17 @@ type PoolManager interface { tokenOutDenom string, tokenOutMinAmount sdk.Int, ) (sdk.Int, error) + + SwapExactAmountInNoTakerFee( + ctx sdk.Context, + sender sdk.AccAddress, + poolId uint64, + tokenIn sdk.Coin, + tokenOutDenom string, + tokenOutMinAmount sdk.Int, + ) (sdk.Int, error) + + GetParams(ctx sdk.Context) (params poolmanagertypes.Params) } // AccountKeeper defines the contract needed for AccountKeeper related APIs. @@ -48,6 +59,7 @@ type FeegrantKeeper interface { type BankKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin + GetAllBalances(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error } @@ -57,3 +69,11 @@ type TxFeesKeeper interface { GetBaseDenom(ctx sdk.Context) (denom string, err error) GetFeeToken(ctx sdk.Context, denom string) (FeeToken, error) } + +type ProtorevKeeper interface { + GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error) +} + +type DistributionKeeper interface { + FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error +} diff --git a/x/txfees/types/keys.go b/x/txfees/types/keys.go index 0978070fd39..9db441ae159 100644 --- a/x/txfees/types/keys.go +++ b/x/txfees/types/keys.go @@ -13,8 +13,10 @@ const ( // FeeCollectorName the module account name for the fee collector account address. FeeCollectorName = "fee_collector" - // NonNativeFeeCollectorName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). - NonNativeFeeCollectorName = "non_native_fee_collector" + // NonNativeFeeCollectorForStakingRewardsName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). + NonNativeFeeCollectorForStakingRewardsName = "non_native_fee_collector" + + NonNativeFeeCollectorForCommunityPoolName = "non_native_fee_collector_community_pool" // QuerierRoute defines the module's query routing key QuerierRoute = ModuleName From f773225b5e332502fbf7c8e5bbb42629f44ac54d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 14 Aug 2023 10:57:31 -0500 Subject: [PATCH 04/83] fix a handfull of tests --- x/gamm/keeper/msg_server_test.go | 8 ++-- x/poolmanager/create_pool_test.go | 6 +-- x/poolmanager/export_test.go | 4 ++ x/poolmanager/keeper_test.go | 61 ++++++++++++++++++++++++--- x/poolmanager/router.go | 20 --------- x/poolmanager/router_test.go | 13 ++++-- x/protorev/keeper/posthandler_test.go | 2 +- x/txfees/keeper/hooks_test.go | 2 +- x/txfees/keeper/keeper_test.go | 14 ++++++ 9 files changed, 92 insertions(+), 38 deletions(-) diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index 110b141101f..ede314ee555 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -46,7 +46,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), expectedSwapEvents: 1, - expectedMessageEvents: 3, // 1 gamm + 2 events emitted by other keeper methods. + expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. }, "two hops": { routes: []poolmanagertypes.SwapAmountInRoute{ @@ -62,7 +62,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), expectedSwapEvents: 2, - expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. + expectedMessageEvents: 9, // 1 gamm + 8 events emitted by other keeper methods. }, "invalid - two hops, denom does not exist": { routes: []poolmanagertypes.SwapAmountInRoute{ @@ -145,7 +145,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), expectedSwapEvents: 1, - expectedMessageEvents: 3, // 1 gamm + 2 events emitted by other keeper methods. + expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. }, "two hops": { routes: []poolmanagertypes.SwapAmountOutRoute{ @@ -161,7 +161,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), expectedSwapEvents: 2, - expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. + expectedMessageEvents: 9, // 1 gamm + 8 events emitted by other keeper methods. }, "invalid - two hops, denom does not exist": { routes: []poolmanagertypes.SwapAmountOutRoute{ diff --git a/x/poolmanager/create_pool_test.go b/x/poolmanager/create_pool_test.go index d6f3073661c..6cd10d42d02 100644 --- a/x/poolmanager/create_pool_test.go +++ b/x/poolmanager/create_pool_test.go @@ -65,9 +65,9 @@ func (s *KeeperTestSuite) TestPoolCreationFee() { poolmanagerKeeper := s.App.PoolManagerKeeper // set pool creation fee - poolmanagerKeeper.SetParams(s.Ctx, types.Params{ - PoolCreationFee: test.poolCreationFee, - }) + newParams := params + newParams.PoolCreationFee = test.poolCreationFee + poolmanagerKeeper.SetParams(s.Ctx, newParams) // fund sender test account sender, err := sdk.AccAddressFromBech32(test.msg.Sender) diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index 3c45f22ab2e..9e9490eff3a 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -43,3 +43,7 @@ func (k Keeper) CreateMultihopExpectedSwapOuts( ) ([]sdk.Int, error) { return k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } + +func (k Keeper) DetermineTakerFee(ctx sdk.Context, pool types.PoolI, poolManagerParams types.Params) sdk.Dec { + return k.determineTakerFee(ctx, pool, poolManagerParams) +} diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index f6d0fad7ad6..259f2902ac9 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -18,8 +18,31 @@ type KeeperTestSuite struct { const testExpectedPoolId = 3 var ( - testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} - testPoolRoute = []types.ModuleRoute{ + testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} + testDefaultTakerFee = sdk.MustNewDecFromStr("0.0015") + testStableswapTakerFee = sdk.MustNewDecFromStr("0.0002") + testCustomPoolTakerFee = []types.CustomPoolTakerFee{ + { + PoolId: 1, + TakerFee: sdk.MustNewDecFromStr("0.0005"), + }, + { + PoolId: 2, + TakerFee: sdk.MustNewDecFromStr("0.0001"), + }, + } + testOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("0.3"), + CommunityPool: sdk.MustNewDecFromStr("0.7"), + } + testNonOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("0.2"), + CommunityPool: sdk.MustNewDecFromStr("0.8"), + } + testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} + testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" + + testPoolRoute = []types.ModuleRoute{ { PoolId: 1, PoolType: types.Balancer, @@ -68,21 +91,42 @@ func (s *KeeperTestSuite) createBalancerPoolsFromCoins(poolCoins []sdk.Coins) { func (s *KeeperTestSuite) TestInitGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ - PoolCreationFee: testPoolCreationFee, + PoolCreationFee: testPoolCreationFee, + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + CustomPoolTakerFee: testCustomPoolTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, }) + params := s.App.PoolManagerKeeper.GetParams(s.Ctx) s.Require().Equal(uint64(testExpectedPoolId), s.App.PoolManagerKeeper.GetNextPoolId(s.Ctx)) - s.Require().Equal(testPoolCreationFee, s.App.PoolManagerKeeper.GetParams(s.Ctx).PoolCreationFee) + s.Require().Equal(testPoolCreationFee, params.PoolCreationFee) + s.Require().Equal(testDefaultTakerFee, params.DefaultTakerFee) + s.Require().Equal(testStableswapTakerFee, params.StableswapTakerFee) + s.Require().Equal(testCustomPoolTakerFee, params.CustomPoolTakerFee) + s.Require().Equal(testOsmoTakerFeeDistribution, params.OsmoTakerFeeDistribution) + s.Require().Equal(testNonOsmoTakerFeeDistribution, params.NonOsmoTakerFeeDistribution) + s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) s.Require().Equal(testPoolRoute, s.App.PoolManagerKeeper.GetAllPoolRoutes(s.Ctx)) } func (s *KeeperTestSuite) TestExportGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ - PoolCreationFee: testPoolCreationFee, + PoolCreationFee: testPoolCreationFee, + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + CustomPoolTakerFee: testCustomPoolTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -91,5 +135,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { genesis := s.App.PoolManagerKeeper.ExportGenesis(s.Ctx) s.Require().Equal(uint64(testExpectedPoolId), genesis.NextPoolId) s.Require().Equal(testPoolCreationFee, genesis.Params.PoolCreationFee) + s.Require().Equal(testDefaultTakerFee, genesis.Params.DefaultTakerFee) + s.Require().Equal(testStableswapTakerFee, genesis.Params.StableswapTakerFee) + s.Require().Equal(testCustomPoolTakerFee, genesis.Params.CustomPoolTakerFee) + s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.OsmoTakerFeeDistribution) + s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.NonOsmoTakerFeeDistribution) + s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) + s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testPoolRoute, genesis.PoolRoutes) } diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 97bc65be304..7ecf18d93bb 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -31,12 +31,6 @@ func (k Keeper) RouteExactAmountIn( tokenIn sdk.Coin, tokenOutMinAmount sdk.Int, ) (tokenOutAmount sdk.Int, err error) { - var ( - isMultiHopRouted bool - routeSpreadFactor sdk.Dec - sumOfSpreadFactors sdk.Dec - ) - poolManagerParams := k.GetParams(ctx) // Ensure that provided route is not empty and has valid denom format. @@ -72,13 +66,6 @@ func (k Keeper) RouteExactAmountIn( } spreadFactor := pool.GetSpreadFactor(ctx) - - // If we determined the route is an osmo multi-hop and both routes are incentivized, - // we modify the spread factor accordingly. - if isMultiHopRouted { - spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) - } - takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) totalFees := spreadFactor.Add(takerFee) @@ -320,7 +307,6 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, tokenInMaxAmount sdk.Int, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { - isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountOutRoutes(route) if err := routeStep.Validate(); err != nil { @@ -377,12 +363,6 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } spreadFactor := pool.GetSpreadFactor(ctx) - // If we determined the routeStep is an osmo multi-hop and both route are incentivized, - // we modify the swap fee accordingly. - if isMultiHopRouted { - spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) - } - takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) totalFees := spreadFactor.Add(takerFee) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index ba3445b0bb9..15797410bc8 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1229,6 +1229,8 @@ func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(routes []types.SwapAmount func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() nextTokenIn := tokenIn + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + for _, hop := range routes { swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) @@ -1238,9 +1240,11 @@ func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmo // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := pool.GetSpreadFactor(cacheCtx) + takerFee := s.App.PoolManagerKeeper.DetermineTakerFee(cacheCtx, pool, poolManagerParams) + totalFee := spreadFactor.Add(takerFee) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFee) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1266,10 +1270,11 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { // - foo: 1000000000000 // - bar: 1000000000000 // - spreadFactor: 0.1% + // - takerFee: 0.15% // - foo in: 100000 // - bar amount out will be calculated according to the formula - // https://www.wolframalpha.com/input?i=solve+%2810%5E12+%2B+10%5E5+x+0.999%29%2810%5E12+-+x%29+%3D+10%5E24 - // We round down the token amount out, get the result is 99899 + // https://www.wolframalpha.com/input?i=solve+%2810%5E12+%2B+10%5E5+x+0.9975%29%2810%5E12+-+x%29+%3D+10%5E24 + // We round down the token amount out, get the result is 99749 { name: "Swap - [foo -> bar], 0.1 percent fee", poolId: 1, @@ -1278,7 +1283,7 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), tokenOutDenom: bar, - expectedTokenOutAmount: sdk.NewInt(99899), + expectedTokenOutAmount: sdk.NewInt(99749), }, { name: "Wrong pool id", diff --git a/x/protorev/keeper/posthandler_test.go b/x/protorev/keeper/posthandler_test.go index 784d7493a01..af750ff3a5a 100644 --- a/x/protorev/keeper/posthandler_test.go +++ b/x/protorev/keeper/posthandler_test.go @@ -438,7 +438,7 @@ func (s *KeeperTestSuite) TestAnteHandle() { // Check that the number of trades is correct numOfTrades, _ := s.App.ProtoRevKeeper.GetNumberOfTrades(s.Ctx) - s.Require().Equal(tc.params.expectedNumOfTrades, numOfTrades) + s.Require().Equal(tc.params.expectedNumOfTrades.String(), numOfTrades.String()) // Check that the profits are correct profits := s.App.ProtoRevKeeper.GetAllProfits(s.Ctx) diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index f584e71c573..5dc4577b492 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -112,7 +112,7 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { // non-osmos module account should be empty as all the funds should be transferred to osmo module s.Empty(s.App.BankKeeper.GetAllBalances(s.Ctx, moduleAddrNonNativeFee)) // check that the total osmo amount has been transferred to module account - s.Equal(moduleBaseDenomBalance.Amount, finalOutputAmount) + s.Equal(moduleBaseDenomBalance.Amount.String(), finalOutputAmount.String()) }) } } diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 46ef4e15164..03df022dae3 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -11,6 +11,7 @@ import ( osmosisapp "github.com/osmosis-labs/osmosis/v17/app" "github.com/osmosis-labs/osmosis/v17/app/apptesting" + protorevtypes "github.com/osmosis-labs/osmosis/v17/x/protorev/types" "github.com/osmosis-labs/osmosis/v17/x/txfees/types" ) @@ -36,6 +37,19 @@ func (s *KeeperTestSuite) SetupTest(isCheckTx bool) { WithLegacyAmino(encodingConfig.Amino). WithCodec(encodingConfig.Marshaler) + baseDenom, err := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) + s.Require().NoError(err) + + // Configure protorev base denoms + baseDenomPriorities := []protorevtypes.BaseDenom{ + { + Denom: baseDenom, + StepSize: sdk.NewInt(1_000_000), + }, + } + err = s.App.ProtoRevKeeper.SetBaseDenoms(s.Ctx, baseDenomPriorities) + s.Require().NoError(err) + // Mint some assets to the accounts. for _, acc := range s.TestAccs { s.FundAcc(acc, From 0e54b358ec41eb4768bd1e0309252445ff0cac66 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 14 Aug 2023 14:32:03 -0500 Subject: [PATCH 05/83] assign taker fee to pool at time of creation --- .../osmosis/concentrated-liquidity/pool.proto | 9 + .../pool-models/balancer/balancerPool.proto | 8 + .../stableswap/stableswap_pool.proto | 8 + .../osmosis/poolmanager/v1beta1/genesis.proto | 16 + x/concentrated-liquidity/keeper_test.go | 1 + x/concentrated-liquidity/model/msgs.go | 4 +- x/concentrated-liquidity/model/pool.go | 3 +- x/concentrated-liquidity/model/pool.pb.go | 138 ++++-- x/concentrated-liquidity/model/pool_test.go | 5 +- x/concentrated-liquidity/pool_test.go | 4 +- .../spread_rewards_test.go | 2 +- x/cosmwasmpool/model/msgs.go | 2 +- .../pool-models/balancer/balancerPool.pb.go | 163 +++--- x/gamm/pool-models/balancer/msgs.go | 3 +- x/gamm/pool-models/balancer/msgs_test.go | 3 +- x/gamm/pool-models/stableswap/msgs.go | 3 +- x/gamm/pool-models/stableswap/msgs_test.go | 3 +- .../stableswap/stableswap_pool.pb.go | 139 ++++-- x/poolmanager/create_pool.go | 74 ++- x/poolmanager/types/genesis.pb.go | 467 +++++++++++++++--- x/poolmanager/types/msg_create_pool.go | 2 +- 21 files changed, 842 insertions(+), 215 deletions(-) diff --git a/proto/osmosis/concentrated-liquidity/pool.proto b/proto/osmosis/concentrated-liquidity/pool.proto index 75709169fb2..612cca8cfe1 100644 --- a/proto/osmosis/concentrated-liquidity/pool.proto +++ b/proto/osmosis/concentrated-liquidity/pool.proto @@ -65,4 +65,13 @@ message Pool { (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_liquidity_update\"" ]; + + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + string taker_fee = 14 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; } \ No newline at end of file diff --git a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto index 1bfd1cad28a..d7cbec4322b 100644 --- a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto +++ b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto @@ -94,6 +94,14 @@ message PoolParams { (gogoproto.moretags) = "yaml:\"smooth_weight_change_params\"", (gogoproto.nullable) = true ]; + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + string taker_fee = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; } // Pool asset is an internal struct that combines the amount of the diff --git a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto index ab2d73db20e..13c17c657d5 100644 --- a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto +++ b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto @@ -33,6 +33,14 @@ message PoolParams { (gogoproto.moretags) = "yaml:\"exit_fee\"", (gogoproto.nullable) = false ]; + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + string taker_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; } // Pool is the stableswap Pool struct diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index a020645c2e3..218c834d0db 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -55,6 +55,15 @@ message Params { string community_pool_denom_to_swap_non_whitelisted_assets_to = 8 [ (gogoproto.moretags) = "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; + // stablecoin_denoms is a list of denoms that are considered stablecoins. + // This is used to determine if a pool should use the stableswap taker + // fee.bool LSTs are NOT apart of this catagory, even though they are eligible + // for stableswap taker fees. This is determined via the + // liquid_stake_denom_pairings field. + repeated string stablecoin_denoms = 9 + [ (gogoproto.moretags) = "yaml:\"stablecoin_denoms\"" ]; + repeated LiquidStakedTokenToUnderlyingDenom liquid_stake_denom_pairings = 10 + [ (gogoproto.moretags) = "yaml:\"liquid_stake_denom_pairings\"" ]; } // GenesisState defines the poolmanager module's genesis state. @@ -90,4 +99,11 @@ message TakerFeeDistributionPercentage { (gogoproto.moretags) = "yaml:\"community_pool\"", (gogoproto.nullable) = false ]; +} + +message LiquidStakedTokenToUnderlyingDenom { + repeated string liquid_staked_token_denoms = 1 + [ (gogoproto.moretags) = "yaml:\"liquid_staked_token_denoms\"" ]; + string underlying_token_denom = 2 + [ (gogoproto.moretags) = "yaml:\"underlying_token_denom\"" ]; } \ No newline at end of file diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index b43cb85a5a0..710abddf118 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -59,6 +59,7 @@ var ( FullRangeLiquidityAmt = sdk.MustNewDecFromStr("70710678.118654752941000000") DefaultTickSpacing = uint64(100) + DefaultTakerFee = sdk.MustNewDecFromStr("0.0015") PoolCreationFee = poolmanagertypes.DefaultParams().PoolCreationFee sqrt4000 = sdk.MustNewDecFromStr("63.245553203367586640") sqrt4994 = sdk.MustNewDecFromStr("70.668238976219012614") diff --git a/x/concentrated-liquidity/model/msgs.go b/x/concentrated-liquidity/model/msgs.go index 0c66a4f3b66..1ef565d884a 100644 --- a/x/concentrated-liquidity/model/msgs.go +++ b/x/concentrated-liquidity/model/msgs.go @@ -97,8 +97,8 @@ func (msg MsgCreateConcentratedPool) InitialLiquidity() sdk.Coins { return sdk.Coins{} } -func (msg MsgCreateConcentratedPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { - poolI, err := NewConcentratedLiquidityPool(poolID, msg.Denom0, msg.Denom1, msg.TickSpacing, msg.SpreadFactor) +func (msg MsgCreateConcentratedPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { + poolI, err := NewConcentratedLiquidityPool(poolID, msg.Denom0, msg.Denom1, msg.TickSpacing, msg.SpreadFactor, takerFee) return &poolI, err } diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index 8d0d825b26e..fe9049bb2f9 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -26,7 +26,7 @@ var ( // NewConcentratedLiquidityPool creates a new ConcentratedLiquidity pool with the specified parameters. // The two provided denoms are ordered so that denom0 is lexicographically smaller than denom1. -func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpacing uint64, spreadFactor sdk.Dec) (Pool, error) { +func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpacing uint64, spreadFactor, takerFee sdk.Dec) (Pool, error) { // Ensure that the two denoms are different if denom0 == denom1 { return Pool{}, types.MatchingDenomError{Denom: denom0} @@ -51,6 +51,7 @@ func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpac TickSpacing: tickSpacing, ExponentAtPriceOne: types.ExponentAtPriceOne, SpreadFactor: spreadFactor, + TakerFee: takerFee, } return pool, nil } diff --git a/x/concentrated-liquidity/model/pool.pb.go b/x/concentrated-liquidity/model/pool.pb.go index dfd1bbf9ad2..21356ba577f 100644 --- a/x/concentrated-liquidity/model/pool.pb.go +++ b/x/concentrated-liquidity/model/pool.pb.go @@ -58,6 +58,10 @@ type Pool struct { // last_liquidity_update is the last time either the pool liquidity or the // active tick changed LastLiquidityUpdate time.Time `protobuf:"bytes,13,opt,name=last_liquidity_update,json=lastLiquidityUpdate,proto3,stdtime" json:"last_liquidity_update" yaml:"last_liquidity_update"` + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *Pool) Reset() { *m = Pool{} } @@ -101,49 +105,51 @@ func init() { } var fileDescriptor_3526ea5373d96c9a = []byte{ - // 659 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6b, 0xd4, 0x40, - 0x14, 0xdf, 0xf4, 0xaf, 0x9d, 0x6d, 0x8b, 0x9d, 0x6e, 0x6b, 0x5a, 0xec, 0x66, 0x0d, 0x28, 0x2b, - 0xb8, 0x89, 0xab, 0x07, 0xa1, 0xb7, 0x2e, 0x52, 0x10, 0x0a, 0x2d, 0x69, 0x45, 0x10, 0x21, 0xcc, - 0x26, 0xd3, 0x74, 0xd8, 0x24, 0x93, 0x66, 0x66, 0x6b, 0xeb, 0x5d, 0xf0, 0xd8, 0xa3, 0xc7, 0x7e, - 0x08, 0x3f, 0x44, 0xf1, 0xd4, 0xa3, 0x78, 0x88, 0xd2, 0x82, 0x1f, 0x60, 0x3f, 0x81, 0x64, 0x66, - 0xb2, 0x1b, 0xe9, 0x8a, 0x78, 0xca, 0xbe, 0xdf, 0xfb, 0xbd, 0xdf, 0xfc, 0xde, 0x9b, 0x37, 0x0b, - 0x1e, 0x53, 0x16, 0x51, 0x46, 0x98, 0xed, 0xd1, 0xd8, 0xc3, 0x31, 0x4f, 0x11, 0xc7, 0x7e, 0x2b, - 0x24, 0xc7, 0x7d, 0xe2, 0x13, 0x7e, 0x66, 0x27, 0x94, 0x86, 0x56, 0x92, 0x52, 0x4e, 0xe1, 0x43, - 0x45, 0xb5, 0xca, 0xd4, 0x21, 0xd3, 0x3a, 0x69, 0x77, 0x31, 0x47, 0xed, 0xf5, 0x35, 0x4f, 0xf0, - 0x5c, 0x51, 0x64, 0xcb, 0x40, 0x2a, 0xac, 0xd7, 0x02, 0x1a, 0x50, 0x89, 0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63, 0x1d, 0xa5, 0x98, 0xe9, 0xcc, 0xcb, - 0x78, 0x5b, 0x84, 0xf0, 0x14, 0xac, 0x84, 0x88, 0xf1, 0xd1, 0x3a, 0xb8, 0xfd, 0xc4, 0x47, 0x1c, - 0xeb, 0x0b, 0x0d, 0xad, 0x59, 0x7d, 0xb6, 0x6e, 0xc9, 0xc7, 0x69, 0x15, 0x8f, 0xd3, 0x3a, 0x28, - 0x1e, 0x67, 0xa7, 0x99, 0x1b, 0x1a, 0x75, 0x38, 0x56, 0xc6, 0x3c, 0xff, 0x61, 0x68, 0xce, 0x72, - 0x9e, 0x1b, 0x6e, 0xd6, 0x6b, 0x91, 0xd9, 0x5c, 0xfa, 0x74, 0x61, 0x54, 0x3e, 0x5f, 0x18, 0x95, - 0xaf, 0x5f, 0x5a, 0xd3, 0xf9, 0xf3, 0x7e, 0xd5, 0x79, 0x77, 0x79, 0x5d, 0xd7, 0xae, 0xae, 0xeb, - 0xda, 0xcf, 0xeb, 0xba, 0x76, 0x7e, 0x53, 0xaf, 0x5c, 0xdd, 0xd4, 0x2b, 0xdf, 0x6e, 0xea, 0x95, - 0xb7, 0x9d, 0x7f, 0x2d, 0xce, 0x49, 0xfb, 0x85, 0x7d, 0xfa, 0xb7, 0x3f, 0xb1, 0x88, 0xfa, 0x38, - 0xec, 0xce, 0x88, 0x1e, 0x9e, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xac, 0x29, 0xa9, 0xf3, - 0x04, 0x00, 0x00, + // 690 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x4e, 0xdb, 0x4a, + 0x14, 0x8e, 0xf9, 0x67, 0x02, 0x08, 0x86, 0xc0, 0x35, 0xe8, 0x12, 0xe7, 0x5a, 0xba, 0x57, 0xb9, + 0x52, 0x63, 0x37, 0xed, 0xa2, 0x12, 0x3b, 0xa2, 0x0a, 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 0x49, 0xbc, + 0x63, 0x42, 0xcc, 0x25, 0xd9, 0x62, 0xeb, 0xc1, 0x2d, 0x2e, 0xeb, 0x4f, 0x94, 0x0b, 0xd9, 0x68, + 0x4e, 0xbe, 0xef, 0x12, 0xb2, 0xbd, 0xf2, 0xe1, 0xca, 0x2a, 0x7d, 0xbc, 0xb2, 0x4a, 0x5f, 0x3e, + 0x35, 0xa6, 0xb3, 0xff, 0xc7, 0x8b, 0xd6, 0x9b, 0xeb, 0xdb, 0xaa, 0x71, 0x73, 0x5b, 0x35, 0x7e, + 0xdc, 0x56, 0x8d, 0xcb, 0xbb, 0x6a, 0xe9, 0xe6, 0xae, 0x5a, 0xfa, 0x7a, 0x57, 0x2d, 0xbd, 0x6e, + 0xfd, 0x69, 0x33, 0xcf, 0x9a, 0xcf, 0xdc, 0xf3, 0xdf, 0xfd, 0x25, 0x7b, 0x2c, 0x20, 0x61, 0x7b, + 0x46, 0x0e, 0xe9, 0xe9, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0x66, 0x26, 0xed, 0x54, 0x05, + 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -166,6 +172,16 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x72 n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastLiquidityUpdate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastLiquidityUpdate):]) if err1 != nil { return 0, err1 @@ -319,6 +335,8 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovPool(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastLiquidityUpdate) n += 1 + l + sovPool(uint64(l)) + l = m.TakerFee.Size() + n += 1 + l + sovPool(uint64(l)) return n } @@ -728,6 +746,40 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 14: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPool(dAtA[iNdEx:]) diff --git a/x/concentrated-liquidity/model/pool_test.go b/x/concentrated-liquidity/model/pool_test.go index 1bbab8baf51..6119df7d1f7 100644 --- a/x/concentrated-liquidity/model/pool_test.go +++ b/x/concentrated-liquidity/model/pool_test.go @@ -41,6 +41,7 @@ var ( }() // 70.710678118654752440 DefaultSpreadFactor = sdk.MustNewDecFromStr("0.01") + DefaultTakerFee = sdk.MustNewDecFromStr("0.0015") ) type ConcentratedPoolTestSuite struct { @@ -138,7 +139,7 @@ func (s *ConcentratedPoolTestSuite) TestGetIncentivesAddress() { func (s *ConcentratedPoolTestSuite) TestString() { s.Setup() - pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor) + pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor, DefaultTakerFee) s.Require().NoError(err) poolString := pool.String() s.Require().Equal(poolString, "{\"address\":\"osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7\",\"incentives_address\":\"osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf\",\"spread_rewards_address\":\"osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv\",\"id\":1,\"current_tick_liquidity\":\"0.000000000000000000\",\"token0\":\"foo\",\"token1\":\"bar\",\"current_sqrt_price\":\"0.000000000000000000000000000000000000\",\"tick_spacing\":1,\"exponent_at_price_one\":-6,\"spread_factor\":\"0.010000000000000000\",\"last_liquidity_update\":\"0001-01-01T00:00:00Z\"}") @@ -543,7 +544,7 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { s.Setup() // Call NewConcentratedLiquidityPool with the parameters from the current test. - pool, err := model.NewConcentratedLiquidityPool(test.param.poolId, test.param.denom0, test.param.denom1, test.param.tickSpacing, test.param.spreadFactor) + pool, err := model.NewConcentratedLiquidityPool(test.param.poolId, test.param.denom0, test.param.denom1, test.param.tickSpacing, test.param.spreadFactor, DefaultTakerFee) if test.expectedErr != nil { // If the test is expected to produce an error, check if it does. diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index 365a88655b5..f5912a225e4 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -25,12 +25,12 @@ func (s *KeeperTestSuite) TestInitializePool() { // Create a concentrated liquidity pool with unauthorized tick spacing invalidTickSpacing := uint64(25) - invalidTickSpacingConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(2, ETH, USDC, invalidTickSpacing, DefaultZeroSpreadFactor) + invalidTickSpacingConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(2, ETH, USDC, invalidTickSpacing, DefaultZeroSpreadFactor, DefaultTakerFee) s.Require().NoError(err) // Create a concentrated liquidity pool with unauthorized spread factor invalidSpreadFactor := sdk.MustNewDecFromStr("0.1") - invalidSpreadFactorConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(3, ETH, USDC, DefaultTickSpacing, invalidSpreadFactor) + invalidSpreadFactorConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(3, ETH, USDC, DefaultTickSpacing, invalidSpreadFactor, DefaultTakerFee) s.Require().NoError(err) // Create an invalid PoolI that doesn't implement ConcentratedPoolExtension diff --git a/x/concentrated-liquidity/spread_rewards_test.go b/x/concentrated-liquidity/spread_rewards_test.go index de29d2af471..c3c5996c599 100644 --- a/x/concentrated-liquidity/spread_rewards_test.go +++ b/x/concentrated-liquidity/spread_rewards_test.go @@ -487,7 +487,7 @@ func (s *KeeperTestSuite) TestCalculateSpreadRewardGrowth() { // Test what happens if somehow the accumulator didn't exist. // TODO: Does this test even matter? We should never be in a situation where the accumulator doesn't exist func (s *KeeperTestSuite) TestGetInitialSpreadRewardGrowthOppositeDirectionOfLastTraversalForTickAccumDoesntExist() { - pool, err := clmodel.NewConcentratedLiquidityPool(validPoolId, ETH, USDC, DefaultTickSpacing, DefaultZeroSpreadFactor) + pool, err := clmodel.NewConcentratedLiquidityPool(validPoolId, ETH, USDC, DefaultTickSpacing, DefaultZeroSpreadFactor, DefaultTakerFee) s.Require().NoError(err) // N.B.: we set the listener mock because we would like to avoid diff --git a/x/cosmwasmpool/model/msgs.go b/x/cosmwasmpool/model/msgs.go index c8d8941b79c..86cb43e6326 100644 --- a/x/cosmwasmpool/model/msgs.go +++ b/x/cosmwasmpool/model/msgs.go @@ -78,7 +78,7 @@ func (msg MsgCreateCosmWasmPool) InitialLiquidity() sdk.Coins { return sdk.Coins{} } -func (msg MsgCreateCosmWasmPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { +func (msg MsgCreateCosmWasmPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg) return poolI, nil } diff --git a/x/gamm/pool-models/balancer/balancerPool.pb.go b/x/gamm/pool-models/balancer/balancerPool.pb.go index cc37401dbb6..44f5cebe3e7 100644 --- a/x/gamm/pool-models/balancer/balancerPool.pb.go +++ b/x/gamm/pool-models/balancer/balancerPool.pb.go @@ -141,6 +141,10 @@ type PoolParams struct { // fee anymore ExitFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exit_fee" yaml:"exit_fee"` SmoothWeightChangeParams *SmoothWeightChangeParams `protobuf:"bytes,3,opt,name=smooth_weight_change_params,json=smoothWeightChangeParams,proto3" json:"smooth_weight_change_params,omitempty" yaml:"smooth_weight_change_params"` + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -302,62 +306,63 @@ func init() { } var fileDescriptor_7e991f749f68c2a4 = []byte{ - // 867 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x8b, 0xdb, 0x46, - 0x14, 0xb7, 0xd6, 0xde, 0x75, 0x76, 0x9c, 0xa6, 0xec, 0xc4, 0x07, 0xd9, 0x4b, 0x3d, 0xcb, 0xb4, - 0x94, 0x10, 0x62, 0x09, 0xa7, 0x85, 0xc2, 0x5e, 0x42, 0x94, 0xa4, 0x25, 0xb7, 0x54, 0x29, 0xa4, - 0x29, 0x01, 0x31, 0xb6, 0xc7, 0x92, 0x88, 0xa4, 0x11, 0x9a, 0xb1, 0x93, 0xfd, 0x06, 0x25, 0xa7, - 0x1c, 0xd3, 0x5b, 0xee, 0xbd, 0xf4, 0xd0, 0x0f, 0xb1, 0xb4, 0x97, 0x40, 0x2f, 0xa5, 0x07, 0xb5, - 0xec, 0x1e, 0x0a, 0x3d, 0xfa, 0x13, 0x94, 0xf9, 0x23, 0xff, 0xd9, 0xda, 0x34, 0x21, 0x17, 0x7b, - 0xe6, 0xcd, 0x7b, 0xbf, 0xf7, 0x7b, 0xef, 0xfd, 0x66, 0x04, 0x3e, 0x67, 0x3c, 0x65, 0x3c, 0xe6, - 0x6e, 0x48, 0xd2, 0xd4, 0xcd, 0x19, 0x4b, 0xfa, 0x29, 0x1b, 0xd3, 0x84, 0xbb, 0x43, 0x92, 0x90, - 0x6c, 0x44, 0x8b, 0xc5, 0xe2, 0x01, 0x63, 0x89, 0x93, 0x17, 0x4c, 0x30, 0xd8, 0x36, 0x51, 0x8e, - 0x8c, 0x72, 0x66, 0x83, 0x21, 0x15, 0x64, 0xd0, 0xed, 0x8c, 0x94, 0x39, 0x50, 0x3e, 0xae, 0xde, - 0xe8, 0x80, 0x6e, 0x3b, 0x64, 0x21, 0xd3, 0x76, 0xb9, 0x32, 0xd6, 0x03, 0x92, 0xc6, 0x19, 0x73, - 0xd5, 0xaf, 0x31, 0xf5, 0x42, 0xc6, 0xc2, 0x84, 0xba, 0x6a, 0x37, 0x9c, 0x4e, 0xdc, 0xf1, 0xb4, - 0x20, 0x22, 0x66, 0x99, 0x39, 0x47, 0x17, 0xcf, 0x45, 0x9c, 0x52, 0x2e, 0x48, 0x9a, 0x57, 0x00, - 0x3a, 0xaf, 0x4b, 0xa6, 0x22, 0x72, 0x0d, 0x33, 0xb5, 0xb9, 0x70, 0x3e, 0x24, 0x9c, 0x2e, 0xce, - 0x47, 0x2c, 0x36, 0x09, 0xf0, 0xaf, 0x75, 0x60, 0x3f, 0x4c, 0x19, 0x13, 0xd1, 0x23, 0x1a, 0x87, - 0x91, 0xb8, 0x13, 0x91, 0x2c, 0xa4, 0x0f, 0x48, 0x41, 0x52, 0x0e, 0xbf, 0x05, 0x80, 0x0b, 0x52, - 0x88, 0x40, 0x66, 0xb5, 0xad, 0x23, 0xeb, 0x5a, 0xeb,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x59, 0x6f, 0xce, 0x7a, 0xd6, 0x5f, 0x67, 0x3d, 0xeb, - 0xe5, 0x79, 0xaf, 0xf6, 0xe6, 0xbc, 0x57, 0xfb, 0xfd, 0xbc, 0x57, 0xfb, 0xee, 0xd6, 0x0a, 0x2d, - 0x13, 0xdf, 0x4f, 0xc8, 0x90, 0x57, 0x1b, 0x77, 0x36, 0xf8, 0xc2, 0x7d, 0xbe, 0xfd, 0x3b, 0x3d, - 0xdc, 0x53, 0x1f, 0x8a, 0xcf, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x23, 0xc0, 0x18, 0x39, 0xd3, - 0x07, 0x00, 0x00, + // 893 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0xc6, 0xce, 0xbf, 0x49, 0x29, 0x64, 0xea, 0x83, 0xe3, 0x08, 0x4f, 0x34, 0x20, 0x54, + 0x55, 0xcd, 0xae, 0x52, 0x90, 0x90, 0x72, 0xa9, 0xba, 0xfd, 0x83, 0x7a, 0x2b, 0x5b, 0xa4, 0x52, + 0x54, 0x69, 0x35, 0xb6, 0x27, 0xbb, 0xab, 0xec, 0xee, 0xac, 0x76, 0xc6, 0x69, 0xf3, 0x0d, 0x10, + 0xa7, 0x1e, 0xcb, 0xad, 0x77, 0x2e, 0x1c, 0xf8, 0x10, 0x11, 0x5c, 0x2a, 0x71, 0x41, 0x1c, 0x16, + 0x94, 0x1c, 0x90, 0xe0, 0xe6, 0x4f, 0x80, 0x66, 0xe6, 0xad, 0xed, 0x04, 0x5b, 0x34, 0xea, 0xc5, + 0x9e, 0xf7, 0xe6, 0xbd, 0xdf, 0xfb, 0xf7, 0x7b, 0x63, 0xa3, 0xcf, 0x84, 0xcc, 0x84, 0x4c, 0xa4, + 0x17, 0xb1, 0x2c, 0xf3, 0x0a, 0x21, 0xd2, 0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x3b, 0xeb, 0x35, 0xbe, 0xb9, 0x3d, 0x93, 0x16, 0xf8, 0xef, 0xa6, 0xac, 0x2f, 0x6b, 0xc1, + 0x3b, 0xda, 0xfb, 0xdc, 0x7b, 0xb1, 0xf8, 0x8f, 0x40, 0x7f, 0xc5, 0xfc, 0x12, 0x7d, 0xfa, 0x6f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x14, 0x38, 0x13, 0x34, 0x08, 0x00, 0x00, } func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error) { @@ -447,6 +452,16 @@ func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintBalancerPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 if m.SmoothWeightChangeParams != nil { { size, err := m.SmoothWeightChangeParams.MarshalToSizedBuffer(dAtA[:i]) @@ -661,6 +676,8 @@ func (m *PoolParams) Size() (n int) { l = m.SmoothWeightChangeParams.Size() n += 1 + l + sovBalancerPool(uint64(l)) } + l = m.TakerFee.Size() + n += 1 + l + sovBalancerPool(uint64(l)) return n } @@ -1032,6 +1049,40 @@ func (m *PoolParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBalancerPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthBalancerPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBalancerPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBalancerPool(dAtA[iNdEx:]) diff --git a/x/gamm/pool-models/balancer/msgs.go b/x/gamm/pool-models/balancer/msgs.go index 4209751cb27..8fc211ec54f 100644 --- a/x/gamm/pool-models/balancer/msgs.go +++ b/x/gamm/pool-models/balancer/msgs.go @@ -96,7 +96,8 @@ func (msg MsgCreateBalancerPool) InitialLiquidity() sdk.Coins { return coins } -func (msg MsgCreateBalancerPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { +func (msg MsgCreateBalancerPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { + msg.PoolParams.TakerFee = takerFee poolI, err := NewBalancerPool(poolID, *msg.PoolParams, msg.PoolAssets, msg.FuturePoolGovernor, ctx.BlockTime()) return &poolI, err } diff --git a/x/gamm/pool-models/balancer/msgs_test.go b/x/gamm/pool-models/balancer/msgs_test.go index 22b60bf2681..7a11e6e1114 100644 --- a/x/gamm/pool-models/balancer/msgs_test.go +++ b/x/gamm/pool-models/balancer/msgs_test.go @@ -243,6 +243,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { } func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { + defaultTakerFee := sdk.MustNewDecFromStr("0.0015") tests := map[string]struct { msg balancer.MsgCreateBalancerPool poolId uint64 @@ -271,7 +272,7 @@ func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { for name, tc := range tests { s.Run(name, func() { - pool, err := tc.msg.CreatePool(s.Ctx, 1) + pool, err := tc.msg.CreatePool(s.Ctx, 1, defaultTakerFee) if tc.expectError { s.Require().Error(err) diff --git a/x/gamm/pool-models/stableswap/msgs.go b/x/gamm/pool-models/stableswap/msgs.go index 8be5ca20dbc..116030e1527 100644 --- a/x/gamm/pool-models/stableswap/msgs.go +++ b/x/gamm/pool-models/stableswap/msgs.go @@ -110,7 +110,8 @@ func (msg MsgCreateStableswapPool) InitialLiquidity() sdk.Coins { return msg.InitialPoolLiquidity } -func (msg MsgCreateStableswapPool) CreatePool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error) { +func (msg MsgCreateStableswapPool) CreatePool(ctx sdk.Context, poolId uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { + msg.PoolParams.TakerFee = takerFee stableswapPool, err := NewStableswapPool(poolId, *msg.PoolParams, msg.InitialPoolLiquidity, msg.ScalingFactors, msg.ScalingFactorController, msg.FuturePoolGovernor) if err != nil { diff --git a/x/gamm/pool-models/stableswap/msgs_test.go b/x/gamm/pool-models/stableswap/msgs_test.go index f8626866ce3..24ead9fd5bd 100644 --- a/x/gamm/pool-models/stableswap/msgs_test.go +++ b/x/gamm/pool-models/stableswap/msgs_test.go @@ -298,6 +298,7 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { func (suite *TestSuite) TestMsgCreateStableswapPool() { suite.SetupTest() + defaultTakerFee := sdk.MustNewDecFromStr("0.0015") var ( validParams = &stableswap.PoolParams{SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.ZeroDec()} @@ -338,7 +339,7 @@ func (suite *TestSuite) TestMsgCreateStableswapPool() { for name, tc := range tests { suite.Run(name, func() { - pool, err := tc.msg.CreatePool(suite.Ctx, 1) + pool, err := tc.msg.CreatePool(suite.Ctx, 1, defaultTakerFee) if tc.expectError { suite.Require().Error(err) diff --git a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go index 7c94c3c27c0..806fad93622 100644 --- a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go +++ b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go @@ -39,6 +39,10 @@ type PoolParams struct { // pools can maintain a non-zero fee. No new pool can be created with non-zero // fee anymore ExitFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exit_fee" yaml:"exit_fee"` + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -140,50 +144,51 @@ func init() { } var fileDescriptor_ae0f054436f9999a = []byte{ - // 676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xbf, 0x6f, 0xd3, 0x4c, - 0x18, 0x8e, 0xdb, 0xb4, 0xe9, 0x77, 0xfd, 0xbe, 0x54, 0x9f, 0xa9, 0x84, 0xdb, 0x0a, 0x5f, 0x6a, - 0xd1, 0x2a, 0xaa, 0x88, 0x4d, 0x40, 0x02, 0xd1, 0xad, 0x29, 0x2a, 0x42, 0x42, 0xa8, 0xb8, 0x13, - 0x3f, 0xa4, 0x70, 0xb6, 0x2f, 0xee, 0x09, 0x3b, 0x67, 0x7c, 0xe7, 0xd2, 0x2e, 0xcc, 0x88, 0x89, - 0x91, 0xb1, 0x33, 0x13, 0x03, 0x7f, 0x44, 0x05, 0x4b, 0x47, 0xc4, 0x60, 0x50, 0x3b, 0xb0, 0xa2, - 0xfc, 0x05, 0xe8, 0xce, 0x97, 0xa4, 0x29, 0x50, 0x55, 0x62, 0x49, 0xee, 0x7d, 0xdf, 0xe7, 0x7d, - 0xde, 0x5f, 0x8f, 0x0c, 0x6e, 0x51, 0x16, 0x53, 0x46, 0x98, 0x13, 0xa2, 0x38, 0x76, 0x12, 0x4a, - 0xa3, 0x46, 0x4c, 0x03, 0x1c, 0x31, 0x87, 0x71, 0xe4, 0x45, 0x98, 0xbd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xff, 0x67, 0x8c, 0xb0, 0xa0, - 0x52, 0x05, 0x00, 0x00, + // 699 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcf, 0x4f, 0x13, 0x4d, + 0x18, 0xc7, 0xdb, 0x52, 0x28, 0x0c, 0xef, 0x5b, 0xde, 0x77, 0x25, 0xb1, 0x40, 0xdc, 0x2d, 0x1b, + 0x21, 0x84, 0xd8, 0x5d, 0xab, 0x89, 0x46, 0x6e, 0x14, 0x83, 0x31, 0x31, 0x06, 0x97, 0x93, 0x3f, + 0x92, 0x75, 0x76, 0x77, 0xba, 0x4c, 0xd8, 0xed, 0xac, 0x33, 0xb3, 0x08, 0x17, 0xcf, 0xc6, 0x93, + 0x47, 0x8f, 0x9c, 0x3d, 0x79, 0xf0, 0x8f, 0x20, 0x7a, 0xc1, 0x9b, 0xf1, 0xb0, 0x1a, 0x38, 0x78, + 0xef, 0x5f, 0x60, 0x66, 0x76, 0xda, 0x52, 0x54, 0x82, 0xf1, 0x02, 0xf3, 0xfc, 0xfa, 0x3c, 0xcf, + 0x3c, 0xf3, 0xed, 0x82, 0x5b, 0x84, 0xc5, 0x84, 0x61, 0x66, 0x87, 0x30, 0x8e, 0xed, 0x84, 0x90, + 0xa8, 0x11, 0x93, 0x00, 0x45, 0xcc, 0x66, 0x1c, 0x7a, 0x11, 0x62, 0xcf, 0x61, 0x72, 0xe2, 0xe8, + 0x8a, 0x0c, 0x2b, 0xa1, 0x84, 0x13, 0x6d, 0x59, 0x95, 0x5a, 0xa2, 0xd4, 0x12, 0x81, 0xbc, 0xd2, + 0x1a, 0xa4, 0x5b, 0x3b, 0x4d, 0x0f, 0x71, 0xd8, 0x9c, 0x9d, 0xf1, 0x65, 0xb2, 0x2b, 0x2b, 0xed, + 0xdc, 0xc8, 0x31, 0xb3, 0xd3, 0x21, 0x09, 0x49, 0xee, 0x17, 0x27, 0xe5, 0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b, 0x34, 0x3f, 0x8e, 0x82, 0xb2, 0x30, 0xb5, 0x2b, 0xa0, 0x02, 0x83, 0x80, 0x22, + 0xc6, 0xd4, 0x32, 0xb5, 0x6e, 0x66, 0x54, 0xf3, 0x0e, 0x2a, 0x60, 0x3a, 0xbd, 0x14, 0xad, 0x0a, + 0x4a, 0x38, 0x90, 0x7b, 0x29, 0x3b, 0x25, 0x1c, 0x68, 0x2f, 0xc0, 0xa4, 0x10, 0xa0, 0x9b, 0x48, + 0xaa, 0xbc, 0xd1, 0xe4, 0xb5, 0x1b, 0xd6, 0xf9, 0x15, 0x6a, 0x0d, 0x66, 0x6a, 0x2d, 0x88, 0x4d, + 0x74, 0x33, 0xe3, 0x92, 0x7a, 0x9c, 0x61, 0xf5, 0xab, 0x1e, 0xa6, 0x03, 0x92, 0x81, 0x16, 0x1e, + 0x80, 0xe9, 0x76, 0xca, 0x53, 0x8a, 0xf2, 0x94, 0x90, 0xec, 0x20, 0xda, 0x21, 0xb4, 0x56, 0x96, + 0x57, 0x31, 0xba, 0x99, 0x31, 0x97, 0xc3, 0x7e, 0x95, 0x65, 0x3a, 0x5a, 0xee, 0x16, 0x33, 0xdc, + 0x51, 0x4e, 0xed, 0x21, 0xf8, 0x87, 0x13, 0x0e, 0x23, 0x97, 0x6d, 0x41, 0x8a, 0x58, 0x6d, 0x54, + 0xde, 0x69, 0xc6, 0x52, 0x3f, 0x1e, 0x21, 0xd2, 0xfe, 0xf0, 0x6b, 0x04, 0x77, 0x5a, 0x73, 0x6a, + 0xec, 0x0b, 0xea, 0x59, 0x4e, 0x14, 0x9b, 0xce, 0xa4, 0x34, 0x37, 0xa5, 0xa5, 0x51, 0x50, 0x95, + 0x03, 0x44, 0xf8, 0x59, 0x8a, 0x03, 0xcc, 0xf7, 0x6a, 0x63, 0xf5, 0x91, 0xb3, 0xe1, 0x57, 0x05, + 0xfc, 0xed, 0x57, 0x63, 0xe9, 0x1c, 0xea, 0x10, 0x05, 0xcc, 0xf9, 0x57, 0xb4, 0xb8, 0xd7, 0xeb, + 0xa0, 0xdd, 0x07, 0x53, 0xcc, 0x87, 0x11, 0xee, 0x84, 0x6e, 0x1b, 0xfa, 0x9c, 0x50, 0x56, 0xab, + 0xd4, 0x47, 0x96, 0xca, 0xad, 0x85, 0x6e, 0x66, 0xcc, 0xff, 0xb4, 0xe9, 0x53, 0xb9, 0xa6, 0x53, + 0x55, 0x9e, 0xf5, 0xdc, 0xa1, 0x3d, 0x05, 0x33, 0xc3, 0x39, 0xae, 0x4f, 0x3a, 0x9c, 0x92, 0x28, + 0x42, 0xb4, 0x36, 0x2e, 0xd7, 0x7e, 0xb9, 0x9b, 0x19, 0x75, 0x45, 0xfe, 0x5d, 0xaa, 0xe9, 0x5c, + 0x1c, 0x02, 0xaf, 0xf5, 0x23, 0x2b, 0xcd, 0x97, 0xfb, 0x46, 0xe1, 0xcd, 0xbe, 0x51, 0xf8, 0xf0, + 0xbe, 0x31, 0x2a, 0x9e, 0xe6, 0xae, 0xd0, 0xf4, 0xdc, 0x19, 0x9a, 0x6e, 0x3d, 0x3e, 0x38, 0xd2, + 0x8b, 0x87, 0x47, 0x7a, 0xf1, 0xdb, 0x91, 0x5e, 0x7c, 0x7d, 0xac, 0x17, 0x0e, 0x8f, 0xf5, 0xc2, + 0xe7, 0x63, 0xbd, 0xf0, 0x68, 0xf5, 0xc4, 0xde, 0x14, 0xa1, 0x11, 0x41, 0x8f, 0xf5, 0x0c, 0x7b, + 0xa7, 0x79, 0xd3, 0xde, 0x3d, 0xeb, 0x2b, 0xec, 0x8d, 0xc9, 0xaf, 0xd0, 0xf5, 0x1f, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x30, 0x84, 0xb8, 0x90, 0xb3, 0x05, 0x00, 0x00, } func (m *PoolParams) Marshal() (dAtA []byte, err error) { @@ -206,6 +211,16 @@ func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintStableswapPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a { size := m.ExitFee.Size() i -= size @@ -351,6 +366,8 @@ func (m *PoolParams) Size() (n int) { n += 1 + l + sovStableswapPool(uint64(l)) l = m.ExitFee.Size() n += 1 + l + sovStableswapPool(uint64(l)) + l = m.TakerFee.Size() + n += 1 + l + sovStableswapPool(uint64(l)) return n } @@ -498,6 +515,40 @@ func (m *PoolParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStableswapPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStableswapPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStableswapPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStableswapPool(dAtA[iNdEx:]) diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 49a6159284a..7d70b7dbd50 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -105,14 +105,20 @@ func (k Keeper) createPoolZeroLiquidityNoCreationFee(ctx sdk.Context, msg types. // Get the next pool ID and increment the pool ID counter. poolId := k.getNextPoolIdAndIncrement(ctx) + poolAssets := msg.InitialLiquidity() + poolType := msg.GetPoolType() + poolManagerParams := k.GetParams(ctx) + + takerFee := determineTakerFee(poolManagerParams, poolAssets, poolType) + // Create the pool with the given pool ID. - pool, err := msg.CreatePool(ctx, poolId) + pool, err := msg.CreatePool(ctx, poolId, takerFee) if err != nil { return nil, err } // Store the pool ID to pool type mapping in state. - k.SetPoolRoute(ctx, poolId, msg.GetPoolType()) + k.SetPoolRoute(ctx, poolId, poolType) // Validates the pool address and pool ID stored match what was expected. if err := k.validateCreatedPool(ctx, poolId, pool); err != nil { @@ -120,7 +126,7 @@ func (k Keeper) createPoolZeroLiquidityNoCreationFee(ctx sdk.Context, msg types. } // Run the respective pool type's initialization logic. - swapModule := k.routes[msg.GetPoolType()] + swapModule := k.routes[poolType] if err := swapModule.InitializePool(ctx, pool, msg.PoolCreator()); err != nil { return nil, err } @@ -214,3 +220,65 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) parsedValue.PoolId = poolId return parsedValue, nil } + +// determineTakerFee determines what the taker fee should be based on the pool type and denoms given. +// This taker fee can be overridden by governance after the pool is created. +func determineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { + if poolType == types.Stableswap { + return poolManagerParams.StableswapTakerFee + } else { + // Check if all denoms exist in the stable denom list in poolmanager params. + // As soon as one denom is not in the list, we know that the pool is not a stableswap pool + // and move on to the next check. + allAssetsAreStable := true + for _, asset := range poolAssets { + isStable := false + for _, stableDenom := range poolManagerParams.StablecoinDenoms { + if asset.Denom == stableDenom { + isStable = true + break + } + } + // If we reach here and isStable is still false, + // it means that the asset denom is not in the stable denom list + if !isStable { + allAssetsAreStable = false + break + } + } + + if allAssetsAreStable { + // If we reach here, it means that all denoms are in the stable denom list + // Therefore, we know that the pool is a stableswap pool and set the taker fee to the stableswap fee. + return poolManagerParams.StableswapTakerFee + } else if len(poolAssets) == 2 { + // This brings us to our check, to see if this is an LST <> underlying denom pool. + isStableLSTPair := false + for _, asset := range poolAssets { + for i, lstDenom := range poolManagerParams.LiquidStakeDenomPairings { + if asset.Denom == lstDenom.UnderlyingTokenDenom { + for _, denom := range lstDenom.LiquidStakedTokenDenoms { + if (i == 0 && poolAssets[1].Denom == denom) || + (i != 0 && poolAssets[0].Denom == denom) { + isStableLSTPair = true + break + } + } + } + if isStableLSTPair { + break + } + } + if isStableLSTPair { + break + } + } + if isStableLSTPair { + // If it is an LST <> underlying denom pool, we set the taker fee to the stableswap fee. + return poolManagerParams.StableswapTakerFee + } + } + } + + return poolManagerParams.DefaultTakerFee +} diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 1d5dbaf1408..38e231b6504 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -49,6 +49,13 @@ type Params struct { // taker fees that are not whitelisted will be swapped to when being sent to // the community pool. CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,8,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` + // stablecoin_denoms is a list of denoms that are considered stablecoins. + // This is used to determine if a pool should use the stableswap taker + // fee.bool LSTs are NOT apart of this catagory, even though they are eligible + // for stableswap taker fees. This is determined via the + // liquid_stake_denom_pairings field. + StablecoinDenoms []string `protobuf:"bytes,9,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` + LiquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom `protobuf:"bytes,10,rep,name=liquid_stake_denom_pairings,json=liquidStakeDenomPairings,proto3" json:"liquid_stake_denom_pairings,omitempty" yaml:"liquid_stake_denom_pairings"` } func (m *Params) Reset() { *m = Params{} } @@ -126,6 +133,20 @@ func (m *Params) GetCommunityPoolDenomToSwapNonWhitelistedAssetsTo() string { return "" } +func (m *Params) GetStablecoinDenoms() []string { + if m != nil { + return m.StablecoinDenoms + } + return nil +} + +func (m *Params) GetLiquidStakeDenomPairings() []*LiquidStakedTokenToUnderlyingDenom { + if m != nil { + return m.LiquidStakeDenomPairings + } + return nil +} + // GenesisState defines the poolmanager module's genesis state. type GenesisState struct { // the next_pool_id @@ -276,11 +297,64 @@ func (m *TakerFeeDistributionPercentage) XXX_DiscardUnknown() { var xxx_messageInfo_TakerFeeDistributionPercentage proto.InternalMessageInfo +type LiquidStakedTokenToUnderlyingDenom struct { + LiquidStakedTokenDenoms []string `protobuf:"bytes,1,rep,name=liquid_staked_token_denoms,json=liquidStakedTokenDenoms,proto3" json:"liquid_staked_token_denoms,omitempty" yaml:"liquid_staked_token_denoms"` + UnderlyingTokenDenom string `protobuf:"bytes,2,opt,name=underlying_token_denom,json=underlyingTokenDenom,proto3" json:"underlying_token_denom,omitempty" yaml:"underlying_token_denom"` +} + +func (m *LiquidStakedTokenToUnderlyingDenom) Reset() { *m = LiquidStakedTokenToUnderlyingDenom{} } +func (m *LiquidStakedTokenToUnderlyingDenom) String() string { return proto.CompactTextString(m) } +func (*LiquidStakedTokenToUnderlyingDenom) ProtoMessage() {} +func (*LiquidStakedTokenToUnderlyingDenom) Descriptor() ([]byte, []int) { + return fileDescriptor_aa099d9fbdf68b35, []int{4} +} +func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Merge(src proto.Message) { + xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.Merge(m, src) +} +func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Size() int { + return m.Size() +} +func (m *LiquidStakedTokenToUnderlyingDenom) XXX_DiscardUnknown() { + xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.DiscardUnknown(m) +} + +var xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom proto.InternalMessageInfo + +func (m *LiquidStakedTokenToUnderlyingDenom) GetLiquidStakedTokenDenoms() []string { + if m != nil { + return m.LiquidStakedTokenDenoms + } + return nil +} + +func (m *LiquidStakedTokenToUnderlyingDenom) GetUnderlyingTokenDenom() string { + if m != nil { + return m.UnderlyingTokenDenom + } + return "" +} + func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") proto.RegisterType((*CustomPoolTakerFee)(nil), "osmosis.poolmanager.v1beta1.CustomPoolTakerFee") proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") + proto.RegisterType((*LiquidStakedTokenToUnderlyingDenom)(nil), "osmosis.poolmanager.v1beta1.LiquidStakedTokenToUnderlyingDenom") } func init() { @@ -288,61 +362,71 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 862 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0x9b, 0xb0, 0x4d, 0x26, 0xa5, 0xa1, 0xa6, 0x2d, 0x6e, 0x22, 0xd9, 0x2b, 0x47, 0x42, - 0xcb, 0xa1, 0xb6, 0x12, 0x24, 0x2a, 0x81, 0x38, 0xc4, 0x59, 0xb5, 0x20, 0x41, 0x9b, 0x3a, 0x91, - 0x90, 0x7a, 0xb1, 0x66, 0xd7, 0x2f, 0x8e, 0x15, 0x7b, 0xde, 0xd6, 0x33, 0x4e, 0x1a, 0x4e, 0x48, - 0x7c, 0x01, 0x24, 0x6e, 0x88, 0x33, 0x07, 0x6e, 0x7c, 0x07, 0x0e, 0x3d, 0xf6, 0x88, 0x38, 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, 0xd7, 0xfa, 0xe9, 0xd4, 0x9d, 0x7b, 0x73, 0xea, 0xce, - 0xfd, 0x75, 0xea, 0xce, 0xbd, 0x78, 0x34, 0xa6, 0x64, 0x46, 0xe0, 0x61, 0x41, 0x3b, 0x7c, 0x78, - 0x08, 0x8f, 0x36, 0x1e, 0x85, 0xaf, 0x26, 0x3e, 0x9a, 0x4a, 0xbe, 0xd3, 0x50, 0x9f, 0xc9, 0x4f, - 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x90, 0x40, 0xdc, 0x2c, 0x08, 0x00, 0x00, + // 1023 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcf, 0x6e, 0xdb, 0xc6, + 0x13, 0x36, 0x63, 0xff, 0x94, 0x78, 0x9d, 0x5f, 0x1c, 0xb3, 0x8e, 0xc3, 0xd8, 0xad, 0xa8, 0xd0, + 0x68, 0xa0, 0x1e, 0x42, 0xc2, 0x2e, 0xd0, 0x00, 0x2d, 0x8a, 0xc2, 0xb4, 0x90, 0x34, 0x40, 0x9a, + 0x28, 0xb4, 0x8a, 0x00, 0xb9, 0x10, 0x2b, 0x71, 0x4d, 0x2f, 0x4c, 0xee, 0xca, 0xdc, 0xa5, 0x1d, + 0xf5, 0x54, 0xa0, 0x2f, 0x50, 0xa0, 0xb7, 0xa2, 0xe7, 0x1c, 0x7a, 0xeb, 0x3b, 0xf4, 0x90, 0x63, + 0x0e, 0x3d, 0x14, 0x3d, 0xb0, 0xad, 0xfc, 0x06, 0x7a, 0x82, 0x62, 0xff, 0x50, 0x7f, 0x2c, 0x5b, + 0xad, 0xdb, 0x93, 0xc4, 0x9d, 0xf9, 0xbe, 0xf9, 0x66, 0x76, 0x66, 0x48, 0xf0, 0x01, 0x65, 0x29, + 0x65, 0x98, 0x79, 0x5d, 0x4a, 0x93, 0x14, 0x12, 0x18, 0xa3, 0xcc, 0x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 0xdc, 0xd4, 0x12, 0x37, 0x9e, 0x52, 0x72, + 0xa1, 0xca, 0x0d, 0x72, 0xb1, 0xd1, 0x7c, 0x09, 0x6e, 0xc3, 0x9c, 0x1f, 0xd0, 0x0c, 0x7f, 0x85, + 0xa2, 0xf0, 0x28, 0xa7, 0x1c, 0x85, 0x11, 0x22, 0x34, 0x65, 0xd6, 0xd5, 0xda, 0x7c, 0x7d, 0xd1, + 0x77, 0x06, 0x85, 0x5d, 0x55, 0xd3, 0x72, 0x81, 0xa3, 0x13, 0xdc, 0x1a, 0x59, 0x9e, 0x0b, 0x43, + 0x43, 0x9e, 0x9b, 0x3f, 0x19, 0xe0, 0xa3, 0x0e, 0x4d, 0xd3, 0x9c, 0x60, 0xde, 0x0b, 0xe5, 0xac, + 0x49, 0x44, 0xc8, 0x69, 0x28, 0x3b, 0x56, 0x54, 0xe8, 0xe4, 0x00, 0x73, 0x94, 0x60, 0xc6, 0x51, + 0x14, 0x42, 0xc6, 0x10, 0x67, 0x21, 0xa7, 0xd6, 0x35, 0x35, 0x33, 0x83, 0xc2, 0xfe, 0x54, 0xc5, + 0xfe, 0x77, 0x3c, 0x4e, 0xe0, 0x0e, 0x81, 0xa2, 0xa7, 0xa4, 0xb0, 0x16, 0xdd, 0x3b, 0x81, 0xdd, + 0xa7, 0x94, 0xbc, 0x18, 0x41, 0x76, 0x24, 0xa2, 0x45, 0xcd, 0xc7, 0x60, 0x45, 0x35, 0xbc, 0x58, + 0x53, 0x65, 0x25, 0x16, 0x65, 0x25, 0xde, 0x1d, 0xed, 0x8d, 0x29, 0x17, 0x27, 0xb8, 0x39, 0x3a, + 0xd3, 0xe9, 0xbf, 0x36, 0xc0, 0x46, 0x82, 0x8f, 0x72, 0x1c, 0x85, 0x4c, 0xb4, 0x80, 0x16, 0x2d, + 0x06, 0x06, 0x93, 0x98, 0x59, 0x40, 0x8e, 0xca, 0x67, 0x33, 0xef, 0xff, 0x89, 0xc4, 0xef, 0x09, + 0x78, 0xd4, 0xa2, 0x87, 0x88, 0xb4, 0xe8, 0x97, 0x24, 0x42, 0x59, 0xd2, 0xc3, 0x24, 0x96, 0x71, + 0xfc, 0x7b, 0x83, 0xc2, 0x76, 0x94, 0xac, 0x19, 0xd1, 0x9c, 0xc0, 0x4a, 0x46, 0x5c, 0x12, 0xd9, + 0x2c, 0x4d, 0x3f, 0x1b, 0xe0, 0xfa, 0x23, 0xf5, 0x06, 0xd9, 0xe3, 0x90, 0x23, 0xb3, 0x06, 0xae, + 0x13, 0xf4, 0x8a, 0xab, 0x52, 0xe3, 0xc8, 0x32, 0x6a, 0x46, 0x7d, 0x21, 0x00, 0xe2, 0x4c, 0x54, + 0xf1, 0x71, 0x64, 0xee, 0x80, 0x4a, 0x57, 0x2e, 0x62, 0xb9, 0xdd, 0x96, 0xb6, 0x37, 0x67, 0x66, + 0xa1, 0x76, 0xb6, 0xbf, 0x20, 0xba, 0x35, 0xd0, 0x40, 0xf3, 0x19, 0x58, 0x92, 0xfc, 0x72, 0xc1, + 0x33, 0x6b, 0x5e, 0x56, 0xa3, 0x3e, 0x93, 0xe7, 0x0b, 0xf9, 0x4a, 0x08, 0x04, 0x40, 0x93, 0x01, + 0xe1, 0x26, 0x0f, 0x98, 0xf3, 0xbd, 0x01, 0xce, 0x59, 0x1f, 0xe6, 0x26, 0xb8, 0x3a, 0x91, 0x87, + 0x0f, 0xfa, 0x85, 0x5d, 0x51, 0x79, 0x04, 0x95, 0xae, 0xca, 0x27, 0x04, 0x8b, 0x67, 0x17, 0xb6, + 0x7f, 0xb9, 0xf5, 0x39, 0x28, 0xec, 0x9b, 0xea, 0x16, 0x86, 0x44, 0x4e, 0x70, 0x8d, 0x6b, 0x15, + 0xce, 0x37, 0x57, 0x40, 0x75, 0xf6, 0x30, 0x9b, 0x47, 0x60, 0x59, 0xdc, 0x9c, 0x58, 0xaa, 0x19, + 0x3a, 0x81, 0x59, 0xc4, 0xa4, 0xe0, 0x45, 0xff, 0xf3, 0x4b, 0x2b, 0x59, 0x1b, 0xb6, 0xe9, 0x38, + 0x9d, 0x13, 0xdc, 0xd0, 0x27, 0x81, 0x3a, 0x30, 0x09, 0xb8, 0x31, 0x39, 0x58, 0x3a, 0xf7, 0x47, + 0x97, 0x8e, 0x78, 0xeb, 0xbc, 0x31, 0x75, 0x82, 0xff, 0x4f, 0x8c, 0x9f, 0xf3, 0xa7, 0x01, 0x9c, + 0xbf, 0x6f, 0x69, 0xb3, 0x0d, 0xd6, 0xc7, 0x5b, 0x39, 0x0a, 0xb9, 0xf0, 0x2b, 0xa7, 0xd1, 0x90, + 0xd3, 0xf8, 0xfe, 0xa0, 0xb0, 0xef, 0x4e, 0xb7, 0xfd, 0xa4, 0xaf, 0x13, 0xdc, 0x4e, 0xce, 0x86, + 0xd3, 0xd3, 0xf9, 0x02, 0xac, 0xe5, 0xc3, 0xb0, 0xe3, 0x20, 0x5d, 0x82, 0xbb, 0x83, 0xc2, 0x7e, + 0x4f, 0xf1, 0x9f, 0xef, 0xe7, 0x04, 0xab, 0x23, 0xc3, 0x88, 0xd9, 0x7f, 0xfe, 0xa6, 0x5f, 0x35, + 0xde, 0xf6, 0xab, 0xc6, 0x1f, 0xfd, 0xaa, 0xf1, 0xed, 0x69, 0x75, 0xee, 0xed, 0x69, 0x75, 0xee, + 0xd7, 0xd3, 0xea, 0xdc, 0xcb, 0x07, 0x63, 0xd5, 0xd4, 0x6d, 0x7e, 0x3f, 0x81, 0x6d, 0x56, 0x3e, + 0x78, 0xc7, 0x5b, 0x0f, 0xbc, 0x57, 0x13, 0x1f, 0x43, 0xb2, 0xc4, 0xed, 0x8a, 0xfc, 0xfc, 0xf9, + 0xf0, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x14, 0x81, 0x9d, 0x04, 0x0a, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -365,6 +449,29 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.LiquidStakeDenomPairings) > 0 { + for iNdEx := len(m.LiquidStakeDenomPairings) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.LiquidStakeDenomPairings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + } + if len(m.StablecoinDenoms) > 0 { + for iNdEx := len(m.StablecoinDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.StablecoinDenoms[iNdEx]) + copy(dAtA[i:], m.StablecoinDenoms[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.StablecoinDenoms[iNdEx]))) + i-- + dAtA[i] = 0x4a + } + } if len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) > 0 { i -= len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) @@ -585,6 +692,45 @@ func (m *TakerFeeDistributionPercentage) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *LiquidStakedTokenToUnderlyingDenom) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *LiquidStakedTokenToUnderlyingDenom) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *LiquidStakedTokenToUnderlyingDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.UnderlyingTokenDenom) > 0 { + i -= len(m.UnderlyingTokenDenom) + copy(dAtA[i:], m.UnderlyingTokenDenom) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.UnderlyingTokenDenom))) + i-- + dAtA[i] = 0x12 + } + if len(m.LiquidStakedTokenDenoms) > 0 { + for iNdEx := len(m.LiquidStakedTokenDenoms) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.LiquidStakedTokenDenoms[iNdEx]) + copy(dAtA[i:], m.LiquidStakedTokenDenoms[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.LiquidStakedTokenDenoms[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -632,6 +778,18 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovGenesis(uint64(l)) } + if len(m.StablecoinDenoms) > 0 { + for _, s := range m.StablecoinDenoms { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.LiquidStakeDenomPairings) > 0 { + for _, e := range m.LiquidStakeDenomPairings { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -682,6 +840,25 @@ func (m *TakerFeeDistributionPercentage) Size() (n int) { return n } +func (m *LiquidStakedTokenToUnderlyingDenom) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.LiquidStakedTokenDenoms) > 0 { + for _, s := range m.LiquidStakedTokenDenoms { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = len(m.UnderlyingTokenDenom) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } + return n +} + func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -983,6 +1160,72 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StablecoinDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StablecoinDenoms = append(m.StablecoinDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidStakeDenomPairings", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidStakeDenomPairings = append(m.LiquidStakeDenomPairings, &LiquidStakedTokenToUnderlyingDenom{}) + if err := m.LiquidStakeDenomPairings[len(m.LiquidStakeDenomPairings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1361,6 +1604,120 @@ func (m *TakerFeeDistributionPercentage) Unmarshal(dAtA []byte) error { } return nil } +func (m *LiquidStakedTokenToUnderlyingDenom) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: LiquidStakedTokenToUnderlyingDenom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: LiquidStakedTokenToUnderlyingDenom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LiquidStakedTokenDenoms", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.LiquidStakedTokenDenoms = append(m.LiquidStakedTokenDenoms, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnderlyingTokenDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UnderlyingTokenDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/msg_create_pool.go b/x/poolmanager/types/msg_create_pool.go index ae8cedd9ded..7faa7047183 100644 --- a/x/poolmanager/types/msg_create_pool.go +++ b/x/poolmanager/types/msg_create_pool.go @@ -17,5 +17,5 @@ type CreatePoolMsg interface { // Initial Liquidity for the pool that the sender is required to send to the pool account InitialLiquidity() sdk.Coins // CreatePool creates a pool implementing PoolI, using data from the message. - CreatePool(ctx sdk.Context, poolID uint64) (PoolI, error) + CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (PoolI, error) } From 4d421fdb33df5ce4c0f74b0842ef48b12f9f431e Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 14 Aug 2023 14:52:31 -0500 Subject: [PATCH 06/83] pull taker fee direct from pool struct --- Makefile | 2 +- .../v1beta1/model/pool_query_msg.proto | 14 + tests/mocks/cfmm_pool.go | 42 ++ tests/mocks/cl_pool.go | 23 +- tests/mocks/pool.go | 14 + tests/mocks/pool_module.go | 30 +- x/concentrated-liquidity/model/pool.go | 4 + .../cosmwasm/msg/pool_query_msg.pb.go | 430 ++++++++++++++++-- x/cosmwasmpool/model/pool.go | 6 + x/cosmwasmpool/model/store_model.go | 4 + x/gamm/pool-models/balancer/pool.go | 4 + x/gamm/pool-models/stableswap/pool.go | 4 + x/poolmanager/export_test.go | 4 - x/poolmanager/router.go | 32 +- x/poolmanager/router_test.go | 3 +- x/poolmanager/types/pool.go | 1 + 16 files changed, 534 insertions(+), 83 deletions(-) diff --git a/Makefile b/Makefile index ff9018b4bcc..69bb4e02944 100644 --- a/Makefile +++ b/Makefile @@ -546,7 +546,7 @@ cl-create-bigbang-config: ############################################################################### go-mock-update: - mockgen -source=x/poolmanager/types/routes.go -destination=tests/mocks/pool_module.go -package=mocks + mockgen -source=x/poolmanager/types/expected_keepers.go -destination=tests/mocks/pool_module.go -package=mocks mockgen -source=x/poolmanager/types/pool.go -destination=tests/mocks/pool.go -package=mocks mockgen -source=x/gamm/types/pool.go -destination=tests/mocks/cfmm_pool.go -package=mocks mockgen -source=x/concentrated-liquidity/types/cl_pool_extensionI.go -destination=tests/mocks/cl_pool.go -package=mocks diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto index f9d66be3f89..0065f925470 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto @@ -20,6 +20,20 @@ message GetSwapFeeQueryMsgResponse { ]; } +// ===================== GetTakerFeeQueryMsg +message GetTakerFeeQueryMsg { + // get_taker_fee is the query strcuture to get taker fee. + EmptyStruct get_taker_fee = 1 [ (gogoproto.nullable) = false ]; +} + +message GetTakerFeeQueryMsgResponse { + // taker_fee is the taker fee for this swap estimate. + string taker_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; +} + // ===================== SpotPriceQueryMsg message SpotPrice { // quote_asset_denom is the quote asset of the spot query. diff --git a/tests/mocks/cfmm_pool.go b/tests/mocks/cfmm_pool.go index a45575cda2b..4c0e505c691 100644 --- a/tests/mocks/cfmm_pool.go +++ b/tests/mocks/cfmm_pool.go @@ -198,6 +198,20 @@ func (mr *MockCFMMPoolIMockRecorder) GetSpreadFactor(ctx interface{}) *gomock.Ca return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpreadFactor", reflect.TypeOf((*MockCFMMPoolI)(nil).GetSpreadFactor), ctx) } +// GetTakerFee mocks base method. +func (m *MockCFMMPoolI) GetTakerFee(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// GetTakerFee indicates an expected call of GetTakerFee. +func (mr *MockCFMMPoolIMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockCFMMPoolI)(nil).GetTakerFee), ctx) +} + // GetTotalPoolLiquidity mocks base method. func (m *MockCFMMPoolI) GetTotalPoolLiquidity(ctx types.Context) types.Coins { m.ctrl.T.Helper() @@ -582,6 +596,20 @@ func (mr *MockPoolAmountOutExtensionMockRecorder) GetSpreadFactor(ctx interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpreadFactor", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).GetSpreadFactor), ctx) } +// GetTakerFee mocks base method. +func (m *MockPoolAmountOutExtension) GetTakerFee(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// GetTakerFee indicates an expected call of GetTakerFee. +func (mr *MockPoolAmountOutExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).GetTakerFee), ctx) +} + // GetTotalPoolLiquidity mocks base method. func (m *MockPoolAmountOutExtension) GetTotalPoolLiquidity(ctx types.Context) types.Coins { m.ctrl.T.Helper() @@ -963,6 +991,20 @@ func (mr *MockWeightedPoolExtensionMockRecorder) GetSpreadFactor(ctx interface{} return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpreadFactor", reflect.TypeOf((*MockWeightedPoolExtension)(nil).GetSpreadFactor), ctx) } +// GetTakerFee mocks base method. +func (m *MockWeightedPoolExtension) GetTakerFee(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// GetTakerFee indicates an expected call of GetTakerFee. +func (mr *MockWeightedPoolExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockWeightedPoolExtension)(nil).GetTakerFee), ctx) +} + // GetTokenWeight mocks base method. func (m *MockWeightedPoolExtension) GetTokenWeight(denom string) (types.Int, error) { m.ctrl.T.Helper() diff --git a/tests/mocks/cl_pool.go b/tests/mocks/cl_pool.go index ac3f0647872..efa42a3bf3e 100644 --- a/tests/mocks/cl_pool.go +++ b/tests/mocks/cl_pool.go @@ -10,6 +10,7 @@ import ( types "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" + osmomath "github.com/osmosis-labs/osmosis/osmomath" types0 "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" ) @@ -37,7 +38,7 @@ func (m *MockConcentratedPoolExtension) EXPECT() *MockConcentratedPoolExtensionM } // ApplySwap mocks base method. -func (m *MockConcentratedPoolExtension) ApplySwap(newLiquidity types.Dec, newCurrentTick int64, newCurrentSqrtPrice types.Dec) error { +func (m *MockConcentratedPoolExtension) ApplySwap(newLiquidity types.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "ApplySwap", newLiquidity, newCurrentTick, newCurrentSqrtPrice) ret0, _ := ret[0].(error) @@ -95,10 +96,10 @@ func (mr *MockConcentratedPoolExtensionMockRecorder) GetAddress() *gomock.Call { } // GetCurrentSqrtPrice mocks base method. -func (m *MockConcentratedPoolExtension) GetCurrentSqrtPrice() types.Dec { +func (m *MockConcentratedPoolExtension) GetCurrentSqrtPrice() osmomath.BigDec { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetCurrentSqrtPrice") - ret0, _ := ret[0].(types.Dec) + ret0, _ := ret[0].(osmomath.BigDec) return ret0 } @@ -220,6 +221,20 @@ func (mr *MockConcentratedPoolExtensionMockRecorder) GetSpreadRewardsAddress() * return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpreadRewardsAddress", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).GetSpreadRewardsAddress)) } +// GetTakerFee mocks base method. +func (m *MockConcentratedPoolExtension) GetTakerFee(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// GetTakerFee indicates an expected call of GetTakerFee. +func (mr *MockConcentratedPoolExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).GetTakerFee), ctx) +} + // GetTickSpacing mocks base method. func (m *MockConcentratedPoolExtension) GetTickSpacing() uint64 { m.ctrl.T.Helper() @@ -329,7 +344,7 @@ func (mr *MockConcentratedPoolExtensionMockRecorder) Reset() *gomock.Call { } // SetCurrentSqrtPrice mocks base method. -func (m *MockConcentratedPoolExtension) SetCurrentSqrtPrice(newSqrtPrice types.Dec) { +func (m *MockConcentratedPoolExtension) SetCurrentSqrtPrice(newSqrtPrice osmomath.BigDec) { m.ctrl.T.Helper() m.ctrl.Call(m, "SetCurrentSqrtPrice", newSqrtPrice) } diff --git a/tests/mocks/pool.go b/tests/mocks/pool.go index 311b313db41..a265f2a33b6 100644 --- a/tests/mocks/pool.go +++ b/tests/mocks/pool.go @@ -91,6 +91,20 @@ func (mr *MockPoolIMockRecorder) GetSpreadFactor(ctx interface{}) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetSpreadFactor", reflect.TypeOf((*MockPoolI)(nil).GetSpreadFactor), ctx) } +// GetTakerFee mocks base method. +func (m *MockPoolI) GetTakerFee(ctx types.Context) types.Dec { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret0, _ := ret[0].(types.Dec) + return ret0 +} + +// GetTakerFee indicates an expected call of GetTakerFee. +func (mr *MockPoolIMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolI)(nil).GetTakerFee), ctx) +} + // GetType mocks base method. func (m *MockPoolI) GetType() types0.PoolType { m.ctrl.T.Helper() diff --git a/tests/mocks/pool_module.go b/tests/mocks/pool_module.go index 1095b25f213..78bbfc2dd0d 100644 --- a/tests/mocks/pool_module.go +++ b/tests/mocks/pool_module.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: x/poolmanager/types/routes.go +// Source: x/poolmanager/types/expected_keepers.go // Package mocks is a generated GoMock package. package mocks @@ -114,6 +114,20 @@ func (m *MockBankI) EXPECT() *MockBankIMockRecorder { return m.recorder } +// GetAllBalances mocks base method. +func (m *MockBankI) GetAllBalances(ctx types.Context, addr types.AccAddress) types.Coins { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAllBalances", ctx, addr) + ret0, _ := ret[0].(types.Coins) + return ret0 +} + +// GetAllBalances indicates an expected call of GetAllBalances. +func (mr *MockBankIMockRecorder) GetAllBalances(ctx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAllBalances", reflect.TypeOf((*MockBankI)(nil).GetAllBalances), ctx, addr) +} + // SendCoins mocks base method. func (m *MockBankI) SendCoins(ctx types.Context, fromAddr, toAddr types.AccAddress, amt types.Coins) error { m.ctrl.T.Helper() @@ -128,6 +142,20 @@ func (mr *MockBankIMockRecorder) SendCoins(ctx, fromAddr, toAddr, amt interface{ return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoins", reflect.TypeOf((*MockBankI)(nil).SendCoins), ctx, fromAddr, toAddr, amt) } +// SendCoinsFromAccountToModule mocks base method. +func (m *MockBankI) SendCoinsFromAccountToModule(ctx types.Context, senderAddr types.AccAddress, recipientModule string, amt types.Coins) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SendCoinsFromAccountToModule", ctx, senderAddr, recipientModule, amt) + ret0, _ := ret[0].(error) + return ret0 +} + +// SendCoinsFromAccountToModule indicates an expected call of SendCoinsFromAccountToModule. +func (mr *MockBankIMockRecorder) SendCoinsFromAccountToModule(ctx, senderAddr, recipientModule, amt interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SendCoinsFromAccountToModule", reflect.TypeOf((*MockBankI)(nil).SendCoinsFromAccountToModule), ctx, senderAddr, recipientModule, amt) +} + // SetDenomMetaData mocks base method. func (m *MockBankI) SetDenomMetaData(ctx types.Context, denomMetaData types1.Metadata) { m.ctrl.T.Helper() diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index fe9049bb2f9..1fb5f99d157 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -101,6 +101,10 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.SpreadFactor } +func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { + return p.TakerFee +} + // IsActive returns true if the pool is active func (p Pool) IsActive(ctx sdk.Context) bool { return true diff --git a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go index 8f18027532c..988bea36d16 100644 --- a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go +++ b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go @@ -109,6 +109,90 @@ func (m *GetSwapFeeQueryMsgResponse) XXX_DiscardUnknown() { var xxx_messageInfo_GetSwapFeeQueryMsgResponse proto.InternalMessageInfo +// ===================== GetTakerFeeQueryMsg +type GetTakerFeeQueryMsg struct { + // get_taker_fee is the query strcuture to get taker fee. + GetTakerFee EmptyStruct `protobuf:"bytes,1,opt,name=get_taker_fee,json=getTakerFee,proto3" json:"get_taker_fee"` +} + +func (m *GetTakerFeeQueryMsg) Reset() { *m = GetTakerFeeQueryMsg{} } +func (m *GetTakerFeeQueryMsg) String() string { return proto.CompactTextString(m) } +func (*GetTakerFeeQueryMsg) ProtoMessage() {} +func (*GetTakerFeeQueryMsg) Descriptor() ([]byte, []int) { + return fileDescriptor_3251d17e76ef0dc1, []int{2} +} +func (m *GetTakerFeeQueryMsg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetTakerFeeQueryMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetTakerFeeQueryMsg.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetTakerFeeQueryMsg) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTakerFeeQueryMsg.Merge(m, src) +} +func (m *GetTakerFeeQueryMsg) XXX_Size() int { + return m.Size() +} +func (m *GetTakerFeeQueryMsg) XXX_DiscardUnknown() { + xxx_messageInfo_GetTakerFeeQueryMsg.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTakerFeeQueryMsg proto.InternalMessageInfo + +func (m *GetTakerFeeQueryMsg) GetGetTakerFee() EmptyStruct { + if m != nil { + return m.GetTakerFee + } + return EmptyStruct{} +} + +type GetTakerFeeQueryMsgResponse struct { + // taker_fee is the taker fee for this swap estimate. + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee"` +} + +func (m *GetTakerFeeQueryMsgResponse) Reset() { *m = GetTakerFeeQueryMsgResponse{} } +func (m *GetTakerFeeQueryMsgResponse) String() string { return proto.CompactTextString(m) } +func (*GetTakerFeeQueryMsgResponse) ProtoMessage() {} +func (*GetTakerFeeQueryMsgResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_3251d17e76ef0dc1, []int{3} +} +func (m *GetTakerFeeQueryMsgResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetTakerFeeQueryMsgResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetTakerFeeQueryMsgResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *GetTakerFeeQueryMsgResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetTakerFeeQueryMsgResponse.Merge(m, src) +} +func (m *GetTakerFeeQueryMsgResponse) XXX_Size() int { + return m.Size() +} +func (m *GetTakerFeeQueryMsgResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetTakerFeeQueryMsgResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetTakerFeeQueryMsgResponse proto.InternalMessageInfo + // ===================== SpotPriceQueryMsg type SpotPrice struct { // quote_asset_denom is the quote asset of the spot query. @@ -121,7 +205,7 @@ func (m *SpotPrice) Reset() { *m = SpotPrice{} } func (m *SpotPrice) String() string { return proto.CompactTextString(m) } func (*SpotPrice) ProtoMessage() {} func (*SpotPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{2} + return fileDescriptor_3251d17e76ef0dc1, []int{4} } func (m *SpotPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -174,7 +258,7 @@ func (m *SpotPriceQueryMsg) Reset() { *m = SpotPriceQueryMsg{} } func (m *SpotPriceQueryMsg) String() string { return proto.CompactTextString(m) } func (*SpotPriceQueryMsg) ProtoMessage() {} func (*SpotPriceQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{3} + return fileDescriptor_3251d17e76ef0dc1, []int{5} } func (m *SpotPriceQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -219,7 +303,7 @@ func (m *SpotPriceQueryMsgResponse) Reset() { *m = SpotPriceQueryMsgResp func (m *SpotPriceQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*SpotPriceQueryMsgResponse) ProtoMessage() {} func (*SpotPriceQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{4} + return fileDescriptor_3251d17e76ef0dc1, []int{6} } func (m *SpotPriceQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -263,7 +347,7 @@ func (m *EmptyStruct) Reset() { *m = EmptyStruct{} } func (m *EmptyStruct) String() string { return proto.CompactTextString(m) } func (*EmptyStruct) ProtoMessage() {} func (*EmptyStruct) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{5} + return fileDescriptor_3251d17e76ef0dc1, []int{7} } func (m *EmptyStruct) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -302,7 +386,7 @@ func (m *GetTotalPoolLiquidityQueryMsg) Reset() { *m = GetTotalPoolLiqui func (m *GetTotalPoolLiquidityQueryMsg) String() string { return proto.CompactTextString(m) } func (*GetTotalPoolLiquidityQueryMsg) ProtoMessage() {} func (*GetTotalPoolLiquidityQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{6} + return fileDescriptor_3251d17e76ef0dc1, []int{8} } func (m *GetTotalPoolLiquidityQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -348,7 +432,7 @@ func (m *GetTotalPoolLiquidityQueryMsgResponse) Reset() { *m = GetTotalP func (m *GetTotalPoolLiquidityQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*GetTotalPoolLiquidityQueryMsgResponse) ProtoMessage() {} func (*GetTotalPoolLiquidityQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{7} + return fileDescriptor_3251d17e76ef0dc1, []int{9} } func (m *GetTotalPoolLiquidityQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -395,7 +479,7 @@ func (m *GetTotalSharesQueryMsg) Reset() { *m = GetTotalSharesQueryMsg{} func (m *GetTotalSharesQueryMsg) String() string { return proto.CompactTextString(m) } func (*GetTotalSharesQueryMsg) ProtoMessage() {} func (*GetTotalSharesQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{8} + return fileDescriptor_3251d17e76ef0dc1, []int{10} } func (m *GetTotalSharesQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -440,7 +524,7 @@ func (m *GetTotalSharesQueryMsgResponse) Reset() { *m = GetTotalSharesQu func (m *GetTotalSharesQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*GetTotalSharesQueryMsgResponse) ProtoMessage() {} func (*GetTotalSharesQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{9} + return fileDescriptor_3251d17e76ef0dc1, []int{11} } func (m *GetTotalSharesQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -479,6 +563,8 @@ func (m *GetTotalSharesQueryMsgResponse) GetTotalShares() string { func init() { proto.RegisterType((*GetSwapFeeQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.GetSwapFeeQueryMsg") proto.RegisterType((*GetSwapFeeQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.GetSwapFeeQueryMsgResponse") + proto.RegisterType((*GetTakerFeeQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.GetTakerFeeQueryMsg") + proto.RegisterType((*GetTakerFeeQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.GetTakerFeeQueryMsgResponse") proto.RegisterType((*SpotPrice)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPrice") proto.RegisterType((*SpotPriceQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPriceQueryMsg") proto.RegisterType((*SpotPriceQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPriceQueryMsgResponse") @@ -494,41 +580,44 @@ func init() { } var fileDescriptor_3251d17e76ef0dc1 = []byte{ - // 544 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x4c, - 0x10, 0xc7, 0xe3, 0xaf, 0x9f, 0x00, 0x4f, 0x4a, 0x69, 0xad, 0x82, 0xda, 0x8a, 0xba, 0xc5, 0x12, - 0x10, 0x90, 0xea, 0x55, 0xcb, 0xa1, 0x12, 0x17, 0x44, 0x5a, 0xa8, 0x90, 0x8a, 0xd4, 0x24, 0x5c, - 0xca, 0xc5, 0xda, 0x38, 0xcb, 0xc6, 0xc2, 0xce, 0x38, 0x99, 0x4d, 0x43, 0x78, 0x03, 0x6e, 0x3c, - 0x56, 0x8f, 0x3d, 0x22, 0x0e, 0x15, 0x4a, 0x5e, 0x04, 0xad, 0xe3, 0x6c, 0x12, 0xa5, 0xe4, 0xd0, - 0x53, 0xb2, 0xb3, 0xf3, 0xdf, 0xdf, 0xfc, 0x67, 0xd6, 0x0b, 0x87, 0x48, 0x09, 0x52, 0x44, 0x2c, - 0x44, 0x4a, 0x7a, 0x9c, 0x92, 0x14, 0x31, 0x66, 0x17, 0xfb, 0x75, 0xa1, 0xf8, 0x3e, 0x4b, 0xb0, - 0x21, 0x62, 0xa6, 0x43, 0x41, 0xbb, 0x2b, 0x3a, 0xfd, 0x20, 0x21, 0xe9, 0xa7, 0x1d, 0x54, 0xe8, - 0x3c, 0xce, 0x85, 0xfe, 0xb4, 0xd0, 0xcf, 0x85, 0x5b, 0xeb, 0x12, 0x25, 0x66, 0x89, 0x4c, 0xff, - 0x1b, 0x69, 0xb6, 0xd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0xc5, 0xfe, 0x21, 0xfb, 0x36, 0xfb, 0xd2, 0x8c, 0x17, 0x2c, 0x21, 0x59, 0xbf, 0x93, 0x3d, - 0x03, 0xaf, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x3e, 0xe5, 0x84, 0x95, 0x04, 0x00, 0x00, + // 582 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0x63, 0x8a, 0xa0, 0x9e, 0xb4, 0xa5, 0x35, 0x05, 0xb5, 0x85, 0xba, 0xc5, 0x12, 0x10, + 0x90, 0x6a, 0x2b, 0xe5, 0x50, 0x89, 0x0b, 0x22, 0x2d, 0x54, 0x88, 0x22, 0x35, 0x09, 0x97, 0x72, + 0xb1, 0x36, 0xce, 0xb2, 0x71, 0x6b, 0x67, 0x1d, 0xcf, 0xa6, 0x21, 0xbc, 0x01, 0x37, 0x1e, 0xab, + 0xc7, 0x1e, 0x11, 0x87, 0x0a, 0x25, 0x2f, 0x82, 0xd6, 0xb1, 0x37, 0x89, 0x12, 0x72, 0x08, 0xa7, + 0xc4, 0xb3, 0xf3, 0xcf, 0x37, 0xff, 0x8c, 0xbd, 0x70, 0xc0, 0x31, 0xe4, 0xe8, 0xa3, 0xe3, 0x71, + 0x0c, 0x3b, 0x04, 0xc3, 0x88, 0xf3, 0xc0, 0xb9, 0x2c, 0xd6, 0xa8, 0x20, 0x45, 0x27, 0xe4, 0x75, + 0x1a, 0x38, 0x32, 0xe4, 0xb6, 0xda, 0x34, 0xee, 0xba, 0x21, 0x32, 0x3b, 0x8a, 0xb9, 0xe0, 0xc6, + 0xe3, 0x54, 0x68, 0x8f, 0x0a, 0xed, 0x54, 0xb8, 0xb5, 0xce, 0x38, 0xe3, 0x49, 0xa2, 0x23, 0xff, + 0x0d, 0x34, 0x5b, 0xa6, 0x97, 0x88,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0x86, 0x92, 0xd2, 0xd9, 0x55, 0xcf, 0xd4, 0xae, 0x7b, 0xa6, 0xf6, 0xa7, 0x67, 0x6a, 0x3f, + 0xfb, 0x66, 0xee, 0xba, 0x6f, 0xe6, 0x7e, 0xf5, 0xcd, 0xdc, 0x97, 0x37, 0x23, 0x9f, 0x47, 0xda, + 0xe9, 0x5e, 0x40, 0x6a, 0x98, 0x3d, 0x38, 0x97, 0xc5, 0x03, 0xe7, 0xdb, 0xf8, 0x0d, 0x9a, 0x3d, + 0x38, 0x21, 0xb2, 0xda, 0x9d, 0xe4, 0x7a, 0x7b, 0xf5, 0x37, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xe8, + 0xae, 0xa0, 0x6d, 0x05, 0x00, 0x00, } func (m *GetSwapFeeQueryMsg) Marshal() (dAtA []byte, err error) { @@ -597,6 +686,72 @@ func (m *GetSwapFeeQueryMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } +func (m *GetTakerFeeQueryMsg) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetTakerFeeQueryMsg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetTakerFeeQueryMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.GetTakerFee.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPoolQueryMsg(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GetTakerFeeQueryMsgResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *GetTakerFeeQueryMsgResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetTakerFeeQueryMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPoolQueryMsg(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + return len(dAtA) - i, nil +} + func (m *SpotPrice) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -886,6 +1041,28 @@ func (m *GetSwapFeeQueryMsgResponse) Size() (n int) { return n } +func (m *GetTakerFeeQueryMsg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.GetTakerFee.Size() + n += 1 + l + sovPoolQueryMsg(uint64(l)) + return n +} + +func (m *GetTakerFeeQueryMsgResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TakerFee.Size() + n += 1 + l + sovPoolQueryMsg(uint64(l)) + return n +} + func (m *SpotPrice) Size() (n int) { if m == nil { return 0 @@ -1159,6 +1336,173 @@ func (m *GetSwapFeeQueryMsgResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *GetTakerFeeQueryMsg) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolQueryMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetTakerFeeQueryMsg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetTakerFeeQueryMsg: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field GetTakerFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolQueryMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPoolQueryMsg + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPoolQueryMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.GetTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoolQueryMsg(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoolQueryMsg + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetTakerFeeQueryMsgResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolQueryMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GetTakerFeeQueryMsgResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetTakerFeeQueryMsgResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPoolQueryMsg + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPoolQueryMsg + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPoolQueryMsg + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPoolQueryMsg(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPoolQueryMsg + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *SpotPrice) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/cosmwasmpool/model/pool.go b/x/cosmwasmpool/model/pool.go index 79b833a9196..1a601a84753 100644 --- a/x/cosmwasmpool/model/pool.go +++ b/x/cosmwasmpool/model/pool.go @@ -65,6 +65,12 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return response.SwapFee } +func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { + request := msg.GetTakerFeeQueryMsg{} + response := cosmwasmutils.MustQuery[msg.GetTakerFeeQueryMsg, msg.GetTakerFeeQueryMsgResponse](ctx, p.WasmKeeper, p.ContractAddress, request) + return response.TakerFee +} + // IsActive returns true if the pool is active func (p Pool) IsActive(ctx sdk.Context) bool { return true diff --git a/x/cosmwasmpool/model/store_model.go b/x/cosmwasmpool/model/store_model.go index c0e0a53b189..0a6cba9bb9c 100644 --- a/x/cosmwasmpool/model/store_model.go +++ b/x/cosmwasmpool/model/store_model.go @@ -37,6 +37,10 @@ func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { panic("CosmWasmPool.GetSpreadFactor not implemented") } +func (p CosmWasmPool) GetTakerFee(ctx sdk.Context) sdk.Dec { + panic("CosmWasmPool.GetTakerFee not implemented") +} + func (p CosmWasmPool) GetExitFee(ctx sdk.Context) sdk.Dec { panic("CosmWasmPool.GetExitFee not implemented") } diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index 49dbdd3c53b..805e4dce030 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -92,6 +92,10 @@ func (p Pool) GetSpreadFactor(_ sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } +func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { + return p.PoolParams.TakerFee +} + func (p Pool) GetTotalPoolLiquidity(_ sdk.Context) sdk.Coins { return poolAssetsCoins(p.PoolAssets) } diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index 8876eaa6bc8..6235d25a7ac 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -90,6 +90,10 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } +func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { + return p.PoolParams.TakerFee +} + func (p Pool) GetExitFee(ctx sdk.Context) sdk.Dec { return p.PoolParams.ExitFee } diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index 9e9490eff3a..3c45f22ab2e 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -43,7 +43,3 @@ func (k Keeper) CreateMultihopExpectedSwapOuts( ) ([]sdk.Int, error) { return k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } - -func (k Keeper) DetermineTakerFee(ctx sdk.Context, pool types.PoolI, poolManagerParams types.Params) sdk.Dec { - return k.determineTakerFee(ctx, pool, poolManagerParams) -} diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 7ecf18d93bb..7d34b623fd8 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -66,7 +66,7 @@ func (k Keeper) RouteExactAmountIn( } spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) + takerFee := pool.GetTakerFee(ctx) totalFees := spreadFactor.Add(takerFee) tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, totalFees) @@ -188,7 +188,7 @@ func (k Keeper) SwapExactAmountIn( poolManagerParams := k.GetParams(ctx) spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) + takerFee := pool.GetTakerFee(ctx) totalFees := spreadFactor.Add(takerFee) // routeStep to the pool-specific SwapExactAmountIn implementation. @@ -256,8 +256,6 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } }() - poolManagerParams := k.GetParams(ctx) - routeStep := types.SwapAmountInRoutes(route) if err := routeStep.Validate(); err != nil { return sdk.Int{}, err @@ -276,7 +274,7 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, poolI, poolManagerParams) + takerFee := poolI.GetTakerFee(ctx) totalFees := spreadFactor.Add(takerFee) tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, totalFees) @@ -363,7 +361,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := k.determineTakerFee(ctx, pool, poolManagerParams) + takerFee := pool.GetTakerFee(ctx) totalFees := spreadFactor.Add(takerFee) _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, totalFees) @@ -631,28 +629,6 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { return totalLiquidity, nil } -// determineTakerFee takes in a pool and determines the taker fee based on the pool type. -// If the pool is a stableswap pool, the stableswap taker fee is returned. -// If the poolId exists in the custom pool taker fee list, the custom taker fee is returned. -func (k Keeper) determineTakerFee(ctx sdk.Context, pool types.PoolI, poolManagerParams types.Params) sdk.Dec { - poolId := pool.GetId() - - // First, we check if the poolId exists in the custom pool taker fee list. - // This supersedes any other taker fee parameter. - for _, tradingPair := range poolManagerParams.CustomPoolTakerFee { - if poolId == tradingPair.PoolId { - return tradingPair.TakerFee - } - } - // If the pool is a stableswap pool, the stableswap taker fee is returned. - if pool.GetType() == types.Stableswap { - return poolManagerParams.StableswapTakerFee - } - - // Otherwise, the default taker fee is returned. - return poolManagerParams.DefaultTakerFee -} - // extractTakerFeeToFeePool takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 15797410bc8..40cf1fad2b7 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1229,7 +1229,6 @@ func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(routes []types.SwapAmount func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() nextTokenIn := tokenIn - poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) for _, hop := range routes { swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) @@ -1240,7 +1239,7 @@ func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmo // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := pool.GetSpreadFactor(cacheCtx) - takerFee := s.App.PoolManagerKeeper.DetermineTakerFee(cacheCtx, pool, poolManagerParams) + takerFee := pool.GetTakerFee(s.Ctx) totalFee := spreadFactor.Add(takerFee) // we then do individual swaps until we reach the end of the swap route diff --git a/x/poolmanager/types/pool.go b/x/poolmanager/types/pool.go index 5ce2f1b5d4d..dcc59cd48b8 100644 --- a/x/poolmanager/types/pool.go +++ b/x/poolmanager/types/pool.go @@ -19,6 +19,7 @@ type PoolI interface { // (prior TWAPs, network downtime, other pool states, etc.) // hence Context is provided as an argument. GetSpreadFactor(ctx sdk.Context) sdk.Dec + GetTakerFee(ctx sdk.Context) sdk.Dec // Returns whether the pool has swaps enabled at the moment IsActive(ctx sdk.Context) bool From 4177b7a34ca84f132be7c5ab23ab3eee267c7bb0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 14 Aug 2023 15:58:01 -0500 Subject: [PATCH 07/83] fix more tests --- x/concentrated-liquidity/model/pool_test.go | 2 +- x/gamm/pool-models/balancer/marshal_test.go | 5 +++-- x/gamm/pool-models/balancer/pool_test.go | 1 + x/poolmanager/router.go | 10 +++++++--- x/protorev/keeper/rebalance_test.go | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/x/concentrated-liquidity/model/pool_test.go b/x/concentrated-liquidity/model/pool_test.go index 6119df7d1f7..643e95d6aaf 100644 --- a/x/concentrated-liquidity/model/pool_test.go +++ b/x/concentrated-liquidity/model/pool_test.go @@ -142,7 +142,7 @@ func (s *ConcentratedPoolTestSuite) TestString() { pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor, DefaultTakerFee) s.Require().NoError(err) poolString := pool.String() - s.Require().Equal(poolString, "{\"address\":\"osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7\",\"incentives_address\":\"osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf\",\"spread_rewards_address\":\"osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv\",\"id\":1,\"current_tick_liquidity\":\"0.000000000000000000\",\"token0\":\"foo\",\"token1\":\"bar\",\"current_sqrt_price\":\"0.000000000000000000000000000000000000\",\"tick_spacing\":1,\"exponent_at_price_one\":-6,\"spread_factor\":\"0.010000000000000000\",\"last_liquidity_update\":\"0001-01-01T00:00:00Z\"}") + s.Require().Equal(poolString, "{\"address\":\"osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7\",\"incentives_address\":\"osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf\",\"spread_rewards_address\":\"osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv\",\"id\":1,\"current_tick_liquidity\":\"0.000000000000000000\",\"token0\":\"foo\",\"token1\":\"bar\",\"current_sqrt_price\":\"0.000000000000000000000000000000000000\",\"tick_spacing\":1,\"exponent_at_price_one\":-6,\"spread_factor\":\"0.010000000000000000\",\"last_liquidity_update\":\"0001-01-01T00:00:00Z\",\"taker_fee\":\"0.001500000000000000\"}") } // TestSpotPrice tests the SpotPrice method of the ConcentratedPoolTestSuite. diff --git a/x/gamm/pool-models/balancer/marshal_test.go b/x/gamm/pool-models/balancer/marshal_test.go index a9db3244073..afd8b840e40 100644 --- a/x/gamm/pool-models/balancer/marshal_test.go +++ b/x/gamm/pool-models/balancer/marshal_test.go @@ -27,8 +27,9 @@ func TestPoolJson(t *testing.T) { }, } pacc, err := balancer.NewBalancerPool(poolId, balancer.PoolParams{ - SwapFee: defaultSpreadFactor, - ExitFee: defaultZeroExitFee, + SwapFee: defaultSpreadFactor, + ExitFee: defaultZeroExitFee, + TakerFee: defaultTakerFee, }, jsonAssetTest, defaultFutureGovernor, defaultCurBlockTime) require.NoError(t, err) diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 2fbf55b6423..58f32a33af2 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -19,6 +19,7 @@ import ( var ( defaultSpreadFactor = sdk.MustNewDecFromStr("0.025") + defaultTakerFee = sdk.MustNewDecFromStr("0.0015") defaultZeroExitFee = sdk.ZeroDec() defaultPoolId = uint64(10) defaultBalancerPoolParams = balancer.PoolParams{ diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 7d34b623fd8..b91daf24966 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -305,14 +305,14 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, tokenInMaxAmount sdk.Int, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { + poolManagerParams := k.GetParams(ctx) + // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountOutRoutes(route) if err := routeStep.Validate(); err != nil { return sdk.Int{}, err } - poolManagerParams := k.GetParams(ctx) - defer func() { if r := recover(); r != nil { tokenInAmount = sdk.Int{} @@ -584,7 +584,11 @@ func (k Keeper) createMultihopExpectedSwapOuts( return nil, err } - tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, poolI.GetSpreadFactor(ctx)) + spreadFactor := poolI.GetSpreadFactor(ctx) + takeFee := poolI.GetTakerFee(ctx) + totalFees := spreadFactor.Add(takeFee) + + tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, totalFees) if err != nil { return nil, err } diff --git a/x/protorev/keeper/rebalance_test.go b/x/protorev/keeper/rebalance_test.go index c6753381326..c3bda8d0f72 100644 --- a/x/protorev/keeper/rebalance_test.go +++ b/x/protorev/keeper/rebalance_test.go @@ -609,8 +609,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { maxProfitInputCoin, maxProfitAmount, optimalRoute := s.App.ProtoRevKeeper.IterateRoutes(s.Ctx, routes, &remainingPoolPoints, &remainingBlockPoolPoints) if test.expectPass { - s.Require().Equal(test.params.expectedMaxProfitAmount, maxProfitAmount) - s.Require().Equal(test.params.expectedMaxProfitInputCoin, maxProfitInputCoin) + s.Require().Equal(test.params.expectedMaxProfitAmount.String(), maxProfitAmount.String()) + s.Require().Equal(test.params.expectedMaxProfitInputCoin.String(), maxProfitInputCoin.String()) s.Require().Equal(test.params.expectedOptimalRoute, optimalRoute) } }) From 49e6aff22287dff936e24232c5bae4929f79ec5b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 15 Aug 2023 14:47:34 -0500 Subject: [PATCH 08/83] fix tests, set back up osmo multi hop discount --- x/concentrated-liquidity/model/pool.go | 4 + x/concentrated-liquidity/swaps.go | 6 +- .../types/cl_pool_extensionI.go | 1 + x/gamm/pool-models/balancer/amm.go | 12 +- x/gamm/pool-models/balancer/pool.go | 14 +- x/gamm/pool-models/balancer/pool_test.go | 2 + x/gamm/pool-models/stableswap/amm.go | 9 +- x/gamm/pool-models/stableswap/pool.go | 4 + x/gamm/types/pool.go | 1 + x/poolmanager/export_test.go | 19 + x/poolmanager/router.go | 203 +++++++++- x/poolmanager/router_test.go | 353 ++++++++++++++---- x/protorev/keeper/keeper_test.go | 5 + x/protorev/keeper/rebalance_test.go | 1 + 14 files changed, 542 insertions(+), 92 deletions(-) diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index 1fb5f99d157..02327d17497 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -198,6 +198,10 @@ func (p *Pool) SetLastLiquidityUpdate(newTime time.Time) { p.LastLiquidityUpdate = newTime } +func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { + p.TakerFee = newTakerFee +} + // updateLiquidityIfActivePosition updates the pool's liquidity if the position is active. // Returns true if updated, false otherwise. func (p *Pool) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) bool { diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index fb5f0a3a3ae..b913e79a3aa 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -349,7 +349,8 @@ func (k Keeper) computeOutAmtGivenIn( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInMin.Denom, priceLimit) + totalFees := spreadFactor.Add(p.GetTakerFee(ctx)) + swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, totalFees, tokenInMin.Denom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } @@ -478,7 +479,8 @@ func (k Keeper) computeInAmtGivenOut( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInDenom, priceLimit) + totalFees := spreadFactor.Add(p.GetTakerFee(ctx)) + swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, totalFees, tokenInDenom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } diff --git a/x/concentrated-liquidity/types/cl_pool_extensionI.go b/x/concentrated-liquidity/types/cl_pool_extensionI.go index 95171dbb0d2..e25d603e3f0 100644 --- a/x/concentrated-liquidity/types/cl_pool_extensionI.go +++ b/x/concentrated-liquidity/types/cl_pool_extensionI.go @@ -27,6 +27,7 @@ type ConcentratedPoolExtension interface { SetCurrentTick(newTick int64) SetTickSpacing(newTickSpacing uint64) SetLastLiquidityUpdate(newTime time.Time) + SetTakerFee(newTakerFee sdk.Dec) UpdateLiquidity(newLiquidity sdk.Dec) ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index 91874594648..c22059dc5bb 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -119,12 +119,12 @@ func calcPoolSharesOutGivenSingleAssetIn( normalizedTokenWeightIn, poolShares, tokenAmountIn, - spreadFactor sdk.Dec, + spreadFactor, takerFee sdk.Dec, ) sdk.Dec { // deduct spread factor on the in asset. // We don't charge spread factor on the token amount that we imagine as unswapped (the normalized weight). // So effective_swapfee = spread factor * (1 - normalized_token_weight) - tokenAmountInAfterFee := tokenAmountIn.Mul(feeRatio(normalizedTokenWeightIn, spreadFactor)) + tokenAmountInAfterFee := tokenAmountIn.Mul(feeRatio(normalizedTokenWeightIn, spreadFactor.Add(takerFee))) // To figure out the number of shares we add, first notice that in balancer we can treat // the number of shares as linearly related to the `k` value function. This is due to the normalization. // e.g. @@ -197,13 +197,13 @@ func calcSingleAssetInGivenPoolSharesOut( normalizedTokenWeightIn, totalPoolSharesSupply, sharesAmountOut, - spreadFactor sdk.Dec, + spreadFactor, takerFee sdk.Dec, ) sdk.Dec { // delta balanceIn is negative(tokens inside the pool increases) // pool weight is always 1 tokenAmountIn := solveConstantFunctionInvariant(totalPoolSharesSupply.Add(sharesAmountOut), totalPoolSharesSupply, sdk.OneDec(), tokenBalanceIn, normalizedTokenWeightIn).Neg() // deduct spread factor on the in asset - tokenAmountInFeeIncluded := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, spreadFactor)) + tokenAmountInFeeIncluded := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, spreadFactor.Add(takerFee))) return tokenAmountInFeeIncluded } @@ -215,10 +215,10 @@ func calcPoolSharesInGivenSingleAssetOut( normalizedTokenWeightOut, totalPoolSharesSupply, tokenAmountOut, - spreadFactor, + spreadFactor, takerFee, exitFee sdk.Dec, ) sdk.Dec { - tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor)) + tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor.Add(takerFee))) // delta poolSupply is positive(total pool shares decreases) // pool weight is always 1 diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index 805e4dce030..25f93115d64 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -116,6 +116,10 @@ func (p Pool) GetTotalShares() sdk.Int { return p.TotalShares.Amount } +func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { + p.PoolParams.TakerFee = newTakerFee +} + func (p *Pool) AddTotalShares(amt sdk.Int) { p.TotalShares.Amount = p.TotalShares.Amount.Add(amt) } @@ -503,7 +507,8 @@ func (p Pool) CalcOutAmtGivenIn( return sdk.Coin{}, err } - tokenAmountInAfterFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(spreadFactor)) + totalFee := spreadFactor.Add(p.GetTakerFee(ctx)) + tokenAmountInAfterFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(totalFee)) poolTokenInBalance := poolAssetIn.Token.Amount.ToDec() poolPostSwapInBalance := poolTokenInBalance.Add(tokenAmountInAfterFee) @@ -570,7 +575,8 @@ func (p Pool) CalcInAmtGivenOut( // and then the spread factor is added to the pool. // Thus in order to give X amount out, we solve the invariant for the invariant input. However invariant input = (1 - spread factor) * trade input. // Therefore we divide by (1 - spread factor) here - tokenAmountInBeforeFee := tokenAmountIn.Quo(sdk.OneDec().Sub(spreadFactor)) + totalFee := spreadFactor.Add(p.GetTakerFee(ctx)) + tokenAmountInBeforeFee := tokenAmountIn.Quo(sdk.OneDec().Sub(totalFee)) // We round up tokenInAmt, as this is whats charged for the swap, for the precise amount out. // Otherwise, the pool would under-charge by this rounding error. @@ -669,6 +675,7 @@ func (p *Pool) calcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor sdk.Dec, token totalShares.ToDec(), tokenIn.Amount.ToDec(), spreadFactor, + p.PoolParams.TakerFee, ).TruncateInt(), nil } @@ -906,6 +913,7 @@ func (p *Pool) CalcTokenInShareAmountOut( p.GetTotalShares().ToDec(), shareOutAmount.ToDec(), spreadFactor, + p.GetTakerFee(ctx), ).Ceil().TruncateInt() if !tokenInAmount.IsPositive() { @@ -933,6 +941,7 @@ func (p *Pool) JoinPoolTokenInMaxShareAmountOut( p.GetTotalShares().ToDec(), shareOutAmount.ToDec(), p.GetSpreadFactor(ctx), + p.GetTakerFee(ctx), ).TruncateInt() if !tokenInAmount.IsPositive() { @@ -964,6 +973,7 @@ func (p *Pool) ExitSwapExactAmountOut( p.GetTotalShares().ToDec(), tokenOut.Amount.ToDec(), p.GetSpreadFactor(ctx), + p.GetTakerFee(ctx), p.GetExitFee(ctx), ).TruncateInt() diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 58f32a33af2..866a6b25ba6 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -675,6 +675,7 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { initialTotalShares, initialCalcTokenOut.ToDec(), spreadFactorDec, + sdk.ZeroDec(), ) inverseCalcTokenOut := balancer.CalcSingleAssetInGivenPoolSharesOut( @@ -683,6 +684,7 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { initialTotalShares.Add(actualSharesOut), actualSharesOut, spreadFactorDec, + sdk.ZeroDec(), ) tol := sdk.NewDec(1) diff --git a/x/gamm/pool-models/stableswap/amm.go b/x/gamm/pool-models/stableswap/amm.go index 88f4d567145..cc7690d51a8 100644 --- a/x/gamm/pool-models/stableswap/amm.go +++ b/x/gamm/pool-models/stableswap/amm.go @@ -194,7 +194,8 @@ func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, spreadFa } // amm input = tokenIn * (1 - spread factor) - ammIn := tokenInDec.Mul(oneMinus(spreadFactor)) + totalFee := spreadFactor.Add(p.PoolParams.TakerFee) + ammIn := tokenInDec.Mul(oneMinus(totalFee)) // We are solving for the amount of token out, hence x = tokenOutSupply, y = tokenInSupply // fmt.Printf("outSupply %s, inSupply %s, remReservs %s, ammIn %s\n ", tokenOutSupply, tokenInSupply, remReserves, ammIn) cfmmOut := solveCfmm(tokenOutSupply, tokenInSupply, remReserves, ammIn) @@ -223,7 +224,8 @@ func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, spreadF // We invert that negative here. cfmmIn = cfmmIn.Neg() // divide by (1 - spread factor) to force a corresponding increase in input asset - inAmt := cfmmIn.QuoRoundUp(oneMinus(spreadFactor)) + totalFee := spreadFactor.Add(p.PoolParams.TakerFee) + inAmt := cfmmIn.QuoRoundUp(oneMinus(totalFee)) inCoinAmt := p.getDescaledPoolAmt(tokenInDenom, inAmt) return inCoinAmt, nil } @@ -246,7 +248,8 @@ func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor sdk.Dec) if err != nil { return sdk.Int{}, err } - oneMinusSpreadFactor := sdk.OneDec().Sub(spreadFactor.Mul(spreadFactorApplicableRatio)) + totalFee := spreadFactor.Add(p.PoolParams.TakerFee) + oneMinusSpreadFactor := sdk.OneDec().Sub(totalFee.Mul(spreadFactorApplicableRatio)) tokenInAmtAfterFee := tokenIn.Amount.ToDec().Mul(oneMinusSpreadFactor).TruncateInt() return cfmm_common.BinarySearchSingleAssetJoin(p, sdk.NewCoin(tokenIn.Denom, tokenInAmtAfterFee), poolWithAddedLiquidityAndShares) diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index 6235d25a7ac..5492fc9389d 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -119,6 +119,10 @@ func (p Pool) GetType() poolmanagertypes.PoolType { return poolmanagertypes.Stableswap } +func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { + p.PoolParams.TakerFee = newTakerFee +} + // CONTRACT: scaling factors follow the same index with pool liquidity denoms func (p Pool) GetScalingFactorByDenom(denom string) uint64 { for i, coin := range p.PoolLiquidity { diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index 832af8d9cb9..88a39475731 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -57,6 +57,7 @@ type CFMMPoolI interface { // GetExitFee returns the pool's exit fee, based on the current state. // Pools may choose to make their exit fees dependent upon state. GetExitFee(ctx sdk.Context) sdk.Dec + SetTakerFee(newTakerFee sdk.Dec) } // PoolAmountOutExtension is an extension of the PoolI diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index ce8e27251c0..f4cb25eecf6 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -12,6 +12,12 @@ func (k Keeper) GetNextPoolIdAndIncrement(ctx sdk.Context) uint64 { return k.getNextPoolIdAndIncrement(ctx) } +func (k Keeper) GetOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route types.MultihopRoute) ( + totalPathSpreadFactor sdk.Dec, sumOfSpreadFactors sdk.Dec, err error, +) { + return k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, route) +} + // SetPoolRoutesUnsafe sets the given routes to the poolmanager keeper // to allow routing from a pool type to a certain swap module. // For example, balancer -> gamm. @@ -36,6 +42,10 @@ func (k Keeper) ValidateCreatedPool(ctx sdk.Context, poolId uint64, pool types.P return k.validateCreatedPool(poolId, pool) } +func (k Keeper) IsOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { + return k.isOsmoRoutedMultihop(ctx, route, inDenom, outDenom) +} + func (k Keeper) CreateMultihopExpectedSwapOuts( ctx sdk.Context, route []types.SwapAmountOutRoute, @@ -43,3 +53,12 @@ func (k Keeper) CreateMultihopExpectedSwapOuts( ) ([]sdk.Int, error) { return k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } + +func (k Keeper) CreateOsmoMultihopExpectedSwapOuts( + ctx sdk.Context, + route []types.SwapAmountOutRoute, + tokenOut sdk.Coin, + cumulativeRouteSwapFee, sumOfSwapFees sdk.Dec, +) ([]sdk.Int, error) { + return k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, cumulativeRouteSwapFee, sumOfSwapFees) +} diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index b91daf24966..e2ec8ef6551 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -31,6 +31,11 @@ func (k Keeper) RouteExactAmountIn( tokenIn sdk.Coin, tokenOutMinAmount sdk.Int, ) (tokenOutAmount sdk.Int, err error) { + var ( + isMultiHopRouted bool + routeSpreadFactor sdk.Dec + sumOfSpreadFactors sdk.Dec + ) poolManagerParams := k.GetParams(ctx) // Ensure that provided route is not empty and has valid denom format. @@ -39,6 +44,24 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } + // In this loop (isOsmoRoutedMultihop), we check if: + // - the routeStep is of length 2 + // - routeStep 1 and routeStep 2 don't trade via the same pool + // - routeStep 1 contains uosmo + // - both routeStep 1 and routeStep 2 are incentivized pools + // + // If all of the above is true, then we collect the additive and max fee between the + // two pools to later calculate the following: + // total_spread_factor = max(spread_factor1, spread_factor2) + // fee_per_pool = total_spread_factor * ((pool_fee) / (spread_factor1 + spread_factor2)) + if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenOutDenom, tokenIn.Denom) { + isMultiHopRouted = true + routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) + if err != nil { + return sdk.Int{}, err + } + } + // Iterate through the route and execute a series of swaps through each pool. for i, routeStep := range route { // To prevent the multihop swap from being interrupted prematurely, we keep @@ -66,10 +89,16 @@ func (k Keeper) RouteExactAmountIn( } spreadFactor := pool.GetSpreadFactor(ctx) + + // If we determined the route is an osmo multi-hop and both routes are incentivized, + // we modify the spread factor accordingly. + if isMultiHopRouted { + spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) + } + takerFee := pool.GetTakerFee(ctx) - totalFees := spreadFactor.Add(takerFee) - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, totalFees) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -189,10 +218,9 @@ func (k Keeper) SwapExactAmountIn( spreadFactor := pool.GetSpreadFactor(ctx) takerFee := pool.GetTakerFee(ctx) - totalFees := spreadFactor.Add(takerFee) // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, totalFees) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -248,6 +276,12 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( route []types.SwapAmountInRoute, tokenIn sdk.Coin, ) (tokenOutAmount sdk.Int, err error) { + var ( + isMultiHopRouted bool + routeSpreadFactor sdk.Dec + sumOfSpreadFactors sdk.Dec + ) + // recover from panic defer func() { if r := recover(); r != nil { @@ -261,6 +295,14 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( return sdk.Int{}, err } + if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenOutDenom, tokenIn.Denom) { + isMultiHopRouted = true + routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) + if err != nil { + return sdk.Int{}, err + } + } + for _, routeStep := range route { swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) if err != nil { @@ -274,10 +316,14 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := poolI.GetTakerFee(ctx) - totalFees := spreadFactor.Add(takerFee) - tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, totalFees) + // If we determined the routeStep is an osmo multi-hop and both route are incentivized, + // we modify the swap fee accordingly. + if isMultiHopRouted { + spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) + } + + tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -305,6 +351,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, tokenInMaxAmount sdk.Int, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { + isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} poolManagerParams := k.GetParams(ctx) // Ensure that provided route is not empty and has valid denom format. @@ -320,8 +367,30 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } }() + // In this loop (isOsmoRoutedMultihop), we check if: + // - the routeStep is of length 2 + // - routeStep 1 and routeStep 2 don't trade via the same pool + // - routeStep 1 contains uosmo + // - both routeStep 1 and routeStep 2 are incentivized pools + // + // if all of the above is true, then we collect the additive and max fee between the two pools to later calculate the following: + // total_spread_factor = total_spread_factor = max(spread_factor1, spread_factor2) + // fee_per_pool = total_spread_factor * ((pool_fee) / (spread_factor1 + spread_factor2)) var insExpected []sdk.Int - insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) + isMultiHopRouted = k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenInDenom, tokenOut.Denom) + + // Determine what the estimated input would be for each pool along the multi-hop routeStep + // if we determined the routeStep is an osmo multi-hop and both route are incentivized, + // we utilize a separate function that calculates the discounted swap fees + if isMultiHopRouted { + routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) + if err != nil { + return sdk.Int{}, err + } + insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, routeSpreadFactor, sumOfSpreadFactors) + } else { + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) + } if err != nil { return sdk.Int{}, err @@ -361,10 +430,16 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } spreadFactor := pool.GetSpreadFactor(ctx) + + // If we determined the routeStep is an osmo multi-hop and both route are incentivized, + // we modify the swap fee accordingly. + if isMultiHopRouted { + spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) + } + takerFee := pool.GetTakerFee(ctx) - totalFees := spreadFactor.Add(takerFee) - _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, totalFees) + _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) if swapErr != nil { return sdk.Int{}, swapErr } @@ -496,6 +571,7 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( route []types.SwapAmountOutRoute, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { + isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} var insExpected []sdk.Int // recover from panic @@ -511,8 +587,22 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( return sdk.Int{}, err } + if k.isOsmoRoutedMultihop(ctx, routeStep, route[0].TokenInDenom, tokenOut.Denom) { + isMultiHopRouted = true + routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) + if err != nil { + return sdk.Int{}, err + } + } + // Determine what the estimated input would be for each pool along the multi-hop route - insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) + // if we determined the route is an osmo multi-hop and both routes are incentivized, + // we utilize a separate function that calculates the discounted spread factors + if isMultiHopRouted { + insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, routeSpreadFactor, sumOfSpreadFactors) + } else { + insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) + } if err != nil { return sdk.Int{}, err } @@ -560,6 +650,63 @@ func (k Keeper) AllPools( return sortedPools, nil } +// IsOsmoRoutedMultihop determines if a multi-hop swap involves OSMO, as one of the intermediary tokens. +func (k Keeper) isOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, inDenom, outDenom string) (isRouted bool) { + if route.Length() != 2 { + return false + } + intemediateDenoms := route.IntermediateDenoms() + if len(intemediateDenoms) != 1 || intemediateDenoms[0] != appparams.BaseCoinUnit { + return false + } + if inDenom == outDenom { + return false + } + poolIds := route.PoolIds() + if poolIds[0] == poolIds[1] { + return false + } + + route0Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[0]) + route1Incentivized := k.poolIncentivesKeeper.IsPoolIncentivized(ctx, poolIds[1]) + + return route0Incentivized && route1Incentivized +} + +// getOsmoRoutedMultihopTotalSpreadFactor calculates and returns the average swap fee and the sum of swap fees for +// a given route. For the former, it sets a lower bound of the highest swap fee pool in the route to ensure total +// swap fees for a route are never more than halved. +func (k Keeper) getOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route types.MultihopRoute) ( + totalPathSpreadFactor sdk.Dec, sumOfSpreadFactors sdk.Dec, err error, +) { + additiveSpreadFactor := sdk.ZeroDec() + maxSpreadFactor := sdk.ZeroDec() + + for _, poolId := range route.PoolIds() { + swapModule, err := k.GetPoolModule(ctx, poolId) + if err != nil { + return sdk.Dec{}, sdk.Dec{}, err + } + + pool, poolErr := swapModule.GetPool(ctx, poolId) + if poolErr != nil { + return sdk.Dec{}, sdk.Dec{}, poolErr + } + SpreadFactor := pool.GetSpreadFactor(ctx) + additiveSpreadFactor = additiveSpreadFactor.Add(SpreadFactor) + maxSpreadFactor = sdk.MaxDec(maxSpreadFactor, SpreadFactor) + } + + // We divide by 2 to get the average since OSMO-routed multihops always have exactly 2 pools. + averageSpreadFactor := additiveSpreadFactor.QuoInt64(2) + + // We take the max here as a guardrail to ensure that there is a lowerbound on the swap fee for the + // whole route equivalent to the highest fee pool + routeSpreadFactor := sdk.MaxDec(maxSpreadFactor, averageSpreadFactor) + + return routeSpreadFactor, additiveSpreadFactor, nil +} + // createMultihopExpectedSwapOuts defines the output denom and output amount for the last pool in // the routeStep of pools the caller is intending to hop through in a fixed-output multihop tx. It estimates the input // amount for this last pool and then chains that input as the output of the previous pool in the routeStep, repeating @@ -600,6 +747,40 @@ func (k Keeper) createMultihopExpectedSwapOuts( return insExpected, nil } +// createOsmoMultihopExpectedSwapOuts does the same as createMultihopExpectedSwapOuts, however discounts the swap fee. +func (k Keeper) createOsmoMultihopExpectedSwapOuts( + ctx sdk.Context, + route []types.SwapAmountOutRoute, + tokenOut sdk.Coin, + cumulativeRouteSpreadFactor, sumOfSpreadFactors sdk.Dec, +) ([]sdk.Int, error) { + insExpected := make([]sdk.Int, len(route)) + for i := len(route) - 1; i >= 0; i-- { + routeStep := route[i] + + swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) + if err != nil { + return nil, err + } + + poolI, err := swapModule.GetPool(ctx, routeStep.PoolId) + if err != nil { + return nil, err + } + + spreadFactor := poolI.GetSpreadFactor(ctx) + tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors)))) + if err != nil { + return nil, err + } + + insExpected[i] = tokenIn.Amount + tokenOut = tokenIn + } + + return insExpected, nil +} + // GetTotalPoolLiquidity gets the total liquidity for a given poolId. func (k Keeper) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) { swapModule, err := k.GetPoolModule(ctx, poolId) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 40cf1fad2b7..4e6e8f7e86f 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -362,16 +362,17 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { // - fee reduction is applied correctly func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { tests := []struct { - name string - poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec - poolType []types.PoolType - routes []types.SwapAmountInRoute - incentivizedGauges []uint64 - tokenIn sdk.Coin - tokenOutMinAmount sdk.Int - spreadFactor sdk.Dec - expectError bool + name string + poolCoins []sdk.Coins + poolSpreadFactor []sdk.Dec + poolType []types.PoolType + routes []types.SwapAmountInRoute + incentivizedGauges []uint64 + tokenIn sdk.Coin + tokenOutMinAmount sdk.Int + spreadFactor sdk.Dec + expectError bool + expectReducedFeeApplied bool }{ { name: "One route: Swap - [foo -> bar], 1 percent fee", @@ -409,6 +410,52 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), }, + { + name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: true, + }, + { + name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: true, + }, { name: "Three routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", poolCoins: []sdk.Coins{ @@ -432,9 +479,10 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: false, }, { name: "Two routes: Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", @@ -456,9 +504,35 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: false, + }, + { + name: "Two routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), + sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), + sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + routes: []types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: true, }, { name: "Three routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", @@ -486,9 +560,10 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + expectReducedFeeApplied: false, }, { name: "[Concentrated] One route: Swap - [foo -> bar], 1 percent fee", @@ -600,7 +675,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcInAmountAsSeparatePoolSwaps(tc.routes, tc.tokenIn) + expectedMultihopTokenOutAmount := s.calcInAmountAsSeparatePoolSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenIn) // execute the swap multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenIn, tc.tokenOutMinAmount) @@ -619,16 +694,17 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { // - fee reduction is applied correctly func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { tests := []struct { - name string - poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec - poolType []types.PoolType - routes []types.SwapAmountOutRoute - incentivizedGauges []uint64 - tokenOut sdk.Coin - tokenInMaxAmount sdk.Int - spreadFactor sdk.Dec - expectError bool + name string + poolCoins []sdk.Coins + poolSpreadFactor []sdk.Dec + poolType []types.PoolType + routes []types.SwapAmountOutRoute + incentivizedGauges []uint64 + tokenOut sdk.Coin + tokenInMaxAmount sdk.Int + spreadFactor sdk.Dec + expectError bool + expectReducedFeeApplied bool }{ { name: "One route: Swap - [foo -> bar], 1 percent fee", @@ -667,6 +743,52 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { tokenInMaxAmount: sdk.NewInt(90000000), tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), }, + { + name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: foo, + }, + { + PoolId: 2, + TokenInDenom: uosmo, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + expectReducedFeeApplied: true, + }, + { + name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, (pool 1) 1 percent fee, (pool 2) 10 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: foo, + }, + { + PoolId: 2, + TokenInDenom: uosmo, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + expectReducedFeeApplied: true, + }, { name: "Three routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", poolCoins: []sdk.Coins{ @@ -690,9 +812,10 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), + expectReducedFeeApplied: false, }, { name: "Two routes: Swap between four asset pools - [foo -> bar](pool 1) - [bar -> baz](pool 2), all pools 1 percent fee", @@ -714,9 +837,35 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + expectReducedFeeApplied: false, + }, + { + name: "Two routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2), with a half fee applied, both pools 1 percent fee", + poolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), + sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount), + sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. + }, + poolType: []types.PoolType{types.Balancer, types.Balancer}, + poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + routes: []types.SwapAmountOutRoute{ + { + PoolId: 1, + TokenInDenom: foo, + }, + { + PoolId: 2, + TokenInDenom: uosmo, + }, + }, + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + expectReducedFeeApplied: true, }, { name: "Three routes: Swap between four asset pools - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", @@ -744,9 +893,10 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: baz, }, }, - incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, + tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), + tokenInMaxAmount: sdk.NewInt(90000000), + expectReducedFeeApplied: false, }, { name: "[Cosmwasm] One route: Swap - [foo -> bar], 1 percent fee", @@ -817,7 +967,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcOutAmountAsSeparateSwaps(tc.routes, tc.tokenOut) + expectedMultihopTokenOutAmount := s.calcOutAmountAsSeparateSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenOut) // execute the swap multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenInMaxAmount, tc.tokenOut) // compare the expected tokenOut to the actual tokenOut @@ -1204,52 +1354,119 @@ func (s *KeeperTestSuite) makeGaugesIncentivized(incentivizedGauges []uint64) { s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, distInfo) } -func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(osmoFeeReduced bool, routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() - nextTokenOut := tokenOut - for i := len(routes) - 1; i >= 0; i-- { - hop := routes[i] - hopPool, err := s.App.PoolManagerKeeper.GetPool(cacheCtx, hop.PoolId) + if osmoFeeReduced { + // extract route from swap + route := types.SwapAmountOutRoutes(routes) + // utilizing the extracted route, determine the routeSpreadFactor and sumOfspreadFactors + // these two variables are used to calculate the overall swap fee utilizing the following formula + // spreadFactor = routeSpreadFactor * ((pool_fee) / (sumOfspreadFactors)) + routeSpreadFactor, sumOfSpreadFactors, err := s.App.PoolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, route) s.Require().NoError(err) - updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) + nextTokenOut := tokenOut + for i := len(routes) - 1; i >= 0; i-- { + hop := routes[i] + // extract the current pool's swap fee + hopPool, err := s.App.GAMMKeeper.GetPoolAndPoke(cacheCtx, hop.PoolId) + s.Require().NoError(err) + currentPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) + // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee + spreadFactor := routeSpreadFactor.Mul((currentPoolSpreadFactor.Quo(sumOfSpreadFactors))) - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) - s.Require().NoError(err) + takerFee := hopPool.GetTakerFee(cacheCtx) + totalFees := spreadFactor.Add(takerFee) - tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) - s.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + s.Require().NoError(err) + + // we then do individual swaps until we reach the end of the swap route + tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, totalFees) + s.Require().NoError(err) + nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + } + return nextTokenOut + } else { + nextTokenOut := tokenOut + for i := len(routes) - 1; i >= 0; i-- { + hop := routes[i] + hopPool, err := s.App.PoolManagerKeeper.GetPool(cacheCtx, hop.PoolId) + s.Require().NoError(err) + updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) + + takerFee := hopPool.GetTakerFee(cacheCtx) + totalFees := updatedPoolSpreadFactor.Add(takerFee) + + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + s.Require().NoError(err) + + tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, totalFees) + s.Require().NoError(err) + nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + } + return nextTokenOut } - return nextTokenOut } // calcInAmountAsSeparatePoolSwaps calculates the output amount of a series of swaps on PoolManager pools while factoring in reduces swap fee changes. // If its GAMM pool functions directly to ensure the poolmanager functions route to the correct modules. It it's CL pool functions directly to ensure the // poolmanager functions route to the correct modules. -func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() - nextTokenIn := tokenIn - - for _, hop := range routes { - swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + if osmoFeeReduced { + // extract route from swap + route := types.SwapAmountInRoutes(routes) + // utilizing the extracted route, determine the routeSpreadFactor and sumOfSpreadFactors + // these two variables are used to calculate the overall swap fee utilizing the following formula + // spreadFactor = routeSpreadFactor * ((pool_fee) / (sumOfSpreadFactors)) + routeSpreadFactor, sumOfSpreadFactors, err := s.App.PoolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, route) s.Require().NoError(err) + nextTokenIn := tokenIn - pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) - s.Require().NoError(err) + for _, hop := range routes { + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + s.Require().NoError(err) + + pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) + s.Require().NoError(err) - // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee - spreadFactor := pool.GetSpreadFactor(cacheCtx) - takerFee := pool.GetTakerFee(s.Ctx) - totalFee := spreadFactor.Add(takerFee) + // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee + spreadFactor := routeSpreadFactor.Mul(pool.GetSpreadFactor(cacheCtx).Quo(sumOfSpreadFactors)) - // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFee) - s.Require().NoError(err) + takerFee := pool.GetTakerFee(cacheCtx) + totalFees := spreadFactor.Add(takerFee) - nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) + // we then do individual swaps until we reach the end of the swap route + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFees) + s.Require().NoError(err) + nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) + } + return nextTokenIn + } else { + nextTokenIn := tokenIn + for _, hop := range routes { + swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) + s.Require().NoError(err) + + pool, err := swapModule.GetPool(s.Ctx, hop.PoolId) + s.Require().NoError(err) + + // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee + spreadFactor := pool.GetSpreadFactor(cacheCtx) + + takerFee := pool.GetTakerFee(cacheCtx) + totalFees := spreadFactor.Add(takerFee) + + // we then do individual swaps until we reach the end of the swap route + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFees) + s.Require().NoError(err) + + nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) + + } + return nextTokenIn } - return nextTokenIn } // TODO: abstract SwapAgainstBalancerPool and SwapAgainstConcentratedPool diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go index b0e73167292..d102f02698d 100644 --- a/x/protorev/keeper/keeper_test.go +++ b/x/protorev/keeper/keeper_test.go @@ -57,6 +57,11 @@ func TestKeeperTestSuite(t *testing.T) { func (s *KeeperTestSuite) SetupTest() { s.Setup() + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.DefaultTakerFee = sdk.ZeroDec() + poolManagerParams.StableswapTakerFee = sdk.ZeroDec() + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) + // Genesis on init should be the same as the default genesis exportDefaultGenesis := s.App.ProtoRevKeeper.ExportGenesis(s.Ctx) s.Require().Equal(exportDefaultGenesis, types.DefaultGenesis()) diff --git a/x/protorev/keeper/rebalance_test.go b/x/protorev/keeper/rebalance_test.go index c3bda8d0f72..f1e4dba2797 100644 --- a/x/protorev/keeper/rebalance_test.go +++ b/x/protorev/keeper/rebalance_test.go @@ -737,6 +737,7 @@ func (s *KeeperTestSuite) TestRemainingPoolPointsForTx() { } func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { + s.SetupTest() s.Run("Extended search on stable pools", func() { route := keeper.RouteMetaData{ Route: extendedRangeRoute, From e57f4a627ac4f8bbc309865a46ed18105e3bef45 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 15 Aug 2023 19:23:54 -0500 Subject: [PATCH 09/83] correct taker fee extraction --- x/poolmanager/router.go | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index e2ec8ef6551..9c98e7dddc4 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -10,7 +10,6 @@ import ( appparams "github.com/osmosis-labs/osmosis/v17/app/params" "github.com/osmosis-labs/osmosis/osmoutils" - cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" ) @@ -103,7 +102,7 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) + err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) if err != nil { return sdk.Int{}, err } @@ -225,7 +224,7 @@ func (k Keeper) SwapExactAmountIn( return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) + err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) if err != nil { return sdk.Int{}, err } @@ -445,7 +444,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) - err = k.extractTakerFeeToFeePool(ctx, pool, tokenIn, takerFee, poolManagerParams) + err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) if err != nil { return sdk.Int{}, err } @@ -817,24 +816,11 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { // extractTakerFeeToFeePool takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params) error { - var relevantPoolAddress sdk.AccAddress +func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params, sender sdk.AccAddress) error { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName baseDenom := appparams.BaseCoinUnit - if pool.GetType() == types.Concentrated { - // If the pool being swapped from is a concentrated pool, the fee is sent from the spread rewards address - concentratedTypePool, ok := pool.(cltypes.ConcentratedPoolExtension) - if !ok { - return fmt.Errorf("pool %d is not a concentrated pool", pool.GetId()) - } - relevantPoolAddress = concentratedTypePool.GetSpreadRewardsAddress() - } else { - // If the pool being swapped from is not a concentrated pool, the fee is sent from the pool address - relevantPoolAddress = pool.GetAddress() - } - // Take the taker fee from the input token and send it to the fee pool module account takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.TruncateInt()) @@ -847,7 +833,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke // Osmo community pool funds is a direct send osmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.CommunityPool) osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, relevantPoolAddress) + err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { return err } @@ -858,7 +844,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke // We could stream these rewards via the fee collector account, but this is decision to be made by governance. osmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.StakingRewards) osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToStakingRewardsDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) if err != nil { return err } @@ -873,7 +859,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke if denomIsWhitelisted { nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, relevantPoolAddress) + err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) if err != nil { return err } @@ -882,7 +868,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { return err } @@ -893,7 +879,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, pool types.PoolI, toke // Non Osmo staking rewards are sent to the non native fee pool module account nonOsmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards) nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToStakingRewardsDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, relevantPoolAddress, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) if err != nil { return err } From 547232fb8cb1d1198ea8eaf5279786c8af8b569f Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 15 Aug 2023 19:29:38 -0500 Subject: [PATCH 10/83] regen mocks --- tests/mocks/cfmm_pool.go | 36 ++++++++++++++++++++++++++++++++++++ tests/mocks/cl_pool.go | 12 ++++++++++++ 2 files changed, 48 insertions(+) diff --git a/tests/mocks/cfmm_pool.go b/tests/mocks/cfmm_pool.go index 4c0e505c691..aa9add9da17 100644 --- a/tests/mocks/cfmm_pool.go +++ b/tests/mocks/cfmm_pool.go @@ -322,6 +322,18 @@ func (mr *MockCFMMPoolIMockRecorder) Reset() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockCFMMPoolI)(nil).Reset)) } +// SetTakerFee mocks base method. +func (m *MockCFMMPoolI) SetTakerFee(newTakerFee types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTakerFee", newTakerFee) +} + +// SetTakerFee indicates an expected call of SetTakerFee. +func (mr *MockCFMMPoolIMockRecorder) SetTakerFee(newTakerFee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTakerFee", reflect.TypeOf((*MockCFMMPoolI)(nil).SetTakerFee), newTakerFee) +} + // SpotPrice mocks base method. func (m *MockCFMMPoolI) SpotPrice(ctx types.Context, quoteAssetDenom, baseAssetDenom string) (types.Dec, error) { m.ctrl.T.Helper() @@ -747,6 +759,18 @@ func (mr *MockPoolAmountOutExtensionMockRecorder) Reset() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).Reset)) } +// SetTakerFee mocks base method. +func (m *MockPoolAmountOutExtension) SetTakerFee(newTakerFee types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTakerFee", newTakerFee) +} + +// SetTakerFee indicates an expected call of SetTakerFee. +func (mr *MockPoolAmountOutExtensionMockRecorder) SetTakerFee(newTakerFee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTakerFee", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).SetTakerFee), newTakerFee) +} + // SpotPrice mocks base method. func (m *MockPoolAmountOutExtension) SpotPrice(ctx types.Context, quoteAssetDenom, baseAssetDenom string) (types.Dec, error) { m.ctrl.T.Helper() @@ -1142,6 +1166,18 @@ func (mr *MockWeightedPoolExtensionMockRecorder) Reset() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockWeightedPoolExtension)(nil).Reset)) } +// SetTakerFee mocks base method. +func (m *MockWeightedPoolExtension) SetTakerFee(newTakerFee types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTakerFee", newTakerFee) +} + +// SetTakerFee indicates an expected call of SetTakerFee. +func (mr *MockWeightedPoolExtensionMockRecorder) SetTakerFee(newTakerFee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTakerFee", reflect.TypeOf((*MockWeightedPoolExtension)(nil).SetTakerFee), newTakerFee) +} + // SpotPrice mocks base method. func (m *MockWeightedPoolExtension) SpotPrice(ctx types.Context, quoteAssetDenom, baseAssetDenom string) (types.Dec, error) { m.ctrl.T.Helper() diff --git a/tests/mocks/cl_pool.go b/tests/mocks/cl_pool.go index efa42a3bf3e..89e4e86ae5d 100644 --- a/tests/mocks/cl_pool.go +++ b/tests/mocks/cl_pool.go @@ -379,6 +379,18 @@ func (mr *MockConcentratedPoolExtensionMockRecorder) SetLastLiquidityUpdate(newT return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetLastLiquidityUpdate", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).SetLastLiquidityUpdate), newTime) } +// SetTakerFee mocks base method. +func (m *MockConcentratedPoolExtension) SetTakerFee(newTakerFee types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTakerFee", newTakerFee) +} + +// SetTakerFee indicates an expected call of SetTakerFee. +func (mr *MockConcentratedPoolExtensionMockRecorder) SetTakerFee(newTakerFee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTakerFee", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).SetTakerFee), newTakerFee) +} + // SetTickSpacing mocks base method. func (m *MockConcentratedPoolExtension) SetTickSpacing(newTickSpacing uint64) { m.ctrl.T.Helper() From 5ea549bd9eb4cdb2f8b7a517c99084bc09c13757 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 16 Aug 2023 20:05:06 -0500 Subject: [PATCH 11/83] abstract taker fee to pool manager (highest lvl) --- .../cosmwasmpool/v1beta1/model/pool.proto | 5 + x/concentrated-liquidity/swaps.go | 6 +- x/cosmwasmpool/model/msgs.go | 2 +- x/cosmwasmpool/model/pool.go | 7 +- x/cosmwasmpool/model/pool.pb.go | 106 +++++++++++++----- x/cosmwasmpool/pool_module_test.go | 3 +- x/gamm/keeper/msg_server_test.go | 7 +- x/gamm/pool-models/balancer/amm.go | 6 +- x/gamm/pool-models/balancer/pool.go | 6 +- x/gamm/pool-models/stableswap/amm.go | 9 +- x/gamm/simulation/sim_msgs.go | 10 +- x/poolmanager/export_test.go | 8 ++ x/poolmanager/msg_server_test.go | 4 +- x/poolmanager/router.go | 81 ++++++++----- x/poolmanager/router_test.go | 51 +++++---- 15 files changed, 205 insertions(+), 106 deletions(-) diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto index f94df821a36..fb80b3d02cb 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto @@ -18,4 +18,9 @@ message CosmWasmPool { uint64 code_id = 3; bytes instantiate_msg = 4 [ (gogoproto.moretags) = "yaml:\"instantiate_msg\"" ]; + string taker_fee = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; } diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index b913e79a3aa..fb5f0a3a3ae 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -349,8 +349,7 @@ func (k Keeper) computeOutAmtGivenIn( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - totalFees := spreadFactor.Add(p.GetTakerFee(ctx)) - swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, totalFees, tokenInMin.Denom, priceLimit) + swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInMin.Denom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } @@ -479,8 +478,7 @@ func (k Keeper) computeInAmtGivenOut( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - totalFees := spreadFactor.Add(p.GetTakerFee(ctx)) - swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, totalFees, tokenInDenom, priceLimit) + swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInDenom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } diff --git a/x/cosmwasmpool/model/msgs.go b/x/cosmwasmpool/model/msgs.go index 86cb43e6326..63883be9ec1 100644 --- a/x/cosmwasmpool/model/msgs.go +++ b/x/cosmwasmpool/model/msgs.go @@ -79,7 +79,7 @@ func (msg MsgCreateCosmWasmPool) InitialLiquidity() sdk.Coins { } func (msg MsgCreateCosmWasmPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { - poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg) + poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg, takerFee) return poolI, nil } diff --git a/x/cosmwasmpool/model/pool.go b/x/cosmwasmpool/model/pool.go index 1a601a84753..306f04b940f 100644 --- a/x/cosmwasmpool/model/pool.go +++ b/x/cosmwasmpool/model/pool.go @@ -23,13 +23,14 @@ var ( ) // NewCosmWasmPool creates a new CosmWasm pool with the specified parameters. -func NewCosmWasmPool(poolId uint64, codeId uint64, instantiateMsg []byte) *Pool { +func NewCosmWasmPool(poolId uint64, codeId uint64, instantiateMsg []byte, takerFee sdk.Dec) *Pool { pool := Pool{ CosmWasmPool: CosmWasmPool{ ContractAddress: "", // N.B. This is to be set in InitializePool() PoolId: poolId, CodeId: codeId, InstantiateMsg: instantiateMsg, + TakerFee: takerFee, }, WasmKeeper: nil, // N.B.: this is set in InitializePool(). } @@ -66,9 +67,7 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { } func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { - request := msg.GetTakerFeeQueryMsg{} - response := cosmwasmutils.MustQuery[msg.GetTakerFeeQueryMsg, msg.GetTakerFeeQueryMsgResponse](ctx, p.WasmKeeper, p.ContractAddress, request) - return response.TakerFee + return p.TakerFee } // IsActive returns true if the pool is active diff --git a/x/cosmwasmpool/model/pool.pb.go b/x/cosmwasmpool/model/pool.pb.go index d7f3c264002..e486355a649 100644 --- a/x/cosmwasmpool/model/pool.pb.go +++ b/x/cosmwasmpool/model/pool.pb.go @@ -6,6 +6,7 @@ package model import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" @@ -26,10 +27,11 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type CosmWasmPool struct { - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - CodeId uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - InstantiateMsg []byte `protobuf:"bytes,4,opt,name=instantiate_msg,json=instantiateMsg,proto3" json:"instantiate_msg,omitempty" yaml:"instantiate_msg"` + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + CodeId uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + InstantiateMsg []byte `protobuf:"bytes,4,opt,name=instantiate_msg,json=instantiateMsg,proto3" json:"instantiate_msg,omitempty" yaml:"instantiate_msg"` + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *CosmWasmPool) Reset() { *m = CosmWasmPool{} } @@ -73,29 +75,33 @@ func init() { } var fileDescriptor_a0cb64564a744af1 = []byte{ - // 350 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x3f, 0x4f, 0xc2, 0x40, - 0x18, 0xc6, 0x7b, 0x8a, 0x18, 0x1b, 0x22, 0xda, 0x18, 0x41, 0x34, 0x2d, 0xe9, 0xc4, 0x42, 0x2f, - 0xc4, 0x41, 0xc3, 0x26, 0x24, 0x26, 0x0c, 0x26, 0xa6, 0x8b, 0x89, 0x4b, 0x73, 0xfd, 0x63, 0x6d, - 0xd2, 0xe3, 0x25, 0xbc, 0x07, 0xea, 0x37, 0x70, 0x74, 0x74, 0xe4, 0x43, 0xf8, 0x21, 0x8c, 0x13, - 0xa3, 0x13, 0x21, 0xf0, 0x0d, 0xf8, 0x04, 0xe6, 0x7a, 0x25, 0x41, 0xb6, 0x3e, 0xbf, 0xe7, 0xd7, - 0xdc, 0xdd, 0xfb, 0xea, 0x4d, 0x40, 0x0e, 0x98, 0x20, 0x0d, 0x00, 0xf9, 0x0b, 0x43, 0x3e, 0x00, - 0x48, 0xe9, 0xb8, 0xe5, 0x47, 0x82, 0xb5, 0x28, 0x87, 0x30, 0x4a, 0xa9, 0x44, 0xce, 0x60, 0x08, - 0x02, 0x8c, 0x8b, 0x5c, 0x77, 0x36, 0x75, 0x27, 0xd7, 0x6b, 0x67, 0x41, 0x56, 0x7b, 0x99, 0x4b, - 0x55, 0x50, 0x3f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0, 0x34, 0x9f, 0x7b, 0x33, 0x65, 0x3e, - 0xae, 0x03, 0x1d, 0xb7, 0xae, 0xe8, 0xeb, 0xff, 0xcd, 0x65, 0x1b, 0xf3, 0x8b, 0xd9, 0xf4, 0x2e, - 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x59, 0xc9, 0x13, 0x28, 0xde, 0x01, 0x00, 0x00, + // 412 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xb1, 0x6e, 0xd4, 0x40, + 0x10, 0x86, 0xed, 0x90, 0x04, 0x62, 0x45, 0x24, 0x58, 0x88, 0x98, 0x03, 0x79, 0x4f, 0x2e, 0xd0, + 0x35, 0xf6, 0xea, 0x44, 0x01, 0x4a, 0x87, 0x83, 0x22, 0x5d, 0x81, 0x84, 0xdc, 0x20, 0xd1, 0x58, + 0x6b, 0xef, 0xc6, 0x58, 0xf1, 0xde, 0x58, 0x9e, 0x4d, 0x20, 0x6f, 0x40, 0x49, 0x49, 0x99, 0x87, + 0xe0, 0x05, 0xe8, 0x4e, 0x54, 0x57, 0x22, 0x0a, 0x0b, 0xdd, 0xbd, 0xc1, 0x3d, 0x01, 0x5a, 0xaf, + 0x0f, 0x5d, 0xae, 0xf2, 0xfe, 0xff, 0xff, 0x79, 0x67, 0x35, 0x33, 0x4e, 0x08, 0x28, 0x01, 0x4b, + 0xa4, 0x39, 0xa0, 0xfc, 0xcc, 0x50, 0xd6, 0x00, 0x15, 0xbd, 0x1e, 0x67, 0x42, 0xb1, 0x31, 0x95, + 0xc0, 0x45, 0x45, 0xb5, 0x15, 0xd5, 0x0d, 0x28, 0x70, 0x9f, 0xf7, 0x78, 0xb4, 0x89, 0x47, 0x3d, + 0x3e, 0x78, 0x9a, 0x77, 0x71, 0xda, 0xb1, 0xd4, 0x08, 0xf3, 0xe3, 0xe0, 0x71, 0x01, 0x05, 0x18, + 0x5f, 0x9f,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x82, 0xe4, 0x41, 0x77, 0x3e, 0x17, 0xe2, 0xf4, 0xd1, + 0xd7, 0x5b, 0x62, 0x7d, 0xbf, 0x25, 0xd6, 0xaf, 0x1f, 0xe1, 0x9e, 0xee, 0xd8, 0x24, 0x4e, 0x66, + 0x0b, 0xdf, 0x9e, 0x2f, 0x7c, 0xfb, 0xef, 0xc2, 0xb7, 0xbf, 0x2d, 0x7d, 0x6b, 0xbe, 0xf4, 0xad, + 0xdf, 0x4b, 0xdf, 0xfa, 0xf8, 0x7a, 0xa3, 0x64, 0x3f, 0xd8, 0xb0, 0x62, 0x19, 0xae, 0x05, 0xbd, + 0x1e, 0xbf, 0xa2, 0x5f, 0xee, 0xae, 0x46, 0xb7, 0x12, 0xd9, 0x7e, 0x37, 0x9e, 0x97, 0xff, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x81, 0xd8, 0xea, 0x01, 0x3f, 0x02, 0x00, 0x00, } func (m *CosmWasmPool) Marshal() (dAtA []byte, err error) { @@ -118,6 +124,16 @@ func (m *CosmWasmPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintPool(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a if len(m.InstantiateMsg) > 0 { i -= len(m.InstantiateMsg) copy(dAtA[i:], m.InstantiateMsg) @@ -176,6 +192,8 @@ func (m *CosmWasmPool) Size() (n int) { if l > 0 { n += 1 + l + sovPool(uint64(l)) } + l = m.TakerFee.Size() + n += 1 + l + sovPool(uint64(l)) return n } @@ -318,6 +336,40 @@ func (m *CosmWasmPool) Unmarshal(dAtA []byte) error { m.InstantiateMsg = []byte{} } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPool + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthPool + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPool + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPool(dAtA[iNdEx:]) diff --git a/x/cosmwasmpool/pool_module_test.go b/x/cosmwasmpool/pool_module_test.go index ec8ade15683..cf96aa57bf0 100644 --- a/x/cosmwasmpool/pool_module_test.go +++ b/x/cosmwasmpool/pool_module_test.go @@ -29,6 +29,7 @@ type PoolModuleSuite struct { var ( defaultAmount = sdk.NewInt(100) + defaultTakerFee = sdk.MustNewDecFromStr("0.0015") initalDefaultSupply = sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)) defaultDenoms = []string{denomA, denomB} @@ -82,7 +83,7 @@ func (s *PoolModuleSuite) TestInitializePool() { var testPool poolmanagertypes.PoolI if !tc.isInvalidPoolType { - testPool = model.NewCosmWasmPool(defaultPoolId, tc.codeid, tc.instantiateMsg) + testPool = model.NewCosmWasmPool(defaultPoolId, tc.codeid, tc.instantiateMsg, defaultTakerFee) } else { testPool = s.PrepareConcentratedPool() } diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index ede314ee555..782e7972845 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -75,9 +75,10 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { TokenOutDenom: "baz", }, }, - tokenIn: sdk.NewCoin(doesNotExistDenom, sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), - expectError: true, + tokenIn: sdk.NewCoin(doesNotExistDenom, sdk.NewInt(tokenIn)), + tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + expectedMessageEvents: 2, // 2 events get triggered prior to failure. + expectError: true, }, } diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index c22059dc5bb..79b87ae6455 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -124,7 +124,7 @@ func calcPoolSharesOutGivenSingleAssetIn( // deduct spread factor on the in asset. // We don't charge spread factor on the token amount that we imagine as unswapped (the normalized weight). // So effective_swapfee = spread factor * (1 - normalized_token_weight) - tokenAmountInAfterFee := tokenAmountIn.Mul(feeRatio(normalizedTokenWeightIn, spreadFactor.Add(takerFee))) + tokenAmountInAfterFee := tokenAmountIn.Mul(feeRatio(normalizedTokenWeightIn, spreadFactor)) // To figure out the number of shares we add, first notice that in balancer we can treat // the number of shares as linearly related to the `k` value function. This is due to the normalization. // e.g. @@ -203,7 +203,7 @@ func calcSingleAssetInGivenPoolSharesOut( // pool weight is always 1 tokenAmountIn := solveConstantFunctionInvariant(totalPoolSharesSupply.Add(sharesAmountOut), totalPoolSharesSupply, sdk.OneDec(), tokenBalanceIn, normalizedTokenWeightIn).Neg() // deduct spread factor on the in asset - tokenAmountInFeeIncluded := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, spreadFactor.Add(takerFee))) + tokenAmountInFeeIncluded := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, spreadFactor)) return tokenAmountInFeeIncluded } @@ -218,7 +218,7 @@ func calcPoolSharesInGivenSingleAssetOut( spreadFactor, takerFee, exitFee sdk.Dec, ) sdk.Dec { - tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor.Add(takerFee))) + tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor)) // delta poolSupply is positive(total pool shares decreases) // pool weight is always 1 diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index 25f93115d64..efcf92d7811 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -507,8 +507,7 @@ func (p Pool) CalcOutAmtGivenIn( return sdk.Coin{}, err } - totalFee := spreadFactor.Add(p.GetTakerFee(ctx)) - tokenAmountInAfterFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(totalFee)) + tokenAmountInAfterFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(spreadFactor)) poolTokenInBalance := poolAssetIn.Token.Amount.ToDec() poolPostSwapInBalance := poolTokenInBalance.Add(tokenAmountInAfterFee) @@ -575,8 +574,7 @@ func (p Pool) CalcInAmtGivenOut( // and then the spread factor is added to the pool. // Thus in order to give X amount out, we solve the invariant for the invariant input. However invariant input = (1 - spread factor) * trade input. // Therefore we divide by (1 - spread factor) here - totalFee := spreadFactor.Add(p.GetTakerFee(ctx)) - tokenAmountInBeforeFee := tokenAmountIn.Quo(sdk.OneDec().Sub(totalFee)) + tokenAmountInBeforeFee := tokenAmountIn.Quo(sdk.OneDec().Sub(spreadFactor)) // We round up tokenInAmt, as this is whats charged for the swap, for the precise amount out. // Otherwise, the pool would under-charge by this rounding error. diff --git a/x/gamm/pool-models/stableswap/amm.go b/x/gamm/pool-models/stableswap/amm.go index cc7690d51a8..88f4d567145 100644 --- a/x/gamm/pool-models/stableswap/amm.go +++ b/x/gamm/pool-models/stableswap/amm.go @@ -194,8 +194,7 @@ func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, spreadFa } // amm input = tokenIn * (1 - spread factor) - totalFee := spreadFactor.Add(p.PoolParams.TakerFee) - ammIn := tokenInDec.Mul(oneMinus(totalFee)) + ammIn := tokenInDec.Mul(oneMinus(spreadFactor)) // We are solving for the amount of token out, hence x = tokenOutSupply, y = tokenInSupply // fmt.Printf("outSupply %s, inSupply %s, remReservs %s, ammIn %s\n ", tokenOutSupply, tokenInSupply, remReserves, ammIn) cfmmOut := solveCfmm(tokenOutSupply, tokenInSupply, remReserves, ammIn) @@ -224,8 +223,7 @@ func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, spreadF // We invert that negative here. cfmmIn = cfmmIn.Neg() // divide by (1 - spread factor) to force a corresponding increase in input asset - totalFee := spreadFactor.Add(p.PoolParams.TakerFee) - inAmt := cfmmIn.QuoRoundUp(oneMinus(totalFee)) + inAmt := cfmmIn.QuoRoundUp(oneMinus(spreadFactor)) inCoinAmt := p.getDescaledPoolAmt(tokenInDenom, inAmt) return inCoinAmt, nil } @@ -248,8 +246,7 @@ func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor sdk.Dec) if err != nil { return sdk.Int{}, err } - totalFee := spreadFactor.Add(p.PoolParams.TakerFee) - oneMinusSpreadFactor := sdk.OneDec().Sub(totalFee.Mul(spreadFactorApplicableRatio)) + oneMinusSpreadFactor := sdk.OneDec().Sub(spreadFactor.Mul(spreadFactorApplicableRatio)) tokenInAmtAfterFee := tokenIn.Amount.ToDec().Mul(oneMinusSpreadFactor).TruncateInt() return cfmm_common.BinarySearchSingleAssetJoin(p, sdk.NewCoin(tokenIn.Denom, tokenInAmtAfterFee), poolWithAddedLiquidityAndShares) diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index ef2ae316ad4..5008be19f55 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -145,7 +145,10 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont randomCoinSubset := sim.RandSubsetCoins(sdk.NewCoins(sdk.NewCoin(accCoinIn.Denom, accCoinIn.Amount))) // calculate the minimum number of tokens received from input of tokenIn - tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, randomCoinSubset, coinOut.Denom, pool.GetSpreadFactor(ctx)) + // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. + // We therefore need to add the taker fee to the spread factor when calling the calc method. + totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee(ctx)) + tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, randomCoinSubset, coinOut.Denom, totalFees) if err != nil { return nil, err } @@ -183,7 +186,10 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con randomCoinInSubset := osmoutils.MinCoins(sdk.NewCoins(coinIn), sdk.NewCoins(accCoin)) // utilize CalcOutAmtGivenIn to calculate tokenOut and use tokenOut to calculate tokenInMax - tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, pool.GetSpreadFactor(ctx)) + // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. + // We therefore need to add the taker fee to the spread factor when calling the calc method. + totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee(ctx)) + tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, totalFees) if err != nil { return nil, err } diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index f4cb25eecf6..3627ae244d3 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -62,3 +62,11 @@ func (k Keeper) CreateOsmoMultihopExpectedSwapOuts( ) ([]sdk.Int, error) { return k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, cumulativeRouteSwapFee, sumOfSwapFees) } + +func (k Keeper) CalcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + return k.calcTakerFeeExactIn(tokenIn, takerFee) +} + +func (k Keeper) CalcTakerFeeExactOut(tokenOut sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + return k.calcTakerFeeExactOut(tokenOut, takerFee) +} diff --git a/x/poolmanager/msg_server_test.go b/x/poolmanager/msg_server_test.go index fec5f22c294..b26c4633b48 100644 --- a/x/poolmanager/msg_server_test.go +++ b/x/poolmanager/msg_server_test.go @@ -48,7 +48,7 @@ func (s *KeeperTestSuite) TestSplitRouteSwapExactAmountIn() { tokenoutMinAmount: min_amount, expectedSplitRouteSwapEvent: 1, - expectedMessageEvents: 9, // 4 pool creation + 5 events in SplitRouteExactAmountIn keeper methods + expectedMessageEvents: 16, // 4 pool creation + 12 events in SplitRouteExactAmountIn keeper methods }, "error: empty route": { routes: []types.SwapAmountInSplitRoute{}, @@ -134,7 +134,7 @@ func (s *KeeperTestSuite) TestSplitRouteSwapExactAmountOut() { tokenoutMaxAmount: max_amount, expectedSplitRouteSwapEvent: 1, - expectedMessageEvents: 9, // 4 pool creation + 5 events in SplitRouteExactAmountOut keeper methods + expectedMessageEvents: 17, // 4 pool creation + 13 events in SplitRouteExactAmountOut keeper methods }, "error: empty route": { routes: []types.SwapAmountOutSplitRoute{}, diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 9c98e7dddc4..5cda3b6d481 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -96,13 +96,12 @@ func (k Keeper) RouteExactAmountIn( } takerFee := pool.GetTakerFee(ctx) - - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) + tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -218,13 +217,13 @@ func (k Keeper) SwapExactAmountIn( spreadFactor := pool.GetSpreadFactor(ctx) takerFee := pool.GetTakerFee(ctx) - // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, spreadFactor) + tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err } - err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) + // routeStep to the pool-specific SwapExactAmountIn implementation. + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, tokenOutDenom, tokenOutMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -322,7 +321,9 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenIn, routeStep.TokenOutDenom, spreadFactor) + tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, poolI.GetTakerFee(ctx)) + + tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterTakerFee, routeStep.TokenOutDenom, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -444,7 +445,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) - err = k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender) + tokenInWithTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, false) if err != nil { return sdk.Int{}, err } @@ -453,7 +454,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // whole method and will not change after the first iteration, we still iterate through the rest of the pools to execute their respective // swaps. if i == 0 { - tokenInAmount = _tokenInAmount + tokenInAmount = tokenInWithTakerFee.Amount } } @@ -731,16 +732,17 @@ func (k Keeper) createMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - takeFee := poolI.GetTakerFee(ctx) - totalFees := spreadFactor.Add(takeFee) + takerFee := poolI.GetTakerFee(ctx) - tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, totalFees) + tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, spreadFactor) if err != nil { return nil, err } - insExpected[i] = tokenIn.Amount - tokenOut = tokenIn + tokenInAfterTakerFee, _ := k.calcTakerFeeExactOut(tokenIn, takerFee) + + insExpected[i] = tokenInAfterTakerFee.Amount + tokenOut = tokenInAfterTakerFee } return insExpected, nil @@ -768,13 +770,18 @@ func (k Keeper) createOsmoMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors)))) + takerFee := poolI.GetTakerFee(ctx) + osmoDiscountedSpreadFactor := cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) + + tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, osmoDiscountedSpreadFactor) if err != nil { return nil, err } - insExpected[i] = tokenIn.Amount - tokenOut = tokenIn + tokenInAfterTakerFee, _ := k.calcTakerFeeExactOut(tokenIn, takerFee) + + insExpected[i] = tokenInAfterTakerFee.Amount + tokenOut = tokenInAfterTakerFee } return insExpected, nil @@ -816,14 +823,18 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { // extractTakerFeeToFeePool takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params, sender sdk.AccAddress) error { +func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName baseDenom := appparams.BaseCoinUnit - // Take the taker fee from the input token and send it to the fee pool module account - takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.TruncateInt()) + var tokenInAfterTakerFee sdk.Coin + var takerFeeCoin sdk.Coin + if exactIn { + tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactIn(tokenIn, takerFee) + } else { + tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactOut(tokenIn, takerFee) + } // We determine the distributution of the taker fee based on its denom // If the denom is the base denom: @@ -835,7 +846,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { - return err + return sdk.Coin{}, err } } // Staking Rewards: @@ -846,7 +857,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToStakingRewardsDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) if err != nil { - return err + return sdk.Coin{}, err } } @@ -861,7 +872,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) if err != nil { - return err + return sdk.Coin{}, err } } else { // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. @@ -870,7 +881,7 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { - return err + return sdk.Coin{}, err } } } @@ -881,12 +892,28 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToStakingRewardsDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) if err != nil { - return err + return sdk.Coin{}, err } } } - return nil + return tokenInAfterTakerFee, nil +} + +func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.TruncateInt()) + tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(takerFeeCoin.Amount)) + + return tokenInAfterTakerFee, takerFeeCoin +} + +func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.RoundInt()) + tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Add(takerFeeCoin.Amount)) + + return tokenInAfterTakerFee, takerFeeCoin } func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 4e6e8f7e86f..94dd88511db 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -675,7 +675,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcInAmountAsSeparatePoolSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenIn) + expectedMultihopTokenOutAmount := s.calcOutGivenInAmountAsSeparatePoolSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenIn) // execute the swap multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenIn, tc.tokenOutMinAmount) @@ -967,12 +967,12 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { s.Require().Error(err) } else { // calculate the swap as separate swaps with either the reduced swap fee or normal fee - expectedMultihopTokenOutAmount := s.calcOutAmountAsSeparateSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenOut) + expectedMultihopTokenInAmount := s.calcInGivenOutAmountAsSeparateSwaps(tc.expectReducedFeeApplied, tc.routes, tc.tokenOut) // execute the swap - multihopTokenOutAmount, err := poolmanagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenInMaxAmount, tc.tokenOut) + multihopTokenInAmount, err := poolmanagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], tc.routes, tc.tokenInMaxAmount, tc.tokenOut) // compare the expected tokenOut to the actual tokenOut s.Require().NoError(err) - s.Require().Equal(expectedMultihopTokenOutAmount.Amount.String(), multihopTokenOutAmount.String()) + s.Require().Equal(expectedMultihopTokenInAmount.Amount.String(), multihopTokenInAmount.String()) } }) } @@ -1323,7 +1323,7 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { if test.expectPass { s.Require().NoError(errMultihop, "test: %v", test.name) s.Require().NoError(errEstimate, "test: %v", test.name) - s.Require().Equal(multihopTokenInAmount, estimateMultihopTokenInAmount) + s.Require().Equal(estimateMultihopTokenInAmount.String(), multihopTokenInAmount.String()) } else { s.Require().Error(errMultihop, "test: %v", test.name) s.Require().Error(errEstimate, "test: %v", test.name) @@ -1354,7 +1354,7 @@ func (s *KeeperTestSuite) makeGaugesIncentivized(incentivizedGauges []uint64) { s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, distInfo) } -func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(osmoFeeReduced bool, routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced bool, routes []types.SwapAmountOutRoute, tokenOut sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() if osmoFeeReduced { // extract route from swap @@ -1375,15 +1375,18 @@ func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(osmoFeeReduced bool, rout spreadFactor := routeSpreadFactor.Mul((currentPoolSpreadFactor.Quo(sumOfSpreadFactors))) takerFee := hopPool.GetTakerFee(cacheCtx) - totalFees := spreadFactor.Add(takerFee) swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, totalFees) + tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, spreadFactor) s.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + + tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) + tokenInCoinAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) + + nextTokenOut = tokenInCoinAfterTakerFee } return nextTokenOut } else { @@ -1395,23 +1398,26 @@ func (s *KeeperTestSuite) calcOutAmountAsSeparateSwaps(osmoFeeReduced bool, rout updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) takerFee := hopPool.GetTakerFee(cacheCtx) - totalFees := updatedPoolSpreadFactor.Add(takerFee) swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) - tokenOut, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, totalFees) + tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) s.Require().NoError(err) - nextTokenOut = sdk.NewCoin(hop.TokenInDenom, tokenOut) + + tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) + tokenInCoinAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) + + nextTokenOut = tokenInCoinAfterTakerFee } return nextTokenOut } } -// calcInAmountAsSeparatePoolSwaps calculates the output amount of a series of swaps on PoolManager pools while factoring in reduces swap fee changes. +// calcOutGivenInAmountAsSeparatePoolSwaps calculates the output amount of a series of swaps on PoolManager pools while factoring in reduces swap fee changes. // If its GAMM pool functions directly to ensure the poolmanager functions route to the correct modules. It it's CL pool functions directly to ensure the // poolmanager functions route to the correct modules. -func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { +func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, routes []types.SwapAmountInRoute, tokenIn sdk.Coin) sdk.Coin { cacheCtx, _ := s.Ctx.CacheContext() if osmoFeeReduced { // extract route from swap @@ -1434,10 +1440,11 @@ func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, r spreadFactor := routeSpreadFactor.Mul(pool.GetSpreadFactor(cacheCtx).Quo(sumOfSpreadFactors)) takerFee := pool.GetTakerFee(cacheCtx) - totalFees := spreadFactor.Add(takerFee) + + nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFees) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1456,10 +1463,11 @@ func (s *KeeperTestSuite) calcInAmountAsSeparatePoolSwaps(osmoFeeReduced bool, r spreadFactor := pool.GetSpreadFactor(cacheCtx) takerFee := pool.GetTakerFee(cacheCtx) - totalFees := spreadFactor.Add(takerFee) + + nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenIn, hop.TokenOutDenom, sdk.OneInt(), totalFees) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1490,7 +1498,6 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { // - foo in: 100000 // - bar amount out will be calculated according to the formula // https://www.wolframalpha.com/input?i=solve+%2810%5E12+%2B+10%5E5+x+0.9975%29%2810%5E12+-+x%29+%3D+10%5E24 - // We round down the token amount out, get the result is 99749 { name: "Swap - [foo -> bar], 0.1 percent fee", poolId: 1, @@ -1499,7 +1506,7 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), tokenOutMinAmount: sdk.NewInt(1), tokenOutDenom: bar, - expectedTokenOutAmount: sdk.NewInt(99749), + expectedTokenOutAmount: sdk.NewInt(99750), }, { name: "Wrong pool id", @@ -1860,7 +1867,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(97866545) + priceImpactThreshold = sdk.NewInt(97595721) ) tests := map[string]struct { @@ -2060,7 +2067,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { TokenOutAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(102239504) + priceImpactThreshold = sdk.NewInt(102530430) ) tests := map[string]struct { From 914cedc90d5edbc78ab01007419a4db30d30e9c8 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Thu, 17 Aug 2023 15:26:43 -0500 Subject: [PATCH 12/83] fix extract cmd --- x/poolmanager/router.go | 19 ++++++++++++------- x/superfluid/keeper/stake_test.go | 4 ++-- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 5cda3b6d481..4f4b5fdc5ec 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -836,25 +836,29 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactOut(tokenIn, takerFee) } + // N.B. We truncate from the community pool calculation, then remove that from the total, and use the remaining for staking rewards. + // If we truncate both, these can leave tokens in the users wallet when swapping and exact amount in, which is bad UX. + // We determine the distributution of the taker fee based on its denom // If the denom is the base denom: + takerFeeAmtRemaining := takerFeeCoin.Amount if takerFeeCoin.Denom == baseDenom { // Community Pool: if poolManagerParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { // Osmo community pool funds is a direct send - osmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.CommunityPool) + osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.CommunityPool) osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { return sdk.Coin{}, err } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(baseDenom)) } // Staking Rewards: if poolManagerParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) // We could stream these rewards via the fee collector account, but this is decision to be made by governance. - osmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.StakingRewards) - osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToStakingRewardsDec.TruncateInt())) + osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, takerFeeAmtRemaining)) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) if err != nil { return sdk.Coin{}, err @@ -868,28 +872,29 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take denomIsWhitelisted := isDenomWhitelisted(takerFeeCoin.Denom, poolManagerParams.AuthorizedQuoteDenoms) // If the non osmo denom is a whitelisted quote asset, we send to the community pool if denomIsWhitelisted { - nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) if err != nil { return sdk.Coin{}, err } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) } else { // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. - nonOsmoTakerFeeToCommunityPoolDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { return sdk.Coin{}, err } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) } } // Staking Rewards: if poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Non Osmo staking rewards are sent to the non native fee pool module account - nonOsmoTakerFeeToStakingRewardsDec := takerFeeCoin.Amount.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards) - nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToStakingRewardsDec.TruncateInt())) + nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) if err != nil { return sdk.Coin{}, err diff --git a/x/superfluid/keeper/stake_test.go b/x/superfluid/keeper/stake_test.go index c0eb11aa5d9..1d5063fad58 100644 --- a/x/superfluid/keeper/stake_test.go +++ b/x/superfluid/keeper/stake_test.go @@ -1160,7 +1160,7 @@ func (s *KeeperTestSuite) TestConvertLockToStake() { "error: min amount to stake greater than actual amount": { useMinAmountToStake: true, expectedError: types.TokenConvertedLessThenDesiredStakeError{ - ActualTotalAmtToStake: sdk.NewInt(8309), + ActualTotalAmtToStake: sdk.NewInt(8306), ExpectedTotalAmtToStake: sdk.NewInt(999999999), }, }, @@ -1359,7 +1359,7 @@ func (s *KeeperTestSuite) TestConvertGammSharesToOsmoAndStake() { }, "error: min amount to stake exceeds actual amount staking": { useMinAmtToStake: true, - expectedError: "actual amount converted to stake (8309) is less then minimum amount expected to be staked (999999999)", + expectedError: "actual amount converted to stake (8306) is less then minimum amount expected to be staked (999999999)", }, } From 5a68fa61ea149e90af67bcd7b9af3c75fee04516 Mon Sep 17 00:00:00 2001 From: devbot-wizard <141283918+devbot-wizard@users.noreply.github.com> Date: Thu, 17 Aug 2023 20:34:32 +0000 Subject: [PATCH 13/83] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d89a905bf84..1a8d577cf6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Features + +* [#6034](https://github.com/osmosis-labs/osmosis/pull/6034) feat(spike): taker fee + ### API breaks * [#6071](https://github.com/osmosis-labs/osmosis/pull/6071) reduce number of returns for UpdatePosition and TicksToSqrtPrice functions From f0afc3d6efb682de72d5b0d75fbb0ed83bece45b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 18 Aug 2023 16:16:53 -0500 Subject: [PATCH 14/83] tidy --- app/upgrades/v18/upgrades.go | 34 ++ .../cosmwasmpool/v1beta1/model/pool.proto | 3 + .../v1beta1/model/pool_query_msg.proto | 14 - .../osmosis/poolmanager/v1beta1/genesis.proto | 44 +- tests/mocks/cfmm_pool.go | 24 +- tests/mocks/cl_pool.go | 8 +- tests/mocks/pool.go | 20 +- x/concentrated-liquidity/model/pool.go | 2 +- .../cosmwasm/msg/pool_query_msg.pb.go | 430 ++--------------- x/cosmwasmpool/model/pool.go | 2 +- x/cosmwasmpool/model/pool.pb.go | 13 +- x/cosmwasmpool/model/store_model.go | 8 +- x/gamm/pool-models/balancer/amm.go | 6 +- x/gamm/pool-models/balancer/pool.go | 6 +- x/gamm/pool-models/balancer/pool_test.go | 2 - x/gamm/pool-models/stableswap/pool.go | 2 +- x/gamm/simulation/sim_msgs.go | 4 +- x/poolmanager/create_pool.go | 4 +- x/poolmanager/router.go | 12 +- x/poolmanager/router_test.go | 8 +- x/poolmanager/types/genesis.pb.go | 435 ++++-------------- x/poolmanager/types/pool.go | 3 +- 22 files changed, 273 insertions(+), 811 deletions(-) diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v18/upgrades.go index b35ce162a23..d3c8a2a4b0f 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v18/upgrades.go @@ -7,6 +7,8 @@ import ( "github.com/osmosis-labs/osmosis/v17/app/keepers" "github.com/osmosis-labs/osmosis/v17/app/upgrades" + poolmanager "github.com/osmosis-labs/osmosis/v17/x/poolmanager" + poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" ) func CreateUpgradeHandler( @@ -23,6 +25,38 @@ func CreateUpgradeHandler( return nil, err } + keepers.PoolManagerKeeper.SetParams(ctx, poolmanagertypes.DefaultParams()) + + err = SetAllExistingPoolsTakerFee(ctx, keepers) + if err != nil { + return nil, err + } + return migrations, nil } } + +func SetAllExistingPoolsTakerFee(ctx sdk.Context, keepers *keepers.AppKeepers) error { + lastPoolId := keepers.PoolManagerKeeper.GetNextPoolId(ctx) - 1 + + for i := uint64(1); i <= lastPoolId; i++ { + pool, err := keepers.PoolManagerKeeper.GetPool(ctx, i) + if err != nil { + return err + } + + poolManagerParams := keepers.PoolManagerKeeper.GetParams(ctx) + accAddress := pool.GetAddress() + poolBalances := keepers.BankKeeper.GetAllBalances(ctx, accAddress) + poolType := pool.GetType() + + takerFee := poolmanager.DetermineTakerFee(poolManagerParams, poolBalances, poolType) + + pool.SetTakerFee(takerFee) + err = keepers.GAMMKeeper.OverwritePoolV15MigrationUnsafe(ctx, pool) + if err != nil { + return err + } + } + return nil +} diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto index fb80b3d02cb..4b6dde68d55 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto @@ -18,6 +18,9 @@ message CosmWasmPool { uint64 code_id = 3; bytes instantiate_msg = 4 [ (gogoproto.moretags) = "yaml:\"instantiate_msg\"" ]; + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. string taker_fee = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"taker_fee\"", diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto index 0065f925470..f9d66be3f89 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto @@ -20,20 +20,6 @@ message GetSwapFeeQueryMsgResponse { ]; } -// ===================== GetTakerFeeQueryMsg -message GetTakerFeeQueryMsg { - // get_taker_fee is the query strcuture to get taker fee. - EmptyStruct get_taker_fee = 1 [ (gogoproto.nullable) = false ]; -} - -message GetTakerFeeQueryMsgResponse { - // taker_fee is the taker fee for this swap estimate. - string taker_fee = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false - ]; -} - // ===================== SpotPriceQueryMsg message SpotPrice { // quote_asset_denom is the quote asset of the spot query. diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 218c834d0db..a9481d74546 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -17,24 +17,40 @@ message Params { (gogoproto.moretags) = "yaml:\"pool_creation_fee\"", (gogoproto.nullable) = false ]; + // default_taker_fee is the fee used when creating a new pool that doesn't + // fall under a custom pool taker fee or stableswap taker fee category. string default_taker_fee = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.customname) = "DefaultTakerFee", (gogoproto.nullable) = false ]; + // stableswap_taker_fee is the fee used when creating a new pool in which all + // the underlying tokens are present in the stablecoin_denoms paramater entry + // OR has a liquid_stake_denom_pairings entry. string stableswap_taker_fee = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.customname) = "StableswapTakerFee", (gogoproto.nullable) = false ]; - repeated CustomPoolTakerFee trading_pair_taker_fee = 4 [ - (gogoproto.customname) = "CustomPoolTakerFee", - (gogoproto.nullable) = false - ]; + // osmo_taker_fee_distribution defines the distribution of taker fees + // generated in OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets distributed to + // stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. TakerFeeDistributionPercentage osmo_taker_fee_distribution = 5 [ (gogoproto.customname) = "OsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; + // non_osmo_taker_fee_distribution defines the distribution of taker fees + // generated in non-OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets swapped to OSMO + // and then distirbuted to stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. Note: If the non-OSMO asset is an authorized_quote_denom, + // that denom is sent directly to the community pool. Otherwise, it is + // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and + // then sent to the community pool as that denom. TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 6 [ (gogoproto.customname) = "NonOsmoTakerFeeDistribution", (gogoproto.nullable) = false @@ -57,11 +73,15 @@ message Params { "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; // stablecoin_denoms is a list of denoms that are considered stablecoins. // This is used to determine if a pool should use the stableswap taker - // fee.bool LSTs are NOT apart of this catagory, even though they are eligible - // for stableswap taker fees. This is determined via the + // fee. Note: LSTs are NOT apart of this catagory, even though they are + // eligible for stableswap taker fees. This is determined via the // liquid_stake_denom_pairings field. repeated string stablecoin_denoms = 9 [ (gogoproto.moretags) = "yaml:\"stablecoin_denoms\"" ]; + // liquid_stake_denom_pairings is a list of pairings of a natural denom with + // its corresponding LST denoms. If a pool is created with a natural denom + // that is paired with an LST denom, then the pool will be considered a + // stableswap pool and will use the stableswap taker fee. repeated LiquidStakedTokenToUnderlyingDenom liquid_stake_denom_pairings = 10 [ (gogoproto.moretags) = "yaml:\"liquid_stake_denom_pairings\"" ]; } @@ -76,16 +96,6 @@ message GenesisState { repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ]; } -// CustomPoolTakerFee defines a custom taker fee for a specific pool. -message CustomPoolTakerFee { - uint64 pool_id = 1 [ (gogoproto.customname) = "PoolId" ]; - string taker_fee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"taker_fee\"", - (gogoproto.nullable) = false - ]; -} - // TakerFeeDistributionPercentage defines what percent of the taker fee category // gets distributed to the available categories. message TakerFeeDistributionPercentage { @@ -101,6 +111,8 @@ message TakerFeeDistributionPercentage { ]; } +// LiquidStakedTokenToUnderlyingDenom defines a pairing of a single natural +// denom with its corresponding LST denoms. message LiquidStakedTokenToUnderlyingDenom { repeated string liquid_staked_token_denoms = 1 [ (gogoproto.moretags) = "yaml:\"liquid_staked_token_denoms\"" ]; diff --git a/tests/mocks/cfmm_pool.go b/tests/mocks/cfmm_pool.go index aa9add9da17..bd36e0406c4 100644 --- a/tests/mocks/cfmm_pool.go +++ b/tests/mocks/cfmm_pool.go @@ -199,17 +199,17 @@ func (mr *MockCFMMPoolIMockRecorder) GetSpreadFactor(ctx interface{}) *gomock.Ca } // GetTakerFee mocks base method. -func (m *MockCFMMPoolI) GetTakerFee(ctx types.Context) types.Dec { +func (m *MockCFMMPoolI) GetTakerFee() types.Dec { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret := m.ctrl.Call(m, "GetTakerFee") ret0, _ := ret[0].(types.Dec) return ret0 } // GetTakerFee indicates an expected call of GetTakerFee. -func (mr *MockCFMMPoolIMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { +func (mr *MockCFMMPoolIMockRecorder) GetTakerFee() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockCFMMPoolI)(nil).GetTakerFee), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockCFMMPoolI)(nil).GetTakerFee)) } // GetTotalPoolLiquidity mocks base method. @@ -609,17 +609,17 @@ func (mr *MockPoolAmountOutExtensionMockRecorder) GetSpreadFactor(ctx interface{ } // GetTakerFee mocks base method. -func (m *MockPoolAmountOutExtension) GetTakerFee(ctx types.Context) types.Dec { +func (m *MockPoolAmountOutExtension) GetTakerFee() types.Dec { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret := m.ctrl.Call(m, "GetTakerFee") ret0, _ := ret[0].(types.Dec) return ret0 } // GetTakerFee indicates an expected call of GetTakerFee. -func (mr *MockPoolAmountOutExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { +func (mr *MockPoolAmountOutExtensionMockRecorder) GetTakerFee() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).GetTakerFee), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolAmountOutExtension)(nil).GetTakerFee)) } // GetTotalPoolLiquidity mocks base method. @@ -1016,17 +1016,17 @@ func (mr *MockWeightedPoolExtensionMockRecorder) GetSpreadFactor(ctx interface{} } // GetTakerFee mocks base method. -func (m *MockWeightedPoolExtension) GetTakerFee(ctx types.Context) types.Dec { +func (m *MockWeightedPoolExtension) GetTakerFee() types.Dec { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret := m.ctrl.Call(m, "GetTakerFee") ret0, _ := ret[0].(types.Dec) return ret0 } // GetTakerFee indicates an expected call of GetTakerFee. -func (mr *MockWeightedPoolExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { +func (mr *MockWeightedPoolExtensionMockRecorder) GetTakerFee() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockWeightedPoolExtension)(nil).GetTakerFee), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockWeightedPoolExtension)(nil).GetTakerFee)) } // GetTokenWeight mocks base method. diff --git a/tests/mocks/cl_pool.go b/tests/mocks/cl_pool.go index 89e4e86ae5d..46d3e3c9319 100644 --- a/tests/mocks/cl_pool.go +++ b/tests/mocks/cl_pool.go @@ -222,17 +222,17 @@ func (mr *MockConcentratedPoolExtensionMockRecorder) GetSpreadRewardsAddress() * } // GetTakerFee mocks base method. -func (m *MockConcentratedPoolExtension) GetTakerFee(ctx types.Context) types.Dec { +func (m *MockConcentratedPoolExtension) GetTakerFee() types.Dec { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret := m.ctrl.Call(m, "GetTakerFee") ret0, _ := ret[0].(types.Dec) return ret0 } // GetTakerFee indicates an expected call of GetTakerFee. -func (mr *MockConcentratedPoolExtensionMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { +func (mr *MockConcentratedPoolExtensionMockRecorder) GetTakerFee() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).GetTakerFee), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockConcentratedPoolExtension)(nil).GetTakerFee)) } // GetTickSpacing mocks base method. diff --git a/tests/mocks/pool.go b/tests/mocks/pool.go index a265f2a33b6..b6812aeb456 100644 --- a/tests/mocks/pool.go +++ b/tests/mocks/pool.go @@ -92,17 +92,17 @@ func (mr *MockPoolIMockRecorder) GetSpreadFactor(ctx interface{}) *gomock.Call { } // GetTakerFee mocks base method. -func (m *MockPoolI) GetTakerFee(ctx types.Context) types.Dec { +func (m *MockPoolI) GetTakerFee() types.Dec { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTakerFee", ctx) + ret := m.ctrl.Call(m, "GetTakerFee") ret0, _ := ret[0].(types.Dec) return ret0 } // GetTakerFee indicates an expected call of GetTakerFee. -func (mr *MockPoolIMockRecorder) GetTakerFee(ctx interface{}) *gomock.Call { +func (mr *MockPoolIMockRecorder) GetTakerFee() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolI)(nil).GetTakerFee), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTakerFee", reflect.TypeOf((*MockPoolI)(nil).GetTakerFee)) } // GetType mocks base method. @@ -157,6 +157,18 @@ func (mr *MockPoolIMockRecorder) Reset() *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Reset", reflect.TypeOf((*MockPoolI)(nil).Reset)) } +// SetTakerFee mocks base method. +func (m *MockPoolI) SetTakerFee(newTakerFee types.Dec) { + m.ctrl.T.Helper() + m.ctrl.Call(m, "SetTakerFee", newTakerFee) +} + +// SetTakerFee indicates an expected call of SetTakerFee. +func (mr *MockPoolIMockRecorder) SetTakerFee(newTakerFee interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetTakerFee", reflect.TypeOf((*MockPoolI)(nil).SetTakerFee), newTakerFee) +} + // SpotPrice mocks base method. func (m *MockPoolI) SpotPrice(ctx types.Context, quoteAssetDenom, baseAssetDenom string) (types.Dec, error) { m.ctrl.T.Helper() diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index b3006b841cb..435e1be5d45 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -101,7 +101,7 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.SpreadFactor } -func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { +func (p Pool) GetTakerFee() sdk.Dec { return p.TakerFee } diff --git a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go index 988bea36d16..8f18027532c 100644 --- a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go +++ b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go @@ -109,90 +109,6 @@ func (m *GetSwapFeeQueryMsgResponse) XXX_DiscardUnknown() { var xxx_messageInfo_GetSwapFeeQueryMsgResponse proto.InternalMessageInfo -// ===================== GetTakerFeeQueryMsg -type GetTakerFeeQueryMsg struct { - // get_taker_fee is the query strcuture to get taker fee. - GetTakerFee EmptyStruct `protobuf:"bytes,1,opt,name=get_taker_fee,json=getTakerFee,proto3" json:"get_taker_fee"` -} - -func (m *GetTakerFeeQueryMsg) Reset() { *m = GetTakerFeeQueryMsg{} } -func (m *GetTakerFeeQueryMsg) String() string { return proto.CompactTextString(m) } -func (*GetTakerFeeQueryMsg) ProtoMessage() {} -func (*GetTakerFeeQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{2} -} -func (m *GetTakerFeeQueryMsg) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetTakerFeeQueryMsg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetTakerFeeQueryMsg.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GetTakerFeeQueryMsg) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetTakerFeeQueryMsg.Merge(m, src) -} -func (m *GetTakerFeeQueryMsg) XXX_Size() int { - return m.Size() -} -func (m *GetTakerFeeQueryMsg) XXX_DiscardUnknown() { - xxx_messageInfo_GetTakerFeeQueryMsg.DiscardUnknown(m) -} - -var xxx_messageInfo_GetTakerFeeQueryMsg proto.InternalMessageInfo - -func (m *GetTakerFeeQueryMsg) GetGetTakerFee() EmptyStruct { - if m != nil { - return m.GetTakerFee - } - return EmptyStruct{} -} - -type GetTakerFeeQueryMsgResponse struct { - // taker_fee is the taker fee for this swap estimate. - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee"` -} - -func (m *GetTakerFeeQueryMsgResponse) Reset() { *m = GetTakerFeeQueryMsgResponse{} } -func (m *GetTakerFeeQueryMsgResponse) String() string { return proto.CompactTextString(m) } -func (*GetTakerFeeQueryMsgResponse) ProtoMessage() {} -func (*GetTakerFeeQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{3} -} -func (m *GetTakerFeeQueryMsgResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GetTakerFeeQueryMsgResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GetTakerFeeQueryMsgResponse.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *GetTakerFeeQueryMsgResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetTakerFeeQueryMsgResponse.Merge(m, src) -} -func (m *GetTakerFeeQueryMsgResponse) XXX_Size() int { - return m.Size() -} -func (m *GetTakerFeeQueryMsgResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetTakerFeeQueryMsgResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_GetTakerFeeQueryMsgResponse proto.InternalMessageInfo - // ===================== SpotPriceQueryMsg type SpotPrice struct { // quote_asset_denom is the quote asset of the spot query. @@ -205,7 +121,7 @@ func (m *SpotPrice) Reset() { *m = SpotPrice{} } func (m *SpotPrice) String() string { return proto.CompactTextString(m) } func (*SpotPrice) ProtoMessage() {} func (*SpotPrice) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{4} + return fileDescriptor_3251d17e76ef0dc1, []int{2} } func (m *SpotPrice) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -258,7 +174,7 @@ func (m *SpotPriceQueryMsg) Reset() { *m = SpotPriceQueryMsg{} } func (m *SpotPriceQueryMsg) String() string { return proto.CompactTextString(m) } func (*SpotPriceQueryMsg) ProtoMessage() {} func (*SpotPriceQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{5} + return fileDescriptor_3251d17e76ef0dc1, []int{3} } func (m *SpotPriceQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -303,7 +219,7 @@ func (m *SpotPriceQueryMsgResponse) Reset() { *m = SpotPriceQueryMsgResp func (m *SpotPriceQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*SpotPriceQueryMsgResponse) ProtoMessage() {} func (*SpotPriceQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{6} + return fileDescriptor_3251d17e76ef0dc1, []int{4} } func (m *SpotPriceQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -347,7 +263,7 @@ func (m *EmptyStruct) Reset() { *m = EmptyStruct{} } func (m *EmptyStruct) String() string { return proto.CompactTextString(m) } func (*EmptyStruct) ProtoMessage() {} func (*EmptyStruct) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{7} + return fileDescriptor_3251d17e76ef0dc1, []int{5} } func (m *EmptyStruct) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -386,7 +302,7 @@ func (m *GetTotalPoolLiquidityQueryMsg) Reset() { *m = GetTotalPoolLiqui func (m *GetTotalPoolLiquidityQueryMsg) String() string { return proto.CompactTextString(m) } func (*GetTotalPoolLiquidityQueryMsg) ProtoMessage() {} func (*GetTotalPoolLiquidityQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{8} + return fileDescriptor_3251d17e76ef0dc1, []int{6} } func (m *GetTotalPoolLiquidityQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -432,7 +348,7 @@ func (m *GetTotalPoolLiquidityQueryMsgResponse) Reset() { *m = GetTotalP func (m *GetTotalPoolLiquidityQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*GetTotalPoolLiquidityQueryMsgResponse) ProtoMessage() {} func (*GetTotalPoolLiquidityQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{9} + return fileDescriptor_3251d17e76ef0dc1, []int{7} } func (m *GetTotalPoolLiquidityQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -479,7 +395,7 @@ func (m *GetTotalSharesQueryMsg) Reset() { *m = GetTotalSharesQueryMsg{} func (m *GetTotalSharesQueryMsg) String() string { return proto.CompactTextString(m) } func (*GetTotalSharesQueryMsg) ProtoMessage() {} func (*GetTotalSharesQueryMsg) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{10} + return fileDescriptor_3251d17e76ef0dc1, []int{8} } func (m *GetTotalSharesQueryMsg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -524,7 +440,7 @@ func (m *GetTotalSharesQueryMsgResponse) Reset() { *m = GetTotalSharesQu func (m *GetTotalSharesQueryMsgResponse) String() string { return proto.CompactTextString(m) } func (*GetTotalSharesQueryMsgResponse) ProtoMessage() {} func (*GetTotalSharesQueryMsgResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3251d17e76ef0dc1, []int{11} + return fileDescriptor_3251d17e76ef0dc1, []int{9} } func (m *GetTotalSharesQueryMsgResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -563,8 +479,6 @@ func (m *GetTotalSharesQueryMsgResponse) GetTotalShares() string { func init() { proto.RegisterType((*GetSwapFeeQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.GetSwapFeeQueryMsg") proto.RegisterType((*GetSwapFeeQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.GetSwapFeeQueryMsgResponse") - proto.RegisterType((*GetTakerFeeQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.GetTakerFeeQueryMsg") - proto.RegisterType((*GetTakerFeeQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.GetTakerFeeQueryMsgResponse") proto.RegisterType((*SpotPrice)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPrice") proto.RegisterType((*SpotPriceQueryMsg)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPriceQueryMsg") proto.RegisterType((*SpotPriceQueryMsgResponse)(nil), "osmosis.cosmwasmpool.v1beta1.SpotPriceQueryMsgResponse") @@ -580,44 +494,41 @@ func init() { } var fileDescriptor_3251d17e76ef0dc1 = []byte{ - // 582 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0x86, 0x63, 0x8a, 0xa0, 0x9e, 0xb4, 0xa5, 0x35, 0x05, 0xb5, 0x85, 0xba, 0xc5, 0x12, 0x10, - 0x90, 0x6a, 0x2b, 0xe5, 0x50, 0x89, 0x0b, 0x22, 0x2d, 0x54, 0x88, 0x22, 0x35, 0x09, 0x97, 0x72, - 0xb1, 0x36, 0xce, 0xb2, 0x71, 0x6b, 0x67, 0x1d, 0xcf, 0xa6, 0x21, 0xbc, 0x01, 0x37, 0x1e, 0xab, - 0xc7, 0x1e, 0x11, 0x87, 0x0a, 0x25, 0x2f, 0x82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41, 0x96, 0x33, 0xef, 0xfa, 0x1f, 0xb0, 0x69, 0x44, 0xeb, 0x3b, 0x3c, 0x9d, 0xd9, - 0x8a, 0xb2, 0x58, 0x86, 0xf5, 0x7f, 0xb4, 0xb3, 0x50, 0xc8, 0xef, 0x6f, 0xda, 0x83, 0x97, 0xc0, - 0x96, 0x8b, 0x51, 0x5d, 0x1c, 0x72, 0xbf, 0x99, 0xe2, 0x0d, 0x31, 0xc9, 0x46, 0x78, 0x98, 0xb1, - 0xab, 0x0d, 0x12, 0x53, 0x54, 0xfe, 0xcf, 0x60, 0x75, 0xe8, 0x1f, 0x93, 0xb3, 0x79, 0x7d, 0xaf, - 0xb0, 0x31, 0x84, 0x75, 0x08, 0xe6, 0x74, 0xa8, 0x72, 0xfa, 0x04, 0x96, 0x26, 0xc0, 0x7a, 0x25, - 0x2f, 0x86, 0x92, 0xd2, 0xd9, 0x55, 0xcf, 0xd4, 0xae, 0x7b, 0xa6, 0xf6, 0xa7, 0x67, 0x6a, 0x3f, - 0xfb, 0x66, 0xee, 0xba, 0x6f, 0xe6, 0x7e, 0xf5, 0xcd, 0xdc, 0x97, 0x37, 0x23, 0x9f, 0x47, 0xda, - 0xe9, 0x5e, 0x40, 0x6a, 0x98, 0x3d, 0x38, 0x97, 0xc5, 0x03, 0xe7, 0xdb, 0xf8, 0x0d, 0x9a, 0x3d, - 0x38, 0x21, 0xb2, 0xda, 0x9d, 0xe4, 0x7a, 0x7b, 0xf5, 0x37, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xe8, - 0xae, 0xa0, 0x6d, 0x05, 0x00, 0x00, + // 544 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0xc7, 0xe3, 0xaf, 0x9f, 0x00, 0x4f, 0x4a, 0x69, 0xad, 0x82, 0xda, 0x8a, 0xba, 0xc5, 0x12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0xdb, 0x8e, + 0xfe, 0xa1, 0xbc, 0x89, 0xe8, 0x7d, 0x87, 0xa7, 0x0b, 0x4b, 0x31, 0x16, 0x2b, 0xb0, 0xfe, 0x8f, + 0x72, 0x96, 0x4a, 0xc5, 0x83, 0x4d, 0x7f, 0x74, 0x07, 0x7c, 0x3d, 0x18, 0x53, 0xc5, 0x11, 0x46, + 0xad, 0x1c, 0xef, 0xa8, 0x79, 0x36, 0xc1, 0xa3, 0x31, 0xbb, 0xd6, 0xe4, 0x1d, 0x41, 0xc6, 0xff, + 0x39, 0xac, 0x4e, 0xfc, 0x53, 0xb6, 0x77, 0x5b, 0xdf, 0x2b, 0x72, 0x06, 0xe1, 0x1d, 0x81, 0x7b, + 0x33, 0xd4, 0x38, 0x7d, 0x02, 0xcb, 0x73, 0x60, 0xbb, 0x5a, 0x54, 0x13, 0x49, 0xf9, 0xfc, 0x72, + 0xe0, 0x5a, 0x57, 0x03, 0xd7, 0xfa, 0x33, 0x70, 0xad, 0x9f, 0x43, 0xb7, 0x70, 0x35, 0x74, 0x0b, + 0xbf, 0x86, 0x6e, 0xe1, 0xf3, 0x9b, 0xa9, 0xaf, 0x23, 0xaf, 0x74, 0x2f, 0xe6, 0x75, 0x1a, 0x2f, + 0xd8, 0xc5, 0xfe, 0x21, 0xfb, 0x36, 0xfb, 0xd2, 0x8c, 0x17, 0x2c, 0x21, 0x59, 0xbf, 0x93, 0x3d, + 0x03, 0xaf, 0xfe, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x3e, 0xe5, 0x84, 0x95, 0x04, 0x00, 0x00, } func (m *GetSwapFeeQueryMsg) Marshal() (dAtA []byte, err error) { @@ -686,72 +597,6 @@ func (m *GetSwapFeeQueryMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *GetTakerFeeQueryMsg) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetTakerFeeQueryMsg) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetTakerFeeQueryMsg) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.GetTakerFee.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintPoolQueryMsg(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *GetTakerFeeQueryMsgResponse) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *GetTakerFeeQueryMsgResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GetTakerFeeQueryMsgResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPoolQueryMsg(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - return len(dAtA) - i, nil -} - func (m *SpotPrice) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1041,28 +886,6 @@ func (m *GetSwapFeeQueryMsgResponse) Size() (n int) { return n } -func (m *GetTakerFeeQueryMsg) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.GetTakerFee.Size() - n += 1 + l + sovPoolQueryMsg(uint64(l)) - return n -} - -func (m *GetTakerFeeQueryMsgResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.TakerFee.Size() - n += 1 + l + sovPoolQueryMsg(uint64(l)) - return n -} - func (m *SpotPrice) Size() (n int) { if m == nil { return 0 @@ -1336,173 +1159,6 @@ func (m *GetSwapFeeQueryMsgResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *GetTakerFeeQueryMsg) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPoolQueryMsg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetTakerFeeQueryMsg: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetTakerFeeQueryMsg: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field GetTakerFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPoolQueryMsg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthPoolQueryMsg - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthPoolQueryMsg - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.GetTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPoolQueryMsg(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPoolQueryMsg - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *GetTakerFeeQueryMsgResponse) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPoolQueryMsg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: GetTakerFeeQueryMsgResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GetTakerFeeQueryMsgResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPoolQueryMsg - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPoolQueryMsg - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPoolQueryMsg - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipPoolQueryMsg(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthPoolQueryMsg - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *SpotPrice) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/cosmwasmpool/model/pool.go b/x/cosmwasmpool/model/pool.go index 306f04b940f..b5840817d81 100644 --- a/x/cosmwasmpool/model/pool.go +++ b/x/cosmwasmpool/model/pool.go @@ -66,7 +66,7 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return response.SwapFee } -func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { +func (p Pool) GetTakerFee() sdk.Dec { return p.TakerFee } diff --git a/x/cosmwasmpool/model/pool.pb.go b/x/cosmwasmpool/model/pool.pb.go index e486355a649..f0de0b4bc95 100644 --- a/x/cosmwasmpool/model/pool.pb.go +++ b/x/cosmwasmpool/model/pool.pb.go @@ -27,11 +27,14 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type CosmWasmPool struct { - ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - CodeId uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` - InstantiateMsg []byte `protobuf:"bytes,4,opt,name=instantiate_msg,json=instantiateMsg,proto3" json:"instantiate_msg,omitempty" yaml:"instantiate_msg"` - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` + ContractAddress string `protobuf:"bytes,1,opt,name=contract_address,json=contractAddress,proto3" json:"contract_address,omitempty" yaml:"contract_address"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + CodeId uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` + InstantiateMsg []byte `protobuf:"bytes,4,opt,name=instantiate_msg,json=instantiateMsg,proto3" json:"instantiate_msg,omitempty" yaml:"instantiate_msg"` + // taker_fee is the ratio that is charged on the amount of token in. + // this value is assigned by the protocol at time of pool creation, + // however can be changed by governance. + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *CosmWasmPool) Reset() { *m = CosmWasmPool{} } diff --git a/x/cosmwasmpool/model/store_model.go b/x/cosmwasmpool/model/store_model.go index 0a6cba9bb9c..0a6cca8b998 100644 --- a/x/cosmwasmpool/model/store_model.go +++ b/x/cosmwasmpool/model/store_model.go @@ -37,8 +37,12 @@ func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { panic("CosmWasmPool.GetSpreadFactor not implemented") } -func (p CosmWasmPool) GetTakerFee(ctx sdk.Context) sdk.Dec { - panic("CosmWasmPool.GetTakerFee not implemented") +func (p CosmWasmPool) GetTakerFee() sdk.Dec { + return p.TakerFee +} + +func (p *CosmWasmPool) SetTakerFee(newTakerFee sdk.Dec) { + p.TakerFee = newTakerFee } func (p CosmWasmPool) GetExitFee(ctx sdk.Context) sdk.Dec { diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index 79b87ae6455..91874594648 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -119,7 +119,7 @@ func calcPoolSharesOutGivenSingleAssetIn( normalizedTokenWeightIn, poolShares, tokenAmountIn, - spreadFactor, takerFee sdk.Dec, + spreadFactor sdk.Dec, ) sdk.Dec { // deduct spread factor on the in asset. // We don't charge spread factor on the token amount that we imagine as unswapped (the normalized weight). @@ -197,7 +197,7 @@ func calcSingleAssetInGivenPoolSharesOut( normalizedTokenWeightIn, totalPoolSharesSupply, sharesAmountOut, - spreadFactor, takerFee sdk.Dec, + spreadFactor sdk.Dec, ) sdk.Dec { // delta balanceIn is negative(tokens inside the pool increases) // pool weight is always 1 @@ -215,7 +215,7 @@ func calcPoolSharesInGivenSingleAssetOut( normalizedTokenWeightOut, totalPoolSharesSupply, tokenAmountOut, - spreadFactor, takerFee, + spreadFactor, exitFee sdk.Dec, ) sdk.Dec { tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor)) diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index efcf92d7811..f9872767389 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -92,7 +92,7 @@ func (p Pool) GetSpreadFactor(_ sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } -func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { +func (p Pool) GetTakerFee() sdk.Dec { return p.PoolParams.TakerFee } @@ -673,7 +673,6 @@ func (p *Pool) calcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor sdk.Dec, token totalShares.ToDec(), tokenIn.Amount.ToDec(), spreadFactor, - p.PoolParams.TakerFee, ).TruncateInt(), nil } @@ -911,7 +910,6 @@ func (p *Pool) CalcTokenInShareAmountOut( p.GetTotalShares().ToDec(), shareOutAmount.ToDec(), spreadFactor, - p.GetTakerFee(ctx), ).Ceil().TruncateInt() if !tokenInAmount.IsPositive() { @@ -939,7 +937,6 @@ func (p *Pool) JoinPoolTokenInMaxShareAmountOut( p.GetTotalShares().ToDec(), shareOutAmount.ToDec(), p.GetSpreadFactor(ctx), - p.GetTakerFee(ctx), ).TruncateInt() if !tokenInAmount.IsPositive() { @@ -971,7 +968,6 @@ func (p *Pool) ExitSwapExactAmountOut( p.GetTotalShares().ToDec(), tokenOut.Amount.ToDec(), p.GetSpreadFactor(ctx), - p.GetTakerFee(ctx), p.GetExitFee(ctx), ).TruncateInt() diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 866a6b25ba6..58f32a33af2 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -675,7 +675,6 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { initialTotalShares, initialCalcTokenOut.ToDec(), spreadFactorDec, - sdk.ZeroDec(), ) inverseCalcTokenOut := balancer.CalcSingleAssetInGivenPoolSharesOut( @@ -684,7 +683,6 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { initialTotalShares.Add(actualSharesOut), actualSharesOut, spreadFactorDec, - sdk.ZeroDec(), ) tol := sdk.NewDec(1) diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index 5492fc9389d..e0c58377539 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -90,7 +90,7 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } -func (p Pool) GetTakerFee(ctx sdk.Context) sdk.Dec { +func (p Pool) GetTakerFee() sdk.Dec { return p.PoolParams.TakerFee } diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index 5008be19f55..4c7a067226a 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -147,7 +147,7 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont // calculate the minimum number of tokens received from input of tokenIn // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. - totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee(ctx)) + totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee()) tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, randomCoinSubset, coinOut.Denom, totalFees) if err != nil { return nil, err @@ -188,7 +188,7 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con // utilize CalcOutAmtGivenIn to calculate tokenOut and use tokenOut to calculate tokenInMax // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. - totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee(ctx)) + totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee()) tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, totalFees) if err != nil { return nil, err diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 38d19e2bfe6..30823332477 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -109,7 +109,7 @@ func (k Keeper) createPoolZeroLiquidityNoCreationFee(ctx sdk.Context, msg types. poolType := msg.GetPoolType() poolManagerParams := k.GetParams(ctx) - takerFee := determineTakerFee(poolManagerParams, poolAssets, poolType) + takerFee := DetermineTakerFee(poolManagerParams, poolAssets, poolType) // Create the pool with the given pool ID. pool, err := msg.CreatePool(ctx, poolId, takerFee) @@ -223,7 +223,7 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) // determineTakerFee determines what the taker fee should be based on the pool type and denoms given. // This taker fee can be overridden by governance after the pool is created. -func determineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { +func DetermineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { if poolType == types.Stableswap { return poolManagerParams.StableswapTakerFee } else { diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 4f4b5fdc5ec..06dc1f185a5 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -95,7 +95,7 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - takerFee := pool.GetTakerFee(ctx) + takerFee := pool.GetTakerFee() tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err @@ -215,7 +215,7 @@ func (k Keeper) SwapExactAmountIn( poolManagerParams := k.GetParams(ctx) spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := pool.GetTakerFee(ctx) + takerFee := pool.GetTakerFee() tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { @@ -321,7 +321,7 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, poolI.GetTakerFee(ctx)) + tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, poolI.GetTakerFee()) tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterTakerFee, routeStep.TokenOutDenom, spreadFactor) if err != nil { @@ -437,7 +437,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - takerFee := pool.GetTakerFee(ctx) + takerFee := pool.GetTakerFee() _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) if swapErr != nil { @@ -732,7 +732,7 @@ func (k Keeper) createMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := poolI.GetTakerFee(ctx) + takerFee := poolI.GetTakerFee() tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, spreadFactor) if err != nil { @@ -770,7 +770,7 @@ func (k Keeper) createOsmoMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := poolI.GetTakerFee(ctx) + takerFee := poolI.GetTakerFee() osmoDiscountedSpreadFactor := cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, osmoDiscountedSpreadFactor) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 94dd88511db..ac46ff67995 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1374,7 +1374,7 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := routeSpreadFactor.Mul((currentPoolSpreadFactor.Quo(sumOfSpreadFactors))) - takerFee := hopPool.GetTakerFee(cacheCtx) + takerFee := hopPool.GetTakerFee() swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) @@ -1397,7 +1397,7 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo s.Require().NoError(err) updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) - takerFee := hopPool.GetTakerFee(cacheCtx) + takerFee := hopPool.GetTakerFee() swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) @@ -1439,7 +1439,7 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := routeSpreadFactor.Mul(pool.GetSpreadFactor(cacheCtx).Quo(sumOfSpreadFactors)) - takerFee := pool.GetTakerFee(cacheCtx) + takerFee := pool.GetTakerFee() nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) @@ -1462,7 +1462,7 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := pool.GetSpreadFactor(cacheCtx) - takerFee := pool.GetTakerFee(cacheCtx) + takerFee := pool.GetTakerFee() nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 38e231b6504..ab96003415e 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -30,12 +30,31 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the poolmanager module type Params struct { - PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` - DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` - StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` - CustomPoolTakerFee []CustomPoolTakerFee `protobuf:"bytes,4,rep,name=trading_pair_taker_fee,json=tradingPairTakerFee,proto3" json:"trading_pair_taker_fee"` - OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,5,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` - NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,6,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` + PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` + // default_taker_fee is the fee used when creating a new pool that doesn't + // fall under a custom pool taker fee or stableswap taker fee category. + DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` + // stableswap_taker_fee is the fee used when creating a new pool in which all + // the underlying tokens are present in the stablecoin_denoms paramater entry + // OR has a liquid_stake_denom_pairings entry. + StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` + // osmo_taker_fee_distribution defines the distribution of taker fees + // generated in OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets distributed to + // stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. + OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,5,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` + // non_osmo_taker_fee_distribution defines the distribution of taker fees + // generated in non-OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets swapped to OSMO + // and then distirbuted to stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. Note: If the non-OSMO asset is an authorized_quote_denom, + // that denom is sent directly to the community pool. Otherwise, it is + // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and + // then sent to the community pool as that denom. + NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,6,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` // authorized_quote_denoms is a list of quote denoms that can be used as // token1 when creating a concentrated pool. We limit the quote assets to a // small set for the purposes of having convinient price increments stemming @@ -51,10 +70,14 @@ type Params struct { CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,8,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` // stablecoin_denoms is a list of denoms that are considered stablecoins. // This is used to determine if a pool should use the stableswap taker - // fee.bool LSTs are NOT apart of this catagory, even though they are eligible - // for stableswap taker fees. This is determined via the + // fee. Note: LSTs are NOT apart of this catagory, even though they are + // eligible for stableswap taker fees. This is determined via the // liquid_stake_denom_pairings field. - StablecoinDenoms []string `protobuf:"bytes,9,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` + StablecoinDenoms []string `protobuf:"bytes,9,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` + // liquid_stake_denom_pairings is a list of pairings of a natural denom with + // its corresponding LST denoms. If a pool is created with a natural denom + // that is paired with an LST denom, then the pool will be considered a + // stableswap pool and will use the stableswap taker fee. LiquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom `protobuf:"bytes,10,rep,name=liquid_stake_denom_pairings,json=liquidStakeDenomPairings,proto3" json:"liquid_stake_denom_pairings,omitempty" yaml:"liquid_stake_denom_pairings"` } @@ -98,13 +121,6 @@ func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -func (m *Params) GetCustomPoolTakerFee() []CustomPoolTakerFee { - if m != nil { - return m.CustomPoolTakerFee - } - return nil -} - func (m *Params) GetOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { if m != nil { return m.OsmoTakerFeeDistribution @@ -211,52 +227,6 @@ func (m *GenesisState) GetPoolRoutes() []ModuleRoute { return nil } -// CustomPoolTakerFee defines a custom taker fee for a specific pool. -type CustomPoolTakerFee struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` -} - -func (m *CustomPoolTakerFee) Reset() { *m = CustomPoolTakerFee{} } -func (m *CustomPoolTakerFee) String() string { return proto.CompactTextString(m) } -func (*CustomPoolTakerFee) ProtoMessage() {} -func (*CustomPoolTakerFee) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{2} -} -func (m *CustomPoolTakerFee) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *CustomPoolTakerFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_CustomPoolTakerFee.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *CustomPoolTakerFee) XXX_Merge(src proto.Message) { - xxx_messageInfo_CustomPoolTakerFee.Merge(m, src) -} -func (m *CustomPoolTakerFee) XXX_Size() int { - return m.Size() -} -func (m *CustomPoolTakerFee) XXX_DiscardUnknown() { - xxx_messageInfo_CustomPoolTakerFee.DiscardUnknown(m) -} - -var xxx_messageInfo_CustomPoolTakerFee proto.InternalMessageInfo - -func (m *CustomPoolTakerFee) GetPoolId() uint64 { - if m != nil { - return m.PoolId - } - return 0 -} - // TakerFeeDistributionPercentage defines what percent of the taker fee category // gets distributed to the available categories. type TakerFeeDistributionPercentage struct { @@ -268,7 +238,7 @@ func (m *TakerFeeDistributionPercentage) Reset() { *m = TakerFeeDistribu func (m *TakerFeeDistributionPercentage) String() string { return proto.CompactTextString(m) } func (*TakerFeeDistributionPercentage) ProtoMessage() {} func (*TakerFeeDistributionPercentage) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{3} + return fileDescriptor_aa099d9fbdf68b35, []int{2} } func (m *TakerFeeDistributionPercentage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -297,6 +267,8 @@ func (m *TakerFeeDistributionPercentage) XXX_DiscardUnknown() { var xxx_messageInfo_TakerFeeDistributionPercentage proto.InternalMessageInfo +// LiquidStakedTokenToUnderlyingDenom defines a pairing of a single natural +// denom with its corresponding LST denoms. type LiquidStakedTokenToUnderlyingDenom struct { LiquidStakedTokenDenoms []string `protobuf:"bytes,1,rep,name=liquid_staked_token_denoms,json=liquidStakedTokenDenoms,proto3" json:"liquid_staked_token_denoms,omitempty" yaml:"liquid_staked_token_denoms"` UnderlyingTokenDenom string `protobuf:"bytes,2,opt,name=underlying_token_denom,json=underlyingTokenDenom,proto3" json:"underlying_token_denom,omitempty" yaml:"underlying_token_denom"` @@ -306,7 +278,7 @@ func (m *LiquidStakedTokenToUnderlyingDenom) Reset() { *m = LiquidStaked func (m *LiquidStakedTokenToUnderlyingDenom) String() string { return proto.CompactTextString(m) } func (*LiquidStakedTokenToUnderlyingDenom) ProtoMessage() {} func (*LiquidStakedTokenToUnderlyingDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{4} + return fileDescriptor_aa099d9fbdf68b35, []int{3} } func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -352,7 +324,6 @@ func (m *LiquidStakedTokenToUnderlyingDenom) GetUnderlyingTokenDenom() string { func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") - proto.RegisterType((*CustomPoolTakerFee)(nil), "osmosis.poolmanager.v1beta1.CustomPoolTakerFee") proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") proto.RegisterType((*LiquidStakedTokenToUnderlyingDenom)(nil), "osmosis.poolmanager.v1beta1.LiquidStakedTokenToUnderlyingDenom") } @@ -362,71 +333,66 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 1023 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0xcf, 0x6e, 0xdb, 0xc6, - 0x13, 0x36, 0x63, 0xff, 0x94, 0x78, 0x9d, 0x5f, 0x1c, 0xb3, 0x8e, 0xc3, 0xd8, 0xad, 0xa8, 0xd0, - 0x68, 0xa0, 0x1e, 0x42, 0xc2, 0x2e, 0xd0, 0x00, 0x2d, 0x8a, 0xc2, 0xb4, 0x90, 0x34, 0x40, 0x9a, - 0x28, 0xb4, 0x8a, 0x00, 0xb9, 0x10, 0x2b, 0x71, 0x4d, 0x2f, 0x4c, 0xee, 0xca, 0xdc, 0xa5, 0x1d, - 0xf5, 0x54, 0xa0, 0x2f, 0x50, 0xa0, 0xb7, 0xa2, 0xe7, 0x1c, 0x7a, 0xeb, 0x3b, 0xf4, 0x90, 0x63, - 0x0e, 0x3d, 0x14, 0x3d, 0xb0, 0xad, 0xfc, 0x06, 0x7a, 0x82, 0x62, 0xff, 0x50, 0x7f, 0x2c, 0x5b, - 0xad, 0xdb, 0x93, 0xc4, 0x9d, 0xf9, 0xbe, 0xf9, 0x66, 0x76, 0x66, 0x48, 0xf0, 0x01, 0x65, 0x29, - 0x65, 0x98, 0x79, 0x5d, 0x4a, 0x93, 0x14, 0x12, 0x18, 0xa3, 0xcc, 0x3b, 0xde, 0x6a, 0x23, 0x0e, - 0xb7, 0xbc, 0x18, 0x11, 0xc4, 0x30, 0x73, 0xbb, 0x19, 0xe5, 0xd4, 0xdc, 0xd0, 0xae, 0xee, 0x98, - 0xab, 0x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7f, 0x85, - 0xa2, 0xf0, 0x28, 0xa7, 0x1c, 0x85, 0x11, 0x22, 0x34, 0x65, 0xd6, 0xd5, 0xda, 0x7c, 0x7d, 0xd1, - 0x77, 0x06, 0x85, 0x5d, 0x55, 0xd3, 0x72, 0x81, 0xa3, 0x13, 0xdc, 0x1a, 0x59, 0x9e, 0x0b, 0x43, - 0x43, 0x9e, 0x9b, 0x3f, 0x19, 0xe0, 0xa3, 0x0e, 0x4d, 0xd3, 0x9c, 0x60, 0xde, 0x0b, 0xe5, 0xac, - 0x49, 0x44, 0xc8, 0x69, 0x28, 0x3b, 0x56, 0x54, 0xe8, 0xe4, 0x00, 0x73, 0x94, 0x60, 0xc6, 0x51, - 0x14, 0x42, 0xc6, 0x10, 0x67, 0x21, 0xa7, 0xd6, 0x35, 0x35, 0x33, 0x83, 0xc2, 0xfe, 0x54, 0xc5, - 0xfe, 0x77, 0x3c, 0x4e, 0xe0, 0x0e, 0x81, 0xa2, 0xa7, 0xa4, 0xb0, 0x16, 0xdd, 0x3b, 0x81, 0xdd, - 0xa7, 0x94, 0xbc, 0x18, 0x41, 0x76, 0x24, 0xa2, 0x45, 0xcd, 0xc7, 0x60, 0x45, 0x35, 0xbc, 0x58, - 0x53, 0x65, 0x25, 0x16, 0x65, 0x25, 0xde, 0x1d, 0xed, 0x8d, 0x29, 0x17, 0x27, 0xb8, 0x39, 0x3a, - 0xd3, 0xe9, 0xbf, 0x36, 0xc0, 0x46, 0x82, 0x8f, 0x72, 0x1c, 0x85, 0x4c, 0xb4, 0x80, 0x16, 0x2d, - 0x06, 0x06, 0x93, 0x98, 0x59, 0x40, 0x8e, 0xca, 0x67, 0x33, 0xef, 0xff, 0x89, 0xc4, 0xef, 0x09, - 0x78, 0xd4, 0xa2, 0x87, 0x88, 0xb4, 0xe8, 0x97, 0x24, 0x42, 0x59, 0xd2, 0xc3, 0x24, 0x96, 0x71, - 0xfc, 0x7b, 0x83, 0xc2, 0x76, 0x94, 0xac, 0x19, 0xd1, 0x9c, 0xc0, 0x4a, 0x46, 0x5c, 0x12, 0xd9, - 0x2c, 0x4d, 0x3f, 0x1b, 0xe0, 0xfa, 0x23, 0xf5, 0x06, 0xd9, 0xe3, 0x90, 0x23, 0xb3, 0x06, 0xae, - 0x13, 0xf4, 0x8a, 0xab, 0x52, 0xe3, 0xc8, 0x32, 0x6a, 0x46, 0x7d, 0x21, 0x00, 0xe2, 0x4c, 0x54, - 0xf1, 0x71, 0x64, 0xee, 0x80, 0x4a, 0x57, 0x2e, 0x62, 0xb9, 0xdd, 0x96, 0xb6, 0x37, 0x67, 0x66, - 0xa1, 0x76, 0xb6, 0xbf, 0x20, 0xba, 0x35, 0xd0, 0x40, 0xf3, 0x19, 0x58, 0x92, 0xfc, 0x72, 0xc1, - 0x33, 0x6b, 0x5e, 0x56, 0xa3, 0x3e, 0x93, 0xe7, 0x0b, 0xf9, 0x4a, 0x08, 0x04, 0x40, 0x93, 0x01, - 0xe1, 0x26, 0x0f, 0x98, 0xf3, 0xbd, 0x01, 0xce, 0x59, 0x1f, 0xe6, 0x26, 0xb8, 0x3a, 0x91, 0x87, - 0x0f, 0xfa, 0x85, 0x5d, 0x51, 0x79, 0x04, 0x95, 0xae, 0xca, 0x27, 0x04, 0x8b, 0x67, 0x17, 0xb6, - 0x7f, 0xb9, 0xf5, 0x39, 0x28, 0xec, 0x9b, 0xea, 0x16, 0x86, 0x44, 0x4e, 0x70, 0x8d, 0x6b, 0x15, - 0xce, 0x37, 0x57, 0x40, 0x75, 0xf6, 0x30, 0x9b, 0x47, 0x60, 0x59, 0xdc, 0x9c, 0x58, 0xaa, 0x19, - 0x3a, 0x81, 0x59, 0xc4, 0xa4, 0xe0, 0x45, 0xff, 0xf3, 0x4b, 0x2b, 0x59, 0x1b, 0xb6, 0xe9, 0x38, - 0x9d, 0x13, 0xdc, 0xd0, 0x27, 0x81, 0x3a, 0x30, 0x09, 0xb8, 0x31, 0x39, 0x58, 0x3a, 0xf7, 0x47, - 0x97, 0x8e, 0x78, 0xeb, 0xbc, 0x31, 0x75, 0x82, 0xff, 0x4f, 0x8c, 0x9f, 0xf3, 0xa7, 0x01, 0x9c, - 0xbf, 0x6f, 0x69, 0xb3, 0x0d, 0xd6, 0xc7, 0x5b, 0x39, 0x0a, 0xb9, 0xf0, 0x2b, 0xa7, 0xd1, 0x90, - 0xd3, 0xf8, 0xfe, 0xa0, 0xb0, 0xef, 0x4e, 0xb7, 0xfd, 0xa4, 0xaf, 0x13, 0xdc, 0x4e, 0xce, 0x86, - 0xd3, 0xd3, 0xf9, 0x02, 0xac, 0xe5, 0xc3, 0xb0, 0xe3, 0x20, 0x5d, 0x82, 0xbb, 0x83, 0xc2, 0x7e, - 0x4f, 0xf1, 0x9f, 0xef, 0xe7, 0x04, 0xab, 0x23, 0xc3, 0x88, 0xd9, 0x7f, 0xfe, 0xa6, 0x5f, 0x35, - 0xde, 0xf6, 0xab, 0xc6, 0x1f, 0xfd, 0xaa, 0xf1, 0xed, 0x69, 0x75, 0xee, 0xed, 0x69, 0x75, 0xee, - 0xd7, 0xd3, 0xea, 0xdc, 0xcb, 0x07, 0x63, 0xd5, 0xd4, 0x6d, 0x7e, 0x3f, 0x81, 0x6d, 0x56, 0x3e, - 0x78, 0xc7, 0x5b, 0x0f, 0xbc, 0x57, 0x13, 0x1f, 0x43, 0xb2, 0xc4, 0xed, 0x8a, 0xfc, 0xfc, 0xf9, - 0xf0, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x14, 0x81, 0x9d, 0x04, 0x0a, 0x00, 0x00, + // 934 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0xc4, + 0x1b, 0x8e, 0x9b, 0xfe, 0xf2, 0x63, 0x27, 0xa5, 0x21, 0x56, 0xda, 0xba, 0x09, 0xd8, 0x5b, 0x57, + 0x54, 0xcb, 0xa1, 0xb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, 0x31, 0x57, 0x77, 0x6b, 0xb4, 0xbf, 0xbc, + 0xd8, 0xa2, 0x1a, 0x95, 0xce, 0xf5, 0xb1, 0x13, 0xa6, 0xe9, 0xdc, 0xe0, 0xaa, 0x8e, 0x04, 0x55, + 0xc0, 0xa4, 0xe8, 0xea, 0xac, 0x77, 0xf5, 0x32, 0x7e, 0x78, 0x61, 0xc5, 0x6b, 0x67, 0xbd, 0x04, + 0x37, 0x78, 0x77, 0xc6, 0xe1, 0xee, 0x9f, 0x06, 0x72, 0xff, 0xde, 0x35, 0x66, 0x84, 0xd6, 0xa7, + 0xdd, 0x12, 0x87, 0x42, 0xd6, 0xd5, 0x86, 0x37, 0x94, 0xe1, 0x3f, 0x1c, 0x95, 0xce, 0xad, 0xd3, + 0xce, 0x9a, 0xad, 0x75, 0x83, 0x1b, 0xe9, 0xdb, 0x72, 0xfa, 0x01, 0x3c, 0x47, 0xd7, 0x8b, 0xb1, + 0xec, 0x34, 0x48, 0x8f, 0xe0, 0xd6, 0xa8, 0x74, 0x3e, 0xa8, 0xf8, 0xcf, 0xae, 0x73, 0x83, 0xb5, + 0x49, 0x62, 0xc2, 0xdc, 0x7e, 0xf6, 0x7a, 0x68, 0x1b, 0x6f, 0x86, 0xb6, 0xf1, 0xc7, 0xd0, 0x36, + 0xbe, 0x3b, 0xb1, 0x17, 0xde, 0x9c, 0xd8, 0x0b, 0xbf, 0x9e, 0xd8, 0x0b, 0x2f, 0xee, 0x4d, 0x4d, + 0x53, 0x3b, 0xe9, 0x6e, 0x8a, 0x23, 0x5e, 0x1f, 0xfc, 0xa3, 0xcd, 0x7b, 0xfe, 0xcb, 0x99, 0x8f, + 0xbd, 0x1a, 0x71, 0xb4, 0xa4, 0x3e, 0xef, 0x1f, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0x42, 0x15, + 0xdf, 0x9b, 0xe4, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -508,20 +474,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x2a - if len(m.CustomPoolTakerFee) > 0 { - for iNdEx := len(m.CustomPoolTakerFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.CustomPoolTakerFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } { size := m.StableswapTakerFee.Size() i -= size @@ -611,44 +563,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *CustomPoolTakerFee) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *CustomPoolTakerFee) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *CustomPoolTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - if m.PoolId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.PoolId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func (m *TakerFeeDistributionPercentage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -758,12 +672,6 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.StableswapTakerFee.Size() n += 1 + l + sovGenesis(uint64(l)) - if len(m.CustomPoolTakerFee) > 0 { - for _, e := range m.CustomPoolTakerFee { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } l = m.OsmoTakerFeeDistribution.Size() n += 1 + l + sovGenesis(uint64(l)) l = m.NonOsmoTakerFeeDistribution.Size() @@ -813,20 +721,6 @@ func (m *GenesisState) Size() (n int) { return n } -func (m *CustomPoolTakerFee) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.PoolId != 0 { - n += 1 + sovGenesis(uint64(m.PoolId)) - } - l = m.TakerFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - func (m *TakerFeeDistributionPercentage) Size() (n int) { if m == nil { return 0 @@ -996,40 +890,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CustomPoolTakerFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CustomPoolTakerFee = append(m.CustomPoolTakerFee, CustomPoolTakerFee{}) - if err := m.CustomPoolTakerFee[len(m.CustomPoolTakerFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmoTakerFeeDistribution", wireType) @@ -1383,109 +1243,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } return nil } -func (m *CustomPoolTakerFee) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: CustomPoolTakerFee: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: CustomPoolTakerFee: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolId", wireType) - } - m.PoolId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.PoolId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func (m *TakerFeeDistributionPercentage) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/pool.go b/x/poolmanager/types/pool.go index dcc59cd48b8..a196f8ffdca 100644 --- a/x/poolmanager/types/pool.go +++ b/x/poolmanager/types/pool.go @@ -19,7 +19,8 @@ type PoolI interface { // (prior TWAPs, network downtime, other pool states, etc.) // hence Context is provided as an argument. GetSpreadFactor(ctx sdk.Context) sdk.Dec - GetTakerFee(ctx sdk.Context) sdk.Dec + GetTakerFee() sdk.Dec + SetTakerFee(newTakerFee sdk.Dec) // Returns whether the pool has swaps enabled at the moment IsActive(ctx sdk.Context) bool From a3863d55caa500b1c16c91d85b903a23adff12e5 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 18 Aug 2023 16:20:40 -0500 Subject: [PATCH 15/83] remove param that no longer exists --- x/poolmanager/keeper_test.go | 20 +++----------------- x/poolmanager/types/params.go | 29 +---------------------------- 2 files changed, 4 insertions(+), 45 deletions(-) diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 259f2902ac9..427b985ebaa 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -18,19 +18,9 @@ type KeeperTestSuite struct { const testExpectedPoolId = 3 var ( - testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} - testDefaultTakerFee = sdk.MustNewDecFromStr("0.0015") - testStableswapTakerFee = sdk.MustNewDecFromStr("0.0002") - testCustomPoolTakerFee = []types.CustomPoolTakerFee{ - { - PoolId: 1, - TakerFee: sdk.MustNewDecFromStr("0.0005"), - }, - { - PoolId: 2, - TakerFee: sdk.MustNewDecFromStr("0.0001"), - }, - } + testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} + testDefaultTakerFee = sdk.MustNewDecFromStr("0.0015") + testStableswapTakerFee = sdk.MustNewDecFromStr("0.0002") testOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ StakingRewards: sdk.MustNewDecFromStr("0.3"), CommunityPool: sdk.MustNewDecFromStr("0.7"), @@ -94,7 +84,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { PoolCreationFee: testPoolCreationFee, DefaultTakerFee: testDefaultTakerFee, StableswapTakerFee: testStableswapTakerFee, - CustomPoolTakerFee: testCustomPoolTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, @@ -109,7 +98,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Require().Equal(testPoolCreationFee, params.PoolCreationFee) s.Require().Equal(testDefaultTakerFee, params.DefaultTakerFee) s.Require().Equal(testStableswapTakerFee, params.StableswapTakerFee) - s.Require().Equal(testCustomPoolTakerFee, params.CustomPoolTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, params.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, params.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) @@ -122,7 +110,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { PoolCreationFee: testPoolCreationFee, DefaultTakerFee: testDefaultTakerFee, StableswapTakerFee: testStableswapTakerFee, - CustomPoolTakerFee: testCustomPoolTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, @@ -137,7 +124,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(testPoolCreationFee, genesis.Params.PoolCreationFee) s.Require().Equal(testDefaultTakerFee, genesis.Params.DefaultTakerFee) s.Require().Equal(testStableswapTakerFee, genesis.Params.StableswapTakerFee) - s.Require().Equal(testCustomPoolTakerFee, genesis.Params.CustomPoolTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 2bbf40acb8f..49c2f4f476b 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -14,7 +14,6 @@ var ( KeyPoolCreationFee = []byte("PoolCreationFee") KeyDefaultTakerFee = []byte("DefaultTakerFee") KeyStableswapTakerFee = []byte("StableswapTakerFee") - KeyCustomPoolTakerFee = []byte("CustomPoolTakerFee") KeyOsmoTakerFeeDistribution = []byte("OsmoTakerFeeDistribution") KeyNonOsmoTakerFeeDistribution = []byte("NonOsmoTakerFeeDistribution") KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") @@ -26,12 +25,11 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, customPoolTakerFee []CustomPoolTakerFee, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { +func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { return Params{ PoolCreationFee: poolCreationFee, DefaultTakerFee: defaultTakerFee, StableswapTakerFee: stableswapTakerFee, - CustomPoolTakerFee: customPoolTakerFee, OsmoTakerFeeDistribution: osmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: authorizedQuoteDenoms, @@ -45,7 +43,6 @@ func DefaultParams() Params { PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% - CustomPoolTakerFee: []CustomPoolTakerFee{}, OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ StakingRewards: sdk.MustNewDecFromStr("1"), // 100% CommunityPool: sdk.MustNewDecFromStr("0"), // 0% @@ -75,9 +72,6 @@ func (p Params) Validate() error { if err := validateStableswapTakerFee(p.StableswapTakerFee); err != nil { return err } - if err := validateCustomPoolTakerFee(p.CustomPoolTakerFee); err != nil { - return err - } if err := validateTakerFeeDistribution(p.OsmoTakerFeeDistribution); err != nil { return err } @@ -100,7 +94,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), paramtypes.NewParamSetPair(KeyDefaultTakerFee, &p.DefaultTakerFee, validateDefaultTakerFee), paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.StableswapTakerFee, validateStableswapTakerFee), - paramtypes.NewParamSetPair(KeyCustomPoolTakerFee, &p.CustomPoolTakerFee, validateCustomPoolTakerFee), paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.OsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyAuthorizedQuoteDenoms, &p.AuthorizedQuoteDenoms, validateAuthorizedQuoteDenoms), @@ -153,26 +146,6 @@ func validateStableswapTakerFee(i interface{}) error { return nil } -func validateCustomPoolTakerFee(i interface{}) error { - // Convert the given parameter to sdk.Dec. - customPoolTakerFee, ok := i.([]CustomPoolTakerFee) - - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - for _, customPoolTakerFee := range customPoolTakerFee { - if customPoolTakerFee.PoolId <= 0 { - return fmt.Errorf("invalid pool ID: %d", customPoolTakerFee.PoolId) - } - if customPoolTakerFee.TakerFee.IsNegative() || customPoolTakerFee.TakerFee.GT(sdk.OneDec()) { - return fmt.Errorf("invalid taker fee: %s", customPoolTakerFee.TakerFee) - } - } - - return nil -} - func validateTakerFeeDistribution(i interface{}) error { // Convert the given parameter to sdk.Dec. takerFeeDistribution, ok := i.(TakerFeeDistributionPercentage) From e4294a4b045840f7f77a7e390aaf6518577176d0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 18 Aug 2023 16:44:11 -0500 Subject: [PATCH 16/83] add extra params to genesis logic --- x/poolmanager/keeper_test.go | 20 +++++++++ x/poolmanager/types/params.go | 79 ++++++++++++++++++++++++++++++++++- 2 files changed, 98 insertions(+), 1 deletion(-) diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 427b985ebaa..c02f6d715a3 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -31,6 +31,17 @@ var ( } testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" + testStablecoinDenoms = []string{"uusdc", "uusdt", "udai"} + testLiquidStakeDenomPairings = []*types.LiquidStakedTokenToUnderlyingDenom{ + { + LiquidStakedTokenDenoms: []string{"ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC"}, + UnderlyingTokenDenom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM + }, + { + LiquidStakedTokenDenoms: []string{"ibc/D176154B0C63D1F9C6DCFB4F70349EBF2E2B5A87A05902F57A6AE92B863E9AEC", "ibc/42D24879D4569CE6477B7E88206ADBFE47C222C6CAD51A54083E4A72594269FC"}, + UnderlyingTokenDenom: "uosmo", + }, + } testPoolRoute = []types.ModuleRoute{ { @@ -88,6 +99,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, + StablecoinDenoms: testStablecoinDenoms, + LiquidStakeDenomPairings: testLiquidStakeDenomPairings, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -101,6 +114,9 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Require().Equal(testOsmoTakerFeeDistribution, params.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, params.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) + s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + s.Require().Equal(testStablecoinDenoms, params.StablecoinDenoms) + s.Require().Equal(testLiquidStakeDenomPairings, params.LiquidStakeDenomPairings) s.Require().Equal(testPoolRoute, s.App.PoolManagerKeeper.GetAllPoolRoutes(s.Ctx)) } @@ -114,6 +130,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, + StablecoinDenoms: testStablecoinDenoms, + LiquidStakeDenomPairings: testLiquidStakeDenomPairings, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -128,5 +146,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + s.Require().Equal(testStablecoinDenoms, genesis.Params.StablecoinDenoms) + s.Require().Equal(testLiquidStakeDenomPairings, genesis.Params.LiquidStakeDenomPairings) s.Require().Equal(testPoolRoute, genesis.PoolRoutes) } diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 49c2f4f476b..975611fea34 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -18,6 +18,8 @@ var ( KeyNonOsmoTakerFeeDistribution = []byte("NonOsmoTakerFeeDistribution") KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo = []byte("CommunityPoolDenomToSwapNonWhitelistedAssetsTo") + KeyStablecoinDenoms = []byte("StablecoinDenoms") + KeyLiquidStakeDenomPairings = []byte("LiquidStakeDenomPairings") ) // ParamTable for gamm module. @@ -25,7 +27,13 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { +func NewParams(poolCreationFee sdk.Coins, + defaultTakerFee, stableswapTakerFee sdk.Dec, + osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, + authorizedQuoteDenoms []string, + communityPoolDenomToSwapNonWhitelistedAssetsTo string, + stablecoinDenoms []string, + liquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom) Params { return Params{ PoolCreationFee: poolCreationFee, DefaultTakerFee: defaultTakerFee, @@ -34,6 +42,8 @@ func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sd NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, AuthorizedQuoteDenoms: authorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: communityPoolDenomToSwapNonWhitelistedAssetsTo, + StablecoinDenoms: stablecoinDenoms, + LiquidStakeDenomPairings: liquidStakeDenomPairings, } } @@ -58,6 +68,20 @@ func DefaultParams() Params { "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC }, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC + StablecoinDenoms: []string{ + "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", // DAI + "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC + }, + LiquidStakeDenomPairings: []*LiquidStakedTokenToUnderlyingDenom{ + { + LiquidStakedTokenDenoms: []string{"ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC"}, + UnderlyingTokenDenom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM + }, + { + LiquidStakedTokenDenoms: []string{"ibc/D176154B0C63D1F9C6DCFB4F70349EBF2E2B5A87A05902F57A6AE92B863E9AEC", "ibc/42D24879D4569CE6477B7E88206ADBFE47C222C6CAD51A54083E4A72594269FC"}, + UnderlyingTokenDenom: "uosmo", + }, + }, } } @@ -84,6 +108,12 @@ func (p Params) Validate() error { if err := validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo); err != nil { return err } + if err := validateStablecoinDenoms(p.StablecoinDenoms); err != nil { + return err + } + if err := validateLiquidStakeDenomPairings(p.LiquidStakeDenomPairings); err != nil { + return err + } return nil } @@ -98,6 +128,8 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyAuthorizedQuoteDenoms, &p.AuthorizedQuoteDenoms, validateAuthorizedQuoteDenoms), paramtypes.NewParamSetPair(KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo, &p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo, validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo), + paramtypes.NewParamSetPair(KeyStablecoinDenoms, &p.StablecoinDenoms, validateStablecoinDenoms), + paramtypes.NewParamSetPair(KeyLiquidStakeDenomPairings, &p.LiquidStakeDenomPairings, validateLiquidStakeDenomPairings), } } @@ -206,3 +238,48 @@ func validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(i interface{}) error return nil } + +func validateStablecoinDenoms(i interface{}) error { + stablecoinDenoms, ok := i.([]string) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if len(stablecoinDenoms) == 0 { + return fmt.Errorf("stablecoin denoms cannot be empty") + } + + for _, denom := range stablecoinDenoms { + if err := sdk.ValidateDenom(denom); err != nil { + return err + } + } + + return nil +} + +func validateLiquidStakeDenomPairings(i interface{}) error { + liquidStakeDenomPairings, ok := i.([]*LiquidStakedTokenToUnderlyingDenom) + + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if len(liquidStakeDenomPairings) == 0 { + return fmt.Errorf("liquid stake denom pairings cannot be empty") + } + + for _, pairing := range liquidStakeDenomPairings { + for _, lst := range pairing.LiquidStakedTokenDenoms { + if err := sdk.ValidateDenom(lst); err != nil { + return err + } + } + if err := sdk.ValidateDenom(pairing.UnderlyingTokenDenom); err != nil { + return err + } + } + + return nil +} From f21dba0bdb2acde580a4133b8b94ccaf0f845c4c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 18 Aug 2023 17:28:03 -0500 Subject: [PATCH 17/83] add back osmo multihop tests --- x/poolmanager/router_test.go | 301 +++++++++++++++++++++++++++++++++++ 1 file changed, 301 insertions(+) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index ac46ff67995..7f4e3a5cba5 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -2315,6 +2315,307 @@ func (s *KeeperTestSuite) TestGetTotalPoolLiquidity() { } } +func (s *KeeperTestSuite) TestIsOsmoRoutedMultihop() { + tests := map[string]struct { + route types.MultihopRoute + balancerPoolCoins []sdk.Coins + concentratedPoolDenoms [][]string + incentivizedGauges []uint64 + inDenom string + outDenom string + expectIsRouted bool + }{ + "happy path: osmo routed (balancer)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + balancerPoolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. + }, + // Note that we incentivize all candidate gauges for the sake of test readability. + incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, + inDenom: foo, + outDenom: bar, + + expectIsRouted: true, + }, + "happy path: osmo routed (balancer, only one active gauge for each pool)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + balancerPoolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. + }, + incentivizedGauges: []uint64{1, 4}, + inDenom: foo, + outDenom: bar, + + expectIsRouted: true, + }, + "osmo routed (concentrated)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + concentratedPoolDenoms: [][]string{ + {foo, uosmo}, // pool 1. + {uosmo, baz}, // pool 2. + }, + incentivizedGauges: []uint64{1, 2}, + inDenom: foo, + outDenom: bar, + + expectIsRouted: true, + }, + "osmo routed (mixed concentrated and balancer)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + concentratedPoolDenoms: [][]string{ + {foo, uosmo}, // pool 1. + }, + balancerPoolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. + }, + + incentivizedGauges: []uint64{1, 2}, + inDenom: foo, + outDenom: bar, + + expectIsRouted: true, + }, + "not osmo routed (single pool)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: bar, + }, + }), + inDenom: foo, + outDenom: bar, + + expectIsRouted: false, + }, + "not osmo routed (two pools)": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: bar, + }, + { + PoolId: 2, + TokenOutDenom: baz, + }, + }), + inDenom: foo, + outDenom: baz, + + expectIsRouted: false, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + poolManagerKeeper := s.App.PoolManagerKeeper + + // Create pools to route through + if tc.concentratedPoolDenoms != nil { + s.CreateConcentratedPoolsAndFullRangePosition(tc.concentratedPoolDenoms) + } + + if tc.balancerPoolCoins != nil { + s.createBalancerPoolsFromCoins(tc.balancerPoolCoins) + } + + // If test specifies incentivized gauges, set them here + if len(tc.incentivizedGauges) > 0 { + s.makeGaugesIncentivized(tc.incentivizedGauges) + } + + // System under test + isRouted := poolManagerKeeper.IsOsmoRoutedMultihop(s.Ctx, tc.route, tc.inDenom, tc.outDenom) + + // Check output + s.Require().Equal(tc.expectIsRouted, isRouted) + }) + } +} + +// TestGetOsmoRoutedMultihopTotalSpreadFactor tests the GetOsmoRoutedMultihopTotalSpreadFactor function +func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { + tests := map[string]struct { + route types.MultihopRoute + balancerPoolCoins []sdk.Coins + concentratedPoolDenoms [][]string + poolFees []sdk.Dec + + expectedRouteFee sdk.Dec + expectedTotalFee sdk.Dec + expectedError error + }{ + "happy path: balancer route": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + balancerPoolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 1. + sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. + }, + + expectedRouteFee: defaultPoolSpreadFactor, + expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), + }, + "concentrated route": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + concentratedPoolDenoms: [][]string{ + {foo, uosmo}, // pool 1. + {uosmo, baz}, // pool 2. + }, + + expectedRouteFee: defaultPoolSpreadFactor, + expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), + }, + "mixed concentrated and balancer route": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + concentratedPoolDenoms: [][]string{ + {foo, uosmo}, // pool 1. + }, + balancerPoolCoins: []sdk.Coins{ + sdk.NewCoins(sdk.NewCoin(uosmo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), // pool 2. + }, + + expectedRouteFee: defaultPoolSpreadFactor, + expectedTotalFee: defaultPoolSpreadFactor.Add(defaultPoolSpreadFactor), + }, + "edge case: average fee is lower than highest pool fee": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + // Note that pool 2 has 5x the swap fee of pool 1 + poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor.Mul(sdk.NewDec(5))}, + concentratedPoolDenoms: [][]string{ + {foo, uosmo}, // pool 1. + {uosmo, baz}, // pool 2. + }, + + expectedRouteFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(5)), + expectedTotalFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(6)), + }, + "error: pool does not exist": { + route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ + { + PoolId: 1, + TokenOutDenom: uosmo, + }, + { + PoolId: 2, + TokenOutDenom: bar, + }, + }), + poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + + expectedError: types.FailedToFindRouteError{PoolId: 1}, + }, + } + + for name, tc := range tests { + s.Run(name, func() { + s.SetupTest() + poolManagerKeeper := s.App.PoolManagerKeeper + + // Create pools for test route + if tc.concentratedPoolDenoms != nil { + s.CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(tc.concentratedPoolDenoms, tc.poolFees) + } + + if tc.balancerPoolCoins != nil { + s.createBalancerPoolsFromCoinsWithSpreadFactor(tc.balancerPoolCoins, tc.poolFees) + } + + // System under test + routeFee, totalFee, err := poolManagerKeeper.GetOsmoRoutedMultihopTotalSpreadFactor(s.Ctx, tc.route) + + // Assertions + if tc.expectedError != nil { + s.Require().Error(err) + s.Require().Equal(tc.expectedError.Error(), err.Error()) + s.Require().Equal(sdk.Dec{}, routeFee) + s.Require().Equal(sdk.Dec{}, totalFee) + return + } + + s.Require().NoError(err) + s.Require().Equal(tc.expectedRouteFee, routeFee) + s.Require().Equal(tc.expectedTotalFee, totalFee) + }) + } +} + func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { tests := map[string]struct { route []types.SwapAmountOutRoute From 48f1d6fc496148af648f8f8defb68d925cae0617 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 18 Aug 2023 17:35:39 -0500 Subject: [PATCH 18/83] add comment --- x/txfees/keeper/keeper_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 03df022dae3..ca02e28cb03 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -37,6 +37,8 @@ func (s *KeeperTestSuite) SetupTest(isCheckTx bool) { WithLegacyAmino(encodingConfig.Amino). WithCodec(encodingConfig.Marshaler) + // We Set the base denom here in order for highest liquidity routes to get generated. + // This is used in the tx fees epoch hook to swap the non OSMO to other tokens. baseDenom, err := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) s.Require().NoError(err) From 3fe5742eefc0c5f995ad148e5d251a2c43bad48c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 13:21:07 -0500 Subject: [PATCH 19/83] fix e2e keeping prints --- tests/e2e/configurer/chain/commands.go | 31 +++++++- tests/e2e/e2e_test.go | 88 ++++++++++++++++++---- tests/e2e/helpers_e2e_test.go | 19 ++++- x/concentrated-liquidity/incentives.go | 6 ++ x/concentrated-liquidity/spread_rewards.go | 11 +++ x/concentrated-liquidity/swaps.go | 7 ++ x/poolmanager/router.go | 12 +-- 7 files changed, 148 insertions(+), 26 deletions(-) diff --git a/tests/e2e/configurer/chain/commands.go b/tests/e2e/configurer/chain/commands.go index a9c3c3e9358..8782943ccfb 100644 --- a/tests/e2e/configurer/chain/commands.go +++ b/tests/e2e/configurer/chain/commands.go @@ -103,7 +103,7 @@ func (n *NodeConfig) CreateConcentratedPool(from, denom1, denom2 string, tickSpa // CreateConcentratedPosition creates a concentrated position from [lowerTick; upperTick] in pool with id of poolId // token{0,1} - liquidity to create position with -func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick string, tokens string, token0MinAmt, token1MinAmt int64, poolId uint64) uint64 { +func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick string, tokens string, token0MinAmt, token1MinAmt int64, poolId uint64) (uint64, sdk.Dec) { n.LogActionF("creating concentrated position") // gas = 50,000 because e2e default to 40,000, we hardcoded extra 10k gas to initialize tick // fees = 1250 (because 50,000 * 0.0025 = 1250) @@ -114,9 +114,12 @@ func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick strin positionID, err := extractPositionIdFromResponse(resp.Bytes()) require.NoError(n.t, err) + liquidity, err := extractLiquidityFromResponse(resp.Bytes()) + require.NoError(n.t, err) + n.LogActionF("successfully created concentrated position from %s to %s", lowerTick, upperTick) - return positionID + return positionID, liquidity } func (n *NodeConfig) StoreWasmCode(wasmFile, from string) int { @@ -580,6 +583,10 @@ func GetPositionID(responseJson map[string]interface{}) (string, error) { return ParseEvent(responseJson, "position_id") } +func GetLiquidity(responseJson map[string]interface{}) (string, error) { + return ParseEvent(responseJson, "liquidity") +} + func ParseEvent(responseJson map[string]interface{}, field string) (string, error) { logs, ok := responseJson["logs"].([]interface{}) if !ok { @@ -859,6 +866,26 @@ func extractPositionIdFromResponse(responseBytes []byte) (uint64, error) { return positionID, nil } +func extractLiquidityFromResponse(responseBytes []byte) (sdk.Dec, error) { + var txResponse map[string]interface{} + err := json.Unmarshal(responseBytes, &txResponse) + if err != nil { + return sdk.Dec{}, err + } + + liquidityString, err := GetLiquidity(txResponse) + if err != nil { + return sdk.Dec{}, err + } + + positionID, err := sdk.NewDecFromStr(liquidityString) + if err != nil { + return sdk.Dec{}, err + } + + return positionID, nil +} + func extractCodeIdFromResponse(response string) (int, error) { startIndex := strings.Index(response, `{"key":"code_id","value":"`) + len(`{"key":"code_id","value":"`) endIndex := strings.Index(response[startIndex:], `"`) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 9a72774afe4..5a9ae1ca2c1 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -318,7 +318,6 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { s.Require().NoError(err) // Update the protorev admin address to a known wallet we can control - adminWalletAddr := chainABNode.CreateWalletAndFund("admin", []string{"4000000uosmo"}, chainAB) err = chainABNode.ParamChangeProposal("protorev", string(protorevtypes.ParamStoreKeyAdminAccount), []byte(fmt.Sprintf(`"%s"`, adminWalletAddr)), chainAB) s.Require().NoError(err) @@ -357,16 +356,23 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { address2 := chainABNode.CreateWalletAndFund("addr2", fundTokens, chainAB) address3 := chainABNode.CreateWalletAndFund("addr3", fundTokens, chainAB) + totalLiquidity := sdk.ZeroDec() + // Create 2 positions for address1: overlap together, overlap with 2 address3 positions - chainABNode.CreateConcentratedPosition(address1, "[-120000]", "40000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) - chainABNode.CreateConcentratedPosition(address1, "[-40000]", "120000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + _, liquidity := chainABNode.CreateConcentratedPosition(address1, "[-120000]", "40000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + totalLiquidity = totalLiquidity.Add(liquidity) + _, liquidity = chainABNode.CreateConcentratedPosition(address1, "[-40000]", "120000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + totalLiquidity = totalLiquidity.Add(liquidity) // Create 1 position for address2: does not overlap with anything, ends at maximum - chainABNode.CreateConcentratedPosition(address2, "220000", fmt.Sprintf("%d", cltypes.MaxTick), fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + _, liquidity = chainABNode.CreateConcentratedPosition(address2, "220000", fmt.Sprintf("%d", cltypes.MaxTick), fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + totalLiquidity = totalLiquidity.Add(liquidity) // Create 2 positions for address3: overlap together, overlap with 2 address1 positions, one position starts from minimum - chainABNode.CreateConcentratedPosition(address3, "[-160000]", "[-20000]", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) - chainABNode.CreateConcentratedPosition(address3, fmt.Sprintf("[%d]", cltypes.MinInitializedTick), "140000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + _, liquidity = chainABNode.CreateConcentratedPosition(address3, "[-160000]", "[-20000]", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + totalLiquidity = totalLiquidity.Add(liquidity) + _, liquidity = chainABNode.CreateConcentratedPosition(address3, fmt.Sprintf("[%d]", cltypes.MinInitializedTick), "140000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) + totalLiquidity = totalLiquidity.Add(liquidity) // Get newly created positions positionsAddress1 := chainABNode.QueryConcentratedPositions(address1) @@ -401,6 +407,9 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Second position third address s.validateCLPosition(addr3position2, poolID, cltypes.MinInitializedTick, 140000) + // Note the pool's taker fee + takerFee := concentratedPool.GetTakerFee() + // Collect SpreadRewards var ( @@ -420,8 +429,17 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { ) // Perform swap (not crossing initialized ticks) chainABNode.SwapExactAmountIn(uosmoIn_Swap1, outMinAmt, fmt.Sprintf("%d", poolID), denom0, initialization.ValidatorWalletName) + // Calculate and track global spread reward growth for swap 1 - spreadRewardGrowthGlobal.AddMut(calculateSpreadRewardGrowthGlobal(uosmoInDec_Swap1.SDKDec(), spreadFactorDec, concentratedPool.GetLiquidity())) + uosmoInDec_Swap1_SubTakerFee := uosmoInDec_Swap1.SDKDec().Mul(sdk.OneDec().Sub(takerFee)).TruncateDec() + uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor := uosmoInDec_Swap1_SubTakerFee.Mul(sdk.OneDec().Sub(spreadFactorDec)) + totalSpreadReward := uosmoInDec_Swap1_SubTakerFee.Sub(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).TruncateDec() + + // fmt.Println("uosmoInDec_Swap1_AfterTakerFee", uosmoInDec_Swap1_SubTakerFee) + // fmt.Println("totalSpreadReward", totalSpreadReward) + spreadRewardGrowthGlobal.AddMut(calculateSpreadRewardGrowthGlobal(totalSpreadReward, concentratedPool.GetLiquidity())) + // fmt.Println("concentratedPool.GetLiquidity()", concentratedPool.GetLiquidity()) + // fmt.Println("spreadRewardGrowthGlobal", spreadRewardGrowthGlobal) // Update pool and track liquidity and sqrt price liquidityBeforeSwap := concentratedPool.GetLiquidity() @@ -436,10 +454,12 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { s.Require().Equal(liquidityAfterSwap.String(), liquidityBeforeSwap.String()) // Assert current sqrt price - inAmountSubSpreadReward := uosmoInDec_Swap1.Mul(osmomath.OneDec().Sub(osmomath.BigDecFromSDKDec(spreadFactorDec))) - expectedSqrtPriceDelta := inAmountSubSpreadReward.QuoTruncate(osmomath.BigDecFromSDKDec(concentratedPool.GetLiquidity())) // Δ(sqrtPrice) = Δy / L + expectedSqrtPriceDelta := osmomath.BigDecFromSDKDec(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).QuoTruncate(osmomath.BigDecFromSDKDec(concentratedPool.GetLiquidity())) // Δ(sqrtPrice) = Δy / L expectedSqrtPrice := sqrtPriceBeforeSwap.Add(expectedSqrtPriceDelta) + // fmt.Println("sqrtPriceAfterSwap", sqrtPriceAfterSwap.String()) + // fmt.Println("expectedSqrtPrice", expectedSqrtPrice.String()) + // fmt.Println("positionsAddress1[0].Position.Liquidity", positionsAddress1[0].Position.Liquidity) s.Require().Equal(expectedSqrtPrice.String(), sqrtPriceAfterSwap.String()) // Collect SpreadRewards: Swap 1 @@ -463,7 +483,23 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { spreadRewardGrowthGlobal, ) + spreadRewardGrowthGlobalBeforeDustRedistribution := spreadRewardGrowthGlobal.Clone() + // fmt.Println("PRE HERE", spreadRewardGrowthGlobalPre) + + // Determine forfeited dust amount + forfeitedDustAmt := spreadRewardsUncollectedAddress1Position1_Swap1.Sub(spreadRewardsUncollectedAddress1Position1_Swap1.TruncateDec()) + // fmt.Println("ADAM forfeitedDustAmt", forfeitedDustAmt) + forfeitedDust := sdk.NewDecCoins(sdk.NewDecCoinFromDec("uosmo", forfeitedDustAmt)) + + forfeitedDustPerShare := forfeitedDust.QuoDecTruncate(totalLiquidity) + // fmt.Println("ADAM forfeitedDustPerShare", forfeitedDustPerShare) + spreadRewardGrowthGlobal.AddMut(forfeitedDustPerShare.AmountOf("uosmo")) + // fmt.Println("ADAM spreadRewardGrowthGlobal after dust", spreadRewardGrowthGlobal) + // Assert + // fmt.Println("spreadRewardsUncollectedAddress1Position1_Swap1", spreadRewardsUncollectedAddress1Position1_Swap1.String()) + // fmt.Println("addr1BalancesBefore.AmountOf(\"uosmo\")", addr1BalancesBefore.AmountOf("uosmo").String()) + // fmt.Println("addr1BalancesAfter.AmountOf(\"uosmo\")", addr1BalancesAfter.AmountOf("uosmo").String()) s.Require().Equal( addr1BalancesBefore.AmountOf("uosmo").Add(spreadRewardsUncollectedAddress1Position1_Swap1.TruncateInt()).String(), addr1BalancesAfter.AmountOf("uosmo").String(), @@ -514,10 +550,18 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // uosmoInDec_Swap2_NoSpreadReward is calculated such that swapping this amount (not considering spread reward) moves the price over the next initialized tick uosmoInDec_Swap2_NoSpreadReward = amountInToGetToNextInitTick.Add(amountInToGetToTickAfterInitialized) uosmoInDec_Swap2 = uosmoInDec_Swap2_NoSpreadReward.Quo(sdk.OneDec().Sub(spreadFactorDec)).TruncateDec() // account for spread factor of 1% - uosmoIn_Swap2 = fmt.Sprintf("%suosmo", uosmoInDec_Swap2.String()) - spreadRewardGrowthGlobal_Swap1 = spreadRewardGrowthGlobal.Clone() + spreadRewardGrowthGlobal_Swap1 = spreadRewardGrowthGlobalBeforeDustRedistribution.Clone() ) + + // fmt.Println("uosmoInDec_Swap2_NoSpreadReward", uosmoInDec_Swap2_NoSpreadReward) + // fmt.Println("uosmoInDec_Swap2", uosmoInDec_Swap2) + + uosmoInDec_Swap2_AddTakerFee := uosmoInDec_Swap2.Quo(sdk.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee + uosmoIn_Swap2 := fmt.Sprintf("%suosmo", uosmoInDec_Swap2_AddTakerFee.String()) + + // fmt.Println("tokenIn for swap2", uosmoInDec_Swap2_AddTakerFee) + // Perform a swap chainABNode.SwapExactAmountIn(uosmoIn_Swap2, outMinAmt, fmt.Sprintf("%d", poolID), denom0, initialization.ValidatorWalletName) @@ -540,19 +584,32 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // hasReachedTarget in SwapStep is true, hence, to find spread rewards, calculate: // spreadRewardCharge = amountIn * spreadFactor / (1 - spreadFactor) spreadRewardCharge_Swap2_Step1 := amountInToGetToNextInitTick.Mul(spreadFactorDec).Quo(sdk.OneDec().Sub(spreadFactorDec)) + // fmt.Println("spreadRewardCharge_Swap2_Step1", spreadRewardCharge_Swap2_Step1.String()) + // fmt.Println("amountInToGetToNextInitTick", amountInToGetToNextInitTick) // Step2: hasReachedTarget in SwapStep is false (nextTick is 120000), hence, to find spread rewards, calculate: // spreadRewardCharge = amountRemaining - amountOne amountRemainingAfterStep1 := uosmoInDec_Swap2.Sub(amountInToGetToNextInitTick).Sub(spreadRewardCharge_Swap2_Step1) + // fmt.Println("amountRemainingAfterStep1", amountRemainingAfterStep1.String()) spreadRewardCharge_Swap2_Step2 := amountRemainingAfterStep1.Sub(amountInToGetToTickAfterInitialized) + // fmt.Println("spreadRewardCharge_Swap2_Step2", spreadRewardCharge_Swap2_Step2.String()) + + // // HARDCODING + // spreadRewardCharge_Swap2_Step1 = sdk.MustNewDecFromStr("10540.484484484484484485") + // spreadRewardCharge_Swap2_Step2 = sdk.MustNewDecFromStr("27.515515515515515515") // per unit of virtual liquidity spreadRewardCharge_Swap2_Step1.QuoMut(liquidityBeforeSwap) spreadRewardCharge_Swap2_Step2.QuoMut(liquidityAfterSwap) + // fmt.Println("amountRemainingAfterStep1 per unit of liq", spreadRewardCharge_Swap2_Step1.String()) + // fmt.Println("spreadRewardCharge_Swap2_Step2 per unit of liq", spreadRewardCharge_Swap2_Step2.String()) + // Update spreadRewardGrowthGlobal spreadRewardGrowthGlobal.AddMut(spreadRewardCharge_Swap2_Step1.Add(spreadRewardCharge_Swap2_Step2)) + // fmt.Println("spreadRewardGrowthGlobal", spreadRewardGrowthGlobal.String()) + // Assert Balances: Swap 2 // Assert that address1 position1 earned spread rewards only from first swap step @@ -569,12 +626,15 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { spreadRewardsUncollectedAddress1Position1_Swap2 := calculateUncollectedSpreadRewards( positionsAddress1[0].Position.Liquidity, sdk.ZeroDec(), - sdk.ZeroDec(), - calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap1, sdk.ZeroDec(), sdk.ZeroDec()), - spreadRewardGrowthGlobal_Swap1.Add(spreadRewardCharge_Swap2_Step1), // cannot use spreadRewardGrowthGlobal, it was already increased by second swap's step + spreadRewardCharge_Swap2_Step2, + spreadRewardGrowthGlobal_Swap1, + spreadRewardGrowthGlobal, // cannot use spreadRewardGrowthGlobal, it was already increased by second swap's step ) // Assert + // fmt.Println("spreadRewardsUncollectedAddress1Position1_Swap2", spreadRewardsUncollectedAddress1Position1_Swap2) + // fmt.Println("addr1BalancesBefore.AmountOf(\"uosmo\")", addr1BalancesBefore.AmountOf("uosmo")) + // fmt.Println("addr1BalancesAfter.AmountOf(\"uosmo\")", addr1BalancesAfter.AmountOf("uosmo")) s.Require().Equal( addr1BalancesBefore.AmountOf("uosmo").Add(spreadRewardsUncollectedAddress1Position1_Swap2.TruncateInt()), addr1BalancesAfter.AmountOf("uosmo"), diff --git a/tests/e2e/helpers_e2e_test.go b/tests/e2e/helpers_e2e_test.go index 95eab2f110b..5769cdf2870 100644 --- a/tests/e2e/helpers_e2e_test.go +++ b/tests/e2e/helpers_e2e_test.go @@ -22,12 +22,14 @@ var defaultFeePerTx = sdk.NewInt(1000) // amountIn - amount being swapped // spreadFactor - pool's spread factor // poolLiquidity - current pool liquidity -func calculateSpreadRewardGrowthGlobal(amountIn, spreadFactor, poolLiquidity sdk.Dec) sdk.Dec { - // First we get total spread reward charge for the swap (ΔY * spreadFactor) - spreadRewardChargeTotal := amountIn.Mul(spreadFactor) +func calculateSpreadRewardGrowthGlobal(spreadRewardChargeTotal, poolLiquidity sdk.Dec) sdk.Dec { + // // First we get total spread reward charge for the swap (ΔY * spreadFactor) + // spreadRewardChargeTotal := amountIn.Mul(spreadFactor) // Calculating spread reward growth global (dividing by pool liquidity to find spread reward growth per unit of virtual liquidity) - spreadRewardGrowthGlobal := spreadRewardChargeTotal.Quo(poolLiquidity) + spreadRewardGrowthGlobal := spreadRewardChargeTotal.QuoTruncate(poolLiquidity) + // fmt.Println("AAA1 spreadRewardGrowthGlobal: ", spreadRewardGrowthGlobal) + // fmt.Println("AAA2 poolLiquidity: ", poolLiquidity) return spreadRewardGrowthGlobal } @@ -108,10 +110,19 @@ func calculateUncollectedSpreadRewards(positionLiquidity, spreadRewardGrowthBelo // Calculating spread reward growth inside range [-1200; 400] spreadRewardGrowthInside := calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal, spreadRewardGrowthBelow, spreadRewardGrowthAbove) + // fmt.Println("spreadRewardGrowthInside: ", spreadRewardGrowthInside) + // fmt.Println("spreadRewardGrowthGlobal: ", spreadRewardGrowthGlobal) + // fmt.Println("spreadRewardGrowthBelow: ", spreadRewardGrowthBelow) + // fmt.Println("spreadRewardGrowthAbove: ", spreadRewardGrowthAbove) + // Calculating uncollected spread rewards // Formula for finding uncollected spread rewards in time range [t1; t2]: // F_u = position_liquidity * (spread_rewards_growth_inside_t2 - spread_rewards_growth_inside_t1). spreadRewardsUncollected := positionLiquidity.Mul(spreadRewardGrowthInside.Sub(spreadRewardGrowthInsideLast)) + // fmt.Println("spreadRewardsUncollected: ", spreadRewardsUncollected) + // fmt.Println("positionLiquidity: ", positionLiquidity) + // fmt.Println("spreadRewardGrowthInside: ", spreadRewardGrowthInside) + // fmt.Println("spreadRewardGrowthInsideLast: ", spreadRewardGrowthInsideLast) return spreadRewardsUncollected } diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index c5868b9d868..451cdb1966e 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -804,6 +804,12 @@ func updateAccumAndClaimRewards(accum *accum.AccumulatorObject, positionKey stri return sdk.Coins{}, sdk.DecCoins{}, err } + // position, _ := accum.GetPosition(accum1, positionKey) + + // fmt.Println("positions unclaimed rewards total: ", position.UnclaimedRewardsTotal) + // fmt.Println("position.AccumValuePerShare: ", position.AccumValuePerShare) + // fmt.Println("position.NumShares: ", position.NumShares) + // Claim rewards, set the unclaimed rewards to zero, and update the position's accumulator value to reflect the current accumulator value. // Removes the position state from accum if remaining liquidity is zero for the position. incentivesClaimedCurrAccum, dust, err := accum.ClaimRewards(positionKey) diff --git a/x/concentrated-liquidity/spread_rewards.go b/x/concentrated-liquidity/spread_rewards.go index 8669274c93f..d1985e360e1 100644 --- a/x/concentrated-liquidity/spread_rewards.go +++ b/x/concentrated-liquidity/spread_rewards.go @@ -245,12 +245,16 @@ func (k Keeper) prepareClaimableSpreadRewards(ctx sdk.Context, positionId uint64 if err != nil { return nil, err } + // fmt.Println("ADAM spreadRewardGrowthOutside", spreadRewardGrowthOutside) + // fmt.Println("ADAM spreadRewardAccumulator.GetValue() pre", spreadRewardAccumulator.GetValue()) // Claim rewards, set the unclaimed rewards to zero, and update the position's accumulator value to reflect the current accumulator value. spreadRewardsClaimed, forfeitedDust, err := updateAccumAndClaimRewards(spreadRewardAccumulator, positionKey, spreadRewardGrowthOutside) if err != nil { return nil, err } + // fmt.Println("ADAM spreadRewardAccumulator.GetValue() post", spreadRewardAccumulator.GetValue()) + // fmt.Println("ADAM spreadRewardsClaimed", spreadRewardsClaimed) // add foreited dust back to the global accumulator if !forfeitedDust.IsZero() { @@ -266,8 +270,12 @@ func (k Keeper) prepareClaimableSpreadRewards(ctx sdk.Context, positionId uint64 // Total shares remaining can be zero if we claim in withdrawPosition for the last position in the pool. // The shares are decremented in osmoutils/accum.ClaimRewards. if !totalSharesRemaining.IsZero() { + // fmt.Println("ADAM forfeitedDust", forfeitedDust) + // fmt.Println("ADAM totalSharesRemaining", totalSharesRemaining) forfeitedDustPerShare := forfeitedDust.QuoDecTruncate(totalSharesRemaining) + // fmt.Println("ADAM forfeitedDustPerShare", forfeitedDustPerShare) spreadRewardAccumulator.AddToAccumulator(forfeitedDustPerShare) + // fmt.Println("ADAM spreadRewardAccumulator.GetValue()", spreadRewardAccumulator.GetValue()) } } @@ -303,7 +311,10 @@ func updatePositionToInitValuePlusGrowthOutside(accumulator *accum.AccumulatorOb // - Then, during claiming in osmoutils.ClaimRewards, we perform the following computation: // growth_global_at{current block time} - (growth_inside_at_{last time of update} + growth_outside_at_{current block time of update}}) // which ends up being equal to growth_inside_from_{last_time_of_update}_to_{current block time of update}}. + // fmt.Println("growthoutside in spread rewards claim", growthOutside) + // fmt.Println("position.AccumValuePerShare in spread rewards claim", position.AccumValuePerShare) intervalAccumulationOutside := position.AccumValuePerShare.Add(growthOutside...) + // fmt.Println("intervalAccumulationOutside in spread rewards claim", intervalAccumulationOutside) err = accumulator.SetPositionIntervalAccumulation(positionKey, intervalAccumulationOutside) if err != nil { return err diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index fb5f0a3a3ae..c4fab8831dc 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -113,7 +113,11 @@ func (ss *SwapState) updateSpreadRewardGrowthGlobal(spreadRewardChargeTotal sdk. // We round down here since we want to avoid overdistributing (the "spread factor charge" refers to // the total spread factors that will be accrued to the spread factor accumulator) spreadFactorsAccruedPerUnitOfLiquidity := spreadRewardChargeTotal.QuoTruncate(ss.liquidity) + // fmt.Println("AAA1 spreadRewardChargeTotal", spreadRewardChargeTotal) + // fmt.Println("AAA2 ss.liquidity", ss.liquidity) ss.globalSpreadRewardGrowthPerUnitLiquidity.AddMut(spreadFactorsAccruedPerUnitOfLiquidity) + // fmt.Println("AAA3 spreadFactorsAccruedPerUnitOfLiquidity", spreadFactorsAccruedPerUnitOfLiquidity) + // fmt.Println("ADAM ss.globalSpreadRewardGrowthPerUnitLiquidity", ss.globalSpreadRewardGrowthPerUnitLiquidity) } func (k Keeper) SwapExactAmountIn( @@ -349,6 +353,8 @@ func (k Keeper) computeOutAmtGivenIn( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } + fmt.Println("ADAM TokenIn", tokenInMin) + swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInMin.Denom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err @@ -444,6 +450,7 @@ func (k Keeper) computeOutAmtGivenIn( // Add spread reward growth per share to the pool-global spread reward accumulator. spreadRewardGrowth := sdk.NewDecCoinFromDec(tokenInMin.Denom, swapState.globalSpreadRewardGrowthPerUnitLiquidity) + fmt.Println("ADAM spreadRewardGrowth", spreadRewardGrowth) spreadRewardAccumulator.AddToAccumulator(sdk.NewDecCoins(spreadRewardGrowth)) // Coin amounts require int values diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 06dc1f185a5..ec01c62cf10 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -906,17 +906,17 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take } func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.TruncateInt()) - tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(takerFeeCoin.Amount)) + amountInAfterTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterTakerFee.TruncateInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterTakerFee.Amount)) return tokenInAfterTakerFee, takerFeeCoin } func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - takerFeeDec := tokenIn.Amount.ToDec().Mul(takerFee) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, takerFeeDec.RoundInt()) - tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Add(takerFeeCoin.Amount)) + amountInAfterTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterTakerFee.RoundInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Add(tokenInAfterTakerFee.Amount)) return tokenInAfterTakerFee, takerFeeCoin } From 925d619dea52b67351884e3b6b3b48c60b8e1516 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 14:35:06 -0500 Subject: [PATCH 20/83] fixes --- tests/e2e/e2e_test.go | 17 +++++++++-------- x/gamm/simulation/sim_msgs.go | 6 ++++-- x/poolmanager/router.go | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 5a9ae1ca2c1..a28927825de 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -104,14 +104,15 @@ func (s *IntegrationTestSuite) TestAllE2E() { // Upgrade Dependent Tests - if s.skipUpgrade { - s.T().Skip("Skipping StableSwapPostUpgrade test") - } else { - s.T().Run("StableSwapPostUpgrade", func(t *testing.T) { - t.Parallel() - s.StableSwapPostUpgrade() - }) - } + // TODO: Temp disable + // if s.skipUpgrade { + // s.T().Skip("Skipping StableSwapPostUpgrade test") + // } else { + // s.T().Run("StableSwapPostUpgrade", func(t *testing.T) { + // t.Parallel() + // s.StableSwapPostUpgrade() + // }) + // } if s.skipUpgrade { s.T().Skip("Skipping GeometricTwapMigration test") diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index 4c7a067226a..ef802d80ab6 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -147,8 +147,10 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont // calculate the minimum number of tokens received from input of tokenIn // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. - totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee()) - tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, randomCoinSubset, coinOut.Denom, totalFees) + amountInAfterTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(pool.GetTakerFee())) + tokenInAfterTakerFee := sdk.NewCoin(randomCoinSubset[0].Denom, amountInAfterTakerFee.TruncateInt()) + + tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(tokenInAfterTakerFee), coinOut.Denom, pool.GetSpreadFactor(ctx)) if err != nil { return nil, err } diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index ec01c62cf10..6d39e97d9f6 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -916,7 +916,7 @@ func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coi func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { amountInAfterTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterTakerFee.RoundInt()) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Add(tokenInAfterTakerFee.Amount)) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterTakerFee.Amount)) return tokenInAfterTakerFee, takerFeeCoin } From f51eb28bee68f514425c3330cea114b76b08fe49 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 15:36:06 -0500 Subject: [PATCH 21/83] more test fixes --- x/gamm/keeper/msg_server_test.go | 6 +++--- x/poolmanager/router.go | 21 +++++++++++++-------- x/poolmanager/router_test.go | 4 ++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index 782e7972845..4168c0f7f33 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -19,7 +19,7 @@ const ( func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { const ( tokenInMinAmount = 1 - tokenIn = 5 + tokenIn = 10 ) testcases := map[string]struct { @@ -77,7 +77,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { }, tokenIn: sdk.NewCoin(doesNotExistDenom, sdk.NewInt(tokenIn)), tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), - expectedMessageEvents: 2, // 2 events get triggered prior to failure. + expectedMessageEvents: 1, // 1 event gets triggered prior to failure. expectError: true, }, } @@ -119,7 +119,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { const ( tokenInMaxAmount = int64Max - tokenOut = 5 + tokenOut = 10 ) testcases := map[string]struct { diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 6d39e97d9f6..a5022b24094 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -101,11 +101,16 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } + fmt.Println("tokenInAfterTakerFee: ", tokenInAfterTakerFee) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) + fmt.Println("err: ", err) if err != nil { return sdk.Int{}, err } + fmt.Println("iteration i: ", i) + // Chain output of current pool as the input for the next routed pool tokenIn = sdk.NewCoin(routeStep.TokenOutDenom, tokenOutAmount) } @@ -906,19 +911,19 @@ func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, take } func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - amountInAfterTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) - tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterTakerFee.TruncateInt()) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterTakerFee.Amount)) + amountInAfterSubTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + tokenInAfterSubTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterSubTakerFee.TruncateInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterSubTakerFee.Amount)) - return tokenInAfterTakerFee, takerFeeCoin + return tokenInAfterSubTakerFee, takerFeeCoin } func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - amountInAfterTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) - tokenInAfterTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterTakerFee.RoundInt()) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterTakerFee.Amount)) + amountInAfterAddTakerFee := tokenIn.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) + tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.RoundInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenInAfterAddTakerFee.Amount.Sub(tokenIn.Amount)) - return tokenInAfterTakerFee, takerFeeCoin + return tokenInAfterAddTakerFee, takerFeeCoin } func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 7f4e3a5cba5..6ee35e1aec7 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1867,7 +1867,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(97595721) + priceImpactThreshold = sdk.NewInt(97595718) ) tests := map[string]struct { @@ -2067,7 +2067,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { TokenOutAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(102530430) + priceImpactThreshold = sdk.NewInt(102530841) ) tests := map[string]struct { From aa02dad31c19269ed8846e4f0757842e989cf756 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 15:37:32 -0500 Subject: [PATCH 22/83] remove prints --- x/poolmanager/router.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index a5022b24094..f32953e9dc1 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -101,16 +101,11 @@ func (k Keeper) RouteExactAmountIn( return sdk.Int{}, err } - fmt.Println("tokenInAfterTakerFee: ", tokenInAfterTakerFee) - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) - fmt.Println("err: ", err) if err != nil { return sdk.Int{}, err } - fmt.Println("iteration i: ", i) - // Chain output of current pool as the input for the next routed pool tokenIn = sdk.NewCoin(routeStep.TokenOutDenom, tokenOutAmount) } From bf5af4a001ac52f8d096ce9c74cf866e9fd8b35a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 20:17:47 -0500 Subject: [PATCH 23/83] more naive approach to determining taker fee --- app/upgrades/v18/upgrades.go | 31 ---- .../osmosis/concentrated-liquidity/pool.proto | 9 - .../cosmwasmpool/v1beta1/model/pool.proto | 8 - .../pool-models/balancer/balancerPool.proto | 8 - .../stableswap/stableswap_pool.proto | 8 - tests/e2e/e2e_test.go | 4 +- x/concentrated-liquidity/keeper_test.go | 1 - x/concentrated-liquidity/model/msgs.go | 4 +- x/concentrated-liquidity/model/pool.go | 11 +- x/concentrated-liquidity/model/pool.pb.go | 138 +++++---------- x/concentrated-liquidity/model/pool_test.go | 7 +- x/concentrated-liquidity/pool_test.go | 4 +- .../spread_rewards_test.go | 2 +- x/concentrated-liquidity/swaps.go | 4 +- .../types/cl_pool_extensionI.go | 1 - x/cosmwasmpool/model/msgs.go | 4 +- x/cosmwasmpool/model/pool.go | 7 +- x/cosmwasmpool/model/pool.pb.go | 101 +++-------- x/cosmwasmpool/model/store_model.go | 8 - x/cosmwasmpool/pool_module_test.go | 3 +- x/gamm/keeper/pool.go | 4 + .../pool-models/balancer/balancerPool.pb.go | 163 ++++++------------ x/gamm/pool-models/balancer/marshal_test.go | 5 +- x/gamm/pool-models/balancer/msgs.go | 3 +- x/gamm/pool-models/balancer/msgs_test.go | 3 +- x/gamm/pool-models/balancer/pool.go | 8 - x/gamm/pool-models/balancer/pool_test.go | 1 - x/gamm/pool-models/stableswap/msgs.go | 3 +- x/gamm/pool-models/stableswap/msgs_test.go | 3 +- x/gamm/pool-models/stableswap/pool.go | 8 - .../stableswap/stableswap_pool.pb.go | 139 +++++---------- x/gamm/simulation/sim_msgs.go | 14 +- x/gamm/types/expected_keepers.go | 2 + x/gamm/types/pool.go | 1 - x/poolmanager/create_pool.go | 146 +++++++++------- x/poolmanager/router.go | 39 ++++- x/poolmanager/router_test.go | 16 +- x/poolmanager/types/keys.go | 11 ++ x/poolmanager/types/msg_create_pool.go | 2 +- x/poolmanager/types/pool.go | 2 - 40 files changed, 344 insertions(+), 592 deletions(-) diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v18/upgrades.go index d3c8a2a4b0f..598c409e9bc 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v18/upgrades.go @@ -7,7 +7,6 @@ import ( "github.com/osmosis-labs/osmosis/v17/app/keepers" "github.com/osmosis-labs/osmosis/v17/app/upgrades" - poolmanager "github.com/osmosis-labs/osmosis/v17/x/poolmanager" poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" ) @@ -27,36 +26,6 @@ func CreateUpgradeHandler( keepers.PoolManagerKeeper.SetParams(ctx, poolmanagertypes.DefaultParams()) - err = SetAllExistingPoolsTakerFee(ctx, keepers) - if err != nil { - return nil, err - } - return migrations, nil } } - -func SetAllExistingPoolsTakerFee(ctx sdk.Context, keepers *keepers.AppKeepers) error { - lastPoolId := keepers.PoolManagerKeeper.GetNextPoolId(ctx) - 1 - - for i := uint64(1); i <= lastPoolId; i++ { - pool, err := keepers.PoolManagerKeeper.GetPool(ctx, i) - if err != nil { - return err - } - - poolManagerParams := keepers.PoolManagerKeeper.GetParams(ctx) - accAddress := pool.GetAddress() - poolBalances := keepers.BankKeeper.GetAllBalances(ctx, accAddress) - poolType := pool.GetType() - - takerFee := poolmanager.DetermineTakerFee(poolManagerParams, poolBalances, poolType) - - pool.SetTakerFee(takerFee) - err = keepers.GAMMKeeper.OverwritePoolV15MigrationUnsafe(ctx, pool) - if err != nil { - return err - } - } - return nil -} diff --git a/proto/osmosis/concentrated-liquidity/pool.proto b/proto/osmosis/concentrated-liquidity/pool.proto index 612cca8cfe1..75709169fb2 100644 --- a/proto/osmosis/concentrated-liquidity/pool.proto +++ b/proto/osmosis/concentrated-liquidity/pool.proto @@ -65,13 +65,4 @@ message Pool { (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"last_liquidity_update\"" ]; - - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - string taker_fee = 14 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"taker_fee\"", - (gogoproto.nullable) = false - ]; } \ No newline at end of file diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto index 4b6dde68d55..f94df821a36 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool.proto @@ -18,12 +18,4 @@ message CosmWasmPool { uint64 code_id = 3; bytes instantiate_msg = 4 [ (gogoproto.moretags) = "yaml:\"instantiate_msg\"" ]; - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - string taker_fee = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"taker_fee\"", - (gogoproto.nullable) = false - ]; } diff --git a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto index d7cbec4322b..1bfd1cad28a 100644 --- a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto +++ b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto @@ -94,14 +94,6 @@ message PoolParams { (gogoproto.moretags) = "yaml:\"smooth_weight_change_params\"", (gogoproto.nullable) = true ]; - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - string taker_fee = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"taker_fee\"", - (gogoproto.nullable) = false - ]; } // Pool asset is an internal struct that combines the amount of the diff --git a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto index 13c17c657d5..ab2d73db20e 100644 --- a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto +++ b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto @@ -33,14 +33,6 @@ message PoolParams { (gogoproto.moretags) = "yaml:\"exit_fee\"", (gogoproto.nullable) = false ]; - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - string taker_fee = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.moretags) = "yaml:\"taker_fee\"", - (gogoproto.nullable) = false - ]; } // Pool is the stableswap Pool struct diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index a28927825de..37e34cf62db 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -303,6 +303,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { tickSpacing uint64 = 100 spreadFactor = "0.001" // 0.1% spreadFactorDec = sdk.MustNewDecFromStr("0.001") + takerFee = sdk.MustNewDecFromStr("0.0015") ) chainAB, chainABNode, err := s.getChainCfgs() @@ -408,9 +409,6 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Second position third address s.validateCLPosition(addr3position2, poolID, cltypes.MinInitializedTick, 140000) - // Note the pool's taker fee - takerFee := concentratedPool.GetTakerFee() - // Collect SpreadRewards var ( diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index 710abddf118..b43cb85a5a0 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -59,7 +59,6 @@ var ( FullRangeLiquidityAmt = sdk.MustNewDecFromStr("70710678.118654752941000000") DefaultTickSpacing = uint64(100) - DefaultTakerFee = sdk.MustNewDecFromStr("0.0015") PoolCreationFee = poolmanagertypes.DefaultParams().PoolCreationFee sqrt4000 = sdk.MustNewDecFromStr("63.245553203367586640") sqrt4994 = sdk.MustNewDecFromStr("70.668238976219012614") diff --git a/x/concentrated-liquidity/model/msgs.go b/x/concentrated-liquidity/model/msgs.go index 1ef565d884a..0c66a4f3b66 100644 --- a/x/concentrated-liquidity/model/msgs.go +++ b/x/concentrated-liquidity/model/msgs.go @@ -97,8 +97,8 @@ func (msg MsgCreateConcentratedPool) InitialLiquidity() sdk.Coins { return sdk.Coins{} } -func (msg MsgCreateConcentratedPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { - poolI, err := NewConcentratedLiquidityPool(poolID, msg.Denom0, msg.Denom1, msg.TickSpacing, msg.SpreadFactor, takerFee) +func (msg MsgCreateConcentratedPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { + poolI, err := NewConcentratedLiquidityPool(poolID, msg.Denom0, msg.Denom1, msg.TickSpacing, msg.SpreadFactor) return &poolI, err } diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index 435e1be5d45..f9f57aea86f 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -26,7 +26,7 @@ var ( // NewConcentratedLiquidityPool creates a new ConcentratedLiquidity pool with the specified parameters. // The two provided denoms are ordered so that denom0 is lexicographically smaller than denom1. -func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpacing uint64, spreadFactor, takerFee sdk.Dec) (Pool, error) { +func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpacing uint64, spreadFactor sdk.Dec) (Pool, error) { // Ensure that the two denoms are different if denom0 == denom1 { return Pool{}, types.MatchingDenomError{Denom: denom0} @@ -51,7 +51,6 @@ func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpac TickSpacing: tickSpacing, ExponentAtPriceOne: types.ExponentAtPriceOne, SpreadFactor: spreadFactor, - TakerFee: takerFee, } return pool, nil } @@ -101,10 +100,6 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.SpreadFactor } -func (p Pool) GetTakerFee() sdk.Dec { - return p.TakerFee -} - // IsActive returns true if the pool is active func (p Pool) IsActive(ctx sdk.Context) bool { return true @@ -198,10 +193,6 @@ func (p *Pool) SetLastLiquidityUpdate(newTime time.Time) { p.LastLiquidityUpdate = newTime } -func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { - p.TakerFee = newTakerFee -} - // updateLiquidityIfActivePosition updates the pool's liquidity if the position is active. // Returns true if updated, false otherwise. func (p *Pool) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) bool { diff --git a/x/concentrated-liquidity/model/pool.pb.go b/x/concentrated-liquidity/model/pool.pb.go index 21356ba577f..dfd1bbf9ad2 100644 --- a/x/concentrated-liquidity/model/pool.pb.go +++ b/x/concentrated-liquidity/model/pool.pb.go @@ -58,10 +58,6 @@ type Pool struct { // last_liquidity_update is the last time either the pool liquidity or the // active tick changed LastLiquidityUpdate time.Time `protobuf:"bytes,13,opt,name=last_liquidity_update,json=lastLiquidityUpdate,proto3,stdtime" json:"last_liquidity_update" yaml:"last_liquidity_update"` - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,14,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *Pool) Reset() { *m = Pool{} } @@ -105,51 +101,49 @@ func init() { } var fileDescriptor_3526ea5373d96c9a = []byte{ - // 690 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xcd, 0x4e, 0xdb, 0x4a, - 0x14, 0x8e, 0xf9, 0x67, 0x02, 0x08, 0x86, 0xc0, 0x35, 0xe8, 0x12, 0xe7, 0x5a, 0xba, 0x57, 0xb9, - 0x52, 0x63, 0x37, 0xed, 0xa2, 0x12, 0x3b, 0xa2, 0x0a, 0xa9, 0x12, 0x12, 0x68, 0xa0, 0xaa, 0x54, - 0x55, 0xb2, 0x26, 0xf6, 0x10, 0x46, 0x71, 0x3c, 0xc6, 0x33, 0xa1, 0xd0, 0x7d, 0xa5, 0x2e, 0x59, - 0x76, 0xc9, 0x43, 0xf4, 0x1d, 0x8a, 0xba, 0x62, 0x59, 0x75, 0xe1, 0x56, 0xf0, 0x06, 0x79, 0x82, - 0xca, 0x33, 0xe3, 0xc4, 0x15, 0xa9, 0x2a, 0x56, 0xf6, 0xf9, 0xce, 0x77, 0xbe, 0xf9, 0xce, 0xf1, - 0x19, 0x83, 0xff, 0x19, 0xef, 0x31, 0x4e, 0xb9, 0xeb, 0xb3, 0xc8, 0x27, 0x91, 0x48, 0xb0, 0x20, - 0x41, 0x23, 0xa4, 0xa7, 0x7d, 0x1a, 0x50, 0x71, 0xe1, 0xc6, 0x8c, 0x85, 0x4e, 0x9c, 0x30, 0xc1, - 0xe0, 0xbf, 0x9a, 0xea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0x00, 0x00, 0x00, 0xff, 0xff, 0x59, 0x66, 0x26, 0xed, 0x54, 0x05, - 0x00, 0x00, + // 659 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4f, 0x6b, 0xd4, 0x40, + 0x14, 0xdf, 0xf4, 0xaf, 0x9d, 0x6d, 0x8b, 0x9d, 0x6e, 0x6b, 0x5a, 0xec, 0x66, 0x0d, 0x28, 0x2b, + 0xb8, 0x89, 0xab, 0x07, 0xa1, 0xb7, 0x2e, 0x52, 0x10, 0x0a, 0x2d, 0x69, 0x45, 0x10, 0x21, 0xcc, + 0x26, 0xd3, 0x74, 0xd8, 0x24, 0x93, 0x66, 0x66, 0x6b, 0xeb, 0x5d, 0xf0, 0xd8, 0xa3, 0xc7, 0x7e, + 0x08, 0x3f, 0x44, 0xf1, 0xd4, 0xa3, 0x78, 0x88, 0xd2, 0x82, 0x1f, 0x60, 0x3f, 0x81, 0x64, 0x66, + 0xb2, 0x1b, 0xe9, 0x8a, 0x78, 0xca, 0xbe, 0xdf, 0xfb, 0xbd, 0xdf, 0xfc, 0xde, 0x9b, 0x37, 0x0b, + 0x1e, 0x53, 0x16, 0x51, 0x46, 0x98, 0xed, 0xd1, 0xd8, 0xc3, 0x31, 0x4f, 0x11, 0xc7, 0x7e, 0x2b, + 0x24, 0xc7, 0x7d, 0xe2, 0x13, 0x7e, 0x66, 0x27, 0x94, 0x86, 0x56, 0x92, 0x52, 0x4e, 0xe1, 0x43, + 0x45, 0xb5, 0xca, 0xd4, 0x21, 0xd3, 0x3a, 0x69, 0x77, 0x31, 0x47, 0xed, 0xf5, 0x35, 0x4f, 0xf0, + 0x5c, 0x51, 0x64, 0xcb, 0x40, 0x2a, 0xac, 0xd7, 0x02, 0x1a, 0x50, 0x89, 0xe7, 0xbf, 0x14, 0x6a, + 0x04, 0x94, 0x06, 0x21, 0xb6, 0x45, 0xd4, 0xed, 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 0xac, 0x84, 0x88, 0xf1, 0xd1, 0x3a, 0xb8, 0xfd, 0xc4, 0x47, 0x1c, + 0xeb, 0x0b, 0x0d, 0xad, 0x59, 0x7d, 0xb6, 0x6e, 0xc9, 0xc7, 0x69, 0x15, 0x8f, 0xd3, 0x3a, 0x28, + 0x1e, 0x67, 0xa7, 0x99, 0x1b, 0x1a, 0x75, 0x38, 0x56, 0xc6, 0x3c, 0xff, 0x61, 0x68, 0xce, 0x72, + 0x9e, 0x1b, 0x6e, 0xd6, 0x6b, 0x91, 0xd9, 0x5c, 0xfa, 0x74, 0x61, 0x54, 0x3e, 0x5f, 0x18, 0x95, + 0xaf, 0x5f, 0x5a, 0xd3, 0xf9, 0xf3, 0x7e, 0xd5, 0x79, 0x77, 0x79, 0x5d, 0xd7, 0xae, 0xae, 0xeb, + 0xda, 0xcf, 0xeb, 0xba, 0x76, 0x7e, 0x53, 0xaf, 0x5c, 0xdd, 0xd4, 0x2b, 0xdf, 0x6e, 0xea, 0x95, + 0xb7, 0x9d, 0x7f, 0x2d, 0xce, 0x49, 0xfb, 0x85, 0x7d, 0xfa, 0xb7, 0x3f, 0xb1, 0x88, 0xfa, 0x38, + 0xec, 0xce, 0x88, 0x1e, 0x9e, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xf8, 0xac, 0x29, 0xa9, 0xf3, + 0x04, 0x00, 0x00, } func (m *Pool) Marshal() (dAtA []byte, err error) { @@ -172,16 +166,6 @@ func (m *Pool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastLiquidityUpdate, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastLiquidityUpdate):]) if err1 != nil { return 0, err1 @@ -335,8 +319,6 @@ func (m *Pool) Size() (n int) { n += 1 + l + sovPool(uint64(l)) l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastLiquidityUpdate) n += 1 + l + sovPool(uint64(l)) - l = m.TakerFee.Size() - n += 1 + l + sovPool(uint64(l)) return n } @@ -746,40 +728,6 @@ func (m *Pool) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPool(dAtA[iNdEx:]) diff --git a/x/concentrated-liquidity/model/pool_test.go b/x/concentrated-liquidity/model/pool_test.go index 643e95d6aaf..1b80d6b571d 100644 --- a/x/concentrated-liquidity/model/pool_test.go +++ b/x/concentrated-liquidity/model/pool_test.go @@ -41,7 +41,6 @@ var ( }() // 70.710678118654752440 DefaultSpreadFactor = sdk.MustNewDecFromStr("0.01") - DefaultTakerFee = sdk.MustNewDecFromStr("0.0015") ) type ConcentratedPoolTestSuite struct { @@ -139,10 +138,10 @@ func (s *ConcentratedPoolTestSuite) TestGetIncentivesAddress() { func (s *ConcentratedPoolTestSuite) TestString() { s.Setup() - pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor, DefaultTakerFee) + pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor) s.Require().NoError(err) poolString := pool.String() - s.Require().Equal(poolString, "{\"address\":\"osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7\",\"incentives_address\":\"osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf\",\"spread_rewards_address\":\"osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv\",\"id\":1,\"current_tick_liquidity\":\"0.000000000000000000\",\"token0\":\"foo\",\"token1\":\"bar\",\"current_sqrt_price\":\"0.000000000000000000000000000000000000\",\"tick_spacing\":1,\"exponent_at_price_one\":-6,\"spread_factor\":\"0.010000000000000000\",\"last_liquidity_update\":\"0001-01-01T00:00:00Z\",\"taker_fee\":\"0.001500000000000000\"}") + s.Require().Equal("{\"address\":\"osmo19e2mf7cywkv7zaug6nk5f87d07fxrdgrladvymh2gwv5crvm3vnsuewhh7\",\"incentives_address\":\"osmo156gncm3w2hdvuxxaejue8nejxgdgsrvdf7jftntuhxnaarhxcuas4ywjxf\",\"spread_rewards_address\":\"osmo10t3u6ze74jn7et6rluuxyf9vr2arykewmhcx67svg6heuu0gte2syfudcv\",\"id\":1,\"current_tick_liquidity\":\"0.000000000000000000\",\"token0\":\"foo\",\"token1\":\"bar\",\"current_sqrt_price\":\"0.000000000000000000000000000000000000\",\"tick_spacing\":1,\"exponent_at_price_one\":-6,\"spread_factor\":\"0.010000000000000000\",\"last_liquidity_update\":\"0001-01-01T00:00:00Z\"}", poolString) } // TestSpotPrice tests the SpotPrice method of the ConcentratedPoolTestSuite. @@ -544,7 +543,7 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { s.Setup() // Call NewConcentratedLiquidityPool with the parameters from the current test. - pool, err := model.NewConcentratedLiquidityPool(test.param.poolId, test.param.denom0, test.param.denom1, test.param.tickSpacing, test.param.spreadFactor, DefaultTakerFee) + pool, err := model.NewConcentratedLiquidityPool(test.param.poolId, test.param.denom0, test.param.denom1, test.param.tickSpacing, test.param.spreadFactor) if test.expectedErr != nil { // If the test is expected to produce an error, check if it does. diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index f5912a225e4..365a88655b5 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -25,12 +25,12 @@ func (s *KeeperTestSuite) TestInitializePool() { // Create a concentrated liquidity pool with unauthorized tick spacing invalidTickSpacing := uint64(25) - invalidTickSpacingConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(2, ETH, USDC, invalidTickSpacing, DefaultZeroSpreadFactor, DefaultTakerFee) + invalidTickSpacingConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(2, ETH, USDC, invalidTickSpacing, DefaultZeroSpreadFactor) s.Require().NoError(err) // Create a concentrated liquidity pool with unauthorized spread factor invalidSpreadFactor := sdk.MustNewDecFromStr("0.1") - invalidSpreadFactorConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(3, ETH, USDC, DefaultTickSpacing, invalidSpreadFactor, DefaultTakerFee) + invalidSpreadFactorConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(3, ETH, USDC, DefaultTickSpacing, invalidSpreadFactor) s.Require().NoError(err) // Create an invalid PoolI that doesn't implement ConcentratedPoolExtension diff --git a/x/concentrated-liquidity/spread_rewards_test.go b/x/concentrated-liquidity/spread_rewards_test.go index c3c5996c599..de29d2af471 100644 --- a/x/concentrated-liquidity/spread_rewards_test.go +++ b/x/concentrated-liquidity/spread_rewards_test.go @@ -487,7 +487,7 @@ func (s *KeeperTestSuite) TestCalculateSpreadRewardGrowth() { // Test what happens if somehow the accumulator didn't exist. // TODO: Does this test even matter? We should never be in a situation where the accumulator doesn't exist func (s *KeeperTestSuite) TestGetInitialSpreadRewardGrowthOppositeDirectionOfLastTraversalForTickAccumDoesntExist() { - pool, err := clmodel.NewConcentratedLiquidityPool(validPoolId, ETH, USDC, DefaultTickSpacing, DefaultZeroSpreadFactor, DefaultTakerFee) + pool, err := clmodel.NewConcentratedLiquidityPool(validPoolId, ETH, USDC, DefaultTickSpacing, DefaultZeroSpreadFactor) s.Require().NoError(err) // N.B.: we set the listener mock because we would like to avoid diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index c4fab8831dc..d3b459920c7 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -353,7 +353,7 @@ func (k Keeper) computeOutAmtGivenIn( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - fmt.Println("ADAM TokenIn", tokenInMin) + // fmt.Println("ADAM TokenIn", tokenInMin) swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInMin.Denom, priceLimit) if err != nil { @@ -450,7 +450,7 @@ func (k Keeper) computeOutAmtGivenIn( // Add spread reward growth per share to the pool-global spread reward accumulator. spreadRewardGrowth := sdk.NewDecCoinFromDec(tokenInMin.Denom, swapState.globalSpreadRewardGrowthPerUnitLiquidity) - fmt.Println("ADAM spreadRewardGrowth", spreadRewardGrowth) + // fmt.Println("ADAM spreadRewardGrowth", spreadRewardGrowth) spreadRewardAccumulator.AddToAccumulator(sdk.NewDecCoins(spreadRewardGrowth)) // Coin amounts require int values diff --git a/x/concentrated-liquidity/types/cl_pool_extensionI.go b/x/concentrated-liquidity/types/cl_pool_extensionI.go index e25d603e3f0..95171dbb0d2 100644 --- a/x/concentrated-liquidity/types/cl_pool_extensionI.go +++ b/x/concentrated-liquidity/types/cl_pool_extensionI.go @@ -27,7 +27,6 @@ type ConcentratedPoolExtension interface { SetCurrentTick(newTick int64) SetTickSpacing(newTickSpacing uint64) SetLastLiquidityUpdate(newTime time.Time) - SetTakerFee(newTakerFee sdk.Dec) UpdateLiquidity(newLiquidity sdk.Dec) ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error diff --git a/x/cosmwasmpool/model/msgs.go b/x/cosmwasmpool/model/msgs.go index 63883be9ec1..c8d8941b79c 100644 --- a/x/cosmwasmpool/model/msgs.go +++ b/x/cosmwasmpool/model/msgs.go @@ -78,8 +78,8 @@ func (msg MsgCreateCosmWasmPool) InitialLiquidity() sdk.Coins { return sdk.Coins{} } -func (msg MsgCreateCosmWasmPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { - poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg, takerFee) +func (msg MsgCreateCosmWasmPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { + poolI := NewCosmWasmPool(poolID, msg.CodeId, msg.InstantiateMsg) return poolI, nil } diff --git a/x/cosmwasmpool/model/pool.go b/x/cosmwasmpool/model/pool.go index b5840817d81..79b833a9196 100644 --- a/x/cosmwasmpool/model/pool.go +++ b/x/cosmwasmpool/model/pool.go @@ -23,14 +23,13 @@ var ( ) // NewCosmWasmPool creates a new CosmWasm pool with the specified parameters. -func NewCosmWasmPool(poolId uint64, codeId uint64, instantiateMsg []byte, takerFee sdk.Dec) *Pool { +func NewCosmWasmPool(poolId uint64, codeId uint64, instantiateMsg []byte) *Pool { pool := Pool{ CosmWasmPool: CosmWasmPool{ ContractAddress: "", // N.B. This is to be set in InitializePool() PoolId: poolId, CodeId: codeId, InstantiateMsg: instantiateMsg, - TakerFee: takerFee, }, WasmKeeper: nil, // N.B.: this is set in InitializePool(). } @@ -66,10 +65,6 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return response.SwapFee } -func (p Pool) GetTakerFee() sdk.Dec { - return p.TakerFee -} - // IsActive returns true if the pool is active func (p Pool) IsActive(ctx sdk.Context) bool { return true diff --git a/x/cosmwasmpool/model/pool.pb.go b/x/cosmwasmpool/model/pool.pb.go index f0de0b4bc95..d7f3c264002 100644 --- a/x/cosmwasmpool/model/pool.pb.go +++ b/x/cosmwasmpool/model/pool.pb.go @@ -6,7 +6,6 @@ package model import ( fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "github.com/gogo/protobuf/types" @@ -31,10 +30,6 @@ type CosmWasmPool struct { PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` CodeId uint64 `protobuf:"varint,3,opt,name=code_id,json=codeId,proto3" json:"code_id,omitempty"` InstantiateMsg []byte `protobuf:"bytes,4,opt,name=instantiate_msg,json=instantiateMsg,proto3" json:"instantiate_msg,omitempty" yaml:"instantiate_msg"` - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *CosmWasmPool) Reset() { *m = CosmWasmPool{} } @@ -78,33 +73,29 @@ func init() { } var fileDescriptor_a0cb64564a744af1 = []byte{ - // 412 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xb1, 0x6e, 0xd4, 0x40, - 0x10, 0x86, 0xed, 0x90, 0x04, 0x62, 0x45, 0x24, 0x58, 0x88, 0x98, 0x03, 0x79, 0x4f, 0x2e, 0xd0, - 0x35, 0xf6, 0xea, 0x44, 0x01, 0x4a, 0x87, 0x83, 0x22, 0x5d, 0x81, 0x84, 0xdc, 0x20, 0xd1, 0x58, - 0x6b, 0xef, 0xc6, 0x58, 0xf1, 0xde, 0x58, 0x9e, 0x4d, 0x20, 0x6f, 0x40, 0x49, 0x49, 0x99, 0x87, - 0xe0, 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0xa7, 0xa8, 0xd8, 0x54, 0x95, 0x4c, 0x89, 0x54, 0x62, - 0xe1, 0xed, 0x0e, 0xed, 0xd1, 0x61, 0x3c, 0x58, 0xb5, 0xe4, 0x89, 0x29, 0xbc, 0x05, 0x04, 0xc9, - 0xc3, 0x0d, 0xe7, 0x1d, 0x16, 0x6e, 0xea, 0x1c, 0x28, 0x76, 0x29, 0x9a, 0xf4, 0x42, 0x08, 0x6f, - 0xaf, 0x7b, 0x77, 0x3c, 0x6b, 0x89, 0xf5, 0xa7, 0x25, 0x2f, 0x8a, 0x52, 0x7d, 0xba, 0xca, 0xa2, - 0x1c, 0x64, 0xdf, 0xba, 0xfe, 0x13, 0x22, 0xbf, 0xa4, 0xea, 0xa6, 0x16, 0x18, 0xbd, 0x15, 0xf9, - 0xaa, 0x25, 0xc7, 0xa6, 0xd8, 0xff, 0x8b, 0x82, 0xe4, 0x41, 0x77, 0x3e, 0x17, 0xe2, 0xf4, 0xd1, - 0xd7, 0x5b, 0x62, 0x7d, 0xbf, 0x25, 0xd6, 0xaf, 0x1f, 0xe1, 0x9e, 0xee, 0xd8, 0x24, 0x4e, 0x66, - 0x0b, 0xdf, 0x9e, 0x2f, 0x7c, 0xfb, 0xef, 0xc2, 0xb7, 0xbf, 0x2d, 0x7d, 0x6b, 0xbe, 0xf4, 0xad, - 0xdf, 0x4b, 0xdf, 0xfa, 0xf8, 0x7a, 0xa3, 0x64, 0x3f, 0xd8, 0xb0, 0x62, 0x19, 0xae, 0x05, 0xbd, - 0x1e, 0xbf, 0xa2, 0x5f, 0xee, 0xae, 0x46, 0xb7, 0x12, 0xd9, 0x7e, 0x37, 0x9e, 0x97, 0xff, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x81, 0xd8, 0xea, 0x01, 0x3f, 0x02, 0x00, 0x00, + // 350 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0x3f, 0x4f, 0xc2, 0x40, + 0x18, 0xc6, 0x7b, 0x8a, 0x18, 0x1b, 0x22, 0xda, 0x18, 0x41, 0x34, 0x2d, 0xe9, 0xc4, 0x42, 0x2f, + 0xc4, 0x41, 0xc3, 0x26, 0x24, 0x26, 0x0c, 0x26, 0xa6, 0x8b, 0x89, 0x4b, 0x73, 0xfd, 0x63, 0x6d, + 0xd2, 0xe3, 0x25, 0xbc, 0x07, 0xea, 0x37, 0x70, 0x74, 0x74, 0xe4, 0x43, 0xf8, 0x21, 0x8c, 0x13, + 0xa3, 0x13, 0x21, 0xf0, 0x0d, 0xf8, 0x04, 0xe6, 0x7a, 0x25, 0x41, 0xb6, 0x3e, 0xbf, 0xe7, 0xd7, + 0xdc, 0xdd, 0xfb, 0xea, 0x4d, 0x40, 0x0e, 0x98, 0x20, 0x0d, 0x00, 0xf9, 0x0b, 0x43, 0x3e, 0x00, + 0x48, 0xe9, 0xb8, 0xe5, 0x47, 0x82, 0xb5, 0x28, 0x87, 0x30, 0x4a, 0xa9, 0x44, 0xce, 0x60, 0x08, + 0x02, 0x8c, 0x8b, 0x5c, 0x77, 0x36, 0x75, 0x27, 0xd7, 0x6b, 0x67, 0x41, 0x56, 0x7b, 0x99, 0x4b, + 0x55, 0x50, 0x3f, 0xd6, 0x4e, 0x62, 0x88, 0x41, 0x71, 0xf9, 0x95, 0x53, 0x2b, 0x06, 0x88, 0xd3, + 0x88, 0x66, 0xc9, 0x1f, 0x3d, 0x51, 0x91, 0xf0, 0x08, 0x05, 0xe3, 0x03, 0x25, 0xd8, 0x73, 0xa2, + 0x97, 0xba, 0x80, 0xfc, 0x81, 0x21, 0xbf, 0x07, 0x48, 0x8d, 0x5b, 0xfd, 0x28, 0x80, 0xbe, 0x18, + 0xb2, 0x40, 0x78, 0x2c, 0x0c, 0x87, 0x11, 0x62, 0x95, 0xd4, 0x49, 0xe3, 0xa0, 0x73, 0xbe, 0x9a, + 0x59, 0x95, 0x37, 0xc6, 0xd3, 0xb6, 0xbd, 0x6d, 0xd8, 0x6e, 0x79, 0x8d, 0x6e, 0x14, 0x31, 0x2a, + 0xfa, 0xbe, 0xbc, 0xba, 0x97, 0x84, 0xd5, 0x9d, 0x3a, 0x69, 0x14, 0xdc, 0xa2, 0x8c, 0xbd, 0x50, + 0x16, 0x01, 0x84, 0x91, 0x2c, 0x76, 0x55, 0x21, 0x63, 0x2f, 0x34, 0xba, 0x7a, 0x39, 0xe9, 0xa3, + 0x60, 0x7d, 0x91, 0x30, 0x11, 0x79, 0x1c, 0xe3, 0x6a, 0xa1, 0x4e, 0x1a, 0xa5, 0x4e, 0x6d, 0x35, + 0xb3, 0x4e, 0xd5, 0xc1, 0x5b, 0x82, 0xed, 0x1e, 0x6e, 0x90, 0x3b, 0x8c, 0xdb, 0xc7, 0xef, 0x13, + 0x4b, 0xfb, 0x9c, 0x58, 0xda, 0xcf, 0x57, 0x73, 0x4f, 0x3e, 0xa8, 0xd7, 0x71, 0xbf, 0x17, 0x26, + 0x99, 0x2e, 0x4c, 0x32, 0x5f, 0x98, 0xe4, 0x63, 0x69, 0x6a, 0xd3, 0xa5, 0xa9, 0xfd, 0x2e, 0x4d, + 0xed, 0xf1, 0x3a, 0x4e, 0xc4, 0xf3, 0xc8, 0x77, 0x02, 0xe0, 0x34, 0x9f, 0x7b, 0x33, 0x65, 0x3e, + 0xae, 0x03, 0x1d, 0xb7, 0xae, 0xe8, 0xeb, 0xff, 0xcd, 0x65, 0x1b, 0xf3, 0x8b, 0xd9, 0xf4, 0x2e, + 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x59, 0xc9, 0x13, 0x28, 0xde, 0x01, 0x00, 0x00, } func (m *CosmWasmPool) Marshal() (dAtA []byte, err error) { @@ -127,16 +118,6 @@ func (m *CosmWasmPool) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a if len(m.InstantiateMsg) > 0 { i -= len(m.InstantiateMsg) copy(dAtA[i:], m.InstantiateMsg) @@ -195,8 +176,6 @@ func (m *CosmWasmPool) Size() (n int) { if l > 0 { n += 1 + l + sovPool(uint64(l)) } - l = m.TakerFee.Size() - n += 1 + l + sovPool(uint64(l)) return n } @@ -339,40 +318,6 @@ func (m *CosmWasmPool) Unmarshal(dAtA []byte) error { m.InstantiateMsg = []byte{} } iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipPool(dAtA[iNdEx:]) diff --git a/x/cosmwasmpool/model/store_model.go b/x/cosmwasmpool/model/store_model.go index 0a6cca8b998..c0e0a53b189 100644 --- a/x/cosmwasmpool/model/store_model.go +++ b/x/cosmwasmpool/model/store_model.go @@ -37,14 +37,6 @@ func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { panic("CosmWasmPool.GetSpreadFactor not implemented") } -func (p CosmWasmPool) GetTakerFee() sdk.Dec { - return p.TakerFee -} - -func (p *CosmWasmPool) SetTakerFee(newTakerFee sdk.Dec) { - p.TakerFee = newTakerFee -} - func (p CosmWasmPool) GetExitFee(ctx sdk.Context) sdk.Dec { panic("CosmWasmPool.GetExitFee not implemented") } diff --git a/x/cosmwasmpool/pool_module_test.go b/x/cosmwasmpool/pool_module_test.go index cf96aa57bf0..ec8ade15683 100644 --- a/x/cosmwasmpool/pool_module_test.go +++ b/x/cosmwasmpool/pool_module_test.go @@ -29,7 +29,6 @@ type PoolModuleSuite struct { var ( defaultAmount = sdk.NewInt(100) - defaultTakerFee = sdk.MustNewDecFromStr("0.0015") initalDefaultSupply = sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)) defaultDenoms = []string{denomA, denomB} @@ -83,7 +82,7 @@ func (s *PoolModuleSuite) TestInitializePool() { var testPool poolmanagertypes.PoolI if !tc.isInvalidPoolType { - testPool = model.NewCosmWasmPool(defaultPoolId, tc.codeid, tc.instantiateMsg, defaultTakerFee) + testPool = model.NewCosmWasmPool(defaultPoolId, tc.codeid, tc.instantiateMsg) } else { testPool = s.PrepareConcentratedPool() } diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index cfbc8149ee7..19e0f44d6a5 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -354,3 +354,7 @@ func asCFMMPool(pool poolmanagertypes.PoolI) (types.CFMMPoolI, error) { } return cfmmPool, nil } + +func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) { + return k.poolManager.GetTradingPairTakerFee(ctx, denom0, denom1) +} diff --git a/x/gamm/pool-models/balancer/balancerPool.pb.go b/x/gamm/pool-models/balancer/balancerPool.pb.go index 44f5cebe3e7..cc37401dbb6 100644 --- a/x/gamm/pool-models/balancer/balancerPool.pb.go +++ b/x/gamm/pool-models/balancer/balancerPool.pb.go @@ -141,10 +141,6 @@ type PoolParams struct { // fee anymore ExitFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exit_fee" yaml:"exit_fee"` SmoothWeightChangeParams *SmoothWeightChangeParams `protobuf:"bytes,3,opt,name=smooth_weight_change_params,json=smoothWeightChangeParams,proto3" json:"smooth_weight_change_params,omitempty" yaml:"smooth_weight_change_params"` - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -306,63 +302,62 @@ func init() { } var fileDescriptor_7e991f749f68c2a4 = []byte{ - // 893 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xc6, 0xce, 0xbf, 0x49, 0x29, 0x64, 0xea, 0x83, 0xe3, 0x08, 0x4f, 0x34, 0x20, 0x54, - 0x55, 0xcd, 0xae, 0x52, 0x90, 0x90, 0x72, 0xa9, 0xba, 0xfd, 0x83, 0x7a, 0x2b, 0x5b, 0xa4, 0x52, - 0x54, 0x69, 0x35, 0xb6, 0x27, 0xbb, 0xab, 0xec, 0xee, 0xac, 0x76, 0xc6, 0x69, 0xf3, 0x0d, 0x10, - 0xa7, 0x1e, 0xcb, 0xad, 0x77, 0x2e, 0x1c, 0xf8, 0x10, 0x11, 0x5c, 0x2a, 0x71, 0x41, 0x1c, 0x16, - 0x94, 0x1c, 0x90, 0xe0, 0xe6, 0x4f, 0x80, 0x66, 0xe6, 0xad, 0xed, 0x04, 0x5b, 0x34, 0xea, 0xc5, - 0x9e, 0xf7, 0xe6, 0xbd, 0xdf, 0xfb, 0xf7, 0x7b, 0x63, 0xa3, 0xcf, 0x84, 0xcc, 0x84, 0x4c, 0xa4, - 0x17, 0xb1, 0x2c, 0xf3, 0x0a, 0x21, 0xd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e, 0x3b, 0xeb, 0x35, 0xbe, 0xb9, 0x3d, 0x93, 0x16, 0xf8, 0xef, 0xa6, 0xac, 0x2f, 0x6b, 0xc1, - 0x3b, 0xda, 0xfb, 0xdc, 0x7b, 0xb1, 0xf8, 0x8f, 0x40, 0x7f, 0xc5, 0xfc, 0x12, 0x7d, 0xfa, 0x6f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xf9, 0x14, 0x38, 0x13, 0x34, 0x08, 0x00, 0x00, + // 867 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x8b, 0xdb, 0x46, + 0x14, 0xb7, 0xd6, 0xde, 0x75, 0x76, 0x9c, 0xa6, 0xec, 0xc4, 0x07, 0xd9, 0x4b, 0x3d, 0xcb, 0xb4, + 0x94, 0x10, 0x62, 0x09, 0xa7, 0x85, 0xc2, 0x5e, 0x42, 0x94, 0xa4, 0x25, 0xb7, 0x54, 0x29, 0xa4, + 0x29, 0x01, 0x31, 0xb6, 0xc7, 0x92, 0x88, 0xa4, 0x11, 0x9a, 0xb1, 0x93, 0xfd, 0x06, 0x25, 0xa7, + 0x1c, 0xd3, 0x5b, 0xee, 0xbd, 0xf4, 0xd0, 0x0f, 0xb1, 0xb4, 0x97, 0x40, 0x2f, 0xa5, 0x07, 0xb5, + 0xec, 0x1e, 0x0a, 0x3d, 0xfa, 0x13, 0x94, 0xf9, 0x23, 0xff, 0xd9, 0xda, 0x34, 0x21, 0x17, 0x7b, + 0xe6, 0xcd, 0x7b, 0xbf, 0xf7, 0x7b, 0xef, 0xfd, 0x66, 0x04, 0x3e, 0x67, 0x3c, 0x65, 0x3c, 0xe6, + 0x6e, 0x48, 0xd2, 0xd4, 0xcd, 0x19, 0x4b, 0xfa, 0x29, 0x1b, 0xd3, 0x84, 0xbb, 0x43, 0x92, 0x90, + 0x6c, 0x44, 0x8b, 0xc5, 0xe2, 0x01, 0x63, 0x89, 0x93, 0x17, 0x4c, 0x30, 0xd8, 0x36, 0x51, 0x8e, + 0x8c, 0x72, 0x66, 0x83, 0x21, 0x15, 0x64, 0xd0, 0xed, 0x8c, 0x94, 0x39, 0x50, 0x3e, 0xae, 0xde, + 0xe8, 0x80, 0x6e, 0x3b, 0x64, 0x21, 0xd3, 0x76, 0xb9, 0x32, 0xd6, 0x03, 0x92, 0xc6, 0x19, 0x73, + 0xd5, 0xaf, 0x31, 0xf5, 0x42, 0xc6, 0xc2, 0x84, 0xba, 0x6a, 0x37, 0x9c, 0x4e, 0xdc, 0xf1, 0xb4, + 0x20, 0x22, 0x66, 0x99, 0x39, 0x47, 0x17, 0xcf, 0x45, 0x9c, 0x52, 0x2e, 0x48, 0x9a, 0x57, 0x00, + 0x3a, 0xaf, 0x4b, 0xa6, 0x22, 0x72, 0x0d, 0x33, 0xb5, 0xb9, 0x70, 0x3e, 0x24, 0x9c, 0x2e, 0xce, + 0x47, 0x2c, 0x36, 0x09, 0xf0, 0xaf, 0x75, 0x60, 0x3f, 0x4c, 0x19, 0x13, 0xd1, 0x23, 0x1a, 0x87, + 0x91, 0xb8, 0x13, 0x91, 0x2c, 0xa4, 0x0f, 0x48, 0x41, 0x52, 0x0e, 0xbf, 0x05, 0x80, 0x0b, 0x52, + 0x88, 0x40, 0x66, 0xb5, 0xad, 0x23, 0xeb, 0x5a, 0xeb, 0x66, 0xd7, 0xd1, 0x94, 0x9c, 0x8a, 0x92, + 0xf3, 0x4d, 0x45, 0xc9, 0xfb, 0xe8, 0xb4, 0x44, 0xb5, 0x79, 0x89, 0x0e, 0x4e, 0x48, 0x9a, 0x1c, + 0xe3, 0x65, 0x2c, 0x7e, 0xf9, 0x27, 0xb2, 0xfc, 0x7d, 0x65, 0x90, 0xee, 0x30, 0x02, 0x97, 0xaa, + 0x4a, 0xed, 0x1d, 0x85, 0xdb, 0xf9, 0x0f, 0xee, 0x5d, 0xe3, 0xe0, 0x0d, 0x24, 0xec, 0x3f,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, 0x18, 0x39, 0xd3, + 0x07, 0x00, 0x00, } func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error) { @@ -452,16 +447,6 @@ func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintBalancerPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 if m.SmoothWeightChangeParams != nil { { size, err := m.SmoothWeightChangeParams.MarshalToSizedBuffer(dAtA[:i]) @@ -676,8 +661,6 @@ func (m *PoolParams) Size() (n int) { l = m.SmoothWeightChangeParams.Size() n += 1 + l + sovBalancerPool(uint64(l)) } - l = m.TakerFee.Size() - n += 1 + l + sovBalancerPool(uint64(l)) return n } @@ -1049,40 +1032,6 @@ func (m *PoolParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowBalancerPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthBalancerPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthBalancerPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipBalancerPool(dAtA[iNdEx:]) diff --git a/x/gamm/pool-models/balancer/marshal_test.go b/x/gamm/pool-models/balancer/marshal_test.go index afd8b840e40..a9db3244073 100644 --- a/x/gamm/pool-models/balancer/marshal_test.go +++ b/x/gamm/pool-models/balancer/marshal_test.go @@ -27,9 +27,8 @@ func TestPoolJson(t *testing.T) { }, } pacc, err := balancer.NewBalancerPool(poolId, balancer.PoolParams{ - SwapFee: defaultSpreadFactor, - ExitFee: defaultZeroExitFee, - TakerFee: defaultTakerFee, + SwapFee: defaultSpreadFactor, + ExitFee: defaultZeroExitFee, }, jsonAssetTest, defaultFutureGovernor, defaultCurBlockTime) require.NoError(t, err) diff --git a/x/gamm/pool-models/balancer/msgs.go b/x/gamm/pool-models/balancer/msgs.go index 8fc211ec54f..4209751cb27 100644 --- a/x/gamm/pool-models/balancer/msgs.go +++ b/x/gamm/pool-models/balancer/msgs.go @@ -96,8 +96,7 @@ func (msg MsgCreateBalancerPool) InitialLiquidity() sdk.Coins { return coins } -func (msg MsgCreateBalancerPool) CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { - msg.PoolParams.TakerFee = takerFee +func (msg MsgCreateBalancerPool) CreatePool(ctx sdk.Context, poolID uint64) (poolmanagertypes.PoolI, error) { poolI, err := NewBalancerPool(poolID, *msg.PoolParams, msg.PoolAssets, msg.FuturePoolGovernor, ctx.BlockTime()) return &poolI, err } diff --git a/x/gamm/pool-models/balancer/msgs_test.go b/x/gamm/pool-models/balancer/msgs_test.go index 7a11e6e1114..22b60bf2681 100644 --- a/x/gamm/pool-models/balancer/msgs_test.go +++ b/x/gamm/pool-models/balancer/msgs_test.go @@ -243,7 +243,6 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { } func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { - defaultTakerFee := sdk.MustNewDecFromStr("0.0015") tests := map[string]struct { msg balancer.MsgCreateBalancerPool poolId uint64 @@ -272,7 +271,7 @@ func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { for name, tc := range tests { s.Run(name, func() { - pool, err := tc.msg.CreatePool(s.Ctx, 1, defaultTakerFee) + pool, err := tc.msg.CreatePool(s.Ctx, 1) if tc.expectError { s.Require().Error(err) diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index f9872767389..49dbdd3c53b 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -92,10 +92,6 @@ func (p Pool) GetSpreadFactor(_ sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } -func (p Pool) GetTakerFee() sdk.Dec { - return p.PoolParams.TakerFee -} - func (p Pool) GetTotalPoolLiquidity(_ sdk.Context) sdk.Coins { return poolAssetsCoins(p.PoolAssets) } @@ -116,10 +112,6 @@ func (p Pool) GetTotalShares() sdk.Int { return p.TotalShares.Amount } -func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { - p.PoolParams.TakerFee = newTakerFee -} - func (p *Pool) AddTotalShares(amt sdk.Int) { p.TotalShares.Amount = p.TotalShares.Amount.Add(amt) } diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 58f32a33af2..2fbf55b6423 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -19,7 +19,6 @@ import ( var ( defaultSpreadFactor = sdk.MustNewDecFromStr("0.025") - defaultTakerFee = sdk.MustNewDecFromStr("0.0015") defaultZeroExitFee = sdk.ZeroDec() defaultPoolId = uint64(10) defaultBalancerPoolParams = balancer.PoolParams{ diff --git a/x/gamm/pool-models/stableswap/msgs.go b/x/gamm/pool-models/stableswap/msgs.go index 116030e1527..8be5ca20dbc 100644 --- a/x/gamm/pool-models/stableswap/msgs.go +++ b/x/gamm/pool-models/stableswap/msgs.go @@ -110,8 +110,7 @@ func (msg MsgCreateStableswapPool) InitialLiquidity() sdk.Coins { return msg.InitialPoolLiquidity } -func (msg MsgCreateStableswapPool) CreatePool(ctx sdk.Context, poolId uint64, takerFee sdk.Dec) (poolmanagertypes.PoolI, error) { - msg.PoolParams.TakerFee = takerFee +func (msg MsgCreateStableswapPool) CreatePool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error) { stableswapPool, err := NewStableswapPool(poolId, *msg.PoolParams, msg.InitialPoolLiquidity, msg.ScalingFactors, msg.ScalingFactorController, msg.FuturePoolGovernor) if err != nil { diff --git a/x/gamm/pool-models/stableswap/msgs_test.go b/x/gamm/pool-models/stableswap/msgs_test.go index 24ead9fd5bd..f8626866ce3 100644 --- a/x/gamm/pool-models/stableswap/msgs_test.go +++ b/x/gamm/pool-models/stableswap/msgs_test.go @@ -298,7 +298,6 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { func (suite *TestSuite) TestMsgCreateStableswapPool() { suite.SetupTest() - defaultTakerFee := sdk.MustNewDecFromStr("0.0015") var ( validParams = &stableswap.PoolParams{SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.ZeroDec()} @@ -339,7 +338,7 @@ func (suite *TestSuite) TestMsgCreateStableswapPool() { for name, tc := range tests { suite.Run(name, func() { - pool, err := tc.msg.CreatePool(suite.Ctx, 1, defaultTakerFee) + pool, err := tc.msg.CreatePool(suite.Ctx, 1) if tc.expectError { suite.Require().Error(err) diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index e0c58377539..8876eaa6bc8 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -90,10 +90,6 @@ func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { return p.PoolParams.SwapFee } -func (p Pool) GetTakerFee() sdk.Dec { - return p.PoolParams.TakerFee -} - func (p Pool) GetExitFee(ctx sdk.Context) sdk.Dec { return p.PoolParams.ExitFee } @@ -119,10 +115,6 @@ func (p Pool) GetType() poolmanagertypes.PoolType { return poolmanagertypes.Stableswap } -func (p *Pool) SetTakerFee(newTakerFee sdk.Dec) { - p.PoolParams.TakerFee = newTakerFee -} - // CONTRACT: scaling factors follow the same index with pool liquidity denoms func (p Pool) GetScalingFactorByDenom(denom string) uint64 { for i, coin := range p.PoolLiquidity { diff --git a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go index 806fad93622..7c94c3c27c0 100644 --- a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go +++ b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go @@ -39,10 +39,6 @@ type PoolParams struct { // pools can maintain a non-zero fee. No new pool can be created with non-zero // fee anymore ExitFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"exit_fee" yaml:"exit_fee"` - // taker_fee is the ratio that is charged on the amount of token in. - // this value is assigned by the protocol at time of pool creation, - // however can be changed by governance. - TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -144,51 +140,50 @@ func init() { } var fileDescriptor_ae0f054436f9999a = []byte{ - // 699 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcf, 0x4f, 0x13, 0x4d, - 0x18, 0xc7, 0xdb, 0x52, 0x28, 0x0c, 0xef, 0x5b, 0xde, 0x77, 0x25, 0xb1, 0x40, 0xdc, 0x2d, 0x1b, - 0x21, 0x84, 0xd8, 0x5d, 0xab, 0x89, 0x46, 0x6e, 0x14, 0x83, 0x31, 0x31, 0x06, 0x97, 0x93, 0x3f, - 0x92, 0x75, 0x76, 0x77, 0xba, 0x4c, 0xd8, 0xed, 0xac, 0x33, 0xb3, 0x08, 0x17, 0xcf, 0xc6, 0x93, - 0x47, 0x8f, 0x9c, 0x3d, 0x79, 0xf0, 0x8f, 0x20, 0x7a, 0xc1, 0x9b, 0xf1, 0xb0, 0x1a,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, 0x21, 0xb4, 0x56, 0x96, - 0x57, 0x31, 0xba, 0x99, 0x31, 0x97, 0xc3, 0x7e, 0x95, 0x65, 0x3a, 0x5a, 0xee, 0x16, 0x33, 0xdc, - 0x51, 0x4e, 0xed, 0x21, 0xf8, 0x87, 0x13, 0x0e, 0x23, 0x97, 0x6d, 0x41, 0x8a, 0x58, 0x6d, 0x54, - 0xde, 0x69, 0xc6, 0x52, 0x3f, 0x1e, 0x21, 0xd2, 0xfe, 0xf0, 0x6b, 0x04, 0x77, 0x5a, 0x73, 0x6a, - 0xec, 0x0b, 0xea, 0x59, 0x4e, 0x14, 0x9b, 0xce, 0xa4, 0x34, 0x37, 0xa5, 0xa5, 0x51, 0x50, 0x95, - 0x03, 0x44, 0xf8, 0x59, 0x8a, 0x03, 0xcc, 0xf7, 0x6a, 0x63, 0xf5, 0x91, 0xb3, 0xe1, 0x57, 0x05, - 0xfc, 0xed, 0x57, 0x63, 0xe9, 0x1c, 0xea, 0x10, 0x05, 0xcc, 0xf9, 0x57, 0xb4, 0xb8, 0xd7, 0xeb, - 0xa0, 0xdd, 0x07, 0x53, 0xcc, 0x87, 0x11, 0xee, 0x84, 0x6e, 0x1b, 0xfa, 0x9c, 0x50, 0x56, 0xab, - 0xd4, 0x47, 0x96, 0xca, 0xad, 0x85, 0x6e, 0x66, 0xcc, 0xff, 0xb4, 0xe9, 0x53, 0xb9, 0xa6, 0x53, - 0x55, 0x9e, 0xf5, 0xdc, 0xa1, 0x3d, 0x05, 0x33, 0xc3, 0x39, 0xae, 0x4f, 0x3a, 0x9c, 0x92, 0x28, - 0x42, 0xb4, 0x36, 0x2e, 0xd7, 0x7e, 0xb9, 0x9b, 0x19, 0x75, 0x45, 0xfe, 0x5d, 0xaa, 0xe9, 0x5c, - 0x1c, 0x02, 0xaf, 0xf5, 0x23, 0x2b, 0xcd, 0x97, 0xfb, 0x46, 0xe1, 0xcd, 0xbe, 0x51, 0xf8, 0xf0, - 0xbe, 0x31, 0x2a, 0x9e, 0xe6, 0xae, 0xd0, 0xf4, 0xdc, 0x19, 0x9a, 0x6e, 0x3d, 0x3e, 0x38, 0xd2, - 0x8b, 0x87, 0x47, 0x7a, 0xf1, 0xdb, 0x91, 0x5e, 0x7c, 0x7d, 0xac, 0x17, 0x0e, 0x8f, 0xf5, 0xc2, - 0xe7, 0x63, 0xbd, 0xf0, 0x68, 0xf5, 0xc4, 0xde, 0x14, 0xa1, 0x11, 0x41, 0x8f, 0xf5, 0x0c, 0x7b, - 0xa7, 0x79, 0xd3, 0xde, 0x3d, 0xeb, 0x2b, 0xec, 0x8d, 0xc9, 0xaf, 0xd0, 0xf5, 0x1f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0x30, 0x84, 0xb8, 0x90, 0xb3, 0x05, 0x00, 0x00, + // 676 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xbf, 0x6f, 0xd3, 0x4c, + 0x18, 0x8e, 0xdb, 0xb4, 0xe9, 0x77, 0xfd, 0xbe, 0x54, 0x9f, 0xa9, 0x84, 0xdb, 0x0a, 0x5f, 0x6a, + 0xd1, 0x2a, 0xaa, 0x88, 0x4d, 0x40, 0x02, 0xd1, 0xad, 0x29, 0x2a, 0x42, 0x42, 0xa8, 0xb8, 0x13, + 0x3f, 0xa4, 0x70, 0xb6, 0x2f, 0xee, 0x09, 0x3b, 0x67, 0x7c, 0xe7, 0xd2, 0x2e, 0xcc, 0x88, 0x89, + 0x91, 0xb1, 0x33, 0x13, 0x03, 0x7f, 0x44, 0x05, 0x4b, 0x47, 0xc4, 0x60, 0x50, 0x3b, 0xb0, 0xa2, + 0xfc, 0x05, 0xe8, 0xce, 0x97, 0xa4, 0x29, 0x50, 0x55, 0x62, 0x49, 0xee, 0x7d, 0xdf, 0xe7, 0x7d, + 0xde, 0x5f, 0x8f, 0x0c, 0x6e, 0x51, 0x16, 0x53, 0x46, 0x98, 0x13, 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, 0x4d, 0x67, 0xf7, 0xac, 0x8f, + 0xa4, 0x37, 0x29, 0x3f, 0x12, 0xd7, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x67, 0x8c, 0xb0, 0xa0, + 0x52, 0x05, 0x00, 0x00, } func (m *PoolParams) Marshal() (dAtA []byte, err error) { @@ -211,16 +206,6 @@ func (m *PoolParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.TakerFee.Size() - i -= size - if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintStableswapPool(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a { size := m.ExitFee.Size() i -= size @@ -366,8 +351,6 @@ func (m *PoolParams) Size() (n int) { n += 1 + l + sovStableswapPool(uint64(l)) l = m.ExitFee.Size() n += 1 + l + sovStableswapPool(uint64(l)) - l = m.TakerFee.Size() - n += 1 + l + sovStableswapPool(uint64(l)) return n } @@ -515,40 +498,6 @@ func (m *PoolParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowStableswapPool - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthStableswapPool - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthStableswapPool - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStableswapPool(dAtA[iNdEx:]) diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index ef802d80ab6..fa1a2caac95 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -147,7 +147,12 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont // calculate the minimum number of tokens received from input of tokenIn // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. - amountInAfterTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(pool.GetTakerFee())) + takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) + if err != nil { + return nil, err + } + + amountInAfterTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) tokenInAfterTakerFee := sdk.NewCoin(randomCoinSubset[0].Denom, amountInAfterTakerFee.TruncateInt()) tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(tokenInAfterTakerFee), coinOut.Denom, pool.GetSpreadFactor(ctx)) @@ -190,7 +195,12 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con // utilize CalcOutAmtGivenIn to calculate tokenOut and use tokenOut to calculate tokenInMax // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. - totalFees := pool.GetSpreadFactor(ctx).Add(pool.GetTakerFee()) + takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) + if err != nil { + return nil, err + } + totalFees := pool.GetSpreadFactor(ctx).Add(takerFee) + tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, totalFees) if err != nil { return nil, err diff --git a/x/gamm/types/expected_keepers.go b/x/gamm/types/expected_keepers.go index dd21efda346..453dac51933 100644 --- a/x/gamm/types/expected_keepers.go +++ b/x/gamm/types/expected_keepers.go @@ -95,6 +95,8 @@ type PoolManager interface { GetPool(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolI, error) CreateConcentratedPoolAsPoolManager(ctx sdk.Context, msg poolmanagertypes.CreatePoolMsg) (poolmanagertypes.PoolI, error) + + GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) } type PoolIncentivesKeeper interface { diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index 88a39475731..832af8d9cb9 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -57,7 +57,6 @@ type CFMMPoolI interface { // GetExitFee returns the pool's exit fee, based on the current state. // Pools may choose to make their exit fees dependent upon state. GetExitFee(ctx sdk.Context) sdk.Dec - SetTakerFee(newTakerFee sdk.Dec) } // PoolAmountOutExtension is an extension of the PoolI diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 30823332477..69cd7d3529d 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -105,14 +105,10 @@ func (k Keeper) createPoolZeroLiquidityNoCreationFee(ctx sdk.Context, msg types. // Get the next pool ID and increment the pool ID counter. poolId := k.getNextPoolIdAndIncrement(ctx) - poolAssets := msg.InitialLiquidity() poolType := msg.GetPoolType() - poolManagerParams := k.GetParams(ctx) - - takerFee := DetermineTakerFee(poolManagerParams, poolAssets, poolType) // Create the pool with the given pool ID. - pool, err := msg.CreatePool(ctx, poolId, takerFee) + pool, err := msg.CreatePool(ctx, poolId) if err != nil { return nil, err } @@ -221,64 +217,88 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) return parsedValue, nil } -// determineTakerFee determines what the taker fee should be based on the pool type and denoms given. -// This taker fee can be overridden by governance after the pool is created. -func DetermineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { - if poolType == types.Stableswap { - return poolManagerParams.StableswapTakerFee - } else { - // Check if all denoms exist in the stable denom list in poolmanager params. - // As soon as one denom is not in the list, we know that the pool is not a stableswap pool - // and move on to the next check. - allAssetsAreStable := true - for _, asset := range poolAssets { - isStable := false - for _, stableDenom := range poolManagerParams.StablecoinDenoms { - if asset.Denom == stableDenom { - isStable = true - break - } - } - // If we reach here and isStable is still false, - // it means that the asset denom is not in the stable denom list - if !isStable { - allAssetsAreStable = false - break - } - } - - if allAssetsAreStable { - // If we reach here, it means that all denoms are in the stable denom list - // Therefore, we know that the pool is a stableswap pool and set the taker fee to the stableswap fee. - return poolManagerParams.StableswapTakerFee - } else if len(poolAssets) == 2 { - // This brings us to our check, to see if this is an LST <> underlying denom pool. - isStableLSTPair := false - for _, asset := range poolAssets { - for i, lstDenom := range poolManagerParams.LiquidStakeDenomPairings { - if asset.Denom == lstDenom.UnderlyingTokenDenom { - for _, denom := range lstDenom.LiquidStakedTokenDenoms { - if (i == 0 && poolAssets[1].Denom == denom) || - (i != 0 && poolAssets[0].Denom == denom) { - isStableLSTPair = true - break - } - } - } - if isStableLSTPair { - break - } - } - if isStableLSTPair { - break - } - } - if isStableLSTPair { - // If it is an LST <> underlying denom pool, we set the taker fee to the stableswap fee. - return poolManagerParams.StableswapTakerFee - } - } +// // determineTakerFee determines what the taker fee should be based on the pool type and denoms given. +// // This taker fee can be overridden by governance after the pool is created. +// func DetermineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { +// if poolType == types.Stableswap { +// return poolManagerParams.StableswapTakerFee +// } else { +// // Check if all denoms exist in the stable denom list in poolmanager params. +// // As soon as one denom is not in the list, we know that the pool is not a stableswap pool +// // and move on to the next check. +// allAssetsAreStable := true +// for _, asset := range poolAssets { +// isStable := false +// for _, stableDenom := range poolManagerParams.StablecoinDenoms { +// if asset.Denom == stableDenom { +// isStable = true +// break +// } +// } +// // If we reach here and isStable is still false, +// // it means that the asset denom is not in the stable denom list +// if !isStable { +// allAssetsAreStable = false +// break +// } +// } + +// if allAssetsAreStable { +// // If we reach here, it means that all denoms are in the stable denom list +// // Therefore, we know that the pool is a stableswap pool and set the taker fee to the stableswap fee. +// return poolManagerParams.StableswapTakerFee +// } else if len(poolAssets) == 2 { +// // This brings us to our check, to see if this is an LST <> underlying denom pool. +// isStableLSTPair := false +// for _, asset := range poolAssets { +// for i, lstDenom := range poolManagerParams.LiquidStakeDenomPairings { +// if asset.Denom == lstDenom.UnderlyingTokenDenom { +// for _, denom := range lstDenom.LiquidStakedTokenDenoms { +// if (i == 0 && poolAssets[1].Denom == denom) || +// (i != 0 && poolAssets[0].Denom == denom) { +// isStableLSTPair = true +// break +// } +// } +// } +// if isStableLSTPair { +// break +// } +// } +// if isStableLSTPair { +// break +// } +// } +// if isStableLSTPair { +// // If it is an LST <> underlying denom pool, we set the taker fee to the stableswap fee. +// return poolManagerParams.StableswapTakerFee +// } +// } +// } + +// return poolManagerParams.DefaultTakerFee +// } + +// SetTradingPairTakerFee sets the taker fee for the given trading pair. +func (k Keeper) SetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { + store := ctx.KVStore(k.storeKey) + osmoutils.MustSetDec(store, types.FormatDenomTradePairKey(denom0, denom1), takerFee) +} + +// GetTradingPairTakerFee returns the taker fee for the given trading pair. +// If the trading pair does not exist, it returns the default taker fee. +func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) { + store := ctx.KVStore(k.storeKey) + key := types.FormatDenomTradePairKey(denom0, denom1) + + takerFee := &sdk.DecProto{} + found, err := osmoutils.Get(store, key, takerFee) + if err != nil { + return sdk.Dec{}, err + } + if !found { + return k.GetParams(ctx).DefaultTakerFee, nil } - return poolManagerParams.DefaultTakerFee + return takerFee.Dec, nil } diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index f32953e9dc1..c1a04c28e8b 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -95,7 +95,11 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - takerFee := pool.GetTakerFee() + takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenOutDenom, tokenIn.Denom) + if err != nil { + return sdk.Int{}, err + } + tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err @@ -215,7 +219,11 @@ func (k Keeper) SwapExactAmountIn( poolManagerParams := k.GetParams(ctx) spreadFactor := pool.GetSpreadFactor(ctx) - takerFee := pool.GetTakerFee() + + takerFee, err := k.GetTradingPairTakerFee(ctx, tokenOutDenom, tokenIn.Denom) + if err != nil { + return sdk.Int{}, err + } tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) if err != nil { @@ -321,7 +329,14 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, poolI.GetTakerFee()) + takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenOutDenom, tokenIn.Denom) + if err != nil { + return sdk.Int{}, err + } + + fmt.Println("ADAM Taker gee: ", takerFee.String()) + + tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, takerFee) tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterTakerFee, routeStep.TokenOutDenom, spreadFactor) if err != nil { @@ -437,7 +452,10 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - takerFee := pool.GetTakerFee() + takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenInDenom, _tokenOut.Denom) + if err != nil { + return sdk.Int{}, err + } _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) if swapErr != nil { @@ -732,7 +750,11 @@ func (k Keeper) createMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := poolI.GetTakerFee() + + takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenInDenom, tokenOut.Denom) + if err != nil { + return nil, err + } tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, spreadFactor) if err != nil { @@ -770,7 +792,12 @@ func (k Keeper) createOsmoMultihopExpectedSwapOuts( } spreadFactor := poolI.GetSpreadFactor(ctx) - takerFee := poolI.GetTakerFee() + + takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenInDenom, tokenOut.Denom) + if err != nil { + return nil, err + } + osmoDiscountedSpreadFactor := cumulativeRouteSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) tokenIn, err := swapModule.CalcInAmtGivenOut(ctx, poolI, tokenOut, routeStep.TokenInDenom, osmoDiscountedSpreadFactor) diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 6ee35e1aec7..f4e334cda57 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1374,7 +1374,8 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := routeSpreadFactor.Mul((currentPoolSpreadFactor.Quo(sumOfSpreadFactors))) - takerFee := hopPool.GetTakerFee() + takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenInDenom, nextTokenOut.Denom) + s.Require().NoError(err) swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) @@ -1397,7 +1398,8 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo s.Require().NoError(err) updatedPoolSpreadFactor := hopPool.GetSpreadFactor(cacheCtx) - takerFee := hopPool.GetTakerFee() + takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenInDenom, nextTokenOut.Denom) + s.Require().NoError(err) swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) @@ -1439,7 +1441,8 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := routeSpreadFactor.Mul(pool.GetSpreadFactor(cacheCtx).Quo(sumOfSpreadFactors)) - takerFee := pool.GetTakerFee() + takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenOutDenom, nextTokenIn.Denom) + s.Require().NoError(err) nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) @@ -1462,7 +1465,8 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced // utilize the routeSpreadFactor, sumOfSpreadFactors, and current pool swap fee to calculate the new reduced swap fee spreadFactor := pool.GetSpreadFactor(cacheCtx) - takerFee := pool.GetTakerFee() + takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenOutDenom, nextTokenIn.Denom) + s.Require().NoError(err) nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) @@ -1867,7 +1871,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(97595718) + priceImpactThreshold = sdk.NewInt(97469586) ) tests := map[string]struct { @@ -2067,7 +2071,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { TokenOutAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(102530841) + priceImpactThreshold = sdk.NewInt(102666473) ) tests := map[string]struct { diff --git a/x/poolmanager/types/keys.go b/x/poolmanager/types/keys.go index 5f470da6af8..219ecc4f1dc 100644 --- a/x/poolmanager/types/keys.go +++ b/x/poolmanager/types/keys.go @@ -2,6 +2,7 @@ package types import ( "fmt" + "sort" "github.com/gogo/protobuf/proto" ) @@ -20,6 +21,8 @@ var ( // SwapModuleRouterPrefix defines prefix to store pool id to swap module mappings. SwapModuleRouterPrefix = []byte{0x02} + + DenomTradePairPrefix = []byte{0x03} ) // ModuleRouteToBytes serializes moduleRoute to bytes. @@ -27,6 +30,14 @@ func FormatModuleRouteKey(poolId uint64) []byte { return []byte(fmt.Sprintf("%s%d", SwapModuleRouterPrefix, poolId)) } +// FormatDenomTradePairKey serializes denom trade pair to bytes. +// Denom trade pair is automatically sorted lexicographically. +func FormatDenomTradePairKey(denom0, denom1 string) []byte { + denoms := []string{denom0, denom1} + sort.Strings(denoms) + return []byte(fmt.Sprintf("%s%s%s", DenomTradePairPrefix, denoms[0], denoms[1])) +} + // ParseModuleRouteFromBz parses the raw bytes into ModuleRoute. // Returns error if fails to parse or if the bytes are empty. func ParseModuleRouteFromBz(bz []byte) (ModuleRoute, error) { diff --git a/x/poolmanager/types/msg_create_pool.go b/x/poolmanager/types/msg_create_pool.go index 7faa7047183..ae8cedd9ded 100644 --- a/x/poolmanager/types/msg_create_pool.go +++ b/x/poolmanager/types/msg_create_pool.go @@ -17,5 +17,5 @@ type CreatePoolMsg interface { // Initial Liquidity for the pool that the sender is required to send to the pool account InitialLiquidity() sdk.Coins // CreatePool creates a pool implementing PoolI, using data from the message. - CreatePool(ctx sdk.Context, poolID uint64, takerFee sdk.Dec) (PoolI, error) + CreatePool(ctx sdk.Context, poolID uint64) (PoolI, error) } diff --git a/x/poolmanager/types/pool.go b/x/poolmanager/types/pool.go index a196f8ffdca..5ce2f1b5d4d 100644 --- a/x/poolmanager/types/pool.go +++ b/x/poolmanager/types/pool.go @@ -19,8 +19,6 @@ type PoolI interface { // (prior TWAPs, network downtime, other pool states, etc.) // hence Context is provided as an argument. GetSpreadFactor(ctx sdk.Context) sdk.Dec - GetTakerFee() sdk.Dec - SetTakerFee(newTakerFee sdk.Dec) // Returns whether the pool has swaps enabled at the moment IsActive(ctx sdk.Context) bool From 2177b1551a2552e8810fe2f9c8754668fd88dedc Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 22:48:03 -0500 Subject: [PATCH 24/83] fix e2e --- tests/e2e/e2e_test.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 37e34cf62db..78ebbadf296 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -627,7 +627,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { sdk.ZeroDec(), spreadRewardCharge_Swap2_Step2, spreadRewardGrowthGlobal_Swap1, - spreadRewardGrowthGlobal, // cannot use spreadRewardGrowthGlobal, it was already increased by second swap's step + spreadRewardGrowthGlobal, ) // Assert @@ -712,18 +712,21 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { amountInToGetToTickBelowInitialized := liquidityBeforeSwap.Add(positionsAddress1[0].Position.Liquidity).Mul(fractionBelowNextInitializedTick) amountInToGetToNextInitTick = liquidityBeforeSwap.Mul(fractionAtNextInitializedTick.SDKDec()) + // Collect spread rewards for address1 position1 to avoid overhead computations (swap2 already asserted spread rewards are aggregated correctly from multiple swaps) + chainABNode.CollectSpreadRewards(address1, fmt.Sprint(positionsAddress1[0].Position.PositionId)) + var ( // Swap parameters uionInDec_Swap3_NoSpreadReward = amountInToGetToNextInitTick.Add(amountInToGetToTickBelowInitialized) // amount of uion to move price from current to desired (not considering spreadFactor) uionInDec_Swap3 = uionInDec_Swap3_NoSpreadReward.Quo(sdk.OneDec().Sub(spreadFactorDec)).TruncateDec() // consider spreadFactor - uionIn_Swap3 = fmt.Sprintf("%suion", uionInDec_Swap3.String()) // Save variables from previous swaps spreadRewardGrowthGlobal_Swap2 = spreadRewardGrowthGlobal.Clone() - spreadRewardGrowthInsideAddress1Position1Last = spreadRewardGrowthGlobal_Swap1.Add(spreadRewardCharge_Swap2_Step1) + spreadRewardGrowthInsideAddress1Position1Last = spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap2_Step2).Clone() ) - // Collect spread rewards for address1 position1 to avoid overhead computations (swap2 already asserted spread rewards are aggregated correctly from multiple swaps) - chainABNode.CollectSpreadRewards(address1, fmt.Sprint(positionsAddress1[0].Position.PositionId)) + + uionInDec_Swap3_AddTakerFee := uionInDec_Swap3.Quo(sdk.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee + uionIn_Swap3 := fmt.Sprintf("%suion", uionInDec_Swap3_AddTakerFee.String()) // Perform a swap chainABNode.SwapExactAmountIn(uionIn_Swap3, outMinAmt, fmt.Sprintf("%d", poolID), denom1, initialization.ValidatorWalletName) From 3b5453eccec15e0c275c755fee4833a451c15a2b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 20 Aug 2023 23:16:29 -0500 Subject: [PATCH 25/83] re-enable disabled test --- tests/e2e/e2e_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 78ebbadf296..c8f4d21401e 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -105,14 +105,14 @@ func (s *IntegrationTestSuite) TestAllE2E() { // Upgrade Dependent Tests // TODO: Temp disable - // if s.skipUpgrade { - // s.T().Skip("Skipping StableSwapPostUpgrade test") - // } else { - // s.T().Run("StableSwapPostUpgrade", func(t *testing.T) { - // t.Parallel() - // s.StableSwapPostUpgrade() - // }) - // } + if s.skipUpgrade { + s.T().Skip("Skipping StableSwapPostUpgrade test") + } else { + s.T().Run("StableSwapPostUpgrade", func(t *testing.T) { + t.Parallel() + s.StableSwapPostUpgrade() + }) + } if s.skipUpgrade { s.T().Skip("Skipping GeometricTwapMigration test") @@ -955,7 +955,7 @@ func (s *IntegrationTestSuite) StableSwapPostUpgrade() { minAmountOut = "1" ) - coinAIn, coinBIn := fmt.Sprintf("20000%s", denomA), fmt.Sprintf("1%s", denomB) + coinAIn, coinBIn := fmt.Sprintf("20000%s", denomA), fmt.Sprintf("2%s", denomB) chainABNode.BankSend(initialization.WalletFeeTokens.String(), sender, config.StableswapWallet[index]) chainABNode.BankSend(coinAIn, sender, config.StableswapWallet[index]) From e4420d342b2352c85cf008add1bcc00d42db2a01 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 16:59:35 -0500 Subject: [PATCH 26/83] minor cleaning --- tests/e2e/e2e_test.go | 1 - x/gamm/simulation/sim_msgs.go | 23 +++++++++++-------- x/poolmanager/router.go | 43 ++++++++++++----------------------- x/poolmanager/router_test.go | 16 ++++++------- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index c8f4d21401e..793aa9b07d2 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -104,7 +104,6 @@ func (s *IntegrationTestSuite) TestAllE2E() { // Upgrade Dependent Tests - // TODO: Temp disable if s.skipUpgrade { s.T().Skip("Skipping StableSwapPostUpgrade test") } else { diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index fa1a2caac95..f2a8b634eca 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -145,6 +145,7 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont randomCoinSubset := sim.RandSubsetCoins(sdk.NewCoins(sdk.NewCoin(accCoinIn.Denom, accCoinIn.Amount))) // calculate the minimum number of tokens received from input of tokenIn + // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. // We therefore need to add the taker fee to the spread factor when calling the calc method. takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) @@ -152,10 +153,10 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont return nil, err } - amountInAfterTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) - tokenInAfterTakerFee := sdk.NewCoin(randomCoinSubset[0].Denom, amountInAfterTakerFee.TruncateInt()) + amountInAfterSubTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + tokenInAfterSubTakerFee := sdk.NewCoin(randomCoinSubset[0].Denom, amountInAfterSubTakerFee.TruncateInt()) - tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(tokenInAfterTakerFee), coinOut.Denom, pool.GetSpreadFactor(ctx)) + tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(tokenInAfterSubTakerFee), coinOut.Denom, pool.GetSpreadFactor(ctx)) if err != nil { return nil, err } @@ -193,23 +194,25 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con randomCoinInSubset := osmoutils.MinCoins(sdk.NewCoins(coinIn), sdk.NewCoins(accCoin)) // utilize CalcOutAmtGivenIn to calculate tokenOut and use tokenOut to calculate tokenInMax - // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. - // We therefore need to add the taker fee to the spread factor when calling the calc method. - takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) + tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, pool.GetSpreadFactor(ctx)) if err != nil { return nil, err } - totalFees := pool.GetSpreadFactor(ctx).Add(takerFee) - - tokenOut, err := pool.CalcOutAmtGivenIn(ctx, randomCoinInSubset, coinOut.Denom, totalFees) + tokenInMax, err := pool.CalcInAmtGivenOut(ctx, sdk.NewCoins(tokenOut), coinIn.Denom, pool.GetSpreadFactor(ctx)) if err != nil { return nil, err } - tokenInMax, err := pool.CalcInAmtGivenOut(ctx, sdk.NewCoins(tokenOut), coinIn.Denom, pool.GetSpreadFactor(ctx)) + + // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. + // We therefore need to add the taker fee to the spread factor when calling the calc method. + takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) if err != nil { return nil, err } + amountInAfterAddTakerFee := tokenInMax.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) + tokenInMax = sdk.NewCoin(tokenInMax.Denom, amountInAfterAddTakerFee.TruncateInt()) + return &types.MsgSwapExactAmountOut{ Sender: senderAcc.Address.String(), Routes: route, diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index c1a04c28e8b..34155f71365 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -95,17 +95,12 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenOutDenom, tokenIn.Denom) - if err != nil { - return sdk.Int{}, err - } - - tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) + tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, routeStep.TokenOutDenom, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err } - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -220,18 +215,13 @@ func (k Keeper) SwapExactAmountIn( spreadFactor := pool.GetSpreadFactor(ctx) - takerFee, err := k.GetTradingPairTakerFee(ctx, tokenOutDenom, tokenIn.Denom) - if err != nil { - return sdk.Int{}, err - } - - tokenInAfterTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, true) + tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, tokenOutDenom, poolManagerParams, sender, true) if err != nil { return sdk.Int{}, err } // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterTakerFee, tokenOutDenom, tokenOutMinAmount, spreadFactor) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, tokenOutDenom, tokenOutMinAmount, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -334,11 +324,9 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( return sdk.Int{}, err } - fmt.Println("ADAM Taker gee: ", takerFee.String()) + tokenInAfterSubTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, takerFee) - tokenInAfterTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, takerFee) - - tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterTakerFee, routeStep.TokenOutDenom, spreadFactor) + tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterSubTakerFee, routeStep.TokenOutDenom, spreadFactor) if err != nil { return sdk.Int{}, err } @@ -445,25 +433,19 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } spreadFactor := pool.GetSpreadFactor(ctx) - // If we determined the routeStep is an osmo multi-hop and both route are incentivized, // we modify the swap fee accordingly. if isMultiHopRouted { spreadFactor = routeSpreadFactor.Mul((spreadFactor.Quo(sumOfSpreadFactors))) } - takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenInDenom, _tokenOut.Denom) - if err != nil { - return sdk.Int{}, err - } - _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) if swapErr != nil { return sdk.Int{}, swapErr } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) - tokenInWithTakerFee, err := k.extractTakerFeeToFeePool(ctx, tokenIn, takerFee, poolManagerParams, sender, false) + tokenInAfterAddTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, _tokenOut.Denom, poolManagerParams, sender, false) if err != nil { return sdk.Int{}, err } @@ -472,7 +454,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // whole method and will not change after the first iteration, we still iterate through the rest of the pools to execute their respective // swaps. if i == 0 { - tokenInAmount = tokenInWithTakerFee.Amount + tokenInAmount = tokenInAfterAddTakerFee.Amount } } @@ -847,14 +829,19 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { return totalLiquidity, nil } -// extractTakerFeeToFeePool takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. +// extractTakerFeeAndDistribute takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeToFeePool(ctx sdk.Context, tokenIn sdk.Coin, takerFee sdk.Dec, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { +func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName baseDenom := appparams.BaseCoinUnit + takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom) + if err != nil { + return sdk.Coin{}, err + } + var tokenInAfterTakerFee sdk.Coin var takerFeeCoin sdk.Coin if exactIn { diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index f4e334cda57..b2b43712f0c 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1385,9 +1385,9 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo s.Require().NoError(err) tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) - tokenInCoinAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) + tokenInCoinAfterAddTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) - nextTokenOut = tokenInCoinAfterTakerFee + nextTokenOut = tokenInCoinAfterAddTakerFee } return nextTokenOut } else { @@ -1408,9 +1408,9 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo s.Require().NoError(err) tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) - tokenInCoinAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) + tokenInCoinAfterAddTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactOut(tokenInCoin, takerFee) - nextTokenOut = tokenInCoinAfterTakerFee + nextTokenOut = tokenInCoinAfterAddTakerFee } return nextTokenOut } @@ -1444,10 +1444,10 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenOutDenom, nextTokenIn.Denom) s.Require().NoError(err) - nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) + nextTokenInAfterSubTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1468,10 +1468,10 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced takerFee, err := s.App.PoolManagerKeeper.GetTradingPairTakerFee(cacheCtx, hop.TokenOutDenom, nextTokenIn.Denom) s.Require().NoError(err) - nextTokenInAfterTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) + nextTokenInAfterSubTakerFee, _ := s.App.PoolManagerKeeper.CalcTakerFeeExactIn(nextTokenIn, takerFee) // we then do individual swaps until we reach the end of the swap route - tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) From 0834a304461701d5a28859fb644a5b8acc455fdd Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 17:51:56 -0500 Subject: [PATCH 27/83] simplify params --- .../osmosis/poolmanager/v1beta1/genesis.proto | 85 ++- x/poolmanager/create_pool.go | 2 +- x/poolmanager/keeper_test.go | 54 +- x/poolmanager/router.go | 14 +- x/poolmanager/types/genesis.pb.go | 674 ++++++++++-------- x/poolmanager/types/params.go | 91 +-- x/protorev/keeper/keeper_test.go | 4 +- 7 files changed, 495 insertions(+), 429 deletions(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index a9481d74546..26865df5d4a 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -17,9 +17,47 @@ message Params { (gogoproto.moretags) = "yaml:\"pool_creation_fee\"", (gogoproto.nullable) = false ]; + // taker_fee_params is the container of taker fee parameters. + TakerFeeParams taker_fee_params = 2 + [ (gogoproto.moretags) = "yaml:\"taker_fee_params\"" ]; + // authorized_quote_denoms is a list of quote denoms that can be used as + // token1 when creating a concentrated pool. We limit the quote assets to a + // small set for the purposes of having convinient price increments stemming + // from tick to price conversion. These increments are in a human readable + // magnitude only for token1 as a quote. For limit orders in the future, this + // will be a desirable property in terms of UX as to allow users to set limit + // orders at prices in terms of token1 (quote asset) that are easy to reason + // about. + repeated string authorized_quote_denoms = 3 + [ (gogoproto.moretags) = "yaml:\"authorized_quote_denoms\"" ]; + // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that + // taker fees that are not whitelisted will be swapped to when being sent to + // the community pool. + string community_pool_denom_to_swap_non_whitelisted_assets_to = 4 + [ (gogoproto.moretags) = + "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; + // stablecoin_denoms is a list of denoms that are considered stablecoins. + // This is used to determine if a pool should use the stableswap taker + // fee. + repeated string stablecoin_denoms = 5 + [ (gogoproto.moretags) = "yaml:\"stablecoin_denoms\"" ]; +} + +// GenesisState defines the poolmanager module's genesis state. +message GenesisState { + // the next_pool_id + uint64 next_pool_id = 1; + // params is the container of poolmanager parameters. + Params params = 2 [ (gogoproto.nullable) = false ]; + // pool_routes is the container of the mappings from pool id to pool type. + repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ]; +} + +// TakerFeeParams consolidates the taker fee parameters for the poolmanager. +message TakerFeeParams { // default_taker_fee is the fee used when creating a new pool that doesn't // fall under a custom pool taker fee or stableswap taker fee category. - string default_taker_fee = 2 [ + string default_taker_fee = 1 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.customname) = "DefaultTakerFee", (gogoproto.nullable) = false @@ -27,7 +65,7 @@ message Params { // stableswap_taker_fee is the fee used when creating a new pool in which all // the underlying tokens are present in the stablecoin_denoms paramater entry // OR has a liquid_stake_denom_pairings entry. - string stableswap_taker_fee = 3 [ + string stableswap_taker_fee = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.customname) = "StableswapTakerFee", (gogoproto.nullable) = false @@ -38,7 +76,7 @@ message Params { // stakers. // - community_pool: the percent of the taker fee that gets sent to the // community pool. - TakerFeeDistributionPercentage osmo_taker_fee_distribution = 5 [ + TakerFeeDistributionPercentage osmo_taker_fee_distribution = 3 [ (gogoproto.customname) = "OsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; @@ -51,49 +89,10 @@ message Params { // that denom is sent directly to the community pool. Otherwise, it is // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and // then sent to the community pool as that denom. - TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 6 [ + TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 4 [ (gogoproto.customname) = "NonOsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; - // authorized_quote_denoms is a list of quote denoms that can be used as - // token1 when creating a concentrated pool. We limit the quote assets to a - // small set for the purposes of having convinient price increments stemming - // from tick to price conversion. These increments are in a human readable - // magnitude only for token1 as a quote. For limit orders in the future, this - // will be a desirable property in terms of UX as to allow users to set limit - // orders at prices in terms of token1 (quote asset) that are easy to reason - // about. - repeated string authorized_quote_denoms = 7 - [ (gogoproto.moretags) = "yaml:\"authorized_quote_denoms\"" ]; - // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that - // taker fees that are not whitelisted will be swapped to when being sent to - // the community pool. - string community_pool_denom_to_swap_non_whitelisted_assets_to = 8 - [ (gogoproto.moretags) = - "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; - // stablecoin_denoms is a list of denoms that are considered stablecoins. - // This is used to determine if a pool should use the stableswap taker - // fee. Note: LSTs are NOT apart of this catagory, even though they are - // eligible for stableswap taker fees. This is determined via the - // liquid_stake_denom_pairings field. - repeated string stablecoin_denoms = 9 - [ (gogoproto.moretags) = "yaml:\"stablecoin_denoms\"" ]; - // liquid_stake_denom_pairings is a list of pairings of a natural denom with - // its corresponding LST denoms. If a pool is created with a natural denom - // that is paired with an LST denom, then the pool will be considered a - // stableswap pool and will use the stableswap taker fee. - repeated LiquidStakedTokenToUnderlyingDenom liquid_stake_denom_pairings = 10 - [ (gogoproto.moretags) = "yaml:\"liquid_stake_denom_pairings\"" ]; -} - -// GenesisState defines the poolmanager module's genesis state. -message GenesisState { - // the next_pool_id - uint64 next_pool_id = 1; - // params is the container of poolmanager parameters. - Params params = 2 [ (gogoproto.nullable) = false ]; - // pool_routes is the container of the mappings from pool id to pool type. - repeated ModuleRoute pool_routes = 3 [ (gogoproto.nullable) = false ]; } // TakerFeeDistributionPercentage defines what percent of the taker fee category diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 69cd7d3529d..3b6d1dd31f9 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -297,7 +297,7 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( return sdk.Dec{}, err } if !found { - return k.GetParams(ctx).DefaultTakerFee, nil + return k.GetParams(ctx).TakerFeeParams.DefaultTakerFee, nil } return takerFee.Dec, nil diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index c02f6d715a3..4f263961b26 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -32,16 +32,6 @@ var ( testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" testStablecoinDenoms = []string{"uusdc", "uusdt", "udai"} - testLiquidStakeDenomPairings = []*types.LiquidStakedTokenToUnderlyingDenom{ - { - LiquidStakedTokenDenoms: []string{"ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC"}, - UnderlyingTokenDenom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM - }, - { - LiquidStakedTokenDenoms: []string{"ibc/D176154B0C63D1F9C6DCFB4F70349EBF2E2B5A87A05902F57A6AE92B863E9AEC", "ibc/42D24879D4569CE6477B7E88206ADBFE47C222C6CAD51A54083E4A72594269FC"}, - UnderlyingTokenDenom: "uosmo", - }, - } testPoolRoute = []types.ModuleRoute{ { @@ -92,15 +82,16 @@ func (s *KeeperTestSuite) createBalancerPoolsFromCoins(poolCoins []sdk.Coins) { func (s *KeeperTestSuite) TestInitGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ - PoolCreationFee: testPoolCreationFee, - DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, - OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + PoolCreationFee: testPoolCreationFee, + TakerFeeParams: &types.TakerFeeParams{ + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + }, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, StablecoinDenoms: testStablecoinDenoms, - LiquidStakeDenomPairings: testLiquidStakeDenomPairings, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -109,29 +100,29 @@ func (s *KeeperTestSuite) TestInitGenesis() { params := s.App.PoolManagerKeeper.GetParams(s.Ctx) s.Require().Equal(uint64(testExpectedPoolId), s.App.PoolManagerKeeper.GetNextPoolId(s.Ctx)) s.Require().Equal(testPoolCreationFee, params.PoolCreationFee) - s.Require().Equal(testDefaultTakerFee, params.DefaultTakerFee) - s.Require().Equal(testStableswapTakerFee, params.StableswapTakerFee) - s.Require().Equal(testOsmoTakerFeeDistribution, params.OsmoTakerFeeDistribution) - s.Require().Equal(testNonOsmoTakerFeeDistribution, params.NonOsmoTakerFeeDistribution) + s.Require().Equal(testDefaultTakerFee, params.TakerFeeParams.DefaultTakerFee) + s.Require().Equal(testStableswapTakerFee, params.TakerFeeParams.StableswapTakerFee) + s.Require().Equal(testOsmoTakerFeeDistribution, params.TakerFeeParams.OsmoTakerFeeDistribution) + s.Require().Equal(testNonOsmoTakerFeeDistribution, params.TakerFeeParams.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testStablecoinDenoms, params.StablecoinDenoms) - s.Require().Equal(testLiquidStakeDenomPairings, params.LiquidStakeDenomPairings) s.Require().Equal(testPoolRoute, s.App.PoolManagerKeeper.GetAllPoolRoutes(s.Ctx)) } func (s *KeeperTestSuite) TestExportGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ - PoolCreationFee: testPoolCreationFee, - DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, - OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + PoolCreationFee: testPoolCreationFee, + TakerFeeParams: &types.TakerFeeParams{ + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + }, AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, StablecoinDenoms: testStablecoinDenoms, - LiquidStakeDenomPairings: testLiquidStakeDenomPairings, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -140,13 +131,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { genesis := s.App.PoolManagerKeeper.ExportGenesis(s.Ctx) s.Require().Equal(uint64(testExpectedPoolId), genesis.NextPoolId) s.Require().Equal(testPoolCreationFee, genesis.Params.PoolCreationFee) - s.Require().Equal(testDefaultTakerFee, genesis.Params.DefaultTakerFee) - s.Require().Equal(testStableswapTakerFee, genesis.Params.StableswapTakerFee) - s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.OsmoTakerFeeDistribution) - s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.NonOsmoTakerFeeDistribution) + s.Require().Equal(testDefaultTakerFee, genesis.Params.TakerFeeParams.DefaultTakerFee) + s.Require().Equal(testStableswapTakerFee, genesis.Params.TakerFeeParams.StableswapTakerFee) + s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.OsmoTakerFeeDistribution) + s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.NonOsmoTakerFeeDistribution) s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testStablecoinDenoms, genesis.Params.StablecoinDenoms) - s.Require().Equal(testLiquidStakeDenomPairings, genesis.Params.LiquidStakeDenomPairings) s.Require().Equal(testPoolRoute, genesis.PoolRoutes) } diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 34155f71365..c06f3f886a0 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -858,9 +858,9 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, takerFeeAmtRemaining := takerFeeCoin.Amount if takerFeeCoin.Denom == baseDenom { // Community Pool: - if poolManagerParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { // Osmo community pool funds is a direct send - osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.OsmoTakerFeeDistribution.CommunityPool) + osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { @@ -869,7 +869,7 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(baseDenom)) } // Staking Rewards: - if poolManagerParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) // We could stream these rewards via the fee collector account, but this is decision to be made by governance. osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, takerFeeAmtRemaining)) @@ -882,11 +882,11 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, // If the denom is not the base denom: } else { // Community Pool: - if poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { denomIsWhitelisted := isDenomWhitelisted(takerFeeCoin.Denom, poolManagerParams.AuthorizedQuoteDenoms) // If the non osmo denom is a whitelisted quote asset, we send to the community pool if denomIsWhitelisted { - nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) if err != nil { @@ -896,7 +896,7 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, } else { // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. - nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { @@ -906,7 +906,7 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, } } // Staking Rewards: - if poolManagerParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Non Osmo staking rewards are sent to the non native fee pool module account nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index ab96003415e..c6dc93a5a11 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -31,30 +31,8 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Params holds parameters for the poolmanager module type Params struct { PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` - // default_taker_fee is the fee used when creating a new pool that doesn't - // fall under a custom pool taker fee or stableswap taker fee category. - DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` - // stableswap_taker_fee is the fee used when creating a new pool in which all - // the underlying tokens are present in the stablecoin_denoms paramater entry - // OR has a liquid_stake_denom_pairings entry. - StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` - // osmo_taker_fee_distribution defines the distribution of taker fees - // generated in OSMO. As of this writing, it has two catagories: - // - staking_rewards: the percent of the taker fee that gets distributed to - // stakers. - // - community_pool: the percent of the taker fee that gets sent to the - // community pool. - OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,5,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` - // non_osmo_taker_fee_distribution defines the distribution of taker fees - // generated in non-OSMO. As of this writing, it has two catagories: - // - staking_rewards: the percent of the taker fee that gets swapped to OSMO - // and then distirbuted to stakers. - // - community_pool: the percent of the taker fee that gets sent to the - // community pool. Note: If the non-OSMO asset is an authorized_quote_denom, - // that denom is sent directly to the community pool. Otherwise, it is - // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and - // then sent to the community pool as that denom. - NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,6,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` + // taker_fee_params is the container of taker fee parameters. + TakerFeeParams *TakerFeeParams `protobuf:"bytes,2,opt,name=taker_fee_params,json=takerFeeParams,proto3" json:"taker_fee_params,omitempty" yaml:"taker_fee_params"` // authorized_quote_denoms is a list of quote denoms that can be used as // token1 when creating a concentrated pool. We limit the quote assets to a // small set for the purposes of having convinient price increments stemming @@ -63,22 +41,15 @@ type Params struct { // will be a desirable property in terms of UX as to allow users to set limit // orders at prices in terms of token1 (quote asset) that are easy to reason // about. - AuthorizedQuoteDenoms []string `protobuf:"bytes,7,rep,name=authorized_quote_denoms,json=authorizedQuoteDenoms,proto3" json:"authorized_quote_denoms,omitempty" yaml:"authorized_quote_denoms"` + AuthorizedQuoteDenoms []string `protobuf:"bytes,3,rep,name=authorized_quote_denoms,json=authorizedQuoteDenoms,proto3" json:"authorized_quote_denoms,omitempty" yaml:"authorized_quote_denoms"` // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that // taker fees that are not whitelisted will be swapped to when being sent to // the community pool. - CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,8,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` + CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,4,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` // stablecoin_denoms is a list of denoms that are considered stablecoins. // This is used to determine if a pool should use the stableswap taker - // fee. Note: LSTs are NOT apart of this catagory, even though they are - // eligible for stableswap taker fees. This is determined via the - // liquid_stake_denom_pairings field. - StablecoinDenoms []string `protobuf:"bytes,9,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` - // liquid_stake_denom_pairings is a list of pairings of a natural denom with - // its corresponding LST denoms. If a pool is created with a natural denom - // that is paired with an LST denom, then the pool will be considered a - // stableswap pool and will use the stableswap taker fee. - LiquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom `protobuf:"bytes,10,rep,name=liquid_stake_denom_pairings,json=liquidStakeDenomPairings,proto3" json:"liquid_stake_denom_pairings,omitempty" yaml:"liquid_stake_denom_pairings"` + // fee. + StablecoinDenoms []string `protobuf:"bytes,5,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` } func (m *Params) Reset() { *m = Params{} } @@ -121,18 +92,11 @@ func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -func (m *Params) GetOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { - if m != nil { - return m.OsmoTakerFeeDistribution - } - return TakerFeeDistributionPercentage{} -} - -func (m *Params) GetNonOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { +func (m *Params) GetTakerFeeParams() *TakerFeeParams { if m != nil { - return m.NonOsmoTakerFeeDistribution + return m.TakerFeeParams } - return TakerFeeDistributionPercentage{} + return nil } func (m *Params) GetAuthorizedQuoteDenoms() []string { @@ -156,13 +120,6 @@ func (m *Params) GetStablecoinDenoms() []string { return nil } -func (m *Params) GetLiquidStakeDenomPairings() []*LiquidStakedTokenToUnderlyingDenom { - if m != nil { - return m.LiquidStakeDenomPairings - } - return nil -} - // GenesisState defines the poolmanager module's genesis state. type GenesisState struct { // the next_pool_id @@ -227,6 +184,81 @@ func (m *GenesisState) GetPoolRoutes() []ModuleRoute { return nil } +// TakerFeeParams consolidates the taker fee parameters for the poolmanager. +type TakerFeeParams struct { + // default_taker_fee is the fee used when creating a new pool that doesn't + // fall under a custom pool taker fee or stableswap taker fee category. + DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` + // stableswap_taker_fee is the fee used when creating a new pool in which all + // the underlying tokens are present in the stablecoin_denoms paramater entry + // OR has a liquid_stake_denom_pairings entry. + StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` + // osmo_taker_fee_distribution defines the distribution of taker fees + // generated in OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets distributed to + // stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. + OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,3,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` + // non_osmo_taker_fee_distribution defines the distribution of taker fees + // generated in non-OSMO. As of this writing, it has two catagories: + // - staking_rewards: the percent of the taker fee that gets swapped to OSMO + // and then distirbuted to stakers. + // - community_pool: the percent of the taker fee that gets sent to the + // community pool. Note: If the non-OSMO asset is an authorized_quote_denom, + // that denom is sent directly to the community pool. Otherwise, it is + // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and + // then sent to the community pool as that denom. + NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,4,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` +} + +func (m *TakerFeeParams) Reset() { *m = TakerFeeParams{} } +func (m *TakerFeeParams) String() string { return proto.CompactTextString(m) } +func (*TakerFeeParams) ProtoMessage() {} +func (*TakerFeeParams) Descriptor() ([]byte, []int) { + return fileDescriptor_aa099d9fbdf68b35, []int{2} +} +func (m *TakerFeeParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TakerFeeParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TakerFeeParams.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TakerFeeParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_TakerFeeParams.Merge(m, src) +} +func (m *TakerFeeParams) XXX_Size() int { + return m.Size() +} +func (m *TakerFeeParams) XXX_DiscardUnknown() { + xxx_messageInfo_TakerFeeParams.DiscardUnknown(m) +} + +var xxx_messageInfo_TakerFeeParams proto.InternalMessageInfo + +func (m *TakerFeeParams) GetOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { + if m != nil { + return m.OsmoTakerFeeDistribution + } + return TakerFeeDistributionPercentage{} +} + +func (m *TakerFeeParams) GetNonOsmoTakerFeeDistribution() TakerFeeDistributionPercentage { + if m != nil { + return m.NonOsmoTakerFeeDistribution + } + return TakerFeeDistributionPercentage{} +} + // TakerFeeDistributionPercentage defines what percent of the taker fee category // gets distributed to the available categories. type TakerFeeDistributionPercentage struct { @@ -238,7 +270,7 @@ func (m *TakerFeeDistributionPercentage) Reset() { *m = TakerFeeDistribu func (m *TakerFeeDistributionPercentage) String() string { return proto.CompactTextString(m) } func (*TakerFeeDistributionPercentage) ProtoMessage() {} func (*TakerFeeDistributionPercentage) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{2} + return fileDescriptor_aa099d9fbdf68b35, []int{3} } func (m *TakerFeeDistributionPercentage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -278,7 +310,7 @@ func (m *LiquidStakedTokenToUnderlyingDenom) Reset() { *m = LiquidStaked func (m *LiquidStakedTokenToUnderlyingDenom) String() string { return proto.CompactTextString(m) } func (*LiquidStakedTokenToUnderlyingDenom) ProtoMessage() {} func (*LiquidStakedTokenToUnderlyingDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{3} + return fileDescriptor_aa099d9fbdf68b35, []int{4} } func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -324,6 +356,7 @@ func (m *LiquidStakedTokenToUnderlyingDenom) GetUnderlyingTokenDenom() string { func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") + proto.RegisterType((*TakerFeeParams)(nil), "osmosis.poolmanager.v1beta1.TakerFeeParams") proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") proto.RegisterType((*LiquidStakedTokenToUnderlyingDenom)(nil), "osmosis.poolmanager.v1beta1.LiquidStakedTokenToUnderlyingDenom") } @@ -333,66 +366,65 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 934 bytes of a gzipped FileDescriptorProto - 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0x7b, 0xfe, 0xcb, 0x99, 0x8f, - 0xbd, 0x1a, 0x71, 0xb4, 0xa4, 0x3e, 0xef, 0x1f, 0xff, 0x15, 0x00, 0x00, 0xff, 0xff, 0x42, 0x15, - 0xdf, 0x9b, 0xe4, 0x08, 0x00, 0x00, + // 925 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, + 0x14, 0x8f, 0x93, 0x25, 0x52, 0x26, 0x25, 0x69, 0x46, 0x69, 0xb3, 0x4d, 0xc0, 0xde, 0xba, 0x02, + 0x2d, 0x42, 0xb5, 0x95, 0x20, 0x51, 0x09, 0xc4, 0x21, 0xdb, 0x55, 0x4b, 0xa5, 0xd2, 0xa6, 0xce, + 0xa2, 0x4a, 0xbd, 0x8c, 0xc6, 0xeb, 0x89, 0x63, 0xc5, 0x9e, 0xd9, 0x78, 0xc6, 0x49, 0x97, 0x2b, + 0x5f, 0x00, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xf8, 0x04, 0x5c, 0x38, 0xf4, 0xd8, 0x23, 0xe2, 0x60, + 0x60, 0x73, 0xe6, 0xb2, 0x9f, 0x00, 0xcd, 0x9f, 0xfd, 0x97, 0x64, 0x57, 0x09, 0x3d, 0x25, 0x7e, + 0xef, 0xf7, 0xe7, 0xcd, 0xbc, 0x37, 0x6f, 0xc1, 0x27, 0x8c, 0x67, 0x8c, 0x27, 0xdc, 0xef, 0x30, + 0x96, 0x66, 0x98, 0xe2, 0x98, 0xe4, 0xfe, 0xc9, 0x76, 0x48, 0x04, 0xde, 0xf6, 0x63, 0x42, 0x09, + 0x4f, 0xb8, 0xd7, 0xc9, 0x99, 0x60, 0x70, 0xcb, 0x40, 0xbd, 0x31, 0xa8, 0x67, 0xa0, 0x9b, 0xeb, + 0x31, 0x8b, 0x99, 0xc2, 0xf9, 0xf2, 0x3f, 0x4d, 0xd9,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0x90, 0x31, 0x59, 0xdc, 0x93, 0x08, 0xee, 0x82, 0xc5, + 0x89, 0xbe, 0xdf, 0x9b, 0xd9, 0x77, 0xd3, 0xef, 0x8a, 0x9c, 0xca, 0xc0, 0x10, 0xe1, 0x73, 0xb0, + 0xac, 0xf4, 0xd5, 0xe4, 0xeb, 0x26, 0x2e, 0xef, 0xd4, 0x67, 0xea, 0x7c, 0xa3, 0xde, 0x4a, 0x20, + 0x09, 0x46, 0x0c, 0x48, 0x98, 0x0a, 0x70, 0xf7, 0xb7, 0x0a, 0x58, 0x99, 0x9c, 0x30, 0x98, 0x81, + 0xb5, 0x88, 0x1c, 0xe0, 0x22, 0x15, 0x68, 0x38, 0x61, 0xea, 0x34, 0x4b, 0x8d, 0x5d, 0xc9, 0xff, + 0xb3, 0x74, 0x3e, 0xbe, 0xc2, 0x33, 0x68, 0x92, 0x76, 0xaf, 0x74, 0x56, 0x9b, 0x5a, 0x6a, 0xe0, + 0x11, 0xac, 0x46, 0x93, 0x01, 0x78, 0x02, 0xd6, 0xf5, 0xe5, 0xaa, 0x66, 0x8f, 0x1c, 0xe7, 0x95, + 0x63, 0xf3, 0xda, 0x8e, 0x70, 0x7f, 0xa8, 0x36, 0x34, 0x85, 0xfc, 0x42, 0x0c, 0xfe, 0x64, 0x01, + 0xb5, 0x0c, 0x47, 0x96, 0x28, 0x4a, 0xb8, 0xc8, 0x93, 0xb0, 0x90, 0x4f, 0xb6, 0xba, 0xa0, 0x7a, + 0xf4, 0xe5, 0x95, 0xde, 0x66, 0x73, 0x8c, 0xb8, 0x47, 0xf2, 0x36, 0xa1, 0x02, 0xc7, 0xa4, 0x51, + 0x93, 0xc5, 0xf7, 0x4a, 0xa7, 0xfa, 0x9c, 0x67, 0xec, 0x32, 0x6c, 0x50, 0x65, 0x53, 0x32, 0xf0, + 0x67, 0x0b, 0x38, 0x72, 0xf2, 0x67, 0x95, 0x58, 0x79, 0xf7, 0x12, 0xef, 0x99, 0x12, 0xb7, 0x9e, +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8c, 0xdd, 0xa6, 0x19, 0xc6, 0xfb, 0x29, 0x0e, 0xf9, 0xe0, 0xc3, 0x3f, + 0xd9, 0x7e, 0xe0, 0xbf, 0x9e, 0xf8, 0x29, 0x57, 0x57, 0x1c, 0x2e, 0xaa, 0x1f, 0xef, 0xcf, 0xfe, + 0x0b, 0x00, 0x00, 0xff, 0xff, 0x33, 0xb3, 0xa5, 0xa4, 0xc2, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -415,27 +447,13 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.LiquidStakeDenomPairings) > 0 { - for iNdEx := len(m.LiquidStakeDenomPairings) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.LiquidStakeDenomPairings[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - } - } if len(m.StablecoinDenoms) > 0 { for iNdEx := len(m.StablecoinDenoms) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.StablecoinDenoms[iNdEx]) copy(dAtA[i:], m.StablecoinDenoms[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.StablecoinDenoms[iNdEx]))) i-- - dAtA[i] = 0x4a + dAtA[i] = 0x2a } } if len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) > 0 { @@ -443,7 +461,7 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) i = encodeVarintGenesis(dAtA, i, uint64(len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo))) i-- - dAtA[i] = 0x42 + dAtA[i] = 0x22 } if len(m.AuthorizedQuoteDenoms) > 0 { for iNdEx := len(m.AuthorizedQuoteDenoms) - 1; iNdEx >= 0; iNdEx-- { @@ -451,49 +469,21 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AuthorizedQuoteDenoms[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.AuthorizedQuoteDenoms[iNdEx]))) i-- - dAtA[i] = 0x3a - } - } - { - size, err := m.NonOsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - { - size, err := m.OsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.StableswapTakerFee.Size() - i -= size - if _, err := m.StableswapTakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err + dAtA[i] = 0x1a } - i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i-- - dAtA[i] = 0x1a - { - size := m.DefaultTakerFee.Size() - i -= size - if _, err := m.DefaultTakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err + if m.TakerFeeParams != nil { + { + size, err := m.TakerFeeParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } - i = encodeVarintGenesis(dAtA, i, uint64(size)) + i-- + dAtA[i] = 0x12 } - i-- - dAtA[i] = 0x12 if len(m.PoolCreationFee) > 0 { for iNdEx := len(m.PoolCreationFee) - 1; iNdEx >= 0; iNdEx-- { { @@ -563,6 +553,69 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TakerFeeParams) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TakerFeeParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.NonOsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + { + size, err := m.OsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size := m.StableswapTakerFee.Size() + i -= size + if _, err := m.StableswapTakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size := m.DefaultTakerFee.Size() + i -= size + if _, err := m.DefaultTakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *TakerFeeDistributionPercentage) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -668,14 +721,10 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = m.DefaultTakerFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.StableswapTakerFee.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.OsmoTakerFeeDistribution.Size() - n += 1 + l + sovGenesis(uint64(l)) - l = m.NonOsmoTakerFeeDistribution.Size() - n += 1 + l + sovGenesis(uint64(l)) + if m.TakerFeeParams != nil { + l = m.TakerFeeParams.Size() + n += 1 + l + sovGenesis(uint64(l)) + } if len(m.AuthorizedQuoteDenoms) > 0 { for _, s := range m.AuthorizedQuoteDenoms { l = len(s) @@ -692,12 +741,6 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if len(m.LiquidStakeDenomPairings) > 0 { - for _, e := range m.LiquidStakeDenomPairings { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -721,6 +764,23 @@ func (m *GenesisState) Size() (n int) { return n } +func (m *TakerFeeParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.DefaultTakerFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.StableswapTakerFee.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.OsmoTakerFeeDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + l = m.NonOsmoTakerFeeDistribution.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + func (m *TakerFeeDistributionPercentage) Size() (n int) { if m == nil { return 0 @@ -824,9 +884,9 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DefaultTakerFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TakerFeeParams", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -836,29 +896,31 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.DefaultTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if m.TakerFeeParams == nil { + m.TakerFeeParams = &TakerFeeParams{} + } + if err := m.TakerFeeParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableswapTakerFee", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedQuoteDenoms", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -886,15 +948,13 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StableswapTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.AuthorizedQuoteDenoms = append(m.AuthorizedQuoteDenoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 5: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OsmoTakerFeeDistribution", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -904,30 +964,29 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.OsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field NonOsmoTakerFeeDistribution", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StablecoinDenoms", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -937,62 +996,79 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.NonOsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.StablecoinDenoms = append(m.StablecoinDenoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedQuoteDenoms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF } - if postIndex > l { + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { return io.ErrUnexpectedEOF } - m.AuthorizedQuoteDenoms = append(m.AuthorizedQuoteDenoms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break } - var stringLen uint64 + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NextPoolId", wireType) + } + m.NextPoolId = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1002,29 +1078,16 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.NextPoolId |= uint64(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 9: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StablecoinDenoms", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1034,27 +1097,28 @@ func (m *Params) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - m.StablecoinDenoms = append(m.StablecoinDenoms, string(dAtA[iNdEx:postIndex])) + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } iNdEx = postIndex - case 10: + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidStakeDenomPairings", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PoolRoutes", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1081,8 +1145,8 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.LiquidStakeDenomPairings = append(m.LiquidStakeDenomPairings, &LiquidStakedTokenToUnderlyingDenom{}) - if err := m.LiquidStakeDenomPairings[len(m.LiquidStakeDenomPairings)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.PoolRoutes = append(m.PoolRoutes, ModuleRoute{}) + if err := m.PoolRoutes[len(m.PoolRoutes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1107,7 +1171,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func (m *GenesisState) Unmarshal(dAtA []byte) error { +func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1130,17 +1194,17 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GenesisState: wiretype end group for non-group") + return fmt.Errorf("proto: TakerFeeParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TakerFeeParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextPoolId", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DefaultTakerFee", wireType) } - m.NextPoolId = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -1150,14 +1214,63 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.NextPoolId |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.DefaultTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field StableswapTakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.StableswapTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field OsmoTakerFeeDistribution", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1184,13 +1297,13 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.OsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PoolRoutes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field NonOsmoTakerFeeDistribution", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1217,8 +1330,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.PoolRoutes = append(m.PoolRoutes, ModuleRoute{}) - if err := m.PoolRoutes[len(m.PoolRoutes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.NonOsmoTakerFeeDistribution.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 975611fea34..007f1ac1230 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -35,32 +35,36 @@ func NewParams(poolCreationFee sdk.Coins, stablecoinDenoms []string, liquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom) Params { return Params{ - PoolCreationFee: poolCreationFee, - DefaultTakerFee: defaultTakerFee, - StableswapTakerFee: stableswapTakerFee, - OsmoTakerFeeDistribution: osmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, + PoolCreationFee: poolCreationFee, + TakerFeeParams: &TakerFeeParams{ + DefaultTakerFee: defaultTakerFee, + StableswapTakerFee: stableswapTakerFee, + OsmoTakerFeeDistribution: osmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, + }, AuthorizedQuoteDenoms: authorizedQuoteDenoms, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: communityPoolDenomToSwapNonWhitelistedAssetsTo, StablecoinDenoms: stablecoinDenoms, - LiquidStakeDenomPairings: liquidStakeDenomPairings, } } // DefaultParams are the default poolmanager module parameters. func DefaultParams() Params { return Params{ - PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO - DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% - StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% - OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("1"), // 100% - CommunityPool: sdk.MustNewDecFromStr("0"), // 0% - }, - NonOsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("0.67"), // 67% - CommunityPool: sdk.MustNewDecFromStr("0.33"), // 33% + PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO + TakerFeeParams: &TakerFeeParams{ + DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% + StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% + OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("1"), // 100% + CommunityPool: sdk.MustNewDecFromStr("0"), // 0% + }, + NonOsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ + StakingRewards: sdk.MustNewDecFromStr("0.67"), // 67% + CommunityPool: sdk.MustNewDecFromStr("0.33"), // 33% + }, }, + AuthorizedQuoteDenoms: []string{ "uosmo", "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM @@ -72,16 +76,6 @@ func DefaultParams() Params { "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", // DAI "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC }, - LiquidStakeDenomPairings: []*LiquidStakedTokenToUnderlyingDenom{ - { - LiquidStakedTokenDenoms: []string{"ibc/C140AFD542AE77BD7DCC83F13FDD8C5E5BB8C4929785E6EC2F4C636F98F17901", "ibc/FA602364BEC305A696CBDF987058E99D8B479F0318E47314C49173E8838C5BAC"}, - UnderlyingTokenDenom: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM - }, - { - LiquidStakedTokenDenoms: []string{"ibc/D176154B0C63D1F9C6DCFB4F70349EBF2E2B5A87A05902F57A6AE92B863E9AEC", "ibc/42D24879D4569CE6477B7E88206ADBFE47C222C6CAD51A54083E4A72594269FC"}, - UnderlyingTokenDenom: "uosmo", - }, - }, } } @@ -90,16 +84,16 @@ func (p Params) Validate() error { if err := validatePoolCreationFee(p.PoolCreationFee); err != nil { return err } - if err := validateDefaultTakerFee(p.DefaultTakerFee); err != nil { + if err := validateDefaultTakerFee(p.TakerFeeParams.DefaultTakerFee); err != nil { return err } - if err := validateStableswapTakerFee(p.StableswapTakerFee); err != nil { + if err := validateStableswapTakerFee(p.TakerFeeParams.StableswapTakerFee); err != nil { return err } - if err := validateTakerFeeDistribution(p.OsmoTakerFeeDistribution); err != nil { + if err := validateTakerFeeDistribution(p.TakerFeeParams.OsmoTakerFeeDistribution); err != nil { return err } - if err := validateTakerFeeDistribution(p.NonOsmoTakerFeeDistribution); err != nil { + if err := validateTakerFeeDistribution(p.TakerFeeParams.NonOsmoTakerFeeDistribution); err != nil { return err } if err := validateAuthorizedQuoteDenoms(p.AuthorizedQuoteDenoms); err != nil { @@ -111,9 +105,6 @@ func (p Params) Validate() error { if err := validateStablecoinDenoms(p.StablecoinDenoms); err != nil { return err } - if err := validateLiquidStakeDenomPairings(p.LiquidStakeDenomPairings); err != nil { - return err - } return nil } @@ -122,14 +113,13 @@ func (p Params) Validate() error { func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), - paramtypes.NewParamSetPair(KeyDefaultTakerFee, &p.DefaultTakerFee, validateDefaultTakerFee), - paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.StableswapTakerFee, validateStableswapTakerFee), - paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.OsmoTakerFeeDistribution, validateTakerFeeDistribution), - paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), + paramtypes.NewParamSetPair(KeyDefaultTakerFee, &p.TakerFeeParams.DefaultTakerFee, validateDefaultTakerFee), + paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.TakerFeeParams.StableswapTakerFee, validateStableswapTakerFee), + paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.TakerFeeParams.OsmoTakerFeeDistribution, validateTakerFeeDistribution), + paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.TakerFeeParams.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyAuthorizedQuoteDenoms, &p.AuthorizedQuoteDenoms, validateAuthorizedQuoteDenoms), paramtypes.NewParamSetPair(KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo, &p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo, validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo), paramtypes.NewParamSetPair(KeyStablecoinDenoms, &p.StablecoinDenoms, validateStablecoinDenoms), - paramtypes.NewParamSetPair(KeyLiquidStakeDenomPairings, &p.LiquidStakeDenomPairings, validateLiquidStakeDenomPairings), } } @@ -258,28 +248,3 @@ func validateStablecoinDenoms(i interface{}) error { return nil } - -func validateLiquidStakeDenomPairings(i interface{}) error { - liquidStakeDenomPairings, ok := i.([]*LiquidStakedTokenToUnderlyingDenom) - - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if len(liquidStakeDenomPairings) == 0 { - return fmt.Errorf("liquid stake denom pairings cannot be empty") - } - - for _, pairing := range liquidStakeDenomPairings { - for _, lst := range pairing.LiquidStakedTokenDenoms { - if err := sdk.ValidateDenom(lst); err != nil { - return err - } - } - if err := sdk.ValidateDenom(pairing.UnderlyingTokenDenom); err != nil { - return err - } - } - - return nil -} diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go index 41ab435dcb1..0f0ae9b6702 100644 --- a/x/protorev/keeper/keeper_test.go +++ b/x/protorev/keeper/keeper_test.go @@ -58,8 +58,8 @@ func (s *KeeperTestSuite) SetupTest() { s.Setup() poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) - poolManagerParams.DefaultTakerFee = sdk.ZeroDec() - poolManagerParams.StableswapTakerFee = sdk.ZeroDec() + poolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() + poolManagerParams.TakerFeeParams.StableswapTakerFee = sdk.ZeroDec() s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) // Genesis on init should be the same as the default genesis From 9a7b1c2db5396ff4d8288ae7cc13bd4238a32ac2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 18:22:21 -0500 Subject: [PATCH 28/83] not nullable --- .../osmosis/poolmanager/v1beta1/genesis.proto | 6 +- x/poolmanager/keeper_test.go | 4 +- x/poolmanager/types/genesis.pb.go | 141 +++++++++--------- x/poolmanager/types/params.go | 8 +- 4 files changed, 76 insertions(+), 83 deletions(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 26865df5d4a..1098b09b68e 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -18,8 +18,10 @@ message Params { (gogoproto.nullable) = false ]; // taker_fee_params is the container of taker fee parameters. - TakerFeeParams taker_fee_params = 2 - [ (gogoproto.moretags) = "yaml:\"taker_fee_params\"" ]; + TakerFeeParams taker_fee_params = 2 [ + (gogoproto.moretags) = "yaml:\"taker_fee_params\"", + (gogoproto.nullable) = false + ]; // authorized_quote_denoms is a list of quote denoms that can be used as // token1 when creating a concentrated pool. We limit the quote assets to a // small set for the purposes of having convinient price increments stemming diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 4f263961b26..d1d5924c6a4 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -83,7 +83,7 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ PoolCreationFee: testPoolCreationFee, - TakerFeeParams: &types.TakerFeeParams{ + TakerFeeParams: types.TakerFeeParams{ DefaultTakerFee: testDefaultTakerFee, StableswapTakerFee: testStableswapTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, @@ -114,7 +114,7 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.App.PoolManagerKeeper.InitGenesis(s.Ctx, &types.GenesisState{ Params: types.Params{ PoolCreationFee: testPoolCreationFee, - TakerFeeParams: &types.TakerFeeParams{ + TakerFeeParams: types.TakerFeeParams{ DefaultTakerFee: testDefaultTakerFee, StableswapTakerFee: testStableswapTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index c6dc93a5a11..6d67e21f34b 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -32,7 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { PoolCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=pool_creation_fee,json=poolCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"pool_creation_fee" yaml:"pool_creation_fee"` // taker_fee_params is the container of taker fee parameters. - TakerFeeParams *TakerFeeParams `protobuf:"bytes,2,opt,name=taker_fee_params,json=takerFeeParams,proto3" json:"taker_fee_params,omitempty" yaml:"taker_fee_params"` + TakerFeeParams TakerFeeParams `protobuf:"bytes,2,opt,name=taker_fee_params,json=takerFeeParams,proto3" json:"taker_fee_params" yaml:"taker_fee_params"` // authorized_quote_denoms is a list of quote denoms that can be used as // token1 when creating a concentrated pool. We limit the quote assets to a // small set for the purposes of having convinient price increments stemming @@ -92,11 +92,11 @@ func (m *Params) GetPoolCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { return nil } -func (m *Params) GetTakerFeeParams() *TakerFeeParams { +func (m *Params) GetTakerFeeParams() TakerFeeParams { if m != nil { return m.TakerFeeParams } - return nil + return TakerFeeParams{} } func (m *Params) GetAuthorizedQuoteDenoms() []string { @@ -366,65 +366,65 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 925 bytes of a gzipped FileDescriptorProto + // 924 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, 0x14, 0x8f, 0x93, 0x25, 0x52, 0x26, 0x25, 0x69, 0x46, 0x69, 0xb3, 0x4d, 0xc0, 0xde, 0xba, 0x02, 0x2d, 0x42, 0xb5, 0x95, 0x20, 0x51, 0x09, 0xc4, 0x21, 0xdb, 0x55, 0x4b, 0xa5, 0xd2, 0xa6, 0xce, 0xa2, 0x4a, 0xbd, 0x8c, 0xc6, 0xeb, 0x89, 0x63, 0xc5, 0x9e, 0xd9, 0x78, 0xc6, 0x49, 0x97, 0x2b, 0x5f, 0x00, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xf8, 0x04, 0x5c, 0x38, 0xf4, 0xd8, 0x23, 0xe2, 0x60, - 0x60, 0x73, 0xe6, 0xb2, 0x9f, 0x00, 0xcd, 0x9f, 0xfd, 0x97, 0x64, 0x57, 0x09, 0x3d, 0x25, 0x7e, - 0xef, 0xf7, 0xe7, 0xcd, 0xbc, 0x37, 0x6f, 0xc1, 0x27, 0x8c, 0x67, 0x8c, 0x27, 0xdc, 0xef, 0x30, - 0x96, 0x66, 0x98, 0xe2, 0x98, 0xe4, 0xfe, 0xc9, 0x76, 0x48, 0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47, 0x31, 0x7d, 0x7c, 0xf7, 0x77, 0x0b, 0xdc, - 0x78, 0xac, 0x9f, 0xd6, 0xbe, 0xc0, 0x82, 0xc0, 0x1a, 0xb8, 0x41, 0xc9, 0x6b, 0xa1, 0x4f, 0x90, - 0x44, 0x55, 0xab, 0x66, 0xd5, 0x2b, 0x01, 0x90, 0x31, 0x59, 0xdc, 0x93, 0x08, 0xee, 0x82, 0xc5, - 0x89, 0xbe, 0xdf, 0x9b, 0xd9, 0x77, 0xd3, 0xef, 0x8a, 0x9c, 0xca, 0xc0, 0x10, 0xe1, 0x73, 0xb0, - 0xac, 0xf4, 0xd5, 0xe4, 0xeb, 0x26, 0x2e, 0xef, 0xd4, 0x67, 0xea, 0x7c, 0xa3, 0xde, 0x4a, 0x20, - 0x09, 0x46, 0x0c, 0x48, 0x98, 0x0a, 0x70, 0xf7, 0xb7, 0x0a, 0x58, 0x99, 0x9c, 0x30, 0x98, 0x81, - 0xb5, 0x88, 0x1c, 0xe0, 0x22, 0x15, 0x68, 0x38, 0x61, 0xea, 0x34, 0x4b, 0x8d, 0x5d, 0xc9, 0xff, - 0xb3, 0x74, 0x3e, 0xbe, 0xc2, 0x33, 0x68, 0x92, 0x76, 0xaf, 0x74, 0x56, 0x9b, 0x5a, 0x6a, 0xe0, - 0x11, 0xac, 0x46, 0x93, 0x01, 0x78, 0x02, 0xd6, 0xf5, 0xe5, 0xaa, 0x66, 0x8f, 0x1c, 0xe7, 0x95, - 0x63, 0xf3, 0xda, 0x8e, 0x70, 0x7f, 0xa8, 0x36, 0x34, 0x85, 0xfc, 0x42, 0x0c, 0xfe, 0x64, 0x01, - 0xb5, 0x0c, 0x47, 0x96, 0x28, 0x4a, 0xb8, 0xc8, 0x93, 0xb0, 0x90, 0x4f, 0xb6, 0xba, 0xa0, 0x7a, - 0xf4, 0xe5, 0x95, 0xde, 0x66, 0x73, 0x8c, 0xb8, 0x47, 0xf2, 0x36, 0xa1, 0x02, 0xc7, 0xa4, 0x51, - 0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0xff, 0xff, 0x8d, 0x7a, 0x5a, 0x76, 0xc6, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -472,18 +472,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x1a } } - if m.TakerFeeParams != nil { - { - size, err := m.TakerFeeParams.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) + { + size, err := m.TakerFeeParams.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } - i-- - dAtA[i] = 0x12 + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 if len(m.PoolCreationFee) > 0 { for iNdEx := len(m.PoolCreationFee) - 1; iNdEx >= 0; iNdEx-- { { @@ -721,10 +719,8 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - if m.TakerFeeParams != nil { - l = m.TakerFeeParams.Size() - n += 1 + l + sovGenesis(uint64(l)) - } + l = m.TakerFeeParams.Size() + n += 1 + l + sovGenesis(uint64(l)) if len(m.AuthorizedQuoteDenoms) > 0 { for _, s := range m.AuthorizedQuoteDenoms { l = len(s) @@ -911,9 +907,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.TakerFeeParams == nil { - m.TakerFeeParams = &TakerFeeParams{} - } if err := m.TakerFeeParams.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 007f1ac1230..073140ed4e7 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -19,7 +19,6 @@ var ( KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo = []byte("CommunityPoolDenomToSwapNonWhitelistedAssetsTo") KeyStablecoinDenoms = []byte("StablecoinDenoms") - KeyLiquidStakeDenomPairings = []byte("LiquidStakeDenomPairings") ) // ParamTable for gamm module. @@ -32,11 +31,10 @@ func NewParams(poolCreationFee sdk.Coins, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string, - stablecoinDenoms []string, - liquidStakeDenomPairings []*LiquidStakedTokenToUnderlyingDenom) Params { + stablecoinDenoms []string) Params { return Params{ PoolCreationFee: poolCreationFee, - TakerFeeParams: &TakerFeeParams{ + TakerFeeParams: TakerFeeParams{ DefaultTakerFee: defaultTakerFee, StableswapTakerFee: stableswapTakerFee, OsmoTakerFeeDistribution: osmoTakerFeeDistribution, @@ -52,7 +50,7 @@ func NewParams(poolCreationFee sdk.Coins, func DefaultParams() Params { return Params{ PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO - TakerFeeParams: &TakerFeeParams{ + TakerFeeParams: TakerFeeParams{ DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ From 279ae06fe8a54d0b0ebb04dbbc93a476fb08f5a2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 18:33:34 -0500 Subject: [PATCH 29/83] clean up --- tests/e2e/e2e_test.go | 40 ++------------ tests/e2e/helpers_e2e_test.go | 14 +---- x/concentrated-liquidity/incentives.go | 6 --- x/concentrated-liquidity/spread_rewards.go | 11 ---- x/concentrated-liquidity/swaps.go | 6 --- x/poolmanager/create_pool.go | 62 ---------------------- x/txfees/keeper/keeper_test.go | 2 +- 7 files changed, 5 insertions(+), 136 deletions(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 793aa9b07d2..49001efcbec 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -433,11 +433,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor := uosmoInDec_Swap1_SubTakerFee.Mul(sdk.OneDec().Sub(spreadFactorDec)) totalSpreadReward := uosmoInDec_Swap1_SubTakerFee.Sub(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).TruncateDec() - // fmt.Println("uosmoInDec_Swap1_AfterTakerFee", uosmoInDec_Swap1_SubTakerFee) - // fmt.Println("totalSpreadReward", totalSpreadReward) spreadRewardGrowthGlobal.AddMut(calculateSpreadRewardGrowthGlobal(totalSpreadReward, concentratedPool.GetLiquidity())) - // fmt.Println("concentratedPool.GetLiquidity()", concentratedPool.GetLiquidity()) - // fmt.Println("spreadRewardGrowthGlobal", spreadRewardGrowthGlobal) // Update pool and track liquidity and sqrt price liquidityBeforeSwap := concentratedPool.GetLiquidity() @@ -454,10 +450,6 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Assert current sqrt price expectedSqrtPriceDelta := osmomath.BigDecFromSDKDec(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).QuoTruncate(osmomath.BigDecFromSDKDec(concentratedPool.GetLiquidity())) // Δ(sqrtPrice) = Δy / L expectedSqrtPrice := sqrtPriceBeforeSwap.Add(expectedSqrtPriceDelta) - - // fmt.Println("sqrtPriceAfterSwap", sqrtPriceAfterSwap.String()) - // fmt.Println("expectedSqrtPrice", expectedSqrtPrice.String()) - // fmt.Println("positionsAddress1[0].Position.Liquidity", positionsAddress1[0].Position.Liquidity) s.Require().Equal(expectedSqrtPrice.String(), sqrtPriceAfterSwap.String()) // Collect SpreadRewards: Swap 1 @@ -481,23 +473,18 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { spreadRewardGrowthGlobal, ) + // Note the global spread reward growth before dust redistribution spreadRewardGrowthGlobalBeforeDustRedistribution := spreadRewardGrowthGlobal.Clone() - // fmt.Println("PRE HERE", spreadRewardGrowthGlobalPre) // Determine forfeited dust amount forfeitedDustAmt := spreadRewardsUncollectedAddress1Position1_Swap1.Sub(spreadRewardsUncollectedAddress1Position1_Swap1.TruncateDec()) - // fmt.Println("ADAM forfeitedDustAmt", forfeitedDustAmt) forfeitedDust := sdk.NewDecCoins(sdk.NewDecCoinFromDec("uosmo", forfeitedDustAmt)) - forfeitedDustPerShare := forfeitedDust.QuoDecTruncate(totalLiquidity) - // fmt.Println("ADAM forfeitedDustPerShare", forfeitedDustPerShare) + + // Add forfeited dust back to the global spread reward growth spreadRewardGrowthGlobal.AddMut(forfeitedDustPerShare.AmountOf("uosmo")) - // fmt.Println("ADAM spreadRewardGrowthGlobal after dust", spreadRewardGrowthGlobal) // Assert - // fmt.Println("spreadRewardsUncollectedAddress1Position1_Swap1", spreadRewardsUncollectedAddress1Position1_Swap1.String()) - // fmt.Println("addr1BalancesBefore.AmountOf(\"uosmo\")", addr1BalancesBefore.AmountOf("uosmo").String()) - // fmt.Println("addr1BalancesAfter.AmountOf(\"uosmo\")", addr1BalancesAfter.AmountOf("uosmo").String()) s.Require().Equal( addr1BalancesBefore.AmountOf("uosmo").Add(spreadRewardsUncollectedAddress1Position1_Swap1.TruncateInt()).String(), addr1BalancesAfter.AmountOf("uosmo").String(), @@ -552,14 +539,9 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { spreadRewardGrowthGlobal_Swap1 = spreadRewardGrowthGlobalBeforeDustRedistribution.Clone() ) - // fmt.Println("uosmoInDec_Swap2_NoSpreadReward", uosmoInDec_Swap2_NoSpreadReward) - // fmt.Println("uosmoInDec_Swap2", uosmoInDec_Swap2) - uosmoInDec_Swap2_AddTakerFee := uosmoInDec_Swap2.Quo(sdk.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee uosmoIn_Swap2 := fmt.Sprintf("%suosmo", uosmoInDec_Swap2_AddTakerFee.String()) - // fmt.Println("tokenIn for swap2", uosmoInDec_Swap2_AddTakerFee) - // Perform a swap chainABNode.SwapExactAmountIn(uosmoIn_Swap2, outMinAmt, fmt.Sprintf("%d", poolID), denom0, initialization.ValidatorWalletName) @@ -582,32 +564,19 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // hasReachedTarget in SwapStep is true, hence, to find spread rewards, calculate: // spreadRewardCharge = amountIn * spreadFactor / (1 - spreadFactor) spreadRewardCharge_Swap2_Step1 := amountInToGetToNextInitTick.Mul(spreadFactorDec).Quo(sdk.OneDec().Sub(spreadFactorDec)) - // fmt.Println("spreadRewardCharge_Swap2_Step1", spreadRewardCharge_Swap2_Step1.String()) - // fmt.Println("amountInToGetToNextInitTick", amountInToGetToNextInitTick) // Step2: hasReachedTarget in SwapStep is false (nextTick is 120000), hence, to find spread rewards, calculate: // spreadRewardCharge = amountRemaining - amountOne amountRemainingAfterStep1 := uosmoInDec_Swap2.Sub(amountInToGetToNextInitTick).Sub(spreadRewardCharge_Swap2_Step1) - // fmt.Println("amountRemainingAfterStep1", amountRemainingAfterStep1.String()) spreadRewardCharge_Swap2_Step2 := amountRemainingAfterStep1.Sub(amountInToGetToTickAfterInitialized) - // fmt.Println("spreadRewardCharge_Swap2_Step2", spreadRewardCharge_Swap2_Step2.String()) - - // // HARDCODING - // spreadRewardCharge_Swap2_Step1 = sdk.MustNewDecFromStr("10540.484484484484484485") - // spreadRewardCharge_Swap2_Step2 = sdk.MustNewDecFromStr("27.515515515515515515") // per unit of virtual liquidity spreadRewardCharge_Swap2_Step1.QuoMut(liquidityBeforeSwap) spreadRewardCharge_Swap2_Step2.QuoMut(liquidityAfterSwap) - // fmt.Println("amountRemainingAfterStep1 per unit of liq", spreadRewardCharge_Swap2_Step1.String()) - // fmt.Println("spreadRewardCharge_Swap2_Step2 per unit of liq", spreadRewardCharge_Swap2_Step2.String()) - // Update spreadRewardGrowthGlobal spreadRewardGrowthGlobal.AddMut(spreadRewardCharge_Swap2_Step1.Add(spreadRewardCharge_Swap2_Step2)) - // fmt.Println("spreadRewardGrowthGlobal", spreadRewardGrowthGlobal.String()) - // Assert Balances: Swap 2 // Assert that address1 position1 earned spread rewards only from first swap step @@ -630,9 +599,6 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { ) // Assert - // fmt.Println("spreadRewardsUncollectedAddress1Position1_Swap2", spreadRewardsUncollectedAddress1Position1_Swap2) - // fmt.Println("addr1BalancesBefore.AmountOf(\"uosmo\")", addr1BalancesBefore.AmountOf("uosmo")) - // fmt.Println("addr1BalancesAfter.AmountOf(\"uosmo\")", addr1BalancesAfter.AmountOf("uosmo")) s.Require().Equal( addr1BalancesBefore.AmountOf("uosmo").Add(spreadRewardsUncollectedAddress1Position1_Swap2.TruncateInt()), addr1BalancesAfter.AmountOf("uosmo"), diff --git a/tests/e2e/helpers_e2e_test.go b/tests/e2e/helpers_e2e_test.go index 5769cdf2870..9f378eda52c 100644 --- a/tests/e2e/helpers_e2e_test.go +++ b/tests/e2e/helpers_e2e_test.go @@ -23,13 +23,10 @@ var defaultFeePerTx = sdk.NewInt(1000) // spreadFactor - pool's spread factor // poolLiquidity - current pool liquidity func calculateSpreadRewardGrowthGlobal(spreadRewardChargeTotal, poolLiquidity sdk.Dec) sdk.Dec { - // // First we get total spread reward charge for the swap (ΔY * spreadFactor) - // spreadRewardChargeTotal := amountIn.Mul(spreadFactor) + // First we get total spread reward charge for the swap (ΔY * spreadFactor) // Calculating spread reward growth global (dividing by pool liquidity to find spread reward growth per unit of virtual liquidity) spreadRewardGrowthGlobal := spreadRewardChargeTotal.QuoTruncate(poolLiquidity) - // fmt.Println("AAA1 spreadRewardGrowthGlobal: ", spreadRewardGrowthGlobal) - // fmt.Println("AAA2 poolLiquidity: ", poolLiquidity) return spreadRewardGrowthGlobal } @@ -110,19 +107,10 @@ func calculateUncollectedSpreadRewards(positionLiquidity, spreadRewardGrowthBelo // Calculating spread reward growth inside range [-1200; 400] spreadRewardGrowthInside := calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal, spreadRewardGrowthBelow, spreadRewardGrowthAbove) - // fmt.Println("spreadRewardGrowthInside: ", spreadRewardGrowthInside) - // fmt.Println("spreadRewardGrowthGlobal: ", spreadRewardGrowthGlobal) - // fmt.Println("spreadRewardGrowthBelow: ", spreadRewardGrowthBelow) - // fmt.Println("spreadRewardGrowthAbove: ", spreadRewardGrowthAbove) - // Calculating uncollected spread rewards // Formula for finding uncollected spread rewards in time range [t1; t2]: // F_u = position_liquidity * (spread_rewards_growth_inside_t2 - spread_rewards_growth_inside_t1). spreadRewardsUncollected := positionLiquidity.Mul(spreadRewardGrowthInside.Sub(spreadRewardGrowthInsideLast)) - // fmt.Println("spreadRewardsUncollected: ", spreadRewardsUncollected) - // fmt.Println("positionLiquidity: ", positionLiquidity) - // fmt.Println("spreadRewardGrowthInside: ", spreadRewardGrowthInside) - // fmt.Println("spreadRewardGrowthInsideLast: ", spreadRewardGrowthInsideLast) return spreadRewardsUncollected } diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index 451cdb1966e..c5868b9d868 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -804,12 +804,6 @@ func updateAccumAndClaimRewards(accum *accum.AccumulatorObject, positionKey stri return sdk.Coins{}, sdk.DecCoins{}, err } - // position, _ := accum.GetPosition(accum1, positionKey) - - // fmt.Println("positions unclaimed rewards total: ", position.UnclaimedRewardsTotal) - // fmt.Println("position.AccumValuePerShare: ", position.AccumValuePerShare) - // fmt.Println("position.NumShares: ", position.NumShares) - // Claim rewards, set the unclaimed rewards to zero, and update the position's accumulator value to reflect the current accumulator value. // Removes the position state from accum if remaining liquidity is zero for the position. incentivesClaimedCurrAccum, dust, err := accum.ClaimRewards(positionKey) diff --git a/x/concentrated-liquidity/spread_rewards.go b/x/concentrated-liquidity/spread_rewards.go index d1985e360e1..8669274c93f 100644 --- a/x/concentrated-liquidity/spread_rewards.go +++ b/x/concentrated-liquidity/spread_rewards.go @@ -245,16 +245,12 @@ func (k Keeper) prepareClaimableSpreadRewards(ctx sdk.Context, positionId uint64 if err != nil { return nil, err } - // fmt.Println("ADAM spreadRewardGrowthOutside", spreadRewardGrowthOutside) - // fmt.Println("ADAM spreadRewardAccumulator.GetValue() pre", spreadRewardAccumulator.GetValue()) // Claim rewards, set the unclaimed rewards to zero, and update the position's accumulator value to reflect the current accumulator value. spreadRewardsClaimed, forfeitedDust, err := updateAccumAndClaimRewards(spreadRewardAccumulator, positionKey, spreadRewardGrowthOutside) if err != nil { return nil, err } - // fmt.Println("ADAM spreadRewardAccumulator.GetValue() post", spreadRewardAccumulator.GetValue()) - // fmt.Println("ADAM spreadRewardsClaimed", spreadRewardsClaimed) // add foreited dust back to the global accumulator if !forfeitedDust.IsZero() { @@ -270,12 +266,8 @@ func (k Keeper) prepareClaimableSpreadRewards(ctx sdk.Context, positionId uint64 // Total shares remaining can be zero if we claim in withdrawPosition for the last position in the pool. // The shares are decremented in osmoutils/accum.ClaimRewards. if !totalSharesRemaining.IsZero() { - // fmt.Println("ADAM forfeitedDust", forfeitedDust) - // fmt.Println("ADAM totalSharesRemaining", totalSharesRemaining) forfeitedDustPerShare := forfeitedDust.QuoDecTruncate(totalSharesRemaining) - // fmt.Println("ADAM forfeitedDustPerShare", forfeitedDustPerShare) spreadRewardAccumulator.AddToAccumulator(forfeitedDustPerShare) - // fmt.Println("ADAM spreadRewardAccumulator.GetValue()", spreadRewardAccumulator.GetValue()) } } @@ -311,10 +303,7 @@ func updatePositionToInitValuePlusGrowthOutside(accumulator *accum.AccumulatorOb // - Then, during claiming in osmoutils.ClaimRewards, we perform the following computation: // growth_global_at{current block time} - (growth_inside_at_{last time of update} + growth_outside_at_{current block time of update}}) // which ends up being equal to growth_inside_from_{last_time_of_update}_to_{current block time of update}}. - // fmt.Println("growthoutside in spread rewards claim", growthOutside) - // fmt.Println("position.AccumValuePerShare in spread rewards claim", position.AccumValuePerShare) intervalAccumulationOutside := position.AccumValuePerShare.Add(growthOutside...) - // fmt.Println("intervalAccumulationOutside in spread rewards claim", intervalAccumulationOutside) err = accumulator.SetPositionIntervalAccumulation(positionKey, intervalAccumulationOutside) if err != nil { return err diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index d3b459920c7..87b0686ef00 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -113,11 +113,7 @@ func (ss *SwapState) updateSpreadRewardGrowthGlobal(spreadRewardChargeTotal sdk. // We round down here since we want to avoid overdistributing (the "spread factor charge" refers to // the total spread factors that will be accrued to the spread factor accumulator) spreadFactorsAccruedPerUnitOfLiquidity := spreadRewardChargeTotal.QuoTruncate(ss.liquidity) - // fmt.Println("AAA1 spreadRewardChargeTotal", spreadRewardChargeTotal) - // fmt.Println("AAA2 ss.liquidity", ss.liquidity) ss.globalSpreadRewardGrowthPerUnitLiquidity.AddMut(spreadFactorsAccruedPerUnitOfLiquidity) - // fmt.Println("AAA3 spreadFactorsAccruedPerUnitOfLiquidity", spreadFactorsAccruedPerUnitOfLiquidity) - // fmt.Println("ADAM ss.globalSpreadRewardGrowthPerUnitLiquidity", ss.globalSpreadRewardGrowthPerUnitLiquidity) } func (k Keeper) SwapExactAmountIn( @@ -353,8 +349,6 @@ func (k Keeper) computeOutAmtGivenIn( return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err } - // fmt.Println("ADAM TokenIn", tokenInMin) - swapStrategy, sqrtPriceLimit, err := k.setupSwapStrategy(p, spreadFactor, tokenInMin.Denom, priceLimit) if err != nil { return sdk.Coin{}, sdk.Coin{}, PoolUpdates{}, sdk.Dec{}, err diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 3b6d1dd31f9..786f75e1f40 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -217,68 +217,6 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) return parsedValue, nil } -// // determineTakerFee determines what the taker fee should be based on the pool type and denoms given. -// // This taker fee can be overridden by governance after the pool is created. -// func DetermineTakerFee(poolManagerParams types.Params, poolAssets sdk.Coins, poolType types.PoolType) sdk.Dec { -// if poolType == types.Stableswap { -// return poolManagerParams.StableswapTakerFee -// } else { -// // Check if all denoms exist in the stable denom list in poolmanager params. -// // As soon as one denom is not in the list, we know that the pool is not a stableswap pool -// // and move on to the next check. -// allAssetsAreStable := true -// for _, asset := range poolAssets { -// isStable := false -// for _, stableDenom := range poolManagerParams.StablecoinDenoms { -// if asset.Denom == stableDenom { -// isStable = true -// break -// } -// } -// // If we reach here and isStable is still false, -// // it means that the asset denom is not in the stable denom list -// if !isStable { -// allAssetsAreStable = false -// break -// } -// } - -// if allAssetsAreStable { -// // If we reach here, it means that all denoms are in the stable denom list -// // Therefore, we know that the pool is a stableswap pool and set the taker fee to the stableswap fee. -// return poolManagerParams.StableswapTakerFee -// } else if len(poolAssets) == 2 { -// // This brings us to our check, to see if this is an LST <> underlying denom pool. -// isStableLSTPair := false -// for _, asset := range poolAssets { -// for i, lstDenom := range poolManagerParams.LiquidStakeDenomPairings { -// if asset.Denom == lstDenom.UnderlyingTokenDenom { -// for _, denom := range lstDenom.LiquidStakedTokenDenoms { -// if (i == 0 && poolAssets[1].Denom == denom) || -// (i != 0 && poolAssets[0].Denom == denom) { -// isStableLSTPair = true -// break -// } -// } -// } -// if isStableLSTPair { -// break -// } -// } -// if isStableLSTPair { -// break -// } -// } -// if isStableLSTPair { -// // If it is an LST <> underlying denom pool, we set the taker fee to the stableswap fee. -// return poolManagerParams.StableswapTakerFee -// } -// } -// } - -// return poolManagerParams.DefaultTakerFee -// } - // SetTradingPairTakerFee sets the taker fee for the given trading pair. func (k Keeper) SetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { store := ctx.KVStore(k.storeKey) diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index ca02e28cb03..2003bde82b4 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -37,7 +37,7 @@ func (s *KeeperTestSuite) SetupTest(isCheckTx bool) { WithLegacyAmino(encodingConfig.Amino). WithCodec(encodingConfig.Marshaler) - // We Set the base denom here in order for highest liquidity routes to get generated. + // We set the base denom here in order for highest liquidity routes to get generated. // This is used in the tx fees epoch hook to swap the non OSMO to other tokens. baseDenom, err := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) s.Require().NoError(err) From 323d74290a58b04b8558926ff2020e1428a53678 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 22:15:05 -0500 Subject: [PATCH 30/83] add whitelist set message denom pair taker fees --- .../osmosis/poolmanager/v1beta1/genesis.proto | 23 +- proto/osmosis/poolmanager/v1beta1/tx.proto | 25 + x/poolmanager/create_pool.go | 44 +- x/poolmanager/keeper_test.go | 40 +- x/poolmanager/msg_server.go | 22 + x/poolmanager/types/events.go | 3 + x/poolmanager/types/genesis.pb.go | 343 ++++---- x/poolmanager/types/msgs.go | 42 + x/poolmanager/types/params.go | 78 +- x/poolmanager/types/tx.pb.go | 814 ++++++++++++++++-- x/txfees/keeper/hooks.go | 2 +- 11 files changed, 1134 insertions(+), 302 deletions(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 1098b09b68e..92f1383fad6 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -32,17 +32,6 @@ message Params { // about. repeated string authorized_quote_denoms = 3 [ (gogoproto.moretags) = "yaml:\"authorized_quote_denoms\"" ]; - // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that - // taker fees that are not whitelisted will be swapped to when being sent to - // the community pool. - string community_pool_denom_to_swap_non_whitelisted_assets_to = 4 - [ (gogoproto.moretags) = - "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; - // stablecoin_denoms is a list of denoms that are considered stablecoins. - // This is used to determine if a pool should use the stableswap taker - // fee. - repeated string stablecoin_denoms = 5 - [ (gogoproto.moretags) = "yaml:\"stablecoin_denoms\"" ]; } // GenesisState defines the poolmanager module's genesis state. @@ -95,6 +84,18 @@ message TakerFeeParams { (gogoproto.customname) = "NonOsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; + // admin_addresses is a list of addresses that are allowed to set and remove + // custom taker fees for denom pairs. Governance also has the ability to set + // and removecustom taker fees for denom pairs, but with the normal governance + // delay. + repeated string admin_addresses = 5 + [ (gogoproto.moretags) = "yaml:\"admin_addresses\"" ]; + // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that + // non-whitelisted taker fees will be swapped to before being sent to + // the community pool. + string community_pool_denom_to_swap_non_whitelisted_assets_to = 6 + [ (gogoproto.moretags) = + "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; } // TakerFeeDistributionPercentage defines what percent of the taker fee category diff --git a/proto/osmosis/poolmanager/v1beta1/tx.proto b/proto/osmosis/poolmanager/v1beta1/tx.proto index a870549e889..89a3d1ef1f4 100644 --- a/proto/osmosis/poolmanager/v1beta1/tx.proto +++ b/proto/osmosis/poolmanager/v1beta1/tx.proto @@ -17,6 +17,8 @@ service Msg { returns (MsgSplitRouteSwapExactAmountInResponse); rpc SplitRouteSwapExactAmountOut(MsgSplitRouteSwapExactAmountOut) returns (MsgSplitRouteSwapExactAmountOutResponse); + rpc SetDenomPairTakerFee(MsgSetDenomPairTakerFee) + returns (MsgSetDenomPairTakerFeeResponse); } // ===================== MsgSwapExactAmountIn @@ -114,3 +116,26 @@ message MsgSplitRouteSwapExactAmountOutResponse { (gogoproto.nullable) = false ]; } + +// ===================== MsgSetDenomPairTakerFee +message MsgSetDenomPairTakerFee { + option (amino.name) = "osmosis/poolmanager/set-denom-pair-taker-fee"; + + string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; + repeated DenomPairTakerFee denom_pair_taker_fee = 2 [ + (gogoproto.moretags) = "yaml:\"denom_pair_taker_fee\"", + (gogoproto.nullable) = false + ]; +} + +message MsgSetDenomPairTakerFeeResponse { bool success = 1; } + +message DenomPairTakerFee { + string denom_0 = 1 [ (gogoproto.moretags) = "yaml:\"denom_0\"" ]; + string denom_1 = 2 [ (gogoproto.moretags) = "yaml:\"denom_1\"" ]; + string taker_fee = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.moretags) = "yaml:\"taker_fee\"", + (gogoproto.nullable) = false + ]; +} \ No newline at end of file diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 786f75e1f40..4a3a539f0a6 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -217,10 +217,48 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) return parsedValue, nil } -// SetTradingPairTakerFee sets the taker fee for the given trading pair. -func (k Keeper) SetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { +// SetDenomPairTakerFee sets the taker fee for the given trading pair. +// If the taker fee for this denom pair matches the default taker fee, then +// it is deleted from state. +func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { store := ctx.KVStore(k.storeKey) - osmoutils.MustSetDec(store, types.FormatDenomTradePairKey(denom0, denom1), takerFee) + if takerFee.Equal(k.GetParams(ctx).TakerFeeParams.DefaultTakerFee) { + store.Delete(types.FormatDenomTradePairKey(denom0, denom1)) + return + } else { + osmoutils.MustSetDec(store, types.FormatDenomTradePairKey(denom0, denom1), takerFee) + } +} + +// SenderValidationSetDenomPairTakerFee sets the taker fee for the given trading pair iff the sender's address +// also exists in the pool manager taker fee admin address list. +func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee sdk.Dec) error { + adminAddresses := k.GetParams(ctx).TakerFeeParams.AdminAddresses + isAdmin := false + for _, admin := range adminAddresses { + if admin == sender { + isAdmin = true + break + } + } + if !isAdmin { + return fmt.Errorf("%s is not in the pool manager taker fee admin address list", sender) + } + + k.SetDenomPairTakerFee(ctx, denom0, denom1, takerFee) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgSetDenomPairTakerFee, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender), + sdk.NewAttribute(types.AttributeKeyDenom0, denom0), + sdk.NewAttribute(types.AttributeKeyDenom1, denom1), + sdk.NewAttribute(types.AttributeKeyTakerFee, takerFee.String()), + ), + }) + + return nil } // GetTradingPairTakerFee returns the taker fee for the given trading pair. diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index d1d5924c6a4..aca2fa768d4 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -29,9 +29,9 @@ var ( StakingRewards: sdk.MustNewDecFromStr("0.2"), CommunityPool: sdk.MustNewDecFromStr("0.8"), } - testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} + testAdminAddresses = []string{"osmo1qnpk2xwq6q5s6zj4qz4z2s6qz4z2s6qz4z2s6q"} testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" - testStablecoinDenoms = []string{"uusdc", "uusdt", "udai"} + testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} testPoolRoute = []types.ModuleRoute{ { @@ -84,14 +84,14 @@ func (s *KeeperTestSuite) TestInitGenesis() { Params: types.Params{ PoolCreationFee: testPoolCreationFee, TakerFeeParams: types.TakerFeeParams{ - DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, - OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + AdminAddresses: testAdminAddresses, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, }, - AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, - CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, - StablecoinDenoms: testStablecoinDenoms, + AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -104,9 +104,9 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Require().Equal(testStableswapTakerFee, params.TakerFeeParams.StableswapTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, params.TakerFeeParams.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, params.TakerFeeParams.NonOsmoTakerFeeDistribution) + s.Require().Equal(testAdminAddresses, params.TakerFeeParams.AdminAddresses) + s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, params.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testAuthorizedQuoteDenoms, params.AuthorizedQuoteDenoms) - s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) - s.Require().Equal(testStablecoinDenoms, params.StablecoinDenoms) s.Require().Equal(testPoolRoute, s.App.PoolManagerKeeper.GetAllPoolRoutes(s.Ctx)) } @@ -115,14 +115,14 @@ func (s *KeeperTestSuite) TestExportGenesis() { Params: types.Params{ PoolCreationFee: testPoolCreationFee, TakerFeeParams: types.TakerFeeParams{ - DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, - OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + DefaultTakerFee: testDefaultTakerFee, + StableswapTakerFee: testStableswapTakerFee, + OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, + AdminAddresses: testAdminAddresses, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, }, - AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, - CommunityPoolDenomToSwapNonWhitelistedAssetsTo: testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, - StablecoinDenoms: testStablecoinDenoms, + AuthorizedQuoteDenoms: testAuthorizedQuoteDenoms, }, NextPoolId: testExpectedPoolId, PoolRoutes: testPoolRoute, @@ -135,8 +135,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(testStableswapTakerFee, genesis.Params.TakerFeeParams.StableswapTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.NonOsmoTakerFeeDistribution) + s.Require().Equal(testAdminAddresses, genesis.Params.TakerFeeParams.AdminAddresses) + s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) s.Require().Equal(testAuthorizedQuoteDenoms, genesis.Params.AuthorizedQuoteDenoms) - s.Require().Equal(testCommunityPoolDenomToSwapNonWhitelistedAssetsTo, genesis.Params.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) - s.Require().Equal(testStablecoinDenoms, genesis.Params.StablecoinDenoms) s.Require().Equal(testPoolRoute, genesis.PoolRoutes) } diff --git a/x/poolmanager/msg_server.go b/x/poolmanager/msg_server.go index 4a33a027ec1..39b1255eac3 100644 --- a/x/poolmanager/msg_server.go +++ b/x/poolmanager/msg_server.go @@ -119,3 +119,25 @@ func (server msgServer) SplitRouteSwapExactAmountOut(goCtx context.Context, msg return &types.MsgSplitRouteSwapExactAmountOutResponse{TokenInAmount: tokenInAmount}, nil } + +func (server msgServer) SetDenomPairTakerFee(goCtx context.Context, msg *types.MsgSetDenomPairTakerFee) (*types.MsgSetDenomPairTakerFeeResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + for _, denomPair := range msg.DenomPairTakerFee { + err := server.keeper.SenderValidationSetDenomPairTakerFee(ctx, msg.Sender, denomPair.Denom_0, denomPair.Denom_1, denomPair.TakerFee) + if err != nil { + return nil, err + } + } + + // Set denom pair taker fee event is handled in each iteration of the loop above + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + }) + + return &types.MsgSetDenomPairTakerFeeResponse{Success: true}, nil +} diff --git a/x/poolmanager/types/events.go b/x/poolmanager/types/events.go index a080865806b..0133711ab60 100644 --- a/x/poolmanager/types/events.go +++ b/x/poolmanager/types/events.go @@ -7,4 +7,7 @@ const ( AttributeKeyTokensIn = "tokens_in" AttributeKeyTokensOut = "tokens_out" AttributeKeyPoolId = "pool_id" + AttributeKeyDenom0 = "denom0" + AttributeKeyDenom1 = "denom1" + AttributeKeyTakerFee = "taker_fee" ) diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 6d67e21f34b..ed7d2398f70 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -42,14 +42,6 @@ type Params struct { // orders at prices in terms of token1 (quote asset) that are easy to reason // about. AuthorizedQuoteDenoms []string `protobuf:"bytes,3,rep,name=authorized_quote_denoms,json=authorizedQuoteDenoms,proto3" json:"authorized_quote_denoms,omitempty" yaml:"authorized_quote_denoms"` - // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that - // taker fees that are not whitelisted will be swapped to when being sent to - // the community pool. - CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,4,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` - // stablecoin_denoms is a list of denoms that are considered stablecoins. - // This is used to determine if a pool should use the stableswap taker - // fee. - StablecoinDenoms []string `protobuf:"bytes,5,rep,name=stablecoin_denoms,json=stablecoinDenoms,proto3" json:"stablecoin_denoms,omitempty" yaml:"stablecoin_denoms"` } func (m *Params) Reset() { *m = Params{} } @@ -106,20 +98,6 @@ func (m *Params) GetAuthorizedQuoteDenoms() []string { return nil } -func (m *Params) GetCommunityPoolDenomToSwapNonWhitelistedAssetsTo() string { - if m != nil { - return m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo - } - return "" -} - -func (m *Params) GetStablecoinDenoms() []string { - if m != nil { - return m.StablecoinDenoms - } - return nil -} - // GenesisState defines the poolmanager module's genesis state. type GenesisState struct { // the next_pool_id @@ -210,6 +188,15 @@ type TakerFeeParams struct { // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and // then sent to the community pool as that denom. NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,4,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` + // admin_addresses is a list of addresses that are allowed to set and remove + // custom taker fees for denom pairs. Governance also has the ability to set + // and removecustom taker fees for denom pairs, but with the normal governance + // delay. + AdminAddresses []string `protobuf:"bytes,5,rep,name=admin_addresses,json=adminAddresses,proto3" json:"admin_addresses,omitempty" yaml:"admin_addresses"` + // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that + // non-whitelisted taker fees will be swapped to before being sent to + // the community pool. + CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,6,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` } func (m *TakerFeeParams) Reset() { *m = TakerFeeParams{} } @@ -259,6 +246,20 @@ func (m *TakerFeeParams) GetNonOsmoTakerFeeDistribution() TakerFeeDistributionPe return TakerFeeDistributionPercentage{} } +func (m *TakerFeeParams) GetAdminAddresses() []string { + if m != nil { + return m.AdminAddresses + } + return nil +} + +func (m *TakerFeeParams) GetCommunityPoolDenomToSwapNonWhitelistedAssetsTo() string { + if m != nil { + return m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo + } + return "" +} + // TakerFeeDistributionPercentage defines what percent of the taker fee category // gets distributed to the available categories. type TakerFeeDistributionPercentage struct { @@ -366,65 +367,65 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 924 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0x93, 0x25, 0x52, 0x26, 0x25, 0x69, 0x46, 0x69, 0xb3, 0x4d, 0xc0, 0xde, 0xba, 0x02, - 0x2d, 0x42, 0xb5, 0x95, 0x20, 0x51, 0x09, 0xc4, 0x21, 0xdb, 0x55, 0x4b, 0xa5, 0xd2, 0xa6, 0xce, - 0xa2, 0x4a, 0xbd, 0x8c, 0xc6, 0xeb, 0x89, 0x63, 0xc5, 0x9e, 0xd9, 0x78, 0xc6, 0x49, 0x97, 0x2b, - 0x5f, 0x00, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xf8, 0x04, 0x5c, 0x38, 0xf4, 0xd8, 0x23, 0xe2, 0x60, - 0x60, 0xf3, 0x09, 0xd8, 0x4f, 0x80, 0xe6, 0xcf, 0xfe, 0x4b, 0xb2, 0xab, 0x84, 0x9e, 0x12, 0xbf, - 0xf7, 0xfb, 0xf3, 0x66, 0xde, 0x9b, 0xb7, 0xe0, 0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0x33, 0x8b, - 0xf9, 0x25, 0xb8, 0x5d, 0x0c, 0x6d, 0xc7, 0x49, 0xe6, 0x0a, 0xee, 0xf6, 0x4b, 0xe7, 0x43, 0xad, - 0x7f, 0x39, 0xce, 0x0d, 0xd6, 0x47, 0x89, 0x91, 0x72, 0xe3, 0xc5, 0x9b, 0x9e, 0x6d, 0xbd, 0xed, - 0xd9, 0xd6, 0xdf, 0x3d, 0xdb, 0xfa, 0xe1, 0xcc, 0x9e, 0x7b, 0x7b, 0x66, 0xcf, 0xfd, 0x71, 0x66, - 0xcf, 0xbd, 0x7a, 0x30, 0x76, 0x9b, 0x66, 0x18, 0xef, 0xa7, 0x38, 0xe4, 0x83, 0x0f, 0xff, 0x64, - 0xfb, 0x81, 0xff, 0x7a, 0xe2, 0xe7, 0x5c, 0x5d, 0x71, 0xb8, 0xa8, 0x7e, 0xc0, 0x3f, 0xfb, 0x2f, - 0x00, 0x00, 0xff, 0xff, 0x8d, 0x7a, 0x5a, 0x76, 0xc6, 0x08, 0x00, 0x00, + // 925 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0x6d, 0x57, 0x40, 0xd6, 0xa9, 0xd4, 0x2c, 0x9c, 0x98, 0xb1, 0x51, 0x51, 0x61, 0xd0, + 0x42, 0x45, 0x11, 0x12, 0x76, 0x81, 0x06, 0x68, 0xd1, 0x83, 0x65, 0x21, 0x69, 0x81, 0x34, 0x71, + 0x68, 0x15, 0x01, 0x72, 0x59, 0x2c, 0xc5, 0x31, 0x4d, 0x98, 0xdc, 0x95, 0xb9, 0x4b, 0x3b, 0xea, + 0xb5, 0x2f, 0x50, 0xa0, 0xd7, 0x9e, 0x7b, 0xe8, 0xad, 0xb7, 0x3e, 0x40, 0x0f, 0x39, 0xe6, 0x58, + 0xf4, 0xc0, 0xb6, 0xf2, 0x1b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, 0x85, 0xf9, + 0x68, 0x98, 0x5b, 0xf7, 0x74, 0xd1, 0xf9, 0x58, 0xdb, 0xdb, 0x88, 0x2f, 0x96, 0xd3, 0x9f, 0x64, + 0xfc, 0x02, 0xdd, 0xc9, 0xc6, 0x65, 0xa7, 0x49, 0xa5, 0x05, 0xf7, 0x86, 0xb9, 0xf5, 0xa1, 0xd6, + 0xbf, 0x1c, 0x67, 0x7b, 0xeb, 0x93, 0xc4, 0x44, 0xb9, 0xf5, 0xfc, 0xf5, 0xa0, 0x6e, 0xbc, 0x19, + 0xd4, 0x8d, 0x7f, 0x06, 0x75, 0xe3, 0xc7, 0xf3, 0xfa, 0xd2, 0x9b, 0xf3, 0xfa, 0xd2, 0x9f, 0xe7, + 0xf5, 0xa5, 0x97, 0x0f, 0xa7, 0xdc, 0x2c, 0xaf, 0xf0, 0x41, 0x4c, 0x7d, 0x31, 0x7a, 0x70, 0x4f, + 0xb7, 0x1f, 0xba, 0xaf, 0x66, 0x7e, 0xc8, 0x95, 0xc5, 0x7e, 0x45, 0xfd, 0x74, 0x7f, 0xf6, 0x5f, + 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x09, 0xb8, 0x69, 0xc0, 0x08, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -447,22 +448,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.StablecoinDenoms) > 0 { - for iNdEx := len(m.StablecoinDenoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.StablecoinDenoms[iNdEx]) - copy(dAtA[i:], m.StablecoinDenoms[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.StablecoinDenoms[iNdEx]))) - i-- - dAtA[i] = 0x2a - } - } - if len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) > 0 { - i -= len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) - copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo))) - i-- - dAtA[i] = 0x22 - } if len(m.AuthorizedQuoteDenoms) > 0 { for iNdEx := len(m.AuthorizedQuoteDenoms) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.AuthorizedQuoteDenoms[iNdEx]) @@ -571,6 +556,22 @@ func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) > 0 { + i -= len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo))) + i-- + dAtA[i] = 0x32 + } + if len(m.AdminAddresses) > 0 { + for iNdEx := len(m.AdminAddresses) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AdminAddresses[iNdEx]) + copy(dAtA[i:], m.AdminAddresses[iNdEx]) + i = encodeVarintGenesis(dAtA, i, uint64(len(m.AdminAddresses[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } { size, err := m.NonOsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -727,16 +728,6 @@ func (m *Params) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } - l = len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if len(m.StablecoinDenoms) > 0 { - for _, s := range m.StablecoinDenoms { - l = len(s) - n += 1 + l + sovGenesis(uint64(l)) - } - } return n } @@ -774,6 +765,16 @@ func (m *TakerFeeParams) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.NonOsmoTakerFeeDistribution.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.AdminAddresses) > 0 { + for _, s := range m.AdminAddresses { + l = len(s) + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) + if l > 0 { + n += 1 + l + sovGenesis(uint64(l)) + } return n } @@ -943,70 +944,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.AuthorizedQuoteDenoms = append(m.AuthorizedQuoteDenoms, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StablecoinDenoms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StablecoinDenoms = append(m.StablecoinDenoms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) @@ -1327,6 +1264,70 @@ func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AdminAddresses", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AdminAddresses = append(m.AdminAddresses, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index f1af10033a2..4895eb438e8 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -12,6 +12,7 @@ const ( TypeMsgSwapExactAmountOut = "swap_exact_amount_out" TypeMsgSplitRouteSwapExactAmountIn = "split_route_swap_exact_amount_in" TypeMsgSplitRouteSwapExactAmountOut = "split_route_swap_exact_amount_out" + TypeMsgSetDenomPairTakerFee = "set_denom_pair_taker_fee" ) var _ sdk.Msg = &MsgSwapExactAmountIn{} @@ -166,3 +167,44 @@ func (msg MsgSplitRouteSwapExactAmountOut) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{sender} } + +var _ sdk.Msg = &MsgSetDenomPairTakerFee{} + +func (msg MsgSetDenomPairTakerFee) Route() string { return RouterKey } +func (msg MsgSetDenomPairTakerFee) Type() string { return TypeMsgSetDenomPairTakerFee } + +func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return InvalidSenderError{Sender: msg.Sender} + } + + for _, denomPair := range msg.DenomPairTakerFee { + if err := sdk.ValidateDenom(denomPair.Denom_0); err != nil { + return err + } + if err := sdk.ValidateDenom(denomPair.Denom_1); err != nil { + return err + } + if denomPair.TakerFee.IsNegative() { + return nonPositiveAmountError{denomPair.TakerFee.String()} + } + if denomPair.TakerFee.GT(sdk.OneDec()) { + return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Taker fee %s is greater than 1", denomPair.TakerFee.String()) + } + } + + return nil +} + +func (msg MsgSetDenomPairTakerFee) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) +} + +func (msg MsgSetDenomPairTakerFee) GetSigners() []sdk.AccAddress { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{sender} +} diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 073140ed4e7..e6c752607ef 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -16,9 +16,9 @@ var ( KeyStableswapTakerFee = []byte("StableswapTakerFee") KeyOsmoTakerFeeDistribution = []byte("OsmoTakerFeeDistribution") KeyNonOsmoTakerFeeDistribution = []byte("NonOsmoTakerFeeDistribution") - KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") + KeyAdminAddresses = []byte("AdminAddresses") KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo = []byte("CommunityPoolDenomToSwapNonWhitelistedAssetsTo") - KeyStablecoinDenoms = []byte("StablecoinDenoms") + KeyAuthorizedQuoteDenoms = []byte("AuthorizedQuoteDenoms") ) // ParamTable for gamm module. @@ -29,20 +29,19 @@ func ParamKeyTable() paramtypes.KeyTable { func NewParams(poolCreationFee sdk.Coins, defaultTakerFee, stableswapTakerFee sdk.Dec, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, - authorizedQuoteDenoms []string, - communityPoolDenomToSwapNonWhitelistedAssetsTo string, - stablecoinDenoms []string) Params { + adminAddresses, authorizedQuoteDenoms []string, + communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { return Params{ PoolCreationFee: poolCreationFee, TakerFeeParams: TakerFeeParams{ - DefaultTakerFee: defaultTakerFee, - StableswapTakerFee: stableswapTakerFee, - OsmoTakerFeeDistribution: osmoTakerFeeDistribution, - NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, + DefaultTakerFee: defaultTakerFee, + StableswapTakerFee: stableswapTakerFee, + OsmoTakerFeeDistribution: osmoTakerFeeDistribution, + NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, + AdminAddresses: adminAddresses, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: communityPoolDenomToSwapNonWhitelistedAssetsTo, }, - AuthorizedQuoteDenoms: authorizedQuoteDenoms, - CommunityPoolDenomToSwapNonWhitelistedAssetsTo: communityPoolDenomToSwapNonWhitelistedAssetsTo, - StablecoinDenoms: stablecoinDenoms, + AuthorizedQuoteDenoms: authorizedQuoteDenoms, } } @@ -61,19 +60,15 @@ func DefaultParams() Params { StakingRewards: sdk.MustNewDecFromStr("0.67"), // 67% CommunityPool: sdk.MustNewDecFromStr("0.33"), // 33% }, + AdminAddresses: []string{}, + CommunityPoolDenomToSwapNonWhitelistedAssetsTo: "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC }, - AuthorizedQuoteDenoms: []string{ "uosmo", "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", // ATOM "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", // DAI "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC }, - CommunityPoolDenomToSwapNonWhitelistedAssetsTo: "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC - StablecoinDenoms: []string{ - "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", // DAI - "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC - }, } } @@ -94,13 +89,13 @@ func (p Params) Validate() error { if err := validateTakerFeeDistribution(p.TakerFeeParams.NonOsmoTakerFeeDistribution); err != nil { return err } - if err := validateAuthorizedQuoteDenoms(p.AuthorizedQuoteDenoms); err != nil { + if err := validateAdminAddresses(p.TakerFeeParams.AdminAddresses); err != nil { return err } - if err := validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo); err != nil { + if err := validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(p.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo); err != nil { return err } - if err := validateStablecoinDenoms(p.StablecoinDenoms); err != nil { + if err := validateAuthorizedQuoteDenoms(p.AuthorizedQuoteDenoms); err != nil { return err } @@ -115,9 +110,9 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.TakerFeeParams.StableswapTakerFee, validateStableswapTakerFee), paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.TakerFeeParams.OsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.TakerFeeParams.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), + paramtypes.NewParamSetPair(KeyAdminAddresses, &p.TakerFeeParams.AdminAddresses, validateAdminAddresses), + paramtypes.NewParamSetPair(KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo, &p.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo, validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo), paramtypes.NewParamSetPair(KeyAuthorizedQuoteDenoms, &p.AuthorizedQuoteDenoms, validateAuthorizedQuoteDenoms), - paramtypes.NewParamSetPair(KeyCommunityPoolDenomToSwapNonWhitelistedAssetsTo, &p.CommunityPoolDenomToSwapNonWhitelistedAssetsTo, validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo), - paramtypes.NewParamSetPair(KeyStablecoinDenoms, &p.StablecoinDenoms, validateStablecoinDenoms), } } @@ -184,6 +179,23 @@ func validateTakerFeeDistribution(i interface{}) error { return nil } +func validateAdminAddresses(i interface{}) error { + adminAddresses, ok := i.([]string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + if len(adminAddresses) > 0 { + for _, adminAddress := range adminAddresses { + if _, err := sdk.AccAddressFromBech32(adminAddress); err != nil { + return fmt.Errorf("invalid account address: %s", adminAddress) + } + } + } + + return nil +} + // validateAuthorizedQuoteDenoms validates a slice of authorized quote denoms. // // Parameters: @@ -226,23 +238,3 @@ func validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(i interface{}) error return nil } - -func validateStablecoinDenoms(i interface{}) error { - stablecoinDenoms, ok := i.([]string) - - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - if len(stablecoinDenoms) == 0 { - return fmt.Errorf("stablecoin denoms cannot be empty") - } - - for _, denom := range stablecoinDenoms { - if err := sdk.ValidateDenom(denom); err != nil { - return err - } - } - - return nil -} diff --git a/x/poolmanager/types/tx.pb.go b/x/poolmanager/types/tx.pb.go index e8e7a78379c..17dc553b416 100644 --- a/x/poolmanager/types/tx.pb.go +++ b/x/poolmanager/types/tx.pb.go @@ -431,6 +431,156 @@ func (m *MsgSplitRouteSwapExactAmountOutResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSplitRouteSwapExactAmountOutResponse proto.InternalMessageInfo +// ===================== MsgSetDenomPairTakerFee +type MsgSetDenomPairTakerFee struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + DenomPairTakerFee []DenomPairTakerFee `protobuf:"bytes,2,rep,name=denom_pair_taker_fee,json=denomPairTakerFee,proto3" json:"denom_pair_taker_fee" yaml:"denom_pair_taker_fee"` +} + +func (m *MsgSetDenomPairTakerFee) Reset() { *m = MsgSetDenomPairTakerFee{} } +func (m *MsgSetDenomPairTakerFee) String() string { return proto.CompactTextString(m) } +func (*MsgSetDenomPairTakerFee) ProtoMessage() {} +func (*MsgSetDenomPairTakerFee) Descriptor() ([]byte, []int) { + return fileDescriptor_acd130b4825d67dc, []int{8} +} +func (m *MsgSetDenomPairTakerFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDenomPairTakerFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDenomPairTakerFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetDenomPairTakerFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDenomPairTakerFee.Merge(m, src) +} +func (m *MsgSetDenomPairTakerFee) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDenomPairTakerFee) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDenomPairTakerFee.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDenomPairTakerFee proto.InternalMessageInfo + +func (m *MsgSetDenomPairTakerFee) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSetDenomPairTakerFee) GetDenomPairTakerFee() []DenomPairTakerFee { + if m != nil { + return m.DenomPairTakerFee + } + return nil +} + +type MsgSetDenomPairTakerFeeResponse struct { + Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` +} + +func (m *MsgSetDenomPairTakerFeeResponse) Reset() { *m = MsgSetDenomPairTakerFeeResponse{} } +func (m *MsgSetDenomPairTakerFeeResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSetDenomPairTakerFeeResponse) ProtoMessage() {} +func (*MsgSetDenomPairTakerFeeResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_acd130b4825d67dc, []int{9} +} +func (m *MsgSetDenomPairTakerFeeResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSetDenomPairTakerFeeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSetDenomPairTakerFeeResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgSetDenomPairTakerFeeResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSetDenomPairTakerFeeResponse.Merge(m, src) +} +func (m *MsgSetDenomPairTakerFeeResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSetDenomPairTakerFeeResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSetDenomPairTakerFeeResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSetDenomPairTakerFeeResponse proto.InternalMessageInfo + +func (m *MsgSetDenomPairTakerFeeResponse) GetSuccess() bool { + if m != nil { + return m.Success + } + return false +} + +type DenomPairTakerFee struct { + Denom_0 string `protobuf:"bytes,1,opt,name=denom_0,json=denom0,proto3" json:"denom_0,omitempty" yaml:"denom_0"` + Denom_1 string `protobuf:"bytes,2,opt,name=denom_1,json=denom1,proto3" json:"denom_1,omitempty" yaml:"denom_1"` + TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` +} + +func (m *DenomPairTakerFee) Reset() { *m = DenomPairTakerFee{} } +func (m *DenomPairTakerFee) String() string { return proto.CompactTextString(m) } +func (*DenomPairTakerFee) ProtoMessage() {} +func (*DenomPairTakerFee) Descriptor() ([]byte, []int) { + return fileDescriptor_acd130b4825d67dc, []int{10} +} +func (m *DenomPairTakerFee) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DenomPairTakerFee) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DenomPairTakerFee.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DenomPairTakerFee) XXX_Merge(src proto.Message) { + xxx_messageInfo_DenomPairTakerFee.Merge(m, src) +} +func (m *DenomPairTakerFee) XXX_Size() int { + return m.Size() +} +func (m *DenomPairTakerFee) XXX_DiscardUnknown() { + xxx_messageInfo_DenomPairTakerFee.DiscardUnknown(m) +} + +var xxx_messageInfo_DenomPairTakerFee proto.InternalMessageInfo + +func (m *DenomPairTakerFee) GetDenom_0() string { + if m != nil { + return m.Denom_0 + } + return "" +} + +func (m *DenomPairTakerFee) GetDenom_1() string { + if m != nil { + return m.Denom_1 + } + return "" +} + func init() { proto.RegisterType((*MsgSwapExactAmountIn)(nil), "osmosis.poolmanager.v1beta1.MsgSwapExactAmountIn") proto.RegisterType((*MsgSwapExactAmountInResponse)(nil), "osmosis.poolmanager.v1beta1.MsgSwapExactAmountInResponse") @@ -440,6 +590,9 @@ func init() { proto.RegisterType((*MsgSwapExactAmountOutResponse)(nil), "osmosis.poolmanager.v1beta1.MsgSwapExactAmountOutResponse") proto.RegisterType((*MsgSplitRouteSwapExactAmountOut)(nil), "osmosis.poolmanager.v1beta1.MsgSplitRouteSwapExactAmountOut") proto.RegisterType((*MsgSplitRouteSwapExactAmountOutResponse)(nil), "osmosis.poolmanager.v1beta1.MsgSplitRouteSwapExactAmountOutResponse") + proto.RegisterType((*MsgSetDenomPairTakerFee)(nil), "osmosis.poolmanager.v1beta1.MsgSetDenomPairTakerFee") + proto.RegisterType((*MsgSetDenomPairTakerFeeResponse)(nil), "osmosis.poolmanager.v1beta1.MsgSetDenomPairTakerFeeResponse") + proto.RegisterType((*DenomPairTakerFee)(nil), "osmosis.poolmanager.v1beta1.DenomPairTakerFee") } func init() { @@ -447,59 +600,70 @@ func init() { } var fileDescriptor_acd130b4825d67dc = []byte{ - // 818 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x5f, 0x6b, 0xd3, 0x5e, - 0x18, 0xc7, 0x9b, 0x5f, 0xcb, 0x7e, 0xdb, 0x99, 0xfb, 0xd3, 0xb8, 0xb9, 0xae, 0x9b, 0xe9, 0x88, - 0x63, 0x76, 0x62, 0x13, 0xda, 0x09, 0xc3, 0x2a, 0x88, 0xdd, 0x04, 0x0b, 0x2b, 0x75, 0xf1, 0xce, - 0x9b, 0x92, 0x76, 0xa1, 0x86, 0x35, 0xe7, 0x84, 0x9e, 0x93, 0xad, 0x43, 0x10, 0x04, 0x6f, 0x14, - 0x85, 0x89, 0x97, 0x22, 0x82, 0xaf, 0xc0, 0x97, 0xb1, 0xcb, 0xdd, 0x29, 0x5e, 0x14, 0xd9, 0x2e, - 0xbc, 0xef, 0x2b, 0x90, 0x93, 0x93, 0x64, 0x6d, 0xd6, 0x65, 0x8d, 0x03, 0x77, 0xb3, 0x25, 0x27, - 0xcf, 0xbf, 0xef, 0xf3, 0x7c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61, 0x7b, 0xe5, 0x0c, 0xf2, 0x62, 0xff, 0x82, 0xbc, - 0xfc, 0x32, 0xe5, 0x64, 0xf1, 0xdc, 0xa5, 0x42, 0x11, 0xf9, 0xc4, 0x81, 0x9b, 0xe7, 0x8c, 0xe3, - 0xf2, 0x60, 0xc9, 0x7d, 0x8f, 0x81, 0x68, 0x09, 0xd7, 0xf9, 0x57, 0x1c, 0x88, 0x9f, 0xfe, 0xf4, - 0x64, 0x03, 0x67, 0xdd, 0xef, 0x6b, 0x9a, 0xbc, 0x1b, 0xda, 0xc5, 0x53, 0xff, 0x9a, 0x03, 0x7c, - 0x1f, 0x56, 0x73, 0x21, 0x23, 0x96, 0x2d, 0x92, 0xcc, 0x87, 0xf7, 0xf1, 0xca, 0xf8, 0xc2, 0x81, - 0xb9, 0xa0, 0xef, 0xf1, 0xbd, 0x73, 0x63, 0x9f, 0xed, 0x9c, 0x5c, 0xbb, 0x80, 0xb3, 0x57, 0xe1, - 0x57, 0x0e, 0xcc, 0x07, 0xbe, 0xde, 0xf7, 0xff, 0x3a, 0x0b, 0x6d, 0xde, 0xfa, 0x45, 0xbc, 0xdd, - 0x22, 0x0b, 0x9b, 0x07, 0x47, 0x02, 0x77, 0x78, 0x24, 0x70, 0xbf, 0x8e, 0x04, 0x6e, 0xff, 0x58, - 0x88, 0x1c, 0x1e, 0x0b, 0x91, 0x1f, 0xc7, 0x42, 0xe4, 0xd9, 0x6a, 0x17, 0xc4, 0x4e, 0xa6, 0x4c, - 0x43, 0xad, 0x62, 0xf7, 0x46, 0xde, 0xc9, 0xae, 0xca, 0xad, 0x9e, 0xb7, 0xca, 0x26, 0xbb, 0x3a, - 0x64, 0xff, 0xb2, 0x5e, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x43, 0xa8, 0x39, 0xec, 0x15, 0x0c, - 0x00, 0x00, + // 1001 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x97, 0x5d, 0x6f, 0xdb, 0x54, + 0x18, 0xc7, 0x7b, 0x96, 0xd2, 0x97, 0x33, 0xd6, 0x35, 0x26, 0xa3, 0x59, 0x3a, 0x92, 0xca, 0x9b, + 0x46, 0x0a, 0xd8, 0x6e, 0xba, 0x49, 0x13, 0xd9, 0x24, 0x44, 0x56, 0x10, 0x95, 0x16, 0x65, 0x33, + 0x5c, 0x71, 0x63, 0x39, 0xe9, 0x21, 0x58, 0xad, 0xcf, 0xb1, 0x72, 0x8e, 0xb7, 0x4c, 0x48, 0x48, + 0x48, 0xbb, 0x61, 0x02, 0x69, 0x88, 0x4b, 0x84, 0x90, 0xf8, 0x04, 0x7c, 0x8c, 0x5d, 0xa1, 0x5d, + 0x22, 0x2e, 0x22, 0xd4, 0x22, 0x71, 0x9f, 0x0f, 0x80, 0xd0, 0x79, 0xb1, 0x93, 0xba, 0x6e, 0x1a, + 0xb7, 0x12, 0xbd, 0xd9, 0x6c, 0xe7, 0x79, 0xfd, 0x3f, 0xbf, 0xf3, 0xe8, 0x14, 0xde, 0x20, 0xd4, + 0x27, 0xd4, 0xa3, 0x56, 0x40, 0xc8, 0x9e, 0xef, 0x62, 0xb7, 0x8b, 0x7a, 0xd6, 0xe3, 0x5a, 0x1b, + 0x31, 0xb7, 0x66, 0xb1, 0xbe, 0x19, 0xf4, 0x08, 0x23, 0xda, 0xaa, 0xb2, 0x32, 0xc7, 0xac, 0x4c, + 0x65, 0x55, 0x2a, 0x74, 0x49, 0x97, 0x08, 0x3b, 0x8b, 0x3f, 0x49, 0x97, 0x52, 0xde, 0xf5, 0x3d, + 0x4c, 0x2c, 0xf1, 0xaf, 0xfa, 0x54, 0xee, 0x88, 0x30, 0x56, 0xdb, 0xa5, 0x28, 0xce, 0xd1, 0x21, + 0x1e, 0x56, 0xbf, 0xbf, 0x37, 0xa9, 0x16, 0xfa, 0xc4, 0x0d, 0x9c, 0x1e, 0x09, 0x19, 0x92, 0xd6, + 0xfa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xb2, 0xc2, 0xaa, 0xe9, 0xf6, + 0x65, 0x49, 0xda, 0x43, 0xb8, 0x18, 0xab, 0x26, 0x78, 0x9a, 0xb8, 0xd1, 0x8a, 0x6a, 0xa3, 0x2d, + 0x27, 0xf4, 0xd6, 0xed, 0x85, 0x48, 0xe8, 0xba, 0xc9, 0x61, 0x59, 0x9f, 0x6e, 0xa7, 0x70, 0xd7, + 0x1f, 0x00, 0x7c, 0x2b, 0x75, 0x24, 0x31, 0x29, 0x01, 0xbc, 0x1c, 0x77, 0x73, 0x08, 0x94, 0x4f, + 0x32, 0x8b, 0xf3, 0x66, 0x42, 0x9c, 0x48, 0x98, 0x4b, 0x4a, 0x18, 0x85, 0xc9, 0x77, 0x39, 0x58, + 0x99, 0x84, 0x71, 0x46, 0x60, 0xec, 0x04, 0x30, 0xb7, 0xa7, 0x07, 0xe6, 0xd8, 0xa5, 0xd2, 0x88, + 0x44, 0xe1, 0xb8, 0x8f, 0x6f, 0x95, 0x52, 0xb2, 0xcd, 0xd8, 0x20, 0x6a, 0xb3, 0x15, 0x32, 0xb9, + 0x57, 0x8e, 0x21, 0x6f, 0xf6, 0xff, 0x20, 0xaf, 0xbe, 0xce, 0x39, 0xb9, 0x71, 0xe2, 0x52, 0xe1, + 0x88, 0xfc, 0x04, 0xe0, 0xdb, 0x27, 0x8c, 0xe3, 0x1c, 0x61, 0xf9, 0x17, 0xc0, 0x15, 0x5e, 0x1d, + 0x92, 0xaa, 0x3e, 0x74, 0xbd, 0xde, 0x67, 0xee, 0x2e, 0xea, 0x7d, 0x8c, 0x50, 0x16, 0x48, 0x9e, + 0x01, 0x58, 0x10, 0x63, 0x72, 0x02, 0xd7, 0xeb, 0x39, 0x8c, 0x87, 0x70, 0xbe, 0x40, 0x68, 0xaa, + 0x7b, 0xcb, 0x91, 0xcc, 0x8d, 0xeb, 0xea, 0xa8, 0xaa, 0x5d, 0x9f, 0x16, 0x59, 0xb7, 0xf3, 0x3b, + 0x49, 0xbf, 0x7a, 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, 0x7d, 0x62, 0xf8, 0x14, 0xaf, 0xd2, + 0xbd, 0xd3, 0x78, 0x45, 0xc5, 0x34, 0x1e, 0xbd, 0xdc, 0x2f, 0x83, 0x57, 0xfb, 0x65, 0xf0, 0xd7, + 0x7e, 0x19, 0xbc, 0x38, 0x28, 0xcf, 0xbc, 0x3a, 0x28, 0xcf, 0xfc, 0x71, 0x50, 0x9e, 0xf9, 0xfc, + 0xce, 0xd8, 0x31, 0x52, 0x19, 0x8c, 0x3d, 0xb7, 0x4d, 0xa3, 0x17, 0xeb, 0x71, 0xed, 0x8e, 0xd5, + 0x3f, 0xb4, 0x5a, 0xc4, 0xd9, 0x6a, 0xcf, 0x89, 0xbf, 0xfa, 0x6e, 0xfd, 0x17, 0x00, 0x00, 0xff, + 0xff, 0xd3, 0x06, 0x64, 0x62, 0xb1, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -518,6 +682,7 @@ type MsgClient interface { SwapExactAmountOut(ctx context.Context, in *MsgSwapExactAmountOut, opts ...grpc.CallOption) (*MsgSwapExactAmountOutResponse, error) SplitRouteSwapExactAmountIn(ctx context.Context, in *MsgSplitRouteSwapExactAmountIn, opts ...grpc.CallOption) (*MsgSplitRouteSwapExactAmountInResponse, error) SplitRouteSwapExactAmountOut(ctx context.Context, in *MsgSplitRouteSwapExactAmountOut, opts ...grpc.CallOption) (*MsgSplitRouteSwapExactAmountOutResponse, error) + SetDenomPairTakerFee(ctx context.Context, in *MsgSetDenomPairTakerFee, opts ...grpc.CallOption) (*MsgSetDenomPairTakerFeeResponse, error) } type msgClient struct { @@ -564,12 +729,22 @@ func (c *msgClient) SplitRouteSwapExactAmountOut(ctx context.Context, in *MsgSpl return out, nil } +func (c *msgClient) SetDenomPairTakerFee(ctx context.Context, in *MsgSetDenomPairTakerFee, opts ...grpc.CallOption) (*MsgSetDenomPairTakerFeeResponse, error) { + out := new(MsgSetDenomPairTakerFeeResponse) + err := c.cc.Invoke(ctx, "/osmosis.poolmanager.v1beta1.Msg/SetDenomPairTakerFee", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { SwapExactAmountIn(context.Context, *MsgSwapExactAmountIn) (*MsgSwapExactAmountInResponse, error) SwapExactAmountOut(context.Context, *MsgSwapExactAmountOut) (*MsgSwapExactAmountOutResponse, error) SplitRouteSwapExactAmountIn(context.Context, *MsgSplitRouteSwapExactAmountIn) (*MsgSplitRouteSwapExactAmountInResponse, error) SplitRouteSwapExactAmountOut(context.Context, *MsgSplitRouteSwapExactAmountOut) (*MsgSplitRouteSwapExactAmountOutResponse, error) + SetDenomPairTakerFee(context.Context, *MsgSetDenomPairTakerFee) (*MsgSetDenomPairTakerFeeResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -588,6 +763,9 @@ func (*UnimplementedMsgServer) SplitRouteSwapExactAmountIn(ctx context.Context, func (*UnimplementedMsgServer) SplitRouteSwapExactAmountOut(ctx context.Context, req *MsgSplitRouteSwapExactAmountOut) (*MsgSplitRouteSwapExactAmountOutResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SplitRouteSwapExactAmountOut not implemented") } +func (*UnimplementedMsgServer) SetDenomPairTakerFee(ctx context.Context, req *MsgSetDenomPairTakerFee) (*MsgSetDenomPairTakerFeeResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SetDenomPairTakerFee not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -665,6 +843,24 @@ func _Msg_SplitRouteSwapExactAmountOut_Handler(srv interface{}, ctx context.Cont return interceptor(ctx, in, info, handler) } +func _Msg_SetDenomPairTakerFee_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSetDenomPairTakerFee) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SetDenomPairTakerFee(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.poolmanager.v1beta1.Msg/SetDenomPairTakerFee", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SetDenomPairTakerFee(ctx, req.(*MsgSetDenomPairTakerFee)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "osmosis.poolmanager.v1beta1.Msg", HandlerType: (*MsgServer)(nil), @@ -685,6 +881,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SplitRouteSwapExactAmountOut", Handler: _Msg_SplitRouteSwapExactAmountOut_Handler, }, + { + MethodName: "SetDenomPairTakerFee", + Handler: _Msg_SetDenomPairTakerFee_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "osmosis/poolmanager/v1beta1/tx.proto", @@ -1072,6 +1272,130 @@ func (m *MsgSplitRouteSwapExactAmountOutResponse) MarshalToSizedBuffer(dAtA []by return len(dAtA) - i, nil } +func (m *MsgSetDenomPairTakerFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetDenomPairTakerFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDenomPairTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DenomPairTakerFee) > 0 { + for iNdEx := len(m.DenomPairTakerFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DenomPairTakerFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSetDenomPairTakerFeeResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSetDenomPairTakerFeeResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSetDenomPairTakerFeeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Success { + i-- + if m.Success { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *DenomPairTakerFee) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DenomPairTakerFee) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DenomPairTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size := m.TakerFee.Size() + i -= size + if _, err := m.TakerFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.Denom_1) > 0 { + i -= len(m.Denom_1) + copy(dAtA[i:], m.Denom_1) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom_1))) + i-- + dAtA[i] = 0x12 + } + if len(m.Denom_0) > 0 { + i -= len(m.Denom_0) + copy(dAtA[i:], m.Denom_0) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom_0))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1223,6 +1547,56 @@ func (m *MsgSplitRouteSwapExactAmountOutResponse) Size() (n int) { return n } +func (m *MsgSetDenomPairTakerFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.DenomPairTakerFee) > 0 { + for _, e := range m.DenomPairTakerFee { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSetDenomPairTakerFeeResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Success { + n += 2 + } + return n +} + +func (m *DenomPairTakerFee) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Denom_0) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Denom_1) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.TakerFee.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2295,6 +2669,340 @@ func (m *MsgSplitRouteSwapExactAmountOutResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSetDenomPairTakerFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetDenomPairTakerFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetDenomPairTakerFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomPairTakerFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomPairTakerFee = append(m.DenomPairTakerFee, DenomPairTakerFee{}) + if err := m.DenomPairTakerFee[len(m.DenomPairTakerFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgSetDenomPairTakerFeeResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgSetDenomPairTakerFeeResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSetDenomPairTakerFeeResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Success", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.Success = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *DenomPairTakerFee) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DenomPairTakerFee: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DenomPairTakerFee: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom_0", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom_0 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom_1", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom_1 = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TakerFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.TakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 25ad6995745..d263e52c1a3 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -63,7 +63,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // Non-native fee collector for community pool get swapped entirely into denom specified in the pool manager params. poolManagerParams := k.poolManager.GetParams(ctx) - denomToSwapTo := poolManagerParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo + denomToSwapTo := poolManagerParams.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo nonNativeFeeCollectorForCommunityPoolAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForCommunityPoolName) nonNativeFeeCollectorForCommunityPoolBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForCommunityPoolAddr) From f96efbf4a3bea3846703cca7de27c2a1a9ec128d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 22:32:32 -0500 Subject: [PATCH 31/83] use real addresses --- x/poolmanager/keeper_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index aca2fa768d4..104f3001bb8 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -29,7 +29,7 @@ var ( StakingRewards: sdk.MustNewDecFromStr("0.2"), CommunityPool: sdk.MustNewDecFromStr("0.8"), } - testAdminAddresses = []string{"osmo1qnpk2xwq6q5s6zj4qz4z2s6qz4z2s6qz4z2s6q"} + testAdminAddresses = []string{"osmo106x8q2nv7xsg7qrec2zgdf3vvq0t3gn49zvaha", "osmo105l5r3rjtynn7lg362r2m9hkpfvmgmjtkglsn9"} testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" testAuthorizedQuoteDenoms = []string{"uosmo", "uion", "uatom"} From 7e2bcf40219a5a21cb2ef11a3710eb1b98754be5 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 21 Aug 2023 23:04:44 -0500 Subject: [PATCH 32/83] add gov prop for denom pair taker fee update --- app/keepers/keepers.go | 3 +- proto/osmosis/poolmanager/v1beta1/gov.proto | 18 + x/poolmanager/gov.go | 30 ++ x/poolmanager/types/gov.go | 88 +++++ x/poolmanager/types/gov.pb.go | 416 ++++++++++++++++++++ 5 files changed, 554 insertions(+), 1 deletion(-) create mode 100644 proto/osmosis/poolmanager/v1beta1/gov.proto create mode 100644 x/poolmanager/gov.go create mode 100644 x/poolmanager/types/gov.go create mode 100644 x/poolmanager/types/gov.pb.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 235de53201d..1015a02dcde 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -507,7 +507,8 @@ func (appKeepers *AppKeepers) InitNormalKeepers( AddRoute(protorevtypes.RouterKey, protorev.NewProtoRevProposalHandler(*appKeepers.ProtoRevKeeper)). AddRoute(gammtypes.RouterKey, gamm.NewGammProposalHandler(*appKeepers.GAMMKeeper)). AddRoute(concentratedliquiditytypes.RouterKey, concentratedliquidity.NewConcentratedLiquidityProposalHandler(*appKeepers.ConcentratedLiquidityKeeper)). - AddRoute(cosmwasmpooltypes.RouterKey, cosmwasmpool.NewCosmWasmPoolProposalHandler(*appKeepers.CosmwasmPoolKeeper)) + AddRoute(cosmwasmpooltypes.RouterKey, cosmwasmpool.NewCosmWasmPoolProposalHandler(*appKeepers.CosmwasmPoolKeeper)). + AddRoute(poolmanagertypes.RouterKey, poolmanager.NewPoolManagerProposalHandler(*appKeepers.PoolManagerKeeper)) // The gov proposal types can be individually enabled if len(wasmEnabledProposals) != 0 { diff --git a/proto/osmosis/poolmanager/v1beta1/gov.proto b/proto/osmosis/poolmanager/v1beta1/gov.proto new file mode 100644 index 00000000000..7e783020c00 --- /dev/null +++ b/proto/osmosis/poolmanager/v1beta1/gov.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; +package osmosis.poolmanager.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/poolmanager/v1beta1/tx.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types"; + +message DenomPairTakerFeeProposal { + option (gogoproto.goproto_getters) = false; + option (gogoproto.goproto_stringer) = false; + + string title = 1; + string description = 2; + + repeated osmosis.poolmanager.v1beta1.DenomPairTakerFee denom_pair_taker_fee = + 3 [ (gogoproto.nullable) = false ]; +} diff --git a/x/poolmanager/gov.go b/x/poolmanager/gov.go new file mode 100644 index 00000000000..169155531d7 --- /dev/null +++ b/x/poolmanager/gov.go @@ -0,0 +1,30 @@ +package poolmanager + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" +) + +func (k Keeper) HandleDenomPairTakerFeeProposal(ctx sdk.Context, p *types.DenomPairTakerFeeProposal) error { + for _, denomPair := range p.DenomPairTakerFee { + k.SetDenomPairTakerFee(ctx, denomPair.Denom_0, denomPair.Denom_1, denomPair.TakerFee) + } + return nil +} + +func NewPoolManagerProposalHandler(k Keeper) govtypes.Handler { + return func(ctx sdk.Context, content govtypes.Content) error { + switch c := content.(type) { + case *types.DenomPairTakerFeeProposal: + return k.HandleDenomPairTakerFeeProposal(ctx, c) + + default: + return fmt.Errorf("unrecognized pool manager proposal content type: %T", c) + } + } +} diff --git a/x/poolmanager/types/gov.go b/x/poolmanager/types/gov.go new file mode 100644 index 00000000000..b807512616f --- /dev/null +++ b/x/poolmanager/types/gov.go @@ -0,0 +1,88 @@ +package types + +import ( + "fmt" + "strings" + + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + ProposalTypeDenomPairTakerFee = "DenomPairTakerFee" +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeDenomPairTakerFee) + govtypes.RegisterProposalTypeCodec(&DenomPairTakerFeeProposal{}, "osmosis/DenomPairTakerFeeProposal") +} + +var ( + _ govtypes.Content = &DenomPairTakerFeeProposal{} +) + +// NewDenomPairTakerFeeProposal returns a new instance of a denom pair taker fee proposal struct. +func NewDenomPairTakerFeeProposal(title, description string, records []DenomPairTakerFee) govtypes.Content { + return &DenomPairTakerFeeProposal{ + Title: title, + Description: description, + DenomPairTakerFee: records, + } +} + +func (p *DenomPairTakerFeeProposal) GetTitle() string { return p.Title } + +// GetDescription gets the description of the proposal +func (p *DenomPairTakerFeeProposal) GetDescription() string { return p.Description } + +// ProposalRoute returns the router key for the proposal +func (p *DenomPairTakerFeeProposal) ProposalRoute() string { return RouterKey } + +// ProposalType returns the type of the proposal +func (p *DenomPairTakerFeeProposal) ProposalType() string { + return ProposalTypeDenomPairTakerFee +} + +// ValidateBasic validates a governance proposal's abstract and basic contents +func (p *DenomPairTakerFeeProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(p) + if err != nil { + return err + } + + for _, record := range p.DenomPairTakerFee { + if record.Denom_0 == record.Denom_1 { + return fmt.Errorf("denom0 and denom1 must be different") + } + + if sdk.ValidateDenom(record.Denom_0) != nil { + return fmt.Errorf("denom0 is invalid: %s", sdk.ValidateDenom(record.Denom_0)) + } + + if sdk.ValidateDenom(record.Denom_1) != nil { + return fmt.Errorf("denom1 is invalid: %s", sdk.ValidateDenom(record.Denom_1)) + } + + takerFee := record.TakerFee + if takerFee.IsNegative() || takerFee.GTE(sdk.OneDec()) { + return fmt.Errorf("taker fee must be between 0 and 1: %s", takerFee.String()) + } + } + return nil +} + +// String returns a string containing the denom pair taker fee proposal. +func (p DenomPairTakerFeeProposal) String() string { + recordsStr := "" + for _, record := range p.DenomPairTakerFee { + recordsStr = recordsStr + fmt.Sprintf("(Denom0: %s, Denom1: %s, TakerFee: %s) ", record.Denom_0, record.Denom_1, record.TakerFee.String()) + } + + var b strings.Builder + b.WriteString(fmt.Sprintf(`Denom Pair Taker Fee Proposal: +Title: %s +Description: %s +Records: %s +`, p.Title, p.Description, recordsStr)) + return b.String() +} diff --git a/x/poolmanager/types/gov.pb.go b/x/poolmanager/types/gov.pb.go new file mode 100644 index 00000000000..cf42c10c383 --- /dev/null +++ b/x/poolmanager/types/gov.pb.go @@ -0,0 +1,416 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/poolmanager/v1beta1/gov.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type DenomPairTakerFeeProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + DenomPairTakerFee []DenomPairTakerFee `protobuf:"bytes,3,rep,name=denom_pair_taker_fee,json=denomPairTakerFee,proto3" json:"denom_pair_taker_fee"` +} + +func (m *DenomPairTakerFeeProposal) Reset() { *m = DenomPairTakerFeeProposal{} } +func (*DenomPairTakerFeeProposal) ProtoMessage() {} +func (*DenomPairTakerFeeProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_c95b3c1cda2a8632, []int{0} +} +func (m *DenomPairTakerFeeProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DenomPairTakerFeeProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DenomPairTakerFeeProposal.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DenomPairTakerFeeProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_DenomPairTakerFeeProposal.Merge(m, src) +} +func (m *DenomPairTakerFeeProposal) XXX_Size() int { + return m.Size() +} +func (m *DenomPairTakerFeeProposal) XXX_DiscardUnknown() { + xxx_messageInfo_DenomPairTakerFeeProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_DenomPairTakerFeeProposal proto.InternalMessageInfo + +func init() { + proto.RegisterType((*DenomPairTakerFeeProposal)(nil), "osmosis.poolmanager.v1beta1.DenomPairTakerFeeProposal") +} + +func init() { + proto.RegisterFile("osmosis/poolmanager/v1beta1/gov.proto", fileDescriptor_c95b3c1cda2a8632) +} + +var fileDescriptor_c95b3c1cda2a8632 = []byte{ + // 288 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0xcd, 0x2f, 0xce, 0xcd, + 0x2f, 0xce, 0x2c, 0xd6, 0x2f, 0xc8, 0xcf, 0xcf, 0xc9, 0x4d, 0xcc, 0x4b, 0x4c, 0x4f, 0x2d, 0xd2, + 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0xcf, 0x2f, 0xd3, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x92, 0x86, 0x2a, 0xd3, 0x43, 0x52, 0xa6, 0x07, 0x55, 0x26, 0x25, 0x92, 0x9e, 0x9f, + 0x9e, 0x0f, 0x56, 0xa7, 0x0f, 0x62, 0x41, 0xb4, 0x48, 0xa9, 0xe0, 0x33, 0xb9, 0xa4, 0x02, 0xa2, + 0x4a, 0xe9, 0x08, 0x23, 0x97, 0xa4, 0x4b, 0x6a, 0x5e, 0x7e, 0x6e, 0x40, 0x62, 0x66, 0x51, 0x48, + 0x62, 0x76, 0x6a, 0x91, 0x5b, 0x6a, 0x6a, 0x40, 0x51, 0x7e, 0x41, 0x7e, 0x71, 0x62, 0x8e, 0x90, + 0x08, 0x17, 0x6b, 0x49, 0x66, 0x49, 0x4e, 0xaa, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0x67, 0x10, 0x84, + 0x23, 0xa4, 0xc0, 0xc5, 0x9d, 0x92, 0x5a, 0x9c, 0x5c, 0x94, 0x59, 0x50, 0x92, 0x99, 0x9f, 0x27, + 0xc1, 0x04, 0x96, 0x43, 0x16, 0x12, 0x4a, 0xe5, 0x12, 0x49, 0x01, 0x19, 0x1a, 0x5f, 0x90, 0x98, + 0x59, 0x14, 0x5f, 0x02, 0x32, 0x36, 0x3e, 0x2d, 0x35, 0x55, 0x82, 0x59, 0x81, 0x59, 0x83, 0xdb, + 0x48, 0x4f, 0x0f, 0x8f, 0x6f, 0xf4, 0x30, 0x5c, 0xe3, 0xc4, 0x72, 0xe2, 0x9e, 0x3c, 0x43, 0x90, + 0x60, 0x0a, 0xba, 0x84, 0x15, 0x47, 0xc7, 0x02, 0x79, 0x86, 0x19, 0x0b, 0xe4, 0x19, 0x9c, 0x02, + 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, + 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3c, 0x3d, 0xb3, 0x24, 0xa3, + 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x6a, 0xad, 0x6e, 0x4e, 0x62, 0x52, 0x31, 0x8c, 0xa3, + 0x5f, 0x66, 0x68, 0xae, 0x5f, 0x81, 0x12, 0x48, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, + 0x00, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xe7, 0x75, 0xea, 0xa2, 0x01, 0x00, 0x00, +} + +func (m *DenomPairTakerFeeProposal) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DenomPairTakerFeeProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DenomPairTakerFeeProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DenomPairTakerFee) > 0 { + for iNdEx := len(m.DenomPairTakerFee) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.DenomPairTakerFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGov(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *DenomPairTakerFeeProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + if len(m.DenomPairTakerFee) > 0 { + for _, e := range m.DenomPairTakerFee { + l = e.Size() + n += 1 + l + sovGov(uint64(l)) + } + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *DenomPairTakerFeeProposal) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DenomPairTakerFeeProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DenomPairTakerFeeProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DenomPairTakerFee", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGov + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DenomPairTakerFee = append(m.DenomPairTakerFee, DenomPairTakerFee{}) + if err := m.DenomPairTakerFee[len(m.DenomPairTakerFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGov + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) From 71f1e9017074f72f3cdf8e84318d41620df7d507 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 11:47:53 -0500 Subject: [PATCH 33/83] clean --- app/upgrades/v18/upgrades.go | 7 + .../osmosis/poolmanager/v1beta1/genesis.proto | 9 - proto/osmosis/poolmanager/v1beta1/tx.proto | 4 +- tests/e2e/e2e_test.go | 2 + x/concentrated-liquidity/swaps.go | 1 - x/poolmanager/gov.go | 2 +- x/poolmanager/msg_server.go | 2 +- x/poolmanager/types/genesis.pb.go | 340 +++--------------- x/poolmanager/types/gov.go | 12 +- x/poolmanager/types/msgs.go | 4 +- x/poolmanager/types/tx.pb.go | 165 +++++---- 11 files changed, 157 insertions(+), 391 deletions(-) diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v18/upgrades.go index 598c409e9bc..a9602658fd9 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v18/upgrades.go @@ -24,6 +24,13 @@ func CreateUpgradeHandler( return nil, err } + // Move the current authorized quote denoms from the concentrated liquidity params to the pool manager params. + // This is needed since the pool manager needs access to these denoms to determine if the taker fee should + // be swapped into OSMO or not. + // TODO: In v19 upgrade handler, delete this param from the concentrated liquidity params. + currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) + defaultPoolManagerParams := poolmanagertypes.DefaultParams() + defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms keepers.PoolManagerKeeper.SetParams(ctx, poolmanagertypes.DefaultParams()) return migrations, nil diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 92f1383fad6..e59e2cf2c03 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -112,12 +112,3 @@ message TakerFeeDistributionPercentage { (gogoproto.nullable) = false ]; } - -// LiquidStakedTokenToUnderlyingDenom defines a pairing of a single natural -// denom with its corresponding LST denoms. -message LiquidStakedTokenToUnderlyingDenom { - repeated string liquid_staked_token_denoms = 1 - [ (gogoproto.moretags) = "yaml:\"liquid_staked_token_denoms\"" ]; - string underlying_token_denom = 2 - [ (gogoproto.moretags) = "yaml:\"underlying_token_denom\"" ]; -} \ No newline at end of file diff --git a/proto/osmosis/poolmanager/v1beta1/tx.proto b/proto/osmosis/poolmanager/v1beta1/tx.proto index 89a3d1ef1f4..14bf2634eb3 100644 --- a/proto/osmosis/poolmanager/v1beta1/tx.proto +++ b/proto/osmosis/poolmanager/v1beta1/tx.proto @@ -131,8 +131,8 @@ message MsgSetDenomPairTakerFee { message MsgSetDenomPairTakerFeeResponse { bool success = 1; } message DenomPairTakerFee { - string denom_0 = 1 [ (gogoproto.moretags) = "yaml:\"denom_0\"" ]; - string denom_1 = 2 [ (gogoproto.moretags) = "yaml:\"denom_1\"" ]; + string denom0 = 1 [ (gogoproto.moretags) = "yaml:\"denom0\"" ]; + string denom1 = 2 [ (gogoproto.moretags) = "yaml:\"denom1\"" ]; string taker_fee = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.moretags) = "yaml:\"taker_fee\"", diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 49001efcbec..d93fbbf700f 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -357,6 +357,8 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { address2 := chainABNode.CreateWalletAndFund("addr2", fundTokens, chainAB) address3 := chainABNode.CreateWalletAndFund("addr3", fundTokens, chainAB) + // When claiming rewards, a small portion of dust is forfeited and is redistributed to everyone. We must track the total + // liquidity across all positions (even if not active), in order to calculate how much to increase the reward growth global per share by. totalLiquidity := sdk.ZeroDec() // Create 2 positions for address1: overlap together, overlap with 2 address3 positions diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index 87b0686ef00..fb5f0a3a3ae 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -444,7 +444,6 @@ func (k Keeper) computeOutAmtGivenIn( // Add spread reward growth per share to the pool-global spread reward accumulator. spreadRewardGrowth := sdk.NewDecCoinFromDec(tokenInMin.Denom, swapState.globalSpreadRewardGrowthPerUnitLiquidity) - // fmt.Println("ADAM spreadRewardGrowth", spreadRewardGrowth) spreadRewardAccumulator.AddToAccumulator(sdk.NewDecCoins(spreadRewardGrowth)) // Coin amounts require int values diff --git a/x/poolmanager/gov.go b/x/poolmanager/gov.go index 169155531d7..eae1708d73a 100644 --- a/x/poolmanager/gov.go +++ b/x/poolmanager/gov.go @@ -12,7 +12,7 @@ import ( func (k Keeper) HandleDenomPairTakerFeeProposal(ctx sdk.Context, p *types.DenomPairTakerFeeProposal) error { for _, denomPair := range p.DenomPairTakerFee { - k.SetDenomPairTakerFee(ctx, denomPair.Denom_0, denomPair.Denom_1, denomPair.TakerFee) + k.SetDenomPairTakerFee(ctx, denomPair.Denom0, denomPair.Denom1, denomPair.TakerFee) } return nil } diff --git a/x/poolmanager/msg_server.go b/x/poolmanager/msg_server.go index 39b1255eac3..717619dad0b 100644 --- a/x/poolmanager/msg_server.go +++ b/x/poolmanager/msg_server.go @@ -124,7 +124,7 @@ func (server msgServer) SetDenomPairTakerFee(goCtx context.Context, msg *types.M ctx := sdk.UnwrapSDKContext(goCtx) for _, denomPair := range msg.DenomPairTakerFee { - err := server.keeper.SenderValidationSetDenomPairTakerFee(ctx, msg.Sender, denomPair.Denom_0, denomPair.Denom_1, denomPair.TakerFee) + err := server.keeper.SenderValidationSetDenomPairTakerFee(ctx, msg.Sender, denomPair.Denom0, denomPair.Denom1, denomPair.TakerFee) if err != nil { return nil, err } diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index ed7d2398f70..552954565a3 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -300,66 +300,11 @@ func (m *TakerFeeDistributionPercentage) XXX_DiscardUnknown() { var xxx_messageInfo_TakerFeeDistributionPercentage proto.InternalMessageInfo -// LiquidStakedTokenToUnderlyingDenom defines a pairing of a single natural -// denom with its corresponding LST denoms. -type LiquidStakedTokenToUnderlyingDenom struct { - LiquidStakedTokenDenoms []string `protobuf:"bytes,1,rep,name=liquid_staked_token_denoms,json=liquidStakedTokenDenoms,proto3" json:"liquid_staked_token_denoms,omitempty" yaml:"liquid_staked_token_denoms"` - UnderlyingTokenDenom string `protobuf:"bytes,2,opt,name=underlying_token_denom,json=underlyingTokenDenom,proto3" json:"underlying_token_denom,omitempty" yaml:"underlying_token_denom"` -} - -func (m *LiquidStakedTokenToUnderlyingDenom) Reset() { *m = LiquidStakedTokenToUnderlyingDenom{} } -func (m *LiquidStakedTokenToUnderlyingDenom) String() string { return proto.CompactTextString(m) } -func (*LiquidStakedTokenToUnderlyingDenom) ProtoMessage() {} -func (*LiquidStakedTokenToUnderlyingDenom) Descriptor() ([]byte, []int) { - return fileDescriptor_aa099d9fbdf68b35, []int{4} -} -func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Merge(src proto.Message) { - xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.Merge(m, src) -} -func (m *LiquidStakedTokenToUnderlyingDenom) XXX_Size() int { - return m.Size() -} -func (m *LiquidStakedTokenToUnderlyingDenom) XXX_DiscardUnknown() { - xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom.DiscardUnknown(m) -} - -var xxx_messageInfo_LiquidStakedTokenToUnderlyingDenom proto.InternalMessageInfo - -func (m *LiquidStakedTokenToUnderlyingDenom) GetLiquidStakedTokenDenoms() []string { - if m != nil { - return m.LiquidStakedTokenDenoms - } - return nil -} - -func (m *LiquidStakedTokenToUnderlyingDenom) GetUnderlyingTokenDenom() string { - if m != nil { - return m.UnderlyingTokenDenom - } - return "" -} - func init() { proto.RegisterType((*Params)(nil), "osmosis.poolmanager.v1beta1.Params") proto.RegisterType((*GenesisState)(nil), "osmosis.poolmanager.v1beta1.GenesisState") proto.RegisterType((*TakerFeeParams)(nil), "osmosis.poolmanager.v1beta1.TakerFeeParams") proto.RegisterType((*TakerFeeDistributionPercentage)(nil), "osmosis.poolmanager.v1beta1.TakerFeeDistributionPercentage") - proto.RegisterType((*LiquidStakedTokenToUnderlyingDenom)(nil), "osmosis.poolmanager.v1beta1.LiquidStakedTokenToUnderlyingDenom") } func init() { @@ -367,65 +312,60 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 925 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x36, 0x6d, 0x57, 0x40, 0xd6, 0xa9, 0xd4, 0x2c, 0x9c, 0x98, 0xb1, 0x51, 0x51, 0x61, 0xd0, - 0x42, 0x45, 0x11, 0x12, 0x76, 0x81, 0x06, 0x68, 0xd1, 0x83, 0x65, 0x21, 0x69, 0x81, 0x34, 0x71, - 0x68, 0x15, 0x01, 0x72, 0x59, 0x2c, 0xc5, 0x31, 0x4d, 0x98, 0xdc, 0x95, 0xb9, 0x4b, 0x3b, 0xea, - 0xb5, 0x2f, 0x50, 0xa0, 0xd7, 0x9e, 0x7b, 0xe8, 0xad, 0xb7, 0x3e, 0x40, 0x0f, 0x39, 0xe6, 0x58, - 0xf4, 0xc0, 0xb6, 0xf2, 0x1b, 0xe8, 0x09, 0x0a, 0xee, 0x52, 0x7f, 0x8e, 0x25, 0xd8, 0xcd, 0xc9, - 0xe6, 0xcc, 0xf7, 0x7d, 0x33, 0xf3, 0x71, 0x86, 0x42, 0x9f, 0x70, 0x91, 0x70, 0x11, 0x09, 0xb7, - 0xc7, 0x79, 0x9c, 0x50, 0x46, 0x43, 0x48, 0xdd, 0xd3, 0x6d, 0x1f, 0x24, 0xdd, 0x76, 0x43, 0x60, - 0x20, 0x22, 0xe1, 0xf4, 0x52, 0x2e, 0x39, 0xde, 0x2a, 0xa1, 0xce, 0x14, 0xd4, 0x29, 0xa1, 0x9b, - 0xeb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x36, 0x80, 0x4f, 0xd1, 0xba, - 0x90, 0xd4, 0x8f, 0x41, 0x9c, 0xd1, 0xde, 0x54, 0xc5, 0x65, 0x55, 0xb1, 0x7d, 0xed, 0x8a, 0xf8, - 0x60, 0xac, 0x36, 0x2e, 0x8a, 0xc5, 0x5b, 0x31, 0xfc, 0xb3, 0x81, 0xd4, 0x17, 0x61, 0x52, 0x92, - 0x04, 0x91, 0x90, 0x69, 0xe4, 0x67, 0xc5, 0xde, 0x9a, 0x2b, 0xea, 0x1d, 0x7d, 0x79, 0xa5, 0x05, - 0x6d, 0x4f, 0x11, 0xf7, 0x21, 0xed, 0x02, 0x93, 0x34, 0x84, 0x56, 0xa3, 0x68, 0x7e, 0x90, 0x5b, - 0xe6, 0x33, 0x91, 0xf0, 0xcb, 0xb0, 0x9e, 0xc9, 0xe7, 0x64, 0xf0, 0x2f, 0x06, 0xb2, 0x18, 0x67, - 0x64, 0x51, 0x8b, 0xab, 0xef, 0xde, 0xe2, 0xfd, 0xb2, 0xc5, 0xad, 0xa7, 0x9c, 0xcd, 0xed, 0x72, - 0x8b, 0xcd, 0x4f, 0xe2, 0x3d, 0x54, 0xa3, 0x41, 0x12, 0x31, 0x42, 0x83, 0x20, 0x05, 0x21, 0x40, - 0x98, 0xef, 0xa9, 0xe3, 0xda, 0x1c, 0xe6, 0xd6, 0x9d, 0xf2, 0xb8, 0x66, 0x01, 0xb6, 0x57, 0x55, - 0x91, 0xdd, 0x51, 0x00, 0xff, 0x66, 0xa0, 0xcf, 0xbb, 0x3c, 0x49, 0x32, 0x16, 0xc9, 0xbe, 0x3e, - 0x21, 0x75, 0x7f, 0x44, 0x72, 0xa2, 0xf6, 0xa2, 0xb0, 0xe2, 0xec, 0x28, 0x92, 0x10, 0x47, 0x42, - 0x42, 0x40, 0xa8, 0x10, 0x20, 0x05, 0x91, 0xdc, 0xac, 0xe8, 0xcd, 0x1c, 0xe6, 0xd6, 0x57, 0xba, - 0xd8, 0xff, 0xd3, 0xb1, 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 0xfa, 0xd2, 0x9b, 0xf3, 0xfa, 0xd2, 0x9f, 0xe7, - 0xf5, 0xa5, 0x97, 0x0f, 0xa7, 0xdc, 0x2c, 0xaf, 0xf0, 0x41, 0x4c, 0x7d, 0x31, 0x7a, 0x70, 0x4f, - 0xb7, 0x1f, 0xba, 0xaf, 0x66, 0x7e, 0xc8, 0x95, 0xc5, 0x7e, 0x45, 0xfd, 0x74, 0x7f, 0xf6, 0x5f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xae, 0x09, 0xb8, 0x69, 0xc0, 0x08, 0x00, 0x00, + // 837 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, + 0x14, 0x8f, 0x93, 0xb0, 0x52, 0x27, 0x65, 0x97, 0x8e, 0x5a, 0xea, 0x26, 0x92, 0xbd, 0x72, 0x25, + 0xb4, 0x08, 0xd5, 0x56, 0x82, 0x44, 0x25, 0x10, 0x87, 0x6c, 0x56, 0x2d, 0x48, 0xd0, 0xa6, 0x4e, + 0x24, 0xa4, 0x5e, 0x46, 0xb3, 0xeb, 0x17, 0xc7, 0x8a, 0x3d, 0xb3, 0xf5, 0x8c, 0x93, 0x86, 0x2b, + 0x5f, 0x00, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xb8, 0xf1, 0x01, 0x38, 0xf4, 0xd8, 0x23, 0xe2, 0x60, + 0xd0, 0xe6, 0x1b, 0xec, 0x27, 0x40, 0xf3, 0x67, 0x37, 0x71, 0xda, 0xac, 0x1a, 0x38, 0xed, 0xce, + 0x7b, 0xef, 0xf7, 0xfb, 0xbd, 0xf7, 0xe6, 0x3d, 0x0f, 0xfa, 0x98, 0x8b, 0x82, 0x8b, 0x4c, 0x44, + 0x63, 0xce, 0xf3, 0x82, 0x32, 0x9a, 0x42, 0x19, 0x1d, 0x6f, 0x0e, 0x41, 0xd2, 0xcd,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1d, 0x66, 0x61, 0x00, 0xa3, + 0x49, 0xed, 0x77, 0x06, 0x86, 0x6a, 0xa6, 0x11, 0x77, 0x92, 0xa6, 0x01, 0x1f, 0xa3, 0xdb, 0x42, + 0xd2, 0x61, 0x0e, 0xe2, 0x84, 0x8e, 0x2f, 0x28, 0x2e, 0x6b, 0xc5, 0xc1, 0xb5, 0x15, 0xf1, 0xde, + 0x9c, 0x6d, 0x2e, 0x8a, 0xc5, 0x1b, 0x36, 0xfc, 0xb3, 0x83, 0xf4, 0x17, 0xe1, 0x5c, 0x92, 0x24, + 0x99, 0x90, 0x65, 0x36, 0xac, 0xd4, 0xdc, 0xba, 0x2b, 0xfa, 0x8e, 0xbe, 0x78, 0xa7, 0x01, 0x1d, + 0x5c, 0x00, 0xee, 0x42, 0x39, 0x02, 0x26, 0x69, 0x0a, 0xfd, 0xae, 0x4a, 0x7e, 0x52, 0xfb, 0xee, + 0x53, 0x51, 0xf0, 0xb7, 0xc5, 0xc6, 0x2e, 0xbf, 0xc2, 0x83, 0x7f, 0x71, 0x90, 0xcf, 0x38, 0x23, + 0x8b, 0x52, 0x5c, 0xfd, 0xff, 0x29, 0xde, 0xb7, 0x29, 0x6e, 0x3c, 0xe1, 0xec, 0xca, 0x2c, 0x37, + 0xd8, 0xd5, 0x4e, 0xbc, 0x83, 0x3a, 0x34, 0x29, 0x32, 0x46, 0x68, 0x92, 0x94, 0x20, 0x04, 0x08, + 0xf7, 0x3d, 0xbd, 0x5c, 0xeb, 0xd3, 0xda, 0xff, 0xd0, 0x2e, 0x57, 0x33, 0x20, 0x88, 0xdb, 0xda, + 0xb2, 0x3d, 0x33, 0xe0, 0xdf, 0x1c, 0xf4, 0xd9, 0x88, 0x17, 0x45, 0xc5, 0x32, 0x79, 0x6a, 0x56, + 0x48, 0xef, 0x1f, 0x91, 0x9c, 0xe8, 0xb9, 0x50, 0xad, 0x38, 0x39, 0xcc, 0x24, 0xe4, 0x99, 0x90, + 0x90, 0x10, 0x2a, 0x04, 0x48, 0x41, 0x24, 0x77, 0x5b, 0x66, 0x32, 0xa7, 0xb5, 0xff, 0xa5, 0x11, + 0xfb, 0x6f, 0x3c, 0x41, 0x1c, 0xce, 0x81, 0x6a, 0x5f, 0xf5, 0x9a, 0xef, 0xf3, 0xbd, 0x13, 0x3a, + 0x7e, 0xc2, 0xd9, 0x77, 0xe7, 0x90, 0x6d, 0x8d, 0xd8, 0xe7, 0xc1, 0x0f, 0xcb, 0xc8, 0x5b, 0xdc, + 0x5d, 0xfc, 0x02, 0x75, 0x84, 0xa4, 0x47, 0x19, 0x4b, 0x49, 0x09, 0x27, 0xb4, 0x4c, 0x84, 0x5d, + 0xa4, 0xaf, 0xae, 0x37, 0xd6, 0xe7, 0x9d, 0xbc, 0x44, 0x17, 0xc4, 0x6d, 0x6b, 0x89, 0x8d, 0x01, + 0x33, 0xd4, 0x6e, 0x36, 0xc0, 0x2e, 0xd2, 0xe3, 0x6b, 0x2b, 0xde, 0x79, 0x5b, 0x3b, 0x83, 0xf8, + 0xfd, 0x46, 0x9b, 0xfa, 0xcf, 0x5e, 0x4d, 0x3c, 0xe7, 0xf5, 0xc4, 0x73, 0xfe, 0x99, 0x78, 0xce, + 0x8f, 0x67, 0xde, 0xd2, 0xeb, 0x33, 0x6f, 0xe9, 0xcf, 0x33, 0x6f, 0xe9, 0xf9, 0xc3, 0x0b, 0x4a, + 0x76, 0x42, 0x1f, 0xe4, 0x74, 0x28, 0x66, 0x87, 0xe8, 0x78, 0xf3, 0x61, 0xf4, 0xb2, 0xf1, 0xc8, + 0x69, 0xf9, 0x61, 0x4b, 0x3f, 0x6b, 0x9f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x99, 0x6e, + 0xb3, 0xdc, 0x07, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -658,45 +598,6 @@ func (m *TakerFeeDistributionPercentage) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *LiquidStakedTokenToUnderlyingDenom) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *LiquidStakedTokenToUnderlyingDenom) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *LiquidStakedTokenToUnderlyingDenom) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.UnderlyingTokenDenom) > 0 { - i -= len(m.UnderlyingTokenDenom) - copy(dAtA[i:], m.UnderlyingTokenDenom) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.UnderlyingTokenDenom))) - i-- - dAtA[i] = 0x12 - } - if len(m.LiquidStakedTokenDenoms) > 0 { - for iNdEx := len(m.LiquidStakedTokenDenoms) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.LiquidStakedTokenDenoms[iNdEx]) - copy(dAtA[i:], m.LiquidStakedTokenDenoms[iNdEx]) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.LiquidStakedTokenDenoms[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { offset -= sovGenesis(v) base := offset @@ -791,25 +692,6 @@ func (m *TakerFeeDistributionPercentage) Size() (n int) { return n } -func (m *LiquidStakedTokenToUnderlyingDenom) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.LiquidStakedTokenDenoms) > 0 { - for _, s := range m.LiquidStakedTokenDenoms { - l = len(s) - n += 1 + l + sovGenesis(uint64(l)) - } - } - l = len(m.UnderlyingTokenDenom) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - return n -} - func sovGenesis(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1467,120 +1349,6 @@ func (m *TakerFeeDistributionPercentage) Unmarshal(dAtA []byte) error { } return nil } -func (m *LiquidStakedTokenToUnderlyingDenom) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: LiquidStakedTokenToUnderlyingDenom: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: LiquidStakedTokenToUnderlyingDenom: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LiquidStakedTokenDenoms", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.LiquidStakedTokenDenoms = append(m.LiquidStakedTokenDenoms, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UnderlyingTokenDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UnderlyingTokenDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipGenesis(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/poolmanager/types/gov.go b/x/poolmanager/types/gov.go index b807512616f..2a743611055 100644 --- a/x/poolmanager/types/gov.go +++ b/x/poolmanager/types/gov.go @@ -51,16 +51,16 @@ func (p *DenomPairTakerFeeProposal) ValidateBasic() error { } for _, record := range p.DenomPairTakerFee { - if record.Denom_0 == record.Denom_1 { + if record.Denom0 == record.Denom1 { return fmt.Errorf("denom0 and denom1 must be different") } - if sdk.ValidateDenom(record.Denom_0) != nil { - return fmt.Errorf("denom0 is invalid: %s", sdk.ValidateDenom(record.Denom_0)) + if sdk.ValidateDenom(record.Denom0) != nil { + return fmt.Errorf("denom0 is invalid: %s", sdk.ValidateDenom(record.Denom0)) } - if sdk.ValidateDenom(record.Denom_1) != nil { - return fmt.Errorf("denom1 is invalid: %s", sdk.ValidateDenom(record.Denom_1)) + if sdk.ValidateDenom(record.Denom1) != nil { + return fmt.Errorf("denom1 is invalid: %s", sdk.ValidateDenom(record.Denom1)) } takerFee := record.TakerFee @@ -75,7 +75,7 @@ func (p *DenomPairTakerFeeProposal) ValidateBasic() error { func (p DenomPairTakerFeeProposal) String() string { recordsStr := "" for _, record := range p.DenomPairTakerFee { - recordsStr = recordsStr + fmt.Sprintf("(Denom0: %s, Denom1: %s, TakerFee: %s) ", record.Denom_0, record.Denom_1, record.TakerFee.String()) + recordsStr = recordsStr + fmt.Sprintf("(Denom0: %s, Denom1: %s, TakerFee: %s) ", record.Denom0, record.Denom1, record.TakerFee.String()) } var b strings.Builder diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index 4895eb438e8..39919abd0a9 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -180,10 +180,10 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { } for _, denomPair := range msg.DenomPairTakerFee { - if err := sdk.ValidateDenom(denomPair.Denom_0); err != nil { + if err := sdk.ValidateDenom(denomPair.Denom0); err != nil { return err } - if err := sdk.ValidateDenom(denomPair.Denom_1); err != nil { + if err := sdk.ValidateDenom(denomPair.Denom1); err != nil { return err } if denomPair.TakerFee.IsNegative() { diff --git a/x/poolmanager/types/tx.pb.go b/x/poolmanager/types/tx.pb.go index 17dc553b416..36f25b578a4 100644 --- a/x/poolmanager/types/tx.pb.go +++ b/x/poolmanager/types/tx.pb.go @@ -529,8 +529,8 @@ func (m *MsgSetDenomPairTakerFeeResponse) GetSuccess() bool { } type DenomPairTakerFee struct { - Denom_0 string `protobuf:"bytes,1,opt,name=denom_0,json=denom0,proto3" json:"denom_0,omitempty" yaml:"denom_0"` - Denom_1 string `protobuf:"bytes,2,opt,name=denom_1,json=denom1,proto3" json:"denom_1,omitempty" yaml:"denom_1"` + Denom0 string `protobuf:"bytes,1,opt,name=denom0,proto3" json:"denom0,omitempty" yaml:"denom0"` + Denom1 string `protobuf:"bytes,2,opt,name=denom1,proto3" json:"denom1,omitempty" yaml:"denom1"` TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` } @@ -567,16 +567,16 @@ func (m *DenomPairTakerFee) XXX_DiscardUnknown() { var xxx_messageInfo_DenomPairTakerFee proto.InternalMessageInfo -func (m *DenomPairTakerFee) GetDenom_0() string { +func (m *DenomPairTakerFee) GetDenom0() string { if m != nil { - return m.Denom_0 + return m.Denom0 } return "" } -func (m *DenomPairTakerFee) GetDenom_1() string { +func (m *DenomPairTakerFee) GetDenom1() string { if m != nil { - return m.Denom_1 + return m.Denom1 } return "" } @@ -600,70 +600,69 @@ func init() { } var fileDescriptor_acd130b4825d67dc = []byte{ - // 1001 bytes of a gzipped FileDescriptorProto + // 990 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x97, 0x5d, 0x6f, 0xdb, 0x54, - 0x18, 0xc7, 0x7b, 0x96, 0xd2, 0x97, 0x33, 0xd6, 0x35, 0x26, 0xa3, 0x59, 0x3a, 0x92, 0xca, 0x9b, - 0x46, 0x0a, 0xd8, 0x6e, 0xba, 0x49, 0x13, 0xd9, 0x24, 0x44, 0x56, 0x10, 0x95, 0x16, 0x65, 0x33, - 0x5c, 0x71, 0x63, 0x39, 0xe9, 0x21, 0x58, 0xad, 0xcf, 0xb1, 0x72, 0x8e, 0xb7, 0x4c, 0x48, 0x48, - 0x48, 0xbb, 0x61, 0x02, 0x69, 0x88, 0x4b, 0x84, 0x90, 0xf8, 0x04, 0x7c, 0x8c, 0x5d, 0xa1, 0x5d, - 0x22, 0x2e, 0x22, 0xd4, 0x22, 0x71, 0x9f, 0x0f, 0x80, 0xd0, 0x79, 0xb1, 0x93, 0xba, 0x6e, 0x1a, - 0xb7, 0x12, 0xbd, 0xd9, 0x6c, 0xe7, 0x79, 0xfd, 0x3f, 0xbf, 0xf3, 0xe8, 0x14, 0xde, 0x20, 0xd4, - 0x27, 0xd4, 0xa3, 0x56, 0x40, 0xc8, 0x9e, 0xef, 0x62, 0xb7, 0x8b, 0x7a, 0xd6, 0xe3, 0x5a, 0x1b, - 0x31, 0xb7, 0x66, 0xb1, 0xbe, 0x19, 0xf4, 0x08, 0x23, 0xda, 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e1, 0x3d, 0x8f, 0x11, 0xf2, 0x33, 0x80, 0x37, 0x27, 0xcf, 0xe2, 0x7c, 0x59, - 0x79, 0x91, 0x83, 0x57, 0x8e, 0x12, 0xdc, 0x0a, 0x59, 0x16, 0x44, 0x9a, 0x09, 0x44, 0xac, 0x29, - 0x11, 0x69, 0x85, 0xa9, 0x78, 0x7c, 0x05, 0xdf, 0x88, 0xc7, 0xef, 0xbb, 0xfd, 0x48, 0x0b, 0xc9, - 0xc8, 0x83, 0xcc, 0x5a, 0x94, 0x12, 0x44, 0x8d, 0x42, 0xea, 0xf6, 0xb2, 0xc2, 0xaa, 0xe9, 0xf6, - 0x65, 0x49, 0xda, 0x43, 0xb8, 0x18, 0xab, 0x26, 0x78, 0x9a, 0xb8, 0xd1, 0x8a, 0x6a, 0xa3, 0x2d, - 0x27, 0xf4, 0xd6, 0xed, 0x85, 0x48, 0xe8, 0xba, 0xc9, 0x61, 0x59, 0x9f, 0x6e, 0xa7, 0x70, 0xd7, - 0x1f, 0x00, 0x7c, 0x2b, 0x75, 0x24, 0x31, 0x29, 0x01, 0xbc, 0x1c, 0x77, 0x73, 0x08, 0x94, 0x4f, - 0x32, 0x8b, 0xf3, 0x66, 0x42, 0x9c, 0x48, 0x98, 0x4b, 0x4a, 0x18, 0x85, 0xc9, 0x77, 0x39, 0x58, - 0x99, 0x84, 0x71, 0x46, 0x60, 0xec, 0x04, 0x30, 0xb7, 0xa7, 0x07, 0xe6, 0xd8, 0xa5, 0xd2, 0x88, - 0x44, 0xe1, 0xb8, 0x8f, 0x6f, 0x95, 0x52, 0xb2, 0xcd, 0xd8, 0x20, 0x6a, 0xb3, 0x15, 0x32, 0xb9, - 0x57, 0x8e, 0x21, 0x6f, 0xf6, 0xff, 0x20, 0xaf, 0xbe, 0xce, 0x39, 0xb9, 0x71, 0xe2, 0x52, 0xe1, - 0x88, 0xfc, 0x04, 0xe0, 0xdb, 0x27, 0x8c, 0xe3, 0x1c, 0x61, 0xf9, 0x17, 0x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xf5, 0x71, + 0x29, 0xea, 0x43, 0xa6, 0xd7, 0xbf, 0x2d, 0xc0, 0x2a, 0xaf, 0x2a, 0xd8, 0xf5, 0x98, 0x98, 0xd9, + 0xa9, 0x78, 0x79, 0x94, 0xe0, 0xe5, 0xd6, 0xcc, 0xbc, 0x8c, 0x0b, 0x48, 0x40, 0xf3, 0x01, 0xbc, + 0x14, 0xcd, 0xde, 0xd9, 0x46, 0x98, 0xf8, 0x02, 0x9d, 0xa5, 0xd6, 0xd5, 0x83, 0x51, 0xed, 0xca, + 0x61, 0x36, 0xe4, 0xf7, 0xba, 0xfd, 0xba, 0x22, 0x64, 0x93, 0x3f, 0x9e, 0x39, 0x26, 0x75, 0x8e, + 0xc9, 0xf5, 0x54, 0x4c, 0x78, 0xcf, 0x13, 0x84, 0xfc, 0x0c, 0xe0, 0xcd, 0xec, 0x59, 0x9c, 0x2d, + 0x2b, 0x2f, 0x0a, 0xf0, 0xca, 0x51, 0x82, 0x3b, 0x21, 0xcb, 0x83, 0x48, 0x3b, 0x81, 0x88, 0x35, + 0x23, 0x22, 0x9d, 0x30, 0x15, 0x8f, 0xaf, 0xe0, 0x1b, 0xf1, 0xf8, 0x7d, 0x77, 0x18, 0x69, 0x21, + 0x19, 0x79, 0x90, 0x5b, 0x8b, 0x4a, 0x82, 0xa8, 0x71, 0x48, 0xdd, 0x5e, 0x56, 0x58, 0xb5, 0xdd, + 0xa1, 0x2c, 0x49, 0x7b, 0x08, 0x97, 0x62, 0xd5, 0x04, 0x4f, 0x99, 0x1b, 0xad, 0xac, 0x36, 0xda, + 0x72, 0x42, 0x6f, 0xdd, 0x5e, 0x8c, 0x84, 0x6e, 0x9a, 0x1c, 0x96, 0xf5, 0xd9, 0x76, 0x0a, 0x77, + 0xfd, 0x01, 0xc0, 0xb7, 0x52, 0x47, 0x12, 0x93, 0x12, 0xc0, 0xcb, 0x71, 0x37, 0x87, 0x40, 0xf9, + 0x24, 0xb7, 0x38, 0x6f, 0x26, 0xc4, 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x00, 0x00, 0xff, 0xff, 0xb0, 0xbe, 0xa1, 0xd8, 0xad, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1379,17 +1378,17 @@ func (m *DenomPairTakerFee) MarshalToSizedBuffer(dAtA []byte) (int, error) { } i-- dAtA[i] = 0x1a - if len(m.Denom_1) > 0 { - i -= len(m.Denom_1) - copy(dAtA[i:], m.Denom_1) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom_1))) + if len(m.Denom1) > 0 { + i -= len(m.Denom1) + copy(dAtA[i:], m.Denom1) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom1))) i-- dAtA[i] = 0x12 } - if len(m.Denom_0) > 0 { - i -= len(m.Denom_0) - copy(dAtA[i:], m.Denom_0) - i = encodeVarintTx(dAtA, i, uint64(len(m.Denom_0))) + if len(m.Denom0) > 0 { + i -= len(m.Denom0) + copy(dAtA[i:], m.Denom0) + i = encodeVarintTx(dAtA, i, uint64(len(m.Denom0))) i-- dAtA[i] = 0xa } @@ -1584,11 +1583,11 @@ func (m *DenomPairTakerFee) Size() (n int) { } var l int _ = l - l = len(m.Denom_0) + l = len(m.Denom0) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Denom_1) + l = len(m.Denom1) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -2886,7 +2885,7 @@ func (m *DenomPairTakerFee) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom_0", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom0", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2914,11 +2913,11 @@ func (m *DenomPairTakerFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom_0 = string(dAtA[iNdEx:postIndex]) + m.Denom0 = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Denom_1", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Denom1", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2946,7 +2945,7 @@ func (m *DenomPairTakerFee) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Denom_1 = string(dAtA[iNdEx:postIndex]) + m.Denom1 = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { From 1bd9f154b662947c794f24c71609e74505d142f0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 11:51:34 -0500 Subject: [PATCH 34/83] move logic to its own taker_fee.go file --- x/poolmanager/create_pool.go | 62 ------------ x/poolmanager/router.go | 107 --------------------- x/poolmanager/taker_fee.go | 181 +++++++++++++++++++++++++++++++++++ 3 files changed, 181 insertions(+), 169 deletions(-) create mode 100644 x/poolmanager/taker_fee.go diff --git a/x/poolmanager/create_pool.go b/x/poolmanager/create_pool.go index 4a3a539f0a6..dfebdb41d97 100644 --- a/x/poolmanager/create_pool.go +++ b/x/poolmanager/create_pool.go @@ -216,65 +216,3 @@ func parsePoolRouteWithKey(key []byte, value []byte) (types.ModuleRoute, error) parsedValue.PoolId = poolId return parsedValue, nil } - -// SetDenomPairTakerFee sets the taker fee for the given trading pair. -// If the taker fee for this denom pair matches the default taker fee, then -// it is deleted from state. -func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { - store := ctx.KVStore(k.storeKey) - if takerFee.Equal(k.GetParams(ctx).TakerFeeParams.DefaultTakerFee) { - store.Delete(types.FormatDenomTradePairKey(denom0, denom1)) - return - } else { - osmoutils.MustSetDec(store, types.FormatDenomTradePairKey(denom0, denom1), takerFee) - } -} - -// SenderValidationSetDenomPairTakerFee sets the taker fee for the given trading pair iff the sender's address -// also exists in the pool manager taker fee admin address list. -func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee sdk.Dec) error { - adminAddresses := k.GetParams(ctx).TakerFeeParams.AdminAddresses - isAdmin := false - for _, admin := range adminAddresses { - if admin == sender { - isAdmin = true - break - } - } - if !isAdmin { - return fmt.Errorf("%s is not in the pool manager taker fee admin address list", sender) - } - - k.SetDenomPairTakerFee(ctx, denom0, denom1, takerFee) - - ctx.EventManager().EmitEvents(sdk.Events{ - sdk.NewEvent( - types.TypeMsgSetDenomPairTakerFee, - sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), - sdk.NewAttribute(sdk.AttributeKeySender, sender), - sdk.NewAttribute(types.AttributeKeyDenom0, denom0), - sdk.NewAttribute(types.AttributeKeyDenom1, denom1), - sdk.NewAttribute(types.AttributeKeyTakerFee, takerFee.String()), - ), - }) - - return nil -} - -// GetTradingPairTakerFee returns the taker fee for the given trading pair. -// If the trading pair does not exist, it returns the default taker fee. -func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) { - store := ctx.KVStore(k.storeKey) - key := types.FormatDenomTradePairKey(denom0, denom1) - - takerFee := &sdk.DecProto{} - found, err := osmoutils.Get(store, key, takerFee) - if err != nil { - return sdk.Dec{}, err - } - if !found { - return k.GetParams(ctx).TakerFeeParams.DefaultTakerFee, nil - } - - return takerFee.Dec, nil -} diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index c06f3f886a0..a633ed2248f 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -11,7 +11,6 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" - txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" ) // 1 << 256 - 1 where 256 is the max bit length defined for sdk.Int @@ -829,112 +828,6 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { return totalLiquidity, nil } -// extractTakerFeeAndDistribute takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. -// Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we -// pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { - nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName - nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName - baseDenom := appparams.BaseCoinUnit - - takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom) - if err != nil { - return sdk.Coin{}, err - } - - var tokenInAfterTakerFee sdk.Coin - var takerFeeCoin sdk.Coin - if exactIn { - tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactIn(tokenIn, takerFee) - } else { - tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactOut(tokenIn, takerFee) - } - - // N.B. We truncate from the community pool calculation, then remove that from the total, and use the remaining for staking rewards. - // If we truncate both, these can leave tokens in the users wallet when swapping and exact amount in, which is bad UX. - - // We determine the distributution of the taker fee based on its denom - // If the denom is the base denom: - takerFeeAmtRemaining := takerFeeCoin.Amount - if takerFeeCoin.Denom == baseDenom { - // Community Pool: - if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { - // Osmo community pool funds is a direct send - osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) - osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) - if err != nil { - return sdk.Coin{}, err - } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(baseDenom)) - } - // Staking Rewards: - if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { - // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) - // We could stream these rewards via the fee collector account, but this is decision to be made by governance. - osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) - if err != nil { - return sdk.Coin{}, err - } - } - - // If the denom is not the base denom: - } else { - // Community Pool: - if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { - denomIsWhitelisted := isDenomWhitelisted(takerFeeCoin.Denom, poolManagerParams.AuthorizedQuoteDenoms) - // If the non osmo denom is a whitelisted quote asset, we send to the community pool - if denomIsWhitelisted { - nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) - nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) - if err != nil { - return sdk.Coin{}, err - } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) - } else { - // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. - // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. - nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) - nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) - if err != nil { - return sdk.Coin{}, err - } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) - } - } - // Staking Rewards: - if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { - // Non Osmo staking rewards are sent to the non native fee pool module account - nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) - if err != nil { - return sdk.Coin{}, err - } - } - } - - return tokenInAfterTakerFee, nil -} - -func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - amountInAfterSubTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) - tokenInAfterSubTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterSubTakerFee.TruncateInt()) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterSubTakerFee.Amount)) - - return tokenInAfterSubTakerFee, takerFeeCoin -} - -func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - amountInAfterAddTakerFee := tokenIn.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) - tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.RoundInt()) - takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenInAfterAddTakerFee.Amount.Sub(tokenIn.Amount)) - - return tokenInAfterAddTakerFee, takerFeeCoin -} - func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { for _, authorizedQuoteDenom := range authorizedQuoteDenoms { if denom == authorizedQuoteDenom { diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go new file mode 100644 index 00000000000..b398b3e0329 --- /dev/null +++ b/x/poolmanager/taker_fee.go @@ -0,0 +1,181 @@ +package poolmanager + +import ( + "fmt" + + sdk "github.com/cosmos/cosmos-sdk/types" + + appparams "github.com/osmosis-labs/osmosis/v17/app/params" + + "github.com/osmosis-labs/osmosis/osmoutils" + "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" + txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" +) + +// SetDenomPairTakerFee sets the taker fee for the given trading pair. +// If the taker fee for this denom pair matches the default taker fee, then +// it is deleted from state. +func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee sdk.Dec) { + store := ctx.KVStore(k.storeKey) + if takerFee.Equal(k.GetParams(ctx).TakerFeeParams.DefaultTakerFee) { + store.Delete(types.FormatDenomTradePairKey(denom0, denom1)) + return + } else { + osmoutils.MustSetDec(store, types.FormatDenomTradePairKey(denom0, denom1), takerFee) + } +} + +// SenderValidationSetDenomPairTakerFee sets the taker fee for the given trading pair iff the sender's address +// also exists in the pool manager taker fee admin address list. +func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee sdk.Dec) error { + adminAddresses := k.GetParams(ctx).TakerFeeParams.AdminAddresses + isAdmin := false + for _, admin := range adminAddresses { + if admin == sender { + isAdmin = true + break + } + } + if !isAdmin { + return fmt.Errorf("%s is not in the pool manager taker fee admin address list", sender) + } + + k.SetDenomPairTakerFee(ctx, denom0, denom1, takerFee) + + ctx.EventManager().EmitEvents(sdk.Events{ + sdk.NewEvent( + types.TypeMsgSetDenomPairTakerFee, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, sender), + sdk.NewAttribute(types.AttributeKeyDenom0, denom0), + sdk.NewAttribute(types.AttributeKeyDenom1, denom1), + sdk.NewAttribute(types.AttributeKeyTakerFee, takerFee.String()), + ), + }) + + return nil +} + +// GetTradingPairTakerFee returns the taker fee for the given trading pair. +// If the trading pair does not exist, it returns the default taker fee. +func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) { + store := ctx.KVStore(k.storeKey) + key := types.FormatDenomTradePairKey(denom0, denom1) + + takerFee := &sdk.DecProto{} + found, err := osmoutils.Get(store, key, takerFee) + if err != nil { + return sdk.Dec{}, err + } + if !found { + return k.GetParams(ctx).TakerFeeParams.DefaultTakerFee, nil + } + + return takerFee.Dec, nil +} + +// extractTakerFeeAndDistribute takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. +// Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we +// pull directly from the pool and not the user's account. +func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { + nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName + nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName + baseDenom := appparams.BaseCoinUnit + + takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom) + if err != nil { + return sdk.Coin{}, err + } + + var tokenInAfterTakerFee sdk.Coin + var takerFeeCoin sdk.Coin + if exactIn { + tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactIn(tokenIn, takerFee) + } else { + tokenInAfterTakerFee, takerFeeCoin = k.calcTakerFeeExactOut(tokenIn, takerFee) + } + + // N.B. We truncate from the community pool calculation, then remove that from the total, and use the remaining for staking rewards. + // If we truncate both, these can leave tokens in the users wallet when swapping and exact amount in, which is bad UX. + + // We determine the distributution of the taker fee based on its denom + // If the denom is the base denom: + takerFeeAmtRemaining := takerFeeCoin.Amount + if takerFeeCoin.Denom == baseDenom { + // Community Pool: + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + // Osmo community pool funds is a direct send + osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) + osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) + if err != nil { + return sdk.Coin{}, err + } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(baseDenom)) + } + // Staking Rewards: + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) + // We could stream these rewards via the fee collector account, but this is decision to be made by governance. + osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, takerFeeAmtRemaining)) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) + if err != nil { + return sdk.Coin{}, err + } + } + + // If the denom is not the base denom: + } else { + // Community Pool: + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + denomIsWhitelisted := isDenomWhitelisted(takerFeeCoin.Denom, poolManagerParams.AuthorizedQuoteDenoms) + // If the non osmo denom is a whitelisted quote asset, we send to the community pool + if denomIsWhitelisted { + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) + if err != nil { + return sdk.Coin{}, err + } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) + } else { + // If the non osmo denom is not a whitelisted asset, we send to the non native fee pool for community pool module account. + // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) + nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) + if err != nil { + return sdk.Coin{}, err + } + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(nonOsmoTakerFeeToCommunityPoolCoins.AmountOf(tokenIn.Denom)) + } + } + // Staking Rewards: + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + // Non Osmo staking rewards are sent to the non native fee pool module account + nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) + if err != nil { + return sdk.Coin{}, err + } + } + } + + return tokenInAfterTakerFee, nil +} + +func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + amountInAfterSubTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + tokenInAfterSubTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterSubTakerFee.TruncateInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterSubTakerFee.Amount)) + + return tokenInAfterSubTakerFee, takerFeeCoin +} + +func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { + amountInAfterAddTakerFee := tokenIn.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) + tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.RoundInt()) + takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenInAfterAddTakerFee.Amount.Sub(tokenIn.Amount)) + + return tokenInAfterAddTakerFee, takerFeeCoin +} From 21c7316bb9d37401fc7f70f25847dfdae040eccf Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 12:30:50 -0500 Subject: [PATCH 35/83] add CLI for gov prop for denomPairTakerFee --- tests/e2e/e2e_test.go | 1 - x/gamm/keeper/pool.go | 2 + x/poolmanager/client/cli/tx.go | 118 +++++++++++++++++++++++++++++++++ 3 files changed, 120 insertions(+), 1 deletion(-) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index d93fbbf700f..212ce758c59 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -429,7 +429,6 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { ) // Perform swap (not crossing initialized ticks) chainABNode.SwapExactAmountIn(uosmoIn_Swap1, outMinAmt, fmt.Sprintf("%d", poolID), denom0, initialization.ValidatorWalletName) - // Calculate and track global spread reward growth for swap 1 uosmoInDec_Swap1_SubTakerFee := uosmoInDec_Swap1.SDKDec().Mul(sdk.OneDec().Sub(takerFee)).TruncateDec() uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor := uosmoInDec_Swap1_SubTakerFee.Mul(sdk.OneDec().Sub(spreadFactorDec)) diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index 19e0f44d6a5..c26cd9fcfac 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -355,6 +355,8 @@ func asCFMMPool(pool poolmanagertypes.PoolI) (types.CFMMPoolI, error) { return cfmmPool, nil } +// GetTradingPairTakerFee is a wrapper for poolmanager's GetTradingPairTakerFee, and is solely used +// to get access to this method for use in sim_msgs.go for the GAMM module. func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) { return k.poolManager.GetTradingPairTakerFee(ctx, denom0, denom1) } diff --git a/x/poolmanager/client/cli/tx.go b/x/poolmanager/client/cli/tx.go index 821878fe2c7..edeb96d870b 100644 --- a/x/poolmanager/client/cli/tx.go +++ b/x/poolmanager/client/cli/tx.go @@ -14,6 +14,9 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/spf13/cobra" sdk "github.com/cosmos/cosmos-sdk/types" @@ -446,3 +449,118 @@ func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) { } return sdk.NormalizeCoins(decCoins), nil } + +// NewCmdHandleDenomPairTakerFeeProposal implements a command handler for denom pair taker fee proposal +func NewCmdHandleDenomPairTakerFeeProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "denom-pair-taker-fee-proposal [denom-pairs-with-taker-fee] [flags]", + Args: cobra.ExactArgs(0), + Short: "Submit a denom pair taker fee proposal", + Long: strings.TrimSpace(`Submit a denom pair taker fee proposal. + +Pass in denom-pairs-with-taker-fee separated by commas would be parsed automatically to pairs of denomPairTakerFee records. +Ex) denom-pair-taker-fee-proposal uion,uosmo,0.0016,stake,uosmo,0.005,uatom,uosmo,0.0015 -> +[uion<>uosmo, takerFee 0.16%] +[stake<>uosmo, takerFee 0.5%] +[uatom<>uosmo, removes from state since its being set to the default takerFee value] + + `), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + content, err := parseDenomPairTakerFeeArgToContent(cmd, args[0]) + if err != nil { + return err + } + + from := clientCtx.GetFromAddress() + + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") + cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") + cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal") + cmd.Flags().Bool(govcli.FlagIsExpedited, false, "If true, makes the proposal an expedited one") + cmd.Flags().String(govcli.FlagProposal, "", "Proposal file path (if this path is given, other proposal flags are ignored)") + + return cmd +} + +func parseDenomPairTakerFeeArgToContent(cmd *cobra.Command, arg string) (govtypes.Content, error) { + title, err := cmd.Flags().GetString(govcli.FlagTitle) + if err != nil { + return nil, err + } + + description, err := cmd.Flags().GetString(govcli.FlagDescription) + if err != nil { + return nil, err + } + + denomPairTakerFee, err := parsedenomPairTakerFee(arg) + if err != nil { + return nil, err + } + + content := &types.DenomPairTakerFeeProposal{ + Title: title, + Description: description, + DenomPairTakerFee: denomPairTakerFee, + } + + return content, nil +} + +func parsedenomPairTakerFee(arg string) ([]types.DenomPairTakerFee, error) { + denomPairTakerFeeRecords := strings.Split(arg, ",") + + if len(denomPairTakerFeeRecords)%3 != 0 { + return nil, fmt.Errorf("denomPairTakerFeeRecords must be a list of denom0, denom1, and takerFee separated by commas") + } + + finaldenomPairTakerFeeRecordsRecords := []types.DenomPairTakerFee{} + i := 0 + for i < len(denomPairTakerFeeRecords) { + denom0 := denomPairTakerFeeRecords[i] + denom1 := denomPairTakerFeeRecords[i+1] + + takerFeeStr := denomPairTakerFeeRecords[i+2] + takerFee, err := sdk.NewDecFromStr(takerFeeStr) + if err != nil { + return nil, err + } + + finaldenomPairTakerFeeRecordsRecords = append(finaldenomPairTakerFeeRecordsRecords, types.DenomPairTakerFee{ + Denom0: denom0, + Denom1: denom1, + TakerFee: takerFee, + }) + + // increase counter by the next 3 + i = i + 3 + } + + return finaldenomPairTakerFeeRecordsRecords, nil +} From 89b0fe38e0f3b91ca40d3baf127edc87f72324bf Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 12:59:41 -0500 Subject: [PATCH 36/83] add admin address denomPairTakerFee cli msg --- x/poolmanager/client/cli/tx.go | 59 ++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/x/poolmanager/client/cli/tx.go b/x/poolmanager/client/cli/tx.go index edeb96d870b..7340a4a81b6 100644 --- a/x/poolmanager/client/cli/tx.go +++ b/x/poolmanager/client/cli/tx.go @@ -454,11 +454,11 @@ func ParseCoinsNoSort(coinsStr string) (sdk.Coins, error) { func NewCmdHandleDenomPairTakerFeeProposal() *cobra.Command { cmd := &cobra.Command{ Use: "denom-pair-taker-fee-proposal [denom-pairs-with-taker-fee] [flags]", - Args: cobra.ExactArgs(0), + Args: cobra.ExactArgs(1), Short: "Submit a denom pair taker fee proposal", Long: strings.TrimSpace(`Submit a denom pair taker fee proposal. -Pass in denom-pairs-with-taker-fee separated by commas would be parsed automatically to pairs of denomPairTakerFee records. +Passing in denom-pairs-with-taker-fee separated by commas would be parsed automatically to pairs of denomPairTakerFee records. Ex) denom-pair-taker-fee-proposal uion,uosmo,0.0016,stake,uosmo,0.005,uatom,uosmo,0.0015 -> [uion<>uosmo, takerFee 0.16%] [stake<>uosmo, takerFee 0.5%] @@ -508,6 +508,47 @@ Ex) denom-pair-taker-fee-proposal uion,uosmo,0.0016,stake,uosmo,0.005,uatom,uosm return cmd } +func NewSetDenomPairTakerFeeCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "set-denom-pair-taker-fee [flags]", + Short: "allows admin addresses to set the taker fee for a denom pair", + Long: strings.TrimSpace(`Allows admin addresses to set the taker fee for a denom pair. + +Passing in set-denom-pair-taker-fee separated by commas would be parsed automatically to pairs of denomPairTakerFee records. +Ex) set-denom-pair-taker-fee uion,uosmo,0.0016,stake,uosmo,0.005,uatom,uosmo,0.0015 -> +[uion<>uosmo, takerFee 0.16%] +[stake<>uosmo, takerFee 0.5%] +[uatom<>uosmo, removes from state since its being set to the default takerFee value] + + `), + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg, err := parseDenomPairTakerFeeArgToMsg(clientCtx, args[0]) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().AddFlagSet(FlagSetCreatePool()) + flags.AddTxFlagsToCmd(cmd) + + _ = cmd.MarkFlagRequired(FlagPoolFile) + + return cmd +} + func parseDenomPairTakerFeeArgToContent(cmd *cobra.Command, arg string) (govtypes.Content, error) { title, err := cmd.Flags().GetString(govcli.FlagTitle) if err != nil { @@ -533,6 +574,20 @@ func parseDenomPairTakerFeeArgToContent(cmd *cobra.Command, arg string) (govtype return content, nil } +func parseDenomPairTakerFeeArgToMsg(clientCtx client.Context, arg string) (sdk.Msg, error) { + denomPairTakerFee, err := parsedenomPairTakerFee(arg) + if err != nil { + return nil, err + } + + msg := &types.MsgSetDenomPairTakerFee{ + Sender: clientCtx.GetFromAddress().String(), + DenomPairTakerFee: denomPairTakerFee, + } + + return msg, nil +} + func parsedenomPairTakerFee(arg string) ([]types.DenomPairTakerFee, error) { denomPairTakerFeeRecords := strings.Split(arg, ",") From 7ec60cca558268171f07b5a06472b2b0019f37d3 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 14:50:49 -0500 Subject: [PATCH 37/83] clean and simplifications --- proto/osmosis/poolmanager/v1beta1/gov.proto | 2 ++ x/gamm/simulation/sim_msgs.go | 8 +++--- x/poolmanager/router.go | 31 ++++++++++----------- x/poolmanager/router_test.go | 6 +++- x/poolmanager/taker_fee.go | 3 +- x/poolmanager/types/gov.pb.go | 2 ++ 6 files changed, 30 insertions(+), 22 deletions(-) diff --git a/proto/osmosis/poolmanager/v1beta1/gov.proto b/proto/osmosis/poolmanager/v1beta1/gov.proto index 7e783020c00..935b205c24a 100644 --- a/proto/osmosis/poolmanager/v1beta1/gov.proto +++ b/proto/osmosis/poolmanager/v1beta1/gov.proto @@ -6,6 +6,8 @@ import "osmosis/poolmanager/v1beta1/tx.proto"; option go_package = "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types"; +// DenomPairTakerFeeProposal is a type for adding/removing a custom taker fee(s) +// for one or more denom pairs. message DenomPairTakerFeeProposal { option (gogoproto.goproto_getters) = false; option (gogoproto.goproto_stringer) = false; diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index f2a8b634eca..a48a3887034 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -146,8 +146,8 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont // calculate the minimum number of tokens received from input of tokenIn - // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. - // We therefore need to add the taker fee to the spread factor when calling the calc method. + // N.B. Calling MsgSwapExactAmountIn executes the swap via the pool manager, which charges the taker fee. + // We therefore need to remove the taker fee from the amountIn before calling the calc method. takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) if err != nil { return nil, err @@ -203,8 +203,8 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con return nil, err } - // N.B. Calling the Msg calls it via the pool manager, which charges the taker fee. - // We therefore need to add the taker fee to the spread factor when calling the calc method. + // N.B. Calling MsgSwapExactAmountOut executes the swap via the pool manager, which charges the taker fee. + // We therefore need to add the taker fee to the amountIn after calling the calc method. takerFee, err := k.GetTradingPairTakerFee(ctx, coinIn.Denom, coinOut.Denom) if err != nil { return nil, err diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index a633ed2248f..71001de7766 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -34,7 +34,6 @@ func (k Keeper) RouteExactAmountIn( routeSpreadFactor sdk.Dec sumOfSpreadFactors sdk.Dec ) - poolManagerParams := k.GetParams(ctx) // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountInRoutes(route) @@ -94,7 +93,7 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, routeStep.TokenOutDenom, poolManagerParams, sender, true) + tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, routeStep.TokenOutDenom, sender, true) if err != nil { return sdk.Int{}, err } @@ -210,17 +209,13 @@ func (k Keeper) SwapExactAmountIn( return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } - poolManagerParams := k.GetParams(ctx) - - spreadFactor := pool.GetSpreadFactor(ctx) - - tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, tokenOutDenom, poolManagerParams, sender, true) + tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, tokenOutDenom, sender, true) if err != nil { return sdk.Int{}, err } // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, tokenOutDenom, tokenOutMinAmount, spreadFactor) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, tokenOutDenom, tokenOutMinAmount, pool.GetSpreadFactor(ctx)) if err != nil { return sdk.Int{}, err } @@ -228,6 +223,11 @@ func (k Keeper) SwapExactAmountIn( return tokenOutAmount, nil } +// SwapExactAmountInNoTakerFee is an API for swapping an exact amount of tokens +// as input to a pool to get a minimum amount of the desired token out. +// This method does NOT charge a taker fee, and should only be used in the the +// txfees hooks when swapping taker fees. This prevents us from charging taker fees +// on taker fees. func (k Keeper) SwapExactAmountInNoTakerFee( ctx sdk.Context, sender sdk.AccAddress, @@ -255,10 +255,8 @@ func (k Keeper) SwapExactAmountInNoTakerFee( return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } - spreadFactor := pool.GetSpreadFactor(ctx) - // routeStep to the pool-specific SwapExactAmountIn implementation. - tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, spreadFactor) + tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, pool.GetSpreadFactor(ctx)) if err != nil { return sdk.Int{}, err } @@ -354,7 +352,6 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} - poolManagerParams := k.GetParams(ctx) // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountOutRoutes(route) @@ -444,7 +441,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) - tokenInAfterAddTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, _tokenOut.Denom, poolManagerParams, sender, false) + tokenInAfterAddTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, _tokenOut.Denom, sender, false) if err != nil { return sdk.Int{}, err } @@ -691,9 +688,9 @@ func (k Keeper) getOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route ty if poolErr != nil { return sdk.Dec{}, sdk.Dec{}, poolErr } - SpreadFactor := pool.GetSpreadFactor(ctx) - additiveSpreadFactor = additiveSpreadFactor.Add(SpreadFactor) - maxSpreadFactor = sdk.MaxDec(maxSpreadFactor, SpreadFactor) + spreadFactor := pool.GetSpreadFactor(ctx) + additiveSpreadFactor = additiveSpreadFactor.Add(spreadFactor) + maxSpreadFactor = sdk.MaxDec(maxSpreadFactor, spreadFactor) } // We divide by 2 to get the average since OSMO-routed multihops always have exactly 2 pools. @@ -828,6 +825,8 @@ func (k Keeper) TotalLiquidity(ctx sdk.Context) (sdk.Coins, error) { return totalLiquidity, nil } +// isDenomWhitelisted checks if the denom provided exists in the list of authorized quote denoms. +// If it does, it returns true, otherwise false. func isDenomWhitelisted(denom string, authorizedQuoteDenoms []string) bool { for _, authorizedQuoteDenom := range authorizedQuoteDenoms { if denom == authorizedQuoteDenom { diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index b2b43712f0c..8a7c082223f 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -2745,7 +2745,11 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { var actualSwapOuts []sdk.Int var err error - actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut) + if !tc.sumOfSpreadFactors.IsNil() && !tc.cumulativeRouteSpreadFactor.IsNil() { + actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateOsmoMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut, tc.cumulativeRouteSpreadFactor, tc.sumOfSpreadFactors) + } else { + actualSwapOuts, err = suite.App.PoolManagerKeeper.CreateMultihopExpectedSwapOuts(suite.Ctx, tc.route, tc.tokenOut) + } if tc.expectedError { suite.Require().Error(err) } else { diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index b398b3e0329..c56880e0f76 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -77,10 +77,11 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( // extractTakerFeeAndDistribute takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, poolManagerParams types.Params, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { +func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName baseDenom := appparams.BaseCoinUnit + poolManagerParams := k.GetParams(ctx) takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom) if err != nil { diff --git a/x/poolmanager/types/gov.pb.go b/x/poolmanager/types/gov.pb.go index cf42c10c383..42fdc8fd418 100644 --- a/x/poolmanager/types/gov.pb.go +++ b/x/poolmanager/types/gov.pb.go @@ -23,6 +23,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// DenomPairTakerFeeProposal is a type for adding/removing a custom taker fee(s) +// for one or more denom pairs. type DenomPairTakerFeeProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` From eeefe36d48bd24ae90451b8a5234d1fe91108f6f Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 16:14:39 -0500 Subject: [PATCH 38/83] use authorized quote denoms from poolmanger --- app/apptesting/concentrated_liquidity.go | 6 +++++- x/concentrated-liquidity/keeper.go | 4 ++++ x/concentrated-liquidity/pool.go | 5 +++-- x/concentrated-liquidity/pool_test.go | 4 ++-- x/concentrated-liquidity/simulation/sim_msgs.go | 9 ++++++--- x/concentrated-liquidity/types/expected_keepers.go | 2 ++ x/twap/keeper_test.go | 6 +++--- x/twap/store.go | 1 + 8 files changed, 26 insertions(+), 11 deletions(-) diff --git a/app/apptesting/concentrated_liquidity.go b/app/apptesting/concentrated_liquidity.go index 8107f23ed68..6cfff77a267 100644 --- a/app/apptesting/concentrated_liquidity.go +++ b/app/apptesting/concentrated_liquidity.go @@ -7,6 +7,7 @@ import ( clmodel "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" + poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" cl "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity" ) @@ -139,6 +140,9 @@ func (s *KeeperTestHelper) SetupConcentratedLiquidityDenomsAndPoolCreation() { // modify authorized quote denoms to include test denoms. defaultParams := types.DefaultParams() defaultParams.IsPermissionlessPoolCreationEnabled = true - defaultParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, ETH, USDC, BAR, BAZ, FOO, UOSMO, STAKE, WBTC) s.App.ConcentratedLiquidityKeeper.SetParams(s.Ctx, defaultParams) + + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.AuthorizedQuoteDenoms = append(poolmanagertypes.DefaultParams().AuthorizedQuoteDenoms, ETH, USDC, BAR, BAZ, FOO, UOSMO, STAKE, WBTC) + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) } diff --git a/x/concentrated-liquidity/keeper.go b/x/concentrated-liquidity/keeper.go index 919575fb6cd..24ef6361986 100644 --- a/x/concentrated-liquidity/keeper.go +++ b/x/concentrated-liquidity/keeper.go @@ -126,3 +126,7 @@ func (k Keeper) ValidatePermissionlessPoolCreationEnabled(ctx sdk.Context) error } return nil } + +func (k Keeper) GetPoolManagerKeeper() types.PoolManagerKeeper { + return k.poolmanagerKeeper +} diff --git a/x/concentrated-liquidity/pool.go b/x/concentrated-liquidity/pool.go index 67eb7b5bb50..7b80517f61d 100644 --- a/x/concentrated-liquidity/pool.go +++ b/x/concentrated-liquidity/pool.go @@ -41,6 +41,7 @@ func (k Keeper) InitializePool(ctx sdk.Context, poolI poolmanagertypes.PoolI, cr spreadFactor := concentratedPool.GetSpreadFactor(ctx) poolId := concentratedPool.GetId() quoteAsset := concentratedPool.GetToken1() + poolManagerParams := k.poolmanagerKeeper.GetParams(ctx) if !k.validateTickSpacing(params, tickSpacing) { return types.UnauthorizedTickSpacingError{ProvidedTickSpacing: tickSpacing, AuthorizedTickSpacings: params.AuthorizedTickSpacing} @@ -50,8 +51,8 @@ func (k Keeper) InitializePool(ctx sdk.Context, poolI poolmanagertypes.PoolI, cr return types.UnauthorizedSpreadFactorError{ProvidedSpreadFactor: spreadFactor, AuthorizedSpreadFactors: params.AuthorizedSpreadFactors} } - if !validateAuthorizedQuoteDenoms(quoteAsset, params.AuthorizedQuoteDenoms) { - return types.UnauthorizedQuoteDenomError{ProvidedQuoteDenom: quoteAsset, AuthorizedQuoteDenoms: params.AuthorizedQuoteDenoms} + if !validateAuthorizedQuoteDenoms(quoteAsset, poolManagerParams.AuthorizedQuoteDenoms) { + return types.UnauthorizedQuoteDenomError{ProvidedQuoteDenom: quoteAsset, AuthorizedQuoteDenoms: poolManagerParams.AuthorizedQuoteDenoms} } if err := k.createSpreadRewardAccumulator(ctx, poolId); err != nil { diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index 365a88655b5..e02f4c66b20 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -86,9 +86,9 @@ func (s *KeeperTestSuite) TestInitializePool() { s.SetupTest() if len(test.authorizedDenomsOverwrite) > 0 { - params := s.App.ConcentratedLiquidityKeeper.GetParams(s.Ctx) + params := s.App.PoolManagerKeeper.GetParams(s.Ctx) params.AuthorizedQuoteDenoms = test.authorizedDenomsOverwrite - s.App.ConcentratedLiquidityKeeper.SetParams(s.Ctx, params) + s.App.PoolManagerKeeper.SetParams(s.Ctx, params) } s.setListenerMockOnConcentratedLiquidityKeeper() diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go index e7f647eb22f..4c7cc93ebe6 100644 --- a/x/concentrated-liquidity/simulation/sim_msgs.go +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -25,13 +25,16 @@ func RandomMsgCreateConcentratedPool(k clkeeper.Keeper, sim *osmosimtypes.SimCtx return nil, err } - // make sure the denoms are valid authorized quote denoms + // set permissionless pool creation to true defaultParams := cltypes.DefaultParams() defaultParams.IsPermissionlessPoolCreationEnabled = true - defaultParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, coin1.Denom, coin0.Denom) - k.SetParams(ctx, defaultParams) + // make sure the denoms are valid authorized quote denoms + poolManagerParams := k.GetPoolManagerKeeper().GetParams(ctx) + poolManagerParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, coin1.Denom, coin0.Denom) + k.GetPoolManagerKeeper().SetParams(ctx, poolManagerParams) + denomMetaData := banktypes.Metadata{ DenomUnits: []*banktypes.DenomUnit{{ Denom: appParams.BaseCoinUnit, diff --git a/x/concentrated-liquidity/types/expected_keepers.go b/x/concentrated-liquidity/types/expected_keepers.go index 58fb2d2f4f6..2d7334e5284 100644 --- a/x/concentrated-liquidity/types/expected_keepers.go +++ b/x/concentrated-liquidity/types/expected_keepers.go @@ -30,6 +30,8 @@ type BankKeeper interface { // PoolManagerKeeper defines the interface needed to be fulfilled for // the poolmanager keeper. type PoolManagerKeeper interface { + GetParams(ctx sdk.Context) (params poolmanagertypes.Params) + SetParams(ctx sdk.Context, params poolmanagertypes.Params) CreatePool(ctx sdk.Context, msg poolmanagertypes.CreatePoolMsg) (uint64, error) GetNextPoolId(ctx sdk.Context) uint64 CreateConcentratedPoolAsPoolManager(ctx sdk.Context, msg poolmanagertypes.CreatePoolMsg) (poolmanagertypes.PoolI, error) diff --git a/x/twap/keeper_test.go b/x/twap/keeper_test.go index 25dbcb67279..331bb560648 100644 --- a/x/twap/keeper_test.go +++ b/x/twap/keeper_test.go @@ -43,9 +43,9 @@ func (s *TestSuite) SetupTest() { s.twapkeeper = s.App.TwapKeeper s.Ctx = s.Ctx.WithBlockTime(baseTime) // add x/twap test specific denoms - concentratedLiquidityParams := s.App.ConcentratedLiquidityKeeper.GetParams(s.Ctx) - concentratedLiquidityParams.AuthorizedQuoteDenoms = append(concentratedLiquidityParams.AuthorizedQuoteDenoms, denom0, denom1, denom2) - s.App.ConcentratedLiquidityKeeper.SetParams(s.Ctx, concentratedLiquidityParams) + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.AuthorizedQuoteDenoms = append(poolManagerParams.AuthorizedQuoteDenoms, denom0, denom1, denom2) + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) } var ( diff --git a/x/twap/store.go b/x/twap/store.go index b86872da12b..b9d9c9a518b 100644 --- a/x/twap/store.go +++ b/x/twap/store.go @@ -157,6 +157,7 @@ func (k Keeper) GetAllHistoricalTimeIndexedTWAPs(ctx sdk.Context) ([]types.TwapR } // getAllHistoricalPoolIndexedTWAPs returns all historical TWAPs indexed by pool id. +// nolint:unused func (k Keeper) getAllHistoricalPoolIndexedTWAPs(ctx sdk.Context) ([]types.TwapRecord, error) { return osmoutils.GatherValuesFromStorePrefix(ctx.KVStore(k.storeKey), []byte(types.HistoricalTWAPPoolIndexPrefix), types.ParseTwapFromBz) } From 3ddd4086d89311ec482e85a6130a16f83d6c998e Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 16:44:02 -0500 Subject: [PATCH 39/83] remove stableswap taker fee --- app/upgrades/v18/upgrades.go | 5 +- .../osmosis/poolmanager/v1beta1/genesis.proto | 16 +- x/poolmanager/keeper_test.go | 5 - x/poolmanager/types/genesis.pb.go | 176 ++++++------------ x/poolmanager/types/params.go | 27 +-- x/protorev/keeper/keeper_test.go | 1 - 6 files changed, 71 insertions(+), 159 deletions(-) diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v18/upgrades.go index a9602658fd9..ae1d9e64e06 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v18/upgrades.go @@ -25,8 +25,9 @@ func CreateUpgradeHandler( } // Move the current authorized quote denoms from the concentrated liquidity params to the pool manager params. - // This is needed since the pool manager needs access to these denoms to determine if the taker fee should - // be swapped into OSMO or not. + // This needs to be moved because the pool manager requires access to these denoms to determine if the taker fee should + // be swapped into OSMO or not. The concentrated liquidity module already requires access to the pool manager keeper, + // so the right move in this case is to move this parameter upwards in order to prevent circular dependencies. // TODO: In v19 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index e59e2cf2c03..efe4b0d915b 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -53,21 +53,13 @@ message TakerFeeParams { (gogoproto.customname) = "DefaultTakerFee", (gogoproto.nullable) = false ]; - // stableswap_taker_fee is the fee used when creating a new pool in which all - // the underlying tokens are present in the stablecoin_denoms paramater entry - // OR has a liquid_stake_denom_pairings entry. - string stableswap_taker_fee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.customname) = "StableswapTakerFee", - (gogoproto.nullable) = false - ]; // osmo_taker_fee_distribution defines the distribution of taker fees // generated in OSMO. As of this writing, it has two catagories: // - staking_rewards: the percent of the taker fee that gets distributed to // stakers. // - community_pool: the percent of the taker fee that gets sent to the // community pool. - TakerFeeDistributionPercentage osmo_taker_fee_distribution = 3 [ + TakerFeeDistributionPercentage osmo_taker_fee_distribution = 2 [ (gogoproto.customname) = "OsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; @@ -80,7 +72,7 @@ message TakerFeeParams { // that denom is sent directly to the community pool. Otherwise, it is // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and // then sent to the community pool as that denom. - TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 4 [ + TakerFeeDistributionPercentage non_osmo_taker_fee_distribution = 3 [ (gogoproto.customname) = "NonOsmoTakerFeeDistribution", (gogoproto.nullable) = false ]; @@ -88,12 +80,12 @@ message TakerFeeParams { // custom taker fees for denom pairs. Governance also has the ability to set // and removecustom taker fees for denom pairs, but with the normal governance // delay. - repeated string admin_addresses = 5 + repeated string admin_addresses = 4 [ (gogoproto.moretags) = "yaml:\"admin_addresses\"" ]; // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that // non-whitelisted taker fees will be swapped to before being sent to // the community pool. - string community_pool_denom_to_swap_non_whitelisted_assets_to = 6 + string community_pool_denom_to_swap_non_whitelisted_assets_to = 5 [ (gogoproto.moretags) = "yaml:\"community_pool_denom_to_swap_non_whitelisted_assets_to\"" ]; } diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 104f3001bb8..a02b4b846a0 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -20,7 +20,6 @@ const testExpectedPoolId = 3 var ( testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} testDefaultTakerFee = sdk.MustNewDecFromStr("0.0015") - testStableswapTakerFee = sdk.MustNewDecFromStr("0.0002") testOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ StakingRewards: sdk.MustNewDecFromStr("0.3"), CommunityPool: sdk.MustNewDecFromStr("0.7"), @@ -85,7 +84,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { PoolCreationFee: testPoolCreationFee, TakerFeeParams: types.TakerFeeParams{ DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AdminAddresses: testAdminAddresses, @@ -101,7 +99,6 @@ func (s *KeeperTestSuite) TestInitGenesis() { s.Require().Equal(uint64(testExpectedPoolId), s.App.PoolManagerKeeper.GetNextPoolId(s.Ctx)) s.Require().Equal(testPoolCreationFee, params.PoolCreationFee) s.Require().Equal(testDefaultTakerFee, params.TakerFeeParams.DefaultTakerFee) - s.Require().Equal(testStableswapTakerFee, params.TakerFeeParams.StableswapTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, params.TakerFeeParams.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, params.TakerFeeParams.NonOsmoTakerFeeDistribution) s.Require().Equal(testAdminAddresses, params.TakerFeeParams.AdminAddresses) @@ -116,7 +113,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { PoolCreationFee: testPoolCreationFee, TakerFeeParams: types.TakerFeeParams{ DefaultTakerFee: testDefaultTakerFee, - StableswapTakerFee: testStableswapTakerFee, OsmoTakerFeeDistribution: testOsmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: testNonOsmoTakerFeeDistribution, AdminAddresses: testAdminAddresses, @@ -132,7 +128,6 @@ func (s *KeeperTestSuite) TestExportGenesis() { s.Require().Equal(uint64(testExpectedPoolId), genesis.NextPoolId) s.Require().Equal(testPoolCreationFee, genesis.Params.PoolCreationFee) s.Require().Equal(testDefaultTakerFee, genesis.Params.TakerFeeParams.DefaultTakerFee) - s.Require().Equal(testStableswapTakerFee, genesis.Params.TakerFeeParams.StableswapTakerFee) s.Require().Equal(testOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.OsmoTakerFeeDistribution) s.Require().Equal(testNonOsmoTakerFeeDistribution, genesis.Params.TakerFeeParams.NonOsmoTakerFeeDistribution) s.Require().Equal(testAdminAddresses, genesis.Params.TakerFeeParams.AdminAddresses) diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 552954565a3..dfea36965ac 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -167,17 +167,13 @@ type TakerFeeParams struct { // default_taker_fee is the fee used when creating a new pool that doesn't // fall under a custom pool taker fee or stableswap taker fee category. DefaultTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"default_taker_fee"` - // stableswap_taker_fee is the fee used when creating a new pool in which all - // the underlying tokens are present in the stablecoin_denoms paramater entry - // OR has a liquid_stake_denom_pairings entry. - StableswapTakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=stableswap_taker_fee,json=stableswapTakerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"stableswap_taker_fee"` // osmo_taker_fee_distribution defines the distribution of taker fees // generated in OSMO. As of this writing, it has two catagories: // - staking_rewards: the percent of the taker fee that gets distributed to // stakers. // - community_pool: the percent of the taker fee that gets sent to the // community pool. - OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,3,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` + OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,2,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` // non_osmo_taker_fee_distribution defines the distribution of taker fees // generated in non-OSMO. As of this writing, it has two catagories: // - staking_rewards: the percent of the taker fee that gets swapped to OSMO @@ -187,16 +183,16 @@ type TakerFeeParams struct { // that denom is sent directly to the community pool. Otherwise, it is // swapped to the community_pool_denom_to_swap_non_whitelisted_assets_to and // then sent to the community pool as that denom. - NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,4,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` + NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,3,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` // admin_addresses is a list of addresses that are allowed to set and remove // custom taker fees for denom pairs. Governance also has the ability to set // and removecustom taker fees for denom pairs, but with the normal governance // delay. - AdminAddresses []string `protobuf:"bytes,5,rep,name=admin_addresses,json=adminAddresses,proto3" json:"admin_addresses,omitempty" yaml:"admin_addresses"` + AdminAddresses []string `protobuf:"bytes,4,rep,name=admin_addresses,json=adminAddresses,proto3" json:"admin_addresses,omitempty" yaml:"admin_addresses"` // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that // non-whitelisted taker fees will be swapped to before being sent to // the community pool. - CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,6,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` + CommunityPoolDenomToSwapNonWhitelistedAssetsTo string `protobuf:"bytes,5,opt,name=community_pool_denom_to_swap_non_whitelisted_assets_to,json=communityPoolDenomToSwapNonWhitelistedAssetsTo,proto3" json:"community_pool_denom_to_swap_non_whitelisted_assets_to,omitempty" yaml:"community_pool_denom_to_swap_non_whitelisted_assets_to"` } func (m *TakerFeeParams) Reset() { *m = TakerFeeParams{} } @@ -312,60 +308,58 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 837 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f, 0xdc, 0x44, - 0x14, 0x8f, 0x93, 0xb0, 0x52, 0x27, 0x65, 0x97, 0x8e, 0x5a, 0xea, 0x26, 0x92, 0xbd, 0x72, 0x25, - 0xb4, 0x08, 0xd5, 0x56, 0x82, 0x44, 0x25, 0x10, 0x87, 0x6c, 0x56, 0x2d, 0x48, 0xd0, 0xa6, 0x4e, - 0x24, 0xa4, 0x5e, 0x46, 0xb3, 0xeb, 0x17, 0xc7, 0x8a, 0x3d, 0xb3, 0xf5, 0x8c, 0x93, 0x86, 0x2b, - 0x5f, 0x00, 0x89, 0x2b, 0x67, 0x0e, 0xdc, 0xb8, 0xf1, 0x01, 0x38, 0xf4, 0xd8, 0x23, 0xe2, 0x60, - 0xd0, 0xe6, 0x1b, 0xec, 0x27, 0x40, 0xf3, 0x67, 0x37, 0x71, 0xda, 0xac, 0x1a, 0x38, 0xed, 0xce, - 0x7b, 0xef, 0xf7, 0xfb, 0xbd, 0xf7, 0xe6, 0x3d, 0x0f, 0xfa, 0x98, 0x8b, 0x82, 0x8b, 0x4c, 0x44, - 0x63, 0xce, 0xf3, 0x82, 0x32, 0x9a, 0x42, 0x19, 0x1d, 0x6f, 0x0e, 0x41, 0xd2, 0xcd, 0x28, 0x05, - 0x06, 0x22, 0x13, 0xe1, 0xb8, 0xe4, 0x92, 0xe3, 0x0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a6, 0x11, 0x77, 0x92, 0xa6, 0x01, 0x1f, 0xa3, 0xdb, 0x42, - 0xd2, 0x61, 0x0e, 0xe2, 0x84, 0x8e, 0x2f, 0x28, 0x2e, 0x6b, 0xc5, 0xc1, 0xb5, 0x15, 0xf1, 0xde, - 0x9c, 0x6d, 0x2e, 0x8a, 0xc5, 0x1b, 0x36, 0xfc, 0xb3, 0x83, 0xf4, 0x17, 0xe1, 0x5c, 0x92, 0x24, - 0x99, 0x90, 0x65, 0x36, 0xac, 0xd4, 0xdc, 0xba, 0x2b, 0xfa, 0x8e, 0xbe, 0x78, 0xa7, 0x01, 0x1d, - 0x5c, 0x00, 0xee, 0x42, 0x39, 0x02, 0x26, 0x69, 0x0a, 0xfd, 0xae, 0x4a, 0x7e, 0x52, 0xfb, 0xee, - 0x53, 0x51, 0xf0, 0xb7, 0xc5, 0xc6, 0x2e, 0xbf, 0xc2, 0x83, 0x7f, 0x71, 0x90, 0xcf, 0x38, 0x23, - 0x8b, 0x52, 0x5c, 0xfd, 0xff, 0x29, 0xde, 0xb7, 0x29, 0x6e, 0x3c, 0xe1, 0xec, 0xca, 0x2c, 0x37, - 0xd8, 0xd5, 0x4e, 0xbc, 0x83, 0x3a, 0x34, 0x29, 0x32, 0x46, 0x68, 0x92, 0x94, 0x20, 0x04, 0x08, - 0xf7, 0x3d, 0xbd, 0x5c, 0xeb, 0xd3, 0xda, 0xff, 0xd0, 0x2e, 0x57, 0x33, 0x20, 0x88, 0xdb, 0xda, - 0xb2, 0x3d, 0x33, 0xe0, 0xdf, 0x1c, 0xf4, 0xd9, 0x88, 0x17, 0x45, 0xc5, 0x32, 0x79, 0x6a, 0x56, - 0x48, 0xef, 0x1f, 0x91, 0x9c, 0xe8, 0xb9, 0x50, 0xad, 0x38, 0x39, 0xcc, 0x24, 0xe4, 0x99, 0x90, - 0x90, 0x10, 0x2a, 0x04, 0x48, 0x41, 0x24, 0x77, 0x5b, 0x66, 0x32, 0xa7, 0xb5, 0xff, 0xa5, 0x11, - 0xfb, 0x6f, 0x3c, 0x41, 0x1c, 0xce, 0x81, 0x6a, 0x5f, 0xf5, 0x9a, 0xef, 0xf3, 0xbd, 0x13, 0x3a, - 0x7e, 0xc2, 0xd9, 0x77, 0xe7, 0x90, 0x6d, 0x8d, 0xd8, 0xe7, 0xc1, 0x0f, 0xcb, 0xc8, 0x5b, 0xdc, - 0x5d, 0xfc, 0x02, 0x75, 0x84, 0xa4, 0x47, 0x19, 0x4b, 0x49, 0x09, 0x27, 0xb4, 0x4c, 0x84, 0x5d, - 0xa4, 0xaf, 0xae, 0x37, 0xd6, 0xe7, 0x9d, 0xbc, 0x44, 0x17, 0xc4, 0x6d, 0x6b, 0x89, 0x8d, 0x01, - 0x33, 0xd4, 0x6e, 0x36, 0xc0, 0x2e, 0xd2, 0xe3, 0x6b, 0x2b, 0xde, 0x79, 0x5b, 0x3b, 0x83, 0xf8, - 0xfd, 0x46, 0x9b, 0xfa, 0xcf, 0x5e, 0x4d, 0x3c, 0xe7, 0xf5, 0xc4, 0x73, 0xfe, 0x99, 0x78, 0xce, - 0x8f, 0x67, 0xde, 0xd2, 0xeb, 0x33, 0x6f, 0xe9, 0xcf, 0x33, 0x6f, 0xe9, 0xf9, 0xc3, 0x0b, 0x4a, - 0x76, 0x42, 0x1f, 0xe4, 0x74, 0x28, 0x66, 0x87, 0xe8, 0x78, 0xf3, 0x61, 0xf4, 0xb2, 0xf1, 0xc8, - 0x69, 0xf9, 0x61, 0x4b, 0x3f, 0x6b, 0x9f, 0xfe, 0x1b, 0x00, 0x00, 0xff, 0xff, 0xcf, 0x99, 0x6e, - 0xb3, 0xdc, 0x07, 0x00, 0x00, + // 810 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, + 0x10, 0x36, 0x6d, 0xc7, 0x80, 0x57, 0xa9, 0xd4, 0x10, 0x4d, 0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d, 0x78, 0xee, 0xae, 0xbd, 0x3e, 0x77, 0xd7, 0xfe, 0x3c, 0x77, 0xd7, + 0x9e, 0x3f, 0xb8, 0xd4, 0xc9, 0x38, 0xf4, 0x7e, 0x46, 0x06, 0x7c, 0x7e, 0x08, 0xcf, 0xf6, 0x1e, + 0x84, 0x2f, 0x6b, 0x8f, 0x8d, 0x6a, 0x3f, 0xd8, 0x52, 0xcf, 0xcb, 0xa7, 0xff, 0x06, 0x00, 0x00, + 0xff, 0xff, 0x89, 0xc6, 0x5c, 0xee, 0x64, 0x07, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -501,7 +495,7 @@ func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo) i = encodeVarintGenesis(dAtA, i, uint64(len(m.CommunityPoolDenomToSwapNonWhitelistedAssetsTo))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x2a } if len(m.AdminAddresses) > 0 { for iNdEx := len(m.AdminAddresses) - 1; iNdEx >= 0; iNdEx-- { @@ -509,7 +503,7 @@ func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.AdminAddresses[iNdEx]) i = encodeVarintGenesis(dAtA, i, uint64(len(m.AdminAddresses[iNdEx]))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x22 } } { @@ -521,7 +515,7 @@ func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x1a { size, err := m.OsmoTakerFeeDistribution.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -531,16 +525,6 @@ func (m *TakerFeeParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a - { - size := m.StableswapTakerFee.Size() - i -= size - if _, err := m.StableswapTakerFee.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- dAtA[i] = 0x12 { size := m.DefaultTakerFee.Size() @@ -660,8 +644,6 @@ func (m *TakerFeeParams) Size() (n int) { _ = l l = m.DefaultTakerFee.Size() n += 1 + l + sovGenesis(uint64(l)) - l = m.StableswapTakerFee.Size() - n += 1 + l + sovGenesis(uint64(l)) l = m.OsmoTakerFeeDistribution.Size() n += 1 + l + sovGenesis(uint64(l)) l = m.NonOsmoTakerFeeDistribution.Size() @@ -1047,40 +1029,6 @@ func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StableswapTakerFee", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.StableswapTakerFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field OsmoTakerFeeDistribution", wireType) } @@ -1113,7 +1061,7 @@ func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field NonOsmoTakerFeeDistribution", wireType) } @@ -1146,7 +1094,7 @@ func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AdminAddresses", wireType) } @@ -1178,7 +1126,7 @@ func (m *TakerFeeParams) Unmarshal(dAtA []byte) error { } m.AdminAddresses = append(m.AdminAddresses, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field CommunityPoolDenomToSwapNonWhitelistedAssetsTo", wireType) } diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index e6c752607ef..1828e3ae9ce 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -13,7 +13,6 @@ import ( var ( KeyPoolCreationFee = []byte("PoolCreationFee") KeyDefaultTakerFee = []byte("DefaultTakerFee") - KeyStableswapTakerFee = []byte("StableswapTakerFee") KeyOsmoTakerFeeDistribution = []byte("OsmoTakerFeeDistribution") KeyNonOsmoTakerFeeDistribution = []byte("NonOsmoTakerFeeDistribution") KeyAdminAddresses = []byte("AdminAddresses") @@ -27,7 +26,7 @@ func ParamKeyTable() paramtypes.KeyTable { } func NewParams(poolCreationFee sdk.Coins, - defaultTakerFee, stableswapTakerFee sdk.Dec, + defaultTakerFee sdk.Dec, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, adminAddresses, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { @@ -35,7 +34,6 @@ func NewParams(poolCreationFee sdk.Coins, PoolCreationFee: poolCreationFee, TakerFeeParams: TakerFeeParams{ DefaultTakerFee: defaultTakerFee, - StableswapTakerFee: stableswapTakerFee, OsmoTakerFeeDistribution: osmoTakerFeeDistribution, NonOsmoTakerFeeDistribution: nonOsmoTakerFeeDistribution, AdminAddresses: adminAddresses, @@ -50,8 +48,7 @@ func DefaultParams() Params { return Params{ PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO TakerFeeParams: TakerFeeParams{ - DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% - StableswapTakerFee: sdk.MustNewDecFromStr("0.0002"), // 0.02% + DefaultTakerFee: sdk.MustNewDecFromStr("0.0015"), // 0.15% OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ StakingRewards: sdk.MustNewDecFromStr("1"), // 100% CommunityPool: sdk.MustNewDecFromStr("0"), // 0% @@ -80,9 +77,6 @@ func (p Params) Validate() error { if err := validateDefaultTakerFee(p.TakerFeeParams.DefaultTakerFee); err != nil { return err } - if err := validateStableswapTakerFee(p.TakerFeeParams.StableswapTakerFee); err != nil { - return err - } if err := validateTakerFeeDistribution(p.TakerFeeParams.OsmoTakerFeeDistribution); err != nil { return err } @@ -107,7 +101,6 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { return paramtypes.ParamSetPairs{ paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), paramtypes.NewParamSetPair(KeyDefaultTakerFee, &p.TakerFeeParams.DefaultTakerFee, validateDefaultTakerFee), - paramtypes.NewParamSetPair(KeyStableswapTakerFee, &p.TakerFeeParams.StableswapTakerFee, validateStableswapTakerFee), paramtypes.NewParamSetPair(KeyOsmoTakerFeeDistribution, &p.TakerFeeParams.OsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyNonOsmoTakerFeeDistribution, &p.TakerFeeParams.NonOsmoTakerFeeDistribution, validateTakerFeeDistribution), paramtypes.NewParamSetPair(KeyAdminAddresses, &p.TakerFeeParams.AdminAddresses, validateAdminAddresses), @@ -145,22 +138,6 @@ func validateDefaultTakerFee(i interface{}) error { return nil } -func validateStableswapTakerFee(i interface{}) error { - // Convert the given parameter to sdk.Dec. - stableswapTakerFee, ok := i.(sdk.Dec) - - if !ok { - return fmt.Errorf("invalid parameter type: %T", i) - } - - // Ensure that the passed in discount rate is between 0 and 1. - if stableswapTakerFee.IsNegative() || stableswapTakerFee.GT(sdk.OneDec()) { - return fmt.Errorf("invalid stableswap taker fee: %s", stableswapTakerFee) - } - - return nil -} - func validateTakerFeeDistribution(i interface{}) error { // Convert the given parameter to sdk.Dec. takerFeeDistribution, ok := i.(TakerFeeDistributionPercentage) diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go index 0f0ae9b6702..2b2c9424ec8 100644 --- a/x/protorev/keeper/keeper_test.go +++ b/x/protorev/keeper/keeper_test.go @@ -59,7 +59,6 @@ func (s *KeeperTestSuite) SetupTest() { poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) poolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() - poolManagerParams.TakerFeeParams.StableswapTakerFee = sdk.ZeroDec() s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) // Genesis on init should be the same as the default genesis From 150eeb1a13e6afd22b5e7ef43d603e411e60412a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 17:33:17 -0500 Subject: [PATCH 40/83] sim msg change --- x/concentrated-liquidity/keeper.go | 13 +++++++++++-- x/concentrated-liquidity/simulation/sim_msgs.go | 4 ++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/x/concentrated-liquidity/keeper.go b/x/concentrated-liquidity/keeper.go index 24ef6361986..d215c45b295 100644 --- a/x/concentrated-liquidity/keeper.go +++ b/x/concentrated-liquidity/keeper.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" + poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" ) type Keeper struct { @@ -127,6 +128,14 @@ func (k Keeper) ValidatePermissionlessPoolCreationEnabled(ctx sdk.Context) error return nil } -func (k Keeper) GetPoolManagerKeeper() types.PoolManagerKeeper { - return k.poolmanagerKeeper +// PoolManagerGetParams is a wrapper for poolmanager's GetParams, and is solely used +// to get access to this method for use in sim_msgs.go for the CL module. +func (k Keeper) PoolManagerGetParams(ctx sdk.Context) poolmanagertypes.Params { + return k.poolmanagerKeeper.GetParams(ctx) +} + +// PoolManagerSetParams is a wrapper for poolmanager's SetParams, and is solely used +// to get access to this method for use in sim_msgs.go for the CL module. +func (k Keeper) PoolManagerSetParams(ctx sdk.Context, params poolmanagertypes.Params) { + k.poolmanagerKeeper.SetParams(ctx, params) } diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go index 4c7cc93ebe6..e901520c784 100644 --- a/x/concentrated-liquidity/simulation/sim_msgs.go +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -31,9 +31,9 @@ func RandomMsgCreateConcentratedPool(k clkeeper.Keeper, sim *osmosimtypes.SimCtx k.SetParams(ctx, defaultParams) // make sure the denoms are valid authorized quote denoms - poolManagerParams := k.GetPoolManagerKeeper().GetParams(ctx) + poolManagerParams := k.PoolManagerGetParams(ctx) poolManagerParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, coin1.Denom, coin0.Denom) - k.GetPoolManagerKeeper().SetParams(ctx, poolManagerParams) + k.PoolManagerSetParams(ctx, poolManagerParams) denomMetaData := banktypes.Metadata{ DenomUnits: []*banktypes.DenomUnit{{ From 08bb1eab413e840ed15cc97c0640cf36ba9dc356 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 17:45:33 -0500 Subject: [PATCH 41/83] add test for CLI --- x/poolmanager/client/cli/tx.go | 6 ++-- x/poolmanager/client/cli/tx_test.go | 51 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/x/poolmanager/client/cli/tx.go b/x/poolmanager/client/cli/tx.go index 7340a4a81b6..6b19a60f4ee 100644 --- a/x/poolmanager/client/cli/tx.go +++ b/x/poolmanager/client/cli/tx.go @@ -560,7 +560,7 @@ func parseDenomPairTakerFeeArgToContent(cmd *cobra.Command, arg string) (govtype return nil, err } - denomPairTakerFee, err := parsedenomPairTakerFee(arg) + denomPairTakerFee, err := ParseDenomPairTakerFee(arg) if err != nil { return nil, err } @@ -575,7 +575,7 @@ func parseDenomPairTakerFeeArgToContent(cmd *cobra.Command, arg string) (govtype } func parseDenomPairTakerFeeArgToMsg(clientCtx client.Context, arg string) (sdk.Msg, error) { - denomPairTakerFee, err := parsedenomPairTakerFee(arg) + denomPairTakerFee, err := ParseDenomPairTakerFee(arg) if err != nil { return nil, err } @@ -588,7 +588,7 @@ func parseDenomPairTakerFeeArgToMsg(clientCtx client.Context, arg string) (sdk.M return msg, nil } -func parsedenomPairTakerFee(arg string) ([]types.DenomPairTakerFee, error) { +func ParseDenomPairTakerFee(arg string) ([]types.DenomPairTakerFee, error) { denomPairTakerFeeRecords := strings.Split(arg, ",") if len(denomPairTakerFeeRecords)%3 != 0 { diff --git a/x/poolmanager/client/cli/tx_test.go b/x/poolmanager/client/cli/tx_test.go index 0b3fe70e1be..e912c0f30bf 100644 --- a/x/poolmanager/client/cli/tx_test.go +++ b/x/poolmanager/client/cli/tx_test.go @@ -1,12 +1,14 @@ package cli_test import ( + "fmt" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/osmosis-labs/osmosis/v17/x/poolmanager/client/cli" + "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" ) func TestParseCoinsNoSort(t *testing.T) { @@ -68,3 +70,52 @@ func TestParseCoinsNoSort(t *testing.T) { }) } } + +func TestParseDenomPairTakerFee(t *testing.T) { + tests := map[string]struct { + denomPairTakerFeeStr string + expectedDenomPairTakerFee []types.DenomPairTakerFee + expectedError error + }{ + "one set": { + denomPairTakerFeeStr: "uion,uosmo,0.0016", + expectedDenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "uion", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0016"), + }}, + }, + "two sets": { + denomPairTakerFeeStr: "uion,uosmo,0.0016,stake,uosmo,0.005", + expectedDenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "uion", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0016"), + }, + { + Denom0: "stake", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.005"), + }, + }, + }, + "error: wrong format": { + denomPairTakerFeeStr: "uion,uosmo,0.0016,stake", + expectedError: fmt.Errorf("denomPairTakerFeeRecords must be a list of denom0, denom1, and takerFee separated by commas"), + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + denomPairTakerFee, err := cli.ParseDenomPairTakerFee(tc.denomPairTakerFeeStr) + if tc.expectedError != nil { + require.ErrorAs(t, err, &tc.expectedError) + return + } + require.NoError(t, err) + require.Equal(t, tc.expectedDenomPairTakerFee, denomPairTakerFee) + }) + } +} From a300d6ef8583a8f5794be1c5b11e2f3ca0846027 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 18:53:00 -0500 Subject: [PATCH 42/83] msg server tests --- x/poolmanager/msg_server_test.go | 92 ++++++++++++++++++++++++++++++++ x/poolmanager/types/msgs.go | 4 ++ 2 files changed, 96 insertions(+) diff --git a/x/poolmanager/msg_server_test.go b/x/poolmanager/msg_server_test.go index b26c4633b48..fe966d67fc8 100644 --- a/x/poolmanager/msg_server_test.go +++ b/x/poolmanager/msg_server_test.go @@ -196,3 +196,95 @@ func (s *KeeperTestSuite) TestSplitRouteSwapExactAmountOut() { }) } } + +func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { + adminAcc := s.TestAccs[0].String() + nonAdminAcc := s.TestAccs[1].String() + testcases := map[string]struct { + denomPairTakerFeeMessage types.MsgSetDenomPairTakerFee + + expectedSetDenomPairTakerFeeEvent int + expectedMessageEvents int + expectedError bool + }{ + "valid case: two pairs": { + denomPairTakerFeeMessage: types.MsgSetDenomPairTakerFee{ + Sender: adminAcc, + DenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "denom0", + Denom1: "denom1", + TakerFee: sdk.MustNewDecFromStr("0.0013"), + }, + { + Denom0: "denom0", + Denom1: "denom2", + TakerFee: sdk.MustNewDecFromStr("0.0016"), + }, + }, + }, + + expectedSetDenomPairTakerFeeEvent: 2, + expectedMessageEvents: 1, + }, + "valid case: one pair": { + denomPairTakerFeeMessage: types.MsgSetDenomPairTakerFee{ + Sender: adminAcc, + DenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "denom0", + Denom1: "denom1", + TakerFee: sdk.MustNewDecFromStr("0.0013"), + }, + }, + }, + + expectedSetDenomPairTakerFeeEvent: 1, + expectedMessageEvents: 1, + }, + "error: not admin account": { + denomPairTakerFeeMessage: types.MsgSetDenomPairTakerFee{ + Sender: nonAdminAcc, + DenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "denom0", + Denom1: "denom1", + TakerFee: sdk.MustNewDecFromStr("0.0013"), + }, + }, + }, + + expectedError: true, + }, + } + + for name, tc := range testcases { + s.Run(name, func() { + s.Setup() + msgServer := poolmanagerKeeper.NewMsgServerImpl(s.App.PoolManagerKeeper) + + // Add the admin address to the pool manager params. + poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) + poolManagerParams.TakerFeeParams.AdminAddresses = []string{adminAcc} + s.App.PoolManagerKeeper.SetParams(s.Ctx, poolManagerParams) + + // Reset event counts to 0 by creating a new manager. + s.Ctx = s.Ctx.WithEventManager(sdk.NewEventManager()) + s.Equal(0, len(s.Ctx.EventManager().Events())) + + response, err := msgServer.SetDenomPairTakerFee(sdk.WrapSDKContext(s.Ctx), &types.MsgSetDenomPairTakerFee{ + Sender: tc.denomPairTakerFeeMessage.Sender, + DenomPairTakerFee: tc.denomPairTakerFeeMessage.DenomPairTakerFee, + }) + if tc.expectedError { + s.Require().Error(err) + s.Require().Nil(response) + } else { + s.Require().NoError(err) + s.AssertEventEmitted(s.Ctx, types.TypeMsgSetDenomPairTakerFee, tc.expectedSetDenomPairTakerFeeEvent) + s.AssertEventEmitted(s.Ctx, sdk.EventTypeMessage, tc.expectedMessageEvents) + } + + }) + } +} diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index 39919abd0a9..662b5dedc30 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -179,6 +179,10 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { return InvalidSenderError{Sender: msg.Sender} } + if len(msg.DenomPairTakerFee) == 0 { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty denom pair taker fee") + } + for _, denomPair := range msg.DenomPairTakerFee { if err := sdk.ValidateDenom(denomPair.Denom0); err != nil { return err From 411bfa658fdeffae9ecb52e282bfc8525887d71d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 19:06:22 -0500 Subject: [PATCH 43/83] add route_test test --- x/poolmanager/router.go | 7 +++---- x/poolmanager/router_test.go | 29 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 71001de7766..4ce25432a7c 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -225,9 +225,9 @@ func (k Keeper) SwapExactAmountIn( // SwapExactAmountInNoTakerFee is an API for swapping an exact amount of tokens // as input to a pool to get a minimum amount of the desired token out. -// This method does NOT charge a taker fee, and should only be used in the the -// txfees hooks when swapping taker fees. This prevents us from charging taker fees -// on taker fees. +// This method does NOT charge a taker fee, and should only be used in txfees hooks +// when swapping taker fees. This prevents us from charging taker fees +// on top of taker fees. func (k Keeper) SwapExactAmountInNoTakerFee( ctx sdk.Context, sender sdk.AccAddress, @@ -352,7 +352,6 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, tokenOut sdk.Coin, ) (tokenInAmount sdk.Int, err error) { isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} - // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountOutRoutes(route) if err := routeStep.Validate(); err != nil { diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 8a7c082223f..c5da7b059b0 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -1492,9 +1492,10 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { tokenOutDenom string tokenOutMinAmount sdk.Int expectedTokenOutAmount sdk.Int + swapWithNoTakerFee bool expectError bool }{ - // We have: + // Swap with taker fee: // - foo: 1000000000000 // - bar: 1000000000000 // - spreadFactor: 0.1% @@ -1512,6 +1513,24 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { tokenOutDenom: bar, expectedTokenOutAmount: sdk.NewInt(99750), }, + // Swap with no taker fee: + // - foo: 1000000000000 + // - bar: 1000000000000 + // - spreadFactor: 0.1% + // - foo in: 100000 + // - bar amount out will be calculated according to the formula + // https://www.wolframalpha.com/input?i=solve+%2810%5E12+%2B+10%5E5+x+0.999%29%2810%5E12+-+x%29+%3D+10%5E24 + { + name: "Swap - [foo -> bar], 0.1 percent fee", + poolId: 1, + poolCoins: sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), + poolFee: defaultPoolSpreadFactor, + tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), + tokenOutMinAmount: sdk.NewInt(1), + tokenOutDenom: bar, + swapWithNoTakerFee: true, + expectedTokenOutAmount: sdk.NewInt(99899), + }, { name: "Wrong pool id", poolId: 2, @@ -1556,7 +1575,13 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { }) // execute the swap - multihopTokenOutAmount, err := poolmanagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], tc.poolId, tc.tokenIn, tc.tokenOutDenom, tc.tokenOutMinAmount) + var multihopTokenOutAmount sdk.Int + var err error + if tc.swapWithNoTakerFee { + multihopTokenOutAmount, err = poolmanagerKeeper.SwapExactAmountInNoTakerFee(s.Ctx, s.TestAccs[0], tc.poolId, tc.tokenIn, tc.tokenOutDenom, tc.tokenOutMinAmount) + } else { + multihopTokenOutAmount, err = poolmanagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], tc.poolId, tc.tokenIn, tc.tokenOutDenom, tc.tokenOutMinAmount) + } if tc.expectError { s.Require().Error(err) } else { From 236505ddc959b5f1f22035cb03fd1677a71964e3 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 19:22:46 -0500 Subject: [PATCH 44/83] add gov_test.go --- x/poolmanager/types/gov_test.go | 146 ++++++++++++++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 x/poolmanager/types/gov_test.go diff --git a/x/poolmanager/types/gov_test.go b/x/poolmanager/types/gov_test.go new file mode 100644 index 00000000000..b84d49f3806 --- /dev/null +++ b/x/poolmanager/types/gov_test.go @@ -0,0 +1,146 @@ +package types_test + +import ( + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + proto "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" +) + +func TestDenomPairTakerFeeProposalMarshalUnmarshal(t *testing.T) { + records := []types.DenomPairTakerFee{ + { + Denom0: "uion", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0013"), + }, + { + Denom0: "stake", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0016"), + }, + { + Denom0: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0017"), + }, + } + + tests := []struct { + proposal *types.DenomPairTakerFeeProposal + }{ + { // empty title + proposal: &types.DenomPairTakerFeeProposal{ + Title: "", + Description: "proposal to add denom pair taker fee records", + }, + }, + { // empty description + proposal: &types.DenomPairTakerFeeProposal{ + Title: "title", + Description: "", + }, + }, + { // happy path + proposal: &types.DenomPairTakerFeeProposal{ + Title: "title", + Description: "proposal to add denom pair taker fee records", + DenomPairTakerFee: records, + }, + }, + } + + for _, test := range tests { + bz, err := proto.Marshal(test.proposal) + require.NoError(t, err) + decoded := types.DenomPairTakerFeeProposal{} + err = proto.Unmarshal(bz, &decoded) + require.NoError(t, err) + require.Equal(t, *test.proposal, decoded) + } +} + +func TestDenomPairTakerFeeProposal_ValidateBasic(t *testing.T) { + baseRecord := types.DenomPairTakerFee{ + Denom0: "uion", + Denom1: "uosmo", + TakerFee: sdk.MustNewDecFromStr("0.0013"), + } + + withSameDenom := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { + record.Denom1 = record.Denom0 + return record + } + + withInvalidDenom0 := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { + record.Denom0 = "0" + return record + } + + withInvalidDenom1 := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { + record.Denom1 = "1" + return record + } + + withInvalidTakerFee := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { + record.TakerFee = sdk.MustNewDecFromStr("1.01") + return record + } + + withInvalidRecord := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { + record = types.DenomPairTakerFee{} + return record + } + + tests := []struct { + name string + modifyFunc func(types.DenomPairTakerFee) types.DenomPairTakerFee + expectPass bool + }{ + { + name: "proper msg", + modifyFunc: func(record types.DenomPairTakerFee) types.DenomPairTakerFee { return record }, + expectPass: true, + }, + { + name: "invalid denom pair", + modifyFunc: withSameDenom, + expectPass: false, + }, + { + name: "invalid denom0", + modifyFunc: withInvalidDenom0, + expectPass: false, + }, + { + name: "invalid denom1", + modifyFunc: withInvalidDenom1, + expectPass: false, + }, + { + name: "invalid taker fee", + modifyFunc: withInvalidTakerFee, + expectPass: false, + }, + { + name: "invalid record", + modifyFunc: withInvalidRecord, + expectPass: false, + }, + } + + for _, test := range tests { + records := []types.DenomPairTakerFee{test.modifyFunc(baseRecord)} + + denomPairTakerFeeProposal := types.NewDenomPairTakerFeeProposal("title", "description", records) + + if test.expectPass { + require.NoError(t, denomPairTakerFeeProposal.ValidateBasic(), "test: %v", test.name) + } else { + require.Error(t, denomPairTakerFeeProposal.ValidateBasic(), "test: %v", test.name) + } + } +} From 9c17b7061a07e2c511be9b1c0aab364011042ea6 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 21:19:15 -0500 Subject: [PATCH 45/83] add msgs_test.go --- x/poolmanager/types/msgs.go | 7 +++ x/poolmanager/types/msgs_test.go | 86 ++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index 662b5dedc30..5837464f0a5 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -1,6 +1,8 @@ package types import ( + "fmt" + errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -183,6 +185,8 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty denom pair taker fee") } + fmt.Println("msg.DenomPairTakerFee", msg.DenomPairTakerFee) + for _, denomPair := range msg.DenomPairTakerFee { if err := sdk.ValidateDenom(denomPair.Denom0); err != nil { return err @@ -190,6 +194,9 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { if err := sdk.ValidateDenom(denomPair.Denom1); err != nil { return err } + if denomPair.Denom0 == denomPair.Denom1 { + return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Denom pair cannot consist of the same denoms") + } if denomPair.TakerFee.IsNegative() { return nonPositiveAmountError{denomPair.TakerFee.String()} } diff --git a/x/poolmanager/types/msgs_test.go b/x/poolmanager/types/msgs_test.go index 29e1df01418..3ee4be39a49 100644 --- a/x/poolmanager/types/msgs_test.go +++ b/x/poolmanager/types/msgs_test.go @@ -567,3 +567,89 @@ func TestMsgSplitRouteSwapExactAmountOut(t *testing.T) { }) } } + +func TestMsgSetDenomPairTakerFee(t *testing.T) { + createMsg := func(after func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + properMsg := types.MsgSetDenomPairTakerFee{ + Sender: addr1, + DenomPairTakerFee: []types.DenomPairTakerFee{ + { + Denom0: "uosmo", + Denom1: "uatom", + TakerFee: sdk.MustNewDecFromStr("0.003"), + }, + { + Denom0: "uosmo", + Denom1: "uion", + TakerFee: sdk.MustNewDecFromStr("0.006"), + }, + }, + } + + return after(properMsg) + } + + msg := createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + // Do nothing + return msg + }) + + require.Equal(t, msg.Route(), types.RouterKey) + require.Equal(t, msg.Type(), types.TypeMsgSetDenomPairTakerFee) + signers := msg.GetSigners() + require.Equal(t, len(signers), 1) + require.Equal(t, signers[0].String(), addr1) + + tests := map[string]struct { + msg types.MsgSetDenomPairTakerFee + expectError bool + }{ + "valid": { + msg: createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + // Do nothing + return msg + }), + }, + "invalid sender": { + msg: createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + msg.Sender = "" + return msg + }), + expectError: true, + }, + "invalid denom0": { + msg: createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + msg.DenomPairTakerFee[0].Denom0 = "" + return msg + }), + expectError: true, + }, + "invalid denom1": { + msg: createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + msg.DenomPairTakerFee[0].Denom1 = "" + return msg + }), + expectError: true, + }, + "invalid denom0 = denom1": { + msg: createMsg(func(msg types.MsgSetDenomPairTakerFee) types.MsgSetDenomPairTakerFee { + msg.DenomPairTakerFee[0].Denom0 = msg.DenomPairTakerFee[0].Denom1 + return msg + }), + expectError: true, + }, + } + + for name, tc := range tests { + tc := tc + t.Run(name, func(t *testing.T) { + err := tc.msg.ValidateBasic() + + if tc.expectError { + require.Error(t, err) + return + } + require.NoError(t, err) + }) + } +} From 41a1968234ee69be9a29eda2e97990a310838e87 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 22 Aug 2023 21:20:05 -0500 Subject: [PATCH 46/83] remove print line --- x/poolmanager/types/msgs.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index 5837464f0a5..6ad57273275 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -185,8 +183,6 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty denom pair taker fee") } - fmt.Println("msg.DenomPairTakerFee", msg.DenomPairTakerFee) - for _, denomPair := range msg.DenomPairTakerFee { if err := sdk.ValidateDenom(denomPair.Denom0); err != nil { return err From d081c2a30da808b41cdf333b31ddd90c9051976b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 25 Aug 2023 21:38:06 -0600 Subject: [PATCH 47/83] change from v18 to v19 --- Makefile | 2 +- app/app.go | 4 ++-- app/upgrades/{v18 => v19}/constants.go | 4 ++-- app/upgrades/{v18 => v19}/upgrades.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) rename app/upgrades/{v18 => v19}/constants.go (91%) rename app/upgrades/{v18 => v19}/upgrades.go (99%) diff --git a/Makefile b/Makefile index 227ef5698f3..5c3d7dac135 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LEDGER_ENABLED ?= true SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g') BUILDDIR ?= $(CURDIR)/build DOCKER := $(shell which docker) -E2E_UPGRADE_VERSION := "v18" +E2E_UPGRADE_VERSION := "v19" #SHELL := /bin/bash GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2) diff --git a/app/app.go b/app/app.go index 56e97081517..ebce34fe242 100644 --- a/app/app.go +++ b/app/app.go @@ -58,7 +58,7 @@ import ( v15 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v15" v16 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v16" v17 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v17" - v18 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v18" + v19 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v19" v3 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v3" v4 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v4" v5 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v5" @@ -104,7 +104,7 @@ var ( // _ sdksimapp.App = (*OsmosisApp)(nil) - Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v18.Upgrade} + Upgrades = []upgrades.Upgrade{v4.Upgrade, v5.Upgrade, v7.Upgrade, v9.Upgrade, v11.Upgrade, v12.Upgrade, v13.Upgrade, v14.Upgrade, v15.Upgrade, v16.Upgrade, v17.Upgrade, v19.Upgrade} Forks = []upgrades.Fork{v3.Fork, v6.Fork, v8.Fork, v10.Fork} ) diff --git a/app/upgrades/v18/constants.go b/app/upgrades/v19/constants.go similarity index 91% rename from app/upgrades/v18/constants.go rename to app/upgrades/v19/constants.go index 73c9b440825..d216ad8be75 100644 --- a/app/upgrades/v18/constants.go +++ b/app/upgrades/v19/constants.go @@ -1,4 +1,4 @@ -package v18 +package v19 import ( "github.com/osmosis-labs/osmosis/v17/app/upgrades" @@ -7,7 +7,7 @@ import ( ) // UpgradeName defines the on-chain upgrade name for the Osmosis v18 upgrade. -const UpgradeName = "v18" +const UpgradeName = "v19" var Upgrade = upgrades.Upgrade{ UpgradeName: UpgradeName, diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v19/upgrades.go similarity index 99% rename from app/upgrades/v18/upgrades.go rename to app/upgrades/v19/upgrades.go index ae1d9e64e06..efd5fdcee4b 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -1,4 +1,4 @@ -package v18 +package v19 import ( sdk "github.com/cosmos/cosmos-sdk/types" From 4cb0230bdaad540ee07a461fa523c8dcf89f795f Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 25 Aug 2023 22:52:54 -0500 Subject: [PATCH 48/83] Update upgrades.go --- app/upgrades/v19/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index efd5fdcee4b..c76675be739 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -28,7 +28,7 @@ func CreateUpgradeHandler( // This needs to be moved because the pool manager requires access to these denoms to determine if the taker fee should // be swapped into OSMO or not. The concentrated liquidity module already requires access to the pool manager keeper, // so the right move in this case is to move this parameter upwards in order to prevent circular dependencies. - // TODO: In v19 upgrade handler, delete this param from the concentrated liquidity params. + // TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms From 5c9fbd8818f58d55419c89c8c0d2319be639b27c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 25 Aug 2023 22:31:03 -0600 Subject: [PATCH 49/83] set default taker fee to zero in upgrade handler --- app/upgrades/v19/upgrades.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index c76675be739..05b6d694954 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -32,7 +32,8 @@ func CreateUpgradeHandler( currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms - keepers.PoolManagerKeeper.SetParams(ctx, poolmanagertypes.DefaultParams()) + defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() + keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) return migrations, nil } From e617f04ead7ad508a33d3c5f0f00663242326d50 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 17:58:54 +0200 Subject: [PATCH 50/83] conflicts --- app/app.go | 24 +--- app/apptesting/concentrated_liquidity.go | 7 +- app/upgrades/v19/constants.go | 2 +- app/upgrades/v19/upgrades.go | 6 +- proto/osmosis/poolmanager/v1beta1/gov.proto | 2 +- tests/mocks/cl_pool.go | 4 - x/concentrated-liquidity/keeper.go | 6 +- x/poolmanager/client/cli/tx_test.go | 6 +- x/poolmanager/gov.go | 2 +- x/poolmanager/router.go | 8 +- x/poolmanager/taker_fee.go | 6 +- x/poolmanager/types/genesis.pb.go | 133 ++++++++------------ x/poolmanager/types/gov.pb.go | 4 +- x/poolmanager/types/gov_test.go | 2 +- x/poolmanager/types/tx.pb.go | 76 ++--------- x/txfees/keeper/keeper_test.go | 7 +- 16 files changed, 79 insertions(+), 216 deletions(-) diff --git a/app/app.go b/app/app.go index 2d3f4c89496..39049932423 100644 --- a/app/app.go +++ b/app/app.go @@ -48,28 +48,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/crisis" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" -<<<<<<< HEAD - "github.com/osmosis-labs/osmosis/v17/app/keepers" - "github.com/osmosis-labs/osmosis/v17/app/upgrades" - v10 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v10" - v11 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v11" - v12 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v12" - v13 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v13" - v14 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v14" - v15 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v15" - v16 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v16" - v17 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v17" - v18 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v18" - v19 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v19" - v3 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v3" - v4 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v4" - v5 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v5" - v6 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v6" - v7 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v7" - v8 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v8" - v9 "github.com/osmosis-labs/osmosis/v17/app/upgrades/v9" - _ "github.com/osmosis-labs/osmosis/v17/client/docs/statik" -======= "github.com/osmosis-labs/osmosis/v19/app/keepers" "github.com/osmosis-labs/osmosis/v19/app/upgrades" v10 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v10" @@ -81,6 +59,7 @@ import ( v16 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v16" v17 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v17" v18 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v18" + v19 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v19" v3 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v3" v4 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v4" v5 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v5" @@ -89,7 +68,6 @@ import ( v8 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v8" v9 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v9" _ "github.com/osmosis-labs/osmosis/v19/client/docs/statik" ->>>>>>> main ) const appName = "OsmosisApp" diff --git a/app/apptesting/concentrated_liquidity.go b/app/apptesting/concentrated_liquidity.go index 0a80d24eb91..0f485c18e04 100644 --- a/app/apptesting/concentrated_liquidity.go +++ b/app/apptesting/concentrated_liquidity.go @@ -5,14 +5,9 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" -<<<<<<< HEAD - clmodel "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/model" - "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" - poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" -======= clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ->>>>>>> main + poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" ) diff --git a/app/upgrades/v19/constants.go b/app/upgrades/v19/constants.go index d216ad8be75..719ce80d496 100644 --- a/app/upgrades/v19/constants.go +++ b/app/upgrades/v19/constants.go @@ -1,7 +1,7 @@ package v19 import ( - "github.com/osmosis-labs/osmosis/v17/app/upgrades" + "github.com/osmosis-labs/osmosis/v19/app/upgrades" store "github.com/cosmos/cosmos-sdk/store/types" ) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 05b6d694954..484b987f0fc 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -5,9 +5,9 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" - "github.com/osmosis-labs/osmosis/v17/app/keepers" - "github.com/osmosis-labs/osmosis/v17/app/upgrades" - poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" + "github.com/osmosis-labs/osmosis/v19/app/keepers" + "github.com/osmosis-labs/osmosis/v19/app/upgrades" + poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) func CreateUpgradeHandler( diff --git a/proto/osmosis/poolmanager/v1beta1/gov.proto b/proto/osmosis/poolmanager/v1beta1/gov.proto index 935b205c24a..1a6ebcbb2d3 100644 --- a/proto/osmosis/poolmanager/v1beta1/gov.proto +++ b/proto/osmosis/poolmanager/v1beta1/gov.proto @@ -4,7 +4,7 @@ package osmosis.poolmanager.v1beta1; import "gogoproto/gogo.proto"; import "osmosis/poolmanager/v1beta1/tx.proto"; -option go_package = "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types"; +option go_package = "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types"; // DenomPairTakerFeeProposal is a type for adding/removing a custom taker fee(s) // for one or more denom pairs. diff --git a/tests/mocks/cl_pool.go b/tests/mocks/cl_pool.go index 081103c3ef7..cba059c90b4 100644 --- a/tests/mocks/cl_pool.go +++ b/tests/mocks/cl_pool.go @@ -10,12 +10,8 @@ import ( types "github.com/cosmos/cosmos-sdk/types" gomock "github.com/golang/mock/gomock" -<<<<<<< HEAD osmomath "github.com/osmosis-labs/osmosis/osmomath" - types0 "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" -======= types0 "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ->>>>>>> main ) // MockConcentratedPoolExtension is a mock of ConcentratedPoolExtension interface. diff --git a/x/concentrated-liquidity/keeper.go b/x/concentrated-liquidity/keeper.go index 13f1b70bfc9..ef92d23c032 100644 --- a/x/concentrated-liquidity/keeper.go +++ b/x/concentrated-liquidity/keeper.go @@ -8,12 +8,8 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/osmosis-labs/osmosis/osmoutils" -<<<<<<< HEAD - "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" - poolmanagertypes "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" -======= "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ->>>>>>> main + poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) type Keeper struct { diff --git a/x/poolmanager/client/cli/tx_test.go b/x/poolmanager/client/cli/tx_test.go index ad037d4de71..493cb28dbef 100644 --- a/x/poolmanager/client/cli/tx_test.go +++ b/x/poolmanager/client/cli/tx_test.go @@ -7,12 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" -<<<<<<< HEAD - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/client/cli" - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" -======= "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/cli" ->>>>>>> main + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) func TestParseCoinsNoSort(t *testing.T) { diff --git a/x/poolmanager/gov.go b/x/poolmanager/gov.go index eae1708d73a..b309d31bf7e 100644 --- a/x/poolmanager/gov.go +++ b/x/poolmanager/gov.go @@ -7,7 +7,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) func (k Keeper) HandleDenomPairTakerFeeProposal(ctx sdk.Context, p *types.DenomPairTakerFeeProposal) error { diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index f8ecfc226df..919475cd12d 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -7,16 +7,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" -<<<<<<< HEAD - appparams "github.com/osmosis-labs/osmosis/v17/app/params" + appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/osmoutils" - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" -======= - "github.com/osmosis-labs/osmosis/osmoutils" - appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ->>>>>>> main ) // 1 << 256 - 1 where 256 is the max bit length defined for sdk.Int diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index c56880e0f76..c056e019c11 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -5,11 +5,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" - appparams "github.com/osmosis-labs/osmosis/v17/app/params" + appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/osmoutils" - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" - txfeestypes "github.com/osmosis-labs/osmosis/v17/x/txfees/types" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" + txfeestypes "github.com/osmosis-labs/osmosis/v19/x/txfees/types" ) // SetDenomPairTakerFee sets the taker fee for the given trading pair. diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index f136d5d1626..f2d8dc354bb 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -308,89 +308,58 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ -<<<<<<< HEAD // 810 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0xdb, 0x46, - 0x10, 0x36, 0x6d, 0xc7, 0x80, 0x57, 0xa9, 0xd4, 0x10, 0x4d, 0xc3, 0xd8, 0x00, 0x29, 0x30, 0x40, - 0xa1, 0xa2, 0x08, 0x09, 0xbb, 0x40, 0x03, 0xb4, 0xe8, 0x41, 0xb2, 0x90, 0xb4, 0x40, 0x9b, 0x38, - 0x8c, 0x81, 0x02, 0xb9, 0x2c, 0x56, 0xe2, 0x98, 0x26, 0x4c, 0xee, 0x2a, 0xdc, 0xa5, 0x15, 0xf5, - 0xda, 0x17, 0x28, 0xd0, 0x6b, 0xcf, 0x3d, 0xf4, 0xd6, 0x37, 0xe8, 0xa1, 0x87, 0x1c, 0x73, 0x2c, - 0x7a, 0x60, 0x0b, 0xf9, 0x0d, 0xf4, 0x04, 0xc5, 0xfe, 0xc8, 0x32, 0xdd, 0x48, 0x88, 0x9b, 0x93, - 0xb4, 0x33, 0xf3, 0x7d, 0x33, 0xf3, 0xf1, 0x5b, 0x2c, 0xfa, 0x98, 0xf1, 0x9c, 0xf1, 0x94, 0x87, - 0x23, 0xc6, 0xb2, 0x9c, 0x50, 0x92, 0x40, 0x11, 0x9e, 0xed, 0x0d, 0x40, 0x90, 0xbd, 0x30, 0x01, - 0x0a, 0x3c, 0xe5, 0xc1, 0xa8, 0x60, 0x82, 0xd9, 0xbb, 0xa6, 0x34, 0xb8, 0x54, 0x1a, 0x98, 0xd2, - 0x9d, 0x0f, 0x12, 0x96, 0x30, 0x55, 0x17, 0xca, 0x7f, 0x1a, 0xb2, 0x73, 0x37, 0x61, 0x2c, 0xc9, - 0x20, 0x54, 0xa7, 0x41, 0x79, 0x1c, 0x12, 0x3a, 0x99, 0xa7, 0x86, 0x8a, 0x0e, 0x6b, 0x8c, 0x3e, - 0x98, 0x94, 0x7b, 0x15, 0x15, 0x97, 0x05, 0x11, 0x29, 0xa3, 0xf3, 0xbc, 0xae, 0x0e, 0x07, 0x84, - 0xc3, 0xc5, 0xac, 0x43, 0x96, 0xce, 0xf3, 0xc1, 0xaa, 0x9d, 0x72, 0x16, 0x97, 0x19, 0xe0, 0x82, - 0x95, 0x02, 0x74, 0xbd, 0x3f, 0x5b, 0x47, 0x5b, 0x87, 0xa4, 0x20, 0x39, 0xb7, 0x7f, 0xb2, 0xd0, - 0x2d, 0x89, 0xc2, 0xc3, 0x02, 0x54, 0x4b, 0x7c, 0x0c, 0xe0, 0x58, 0xed, 0x8d, 0x4e, 0x63, 0xff, - 0x6e, 0x60, 0xa6, 0x94, 0x7d, 0xe7, 0x8b, 0x07, 0x07, 0x2c, 0xa5, 0xbd, 0x6f, 0x5e, 0x55, 0xde, - 0xda, 0xac, 0xf2, 0x9c, 0x09, 0xc9, 0xb3, 0xcf, 0xfd, 0xff, 0x30, 0xf8, 0xbf, 0xfe, 0xed, 0x75, - 0x92, 0x54, 0x9c, 0x94, 0x83, 0x60, 0xc8, 0x72, 0xb3, 0xae, 0xf9, 0xb9, 0xcf, 0xe3, 0xd3, 0x50, - 0x4c, 0x46, 0xc0, 0x15, 0x19, 0x8f, 0x5a, 0x12, 0x7f, 0x60, 0xe0, 0x0f, 0x01, 0xec, 0x33, 0xf4, - 0xbe, 0x20, 0xa7, 0x50, 0x48, 0x2a, 0x3c, 0x52, 0x93, 0x3a, 0xeb, 0x6d, 0xab, 0xd3, 0xd8, 0xff, - 0x24, 0x58, 0xf1, 0x51, 0x82, 0x23, 0x09, 0x7a, 0x08, 0xa0, 0x97, 0xeb, 0x79, 0x66, 0xca, 0x3b, - 0x7a, 0xca, 0xab, 0x94, 0x7e, 0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 0xa1, 0xbf, 0xba, 0x9e, 0xa1, 0x17, 0x4a, 0x5e, 0xa1, 0xf3, 0xa3, 0xa6, 0x89, - 0x44, 0x3a, 0x60, 0x53, 0xd4, 0xac, 0x0b, 0xa0, 0x8c, 0xbc, 0xdd, 0x7b, 0x74, 0xed, 0x8e, 0xb7, - 0xdf, 0x24, 0xa7, 0x1f, 0xbd, 0x57, 0x93, 0xa9, 0xf7, 0xf4, 0xd5, 0xd4, 0xb5, 0x5e, 0x4f, 0x5d, - 0xeb, 0x9f, 0xa9, 0x6b, 0xfd, 0x78, 0xee, 0xae, 0xbd, 0x3e, 0x77, 0xd7, 0xfe, 0x3c, 0x77, 0xd7, - 0x9e, 0x3f, 0xb8, 0xd4, 0xc9, 0x38, 0xf4, 0x7e, 0x46, 0x06, 0x7c, 0x7e, 0x08, 0xcf, 0xf6, 0x1e, - 0x84, 0x2f, 0x6b, 0x8f, 0x8d, 0x6a, 0x3f, 0xd8, 0x52, 0xcf, 0xcb, 0xa7, 0xff, 0x06, 0x00, 0x00, - 0xff, 0xff, 0x89, 0xc6, 0x5c, 0xee, 0x64, 0x07, 0x00, 0x00, -======= - // 421 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0xb1, 0x6e, 0xd4, 0x40, - 0x10, 0xf5, 0x92, 0xe8, 0x8a, 0xbd, 0x48, 0x08, 0x8b, 0xc2, 0x09, 0x92, 0xcf, 0x32, 0x8d, 0x29, - 0xb2, 0xab, 0x0b, 0x05, 0x82, 0x8e, 0x8b, 0x04, 0x42, 0x02, 0x11, 0x4c, 0x47, 0x63, 0xad, 0xed, - 0x89, 0xb1, 0xb0, 0x3d, 0x96, 0x77, 0x1d, 0xe5, 0xfe, 0x02, 0x89, 0x9e, 0x0f, 0xe0, 0x3b, 0x28, - 0x52, 0x5e, 0x49, 0x75, 0xa0, 0xbb, 0x3f, 0xe0, 0x0b, 0xd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, 0xf2, 0x72, 0xea, 0x5a, 0xaf, 0xa6, 0xae, + 0xf5, 0xcf, 0xd4, 0xb5, 0x7e, 0x3c, 0x77, 0xd7, 0x5e, 0x9d, 0xbb, 0x6b, 0x7f, 0x9e, 0xbb, 0x6b, + 0xcf, 0x3e, 0xbd, 0xd4, 0xc9, 0x38, 0xf4, 0x7e, 0x46, 0x06, 0x7c, 0x7e, 0x08, 0xcf, 0xf6, 0x3e, + 0x0b, 0x5f, 0xd4, 0x1e, 0x1b, 0xd5, 0x7e, 0xb0, 0xa5, 0x9e, 0x97, 0x8f, 0xff, 0x0d, 0x00, 0x00, + 0xff, 0xff, 0xb2, 0xd3, 0xe1, 0xd1, 0x64, 0x07, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/poolmanager/types/gov.pb.go b/x/poolmanager/types/gov.pb.go index 42fdc8fd418..536341386bb 100644 --- a/x/poolmanager/types/gov.pb.go +++ b/x/poolmanager/types/gov.pb.go @@ -89,8 +89,8 @@ var fileDescriptor_c95b3c1cda2a8632 = []byte{ 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x3c, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x6a, 0xad, 0x6e, 0x4e, 0x62, 0x52, 0x31, 0x8c, 0xa3, - 0x5f, 0x66, 0x68, 0xae, 0x5f, 0x81, 0x12, 0x48, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, - 0x00, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x0d, 0xe7, 0x75, 0xea, 0xa2, 0x01, 0x00, 0x00, + 0x5f, 0x66, 0x68, 0xa9, 0x5f, 0x81, 0x12, 0x48, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, + 0x00, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x36, 0xf2, 0xc8, 0xd5, 0xa2, 0x01, 0x00, 0x00, } func (m *DenomPairTakerFeeProposal) Marshal() (dAtA []byte, err error) { diff --git a/x/poolmanager/types/gov_test.go b/x/poolmanager/types/gov_test.go index b84d49f3806..87dedc2ece7 100644 --- a/x/poolmanager/types/gov_test.go +++ b/x/poolmanager/types/gov_test.go @@ -7,7 +7,7 @@ import ( proto "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" - "github.com/osmosis-labs/osmosis/v17/x/poolmanager/types" + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) func TestDenomPairTakerFeeProposalMarshalUnmarshal(t *testing.T) { diff --git a/x/poolmanager/types/tx.pb.go b/x/poolmanager/types/tx.pb.go index 019fb961a44..dfc5a7fc6f3 100644 --- a/x/poolmanager/types/tx.pb.go +++ b/x/poolmanager/types/tx.pb.go @@ -600,11 +600,10 @@ func init() { } var fileDescriptor_acd130b4825d67dc = []byte{ -<<<<<<< HEAD // 990 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x97, 0x5d, 0x6f, 0xdb, 0x54, 0x18, 0xc7, 0x7b, 0x96, 0xd2, 0xb5, 0x67, 0x6c, 0x6b, 0x4c, 0x46, 0xb3, 0x74, 0x24, 0x95, 0x37, - 0x8d, 0x14, 0x61, 0x9b, 0x74, 0x93, 0x26, 0xb2, 0x49, 0x88, 0xac, 0x20, 0x2a, 0x2d, 0xca, 0x66, + 0x8d, 0x14, 0x61, 0x9b, 0x74, 0x93, 0xd0, 0xb2, 0x49, 0x88, 0xac, 0x20, 0x2a, 0x2d, 0xca, 0x66, 0xb8, 0xe2, 0xc6, 0x72, 0xd2, 0x43, 0xb0, 0x5a, 0x9f, 0x63, 0xe5, 0x1c, 0x6f, 0x99, 0x90, 0x90, 0x90, 0x76, 0xc3, 0x04, 0xd2, 0x10, 0x97, 0x08, 0x21, 0xf1, 0x09, 0xf8, 0x18, 0x13, 0x57, 0xbb, 0x44, 0x5c, 0x44, 0xa8, 0x45, 0xe2, 0xbe, 0x1f, 0x00, 0xa1, 0xf3, 0x62, 0x27, 0x75, 0x5d, 0x27, @@ -654,71 +653,16 @@ var fileDescriptor_acd130b4825d67dc = []byte{ 0x52, 0xbd, 0x77, 0x54, 0x37, 0xf9, 0x5e, 0xb7, 0x95, 0x41, 0x6c, 0xda, 0x28, 0x9f, 0x4b, 0x35, 0x6d, 0x44, 0xa6, 0x0d, 0xcd, 0x81, 0x4b, 0x63, 0x59, 0xe5, 0x69, 0x69, 0xe5, 0xa0, 0x62, 0x13, 0xf5, 0x26, 0x76, 0xdf, 0x58, 0xc5, 0x45, 0xa6, 0xca, 0xde, 0xf8, 0xfb, 0x35, 0x58, 0x68, 0xd3, - 0xbe, 0xf6, 0x0d, 0x80, 0xc5, 0xa3, 0xb7, 0x90, 0x46, 0xe6, 0x08, 0xd3, 0x2e, 0x56, 0x95, 0xf7, - 0x73, 0xbb, 0xc4, 0x92, 0x3f, 0x03, 0x50, 0x4b, 0x59, 0x5b, 0x1b, 0x39, 0x23, 0x76, 0x42, 0x56, - 0x69, 0xe6, 0xf7, 0x89, 0xcb, 0xf8, 0x05, 0xc0, 0xd5, 0xac, 0xab, 0xd9, 0xdd, 0xa9, 0xb1, 0x8f, - 0x77, 0xae, 0xdc, 0x3f, 0x85, 0x73, 0x5c, 0xe1, 0xaf, 0x00, 0x5e, 0xcb, 0xdc, 0xf4, 0xf7, 0x4e, - 0x9c, 0x85, 0x8b, 0xb7, 0x79, 0x1a, 0xef, 0xb8, 0xc8, 0xe7, 0x00, 0x96, 0x52, 0x37, 0xcc, 0xed, - 0xa9, 0xe1, 0x53, 0xbc, 0x2a, 0xf7, 0x4e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, 0xab, 0xbb, 0x20, 0x7e, 0xf1, 0xdd, - 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xb0, 0xbe, 0xa1, 0xd8, 0xad, 0x0e, 0x00, 0x00, -======= - // 818 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x96, 0x5f, 0x6b, 0xd3, 0x5e, - 0x18, 0xc7, 0x9b, 0x5f, 0xcb, 0x7e, 0xdb, 0x99, 0xfb, 0xd3, 0xb8, 0xb9, 0xae, 0x9b, 0xe9, 0x88, - 0x63, 0x76, 0x62, 0x13, 0xda, 0x09, 0xb2, 0x2a, 0x88, 0xdd, 0x04, 0x0b, 0x2b, 0x75, 0xf1, 0xce, - 0x9b, 0x92, 0x76, 0xa1, 0x86, 0x35, 0xe7, 0x84, 0x9e, 0x93, 0xad, 0x43, 0x10, 0x04, 0x6f, 0x14, - 0x85, 0x89, 0x97, 0x22, 0x82, 0xaf, 0xc0, 0x97, 0xb1, 0xcb, 0xdd, 0x29, 0x5e, 0x14, 0xd9, 0x2e, - 0xbc, 0xef, 0x2b, 0x90, 0x93, 0x93, 0x64, 0x6d, 0xd6, 0x65, 0x8d, 0x03, 0x77, 0xb3, 0x25, 0x27, - 0xcf, 0xbf, 0xef, 0xf3, 0x7c, 0xf2, 0xa4, 0x60, 0x11, 0x61, 0x03, 0x61, 0x1d, 0xcb, 0x26, 0x42, - 0x0d, 0x43, 0x85, 0x6a, 0x5d, 0x6b, 0xca, 0x3b, 0xd9, 0xaa, 0x46, 0xd4, 0xac, 0x4c, 0x5a, 0x92, - 0xd9, 0x44, 0x04, 0xf1, 0x73, 0x8e, 0x95, 0xd4, 0x65, 0x25, 0x39, 0x56, 0xc9, 0xa9, 0x3a, 0xaa, - 0x23, 0xdb, 0x4e, 0xa6, 0x57, 0xcc, 0x25, 0x19, 0x57, 0x0d, 0x1d, 0x22, 0xd9, 0xfe, 0xeb, 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f, 0xab, 0xb9, 0x90, 0x11, 0xcb, 0x16, 0x49, 0xe6, 0xc3, 0xfb, 0x78, 0x65, 0x7c, 0xe1, 0xc0, - 0x5c, 0xd0, 0xf7, 0xf8, 0xde, 0xb9, 0xb1, 0xcf, 0x76, 0x4e, 0xae, 0x5d, 0xc0, 0xd9, 0xab, 0xf0, - 0x2b, 0x07, 0xe6, 0x03, 0x5f, 0xef, 0xfb, 0x7f, 0x9d, 0x85, 0x36, 0x6f, 0xfd, 0x22, 0xde, 0x6e, - 0x91, 0x85, 0xcd, 0x83, 0x23, 0x81, 0x3b, 0x3c, 0x12, 0xb8, 0x5f, 0x47, 0x02, 0xb7, 0x7f, 0x2c, - 0x44, 0x0e, 0x8f, 0x85, 0xc8, 0x8f, 0x63, 0x21, 0xf2, 0xec, 0x6e, 0x17, 0xc4, 0x4e, 0xa6, 0x4c, - 0x43, 0xad, 0x62, 0xf7, 0x46, 0xde, 0xc9, 0xae, 0xca, 0xad, 0x9e, 0xb7, 0xca, 0x26, 0xbb, 0x3a, - 0x64, 0xff, 0xb2, 0x5e, 0xf9, 0x13, 0x00, 0x00, 0xff, 0xff, 0x78, 0xbd, 0x84, 0xd3, 0x15, 0x0c, - 0x00, 0x00, ->>>>>>> main + 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xab, 0x1c, 0xe7, 0xad, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 2de64d2860c..7eee526f7cf 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -10,14 +10,9 @@ import ( osmosisapp "github.com/osmosis-labs/osmosis/v19/app" -<<<<<<< HEAD - "github.com/osmosis-labs/osmosis/v17/app/apptesting" - protorevtypes "github.com/osmosis-labs/osmosis/v17/x/protorev/types" - "github.com/osmosis-labs/osmosis/v17/x/txfees/types" -======= "github.com/osmosis-labs/osmosis/v19/app/apptesting" + protorevtypes "github.com/osmosis-labs/osmosis/v19/x/protorev/types" "github.com/osmosis-labs/osmosis/v19/x/txfees/types" ->>>>>>> main ) type KeeperTestSuite struct { From 7e8f86e170226b504d8a70926e40bb1a00728211 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:39:39 +0200 Subject: [PATCH 51/83] Update proto/osmosis/poolmanager/v1beta1/genesis.proto --- proto/osmosis/poolmanager/v1beta1/genesis.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index ee70c8f5225..c682e06ac16 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -64,7 +64,7 @@ message TakerFeeParams { (gogoproto.nullable) = false ]; // non_osmo_taker_fee_distribution defines the distribution of taker fees - // generated in non-OSMO. As of this writing, it has two catagories: + // generated in non-OSMO. As of this writing, it has two categories: // - staking_rewards: the percent of the taker fee that gets swapped to OSMO // and then distirbuted to stakers. // - community_pool: the percent of the taker fee that gets sent to the From c23c5b5c4b6b0f05c3135d95e15cd32b08e598ac Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:39:55 +0200 Subject: [PATCH 52/83] Update proto/osmosis/poolmanager/v1beta1/genesis.proto --- proto/osmosis/poolmanager/v1beta1/genesis.proto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index c682e06ac16..4073ea321b7 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -78,7 +78,7 @@ message TakerFeeParams { ]; // admin_addresses is a list of addresses that are allowed to set and remove // custom taker fees for denom pairs. Governance also has the ability to set - // and removecustom taker fees for denom pairs, but with the normal governance + // and remove custom taker fees for denom pairs, but with the normal governance // delay. repeated string admin_addresses = 4 [ (gogoproto.moretags) = "yaml:\"admin_addresses\"" ]; From 6caac1ff998cb1ce1e58dd45bd6a9b5df5b46ddb Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:41:21 +0200 Subject: [PATCH 53/83] Update x/poolmanager/taker_fee.go --- x/poolmanager/taker_fee.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index c056e019c11..06f19ec9396 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -166,7 +166,7 @@ func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, } func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { - amountInAfterSubTakerFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + amountInAfterSubTakerFee := tokenIn.Amount.ToDec().MulTruncate(sdk.OneDec().Sub(takerFee)) tokenInAfterSubTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterSubTakerFee.TruncateInt()) takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenIn.Amount.Sub(tokenInAfterSubTakerFee.Amount)) From fbd570081625fd9f8eda9bc5dae5bc08f2c295e2 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 26 Aug 2023 19:45:54 +0000 Subject: [PATCH 54/83] Generated protofile changes --- proto/osmosis/poolmanager/v1beta1/genesis.proto | 4 ++-- x/poolmanager/types/genesis.pb.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 4073ea321b7..398d6967cbb 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -78,8 +78,8 @@ message TakerFeeParams { ]; // admin_addresses is a list of addresses that are allowed to set and remove // custom taker fees for denom pairs. Governance also has the ability to set - // and remove custom taker fees for denom pairs, but with the normal governance - // delay. + // and remove custom taker fees for denom pairs, but with the normal + // governance delay. repeated string admin_addresses = 4 [ (gogoproto.moretags) = "yaml:\"admin_addresses\"" ]; // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index f2d8dc354bb..5e80d223dbf 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -175,7 +175,7 @@ type TakerFeeParams struct { // community pool. OsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,2,opt,name=osmo_taker_fee_distribution,json=osmoTakerFeeDistribution,proto3" json:"osmo_taker_fee_distribution"` // non_osmo_taker_fee_distribution defines the distribution of taker fees - // generated in non-OSMO. As of this writing, it has two catagories: + // generated in non-OSMO. As of this writing, it has two categories: // - staking_rewards: the percent of the taker fee that gets swapped to OSMO // and then distirbuted to stakers. // - community_pool: the percent of the taker fee that gets sent to the @@ -186,8 +186,8 @@ type TakerFeeParams struct { NonOsmoTakerFeeDistribution TakerFeeDistributionPercentage `protobuf:"bytes,3,opt,name=non_osmo_taker_fee_distribution,json=nonOsmoTakerFeeDistribution,proto3" json:"non_osmo_taker_fee_distribution"` // admin_addresses is a list of addresses that are allowed to set and remove // custom taker fees for denom pairs. Governance also has the ability to set - // and removecustom taker fees for denom pairs, but with the normal governance - // delay. + // and remove custom taker fees for denom pairs, but with the normal + // governance delay. AdminAddresses []string `protobuf:"bytes,4,rep,name=admin_addresses,json=adminAddresses,proto3" json:"admin_addresses,omitempty" yaml:"admin_addresses"` // community_pool_denom_to_swap_non_whitelisted_assets_to is the denom that // non-whitelisted taker fees will be swapped to before being sent to From 55be63bdfaa72d2086eefb0022b58101d4b7a159 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:54:43 +0200 Subject: [PATCH 55/83] rename extractTakerFeeAndDistribute to chargeTakerFee --- x/poolmanager/router.go | 6 +++--- x/poolmanager/taker_fee.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index 919475cd12d..f3f8d06eaee 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -93,7 +93,7 @@ func (k Keeper) RouteExactAmountIn( spreadFactor = routeSpreadFactor.MulRoundUp((spreadFactor.QuoRoundUp(sumOfSpreadFactors))) } - tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, routeStep.TokenOutDenom, sender, true) + tokenInAfterSubTakerFee, err := k.chargeTakerFee(ctx, tokenIn, routeStep.TokenOutDenom, sender, true) if err != nil { return sdk.Int{}, err } @@ -212,7 +212,7 @@ func (k Keeper) SwapExactAmountIn( return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } - tokenInAfterSubTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, tokenOutDenom, sender, true) + tokenInAfterSubTakerFee, err := k.chargeTakerFee(ctx, tokenIn, tokenOutDenom, sender, true) if err != nil { return sdk.Int{}, err } @@ -443,7 +443,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, curTokenInAmount) - tokenInAfterAddTakerFee, err := k.extractTakerFeeAndDistribute(ctx, tokenIn, _tokenOut.Denom, sender, false) + tokenInAfterAddTakerFee, err := k.chargeTakerFee(ctx, tokenIn, _tokenOut.Denom, sender, false) if err != nil { return sdk.Int{}, err } diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 06f19ec9396..e55b0f3032b 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -74,10 +74,11 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( return takerFee.Dec, nil } -// extractTakerFeeAndDistribute takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. +// chargeTakerFee charges the taker fee for the swap. +// It takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. // Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we // pull directly from the pool and not the user's account. -func (k Keeper) extractTakerFeeAndDistribute(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { +func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName baseDenom := appparams.BaseCoinUnit From b716e7220b966e0105af2f40f3b231ed9a49b27d Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:59:01 +0200 Subject: [PATCH 56/83] clean up --- x/poolmanager/msg_server_test.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x/poolmanager/msg_server_test.go b/x/poolmanager/msg_server_test.go index 82e91ad00d7..334b8865df8 100644 --- a/x/poolmanager/msg_server_test.go +++ b/x/poolmanager/msg_server_test.go @@ -225,7 +225,6 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { }, expectedSetDenomPairTakerFeeEvent: 2, - expectedMessageEvents: 1, }, "valid case: one pair": { denomPairTakerFeeMessage: types.MsgSetDenomPairTakerFee{ @@ -240,7 +239,6 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { }, expectedSetDenomPairTakerFeeEvent: 1, - expectedMessageEvents: 1, }, "error: not admin account": { denomPairTakerFeeMessage: types.MsgSetDenomPairTakerFee{ @@ -282,9 +280,8 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { } else { s.Require().NoError(err) s.AssertEventEmitted(s.Ctx, types.TypeMsgSetDenomPairTakerFee, tc.expectedSetDenomPairTakerFeeEvent) - s.AssertEventEmitted(s.Ctx, sdk.EventTypeMessage, tc.expectedMessageEvents) + s.AssertEventEmitted(s.Ctx, sdk.EventTypeMessage, 1) } - }) } } From 0e5d2eb06b9efadcb06ffb442c48dcf6a641575a Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 21:59:29 +0200 Subject: [PATCH 57/83] comment --- x/txfees/keeper/feedecorator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index 1635256515e..ce66f2b8f3d 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -248,7 +248,7 @@ func DeductFees(txFeesKeeper types.TxFeesKeeper, bankKeeper types.BankKeeper, ct return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } } else { - // sends to NonNativeFeeCollectorName module account + // sends to NonNativeFeeCollectorForStakingRewardsName module account err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.NonNativeFeeCollectorForStakingRewardsName, fees) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) From 333dc17b8b02c63f03483045e04c4f796f3c698f Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 22:00:28 +0200 Subject: [PATCH 58/83] rename --- x/txfees/keeper/hooks.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 0bf1aad3eac..c329fe140af 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -14,14 +14,14 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN // at the end of each epoch, swap all non-OSMO fees into OSMO and transfer to fee module account func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - baseDenom, _ := k.GetBaseDenom(ctx) + defaultTxFeesDenom, _ := k.GetBaseDenom(ctx) nonNativeFeeCollectorForStakingRewardsAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) nonNativeFeeCollectorForStakingRewardsBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForStakingRewardsAddr) // Non-native fee collector for staking rewards get swapped entirely into base denom. for _, coin := range nonNativeFeeCollectorForStakingRewardsBalance { - if coin.Denom == baseDenom { + if coin.Denom == defaultTxFeesDenom { continue } @@ -30,7 +30,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb continue } - poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, baseDenom, coin.Denom) + poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, defaultTxFeesDenom, coin.Denom) if err != nil { // The pool route either doesn't exist or is disabled in protorev. // It will just accrue in the non-native fee collector account. @@ -48,13 +48,13 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that // are accruing from the taker fee itself. - _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, baseDenom, minAmountOut) + _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, defaultTxFeesDenom, minAmountOut) return err }) } // Now that the rewards have been swapped, transfer any base denom existing in the non-native fee collector to the fee collector (indirectly distributing to stakers) - baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, baseDenom)) + baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, defaultTxFeesDenom)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) return err From fca43b5dcc83edc1edf3920b65400325f4d10fe0 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 22:02:01 +0200 Subject: [PATCH 59/83] godoc for NonNativeFeeCollectorForCommunityPoolName --- x/txfees/types/keys.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x/txfees/types/keys.go b/x/txfees/types/keys.go index 9db441ae159..2ab6ff1e76f 100644 --- a/x/txfees/types/keys.go +++ b/x/txfees/types/keys.go @@ -14,8 +14,11 @@ const ( FeeCollectorName = "fee_collector" // NonNativeFeeCollectorForStakingRewardsName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). + // These fees go to the staking rewards pool. NonNativeFeeCollectorForStakingRewardsName = "non_native_fee_collector" + // NonNativeFeeCollectorForCommunityPoolName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). + // These fees go to the community pool. NonNativeFeeCollectorForCommunityPoolName = "non_native_fee_collector_community_pool" // QuerierRoute defines the module's query routing key From 3b4d80ca66a8a2292bffbee4aec7319d7cc3bd6e Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 22:08:53 +0200 Subject: [PATCH 60/83] baseDenom to defaultFeesDenom name change --- x/poolmanager/taker_fee.go | 10 +++++----- x/txfees/keeper/hooks.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index e55b0f3032b..6cae1322dd8 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -81,7 +81,7 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName - baseDenom := appparams.BaseCoinUnit + defaultTakerFeeDenom := appparams.BaseCoinUnit poolManagerParams := k.GetParams(ctx) takerFee, err := k.GetTradingPairTakerFee(ctx, tokenIn.Denom, tokenOutDenom) @@ -103,23 +103,23 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // We determine the distributution of the taker fee based on its denom // If the denom is the base denom: takerFeeAmtRemaining := takerFeeCoin.Amount - if takerFeeCoin.Denom == baseDenom { + if takerFeeCoin.Denom == defaultTakerFeeDenom { // Community Pool: if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { // Osmo community pool funds is a direct send osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) - osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) + osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { return sdk.Coin{}, err } - takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(baseDenom)) + takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(defaultTakerFeeDenom)) } // Staking Rewards: if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) // We could stream these rewards via the fee collector account, but this is decision to be made by governance. - osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, takerFeeAmtRemaining)) + osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, takerFeeAmtRemaining)) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) if err != nil { return sdk.Coin{}, err diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index c329fe140af..a56b3d66628 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -14,14 +14,14 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN // at the end of each epoch, swap all non-OSMO fees into OSMO and transfer to fee module account func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - defaultTxFeesDenom, _ := k.GetBaseDenom(ctx) + defaultFeesDenom, _ := k.GetBaseDenom(ctx) nonNativeFeeCollectorForStakingRewardsAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) nonNativeFeeCollectorForStakingRewardsBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForStakingRewardsAddr) // Non-native fee collector for staking rewards get swapped entirely into base denom. for _, coin := range nonNativeFeeCollectorForStakingRewardsBalance { - if coin.Denom == defaultTxFeesDenom { + if coin.Denom == defaultFeesDenom { continue } @@ -30,7 +30,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb continue } - poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, defaultTxFeesDenom, coin.Denom) + poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, defaultFeesDenom, coin.Denom) if err != nil { // The pool route either doesn't exist or is disabled in protorev. // It will just accrue in the non-native fee collector account. @@ -48,13 +48,13 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that // are accruing from the taker fee itself. - _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, defaultTxFeesDenom, minAmountOut) + _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, defaultFeesDenom, minAmountOut) return err }) } // Now that the rewards have been swapped, transfer any base denom existing in the non-native fee collector to the fee collector (indirectly distributing to stakers) - baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, defaultTxFeesDenom)) + baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, defaultFeesDenom)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) return err From 7563916a6755c6180ac2c774e9a8ad2c759acaf7 Mon Sep 17 00:00:00 2001 From: alpo Date: Sat, 26 Aug 2023 13:37:28 -0700 Subject: [PATCH 61/83] fix upgrade handler --- app/upgrades/v18/upgrades_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/upgrades/v18/upgrades_test.go b/app/upgrades/v18/upgrades_test.go index 63c994e1dcc..e23d59ceb0c 100644 --- a/app/upgrades/v18/upgrades_test.go +++ b/app/upgrades/v18/upgrades_test.go @@ -106,6 +106,7 @@ func (s *UpgradeTestSuite) TestUpgrade() { // Swap toSwap := sdk.NewCoin(pool.GetToken0(), sdk.NewInt(100)) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(toSwap)) _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], updatedCLPool, toSwap, pool.GetToken1(), sdk.NewInt(1), sdk.ZeroDec()) s.Require().NoError(err) @@ -233,7 +234,7 @@ func (suite *UpgradeTestSuite) ensurePreUpgradeDistributionPanics() { suite.App.ConcentratedLiquidityKeeper.SetParams(suite.Ctx, clParams) // prepare CL pool with the same denom as pool 3, which is the pool we are testing with - clPool := suite.PrepareConcentratedPoolWithCoins(v17.OSMO, v17.AKTIBCDenom) + clPool := suite.PrepareConcentratedPoolWithCoins(v17.AKTIBCDenom, v17.OSMO) balancerToCLPoolLink := []gammmigration.BalancerToConcentratedPoolLink{ { BalancerPoolId: 3, From 72ffbb64d389b83f8b6e22099eb10c1f21670100 Mon Sep 17 00:00:00 2001 From: Roman Date: Sat, 26 Aug 2023 23:16:40 +0200 Subject: [PATCH 62/83] fix AfterEpochEnd order of denoms when getting pools; reduce code dupl; tests --- x/protorev/keeper/protorev.go | 23 +++++- x/protorev/types/errors.go | 12 +++ x/txfees/keeper/export_test.go | 7 ++ x/txfees/keeper/hooks.go | 122 +++++++++++------------------ x/txfees/keeper/hooks_test.go | 68 ++++++++++++++++ x/txfees/types/expected_keepers.go | 2 +- 6 files changed, 157 insertions(+), 77 deletions(-) create mode 100644 x/protorev/types/errors.go create mode 100644 x/txfees/keeper/export_test.go diff --git a/x/protorev/keeper/protorev.go b/x/protorev/keeper/protorev.go index 2d29be00752..1e44a5983ae 100644 --- a/x/protorev/keeper/protorev.go +++ b/x/protorev/keeper/protorev.go @@ -1,6 +1,7 @@ package keeper import ( + "errors" "fmt" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" @@ -125,13 +126,33 @@ func (k Keeper) GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch str bz := store.Get(key) if len(bz) == 0 { - return 0, fmt.Errorf("highest liquidity pool between base %s and match denom %s not found", baseDenom, denomToMatch) + return 0, types.NoPoolForDenomPairError{BaseDenom: baseDenom, MatchDenom: denomToMatch} } poolId := sdk.BigEndianToUint64(bz) return poolId, nil } +// GetPoolForDenomPairNoOrder returns the id of the pool between the two denoms. +// It is order-independent. That is, tokenA can either be a base or a quote. Both cases are handled. +// If no pool exists, an error is returned. +// TODO: unit test +func (k Keeper) GetPoolForDenomPairNoOrder(ctx sdk.Context, tokenA, tokenB string) (uint64, error) { + poolId, err := k.GetPoolForDenomPair(ctx, tokenA, tokenB) + if err != nil { + if errors.Is(err, types.NoPoolForDenomPairError{BaseDenom: tokenA, MatchDenom: tokenB}) { + // Attempt changing base and mathch denoms. + poolId, err = k.GetPoolForDenomPair(ctx, tokenB, tokenA) + if err != nil { + return 0, err + } + } else { + return 0, err + } + } + return poolId, nil +} + // SetPoolForDenomPair sets the id of the highest liquidty pool between the base denom and the denom to match func (k Keeper) SetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string, poolId uint64) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixDenomPairToPool) diff --git a/x/protorev/types/errors.go b/x/protorev/types/errors.go new file mode 100644 index 00000000000..ae8ddfe0f49 --- /dev/null +++ b/x/protorev/types/errors.go @@ -0,0 +1,12 @@ +package types + +import fmt "fmt" + +type NoPoolForDenomPairError struct { + BaseDenom string + MatchDenom string +} + +func (e NoPoolForDenomPairError) Error() string { + return fmt.Sprintf("highest liquidity pool between base %s and match denom %s not found", e.BaseDenom, e.MatchDenom) +} diff --git a/x/txfees/keeper/export_test.go b/x/txfees/keeper/export_test.go new file mode 100644 index 00000000000..b432816b3df --- /dev/null +++ b/x/txfees/keeper/export_test.go @@ -0,0 +1,7 @@ +package keeper + +import sdk "github.com/cosmos/cosmos-sdk/types" + +func (k Keeper) SwapNonNativeFeeToDenom(ctx sdk.Context, denomToSwapTo string, feeCollectorAddress sdk.AccAddress) { + k.swapNonNativeFeeToDenom(ctx, denomToSwapTo, feeCollectorAddress) +} diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index a56b3d66628..6e4ea67722c 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -16,97 +16,30 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { defaultFeesDenom, _ := k.GetBaseDenom(ctx) - nonNativeFeeCollectorForStakingRewardsAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) - nonNativeFeeCollectorForStakingRewardsBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForStakingRewardsAddr) + nonNativeStakingCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) // Non-native fee collector for staking rewards get swapped entirely into base denom. - for _, coin := range nonNativeFeeCollectorForStakingRewardsBalance { - if coin.Denom == defaultFeesDenom { - continue - } - - coinBalance := k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, coin.Denom) - if coinBalance.Amount.IsZero() { - continue - } - - poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, defaultFeesDenom, coin.Denom) - if err != nil { - // The pool route either doesn't exist or is disabled in protorev. - // It will just accrue in the non-native fee collector account. - // Skip this denom and move on to the next one. - continue - } - - // Do the swap of this fee token denom to base denom. - _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { - // We allow full slippage. Theres not really an effective way to bound slippage until TWAP's land, - // but even then the point is a bit moot. - // The only thing that could be done is a costly griefing attack to reduce the amount of osmo given as tx fees. - // However the idea of the txfees FeeToken gating is that the pool is sufficiently liquid for that base token. - minAmountOut := sdk.ZeroInt() - - // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that - // are accruing from the taker fee itself. - _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForStakingRewardsAddr, poolId, coinBalance, defaultFeesDenom, minAmountOut) - return err - }) - } + k.swapNonNativeFeeToDenom(ctx, defaultFeesDenom, nonNativeStakingCollectorAddress) // Now that the rewards have been swapped, transfer any base denom existing in the non-native fee collector to the fee collector (indirectly distributing to stakers) - baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForStakingRewardsAddr, defaultFeesDenom)) + baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeStakingCollectorAddress, defaultFeesDenom)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) return err }) // Non-native fee collector for community pool get swapped entirely into denom specified in the pool manager params. - poolManagerParams := k.poolManager.GetParams(ctx) denomToSwapTo := poolManagerParams.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo - - nonNativeFeeCollectorForCommunityPoolAddr := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForCommunityPoolName) - nonNativeFeeCollectorForCommunityPoolBalance := k.bankKeeper.GetAllBalances(ctx, nonNativeFeeCollectorForCommunityPoolAddr) - - // Only non whitelisted assets should exist here since we do direct community pool funds when calculating the taker fee if + // Only non-whitelisted assets should exist here since we do direct community pool funds when calculating the taker fee if // the input is a whitelisted asset. - for _, coin := range nonNativeFeeCollectorForCommunityPoolBalance { - if coin.Denom == denomToSwapTo { - continue - } - - coinBalance := k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForCommunityPoolAddr, coin.Denom) - if coinBalance.Amount.IsZero() { - continue - } - - poolId, err := k.protorevKeeper.GetPoolForDenomPair(ctx, denomToSwapTo, coin.Denom) - if err != nil { - // The pool route either doesn't exist or is disabled in protorev. - // It will just accrue in the non-native fee collector account. - // Skip this denom and move on to the next one. - continue - } - - // Do the swap of this fee token denom to base denom. - _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { - // We allow full slippage. Theres not really an effective way to bound slippage until TWAP's land, - // but even then the point is a bit moot. - // The only thing that could be done is a costly griefing attack to reduce the amount of osmo given as tx fees. - // However the idea of the txfees FeeToken gating is that the pool is sufficiently liquid for that base token. - minAmountOut := sdk.ZeroInt() - - // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that - // are accruing from the taker fee itself. - _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, nonNativeFeeCollectorForCommunityPoolAddr, poolId, coinBalance, denomToSwapTo, minAmountOut) - return err - }) - } + nonNativeCommunityPoolCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForCommunityPoolName) + k.swapNonNativeFeeToDenom(ctx, denomToSwapTo, nonNativeCommunityPoolCollectorAddress) // Now that the non whitelisted assets have been swapped, fund the community pool with the denom we swapped to. - denomToSwapToCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeFeeCollectorForCommunityPoolAddr, denomToSwapTo)) + denomToSwapToCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeCommunityPoolCollectorAddress, denomToSwapTo)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { - err := k.distributionKeeper.FundCommunityPool(ctx, denomToSwapToCoins, nonNativeFeeCollectorForCommunityPoolAddr) + err := k.distributionKeeper.FundCommunityPool(ctx, denomToSwapToCoins, nonNativeCommunityPoolCollectorAddress) return err }) @@ -132,3 +65,42 @@ func (h Hooks) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNu func (h Hooks) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { return h.k.AfterEpochEnd(ctx, epochIdentifier, epochNumber) } + +// swapNonNativeFeeToDenom swaps the given non-native fees into the given denom from the given fee collector address. +// If an error in swap occurs for a given denom, it will be silently skipped. +// CONTRACT: a pool must exist between each denom in the balance and denomToSwapTo. If doesn't exist. Silently skip swap. +// CONTRACT: protorev must be configured to have a pool for the given denom pair. Otherwise, the denom will be skipped. +func (k Keeper) swapNonNativeFeeToDenom(ctx sdk.Context, denomToSwapTo string, feeCollectorAddress sdk.AccAddress) { + feeCollectorBalance := k.bankKeeper.GetAllBalances(ctx, feeCollectorAddress) + + for _, coin := range feeCollectorBalance { + if coin.Denom == denomToSwapTo { + continue + } + + poolId, err := k.protorevKeeper.GetPoolForDenomPairNoOrder(ctx, denomToSwapTo, coin.Denom) + if err != nil { + if err != nil { + // The pool route either doesn't exist or is disabled in protorev. + // It will just accrue in the non-native fee collector account. + // Skip this denom and move on to the next one. + continue + } + + } + + // Do the swap of this fee token denom to base denom. + _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { + // We allow full slippage. Theres not really an effective way to bound slippage until TWAP's land, + // but even then the point is a bit moot. + // The only thing that could be done is a costly griefing attack to reduce the amount of osmo given as tx fees. + // However the idea of the txfees FeeToken gating is that the pool is sufficiently liquid for that base token. + minAmountOut := sdk.ZeroInt() + + // We swap without charging a taker fee / sending to the non native fee collector, since these are funds that + // are accruing from the taker fee itself. + _, err := k.poolManager.SwapExactAmountInNoTakerFee(cacheCtx, feeCollectorAddress, poolId, coin, denomToSwapTo, minAmountOut) + return err + }) + } +} diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index 016dcb0fc59..898a01d90ba 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/v19/app/apptesting" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/txfees/types" @@ -116,3 +117,70 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { }) } } + +func (s *KeeperTestSuite) TestSwapNonNativeFeeToDenom() { + s.Setup() + + var ( + defaultTxFeesDenom, _ = s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) + defaultPoolCoins = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, sdk.NewInt(100))) + defaultBalanceToSwap = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + ) + + tests := []struct { + name string + denomToSwapTo string + poolCoins sdk.Coins + preFundCoins sdk.Coins + feeCollectorAddress sdk.AccAddress + expectPass bool + }{ + { + name: "happy path", + denomToSwapTo: defaultTxFeesDenom, + poolCoins: defaultPoolCoins, + preFundCoins: defaultBalanceToSwap, + }, + + // TODO: add more test cases + // - pool does not exist for denom pair but protorev has it set for a pair + // - error in swap due to no liquidity + // - same denom in balance as denomToSwapTo + // - no pool exists for denom pair in protorev + // - many tokens in balance, some get swapped, others don't + // - different order of denoms in SetPoolForDenomPair() + } + + for _, tc := range tests { + tc := tc + + s.Run(tc.name, func() { + s.Setup() + + // Sets up account with no balance + testAccount := apptesting.CreateRandomAccounts(1)[0] + + // Create a pool to be swapped against + poolId := s.PrepareConcentratedPoolWithCoins(tc.poolCoins[0].Denom, tc.poolCoins[1].Denom).GetId() + + s.FundAcc(s.TestAccs[0], tc.poolCoins) + _, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, poolId, s.TestAccs[0], tc.poolCoins) + s.Require().NoError(err) + + // Set the pool for the denom pair + s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, tc.poolCoins[0].Denom, tc.poolCoins[1].Denom, poolId) + + // Fund the account with the preFundCoins + s.FundAcc(testAccount, tc.preFundCoins) + + s.App.TxFeesKeeper.SwapNonNativeFeeToDenom(s.Ctx, tc.denomToSwapTo, testAccount) + + // Check balance + balances := s.App.BankKeeper.GetAllBalances(s.Ctx, testAccount) + s.Require().Len(balances, 1) + + // Check that the denomToSwapTo is the denom of the balance + s.Require().Equal(balances[0].Denom, tc.denomToSwapTo) + }) + } +} diff --git a/x/txfees/types/expected_keepers.go b/x/txfees/types/expected_keepers.go index f3b98a9e5e2..cd0de930a52 100644 --- a/x/txfees/types/expected_keepers.go +++ b/x/txfees/types/expected_keepers.go @@ -71,7 +71,7 @@ type TxFeesKeeper interface { } type ProtorevKeeper interface { - GetPoolForDenomPair(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error) + GetPoolForDenomPairNoOrder(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error) } type DistributionKeeper interface { From cf5a80ca10a7af114c7b5433b0950cc34dd98751 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 19:42:17 -0500 Subject: [PATCH 63/83] fix track volume --- x/poolmanager/router.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index f3f8d06eaee..5acc078f16a 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -104,7 +104,7 @@ func (k Keeper) RouteExactAmountIn( } // Track volume for volume-splitting incentives - k.trackVolume(ctx, pool.GetId(), tokenInAfterSubTakerFee) + k.trackVolume(ctx, pool.GetId(), tokenIn) // Chain output of current pool as the input for the next routed pool tokenIn = sdk.NewCoin(routeStep.TokenOutDenom, tokenOutAmount) @@ -449,7 +449,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } // Track volume for volume-splitting incentives - k.trackVolume(ctx, pool.GetId(), sdk.NewCoin(routeStep.TokenInDenom, tokenInAfterAddTakerFee.Amount)) + k.trackVolume(ctx, pool.GetId(), sdk.NewCoin(routeStep.TokenInDenom, tokenIn.Amount)) // Sets the final amount of tokens that need to be input into the first pool. Even though this is the final return value for the // whole method and will not change after the first iteration, we still iterate through the rest of the pools to execute their respective From aab35ca62d4350b26fb46eb27d2fff595c36cd67 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 19:57:33 -0500 Subject: [PATCH 64/83] add key separator for pool manager --- x/poolmanager/types/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/poolmanager/types/keys.go b/x/poolmanager/types/keys.go index 9582c5b40e0..41a76bbf631 100644 --- a/x/poolmanager/types/keys.go +++ b/x/poolmanager/types/keys.go @@ -40,7 +40,7 @@ func FormatModuleRouteKey(poolId uint64) []byte { func FormatDenomTradePairKey(denom0, denom1 string) []byte { denoms := []string{denom0, denom1} sort.Strings(denoms) - return []byte(fmt.Sprintf("%s%s%s", DenomTradePairPrefix, denoms[0], denoms[1])) + return []byte(fmt.Sprintf("%s%s%s%s%s", DenomTradePairPrefix, KeySeparator, denoms[0], KeySeparator, denoms[1])) } // ParseModuleRouteFromBz parses the raw bytes into ModuleRoute. From b2c7d5038adcbaa1f2538d15e81c04447381849e Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 20:22:14 -0500 Subject: [PATCH 65/83] add comment to denom pair route --- x/txfees/keeper/hooks.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 6e4ea67722c..569c8a00df0 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -78,6 +78,12 @@ func (k Keeper) swapNonNativeFeeToDenom(ctx sdk.Context, denomToSwapTo string, f continue } + // Search for the denom pair route via the protorev store. + // Since OSMO is one of the protorev denoms, many of the routes will exist in this store. + // There will be times when this store does not know about a route, but this is acceptable + // since this will likely be a very small value of a relatively unknown token. If this begins + // to accrue more value, we can always manually register the route and it will get swapped in + // the next epoch. poolId, err := k.protorevKeeper.GetPoolForDenomPairNoOrder(ctx, denomToSwapTo, coin.Denom) if err != nil { if err != nil { From cbc2ff4cbc766b15b0dbcd71f622f9591b76ecc2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 21:16:38 -0500 Subject: [PATCH 66/83] add basic lexicographical key test --- x/poolmanager/types/keys_test.go | 36 ++++++++++++++++++++++++++++++++ x/txfees/keeper/hooks.go | 1 - 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 x/poolmanager/types/keys_test.go diff --git a/x/poolmanager/types/keys_test.go b/x/poolmanager/types/keys_test.go new file mode 100644 index 00000000000..07a68121a0a --- /dev/null +++ b/x/poolmanager/types/keys_test.go @@ -0,0 +1,36 @@ +package types_test + +import ( + "testing" + + "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" +) + +func TestFormatDenomTradePairKey(t *testing.T) { + tests := map[string]struct { + denom0 string + denom1 string + expectedKey string + }{ + "happy path": { + denom0: "uosmo", + denom1: "uion", + expectedKey: "\x04|uion|uosmo", + }, + "reversed denoms get reordered": { + denom0: "uion", + denom1: "uosmo", + expectedKey: "\x04|uion|uosmo", + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + formatDenomTradePairKey := types.FormatDenomTradePairKey(tc.denom0, tc.denom1) + stringFormatDenomTradePairKeyString := string(formatDenomTradePairKey) + require.Equal(t, tc.expectedKey, stringFormatDenomTradePairKeyString) + }) + } +} diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 569c8a00df0..9ece448b99c 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -92,7 +92,6 @@ func (k Keeper) swapNonNativeFeeToDenom(ctx sdk.Context, denomToSwapTo string, f // Skip this denom and move on to the next one. continue } - } // Do the swap of this fee token denom to base denom. From 0f2da85316575e361844ed53382756ccd6771bf0 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 21:18:33 -0500 Subject: [PATCH 67/83] update chargeTakerFee godoc --- x/poolmanager/taker_fee.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 6cae1322dd8..522d0a16d49 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -74,10 +74,8 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( return takerFee.Dec, nil } -// chargeTakerFee charges the taker fee for the swap. -// It takes in a pool and extracts the taker fee from the pool and sends it to the non native fee pool module account. -// Its important to note here that in the original swap, the taker fee + spread fee is sent to the pool's address, so this is why we -// pull directly from the pool and not the user's account. +// chargeTakerFee extracts the taker fee from the given tokenIn and sends it to the appropriate +// module account. It returns the tokenIn after the taker fee has been extracted. func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName From d129ea37f5490d8a212932a78cd35cb864c799c7 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sat, 26 Aug 2023 23:08:43 -0500 Subject: [PATCH 68/83] set the default taker fee back to non zero for e2e --- tests/e2e/e2e_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index a2894583319..50cc840d3c4 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -44,6 +44,12 @@ var ( // TODO: Find more scalable way to do this func (s *IntegrationTestSuite) TestAllE2E() { + // Reset the default taker fee to 0.15%, so we can actually run tests with it activated + s.T().Run("SetDefaultTakerFeeBothChains", func(t *testing.T) { + s.T().Log("resetting the default taker fee to 0.15%") + s.SetDefaultTakerFeeBothChains() + }) + // Zero Dependent Tests s.T().Run("CreateConcentratedLiquidityPoolVoting_And_TWAP", func(t *testing.T) { t.Parallel() @@ -1817,3 +1823,36 @@ func (s *IntegrationTestSuite) GeometricTWAP() { // quote assset supply / base asset supply = 1_000_000 / 2_000_000 = 0.5 osmoassert.DecApproxEq(s.T(), sdk.NewDecWithPrec(5, 1), afterSwapTwapBOverA, sdk.NewDecWithPrec(1, 2)) } + +func (s *IntegrationTestSuite) SetDefaultTakerFeeBothChains() { + var wg sync.WaitGroup + wg.Add(2) + + // Chain A + + go func() { + defer wg.Done() + chainA, chainANode, err := s.getChainACfgs() + s.Require().NoError(err) + s.SetDefaultTakerFee(chainA, chainANode) + }() + + // Chain B + + go func() { + defer wg.Done() + chainB, chainBNode, err := s.getChainBCfgs() + s.Require().NoError(err) + s.SetDefaultTakerFee(chainB, chainBNode) + }() + + // Wait for all goroutines to complete + wg.Wait() +} + +func (s *IntegrationTestSuite) SetDefaultTakerFee(chain *chain.Config, chainNode *chain.NodeConfig) { + // Change the parameter to set the default taker fee to a non zero value + + err := chainNode.ParamChangeProposal("poolmanager", string(poolmanagertypes.KeyDefaultTakerFee), json.RawMessage(`"0.001500000000000000"`), chain) + s.Require().NoError(err) +} From 9a5616dcd7406ba6af8fb3bb6b5bd6fbce6c73b2 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 27 Aug 2023 18:04:38 +0200 Subject: [PATCH 69/83] change PoolMangerGetParams API to GetAuthorizedQuoteDenoms (same for setters) --- x/concentrated-liquidity/keeper.go | 19 +++++++++++-------- .../simulation/sim_msgs.go | 6 +++--- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/x/concentrated-liquidity/keeper.go b/x/concentrated-liquidity/keeper.go index ef92d23c032..ba80b6094d7 100644 --- a/x/concentrated-liquidity/keeper.go +++ b/x/concentrated-liquidity/keeper.go @@ -9,7 +9,6 @@ import ( "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" - poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) type Keeper struct { @@ -128,14 +127,18 @@ func (k Keeper) ValidatePermissionlessPoolCreationEnabled(ctx sdk.Context) error return nil } -// PoolManagerGetParams is a wrapper for poolmanager's GetParams, and is solely used -// to get access to this method for use in sim_msgs.go for the CL module. -func (k Keeper) PoolManagerGetParams(ctx sdk.Context) poolmanagertypes.Params { - return k.poolmanagerKeeper.GetParams(ctx) +// GetAuthorizedQuoteDenoms gets the authorized quote denoms from the poolmanager keeper. +// This method is meant to be used for getting access to x/poolmanager params +// for use in sim_msgs.go for the CL module. +func (k Keeper) GetAuthorizedQuoteDenoms(ctx sdk.Context) []string { + return k.poolmanagerKeeper.GetParams(ctx).AuthorizedQuoteDenoms } -// PoolManagerSetParams is a wrapper for poolmanager's SetParams, and is solely used -// to get access to this method for use in sim_msgs.go for the CL module. -func (k Keeper) PoolManagerSetParams(ctx sdk.Context, params poolmanagertypes.Params) { +// SetAuthorizedQuoteDenoms sets the authorized quote denoms in the poolmanager keeper. +// This method is meant to be used for getting access to x/poolmanager params +// for use in sim_msgs.go for the CL module. +func (k Keeper) SetAuthorizedQuoteDenoms(ctx sdk.Context, authorizedQuoteDenoms []string) { + params := k.poolmanagerKeeper.GetParams(ctx) + params.AuthorizedQuoteDenoms = authorizedQuoteDenoms k.poolmanagerKeeper.SetParams(ctx, params) } diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go index f9529ef8656..757fa5df113 100644 --- a/x/concentrated-liquidity/simulation/sim_msgs.go +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -31,9 +31,9 @@ func RandomMsgCreateConcentratedPool(k clkeeper.Keeper, sim *osmosimtypes.SimCtx k.SetParams(ctx, defaultParams) // make sure the denoms are valid authorized quote denoms - poolManagerParams := k.PoolManagerGetParams(ctx) - poolManagerParams.AuthorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, coin1.Denom, coin0.Denom) - k.PoolManagerSetParams(ctx, poolManagerParams) + authorizedQuoteDenoms := k.GetAuthorizedQuoteDenoms(ctx) + authorizedQuoteDenoms = append(defaultParams.AuthorizedQuoteDenoms, coin1.Denom, coin0.Denom) + k.SetAuthorizedQuoteDenoms(ctx, authorizedQuoteDenoms) denomMetaData := banktypes.Metadata{ DenomUnits: []*banktypes.DenomUnit{{ From 573565ee507786fd5d5dc758df1914fc976033a2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 27 Aug 2023 12:14:29 -0500 Subject: [PATCH 70/83] update txfees & poolmanager READMEs with takerFee --- x/poolmanager/README.md | 10 ++++++++++ x/txfees/README.md | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/x/poolmanager/README.md b/x/poolmanager/README.md index f5bb0a82f26..656087e5a3c 100644 --- a/x/poolmanager/README.md +++ b/x/poolmanager/README.md @@ -269,6 +269,12 @@ user should be putting in is done through the following formula: `tokenBalanceIn * [{tokenBalanceOut / (tokenBalanceOut - tokenAmountOut)} ^ (tokenWeightOut / tokenWeightIn) -1] / tokenAmountIn` +With the introduction of a `takerFee`, the actual amount of `tokenIn` that is used to calculate the amount of `tokenOut` is reduced by the `takerFee` amount. If governance or a governance approved DAO adds a specified trading pair to the `takerFee` module store, the fee associated with that pair is used. Otherwise, the `defaultTakerFee` defined in the poolmanger's parameters is used. + +The poolmanager only concerns itself with proportionally distributing the takerFee to the respective staking rewards and community pool txfees module accounts. For swaps originating in OSMO, the poolmanger distributes these fees based on the `OsmoTakerFeeDistribution` parameter. For swaps originating in non-OSMO assets, the poolmanager distributes these fees based on the `NonOsmoTakerFeeDistribution` parameter. For taker fees generated in non whitelisted quote denoms assets, the amount that goes to the community pool (defined by the `NonOsmoTakerFeeDistribution` above) is swapped to the `community_pool_denom_to_swap_non_whitelisted_assets_to` parameter defined in poolmanager. For instance, if a taker fee is generated in BTC, the respective community pool percent is sent directly to the community pool since it is a whitelisted quote denom. If it is generated in FOO, which is not a whitelisted quote denom, the respective community pool percent is swapped to the `community_pool_denom_to_swap_non_whitelisted_assets_to` parameter defined in poolmanager and send to the community pool as that denom at epoch. + +For more information on how the final distribution of these fees and how they are swapped, see the txfees module README. + Existing Swap types: - SwapExactAmountIn - SwapExactAmountOut @@ -291,6 +297,10 @@ Existing Swap types: [MsgSplitRouteSwapExactAmountOut](https://github.com/osmosis-labs/osmosis/blob/46e6a0c2051a3a5ef8cdd4ecebfff7305b13ab98/proto/osmosis/poolmanager/v1beta1/tx.proto#L85) +## MsgSetDenomPairTakerFee + +[MsgSplitRouteSwapExactAmountOut](https://github.com/osmosis-labs/osmosis/blob/d129ea37f5490d8a212932a78cd35cb864c799c7/proto/osmosis/poolmanager/v1beta1/tx.proto#L121) + ## Multi-Hop All tokens are swapped using a multi-hop mechanism. That is, all swaps diff --git a/x/txfees/README.md b/x/txfees/README.md index 3ca2f947bf2..c9a352720d6 100644 --- a/x/txfees/README.md +++ b/x/txfees/README.md @@ -15,6 +15,22 @@ Currently the only supported metadata & spot price calculator is using a GAMM po of each epoch. * Adds a new SDK message for creating governance proposals for adding new TxFee denoms. +## Epoch Hooks + +The txfees module includes hooks that trigger actions at the end of each epoch. + +The `AfterEpochEnd` hook performs several actions: + +1. It swaps all non-OSMO denominated fees in the non-native fee collector for staking rewards module account into OSMO. This is done by checking the balance of the non-native fee collector for staking rewards module account, and swapping each non-OSMO denominated fee into OSMO. If a pool does not exist for a particular denomination pair, the swap is silently skipped. See the `swapNonNativeFeeToDenom` function description below for more details. + +2. After the swap, it transfers all OSMO from the non-native fee collector for staking rewards to the primary txfees fee collector module account. This indirectly distributes the fees to stakers. + +3. It also swaps non-whitelisted assets in the non-native community pool collector into the denomination specified in the pool manager parameters (currently USDC). + +4. Finally, it funds the community pool with the swapped denomination. + +The `swapNonNativeFeeToDenom` function is used to perform the swaps. It iterates over each coin in the balance of the specified fee collector account, and swaps it into the specified denomination. This function assumes that a pool route exists in the protorev route store for each denomination pair. If a pool route does not exist or is disabled, the swap is silently skipped. + ## Local Mempool Filters Added * If you specify a min-tx-fee in the $BASEDENOM then From 0ba3702b2bf97a56f5850a08248900b7689f7c86 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 27 Aug 2023 21:27:06 -0500 Subject: [PATCH 71/83] fix merge main --- app/upgrades/v18/upgrades.go | 4 ++-- app/upgrades/v19/upgrades.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/upgrades/v18/upgrades.go b/app/upgrades/v18/upgrades.go index 85dba9b7e31..f97c8321682 100644 --- a/app/upgrades/v18/upgrades.go +++ b/app/upgrades/v18/upgrades.go @@ -12,7 +12,7 @@ import ( ) // OSMO / DAI CL pool ID -const firstCLPoolId = 1066 +const FirstCLPoolId = 1066 func CreateUpgradeHandler( mm *module.Manager, @@ -28,7 +28,7 @@ func CreateUpgradeHandler( return nil, err } - for id := 1; id < firstCLPoolId; id++ { + for id := 1; id < FirstCLPoolId; id++ { resetSumtree(keepers, ctx, uint64(id)) } return migrations, nil diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 3fea9f73eec..158472dded7 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -9,8 +9,8 @@ import ( "github.com/osmosis-labs/osmosis/v19/app/keepers" "github.com/osmosis-labs/osmosis/v19/app/upgrades" - poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" v18 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v18" + poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) const lastPoolToCorrect = v18.FirstCLPoolId - 1 @@ -28,8 +28,8 @@ func CreateUpgradeHandler( if err != nil { return nil, err } - - for id := 1; id <= lastPoolToCorrect; id++ { + + for id := 1; id <= lastPoolToCorrect; id++ { resetSuperfluidSumtree(keepers, ctx, uint64(id)) } From 73830bcd7d6bae9e8dcbe4d41d03ee658b9bc55c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Sun, 27 Aug 2023 22:21:03 -0500 Subject: [PATCH 72/83] add comment to denom pair taker fee --- proto/osmosis/poolmanager/v1beta1/tx.proto | 2 ++ x/poolmanager/types/tx.pb.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/proto/osmosis/poolmanager/v1beta1/tx.proto b/proto/osmosis/poolmanager/v1beta1/tx.proto index 1798be6312d..361d650a193 100644 --- a/proto/osmosis/poolmanager/v1beta1/tx.proto +++ b/proto/osmosis/poolmanager/v1beta1/tx.proto @@ -131,6 +131,8 @@ message MsgSetDenomPairTakerFee { message MsgSetDenomPairTakerFeeResponse { bool success = 1; } message DenomPairTakerFee { + // denom0 and denom1 get automatically lexigographically sorted + // when being stored, so the order of input here does not matter. string denom0 = 1 [ (gogoproto.moretags) = "yaml:\"denom0\"" ]; string denom1 = 2 [ (gogoproto.moretags) = "yaml:\"denom1\"" ]; string taker_fee = 3 [ diff --git a/x/poolmanager/types/tx.pb.go b/x/poolmanager/types/tx.pb.go index dfc5a7fc6f3..1d9e03c3197 100644 --- a/x/poolmanager/types/tx.pb.go +++ b/x/poolmanager/types/tx.pb.go @@ -529,6 +529,8 @@ func (m *MsgSetDenomPairTakerFeeResponse) GetSuccess() bool { } type DenomPairTakerFee struct { + // denom0 and denom1 get automatically lexigographically sorted + // when being stored, so the order of input here does not matter. Denom0 string `protobuf:"bytes,1,opt,name=denom0,proto3" json:"denom0,omitempty" yaml:"denom0"` Denom1 string `protobuf:"bytes,2,opt,name=denom1,proto3" json:"denom1,omitempty" yaml:"denom1"` TakerFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"taker_fee" yaml:"taker_fee"` From 52e210c58ef25b79b1a6245018aafc19d64c6c7c Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Sun, 27 Aug 2023 23:06:29 -0500 Subject: [PATCH 73/83] de-dup taker fee param validation --- x/poolmanager/types/gov.go | 21 +-------------------- x/poolmanager/types/msgs.go | 20 +------------------- x/poolmanager/types/params.go | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/x/poolmanager/types/gov.go b/x/poolmanager/types/gov.go index 2a743611055..db161a3335c 100644 --- a/x/poolmanager/types/gov.go +++ b/x/poolmanager/types/gov.go @@ -4,7 +4,6 @@ import ( "fmt" "strings" - sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" ) @@ -50,25 +49,7 @@ func (p *DenomPairTakerFeeProposal) ValidateBasic() error { return err } - for _, record := range p.DenomPairTakerFee { - if record.Denom0 == record.Denom1 { - return fmt.Errorf("denom0 and denom1 must be different") - } - - if sdk.ValidateDenom(record.Denom0) != nil { - return fmt.Errorf("denom0 is invalid: %s", sdk.ValidateDenom(record.Denom0)) - } - - if sdk.ValidateDenom(record.Denom1) != nil { - return fmt.Errorf("denom1 is invalid: %s", sdk.ValidateDenom(record.Denom1)) - } - - takerFee := record.TakerFee - if takerFee.IsNegative() || takerFee.GTE(sdk.OneDec()) { - return fmt.Errorf("taker fee must be between 0 and 1: %s", takerFee.String()) - } - } - return nil + return validateDenomPairTakerFees(p.DenomPairTakerFee) } // String returns a string containing the denom pair taker fee proposal. diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index 6ad57273275..b4657f6da6b 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -183,25 +183,7 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty denom pair taker fee") } - for _, denomPair := range msg.DenomPairTakerFee { - if err := sdk.ValidateDenom(denomPair.Denom0); err != nil { - return err - } - if err := sdk.ValidateDenom(denomPair.Denom1); err != nil { - return err - } - if denomPair.Denom0 == denomPair.Denom1 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Denom pair cannot consist of the same denoms") - } - if denomPair.TakerFee.IsNegative() { - return nonPositiveAmountError{denomPair.TakerFee.String()} - } - if denomPair.TakerFee.GT(sdk.OneDec()) { - return errorsmod.Wrapf(sdkerrors.ErrInvalidRequest, "Taker fee %s is greater than 1", denomPair.TakerFee.String()) - } - } - - return nil + return validateDenomPairTakerFees(msg.DenomPairTakerFee) } func (msg MsgSetDenomPairTakerFee) GetSignBytes() []byte { diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 9bb22e61bb0..dcd5806ba48 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -215,3 +215,29 @@ func validateCommunityPoolDenomToSwapNonWhitelistedAssetsTo(i interface{}) error return nil } + +func validateDenomPairTakerFees(pairs []DenomPairTakerFee) error { + if len(pairs) == 0 { + return fmt.Errorf("Empty denom pair taker fee") + } + + for _, record := range pairs { + if record.Denom0 == record.Denom1 { + return fmt.Errorf("denom0 and denom1 must be different") + } + + if sdk.ValidateDenom(record.Denom0) != nil { + return fmt.Errorf("denom0 is invalid: %s", sdk.ValidateDenom(record.Denom0)) + } + + if sdk.ValidateDenom(record.Denom1) != nil { + return fmt.Errorf("denom1 is invalid: %s", sdk.ValidateDenom(record.Denom1)) + } + + takerFee := record.TakerFee + if takerFee.IsNegative() || takerFee.GTE(sdk.OneDec()) { + return fmt.Errorf("taker fee must be between 0 and 1: %s", takerFee.String()) + } + } + return nil +} From 303bfb9240dc6ad9a6efc0b253fa59ba3253d7af Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 28 Aug 2023 06:18:14 +0200 Subject: [PATCH 74/83] Update x/poolmanager/types/msgs.go --- x/poolmanager/types/msgs.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/poolmanager/types/msgs.go b/x/poolmanager/types/msgs.go index b4657f6da6b..ae1df8ed7b2 100644 --- a/x/poolmanager/types/msgs.go +++ b/x/poolmanager/types/msgs.go @@ -179,10 +179,6 @@ func (msg MsgSetDenomPairTakerFee) ValidateBasic() error { return InvalidSenderError{Sender: msg.Sender} } - if len(msg.DenomPairTakerFee) == 0 { - return errorsmod.Wrap(sdkerrors.ErrInvalidRequest, "Empty denom pair taker fee") - } - return validateDenomPairTakerFees(msg.DenomPairTakerFee) } From e7b7a20f40f65114fe1a9f92c73490a0de6f99a2 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 28 Aug 2023 07:32:02 +0200 Subject: [PATCH 75/83] Apply suggestions from code review --- x/poolmanager/taker_fee.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 522d0a16d49..8ecee0dcfeb 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -163,7 +163,8 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom return tokenInAfterTakerFee, nil } - +// Returns remaining amount in to swap, and takerFeeCoins. +// returns (1 - takerFee) * tokenIn, takerFee * tokenIn func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { amountInAfterSubTakerFee := tokenIn.Amount.ToDec().MulTruncate(sdk.OneDec().Sub(takerFee)) tokenInAfterSubTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterSubTakerFee.TruncateInt()) @@ -172,6 +173,8 @@ func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coi return tokenInAfterSubTakerFee, takerFeeCoin } +Returns takerFee adjusted required amountIn, and takerFeeCoins. +Computed as tokenIn / (1 - takerFee), tokenIn * (1 - / (1 - takerFee)) func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { amountInAfterAddTakerFee := tokenIn.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.RoundInt()) From d5e9123f0bd54565bb4d9b9150ad5ce1df3a1a86 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 28 Aug 2023 07:32:52 +0200 Subject: [PATCH 76/83] Update x/poolmanager/taker_fee.go --- x/poolmanager/taker_fee.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 8ecee0dcfeb..af30b86a604 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -173,8 +173,8 @@ func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coi return tokenInAfterSubTakerFee, takerFeeCoin } -Returns takerFee adjusted required amountIn, and takerFeeCoins. -Computed as tokenIn / (1 - takerFee), tokenIn * (1 - / (1 - takerFee)) +// Returns takerFee adjusted required amountIn, and takerFeeCoins. +// Computed as tokenIn / (1 - takerFee), tokenIn * (1 - / (1 - takerFee)) func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { amountInAfterAddTakerFee := tokenIn.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.RoundInt()) From 708442ed47c77ebc6bfdf6178172c48e6fda94e2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 10:01:18 -0500 Subject: [PATCH 77/83] remove unneeded setup test --- x/protorev/keeper/rebalance_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/protorev/keeper/rebalance_test.go b/x/protorev/keeper/rebalance_test.go index f2a2c48754e..1880fa19e1c 100644 --- a/x/protorev/keeper/rebalance_test.go +++ b/x/protorev/keeper/rebalance_test.go @@ -737,7 +737,6 @@ func (s *KeeperTestSuite) TestRemainingPoolPointsForTx() { } func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { - s.SetupTest() s.Run("Extended search on stable pools", func() { route := keeper.RouteMetaData{ Route: extendedRangeRoute, From 759c3106dc6841128f734630c7738c3348521d63 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 10:09:56 -0500 Subject: [PATCH 78/83] get pool creation free from previous --- app/upgrades/v19/upgrades.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 158472dded7..9d1d48e1832 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -39,7 +39,10 @@ func CreateUpgradeHandler( // so the right move in this case is to move this parameter upwards in order to prevent circular dependencies. // TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) + currentPoolManagerParams := keepers.PoolManagerKeeper.GetParams(ctx) + defaultPoolManagerParams := poolmanagertypes.DefaultParams() + defaultPoolManagerParams.PoolCreationFee = currentPoolManagerParams.PoolCreationFee defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) From ecaa3f3145dcddc5e7a98138737fa5696cfb43d2 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 10:15:35 -0500 Subject: [PATCH 79/83] take non native out of name --- app/modules.go | 50 ++++++++++++++-------------- x/poolmanager/taker_fee.go | 11 +++--- x/txfees/keeper/feedecorator.go | 8 ++--- x/txfees/keeper/feedecorator_test.go | 2 +- x/txfees/keeper/hooks.go | 6 ++-- x/txfees/keeper/hooks_test.go | 4 +-- x/txfees/types/keys.go | 8 ++--- 7 files changed, 45 insertions(+), 44 deletions(-) diff --git a/app/modules.go b/app/modules.go index 48c16f659b0..cfcbf7bca69 100644 --- a/app/modules.go +++ b/app/modules.go @@ -98,31 +98,31 @@ import ( // moduleAccountPermissions defines module account permissions // TODO: Having to input nil's here is unacceptable, we need a way to automatically derive this. var moduleAccountPermissions = map[string][]string{ - authtypes.FeeCollectorName: nil, - distrtypes.ModuleName: nil, - ibchookstypes.ModuleName: nil, - icatypes.ModuleName: nil, - icqtypes.ModuleName: nil, - minttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - minttypes.DeveloperVestingModuleAcctName: nil, - stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, - stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, - govtypes.ModuleName: {authtypes.Burner}, - ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - poolincentivestypes.ModuleName: nil, - superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - txfeestypes.ModuleName: nil, - txfeestypes.NonNativeFeeCollectorForStakingRewardsName: nil, - txfeestypes.NonNativeFeeCollectorForCommunityPoolName: nil, - wasm.ModuleName: {authtypes.Burner}, - tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, - valsetpreftypes.ModuleName: {authtypes.Staking}, - poolmanagertypes.ModuleName: nil, - cosmwasmpooltypes.ModuleName: nil, + authtypes.FeeCollectorName: nil, + distrtypes.ModuleName: nil, + ibchookstypes.ModuleName: nil, + icatypes.ModuleName: nil, + icqtypes.ModuleName: nil, + minttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + minttypes.DeveloperVestingModuleAcctName: nil, + stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking}, + stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, + govtypes.ModuleName: {authtypes.Burner}, + ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + gammtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + incentivestypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + protorevtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + lockuptypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + poolincentivestypes.ModuleName: nil, + superfluidtypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + txfeestypes.ModuleName: nil, + txfeestypes.FeeCollectorForStakingRewardsName: nil, + txfeestypes.FeeCollectorForCommunityPoolName: nil, + wasm.ModuleName: {authtypes.Burner}, + tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + valsetpreftypes.ModuleName: {authtypes.Staking}, + poolmanagertypes.ModuleName: nil, + cosmwasmpooltypes.ModuleName: nil, } // appModules return modules to initialize module manager. diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index af30b86a604..cfa9222e36d 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -77,8 +77,8 @@ func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) ( // chargeTakerFee extracts the taker fee from the given tokenIn and sends it to the appropriate // module account. It returns the tokenIn after the taker fee has been extracted. func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom string, sender sdk.AccAddress, exactIn bool) (sdk.Coin, error) { - nonNativeFeeCollectorForStakingRewardsName := txfeestypes.NonNativeFeeCollectorForStakingRewardsName - nonNativeFeeCollectorForCommunityPoolName := txfeestypes.NonNativeFeeCollectorForCommunityPoolName + feeCollectorForStakingRewardsName := txfeestypes.FeeCollectorForStakingRewardsName + feeCollectorForCommunityPoolName := txfeestypes.FeeCollectorForCommunityPoolName defaultTakerFeeDenom := appparams.BaseCoinUnit poolManagerParams := k.GetParams(ctx) @@ -118,7 +118,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // Osmo staking rewards funds are sent to the non native fee pool module account (even though its native, we want to distribute at the same time as the non native fee tokens) // We could stream these rewards via the fee collector account, but this is decision to be made by governance. osmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, osmoTakerFeeToStakingRewardsCoins) if err != nil { return sdk.Coin{}, err } @@ -143,7 +143,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // At epoch, this account swaps the non native, non whitelisted assets for XXX and sends to the community pool. nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { return sdk.Coin{}, err } @@ -154,7 +154,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { // Non Osmo staking rewards are sent to the non native fee pool module account nonOsmoTakerFeeToStakingRewardsCoins := sdk.NewCoins(sdk.NewCoin(takerFeeCoin.Denom, takerFeeAmtRemaining)) - err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, nonNativeFeeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) + err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) if err != nil { return sdk.Coin{}, err } @@ -163,6 +163,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom return tokenInAfterTakerFee, nil } + // Returns remaining amount in to swap, and takerFeeCoins. // returns (1 - takerFee) * tokenIn, takerFee * tokenIn func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index ce66f2b8f3d..7ac13d7ef69 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -180,8 +180,8 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo } // checks to make sure a separate module account has been set to collect fees not in base token - if addrNonNativeFee := dfd.ak.GetModuleAddress(types.NonNativeFeeCollectorForStakingRewardsName); addrNonNativeFee == nil { - return ctx, fmt.Errorf("non native fee collector module account (%s) has not been set", types.NonNativeFeeCollectorForStakingRewardsName) + if addrNonNativeFee := dfd.ak.GetModuleAddress(types.FeeCollectorForStakingRewardsName); addrNonNativeFee == nil { + return ctx, fmt.Errorf("non native fee collector module account (%s) has not been set", types.FeeCollectorForStakingRewardsName) } // fee can be in any denom (checked for validity later) @@ -248,8 +248,8 @@ func DeductFees(txFeesKeeper types.TxFeesKeeper, bankKeeper types.BankKeeper, ct return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } } else { - // sends to NonNativeFeeCollectorForStakingRewardsName module account - err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.NonNativeFeeCollectorForStakingRewardsName, fees) + // sends to FeeCollectorForStakingRewardsName module account + err := bankKeeper.SendCoinsFromAccountToModule(ctx, acc.GetAddress(), types.FeeCollectorForStakingRewardsName, fees) if err != nil { return errorsmod.Wrapf(sdkerrors.ErrInsufficientFunds, err.Error()) } diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index 7cb93ca5e3b..489cf6f67b0 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -208,7 +208,7 @@ func (s *KeeperTestSuite) TestFeeDecorator() { if !tc.txFee.IsZero() { moduleName := types.FeeCollectorName if tc.txFee[0].Denom != baseDenom { - moduleName = types.NonNativeFeeCollectorForStakingRewardsName + moduleName = types.FeeCollectorForStakingRewardsName } moduleAddr := s.App.AccountKeeper.GetModuleAddress(moduleName) s.Require().Equal(tc.txFee[0], s.App.BankKeeper.GetBalance(s.Ctx, moduleAddr, tc.txFee[0].Denom), tc.name) diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 9ece448b99c..e6ed1204435 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -16,7 +16,7 @@ func (k Keeper) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochN func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { defaultFeesDenom, _ := k.GetBaseDenom(ctx) - nonNativeStakingCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForStakingRewardsName) + nonNativeStakingCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.FeeCollectorForStakingRewardsName) // Non-native fee collector for staking rewards get swapped entirely into base denom. k.swapNonNativeFeeToDenom(ctx, defaultFeesDenom, nonNativeStakingCollectorAddress) @@ -24,7 +24,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb // Now that the rewards have been swapped, transfer any base denom existing in the non-native fee collector to the fee collector (indirectly distributing to stakers) baseDenomCoins := sdk.NewCoins(k.bankKeeper.GetBalance(ctx, nonNativeStakingCollectorAddress, defaultFeesDenom)) _ = osmoutils.ApplyFuncIfNoError(ctx, func(cacheCtx sdk.Context) error { - err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.NonNativeFeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) + err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, txfeestypes.FeeCollectorForStakingRewardsName, txfeestypes.FeeCollectorName, baseDenomCoins) return err }) @@ -33,7 +33,7 @@ func (k Keeper) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumb denomToSwapTo := poolManagerParams.TakerFeeParams.CommunityPoolDenomToSwapNonWhitelistedAssetsTo // Only non-whitelisted assets should exist here since we do direct community pool funds when calculating the taker fee if // the input is a whitelisted asset. - nonNativeCommunityPoolCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.NonNativeFeeCollectorForCommunityPoolName) + nonNativeCommunityPoolCollectorAddress := k.accountKeeper.GetModuleAddress(txfeestypes.FeeCollectorForCommunityPoolName) k.swapNonNativeFeeToDenom(ctx, denomToSwapTo, nonNativeCommunityPoolCollectorAddress) // Now that the non whitelisted assets have been swapped, fund the community pool with the denom we swapped to. diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index 898a01d90ba..5028921b218 100644 --- a/x/txfees/keeper/hooks_test.go +++ b/x/txfees/keeper/hooks_test.go @@ -92,12 +92,12 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { _, _, addr0 := testdata.KeyTestPubAddr() err = simapp.FundAccount(s.App.BankKeeper, s.Ctx, addr0, sdk.Coins{coin}) s.NoError(err) - err = s.App.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, addr0, types.NonNativeFeeCollectorForStakingRewardsName, sdk.Coins{coin}) + err = s.App.BankKeeper.SendCoinsFromAccountToModule(s.Ctx, addr0, types.FeeCollectorForStakingRewardsName, sdk.Coins{coin}) s.NoError(err) } // checks the balance of the non-native denom in module account - moduleAddrNonNativeFee := s.App.AccountKeeper.GetModuleAddress(types.NonNativeFeeCollectorForStakingRewardsName) + moduleAddrNonNativeFee := s.App.AccountKeeper.GetModuleAddress(types.FeeCollectorForStakingRewardsName) s.Equal(s.App.BankKeeper.GetAllBalances(s.Ctx, moduleAddrNonNativeFee), tc.coins) // End of epoch, so all the non-osmo fee amount should be swapped to osmo and transfer to fee module account diff --git a/x/txfees/types/keys.go b/x/txfees/types/keys.go index 2ab6ff1e76f..13a39b957bc 100644 --- a/x/txfees/types/keys.go +++ b/x/txfees/types/keys.go @@ -13,13 +13,13 @@ const ( // FeeCollectorName the module account name for the fee collector account address. FeeCollectorName = "fee_collector" - // NonNativeFeeCollectorForStakingRewardsName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). + // FeeCollectorForStakingRewardsName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). // These fees go to the staking rewards pool. - NonNativeFeeCollectorForStakingRewardsName = "non_native_fee_collector" + FeeCollectorForStakingRewardsName = "non_native_fee_collector" - // NonNativeFeeCollectorForCommunityPoolName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). + // FeeCollectorForCommunityPoolName the module account name for the alt fee collector account address (used for auto-swapping non-OSMO tx fees). // These fees go to the community pool. - NonNativeFeeCollectorForCommunityPoolName = "non_native_fee_collector_community_pool" + FeeCollectorForCommunityPoolName = "non_native_fee_collector_community_pool" // QuerierRoute defines the module's query routing key QuerierRoute = ModuleName From 87e431028849125e8d9950adf5e221c3bfec3a5a Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 11:12:36 -0500 Subject: [PATCH 80/83] undo param pull instead of default --- app/upgrades/v19/upgrades.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 9d1d48e1832..b62d16c8f1b 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -39,10 +39,8 @@ func CreateUpgradeHandler( // so the right move in this case is to move this parameter upwards in order to prevent circular dependencies. // TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) - currentPoolManagerParams := keepers.PoolManagerKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() - defaultPoolManagerParams.PoolCreationFee = currentPoolManagerParams.PoolCreationFee defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) From 84c8873161e95523723427c8b6f95d8dce126e56 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 11:16:14 -0500 Subject: [PATCH 81/83] use current pool creation fee --- app/upgrades/v19/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index b62d16c8f1b..6c82c69612a 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -39,8 +39,8 @@ func CreateUpgradeHandler( // so the right move in this case is to move this parameter upwards in order to prevent circular dependencies. // TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) - defaultPoolManagerParams := poolmanagertypes.DefaultParams() + defaultPoolManagerParams.PoolCreationFee = keepers.PoolManagerKeeper.GetParams(ctx).PoolCreationFee defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) From 726532ec33257e378d6400a80d7758aaf5361d1b Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 11:33:59 -0500 Subject: [PATCH 82/83] use default --- app/upgrades/v19/upgrades.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 6c82c69612a..33dfab20993 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -40,7 +40,7 @@ func CreateUpgradeHandler( // TODO: In v20 upgrade handler, delete this param from the concentrated liquidity params. currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() - defaultPoolManagerParams.PoolCreationFee = keepers.PoolManagerKeeper.GetParams(ctx).PoolCreationFee + defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) From e48e6140a4e29eb4a7e342ba0112cfb54eb6d7c9 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Mon, 28 Aug 2023 11:45:50 -0500 Subject: [PATCH 83/83] e2e --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 77e1ac8fd35..3b823c4db0d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -100,8 +100,8 @@ jobs: e2e: needs: get_diff if: needs.get_diff.outputs.git_diff - runs-on: self-hosted - timeout-minutes: 25 + runs-on: ubuntu-latest + timeout-minutes: 15 steps: - name: Clean up Pre-Existing E2E Docker containers run: |