From 972f272d8b7efccbe962666de8e9ca740157f2b3 Mon Sep 17 00:00:00 2001 From: roman Date: Mon, 18 Sep 2023 21:35:52 -0400 Subject: [PATCH 1/2] squash --- CHANGELOG.md | 18 +- CONTRIBUTING.md | 12 +- app/apptesting/concentrated_liquidity.go | 25 +- app/apptesting/gamm.go | 90 +- app/apptesting/pool_manager.go | 11 +- app/apptesting/test_suite.go | 31 +- app/params/config.go | 6 +- app/upgrades/v15/upgrade_test.go | 27 +- app/upgrades/v16/upgrades.go | 9 +- app/upgrades/v16/upgrades_test.go | 26 +- app/upgrades/v17/constants.go | 65 +- app/upgrades/v17/upgrades.go | 5 +- app/upgrades/v17/upgrades_test.go | 90 +- app/upgrades/v18/upgrades_test.go | 23 +- app/upgrades/v19/upgrades.go | 3 +- app/upgrades/v19/upgrades_test.go | 9 +- app/upgrades/v3/forks.go | 3 +- app/upgrades/v4/upgrade_test.go | 2 +- app/upgrades/v8/incentive_props.go | 37 +- app/upgrades/v9/prop214.go | 3 +- app/upgrades/v9/prop214_test.go | 2 +- cmd/osmosisd/cmd/airdrop.go.history | 54 +- .../cmd/balances_from_state_export.go | 13 +- cmd/osmosisd/cmd/genaccounts.go | 16 +- cmd/osmosisd/cmd/genesis.go | 131 +-- cmd/osmosisd/cmd/root.go | 5 +- cmd/osmosisd/cmd/stargate-query.go | 5 +- cmd/osmosisd/cmd/testnet.go | 12 +- go.mod | 9 +- go.sum | 15 +- osmomath/binary_search.go | 38 +- osmomath/binary_search_test.go | 83 +- osmomath/decimal.go | 176 +-- osmomath/decimal_test.go | 611 +++++----- osmomath/exp2.go | 38 +- osmomath/exp2_test.go | 123 +- osmomath/export_test.go | 3 +- osmomath/go.mod | 8 +- osmomath/go.sum | 17 +- osmomath/int.go | 48 +- osmomath/int_test.go | 118 +- osmomath/log2_bench_test.go | 14 +- osmomath/math.go | 32 +- osmomath/math_test.go | 132 ++- osmomath/pow_bench_test.go | 56 +- osmomath/rounding_direction.go | 4 +- osmomath/rounding_direction_test.go | 33 +- osmomath/sdk_math_alias.go | 55 + osmomath/sigfig_round.go | 10 +- osmomath/sigfig_round_test.go | 44 +- osmomath/sqrt.go | 13 +- osmomath/sqrt_big_test.go | 33 +- osmomath/sqrt_test.go | 51 +- osmoutils/accum/accum.go | 31 +- osmoutils/accum/accum.pb.go | 60 +- osmoutils/accum/accum_helpers.go | 3 +- osmoutils/accum/accum_test.go | 235 ++-- osmoutils/accum/export_test.go | 7 +- osmoutils/accum/options.go | 6 +- osmoutils/cli_helpers.go | 16 +- osmoutils/coin_helper_test.go | 27 +- osmoutils/errors.go | 2 +- osmoutils/go.mod | 18 +- osmoutils/go.sum | 42 +- osmoutils/osmoassert/assertions.go | 5 +- osmoutils/osmocli/dynamic_test.go | 6 +- osmoutils/osmocli/parsers.go | 17 +- osmoutils/osmocli/parsers_test.go | 35 +- osmoutils/store_helper.go | 12 +- osmoutils/store_helper_test.go | 128 +- osmoutils/sumtree/legacy/v101/tree.go | 5 +- osmoutils/sumtree/legacy/v101/tree_test.go | 3 +- osmoutils/sumtree/node.go | 10 +- osmoutils/sumtree/tree.go | 33 +- osmoutils/sumtree/tree.pb.go | 46 +- osmoutils/sumtree/tree_test.go | 6 +- proto/osmosis/accum/v1beta1/accum.proto | 4 +- .../osmosis/concentrated-liquidity/gov.proto | 2 +- .../incentive_record.proto | 2 +- .../concentrated-liquidity/params.proto | 4 +- .../pool-model/concentrated/tx.proto | 2 +- .../osmosis/concentrated-liquidity/pool.proto | 4 +- .../concentrated-liquidity/position.proto | 2 +- .../concentrated-liquidity/query.proto | 6 +- .../concentrated-liquidity/tickInfo.proto | 4 +- proto/osmosis/concentrated-liquidity/tx.proto | 28 +- .../v1beta1/model/module_query_msg.proto | 4 +- .../v1beta1/model/module_sudo_msg.proto | 12 +- .../v1beta1/model/pool_query_msg.proto | 2 +- .../pool-models/balancer/balancerPool.proto | 8 +- .../stableswap/stableswap_pool.proto | 4 +- proto/osmosis/gamm/v1beta1/gov.proto | 4 +- proto/osmosis/gamm/v1beta1/query.proto | 10 +- proto/osmosis/gamm/v1beta1/tx.proto | 34 +- proto/osmosis/lockup/query.proto | 2 +- proto/osmosis/mint/v1beta1/mint.proto | 16 +- proto/osmosis/mint/v1beta1/query.proto | 2 +- .../pool-incentives/v1beta1/incentives.proto | 4 +- .../osmosis/poolmanager/v1beta1/genesis.proto | 6 +- proto/osmosis/poolmanager/v1beta1/query.proto | 4 +- .../poolmanager/v1beta1/swap_route.proto | 4 +- proto/osmosis/poolmanager/v1beta1/tx.proto | 18 +- proto/osmosis/protorev/v1beta1/protorev.proto | 6 +- proto/osmosis/protorev/v1beta1/query.proto | 2 +- proto/osmosis/sumtree/v1beta1/tree.proto | 2 +- proto/osmosis/superfluid/params.proto | 2 +- proto/osmosis/superfluid/query.proto | 6 +- proto/osmosis/superfluid/superfluid.proto | 2 +- proto/osmosis/superfluid/tx.proto | 16 +- proto/osmosis/twap/v1beta1/query.proto | 8 +- proto/osmosis/twap/v1beta1/twap_record.proto | 10 +- proto/osmosis/txfees/v1beta1/query.proto | 2 +- proto/osmosis/valset-pref/v1beta1/state.proto | 2 +- simulation/simtypes/random/sdkrand.go | 22 +- simulation/simtypes/randutil.go | 9 +- tests/cl-genesis-positions/convert.go | 24 +- tests/cl-genesis-positions/go.mod | 39 +- tests/cl-genesis-positions/go.sum | 55 +- tests/cl-go-client/go.mod | 28 +- tests/cl-go-client/go.sum | 58 +- tests/cl-go-client/main.go | 37 +- tests/e2e/configurer/chain/chain.go | 3 +- tests/e2e/configurer/chain/commands.go | 23 +- tests/e2e/configurer/chain/queries.go | 41 +- tests/e2e/configurer/upgrade.go | 7 +- tests/e2e/containers/containers.go | 5 +- tests/e2e/e2e_test.go | 146 +-- tests/e2e/helpers_e2e_test.go | 9 +- tests/e2e/initialization/config.go | 27 +- tests/e2e/initialization/node.go | 9 +- tests/ibc-hooks/async_acks_test.go | 5 +- tests/ibc-hooks/ibc_middleware_test.go | 137 +-- tests/ibc-hooks/path_validation_test.go | 7 +- tests/ibc-hooks/xcs_cw20_test.go | 12 +- tests/simulator/sim_test.go | 6 +- tests/simulator/state.go | 3 +- wasmbinding/bindings/msg.go | 12 +- wasmbinding/query_plugin_test.go | 17 +- wasmbinding/test/custom_msg_test.go | 5 +- wasmbinding/test/helpers_test.go | 3 +- wasmbinding/test/messages_test.go | 9 +- x/concentrated-liquidity/README.md | 30 +- x/concentrated-liquidity/bench_test.go | 41 +- x/concentrated-liquidity/client/cli/tx.go | 3 +- .../client/query_proto_wrap.go | 9 +- .../client/queryproto/query.pb.go | 295 +++-- x/concentrated-liquidity/event.go | 7 +- x/concentrated-liquidity/export_test.go | 64 +- x/concentrated-liquidity/fuzz_test.go | 40 +- x/concentrated-liquidity/genesis.go | 3 +- x/concentrated-liquidity/genesis_test.go | 191 +-- x/concentrated-liquidity/incentives.go | 22 +- x/concentrated-liquidity/incentives_test.go | 286 +++-- x/concentrated-liquidity/invariant_test.go | 8 +- x/concentrated-liquidity/keeper_test.go | 70 +- x/concentrated-liquidity/lp.go | 84 +- x/concentrated-liquidity/lp_test.go | 336 +++--- x/concentrated-liquidity/math/math.go | 22 +- x/concentrated-liquidity/math/math_test.go | 255 ++-- x/concentrated-liquidity/math/precompute.go | 31 +- x/concentrated-liquidity/math/tick.go | 22 +- x/concentrated-liquidity/math/tick_test.go | 283 +++-- x/concentrated-liquidity/model/msgs.go | 3 +- x/concentrated-liquidity/model/msgs_test.go | 5 +- x/concentrated-liquidity/model/pool.go | 49 +- x/concentrated-liquidity/model/pool.pb.go | 88 +- x/concentrated-liquidity/model/pool_test.go | 94 +- x/concentrated-liquidity/model/position.pb.go | 107 +- x/concentrated-liquidity/model/tickInfo.pb.go | 73 +- x/concentrated-liquidity/model/tx.pb.go | 72 +- x/concentrated-liquidity/msg_server.go | 5 +- x/concentrated-liquidity/msg_server_test.go | 15 +- x/concentrated-liquidity/pool.go | 16 +- x/concentrated-liquidity/pool_test.go | 44 +- x/concentrated-liquidity/position.go | 31 +- x/concentrated-liquidity/position_test.go | 108 +- x/concentrated-liquidity/query.go | 18 +- x/concentrated-liquidity/query_test.go | 392 ++++--- x/concentrated-liquidity/range_test.go | 68 +- .../simulation/sim_msgs.go | 19 +- x/concentrated-liquidity/spread_rewards.go | 3 +- .../spread_rewards_test.go | 318 ++--- x/concentrated-liquidity/swaps.go | 100 +- x/concentrated-liquidity/swaps_test.go | 1028 ++++++++--------- .../swaps_tick_cross_test.go | 122 +- .../swapstrategy/export_test.go | 6 +- .../swapstrategy/one_for_zero.go | 26 +- .../swapstrategy/one_for_zero_test.go | 278 +++-- .../swapstrategy/spread_rewards.go | 10 +- .../swapstrategy/spread_rewards_test.go | 42 +- .../swapstrategy/swap_strategy.go | 20 +- .../swapstrategy/swap_strategy_test.go | 154 +-- .../swapstrategy/zero_for_one.go | 28 +- .../swapstrategy/zero_for_one_test.go | 186 ++- x/concentrated-liquidity/tick.go | 8 +- x/concentrated-liquidity/tick_test.go | 59 +- x/concentrated-liquidity/total_liquidity.go | 11 +- x/concentrated-liquidity/types/cl.go | 12 +- .../types/cl_pool_extensionI.go | 10 +- x/concentrated-liquidity/types/constants.go | 34 +- x/concentrated-liquidity/types/errors.go | 70 +- .../types/expected_keepers.go | 5 +- x/concentrated-liquidity/types/gov.go | 4 +- x/concentrated-liquidity/types/gov.pb.go | 81 +- x/concentrated-liquidity/types/gov_test.go | 12 +- .../types/incentive_record.pb.go | 77 +- x/concentrated-liquidity/types/msgs.go | 4 +- x/concentrated-liquidity/types/msgs_test.go | 95 +- x/concentrated-liquidity/types/params.go | 18 +- x/concentrated-liquidity/types/params.pb.go | 82 +- x/concentrated-liquidity/types/params_test.go | 12 +- x/concentrated-liquidity/types/tx.pb.go | 186 +-- .../cosmwasm/msg/module_query_msg.go | 10 +- .../cosmwasm/msg/module_query_msg.pb.go | 67 +- .../cosmwasm/msg/module_sudo_msg.go | 6 +- .../cosmwasm/msg/module_sudo_msg.pb.go | 87 +- .../cosmwasm/msg/pool_query_msg.pb.go | 72 +- .../msg/transmuter/transmuter_test.go | 5 +- x/cosmwasmpool/model/pool.go | 9 +- x/cosmwasmpool/model/pool_test.go | 6 +- x/cosmwasmpool/model/store_model.go | 7 +- x/cosmwasmpool/pool_module.go | 41 +- x/cosmwasmpool/pool_module_test.go | 57 +- x/cosmwasmpool/types/errors.go | 8 +- x/epochs/go.mod | 15 +- x/epochs/go.sum | 42 +- x/gamm/README.md | 4 +- x/gamm/client/cli/cli_test.go | 21 +- x/gamm/client/cli/flags.go | 4 +- x/gamm/client/cli/query_test.go | 11 +- x/gamm/client/cli/tx.go | 15 +- x/gamm/client/cli/tx_test.go | 11 +- x/gamm/keeper/export_test.go | 3 +- x/gamm/keeper/gas_test.go | 35 +- x/gamm/keeper/genesis_test.go | 41 +- x/gamm/keeper/grpc_query.go | 3 +- x/gamm/keeper/grpc_query_test.go | 167 +-- x/gamm/keeper/keeper_test.go | 5 +- x/gamm/keeper/migrate.go | 5 +- x/gamm/keeper/migrate_test.go | 94 +- x/gamm/keeper/msg_server_test.go | 71 +- x/gamm/keeper/pool.go | 9 +- x/gamm/keeper/pool_service.go | 110 +- x/gamm/keeper/pool_service_test.go | 221 ++-- x/gamm/keeper/pool_test.go | 127 +- x/gamm/keeper/share.go | 9 +- x/gamm/keeper/swap.go | 53 +- x/gamm/keeper/swap_test.go | 125 +- x/gamm/keeper/total_liquidity.go | 11 +- x/gamm/pool-models/balancer/amm.go | 50 +- x/gamm/pool-models/balancer/amm_test.go | 23 +- .../pool-models/balancer/balancerPool.pb.go | 124 +- x/gamm/pool-models/balancer/constants.go | 4 +- x/gamm/pool-models/balancer/export_test.go | 10 +- x/gamm/pool-models/balancer/marshal.go | 6 +- x/gamm/pool-models/balancer/marshal_test.go | 21 +- x/gamm/pool-models/balancer/msgs_test.go | 45 +- x/gamm/pool-models/balancer/pool.go | 199 ++-- x/gamm/pool-models/balancer/pool_asset.go | 9 +- x/gamm/pool-models/balancer/pool_params.go | 13 +- .../pool-models/balancer/pool_suite_test.go | 271 ++--- x/gamm/pool-models/balancer/pool_test.go | 366 +++--- x/gamm/pool-models/balancer/util_test.go | 6 +- x/gamm/pool-models/internal/cfmm_common/lp.go | 48 +- .../internal/cfmm_common/lp_test.go | 47 +- .../internal/test_helpers/test_helpers.go | 20 +- x/gamm/pool-models/stableswap/README.md | 12 +- x/gamm/pool-models/stableswap/amm.go | 70 +- x/gamm/pool-models/stableswap/amm_test.go | 200 ++-- x/gamm/pool-models/stableswap/msgs_test.go | 75 +- x/gamm/pool-models/stableswap/pool.go | 48 +- x/gamm/pool-models/stableswap/pool_params.go | 7 +- x/gamm/pool-models/stableswap/pool_test.go | 238 ++-- .../stableswap/stableswap_pool.pb.go | 93 +- x/gamm/pool-models/stableswap/util_test.go | 3 +- x/gamm/simulation/sim_msgs.go | 41 +- x/gamm/types/constants.go | 16 +- x/gamm/types/expected_keepers.go | 13 +- x/gamm/types/gov.go | 3 +- x/gamm/types/gov.pb.go | 115 +- x/gamm/types/hooks.go | 14 +- x/gamm/types/msgs_test.go | 111 +- x/gamm/types/pool.go | 43 +- x/gamm/types/query.pb.go | 273 ++--- x/gamm/types/tx.pb.go | 240 ++-- x/ibc-hooks/go.mod | 11 +- x/ibc-hooks/go.sum | 37 +- x/ibc-hooks/wasm_hook.go | 4 +- x/ibc-rate-limit/ibc_middleware_test.go | 31 +- x/incentives/client/cli/query_test.go | 3 +- x/incentives/keeper/distribute.go | 9 +- x/incentives/keeper/distribute_test.go | 56 +- x/incentives/keeper/export_test.go | 3 +- x/incentives/keeper/gauge.go | 3 +- x/incentives/keeper/gauge_test.go | 67 +- x/incentives/keeper/grpc_query_test.go | 5 +- x/incentives/keeper/keeper_test.go | 3 +- x/incentives/keeper/msg_server_test.go | 43 +- x/incentives/simulation/operations.go | 5 +- x/incentives/types/expected_keepers.go | 5 +- x/incentives/types/gauge.go | 5 +- x/incentives/types/msgs_test.go | 3 +- x/lockup/client/cli/query.go | 5 +- x/lockup/keeper/bench_test.go | 3 +- x/lockup/keeper/genesis_test.go | 3 +- x/lockup/keeper/grpc_query_test.go | 3 +- x/lockup/keeper/invariants.go | 5 +- x/lockup/keeper/lock.go | 25 +- x/lockup/keeper/lock_test.go | 63 +- x/lockup/keeper/msg_server_test.go | 11 +- x/lockup/keeper/store.go | 3 +- x/lockup/types/lock.go | 6 +- x/lockup/types/msgs_test.go | 23 +- x/lockup/types/query.pb.go | 216 ++-- x/mint/README.md | 2 +- x/mint/keeper/export_test.go | 5 +- x/mint/keeper/genesis.go | 5 +- x/mint/keeper/genesis_test.go | 53 +- x/mint/keeper/hooks_test.go | 145 +-- x/mint/keeper/keeper.go | 43 +- x/mint/keeper/keeper_test.go | 201 ++-- x/mint/simulation/decoder_test.go | 4 +- x/mint/simulation/genesis.go | 51 +- x/mint/simulation/genesis_test.go | 5 +- x/mint/types/expected_keepers.go | 3 +- x/mint/types/mint.pb.go | 119 +- x/mint/types/minter.go | 8 +- x/mint/types/minter_test.go | 15 +- x/mint/types/params.go | 45 +- x/mint/types/params_test.go | 8 +- x/mint/types/query.pb.go | 56 +- x/pool-incentives/keeper/distr.go | 13 +- x/pool-incentives/keeper/distr_test.go | 85 +- x/pool-incentives/keeper/genesis.go | 3 +- x/pool-incentives/keeper/genesis_test.go | 6 +- x/pool-incentives/keeper/grpc_query.go | 11 +- x/pool-incentives/keeper/grpc_query_test.go | 65 +- x/pool-incentives/keeper/hooks.go | 5 +- x/pool-incentives/keeper/keeper_test.go | 6 +- x/pool-incentives/types/genesis.go | 7 +- x/pool-incentives/types/genesis_test.go | 14 +- x/pool-incentives/types/gov_test.go | 12 +- x/pool-incentives/types/incentives.pb.go | 84 +- x/pool-incentives/types/incentives_test.go | 18 +- x/pool-incentives/types/record_test.go | 9 +- x/poolmanager/README.md | 8 +- x/poolmanager/client/cli/cli_test.go | 5 +- x/poolmanager/client/cli/tx.go | 17 +- x/poolmanager/client/cli/tx_test.go | 62 +- x/poolmanager/client/queryproto/query.pb.go | 205 ++-- x/poolmanager/client/testutil/test_helpers.go | 3 +- x/poolmanager/create_pool_test.go | 41 +- x/poolmanager/events/emit_test.go | 17 +- x/poolmanager/export_test.go | 13 +- x/poolmanager/keeper_test.go | 19 +- x/poolmanager/msg_server_test.go | 19 +- x/poolmanager/router.go | 179 +-- x/poolmanager/router_test.go | 530 ++++----- x/poolmanager/taker_fee.go | 31 +- x/poolmanager/types/errors.go | 12 +- x/poolmanager/types/expected_keepers.go | 20 +- x/poolmanager/types/genesis.pb.go | 112 +- x/poolmanager/types/gov_test.go | 12 +- x/poolmanager/types/msgs_test.go | 51 +- x/poolmanager/types/params.go | 27 +- x/poolmanager/types/pool.go | 5 +- x/poolmanager/types/routes_test.go | 21 +- x/poolmanager/types/swap_route.pb.go | 68 +- x/poolmanager/types/tx.pb.go | 174 +-- x/protorev/client/cli/utils.go | 5 +- x/protorev/keeper/developer_fees.go | 7 +- x/protorev/keeper/developer_fees_test.go | 17 +- x/protorev/keeper/emit.go | 3 +- x/protorev/keeper/emit_test.go | 11 +- x/protorev/keeper/epoch_hook.go | 3 +- x/protorev/keeper/epoch_hook_test.go | 7 +- x/protorev/keeper/grpc_query_test.go | 91 +- x/protorev/keeper/hooks.go | 11 +- x/protorev/keeper/hooks_test.go | 107 +- x/protorev/keeper/keeper_test.go | 611 +++++----- x/protorev/keeper/msg_server_test.go | 15 +- x/protorev/keeper/posthandler.go | 4 +- x/protorev/keeper/posthandler_test.go | 83 +- x/protorev/keeper/protorev_test.go | 94 +- x/protorev/keeper/rebalance.go | 71 +- x/protorev/keeper/rebalance_test.go | 214 ++-- x/protorev/keeper/routes.go | 3 +- x/protorev/keeper/routes_test.go | 11 +- x/protorev/keeper/statistics.go | 35 +- x/protorev/keeper/statistics_test.go | 55 +- x/protorev/protorev.md | 2 +- x/protorev/types/constants.go | 8 +- x/protorev/types/expected_keepers.go | 7 +- x/protorev/types/genesis.go | 4 +- x/protorev/types/msg_test.go | 25 +- x/protorev/types/protorev.pb.go | 128 +- x/protorev/types/query.pb.go | 198 ++-- x/protorev/types/token_pair_arb_routes.go | 4 +- x/protorev/types/validate.go | 4 +- x/superfluid/README.md | 8 +- x/superfluid/client/cli/query_test.go | 5 +- x/superfluid/client/cli/tx.go | 9 +- x/superfluid/keeper/concentrated_liquidity.go | 3 +- .../keeper/concentrated_liquidity_test.go | 60 +- x/superfluid/keeper/edge_case_test.go | 16 +- x/superfluid/keeper/epoch.go | 2 +- x/superfluid/keeper/epoch_test.go | 25 +- x/superfluid/keeper/export_test.go | 15 +- x/superfluid/keeper/genesis_test.go | 7 +- x/superfluid/keeper/gov/gov_test.go | 9 +- x/superfluid/keeper/grpc_query.go | 7 +- x/superfluid/keeper/grpc_query_test.go | 37 +- x/superfluid/keeper/hooks.go | 5 +- x/superfluid/keeper/hooks_test.go | 23 +- .../keeper/intermediary_account_test.go | 3 +- .../keeper/internal/events/emit_test.go | 5 +- x/superfluid/keeper/invariants.go | 5 +- x/superfluid/keeper/keeper_test.go | 31 +- x/superfluid/keeper/migrate_test.go | 236 ++-- x/superfluid/keeper/msg_server_test.go | 19 +- x/superfluid/keeper/slash.go | 9 +- x/superfluid/keeper/slash_test.go | 26 +- x/superfluid/keeper/stake.go | 69 +- x/superfluid/keeper/stake_test.go | 173 +-- x/superfluid/keeper/superfluid_asset.go | 11 +- x/superfluid/keeper/superfluid_asset_test.go | 7 +- x/superfluid/keeper/twap_price.go | 19 +- x/superfluid/keeper/twap_price_test.go | 27 +- x/superfluid/keeper/unpool_test.go | 39 +- x/superfluid/simulation/genesis.go | 4 +- x/superfluid/types/errors.go | 7 +- x/superfluid/types/expected_keepers.go | 27 +- x/superfluid/types/msg_test.go | 13 +- x/superfluid/types/msgs.go | 4 +- x/superfluid/types/params.go | 11 +- x/superfluid/types/params.pb.go | 30 +- x/superfluid/types/query.pb.go | 267 ++--- x/superfluid/types/superfluid.pb.go | 112 +- x/superfluid/types/tx.pb.go | 213 ++-- x/tokenfactory/keeper/createdenom_test.go | 9 +- x/tokenfactory/module.go | 3 +- x/tokenfactory/simulation/sim_msgs.go | 3 +- x/tokenfactory/types/msgs.go | 6 +- x/tokenfactory/types/msgs_test.go | 15 +- x/twap/README.md | 2 +- x/twap/api.go | 27 +- x/twap/api_test.go | 184 +-- x/twap/client/query_proto_wrap_test.go | 16 +- x/twap/client/queryproto/query.pb.go | 113 +- x/twap/export_test.go | 18 +- x/twap/keeper_test.go | 173 +-- x/twap/listeners.go | 5 +- x/twap/listeners_test.go | 5 +- x/twap/logic.go | 22 +- x/twap/logic_test.go | 312 ++--- x/twap/migrate_test.go | 29 - x/twap/store_test.go | 21 +- x/twap/strategy.go | 18 +- x/twap/strategy_test.go | 136 ++- x/twap/types/expected_interfaces.go | 8 +- x/twap/types/genesis_test.go | 97 +- x/twap/types/keys.go | 3 +- x/twap/types/keys_test.go | 20 +- x/twap/types/twap_record.pb.go | 82 +- x/twap/types/twapmock/amminterface.go | 7 +- x/twap/types/utils.go | 10 +- x/txfees/keeper/feedecorator.go | 11 +- x/txfees/keeper/feedecorator_test.go | 5 +- x/txfees/keeper/feetokens.go | 9 +- x/txfees/keeper/hooks.go | 3 +- x/txfees/keeper/hooks_test.go | 31 +- x/txfees/keeper/keeper_test.go | 17 +- x/txfees/types/constants.go | 6 +- x/txfees/types/expected_keepers.go | 13 +- x/txfees/types/options.go | 19 +- x/txfees/types/query.pb.go | 86 +- x/valset-pref/README.md | 4 +- x/valset-pref/client/cli/query_test.go | 7 +- x/valset-pref/export_test.go | 3 +- x/valset-pref/keeper.go | 3 +- x/valset-pref/keeper_test.go | 13 +- x/valset-pref/msg_server_test.go | 169 +-- x/valset-pref/simulation/sim_msgs.go | 15 +- x/valset-pref/types/expected_interfaces.go | 7 +- x/valset-pref/types/msgs.go | 12 +- x/valset-pref/types/msgs_test.go | 34 +- x/valset-pref/types/state.pb.go | 50 +- x/valset-pref/validator_set.go | 52 +- x/valset-pref/validator_set_test.go | 51 +- 489 files changed, 12176 insertions(+), 11772 deletions(-) create mode 100644 osmomath/sdk_math_alias.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b5831065164..8a6df571d9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * [#6256](https://github.com/osmosis-labs/osmosis/pull/6256) Refactor CalcPriceToTick to operate on BigDec price to support new price range. * [#6317](https://github.com/osmosis-labs/osmosis/pull/6317) Remove price return from CL `math.TickToSqrtPrice` +* [#6238](https://github.com/osmosis-labs/osmosis/pull/6238) switch osmomath to sdkmath types and rename BigDec constructors to contain "Big" in the name. + * Note: with the update, the Dec and Int do not get initialized to zero values + by default in proto marhaling/unmarshaling. Instead, they get set to nil values. + * maxDecBitLen has changed by one bit so overflow panic can be triggerred sooner. ## v19.0.0 @@ -74,6 +78,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## v18.0.0 + +### Misc Improvements + +* [#6161](https://github.com/osmosis-labs/osmosis/pull/6161) Reduce CPU time of epochs + +### Bug Fixes + +* [#6162](https://github.com/osmosis-labs/osmosis/pull/6162) allow zero qualifying balancer shares in CL incentives + +### Features + +* [#6034](https://github.com/osmosis-labs/osmosis/pull/6034) feat(spike): taker fee Fixes mainnet bugs w/ incorrect accumulation sumtrees, and CL handling for a balancer pool with 0 bonded shares. ### Improvements @@ -99,7 +115,7 @@ Fixes mainnet bugs w/ incorrect accumulation sumtrees, and CL handling for a bal * [#5983](https://github.com/osmosis-labs/osmosis/pull/5983) refactor(CL): 6 return values in CL CreatePosition with a struct * [#6004](https://github.com/osmosis-labs/osmosis/pull/6004) reduce number of returns for creating full range position * [#6018](https://github.com/osmosis-labs/osmosis/pull/6018) golangci: add unused parameters linter -* [#6033](https://github.com/osmosis-labs/osmosis/pull/6033) change tick API from sdk.Dec to osmomath.BigDec +* [#6033](https://github.com/osmosis-labs/osmosis/pull/6033) change tick API from osmomath.Dec to osmomath.BigDec ### Features diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f7d6a8cf39d..4ad129ee564 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -219,13 +219,13 @@ func TestGetPoolAssetsByDenom(t *testing.T) { poolAssets: []balancer.PoolAsset { { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, expectedPoolAssetsByDenom: map[string]balancer.PoolAsset { "uosmo": { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, }, @@ -234,10 +234,10 @@ func TestGetPoolAssetsByDenom(t *testing.T) { poolAssets: []balancer.PoolAsset { { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uosmo", 123), - Weight: sdk.NewInt(400), + Weight: osmomath.NewInt(400), }, }, err: fmt.Errorf(balancer.ErrMsgFormatRepeatingPoolAssetsNotAllowed, "uosmo"), @@ -495,7 +495,7 @@ Additionally, this affects `LastResultsHash` because it contains a `Data` field Version A ```go -func (sk Keeper) validateAmount(ctx context.Context, amount sdk.Int) error { +func (sk Keeper) validateAmount(ctx context.Context, amount osmomath.Int) error { if amount.IsNegative() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "amount must be positive or zero") } @@ -506,7 +506,7 @@ func (sk Keeper) validateAmount(ctx context.Context, amount sdk.Int) error { Version B ```go -func (sk Keeper) validateAmount(ctx context.Context, amount sdk.Int) error { +func (sk Keeper) validateAmount(ctx context.Context, amount osmomath.Int) error { if amount.IsNegative() || amount.IsZero() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "amount must be positive") } diff --git a/app/apptesting/concentrated_liquidity.go b/app/apptesting/concentrated_liquidity.go index 0f485c18e04..ad340f15d68 100644 --- a/app/apptesting/concentrated_liquidity.go +++ b/app/apptesting/concentrated_liquidity.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -19,24 +20,24 @@ var ( DefaultTickSpacing = uint64(100) DefaultLowerTick = int64(30545000) DefaultUpperTick = int64(31500000) - DefaultCoinAmount = sdk.NewInt(1000000000000000000) + DefaultCoinAmount = osmomath.NewInt(1000000000000000000) ) // PrepareConcentratedPool sets up an eth usdc concentrated liquidity pool with a tick spacing of 100, // no liquidity and zero spread factor. func (s *KeeperTestHelper) PrepareConcentratedPool() types.ConcentratedPoolExtension { - return s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, sdk.ZeroDec()) + return s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, osmomath.ZeroDec()) } // PrepareConcentratedPoolWithCoins sets up a concentrated liquidity pool with custom denoms. func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoins(denom1, denom2 string) types.ConcentratedPoolExtension { - return s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, sdk.ZeroDec()) + return s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, osmomath.ZeroDec()) } // PrepareConcentratedPoolWithCoinsAndFullRangePosition sets up a concentrated liquidity pool with custom denoms. // It also creates a full range position. func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndFullRangePosition(denom1, denom2 string) types.ConcentratedPoolExtension { - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, sdk.ZeroDec()) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, osmomath.ZeroDec()) fundCoins := sdk.NewCoins(sdk.NewCoin(denom1, DefaultCoinAmount), sdk.NewCoin(denom2, DefaultCoinAmount)) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool, fundCoins) @@ -45,14 +46,14 @@ func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndFullRangePosition( // createConcentratedPoolsFromCoinsWithSpreadFactor creates CL pools from given sets of coins and respective swap fees. // Where element 1 of the input corresponds to the first pool created, element 2 to the second pool created etc. -func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(poolDenoms [][]string, spreadFactor []sdk.Dec) { +func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(poolDenoms [][]string, spreadFactor []osmomath.Dec) { for i, curPoolDenoms := range poolDenoms { s.Require().Equal(2, len(curPoolDenoms)) - var curSpreadFactor sdk.Dec + var curSpreadFactor osmomath.Dec if len(spreadFactor) > i { curSpreadFactor = spreadFactor[i] } else { - curSpreadFactor = sdk.ZeroDec() + curSpreadFactor = osmomath.ZeroDec() } clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], curPoolDenoms[0], curPoolDenoms[1], DefaultTickSpacing, curSpreadFactor) @@ -65,13 +66,13 @@ func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePositionWithSpread // createConcentratedPoolsFromCoins creates CL pools from given sets of coins (with zero swap fees). // Where element 1 of the input corresponds to the first pool created, element 2 to the second pool created etc. func (s *KeeperTestHelper) CreateConcentratedPoolsAndFullRangePosition(poolDenoms [][]string) { - s.CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(poolDenoms, []sdk.Dec{sdk.ZeroDec()}) + s.CreateConcentratedPoolsAndFullRangePositionWithSpreadFactor(poolDenoms, []osmomath.Dec{osmomath.ZeroDec()}) } // PrepareConcentratedPoolWithCoinsAndLockedFullRangePosition sets up a concentrated liquidity pool with custom denoms. // It also creates a full range position and locks it for 14 days. func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndLockedFullRangePosition(denom1, denom2 string) (types.ConcentratedPoolExtension, uint64, uint64) { - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, sdk.ZeroDec()) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], denom1, denom2, DefaultTickSpacing, osmomath.ZeroDec()) fundCoins := sdk.NewCoins(sdk.NewCoin(denom1, DefaultCoinAmount), sdk.NewCoin(denom2, DefaultCoinAmount)) s.FundAcc(s.TestAccs[0], fundCoins) positionData, concentratedLockId, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePositionLocked(s.Ctx, clPool.GetId(), s.TestAccs[0], fundCoins, time.Hour*24*14) @@ -82,7 +83,7 @@ func (s *KeeperTestHelper) PrepareConcentratedPoolWithCoinsAndLockedFullRangePos } // PrepareCustomConcentratedPool sets up a concentrated liquidity pool with the custom parameters. -func (s *KeeperTestHelper) PrepareCustomConcentratedPool(owner sdk.AccAddress, denom0, denom1 string, tickSpacing uint64, spreadFactor sdk.Dec) types.ConcentratedPoolExtension { +func (s *KeeperTestHelper) PrepareCustomConcentratedPool(owner sdk.AccAddress, denom0, denom1 string, tickSpacing uint64, spreadFactor osmomath.Dec) types.ConcentratedPoolExtension { // Mint some assets to the account. s.FundAcc(s.TestAccs[0], DefaultAcctFunds) @@ -113,7 +114,7 @@ func (s *KeeperTestHelper) PrepareMultipleConcentratedPools(poolsToCreate uint16 } // CreateFullRangePosition creates a full range position and returns position id and the liquidity created. -func (s *KeeperTestHelper) CreateFullRangePosition(pool types.ConcentratedPoolExtension, coins sdk.Coins) (uint64, sdk.Dec) { +func (s *KeeperTestHelper) CreateFullRangePosition(pool types.ConcentratedPoolExtension, coins sdk.Coins) (uint64, osmomath.Dec) { s.FundAcc(s.TestAccs[0], coins) positionData, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, pool.GetId(), s.TestAccs[0], coins) s.Require().NoError(err) @@ -121,7 +122,7 @@ func (s *KeeperTestHelper) CreateFullRangePosition(pool types.ConcentratedPoolEx } // WithdrawFullRangePosition withdraws given liquidity from a position specified by id. -func (s *KeeperTestHelper) WithdrawFullRangePosition(pool types.ConcentratedPoolExtension, positionId uint64, liquidityToRemove sdk.Dec) { +func (s *KeeperTestHelper) WithdrawFullRangePosition(pool types.ConcentratedPoolExtension, positionId uint64, liquidityToRemove osmomath.Dec) { clMsgServer := cl.NewMsgServerImpl(s.App.ConcentratedLiquidityKeeper) _, err := clMsgServer.WithdrawPosition(sdk.WrapSDKContext(s.Ctx), &types.MsgWithdrawPosition{ diff --git a/app/apptesting/gamm.go b/app/apptesting/gamm.go index ff1503cd0f3..fde65a3f876 100644 --- a/app/apptesting/gamm.go +++ b/app/apptesting/gamm.go @@ -20,41 +20,41 @@ const ( ) var DefaultAcctFunds sdk.Coins = sdk.NewCoins( - sdk.NewCoin(UOSMO, sdk.NewInt(10000000000)), - sdk.NewCoin(FOO, sdk.NewInt(10000000000)), - sdk.NewCoin(BAR, sdk.NewInt(10000000000)), - sdk.NewCoin(BAZ, sdk.NewInt(10000000000)), + sdk.NewCoin(UOSMO, osmomath.NewInt(10000000000)), + sdk.NewCoin(FOO, osmomath.NewInt(10000000000)), + sdk.NewCoin(BAR, osmomath.NewInt(10000000000)), + sdk.NewCoin(BAZ, osmomath.NewInt(10000000000)), ) var DefaultPoolAssets = []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(FOO, sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(FOO, osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin(BAR, sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin(BAR, osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(300), - Token: sdk.NewCoin(BAZ, sdk.NewInt(5000000)), + Weight: osmomath.NewInt(300), + Token: sdk.NewCoin(BAZ, osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(400), - Token: sdk.NewCoin(UOSMO, sdk.NewInt(5000000)), + Weight: osmomath.NewInt(400), + Token: sdk.NewCoin(UOSMO, osmomath.NewInt(5000000)), }, } var DefaultStableswapLiquidity = sdk.NewCoins( - sdk.NewCoin(FOO, sdk.NewInt(10000000)), - sdk.NewCoin(BAR, sdk.NewInt(10000000)), - sdk.NewCoin(BAZ, sdk.NewInt(10000000)), + sdk.NewCoin(FOO, osmomath.NewInt(10000000)), + sdk.NewCoin(BAR, osmomath.NewInt(10000000)), + sdk.NewCoin(BAZ, osmomath.NewInt(10000000)), ) var ImbalancedStableswapLiquidity = sdk.NewCoins( - sdk.NewCoin(FOO, sdk.NewInt(10_000_000_000)), - sdk.NewCoin(BAR, sdk.NewInt(20_000_000_000)), - sdk.NewCoin(BAZ, sdk.NewInt(30_000_000_000)), + sdk.NewCoin(FOO, osmomath.NewInt(10_000_000_000)), + sdk.NewCoin(BAR, osmomath.NewInt(20_000_000_000)), + sdk.NewCoin(BAZ, osmomath.NewInt(30_000_000_000)), ) // PrepareBalancerPoolWithCoins returns a balancer pool @@ -74,21 +74,21 @@ func (s *KeeperTestHelper) PrepareBalancerPoolWithCoinsAndWeights(coins sdk.Coin var poolAssets []balancer.PoolAsset for i, coin := range coins { poolAsset := balancer.PoolAsset{ - Weight: sdk.NewInt(weights[i]), + Weight: osmomath.NewInt(weights[i]), Token: coin, } poolAssets = append(poolAssets, poolAsset) } return s.PrepareCustomBalancerPool(poolAssets, balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) } -var zeroDec = sdk.ZeroDec() -var oneThirdSpotPriceUnits = sdk.NewDec(1).Quo(sdk.NewDec(3)). - MulIntMut(gammtypes.SpotPriceSigFigs).RoundInt().ToDec().QuoInt(gammtypes.SpotPriceSigFigs) +var zeroDec = osmomath.ZeroDec() +var oneThirdSpotPriceUnits = osmomath.NewDec(1).Quo(osmomath.NewDec(3)). + MulIntMut(gammtypes.SpotPriceSigFigs).RoundInt().ToLegacyDec().QuoInt(gammtypes.SpotPriceSigFigs) // PrepareBalancerPool returns a Balancer pool's pool-ID with pool params set in PrepareBalancerPoolWithPoolParams. func (s *KeeperTestHelper) PrepareBalancerPool() uint64 { @@ -99,10 +99,10 @@ func (s *KeeperTestHelper) PrepareBalancerPool() uint64 { spotPrice, err := s.App.GAMMKeeper.CalculateSpotPrice(s.Ctx, poolId, FOO, BAR) s.NoError(err) - s.Equal(sdk.NewDec(2), spotPrice) + s.Equal(osmomath.NewDec(2), spotPrice) spotPrice, err = s.App.GAMMKeeper.CalculateSpotPrice(s.Ctx, poolId, BAR, BAZ) s.NoError(err) - s.Equal(sdk.NewDecWithPrec(15, 1), spotPrice) + s.Equal(osmomath.NewDecWithPrec(15, 1), spotPrice) spotPrice, err = s.App.GAMMKeeper.CalculateSpotPrice(s.Ctx, poolId, BAZ, FOO) s.NoError(err) s.Equal(oneThirdSpotPriceUnits, spotPrice) @@ -126,8 +126,8 @@ func (s *KeeperTestHelper) PrepareBasicStableswapPool() uint64 { s.FundAcc(s.TestAccs[0], DefaultAcctFunds) params := stableswap.PoolParams{ - SwapFee: sdk.NewDec(0), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDec(0), + ExitFee: osmomath.NewDec(0), } msg := stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], params, DefaultStableswapLiquidity, []uint64{}, "") @@ -141,8 +141,8 @@ func (s *KeeperTestHelper) PrepareImbalancedStableswapPool() uint64 { s.FundAcc(s.TestAccs[0], ImbalancedStableswapLiquidity) params := stableswap.PoolParams{ - SwapFee: sdk.NewDec(0), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDec(0), + ExitFee: osmomath.NewDec(0), } msg := stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], params, ImbalancedStableswapLiquidity, []uint64{1, 1, 1}, "") @@ -161,7 +161,7 @@ func (s *KeeperTestHelper) PrepareBalancerPoolWithPoolParams(poolParams balancer // PrepareCustomBalancerPool sets up a Balancer pool with an array of assets and given parameters func (s *KeeperTestHelper) PrepareCustomBalancerPool(assets []balancer.PoolAsset, params balancer.PoolParams) uint64 { // Add coins for pool creation fee + coins needed to mint balances - fundCoins := sdk.NewCoins(sdk.NewCoin(UOSMO, sdk.NewInt(10000000000))) + fundCoins := sdk.NewCoins(sdk.NewCoin(UOSMO, osmomath.NewInt(10000000000))) for _, a := range assets { fundCoins = fundCoins.Add(a.Token) } @@ -179,7 +179,7 @@ func (s *KeeperTestHelper) PrepareCustomBalancerPoolFromCoins(coins sdk.Coins, p var poolAssets []balancer.PoolAsset for _, coin := range coins { poolAsset := balancer.PoolAsset{ - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), Token: coin, } poolAssets = append(poolAssets, poolAsset) @@ -189,7 +189,7 @@ func (s *KeeperTestHelper) PrepareCustomBalancerPoolFromCoins(coins sdk.Coins, p } // Modify spotprice of a pool to target spotprice -func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.Dec, baseDenom string) { +func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice osmomath.Dec, baseDenom string) { var quoteDenom string int64Max := int64(^uint64(0) >> 1) @@ -206,20 +206,20 @@ func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.De amountTrade := s.CalcAmoutOfTokenToGetTargetPrice(s.Ctx, pool, targetSpotPrice, baseDenom, quoteDenom) if amountTrade.IsPositive() { - swapIn := sdk.NewCoins(sdk.NewCoin(quoteDenom, sdk.NewInt(amountTrade.RoundInt64()))) + swapIn := sdk.NewCoins(sdk.NewCoin(quoteDenom, osmomath.NewInt(amountTrade.RoundInt64()))) s.FundAcc(s.TestAccs[0], swapIn) msg := gammtypes.MsgSwapExactAmountIn{ Sender: s.TestAccs[0].String(), Routes: []poolmanagertypes.SwapAmountInRoute{{PoolId: poolID, TokenOutDenom: baseDenom}}, TokenIn: swapIn[0], - TokenOutMinAmount: sdk.ZeroInt(), + TokenOutMinAmount: osmomath.ZeroInt(), } gammMsgServer := gammkeeper.NewMsgServerImpl(s.App.GAMMKeeper) _, err = gammMsgServer.SwapExactAmountIn(sdk.WrapSDKContext(s.Ctx), &msg) s.Require().NoError(err) } else { - swapOut := sdk.NewCoins(sdk.NewCoin(quoteDenom, sdk.NewInt(amountTrade.RoundInt64()).Abs())) + swapOut := sdk.NewCoins(sdk.NewCoin(quoteDenom, osmomath.NewInt(amountTrade.RoundInt64()).Abs())) spreadFactor := pool.GetSpreadFactor(s.Ctx) tokenIn, err := pool.CalcInAmtGivenOut(s.Ctx, swapOut, baseDenom, spreadFactor) s.Require().NoError(err) @@ -227,7 +227,7 @@ func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.De msg := gammtypes.MsgSwapExactAmountOut{ Sender: s.TestAccs[0].String(), Routes: []poolmanagertypes.SwapAmountOutRoute{{PoolId: poolID, TokenInDenom: baseDenom}}, - TokenInMaxAmount: sdk.NewInt(int64Max), + TokenInMaxAmount: osmomath.NewInt(int64Max), TokenOut: swapOut[0], } @@ -238,7 +238,7 @@ func (s *KeeperTestHelper) ModifySpotPrice(poolID uint64, targetSpotPrice sdk.De } func (s *KeeperTestHelper) RunBasicExit(poolId uint64) { - shareInAmount := sdk.NewInt(100) + shareInAmount := osmomath.NewInt(100) tokenOutMins := sdk.NewCoins() msg := gammtypes.MsgExitPool{ @@ -260,7 +260,7 @@ func (s *KeeperTestHelper) RunBasicJoin(poolId uint64) { tokenIn := sdk.NewCoins() for _, denom := range denoms { - tokenIn = tokenIn.Add(sdk.NewCoin(denom, sdk.NewInt(10000000))) + tokenIn = tokenIn.Add(sdk.NewCoin(denom, osmomath.NewInt(10000000))) } s.FundAcc(s.TestAccs[0], sdk.NewCoins(tokenIn...)) @@ -269,7 +269,7 @@ func (s *KeeperTestHelper) RunBasicJoin(poolId uint64) { msg := gammtypes.MsgJoinPool{ Sender: s.TestAccs[0].String(), PoolId: poolId, - ShareOutAmount: totalPoolShare.Quo(sdk.NewInt(100000)), + ShareOutAmount: totalPoolShare.Quo(osmomath.NewInt(100000)), TokenInMaxs: tokenIn, } @@ -278,15 +278,15 @@ func (s *KeeperTestHelper) RunBasicJoin(poolId uint64) { s.Require().NoError(err) } -func (s *KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice(ctx sdk.Context, pool gammtypes.CFMMPoolI, targetSpotPrice sdk.Dec, baseDenom, quoteDenom string) (amountTrade sdk.Dec) { +func (s *KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice(ctx sdk.Context, pool gammtypes.CFMMPoolI, targetSpotPrice osmomath.Dec, baseDenom, quoteDenom string) (amountTrade osmomath.Dec) { blPool, ok := pool.(*balancer.Pool) s.Require().True(ok) quoteAsset, _ := blPool.GetPoolAsset(quoteDenom) baseAsset, err := blPool.GetPoolAsset(baseDenom) s.Require().NoError(err) - s.Require().NotEqual(baseAsset.Weight, sdk.ZeroInt()) - s.Require().NotEqual(quoteAsset.Weight, sdk.ZeroInt()) + s.Require().NotEqual(baseAsset.Weight, osmomath.ZeroInt()) + s.Require().NotEqual(quoteAsset.Weight, osmomath.ZeroInt()) spotPriceNow, err := blPool.SpotPrice(ctx, baseDenom, quoteDenom) s.Require().NoError(err) @@ -295,9 +295,9 @@ func (s *KeeperTestHelper) CalcAmoutOfTokenToGetTargetPrice(ctx sdk.Context, poo // AmoutQuoteTokenNeedToTrade = AmoutQuoTokenNow * ((targetSpotPrice/spotPriceNow)^((weight_base/(weight_base + weight_quote))) -1 ) ratioPrice := targetSpotPrice.Quo(spotPriceNow) - ratioWeight := (baseAsset.Weight.ToDec()).Quo(baseAsset.Weight.ToDec().Add(quoteAsset.Weight.ToDec())) + ratioWeight := (baseAsset.Weight.ToLegacyDec()).Quo(baseAsset.Weight.ToLegacyDec().Add(quoteAsset.Weight.ToLegacyDec())) - amountTrade = quoteAsset.Token.Amount.ToDec().Mul(osmomath.Pow(ratioPrice, ratioWeight).Sub(sdk.OneDec())) + amountTrade = quoteAsset.Token.Amount.ToLegacyDec().Mul(osmomath.Pow(ratioPrice, ratioWeight).Sub(osmomath.OneDec())) return amountTrade } diff --git a/app/apptesting/pool_manager.go b/app/apptesting/pool_manager.go index ef2a2ea8777..b091713e9d2 100644 --- a/app/apptesting/pool_manager.go +++ b/app/apptesting/pool_manager.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" poolmanager "github.com/osmosis-labs/osmosis/v19/x/poolmanager" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -14,14 +15,14 @@ func (s *KeeperTestHelper) RunBasicSwap(poolId uint64) { denoms, err := s.App.PoolManagerKeeper.RouteGetPoolDenoms(s.Ctx, poolId) s.Require().NoError(err) - swapIn := sdk.NewCoins(sdk.NewCoin(denoms[0], sdk.NewInt(1000))) + swapIn := sdk.NewCoins(sdk.NewCoin(denoms[0], osmomath.NewInt(1000))) s.FundAcc(s.TestAccs[0], swapIn) msg := poolmanagertypes.MsgSwapExactAmountIn{ Sender: s.TestAccs[0].String(), Routes: []poolmanagertypes.SwapAmountInRoute{{PoolId: poolId, TokenOutDenom: denoms[1]}}, TokenIn: swapIn[0], - TokenOutMinAmount: sdk.ZeroInt(), + TokenOutMinAmount: osmomath.ZeroInt(), } poolManagerMsgServer := poolmanager.NewMsgServerImpl(s.App.PoolManagerKeeper) @@ -49,16 +50,16 @@ func (s *KeeperTestHelper) CreatePoolFromType(poolType poolmanagertypes.PoolType // CreatePoolFromTypeWithCoins creates a pool with the given type and initialized with the given coins. func (s *KeeperTestHelper) CreatePoolFromTypeWithCoins(poolType poolmanagertypes.PoolType, coins sdk.Coins) uint64 { - return s.CreatePoolFromTypeWithCoinsAndSpreadFactor(poolType, coins, sdk.ZeroDec()) + return s.CreatePoolFromTypeWithCoinsAndSpreadFactor(poolType, coins, osmomath.ZeroDec()) } // CreatePoolFromTypeWithCoinsAndSpreadFactor creates a pool with given type, initialized with the given coins as initial liquidity and spread factor. -func (s *KeeperTestHelper) CreatePoolFromTypeWithCoinsAndSpreadFactor(poolType poolmanagertypes.PoolType, coins sdk.Coins, spreadFactor sdk.Dec) uint64 { +func (s *KeeperTestHelper) CreatePoolFromTypeWithCoinsAndSpreadFactor(poolType poolmanagertypes.PoolType, coins sdk.Coins, spreadFactor osmomath.Dec) uint64 { switch poolType { case poolmanagertypes.Balancer: poolId := s.PrepareCustomBalancerPoolFromCoins(coins, balancer.PoolParams{ SwapFee: spreadFactor, - ExitFee: sdk.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) return poolId case poolmanagertypes.Concentrated: diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index 864211a55c5..201195a2882 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -31,6 +31,7 @@ import ( tmtypes "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -62,7 +63,7 @@ type KeeperTestHelper struct { var ( SecondaryDenom = "uion" - SecondaryAmount = sdk.NewInt(100000000) + SecondaryAmount = osmomath.NewInt(100000000) baseTestAccts = []sdk.AccAddress{} defaultTestStartTime = time.Now().UTC() ) @@ -205,14 +206,14 @@ func (s *KeeperTestHelper) SetupValidator(bondStatus stakingtypes.BondStatus) sd valPub := secp256k1.GenPrivKey().PubKey() valAddr := sdk.ValAddress(valPub.Address()) bondDenom := s.App.StakingKeeper.GetParams(s.Ctx).BondDenom - selfBond := sdk.NewCoins(sdk.Coin{Amount: sdk.NewInt(100), Denom: bondDenom}) + selfBond := sdk.NewCoins(sdk.Coin{Amount: osmomath.NewInt(100), Denom: bondDenom}) s.FundAcc(sdk.AccAddress(valAddr), selfBond) stakingHandler := staking.NewHandler(*s.App.StakingKeeper) stakingCoin := sdk.Coin{Denom: sdk.DefaultBondDenom, Amount: selfBond[0].Amount} ZeroCommission := stakingtypes.NewCommissionRates(zeroDec, zeroDec, zeroDec) - msg, err := stakingtypes.NewMsgCreateValidator(valAddr, valPub, stakingCoin, stakingtypes.Description{}, ZeroCommission, sdk.OneInt()) + msg, err := stakingtypes.NewMsgCreateValidator(valAddr, valPub, stakingCoin, stakingtypes.Description{}, ZeroCommission, osmomath.OneInt()) s.Require().NoError(err) res, err := stakingHandler(s.Ctx, msg) s.Require().NoError(err) @@ -323,7 +324,7 @@ func (s *KeeperTestHelper) RunMsg(msg sdk.Msg) (*sdk.Result, error) { } // AllocateRewardsToValidator allocates reward tokens to a distribution module then allocates rewards to the validator address. -func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, rewardAmt sdk.Int) { +func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, rewardAmt osmomath.Int) { validator, found := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) s.Require().True(found) @@ -334,12 +335,12 @@ func (s *KeeperTestHelper) AllocateRewardsToValidator(valAddr sdk.ValAddress, re // allocate rewards to validator s.Ctx = s.Ctx.WithBlockHeight(s.Ctx.BlockHeight() + 1) - decTokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: sdk.NewDec(20000)}} + decTokens := sdk.DecCoins{{Denom: sdk.DefaultBondDenom, Amount: osmomath.NewDec(20000)}} s.App.DistrKeeper.AllocateTokensToValidator(s.Ctx, validator, decTokens) } // SetupGammPoolsWithBondDenomMultiplier uses given multipliers to set initial pool supply of bond denom. -func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []sdk.Dec) []gammtypes.CFMMPoolI { +func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []osmomath.Dec) []gammtypes.CFMMPoolI { bondDenom := s.App.StakingKeeper.BondDenom(s.Ctx) // TODO: use sdk crypto instead of tendermint to generate address acc1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) @@ -349,10 +350,10 @@ func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []s pools := []gammtypes.CFMMPoolI{} for index, multiplier := range multipliers { token := fmt.Sprintf("token%d", index) - uosmoAmount := gammtypes.InitPoolSharesSupply.ToDec().Mul(multiplier).RoundInt() + uosmoAmount := gammtypes.InitPoolSharesSupply.ToLegacyDec().Mul(multiplier).RoundInt() s.FundAcc(acc1, sdk.NewCoins( - sdk.NewCoin(bondDenom, uosmoAmount.Mul(sdk.NewInt(10))), + sdk.NewCoin(bondDenom, uosmoAmount.Mul(osmomath.NewInt(10))), sdk.NewInt64Coin(token, 100000), ).Add(params.PoolCreationFee...)) @@ -361,20 +362,20 @@ func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []s // pool assets defaultFooAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), Token: sdk.NewCoin(bondDenom, uosmoAmount), } defaultBarAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(token, sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(token, osmomath.NewInt(10000)), } poolAssets = []balancer.PoolAsset{defaultFooAsset, defaultBarAsset} ) poolParams := balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.Dec(sdk.ZeroInt()), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.Dec(osmomath.ZeroInt()), } msg := balancer.NewMsgCreateBalancerPool(acc1, poolParams, poolAssets, defaultFutureGovernor) @@ -392,7 +393,7 @@ func (s *KeeperTestHelper) SetupGammPoolsWithBondDenomMultiplier(multipliers []s // SwapAndSetSpotPrice runs a swap to set Spot price of a pool using arbitrary values // returns spot price after the arbitrary swap. -func (s *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin, toAsset sdk.Coin) sdk.Dec { +func (s *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin, toAsset sdk.Coin) osmomath.Dec { // create a dummy account acc1 := sdk.AccAddress(ed25519.GenPrivKey().PubKey().Address().Bytes()) @@ -412,7 +413,7 @@ func (s *KeeperTestHelper) SwapAndSetSpotPrice(poolId uint64, fromAsset sdk.Coin route, fromAsset.Amount, sdk.NewCoin(toAsset.Denom, - toAsset.Amount.Quo(sdk.NewInt(4)))) + toAsset.Amount.Quo(osmomath.NewInt(4)))) s.Require().NoError(err) spotPrice, err := s.App.GAMMKeeper.CalculateSpotPrice(s.Ctx, poolId, fromAsset.Denom, toAsset.Denom) diff --git a/app/params/config.go b/app/params/config.go index b463dd45fcf..e158db4c877 100644 --- a/app/params/config.go +++ b/app/params/config.go @@ -4,6 +4,8 @@ import ( errorsmod "cosmossdk.io/errors" "github.com/cosmos/cosmos-sdk/types/address" + "github.com/osmosis-labs/osmosis/osmomath" + sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -39,11 +41,11 @@ func init() { // RegisterDenoms registers token denoms. func RegisterDenoms() { - err := sdk.RegisterDenom(HumanCoinUnit, sdk.OneDec()) + err := sdk.RegisterDenom(HumanCoinUnit, osmomath.OneDec()) if err != nil { panic(err) } - err = sdk.RegisterDenom(BaseCoinUnit, sdk.NewDecWithPrec(1, OsmoExponent)) + err = sdk.RegisterDenom(BaseCoinUnit, osmomath.NewDecWithPrec(1, OsmoExponent)) if err != nil { panic(err) } diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index bbc6109cf8d..d5183c94844 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -12,6 +12,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" ibcratelimittypes "github.com/osmosis-labs/osmosis/v19/x/ibc-rate-limit/types" @@ -29,10 +30,10 @@ type UpgradeTestSuite struct { } var DefaultAcctFunds sdk.Coins = sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000)), - sdk.NewCoin("baz", sdk.NewInt(10000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000)), + sdk.NewCoin("baz", osmomath.NewInt(10000000)), ) func (suite *UpgradeTestSuite) SetupTest() { @@ -97,8 +98,8 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { suite.FundAcc(testAccount, DefaultAcctFunds) // Create the balancer pool - spreadFactor := sdk.MustNewDecFromStr("0.003") - exitFee := sdk.ZeroDec() + spreadFactor := osmomath.MustNewDecFromStr("0.003") + exitFee := osmomath.ZeroDec() poolID, err := suite.App.PoolManagerKeeper.CreatePool( suite.Ctx, balancer.NewMsgCreateBalancerPool(suite.TestAccs[0], @@ -108,12 +109,12 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { }, []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, ""), @@ -121,8 +122,8 @@ func (suite *UpgradeTestSuite) TestMigrateBalancerToStablePools() { suite.Require().NoError(err) // join the pool - shareOutAmount := sdk.NewInt(1_000_000_000_000_000) - tokenInMaxs := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000))) + shareOutAmount := osmomath.NewInt(1_000_000_000_000_000) + tokenInMaxs := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000000)), sdk.NewCoin("bar", osmomath.NewInt(5000000))) tokenIn, sharesOut, err := suite.App.GAMMKeeper.JoinPoolNoSwap(suite.Ctx, testAccount, poolID, shareOutAmount, tokenInMaxs) suite.Require().NoError(err) @@ -258,6 +259,6 @@ func (suite *UpgradeTestSuite) validateCons(coinsA, coinsB sdk.Coins) { for _, coinA := range coinsA { coinBAmount := coinsB.AmountOf(coinA.Denom) // minor tolerance due to fees and rounding - osmoassert.DecApproxEq(suite.T(), coinBAmount.ToDec(), coinA.Amount.ToDec(), sdk.NewDec(2)) + osmoassert.DecApproxEq(suite.T(), coinBAmount.ToLegacyDec(), coinA.Amount.ToLegacyDec(), osmomath.NewDec(2)) } } diff --git a/app/upgrades/v16/upgrades.go b/app/upgrades/v16/upgrades.go index d85e30fa07c..d108f875ede 100644 --- a/app/upgrades/v16/upgrades.go +++ b/app/upgrades/v16/upgrades.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/keepers" "github.com/osmosis-labs/osmosis/v19/app/upgrades" @@ -45,7 +46,7 @@ var ( ATOMIBCDenom = "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2" DAIIBCDenom = "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7" USDCIBCDenom = "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858" - SpreadFactor = sdk.MustNewDecFromStr("0.002") + SpreadFactor = osmomath.MustNewDecFromStr("0.002") // authorized_quote_denoms quote assets that can be used as token1 // when creating a pool. We limit the quote assets to a small set @@ -83,7 +84,7 @@ func CreateUpgradeHandler( // Update expedited governance param // In particular, set expedited quorum to 2/3. params := keepers.GovKeeper.GetTallyParams(ctx) - params.ExpeditedQuorum = sdk.NewDec(2).Quo(sdk.NewDec(3)) + params.ExpeditedQuorum = osmomath.NewDec(2).Quo(osmomath.NewDec(3)) keepers.GovKeeper.SetTallyParams(ctx, params) // Add cosmwasmpool module address to the list of allowed addresses to upload contract code. @@ -137,12 +138,12 @@ func CreateUpgradeHandler( communityPoolAddress := keepers.AccountKeeper.GetModuleAddress(distrtypes.ModuleName) // Determine the amount of OSMO that can be bought with 1 DAI. - oneDai := sdk.NewCoin(DAIIBCDenom, sdk.NewInt(1000000000000000000)) + oneDai := sdk.NewCoin(DAIIBCDenom, osmomath.NewInt(1000000000000000000)) daiOsmoGammPool, err := keepers.PoolManagerKeeper.GetPool(ctx, DaiOsmoPoolId) if err != nil { return nil, err } - respectiveOsmo, err := keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, daiOsmoGammPool, oneDai, DesiredDenom0, sdk.ZeroDec()) + respectiveOsmo, err := keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, daiOsmoGammPool, oneDai, DesiredDenom0, osmomath.ZeroDec()) if err != nil { return nil, err } diff --git a/app/upgrades/v16/upgrades_test.go b/app/upgrades/v16/upgrades_test.go index f6ecf21f49b..b00650a7916 100644 --- a/app/upgrades/v16/upgrades_test.go +++ b/app/upgrades/v16/upgrades_test.go @@ -25,8 +25,8 @@ import ( var ( DAIIBCDenom = "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7" - defaultDaiAmount, _ = sdk.NewIntFromString("73000000000000000000000") - defaultDenom0mount = sdk.NewInt(10000000000) + defaultDaiAmount, _ = osmomath.NewIntFromString("73000000000000000000000") + defaultDenom0mount = osmomath.NewInt(10000000000) desiredDenom0 = "uosmo" desiredDenom0Coin = sdk.NewCoin(desiredDenom0, defaultDenom0mount) daiCoin = sdk.NewCoin(DAIIBCDenom, defaultDaiAmount) @@ -72,9 +72,9 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // Allow 0.01% margin of error. multiplicativeTolerance := osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.MustNewDecFromStr("0.0001"), + MultiplicativeTolerance: osmomath.MustNewDecFromStr("0.0001"), } - defaultDaiAmount, _ := sdk.NewIntFromString("73000000000000000000000") + defaultDaiAmount, _ := osmomath.NewIntFromString("73000000000000000000000") testCases := []struct { name string pre_upgrade func() @@ -88,11 +88,11 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // Create earlier pools for i := uint64(1); i < v16.DaiOsmoPoolId; i++ { - suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", defaultDaiAmount)) + suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", defaultDaiAmount)) } // Create DAI / OSMO pool - suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", defaultDaiAmount), sdk.NewCoin("uosmo", sdk.NewInt(10000000000))) + suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", defaultDaiAmount), sdk.NewCoin("uosmo", osmomath.NewInt(10000000000))) }, func() { @@ -100,7 +100,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { stakingParams.BondDenom = "uosmo" suite.App.StakingKeeper.SetParams(suite.Ctx, stakingParams) - oneDai := sdk.NewCoins(sdk.NewCoin(v16.DAIIBCDenom, sdk.NewInt(1000000000000000000))) + oneDai := sdk.NewCoins(sdk.NewCoin(v16.DAIIBCDenom, osmomath.NewInt(1000000000000000000))) // Send one dai to the community pool (this is true in current mainnet) suite.FundAcc(suite.TestAccs[0], oneDai) @@ -111,7 +111,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // Determine approx how much OSMO will be used from community pool when 1 DAI used. daiOsmoGammPool, err := suite.App.PoolManagerKeeper.GetPool(suite.Ctx, v16.DaiOsmoPoolId) suite.Require().NoError(err) - respectiveOsmo, err := suite.App.GAMMKeeper.CalcOutAmtGivenIn(suite.Ctx, daiOsmoGammPool, oneDai[0], v16.DesiredDenom0, sdk.ZeroDec()) + respectiveOsmo, err := suite.App.GAMMKeeper.CalcOutAmtGivenIn(suite.Ctx, daiOsmoGammPool, oneDai[0], v16.DesiredDenom0, osmomath.ZeroDec()) suite.Require().NoError(err) // Retrieve the community pool balance before the upgrade @@ -152,7 +152,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { suite.Require().Equal(v16.DAIIBCDenom, concentratedTypePool.GetToken1()) // Validate that the spot price of the CL pool is what we expect - suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromSDKDec(balancerSpotPrice))) + suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromDec(balancerSpotPrice))) // Validate that link was created. migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx) @@ -182,7 +182,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // Validate that expedited quorum was set to 2/3 expQuorum := suite.App.GovKeeper.GetTallyParams(suite.Ctx).ExpeditedQuorum - suite.Require().Equal(sdk.NewDec(2).Quo(sdk.NewDec(3)), expQuorum) + suite.Require().Equal(osmomath.NewDec(2).Quo(osmomath.NewDec(3)), expQuorum) // Validate that cw pool module address is allowed to upload contract code allowedAddresses := suite.App.WasmKeeper.GetParams(suite.Ctx).CodeUploadAccess.Addresses @@ -227,12 +227,12 @@ func upgradeProtorevSetup(suite *UpgradeTestSuite) error { account := apptesting.CreateRandomAccounts(1)[0] suite.App.ProtoRevKeeper.SetDeveloperAccount(suite.Ctx, account) - devFee := sdk.NewCoin("uosmo", sdk.NewInt(1000000)) + devFee := sdk.NewCoin("uosmo", osmomath.NewInt(1000000)) if err := suite.App.ProtoRevKeeper.SetDeveloperFees(suite.Ctx, devFee); err != nil { return err } - fundCoin := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))) + fundCoin := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))) if err := suite.App.AppKeepers.BankKeeper.MintCoins(suite.Ctx, protorevtypes.ModuleName, fundCoin); err != nil { return err @@ -245,7 +245,7 @@ func verifyProtorevUpdateSuccess(suite *UpgradeTestSuite) { // Ensure balance was transferred to the developer account devAcc, err := suite.App.ProtoRevKeeper.GetDeveloperAccount(suite.Ctx) suite.Require().NoError(err) - suite.Require().Equal(suite.App.BankKeeper.GetBalance(suite.Ctx, devAcc, "uosmo"), sdk.NewCoin("uosmo", sdk.NewInt(1000000))) + suite.Require().Equal(suite.App.BankKeeper.GetBalance(suite.Ctx, devAcc, "uosmo"), sdk.NewCoin("uosmo", osmomath.NewInt(1000000))) // Ensure developer fees are empty coins, err := suite.App.ProtoRevKeeper.GetAllDeveloperFees(suite.Ctx) diff --git a/app/upgrades/v17/constants.go b/app/upgrades/v17/constants.go index 864f970e354..9c877a35d62 100644 --- a/app/upgrades/v17/constants.go +++ b/app/upgrades/v17/constants.go @@ -6,6 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/upgrades" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -38,7 +39,7 @@ const ( type AssetPair struct { BaseAsset string QuoteAsset string - SpreadFactor sdk.Dec + SpreadFactor osmomath.Dec LinkedClassicPool uint64 Superfluid bool } @@ -46,7 +47,7 @@ type AssetPair struct { var AssetPairs = []AssetPair{ {LinkedClassicPool: 837}, { - SpreadFactor: sdk.MustNewDecFromStr("0.0005"), // Normally 0.0002, but is not authorized + SpreadFactor: osmomath.MustNewDecFromStr("0.0005"), // Normally 0.0002, but is not authorized LinkedClassicPool: 857, }, { @@ -165,182 +166,182 @@ var AssetPairsForTestsOnly = []AssetPair{ { QuoteAsset: OSMO, BaseAsset: ISTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 837, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: CMSTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.0005"), // Normally 0.0002, but is not authorized + SpreadFactor: osmomath.MustNewDecFromStr("0.0005"), // Normally 0.0002, but is not authorized LinkedClassicPool: 857, Superfluid: false, }, { QuoteAsset: WBTCIBCDenom, BaseAsset: OSMO, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 712, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: DOTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 773, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: CROIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 9, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: AKTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 3, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: AXLIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 812, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: SCRTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 584, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: STARSIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.003"), + SpreadFactor: osmomath.MustNewDecFromStr("0.003"), LinkedClassicPool: 604, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: JUNOIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.003"), + SpreadFactor: osmomath.MustNewDecFromStr("0.003"), LinkedClassicPool: 497, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: STRDIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 806, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: MARSIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 907, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: ION, - SpreadFactor: sdk.MustNewDecFromStr("0.005"), + SpreadFactor: osmomath.MustNewDecFromStr("0.005"), LinkedClassicPool: 1013, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: XPRTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 15, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: MEDIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 586, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: SOMMIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 627, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: BLDIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 795, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: KAVAIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 730, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: IRISIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 7, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: stIBCXDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.003"), + SpreadFactor: osmomath.MustNewDecFromStr("0.003"), LinkedClassicPool: 1039, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: DVPNIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 5, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: BTSGIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 573, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: UMEEIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 641, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: HUAHUAIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 605, Superfluid: true, }, { QuoteAsset: OSMO, BaseAsset: NCTIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 971, Superfluid: false, }, { QuoteAsset: OSMO, BaseAsset: GRAVIBCDenom, - SpreadFactor: sdk.MustNewDecFromStr("0.002"), + SpreadFactor: osmomath.MustNewDecFromStr("0.002"), LinkedClassicPool: 625, Superfluid: false, }, @@ -439,21 +440,21 @@ func InitializeAssetPairsTestnet(ctx sdk.Context, keepers *keepers.AppKeepers) ( // validateSpotPriceFallsInBounds ensures that after swapping in the OSMO for the baseAsset, the resulting spot price is within the // min and max spot price bounds of the concentrated liquidity module. -func validateSpotPriceFallsInBounds(ctx sdk.Context, cfmmPool gammtypes.CFMMPoolI, keepers *keepers.AppKeepers, baseAsset, quoteAsset string, spreadFactor sdk.Dec) error { +func validateSpotPriceFallsInBounds(ctx sdk.Context, cfmmPool gammtypes.CFMMPoolI, keepers *keepers.AppKeepers, baseAsset, quoteAsset string, spreadFactor osmomath.Dec) error { // Check if swapping 0.1 OSMO results in a spot price less than the min or greater than the max var respectiveBaseAsset sdk.Coin var err error if baseAsset == OSMO { - respectiveBaseAsset, err = keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, cfmmPool, sdk.NewCoin(baseAsset, sdk.NewInt(100000)), quoteAsset, spreadFactor) + respectiveBaseAsset, err = keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, cfmmPool, sdk.NewCoin(baseAsset, osmomath.NewInt(100000)), quoteAsset, spreadFactor) } else if quoteAsset == OSMO { - respectiveBaseAsset, err = keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, cfmmPool, sdk.NewCoin(quoteAsset, sdk.NewInt(100000)), baseAsset, spreadFactor) + respectiveBaseAsset, err = keepers.GAMMKeeper.CalcOutAmtGivenIn(ctx, cfmmPool, sdk.NewCoin(quoteAsset, osmomath.NewInt(100000)), baseAsset, spreadFactor) } else { return fmt.Errorf("expected one of the pool's assets to be OSMO, got %s and %s", baseAsset, quoteAsset) } if err != nil { return err } - expectedSpotPriceFromSwap := sdk.NewDec(100000).Quo(respectiveBaseAsset.Amount.ToDec()) + expectedSpotPriceFromSwap := osmomath.NewDec(100000).Quo(respectiveBaseAsset.Amount.ToLegacyDec()) if expectedSpotPriceFromSwap.LT(cltypes.MinSpotPrice) || expectedSpotPriceFromSwap.GT(cltypes.MaxSpotPrice) { return fmt.Errorf("expected spot price from swap to be between %s and %s, got %s", cltypes.MinSpotPrice, cltypes.MaxSpotPrice, expectedSpotPriceFromSwap) } diff --git a/app/upgrades/v17/upgrades.go b/app/upgrades/v17/upgrades.go index efe92b64fcd..ac79680bcdb 100644 --- a/app/upgrades/v17/upgrades.go +++ b/app/upgrades/v17/upgrades.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/osmosis-labs/osmosis/osmomath" ibchookstypes "github.com/osmosis-labs/osmosis/x/ibc-hooks/types" errorsmod "cosmossdk.io/errors" @@ -148,7 +149,7 @@ func CreateUpgradeHandler( // createCLPoolWithCommunityPoolPosition creates a CL pool for a given balancer pool and adds a full range position with the community pool. func createCLPoolWithCommunityPoolPosition(ctx sdk.Context, keepers *keepers.AppKeepers, assetPair AssetPair, communityPoolAddress sdk.AccAddress) (clPoolCreationInfo, sdk.Coins, error) { // Determine if base or quote asset is OSMO and save the non-OSMO asset. - osmoIn := sdk.NewCoin(OSMO, sdk.NewInt(100000)) + osmoIn := sdk.NewCoin(OSMO, osmomath.NewInt(100000)) nonOsmoAsset := "" if assetPair.BaseAsset != OSMO { nonOsmoAsset = assetPair.BaseAsset @@ -188,7 +189,7 @@ func createCLPoolWithCommunityPoolPosition(ctx sdk.Context, keepers *keepers.App commPoolBalancePre := sdk.NewCoins(commPoolBalanceBaseAssetPre, commPoolBalanceQuoteAssetPre) // Swap 0.1 OSMO for nonOsmoAsset from the community pool. - respectiveNonOsmoAssetInt, err := keepers.GAMMKeeper.SwapExactAmountIn(ctx, communityPoolAddress, linkedClassicPool, osmoIn, nonOsmoAsset, sdk.ZeroInt(), linkedClassicPool.GetSpreadFactor(ctx)) + respectiveNonOsmoAssetInt, err := keepers.GAMMKeeper.SwapExactAmountIn(ctx, communityPoolAddress, linkedClassicPool, osmoIn, nonOsmoAsset, osmomath.ZeroInt(), linkedClassicPool.GetSpreadFactor(ctx)) if err != nil { return clPoolCreationInfo{}, sdk.Coins{}, err } diff --git a/app/upgrades/v17/upgrades_test.go b/app/upgrades/v17/upgrades_test.go index 66e5fa527b4..3df210aba0f 100644 --- a/app/upgrades/v17/upgrades_test.go +++ b/app/upgrades/v17/upgrades_test.go @@ -57,7 +57,7 @@ func dummyUpgrade(suite *UpgradeTestSuite) { suite.Ctx = suite.Ctx.WithBlockHeight(dummyUpgradeHeight) } -func dummyTwapRecord(poolId uint64, t time.Time, asset0 string, asset1 string, sp0, accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { +func dummyTwapRecord(poolId uint64, t time.Time, asset0 string, asset1 string, sp0, accum0, accum1, geomAccum osmomath.Dec) types.TwapRecord { return types.TwapRecord{ PoolId: poolId, Time: t, @@ -65,7 +65,7 @@ func dummyTwapRecord(poolId uint64, t time.Time, asset0 string, asset1 string, s Asset1Denom: asset1, P0LastSpotPrice: sp0, - P1LastSpotPrice: sdk.OneDec().Quo(sp0), + P1LastSpotPrice: osmomath.OneDec().Quo(sp0), P0ArithmeticTwapAccumulator: accum0, P1ArithmeticTwapAccumulator: accum1, GeometricTwapAccumulator: geomAccum, @@ -86,7 +86,7 @@ func assertEqual(suite *UpgradeTestSuite, pre, post interface{}) { func (suite *UpgradeTestSuite) TestUpgrade() { // Allow 0.1% margin of error. multiplicativeTolerance := osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.MustNewDecFromStr("0.001"), + MultiplicativeTolerance: osmomath.MustNewDecFromStr("0.001"), } testCases := []struct { @@ -114,17 +114,17 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // If LinkedClassicPool is specified, but it's smaller than the current pool ID, // create dummy pools to fill the gap. for lastPoolID+1 < poolID { - poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, sdk.NewInt(10000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, osmomath.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, osmomath.NewInt(10000000000))) suite.PrepareBalancerPoolWithCoins(poolCoins...) lastPoolID++ } // Now create the pool with the correct pool ID. - poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, sdk.NewInt(10000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, osmomath.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, osmomath.NewInt(10000000000))) suite.PrepareBalancerPoolWithCoins(poolCoins...) // 0.1 OSMO used to get the respective base asset amount, 0.1 OSMO used to create the position - osmoIn := sdk.NewCoin(v17.OSMO, sdk.NewInt(100000).MulRaw(2)) + osmoIn := sdk.NewCoin(v17.OSMO, osmomath.NewInt(100000).MulRaw(2)) // Add the amount of osmo that will be used to the expectedCoinsUsedInUpgradeHandler. expectedCoinsUsedInUpgradeHandler = expectedCoinsUsedInUpgradeHandler.Add(osmoIn) @@ -145,43 +145,43 @@ func (suite *UpgradeTestSuite) TestUpgrade() { existingPool := suite.PrepareConcentratedPoolWithCoins("ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo") existingPool2 := suite.PrepareConcentratedPoolWithCoins("akash", "uosmo") - existingBalancerPoolId := suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("atom", sdk.NewInt(10000000000)), sdk.NewCoin("uosmo", sdk.NewInt(10000000000))) + existingBalancerPoolId := suite.PrepareBalancerPoolWithCoins(sdk.NewCoin("atom", osmomath.NewInt(10000000000)), sdk.NewCoin("uosmo", osmomath.NewInt(10000000000))) // create few TWAP records for the pools - t1 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour*24), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", sdk.NewDec(10), - sdk.OneDec().MulInt64(10*10), - sdk.OneDec().MulInt64(3), - sdk.ZeroDec()) - - t2 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour*10), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", sdk.NewDec(30), - sdk.OneDec().MulInt64(10*10+10), - sdk.OneDec().MulInt64(5), - sdk.ZeroDec()) - - t3 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", sdk.NewDec(20), - sdk.OneDec().MulInt64(10*10+10*5), - sdk.OneDec().MulInt64(10), - sdk.ZeroDec()) - - t4 := dummyTwapRecord(existingPool2.GetId(), time.Now().Add(-time.Hour*24), "akash", "uosmo", sdk.NewDec(10), - sdk.OneDec().MulInt64(10*10*10), - sdk.OneDec().MulInt64(5), - sdk.ZeroDec()) - - t5 := dummyTwapRecord(existingPool2.GetId(), time.Now().Add(-time.Hour), "akash", "uosmo", sdk.NewDec(20), - sdk.OneDec().MulInt64(10), - sdk.OneDec().MulInt64(2), - sdk.ZeroDec()) - - t6 := dummyTwapRecord(existingBalancerPoolId, time.Now().Add(-time.Hour), "atom", "uosmo", sdk.NewDec(10), - sdk.OneDec().MulInt64(10), - sdk.OneDec().MulInt64(10), - sdk.ZeroDec()) - - t7 := dummyTwapRecord(existingBalancerPoolId, time.Now().Add(-time.Minute*20), "atom", "uosmo", sdk.NewDec(50), - sdk.OneDec().MulInt64(10*5), - sdk.OneDec().MulInt64(5), - sdk.ZeroDec()) + t1 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour*24), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", osmomath.NewDec(10), + osmomath.OneDec().MulInt64(10*10), + osmomath.OneDec().MulInt64(3), + osmomath.ZeroDec()) + + t2 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour*10), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", osmomath.NewDec(30), + osmomath.OneDec().MulInt64(10*10+10), + osmomath.OneDec().MulInt64(5), + osmomath.ZeroDec()) + + t3 := dummyTwapRecord(existingPool.GetId(), time.Now().Add(-time.Hour), "ibc/1480B8FD20AD5FCAE81EA87584D269547DD4D436843C1D20F15E00EB64743EF4", "uosmo", osmomath.NewDec(20), + osmomath.OneDec().MulInt64(10*10+10*5), + osmomath.OneDec().MulInt64(10), + osmomath.ZeroDec()) + + t4 := dummyTwapRecord(existingPool2.GetId(), time.Now().Add(-time.Hour*24), "akash", "uosmo", osmomath.NewDec(10), + osmomath.OneDec().MulInt64(10*10*10), + osmomath.OneDec().MulInt64(5), + osmomath.ZeroDec()) + + t5 := dummyTwapRecord(existingPool2.GetId(), time.Now().Add(-time.Hour), "akash", "uosmo", osmomath.NewDec(20), + osmomath.OneDec().MulInt64(10), + osmomath.OneDec().MulInt64(2), + osmomath.ZeroDec()) + + t6 := dummyTwapRecord(existingBalancerPoolId, time.Now().Add(-time.Hour), "atom", "uosmo", osmomath.NewDec(10), + osmomath.OneDec().MulInt64(10), + osmomath.OneDec().MulInt64(10), + osmomath.ZeroDec()) + + t7 := dummyTwapRecord(existingBalancerPoolId, time.Now().Add(-time.Minute*20), "atom", "uosmo", osmomath.NewDec(50), + osmomath.OneDec().MulInt64(10*5), + osmomath.OneDec().MulInt64(5), + osmomath.ZeroDec()) // store TWAP records suite.App.TwapKeeper.StoreNewRecord(suite.Ctx, t1) @@ -296,7 +296,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { suite.Require().Equal(assetPair.QuoteAsset, concentratedTypePool.GetToken1()) // Validate that the spot price of the CL pool is what we expect - suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromSDKDec(balancerSpotPrice))) + suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromDec(balancerSpotPrice))) // Validate that the link is correct. migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx) @@ -353,11 +353,11 @@ func (suite *UpgradeTestSuite) TestUpgrade() { // For testnet, we create a CL pool for ANY balancer pool. // The only thing we use the assetPair list here for to select some pools to enable superfluid for. for lastPoolID+1 < poolID { - poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, sdk.NewInt(10000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, osmomath.NewInt(10000000000)), sdk.NewCoin(assetPair.QuoteAsset, osmomath.NewInt(10000000000))) suite.PrepareBalancerPoolWithCoins(poolCoins...) // 0.1 OSMO used to get the respective base asset amount, 0.1 OSMO used to create the position - osmoIn := sdk.NewCoin(v17.OSMO, sdk.NewInt(100000).MulRaw(2)) + osmoIn := sdk.NewCoin(v17.OSMO, osmomath.NewInt(100000).MulRaw(2)) // Add the amount of osmo that will be used to the expectedCoinsUsedInUpgradeHandler. expectedCoinsUsedInUpgradeHandler = expectedCoinsUsedInUpgradeHandler.Add(osmoIn) @@ -463,7 +463,7 @@ func (suite *UpgradeTestSuite) TestUpgrade() { suite.Require().Equal(quoteAsset, concentratedTypePool.GetToken1()) // Validate that the spot price of the CL pool is what we expect - suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromSDKDec(balancerSpotPrice))) + suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(concentratedTypePool.GetCurrentSqrtPrice().PowerInteger(2), osmomath.BigDecFromDec(balancerSpotPrice))) // Validate that the link is correct. migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx) diff --git a/app/upgrades/v18/upgrades_test.go b/app/upgrades/v18/upgrades_test.go index e23d59ceb0c..4955d35b245 100644 --- a/app/upgrades/v18/upgrades_test.go +++ b/app/upgrades/v18/upgrades_test.go @@ -13,6 +13,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" v17 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v17" @@ -69,7 +70,7 @@ func (s *UpgradeTestSuite) TestUpgrade() { s.Require().NoError(err) // LP Fails before the upgrade - lpTokens := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), sdk.NewInt(1_000_000)), sdk.NewCoin(pool.GetToken1(), sdk.NewInt(1_000_000))) + lpTokens := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), osmomath.NewInt(1_000_000)), sdk.NewCoin(pool.GetToken1(), osmomath.NewInt(1_000_000))) s.FundAcc(s.TestAccs[0], lpTokens) // require a panic s.Require().Panics(func() { @@ -88,7 +89,7 @@ func (s *UpgradeTestSuite) TestUpgrade() { Denom: "gamm/pool/3", Duration: time.Hour * 24 * 14, }) - valueAfterClear.Equal(sdk.NewInt(shareStaysLocked)) + valueAfterClear.Equal(osmomath.NewInt(shareStaysLocked)) s.ensurePostUpgradeDistributionWorks() @@ -105,9 +106,9 @@ func (s *UpgradeTestSuite) TestUpgrade() { s.Require().NoError(err) // Swap - toSwap := sdk.NewCoin(pool.GetToken0(), sdk.NewInt(100)) + toSwap := sdk.NewCoin(pool.GetToken0(), osmomath.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()) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], updatedCLPool, toSwap, pool.GetToken1(), osmomath.NewInt(1), osmomath.ZeroDec()) s.Require().NoError(err) } @@ -139,13 +140,13 @@ func (suite *UpgradeTestSuite) setupPoolsToMainnetState() { // If LinkedClassicPool is specified, but it's smaller than the current pool ID, // create dummy pools to fill the gap. for lastPoolID+1 < poolID { - poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(100000000000)), sdk.NewCoin(assetPair.QuoteAsset, sdk.NewInt(100000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, osmomath.NewInt(100000000000)), sdk.NewCoin(assetPair.QuoteAsset, osmomath.NewInt(100000000000))) suite.PrepareBalancerPoolWithCoins(poolCoins...) lastPoolID++ } // Now create the pool with the correct pool ID. - poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, sdk.NewInt(100000000000)), sdk.NewCoin(assetPair.QuoteAsset, sdk.NewInt(100000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(assetPair.BaseAsset, osmomath.NewInt(100000000000)), sdk.NewCoin(assetPair.QuoteAsset, osmomath.NewInt(100000000000))) suite.PrepareBalancerPoolWithCoins(poolCoins...) // Enable the GAMM pool for superfluid if the record says so. @@ -174,13 +175,13 @@ func (s *UpgradeTestSuite) setupCorruptedState() { addr, err := sdk.AccAddressFromBech32("osmo1urn0pnx8fl5kt89r5nzqd8htruq7skadc2xdk3") s.Require().NoError(err) keepers := &s.App.AppKeepers - err = keepers.BankKeeper.MintCoins(s.Ctx, protorevtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(v17.OSMO, sdk.NewInt(50000000000)))) + err = keepers.BankKeeper.MintCoins(s.Ctx, protorevtypes.ModuleName, sdk.NewCoins(sdk.NewCoin(v17.OSMO, osmomath.NewInt(50000000000)))) s.Require().NoError(err) - err = keepers.BankKeeper.SendCoinsFromModuleToAccount(s.Ctx, protorevtypes.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(v17.OSMO, sdk.NewInt(50000000000)))) + err = keepers.BankKeeper.SendCoinsFromModuleToAccount(s.Ctx, protorevtypes.ModuleName, addr, sdk.NewCoins(sdk.NewCoin(v17.OSMO, osmomath.NewInt(50000000000)))) s.Require().NoError(err) aktGAMMPool, err := keepers.GAMMKeeper.GetPool(s.Ctx, 3) s.Require().NoError(err) - sharesOut, err := keepers.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, addr, aktGAMMPool.GetId(), sdk.NewCoins(sdk.NewCoin(v17.OSMO, sdk.NewInt(50000000000))), sdk.ZeroInt()) + sharesOut, err := keepers.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, addr, aktGAMMPool.GetId(), sdk.NewCoins(sdk.NewCoin(v17.OSMO, osmomath.NewInt(50000000000))), osmomath.ZeroInt()) s.Require().NoError(err) aktSharesDenom := fmt.Sprintf("gamm/pool/%d", aktGAMMPool.GetId()) shareCoins := sdk.NewCoins(sdk.NewCoin(aktSharesDenom, sharesOut)) @@ -189,7 +190,7 @@ func (s *UpgradeTestSuite) setupCorruptedState() { // also create a lock with the shares that would stay locked during the upgrade. // doing this would help us assert if the accumulator has been resetted to the correct value. - shareCoinsStaysLocked := sdk.NewCoins(sdk.NewCoin(aktSharesDenom, sdk.NewInt(shareStaysLocked))) + shareCoinsStaysLocked := sdk.NewCoins(sdk.NewCoin(aktSharesDenom, osmomath.NewInt(shareStaysLocked))) s.FundAcc(addr, shareCoinsStaysLocked) _, err = keepers.LockupKeeper.CreateLock(s.Ctx, addr, shareCoinsStaysLocked, time.Hour*24*14) s.Require().NoError(err) @@ -249,7 +250,7 @@ func (suite *UpgradeTestSuite) ensurePreUpgradeDistributionPanics() { suite.App.GAMMKeeper.SetMigrationRecords(suite.Ctx, migrationInfo) // add new coins to the CL pool gauge so that it would be distributed after epoch ends then trigger panic - coinsToAdd := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000))) + coinsToAdd := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000))) gagueId, err := suite.App.PoolIncentivesKeeper.GetPoolGaugeId(suite.Ctx, clPool.GetId(), epochInfo.Duration) gauge, err := suite.App.IncentivesKeeper.GetGaugeByID(suite.Ctx, gagueId) suite.Require().NoError(err) diff --git a/app/upgrades/v19/upgrades.go b/app/upgrades/v19/upgrades.go index 500ab3607d0..c82eb61adc6 100644 --- a/app/upgrades/v19/upgrades.go +++ b/app/upgrades/v19/upgrades.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/app/keepers" @@ -42,7 +43,7 @@ func CreateUpgradeHandler( currentConcentratedLiquidityParams := keepers.ConcentratedLiquidityKeeper.GetParams(ctx) defaultPoolManagerParams := poolmanagertypes.DefaultParams() defaultPoolManagerParams.AuthorizedQuoteDenoms = currentConcentratedLiquidityParams.AuthorizedQuoteDenoms - defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = sdk.ZeroDec() + defaultPoolManagerParams.TakerFeeParams.DefaultTakerFee = osmomath.ZeroDec() keepers.PoolManagerKeeper.SetParams(ctx, defaultPoolManagerParams) return migrations, nil diff --git a/app/upgrades/v19/upgrades_test.go b/app/upgrades/v19/upgrades_test.go index cae60502154..43217facb1b 100644 --- a/app/upgrades/v19/upgrades_test.go +++ b/app/upgrades/v19/upgrades_test.go @@ -13,6 +13,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -26,7 +27,7 @@ const ( ) var ( - stakeAmt = sdk.NewInt(100000000) + stakeAmt = osmomath.NewInt(100000000) ) type UpgradeTestSuite struct { @@ -42,7 +43,7 @@ func TestUpgradeTestSuite(t *testing.T) { } func (s *UpgradeTestSuite) TestUpgrade() { - initialTokenBonded := sdk.NewInt(100) + initialTokenBonded := osmomath.NewInt(100) s.Setup() // prepare superfluid delegation @@ -64,7 +65,7 @@ func (s *UpgradeTestSuite) TestUpgrade() { // broken states (current status): // synth lock accumulator is set to 0 totalSynthLocked := s.App.SuperfluidKeeper.GetTotalSyntheticAssetsLocked(s.Ctx, stakingSyntheticDenom(lockDenom, superfluidVal.String())) - s.Require().True(totalSynthLocked.Equal(sdk.ZeroInt())) + s.Require().True(totalSynthLocked.Equal(osmomath.ZeroInt())) // superfluid delegated tokens have been undelegated from validator, // only have the initial bonded amount present @@ -105,7 +106,7 @@ func (s *UpgradeTestSuite) setupSuperfluidDelegation() (val sdk.ValAddress, lock superfluidVal := s.SetupValidator(stakingtypes.Bonded) // create single pool with bond denom - pools := s.SetupGammPoolsWithBondDenomMultiplier([]sdk.Dec{sdk.NewDec(20)}) + pools := s.SetupGammPoolsWithBondDenomMultiplier([]osmomath.Dec{osmomath.NewDec(20)}) // we only created one pool, we will use this pool for all the continued tests pool := pools[0] diff --git a/app/upgrades/v3/forks.go b/app/upgrades/v3/forks.go index 512f1b2dc3c..04e6ee62514 100644 --- a/app/upgrades/v3/forks.go +++ b/app/upgrades/v3/forks.go @@ -5,6 +5,7 @@ import ( govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/keepers" ) @@ -22,7 +23,7 @@ func RunForkLogic(ctx sdk.Context, keepers *keepers.AppKeepers) { // not exist, which makes it impossible for a proposal to go to a vote. func FixMinDepositDenom(ctx sdk.Context, gov *govkeeper.Keeper) { params := gov.GetDepositParams(ctx) - params.MinDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(500000000))) + params.MinDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(500000000))) gov.SetDepositParams(ctx, params) } diff --git a/app/upgrades/v4/upgrade_test.go b/app/upgrades/v4/upgrade_test.go index 8147073383a..d15075f1b5f 100644 --- a/app/upgrades/v4/upgrade_test.go +++ b/app/upgrades/v4/upgrade_test.go @@ -111,7 +111,7 @@ func (suite *UpgradeTestSuite) TestUpgradePayments() { // Kept as comments for recordkeeping. Since SetParams is now private, the changes being tested for can no longer be made: // gammParams := suite.app.GAMMKeeper.GetParams(suite.ctx) - // expectedCreationFee := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.OneInt())) + // expectedCreationFee := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.OneInt())) // suite.Require().Equal(gammParams.PoolCreationFee, expectedCreationFee) }, true, diff --git a/app/upgrades/v8/incentive_props.go b/app/upgrades/v8/incentive_props.go index 025c1514aec..7e746a616bb 100644 --- a/app/upgrades/v8/incentive_props.go +++ b/app/upgrades/v8/incentive_props.go @@ -3,6 +3,7 @@ package v8 import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" poolincentiveskeeper "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/keeper" poolincentivestypes "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" @@ -47,12 +48,12 @@ func ApplyProp222Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskee // weight: "3655248" // _PLEASE_ double check these numbers, and double the check the proposals choice itself records := []poolincentivestypes.DistrRecord{ - {GaugeId: 1718, Weight: sdk.NewInt(9138119)}, - {GaugeId: 1719, Weight: sdk.NewInt(5482871)}, - {GaugeId: 1720, Weight: sdk.NewInt(3655247)}, - {GaugeId: 2965, Weight: sdk.NewInt(9138119)}, - {GaugeId: 2966, Weight: sdk.NewInt(5482872)}, - {GaugeId: 2967, Weight: sdk.NewInt(3655248)}, + {GaugeId: 1718, Weight: osmomath.NewInt(9138119)}, + {GaugeId: 1719, Weight: osmomath.NewInt(5482871)}, + {GaugeId: 1720, Weight: osmomath.NewInt(3655247)}, + {GaugeId: 2965, Weight: osmomath.NewInt(9138119)}, + {GaugeId: 2966, Weight: osmomath.NewInt(5482872)}, + {GaugeId: 2967, Weight: osmomath.NewInt(3655248)}, } ctx.Logger().Info("Applying proposal 222 update") @@ -79,12 +80,12 @@ func ApplyProp223Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskee // _PLEASE_ double check these numbers, and double the check the proposals choice itself records := []poolincentivestypes.DistrRecord{ - {GaugeId: 1721, Weight: sdk.NewInt(2831977)}, - {GaugeId: 1722, Weight: sdk.NewInt(1699186)}, - {GaugeId: 1723, Weight: sdk.NewInt(1132791)}, - {GaugeId: 3383, Weight: sdk.NewInt(2831978)}, - {GaugeId: 3384, Weight: sdk.NewInt(1699187)}, - {GaugeId: 3385, Weight: sdk.NewInt(1132791)}, + {GaugeId: 1721, Weight: osmomath.NewInt(2831977)}, + {GaugeId: 1722, Weight: osmomath.NewInt(1699186)}, + {GaugeId: 1723, Weight: osmomath.NewInt(1132791)}, + {GaugeId: 3383, Weight: osmomath.NewInt(2831978)}, + {GaugeId: 3384, Weight: osmomath.NewInt(1699187)}, + {GaugeId: 3385, Weight: osmomath.NewInt(1132791)}, } ctx.Logger().Info("Applying proposal 223 update") @@ -110,12 +111,12 @@ func ApplyProp224Change(ctx sdk.Context, poolincentiveskeeper *poolincentiveskee // weight: "752464" // _PLEASE_ double check these numbers, and double the check the proposals choice itself records := []poolincentivestypes.DistrRecord{ - {GaugeId: 1724, Weight: sdk.NewInt(1881159)}, - {GaugeId: 1725, Weight: sdk.NewInt(1128695)}, - {GaugeId: 1726, Weight: sdk.NewInt(752463)}, - {GaugeId: 2949, Weight: sdk.NewInt(1881160)}, - {GaugeId: 2950, Weight: sdk.NewInt(1128696)}, - {GaugeId: 2951, Weight: sdk.NewInt(752464)}, + {GaugeId: 1724, Weight: osmomath.NewInt(1881159)}, + {GaugeId: 1725, Weight: osmomath.NewInt(1128695)}, + {GaugeId: 1726, Weight: osmomath.NewInt(752463)}, + {GaugeId: 2949, Weight: osmomath.NewInt(1881160)}, + {GaugeId: 2950, Weight: osmomath.NewInt(1128696)}, + {GaugeId: 2951, Weight: osmomath.NewInt(752464)}, } ctx.Logger().Info("Applying proposal 224 update") diff --git a/app/upgrades/v9/prop214.go b/app/upgrades/v9/prop214.go index e4b5a5ffec6..e31fbfb34b1 100644 --- a/app/upgrades/v9/prop214.go +++ b/app/upgrades/v9/prop214.go @@ -3,6 +3,7 @@ package v9 import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" gammkeeper "github.com/osmosis-labs/osmosis/v19/x/gamm/keeper" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" ) @@ -23,7 +24,7 @@ func ExecuteProp214(ctx sdk.Context, gamm *gammkeeper.Keeper) { panic(ok) } - balancerPool.PoolParams.SwapFee = sdk.MustNewDecFromStr("0.002") + balancerPool.PoolParams.SwapFee = osmomath.MustNewDecFromStr("0.002") // Kept as comments for recordkeeping. SetPool is now private: // err = gamm.SetPool(ctx, balancerPool) diff --git a/app/upgrades/v9/prop214_test.go b/app/upgrades/v9/prop214_test.go index b56810bb109..f9780c78382 100644 --- a/app/upgrades/v9/prop214_test.go +++ b/app/upgrades/v9/prop214_test.go @@ -30,7 +30,7 @@ func (suite *UpgradeTestSuite) TestProp214() { // Kept as comments for recordkeeping. Since SetPool is now private, the changes being tested for can no longer be made: // spreadFactor := pool.GetSpreadFactor(suite.Ctx) - // expectedSpreadFactor := sdk.MustNewDecFromStr("0.002") + // expectedSpreadFactor := osmomath.MustNewDecFromStr("0.002") // // suite.Require().Equal(expectedSpreadFactor, spreadFactor) } diff --git a/cmd/osmosisd/cmd/airdrop.go.history b/cmd/osmosisd/cmd/airdrop.go.history index d11859ebe4c..e640a83ba0c 100644 --- a/cmd/osmosisd/cmd/airdrop.go.history +++ b/cmd/osmosisd/cmd/airdrop.go.history @@ -29,8 +29,8 @@ type AppStateV036 struct { } type Snapshot struct { - TotalAtomAmount sdk.Int `json:"total_atom_amount"` - TotalOsmosAirdropAmount sdk.Int `json:"total_osmo_amount"` + TotalAtomAmount osmomath.Int `json:"total_atom_amount"` + TotalOsmosAirdropAmount osmomath.Int `json:"total_osmo_amount"` NumberAccounts uint64 `json:"num_accounts"` Accounts map[string]SnapshotAccount `json:"accounts"` @@ -40,17 +40,17 @@ type Snapshot struct { type SnapshotAccount struct { AtomAddress string `json:"atom_address"` // Atom Balance = AtomStakedBalance + AtomUnstakedBalance - AtomBalance sdk.Int `json:"atom_balance"` - AtomOwnershipPercent sdk.Dec `json:"atom_ownership_percent"` + AtomBalance osmomath.Int `json:"atom_balance"` + AtomOwnershipPercent osmomath.Dec `json:"atom_ownership_percent"` - AtomStakedBalance sdk.Int `json:"atom_staked_balance"` - AtomUnstakedBalance sdk.Int `json:"atom_unstaked_balance"` // AtomStakedPercent = AtomStakedBalance / AtomBalance - AtomStakedPercent sdk.Dec `json:"atom_staked_percent"` + AtomStakedBalance osmomath.Int `json:"atom_staked_balance"` + AtomUnstakedBalance osmomath.Int `json:"atom_unstaked_balance"` // AtomStakedPercent = AtomStakedBalance / AtomBalance + AtomStakedPercent osmomath.Dec `json:"atom_staked_percent"` - OsmoBalance sdk.Int `json:"osmo_balance"` // OsmoBalance = sqrt( AtomBalance ) * (1 + 1.5 * atom staked percent) - OsmoBalanceBase sdk.Int `json:"osmo_balance_base"` // OsmoBalanceBase = sqrt(atom balance) - OsmoBalanceBonus sdk.Int `json:"osmo_balance_bonus"` // OsmoBalanceBonus = OsmoBalanceBase * (1.5 * atom staked percent) - OsmoPercent sdk.Dec `json:"osmo_ownership_percent"` // OsmoPercent = OsmoNormalizedBalance / TotalOsmoSupply + OsmoBalance osmomath.Int `json:"osmo_balance"` // OsmoBalance = sqrt( AtomBalance ) * (1 + 1.5 * atom staked percent) + OsmoBalanceBase osmomath.Int `json:"osmo_balance_base"` // OsmoBalanceBase = sqrt(atom balance) + OsmoBalanceBonus osmomath.Int `json:"osmo_balance_bonus"` // OsmoBalanceBonus = OsmoBalanceBase * (1.5 * atom staked percent) + OsmoPercent osmomath.Dec `json:"osmo_ownership_percent"` // OsmoPercent = OsmoNormalizedBalance / TotalOsmoSupply } // setCosmosBech32Prefixes set config for cosmos address system @@ -111,7 +111,7 @@ Example: // Produce the map of address to total atom balance, both staked and unstaked snapshotAccs := make(map[string]SnapshotAccount) - totalAtomBalance := sdk.NewInt(0) + totalAtomBalance := osmomath.NewInt(0) for _, account := range genStateV036.AppState.Accounts { balance := account.Coins.AmountOf(denom) @@ -125,7 +125,7 @@ Example: AtomAddress: account.Address.String(), AtomBalance: balance, AtomUnstakedBalance: balance, - AtomStakedBalance: sdk.ZeroInt(), + AtomStakedBalance: osmomath.ZeroInt(), } } @@ -136,7 +136,7 @@ Example: panic("no account found for unbonding") } - unbondingAtoms := sdk.NewInt(0) + unbondingAtoms := osmomath.NewInt(0) for _, entry := range unbonding.Entries { unbondingAtoms = unbondingAtoms.Add(entry.Balance) } @@ -170,24 +170,24 @@ Example: snapshotAccs[address] = acc } - totalOsmoBalance := sdk.NewInt(0) - onePointFive := sdk.MustNewDecFromStr("1.5") + totalOsmoBalance := osmomath.NewInt(0) + onePointFive := osmomath.MustNewDecFromStr("1.5") for address, acc := range snapshotAccs { - allAtoms := acc.AtomBalance.ToDec() + allAtoms := acc.AtomBalance.ToLegacyDec() acc.AtomOwnershipPercent = allAtoms.QuoInt(totalAtomBalance) if allAtoms.IsZero() { - acc.AtomStakedPercent = sdk.ZeroDec() - acc.OsmoBalanceBase = sdk.ZeroInt() - acc.OsmoBalanceBonus = sdk.ZeroInt() - acc.OsmoBalance = sdk.ZeroInt() + acc.AtomStakedPercent = osmomath.ZeroDec() + acc.OsmoBalanceBase = osmomath.ZeroInt() + acc.OsmoBalanceBonus = osmomath.ZeroInt() + acc.OsmoBalance = osmomath.ZeroInt() snapshotAccs[address] = acc continue } - stakedAtoms := acc.AtomStakedBalance.ToDec() + stakedAtoms := acc.AtomStakedBalance.ToLegacyDec() stakedPercent := stakedAtoms.Quo(allAtoms) acc.AtomStakedPercent = stakedPercent @@ -204,10 +204,10 @@ Example: // OsmoBalance = sqrt( all atoms) * (1 + 1.5) * (staked atom percent) = acc.OsmoBalance = allOsmo.RoundInt() - if allAtoms.LTE(sdk.NewDec(1000000)) { - acc.OsmoBalanceBase = sdk.ZeroInt() - acc.OsmoBalanceBonus = sdk.ZeroInt() - acc.OsmoBalance = sdk.ZeroInt() + if allAtoms.LTE(osmomath.NewDec(1000000)) { + acc.OsmoBalanceBase = osmomath.ZeroInt() + acc.OsmoBalanceBonus = osmomath.ZeroInt() + acc.OsmoBalance = osmomath.ZeroInt() } totalOsmoBalance = totalOsmoBalance.Add(acc.OsmoBalance) @@ -217,7 +217,7 @@ Example: // iterate to find Osmo ownership percentage per account for address, acc := range snapshotAccs { - acc.OsmoPercent = acc.OsmoBalance.ToDec().Quo(totalOsmoBalance.ToDec()) + acc.OsmoPercent = acc.OsmoBalance.ToLegacyDec().Quo(totalOsmoBalance.ToLegacyDec()) snapshotAccs[address] = acc } diff --git a/cmd/osmosisd/cmd/balances_from_state_export.go b/cmd/osmosisd/cmd/balances_from_state_export.go index e7ef1de637c..6a6dd5a5b50 100644 --- a/cmd/osmosisd/cmd/balances_from_state_export.go +++ b/cmd/osmosisd/cmd/balances_from_state_export.go @@ -12,6 +12,7 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" appparams "github.com/osmosis-labs/osmosis/v19/app/params" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -40,8 +41,8 @@ type DerivedAccount struct { // TODO: Consider removing this, since duplicated Address string `json:"address"` LiquidBalances sdk.Coins `json:"liquid_balance"` - Staked sdk.Int `json:"staked"` - UnbondingStake sdk.Int `json:"unbonding_stake"` + Staked osmomath.Int `json:"staked"` + UnbondingStake osmomath.Int `json:"unbonding_stake"` Bonded sdk.Coins `json:"bonded"` BondedBySelectPools map[uint64]sdk.Coins `json:"bonded_by_select_pools"` TotalBalances sdk.Coins `json:"total_balances"` @@ -52,8 +53,8 @@ func newDerivedAccount(address string) DerivedAccount { return DerivedAccount{ Address: address, LiquidBalances: sdk.Coins{}, - Staked: sdk.ZeroInt(), - UnbondingStake: sdk.ZeroInt(), + Staked: osmomath.ZeroInt(), + UnbondingStake: osmomath.ZeroInt(), Bonded: sdk.Coins{}, } } @@ -211,7 +212,7 @@ Example: acc = newDerivedAccount(address) } - unbondingOsmos := sdk.NewInt(0) + unbondingOsmos := osmomath.NewInt(0) for _, entry := range unbonding.Entries { unbondingOsmos = unbondingOsmos.Add(entry.Balance) } @@ -371,7 +372,7 @@ Example: // iterate through all accounts, leave out accounts that do not meet the user provided min stake amount for _, r := range deriveSnapshot.Accounts { var csvRow []string - if r.Staked.GT(sdk.NewInt(minStakeAmount)) { + if r.Staked.GT(osmomath.NewInt(minStakeAmount)) { csvRow = append(csvRow, r.Address, r.Staked.String()) if err := writer.Write(csvRow); err != nil { return err diff --git a/cmd/osmosisd/cmd/genaccounts.go b/cmd/osmosisd/cmd/genaccounts.go index 4187c274438..0c27e1c8ddb 100644 --- a/cmd/osmosisd/cmd/genaccounts.go +++ b/cmd/osmosisd/cmd/genaccounts.go @@ -255,7 +255,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa // } // for _, acc := range snapshot.Accounts { -// if !acc.OsmoBalance.Equal(sdk.ZeroInt()) { +// if !acc.OsmoBalance.Equal(osmomath.ZeroInt()) { // osmoAddr, err := CosmosToOsmoAddress(acc.AtomAddress) // if err != nil { // return err @@ -362,21 +362,21 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa // } // if val, ok := nonAirdropAccs[address]; ok { -// nonAirdropAccs[address] = val.Add(sdk.NewCoin("uion", sdk.NewInt(amt).MulRaw(1_000_000))) +// nonAirdropAccs[address] = val.Add(sdk.NewCoin("uion", osmomath.NewInt(amt).MulRaw(1_000_000))) // } else { -// nonAirdropAccs[address] = sdk.NewCoins(sdk.NewCoin("uion", sdk.NewInt(amt).MulRaw(1_000_000))) +// nonAirdropAccs[address] = sdk.NewCoins(sdk.NewCoin("uion", osmomath.NewInt(amt).MulRaw(1_000_000))) // } // } // // figure out normalizationFactor to normalize snapshot balances to desired airdrop supply -// normalizationFactor := genesisParams.AirdropSupply.ToDec().QuoInt(snapshot.TotalOsmosAirdropAmount) +// normalizationFactor := genesisParams.AirdropSupply.ToLegacyDec().QuoInt(snapshot.TotalOsmosAirdropAmount) // fmt.Printf("normalization factor: %s\n", normalizationFactor) // bankGenState := banktypes.GetGenesisStateFromAppState(cdc, appState) // liquidBalances := bankGenState.Balances // claimRecords := []claimtypes.ClaimRecord{} -// claimModuleAccountBalance := sdk.NewInt(0) +// claimModuleAccountBalance := osmomath.NewInt(0) // // for each account in the snapshot // for _, acc := range snapshot.Accounts { @@ -392,11 +392,11 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa // } // // get normalized osmo balance for account -// normalizedOsmoBalance := acc.OsmoBalance.ToDec().Mul(normalizationFactor) +// normalizedOsmoBalance := acc.OsmoBalance.ToLegacyDec().Mul(normalizationFactor) // // initial liquid amounts // // We consistently round down to the nearest uosmo -// liquidAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.2")).TruncateInt() // 20% of airdrop amount +// liquidAmount := normalizedOsmoBalance.Mul(osmomath.MustNewDecFromStr("0.2")).TruncateInt() // 20% of airdrop amount // liquidCoins := sdk.NewCoins(sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, liquidAmount)) // if coins, ok := nonAirdropAccs[address]; ok { @@ -410,7 +410,7 @@ contain valid denominations. Accounts may optionally be supplied with vesting pa // }) // // claimable balances -// claimableAmount := normalizedOsmoBalance.Mul(sdk.MustNewDecFromStr("0.8")).TruncateInt() +// claimableAmount := normalizedOsmoBalance.Mul(osmomath.MustNewDecFromStr("0.8")).TruncateInt() // claimRecords = append(claimRecords, claimtypes.ClaimRecord{ // Address: address, diff --git a/cmd/osmosisd/cmd/genesis.go b/cmd/osmosisd/cmd/genesis.go index 1d7fc88bb33..48cedf3ce28 100644 --- a/cmd/osmosisd/cmd/genesis.go +++ b/cmd/osmosisd/cmd/genesis.go @@ -25,6 +25,7 @@ import ( slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" appParams "github.com/osmosis-labs/osmosis/v19/app/params" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -211,7 +212,7 @@ func PrepareGenesis(clientCtx client.Context, appState map[string]json.RawMessag } type GenesisParams struct { - AirdropSupply sdk.Int + AirdropSupply osmomath.Int StrategicReserveAccounts []banktypes.Balance @@ -238,7 +239,7 @@ type GenesisParams struct { func MainnetGenesisParams() GenesisParams { genParams := GenesisParams{} - genParams.AirdropSupply = sdk.NewIntWithDecimal(5, 13) // 5*10^13 uosmo, 5*10^7 (50 million) osmo + genParams.AirdropSupply = osmomath.NewIntWithDecimal(5, 13) // 5*10^13 uosmo, 5*10^7 (50 million) osmo genParams.GenesisTime = time.Date(2021, 6, 18, 17, 0, 0, 0, time.UTC) // Jun 18, 2021 - 17:00 UTC genParams.NativeCoinMetadatas = []banktypes.Metadata{ @@ -280,91 +281,91 @@ func MainnetGenesisParams() GenesisParams { genParams.StrategicReserveAccounts = []banktypes.Balance{ { Address: "osmo1el3aytvehpvxw2ymmya4kdyj9yndyy47fw5zh4", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(47_874_500_000_000))), // 47.8745 million OSMO + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(47_874_500_000_000))), // 47.8745 million OSMO }, { Address: "osmo1g7rp8h6wzekjjy8n6my8za3vg3338eqz3v295v", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(500_000_000_000))), // 500 thousand OSMO + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(500_000_000_000))), // 500 thousand OSMO }, { Address: "osmo1z7ql0vcjlznrruw3hwgm043w8yhzqmtpu5rlp9", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000_000))), // 1 million OSMO + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(1_000_000_000_000))), // 1 million OSMO }, { Address: "osmo1grgelyng2v6v3t8z87wu3sxgt9m5s03xytvfcl", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1yuz4fct5cc3td6fp7he055mut0d4ukcsvlgpkg", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1epr7gp5gf9ftkduzlkckmehqk9dyn063xref53", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1enu76xfqkadu022hkdg7rwyc4pqq6jzn3zy395", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1njvfq5pdad2f5j0uvqtfdujyg8c5sde2n6yw2t", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1gaajper2qphnk6rnpy8zjhhg2kstnd87sh36hx", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(25_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(25_000_000_000))), }, { Address: "osmo1xl6r0n34mq0z7gfx7w2qf3f2vq70g5ph7n78hs", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo13stzqk27y46cr8fz7vfr8dsqqk4wpz90fqmc23", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo12wmptq2zm3s2d8c0xukwj3fkcl0qw66wmxwr7x", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(25_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(25_000_000_000))), }, { Address: "osmo1qc74lw7f8ak737jy2at36wa9tyrgldk8kpskzg", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(5_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(5_000_000_000))), }, { Address: "osmo1m3lvlydlu3mqv7z9xgtqjplcx20yc3lmx3p73e", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(10_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(10_000_000_000))), }, { Address: "osmo14u94qvqqdyjruufc08m6rwq8yz3ukurkzkvczx", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(7_500_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(7_500_000_000))), }, { Address: "osmo15t8y5mzdmz54fcj2wq3qutgtharuxdg7zu9q98", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1ngt8m8722qxcgdpqjwe3ggwcpg6zns8axpxtt0", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo17ncgp84x5vmphdlaaktzp7hljh3mhysqw9up3u", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo16n7070n4whce0wlu76j42dyrxh9f7nlapg6c4a", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(50_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(50_000_000_000))), }, { Address: "osmo1vnyc6q49sr0hs9ddjepcmtlaq3l6wwj0rrw6hd", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(1_000_000_000))), }, { Address: "osmo1ujx3rqerqdksnxnjka2n9tde874mzut75hzx92", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(1_000_000_000))), }, { Address: "osmo1a2r7nqnc9e032wj37ptskh207e232462vcrrjf", - Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, sdk.NewInt(1_000_000_000))), + Coins: sdk.NewCoins(sdk.NewCoin(genParams.NativeCoinMetadatas[0].Base, osmomath.NewInt(1_000_000_000))), }, } @@ -372,110 +373,110 @@ func MainnetGenesisParams() GenesisParams { genParams.StakingParams.UnbondingTime = time.Hour * 24 * 7 * 2 // 2 weeks genParams.StakingParams.MaxValidators = 100 genParams.StakingParams.BondDenom = genParams.NativeCoinMetadatas[0].Base - genParams.StakingParams.MinCommissionRate = sdk.MustNewDecFromStr("0.05") + genParams.StakingParams.MinCommissionRate = osmomath.MustNewDecFromStr("0.05") genParams.MintParams = minttypes.DefaultParams() - genParams.MintParams.EpochIdentifier = "day" // 1 day - genParams.MintParams.GenesisEpochProvisions = sdk.NewDec(300_000_000_000_000).QuoInt64(365) // 300M * 10^6 / 365 = ~821917.8082191781 * 10^6 + genParams.MintParams.EpochIdentifier = "day" // 1 day + genParams.MintParams.GenesisEpochProvisions = osmomath.NewDec(300_000_000_000_000).QuoInt64(365) // 300M * 10^6 / 365 = ~821917.8082191781 * 10^6 genParams.MintParams.MintDenom = genParams.NativeCoinMetadatas[0].Base - genParams.MintParams.ReductionFactor = sdk.NewDec(2).QuoInt64(3) // 2/3 - genParams.MintParams.ReductionPeriodInEpochs = 365 // 1 year (screw leap years) + genParams.MintParams.ReductionFactor = osmomath.NewDec(2).QuoInt64(3) // 2/3 + genParams.MintParams.ReductionPeriodInEpochs = 365 // 1 year (screw leap years) genParams.MintParams.DistributionProportions = minttypes.DistributionProportions{ - Staking: sdk.MustNewDecFromStr("0.25"), // 25% - DeveloperRewards: sdk.MustNewDecFromStr("0.25"), // 25% - PoolIncentives: sdk.MustNewDecFromStr("0.45"), // 45% - CommunityPool: sdk.MustNewDecFromStr("0.05"), // 5% + Staking: osmomath.MustNewDecFromStr("0.25"), // 25% + DeveloperRewards: osmomath.MustNewDecFromStr("0.25"), // 25% + PoolIncentives: osmomath.MustNewDecFromStr("0.45"), // 45% + CommunityPool: osmomath.MustNewDecFromStr("0.05"), // 5% } genParams.MintParams.MintingRewardsDistributionStartEpoch = 1 genParams.MintParams.WeightedDeveloperRewardsReceivers = []minttypes.WeightedAddress{ { Address: "osmo14kjcwdwcqsujkdt8n5qwpd8x8ty2rys5rjrdjj", - Weight: sdk.MustNewDecFromStr("0.2887"), + Weight: osmomath.MustNewDecFromStr("0.2887"), }, { Address: "osmo1gw445ta0aqn26suz2rg3tkqfpxnq2hs224d7gq", - Weight: sdk.MustNewDecFromStr("0.2290"), + Weight: osmomath.MustNewDecFromStr("0.2290"), }, { Address: "osmo13lt0hzc6u3htsk7z5rs6vuurmgg4hh2ecgxqkf", - Weight: sdk.MustNewDecFromStr("0.1625"), + Weight: osmomath.MustNewDecFromStr("0.1625"), }, { Address: "osmo1kvc3he93ygc0us3ycslwlv2gdqry4ta73vk9hu", - Weight: sdk.MustNewDecFromStr("0.109"), + Weight: osmomath.MustNewDecFromStr("0.109"), }, { Address: "osmo19qgldlsk7hdv3ddtwwpvzff30pxqe9phq9evxf", - Weight: sdk.MustNewDecFromStr("0.0995"), + Weight: osmomath.MustNewDecFromStr("0.0995"), }, { Address: "osmo19fs55cx4594een7qr8tglrjtt5h9jrxg458htd", - Weight: sdk.MustNewDecFromStr("0.06"), + Weight: osmomath.MustNewDecFromStr("0.06"), }, { Address: "osmo1ssp6px3fs3kwreles3ft6c07mfvj89a544yj9k", - Weight: sdk.MustNewDecFromStr("0.015"), + Weight: osmomath.MustNewDecFromStr("0.015"), }, { Address: "osmo1c5yu8498yzqte9cmfv5zcgtl07lhpjrj0skqdx", - Weight: sdk.MustNewDecFromStr("0.01"), + Weight: osmomath.MustNewDecFromStr("0.01"), }, { Address: "osmo1yhj3r9t9vw7qgeg22cehfzj7enwgklw5k5v7lj", - Weight: sdk.MustNewDecFromStr("0.0075"), + Weight: osmomath.MustNewDecFromStr("0.0075"), }, { Address: "osmo18nzmtyn5vy5y45dmcdnta8askldyvehx66lqgm", - Weight: sdk.MustNewDecFromStr("0.007"), + Weight: osmomath.MustNewDecFromStr("0.007"), }, { Address: "osmo1z2x9z58cg96ujvhvu6ga07yv9edq2mvkxpgwmc", - Weight: sdk.MustNewDecFromStr("0.005"), + Weight: osmomath.MustNewDecFromStr("0.005"), }, { Address: "osmo1tvf3373skua8e6480eyy38avv8mw3hnt8jcxg9", - Weight: sdk.MustNewDecFromStr("0.0025"), + Weight: osmomath.MustNewDecFromStr("0.0025"), }, { Address: "osmo1zs0txy03pv5crj2rvty8wemd3zhrka2ne8u05n", - Weight: sdk.MustNewDecFromStr("0.0025"), + Weight: osmomath.MustNewDecFromStr("0.0025"), }, { Address: "osmo1djgf9p53n7m5a55hcn6gg0cm5mue4r5g3fadee", - Weight: sdk.MustNewDecFromStr("0.001"), + Weight: osmomath.MustNewDecFromStr("0.001"), }, { Address: "osmo1488zldkrn8xcjh3z40v2mexq7d088qkna8ceze", - Weight: sdk.MustNewDecFromStr("0.0008"), + Weight: osmomath.MustNewDecFromStr("0.0008"), }, } genParams.DistributionParams = distributiontypes.DefaultParams() - genParams.DistributionParams.BaseProposerReward = sdk.MustNewDecFromStr("0.01") - genParams.DistributionParams.BonusProposerReward = sdk.MustNewDecFromStr("0.04") - genParams.DistributionParams.CommunityTax = sdk.MustNewDecFromStr("0") + genParams.DistributionParams.BaseProposerReward = osmomath.MustNewDecFromStr("0.01") + genParams.DistributionParams.BonusProposerReward = osmomath.MustNewDecFromStr("0.04") + genParams.DistributionParams.CommunityTax = osmomath.MustNewDecFromStr("0") genParams.DistributionParams.WithdrawAddrEnabled = true genParams.GovParams = govtypes.DefaultParams() genParams.GovParams.DepositParams.MaxDepositPeriod = time.Hour * 24 * 14 // 2 weeks genParams.GovParams.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin( genParams.NativeCoinMetadatas[0].Base, - sdk.NewInt(2_500_000_000), + osmomath.NewInt(2_500_000_000), )) - genParams.GovParams.TallyParams.Quorum = sdk.MustNewDecFromStr("0.2") // 20% - genParams.GovParams.VotingParams.VotingPeriod = time.Hour * 24 * 3 // 3 days + genParams.GovParams.TallyParams.Quorum = osmomath.MustNewDecFromStr("0.2") // 20% + genParams.GovParams.VotingParams.VotingPeriod = time.Hour * 24 * 3 // 3 days genParams.CrisisConstantFee = sdk.NewCoin( genParams.NativeCoinMetadatas[0].Base, - sdk.NewInt(500_000_000_000), + osmomath.NewInt(500_000_000_000), ) genParams.SlashingParams = slashingtypes.DefaultParams() - genParams.SlashingParams.SignedBlocksWindow = int64(30000) // 30000 blocks (~41 hr at 5 second blocks) - genParams.SlashingParams.MinSignedPerWindow = sdk.MustNewDecFromStr("0.05") // 5% minimum liveness - genParams.SlashingParams.DowntimeJailDuration = time.Minute // 1 minute jail period - genParams.SlashingParams.SlashFractionDoubleSign = sdk.MustNewDecFromStr("0.05") // 5% double sign slashing - genParams.SlashingParams.SlashFractionDowntime = sdk.ZeroDec() // 0% liveness slashing + genParams.SlashingParams.SignedBlocksWindow = int64(30000) // 30000 blocks (~41 hr at 5 second blocks) + genParams.SlashingParams.MinSignedPerWindow = osmomath.MustNewDecFromStr("0.05") // 5% minimum liveness + genParams.SlashingParams.DowntimeJailDuration = time.Minute // 1 minute jail period + genParams.SlashingParams.SlashFractionDoubleSign = osmomath.MustNewDecFromStr("0.05") // 5% double sign slashing + genParams.SlashingParams.SlashFractionDowntime = osmomath.ZeroDec() // 0% liveness slashing genParams.Epochs = epochstypes.DefaultGenesis().Epochs for _, epoch := range genParams.Epochs { @@ -501,11 +502,11 @@ func MainnetGenesisParams() GenesisParams { genParams.PoolIncentivesGenesis.Params.MintedDenom = genParams.NativeCoinMetadatas[0].Base genParams.PoolIncentivesGenesis.LockableDurations = genParams.IncentivesGenesis.LockableDurations genParams.PoolIncentivesGenesis.DistrInfo = &poolincentivestypes.DistrInfo{ - TotalWeight: sdk.NewInt(1000), + TotalWeight: osmomath.NewInt(1000), Records: []poolincentivestypes.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, } @@ -538,10 +539,10 @@ func TestnetGenesisParams() GenesisParams { genParams.GovParams.DepositParams.MinDeposit = sdk.NewCoins(sdk.NewCoin( genParams.NativeCoinMetadatas[0].Base, - sdk.NewInt(1000000), // 1 OSMO + osmomath.NewInt(1000000), // 1 OSMO )) - genParams.GovParams.TallyParams.Quorum = sdk.MustNewDecFromStr("0.0000000001") // 0.00000001% - genParams.GovParams.VotingParams.VotingPeriod = time.Second * 300 // 300 seconds + genParams.GovParams.TallyParams.Quorum = osmomath.MustNewDecFromStr("0.0000000001") // 0.00000001% + genParams.GovParams.VotingParams.VotingPeriod = time.Second * 300 // 300 seconds genParams.IncentivesGenesis = *incentivestypes.DefaultGenesis() genParams.IncentivesGenesis.Params.DistrEpochIdentifier = "15min" diff --git a/cmd/osmosisd/cmd/root.go b/cmd/osmosisd/cmd/root.go index b8a7c9f5f06..b3135e977d9 100644 --- a/cmd/osmosisd/cmd/root.go +++ b/cmd/osmosisd/cmd/root.go @@ -15,6 +15,7 @@ import ( "github.com/prometheus/client_golang/prometheus" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/spf13/cast" @@ -722,11 +723,11 @@ func transformCoinValueToBaseInt(coinValue, coinDenom string, assetMap map[strin if denomUnitMap, ok := assetMap[coinDenom]; ok { // In this case, we just need to replace the denom with the base denom and retain the number if denomUnitMap.Exponent != 0 { - coinDec, err := sdk.NewDecFromStr(coinValue) + coinDec, err := osmomath.NewDecFromStr(coinValue) if err != nil { return "", err } - transformedCoinValue := coinDec.Mul(sdk.MustNewDecFromStr("10").Power(denomUnitMap.Exponent)) + transformedCoinValue := coinDec.Mul(osmomath.MustNewDecFromStr("10").Power(denomUnitMap.Exponent)) transformedCoinValueInt := transformedCoinValue.TruncateInt() transformedCoinValueStr := transformedCoinValueInt.String() return transformedCoinValueStr + assetMap[coinDenom].Base, nil diff --git a/cmd/osmosisd/cmd/stargate-query.go b/cmd/osmosisd/cmd/stargate-query.go index ab80a893281..99d50c8d593 100644 --- a/cmd/osmosisd/cmd/stargate-query.go +++ b/cmd/osmosisd/cmd/stargate-query.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/wasmbinding" @@ -242,9 +243,9 @@ func GetStructAndFill(queryPath, module, structName string, structArguments ...s return nil, err } v.PoolId = poolId - sdkInt, ok := sdk.NewIntFromString(structArguments[1]) + sdkInt, ok := osmomath.NewIntFromString(structArguments[1]) if !ok { - return nil, fmt.Errorf("failed to parse to sdk.Int") + return nil, fmt.Errorf("failed to parse to osmomath.Int") } v.ShareInAmount = sdkInt return v, nil diff --git a/cmd/osmosisd/cmd/testnet.go b/cmd/osmosisd/cmd/testnet.go index 81aaacc8086..e891f88322c 100644 --- a/cmd/osmosisd/cmd/testnet.go +++ b/cmd/osmosisd/cmd/testnet.go @@ -17,6 +17,8 @@ import ( "github.com/tendermint/tendermint/types" tmtime "github.com/tendermint/tendermint/types/time" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -201,8 +203,8 @@ func InitTestnet( return err } - accTokens := sdk.TokensFromConsensusPower(1000, sdk.NewInt(1)) - accStakingTokens := sdk.TokensFromConsensusPower(500, sdk.NewInt(1)) + accTokens := sdk.TokensFromConsensusPower(1000, osmomath.NewInt(1)) + accStakingTokens := sdk.TokensFromConsensusPower(500, osmomath.NewInt(1)) coins := sdk.Coins{ sdk.NewCoin(fmt.Sprintf("%stoken", nodeDirName), accTokens), sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, accStakingTokens), @@ -211,14 +213,14 @@ func InitTestnet( genBalances = append(genBalances, banktypes.Balance{Address: addr.String(), Coins: coins.Sort()}) genAccounts = append(genAccounts, authtypes.NewBaseAccount(addr, nil, 0, 0)) - valTokens := sdk.TokensFromConsensusPower(100, sdk.NewInt(1)) + valTokens := sdk.TokensFromConsensusPower(100, osmomath.NewInt(1)) createValMsg, err := stakingtypes.NewMsgCreateValidator( sdk.ValAddress(addr), valPubKeys[i], sdk.NewCoin(genesisParams.NativeCoinMetadatas[0].Base, valTokens), stakingtypes.NewDescription(nodeDirName, "", "", "", ""), - stakingtypes.NewCommissionRates(sdk.OneDec(), sdk.OneDec(), sdk.OneDec()), - sdk.OneInt(), + stakingtypes.NewCommissionRates(osmomath.OneDec(), osmomath.OneDec(), osmomath.OneDec()), + osmomath.OneInt(), ) if err != nil { return err diff --git a/go.mod b/go.mod index 36ca5a53468..e003ecbbdcd 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( cosmossdk.io/errors v1.0.0 + cosmossdk.io/math v1.1.3-rc.0 github.com/CosmWasm/wasmd v0.31.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 github.com/cosmos/cosmos-sdk v0.47.5 @@ -21,7 +22,7 @@ require ( github.com/mattn/go-sqlite3 v1.14.17 github.com/ory/dockertest/v3 v3.10.0 github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 - github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230908171738-9abfe2e61cf4 + github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d github.com/osmosis-labs/osmosis/osmoutils v0.0.6 github.com/osmosis-labs/osmosis/x/epochs v0.0.2 github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.8 @@ -55,7 +56,7 @@ require ( github.com/alingse/asasalint v0.0.11 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/butuzov/mirror v1.1.0 // indirect - github.com/bytedance/sonic v1.10.0 // indirect + github.com/bytedance/sonic v1.10.1 // 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 @@ -330,8 +331,8 @@ replace ( github.com/CosmWasm/wasmvm => github.com/CosmWasm/wasmvm v1.2.3 // dragonberry github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // N.B. v0.19.5 contains a breaking change to the IAVL API github.com/cosmos/iavl v0.19.5 => github.com/cosmos/iavl v0.19.4 diff --git a/go.sum b/go.sum index deb01a46f48..b4b955d227b 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3f collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= cosmossdk.io/errors v1.0.0 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= +cosmossdk.io/math v1.1.3-rc.0/go.mod h1:l2Gnda87F0su8a/7FEKJfFdJrM0JZRXQaohlgJeyQh0= 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= @@ -197,8 +199,8 @@ github.com/butuzov/mirror v1.1.0/go.mod h1:8Q0BdQU6rC6WILDiBM60DBfvV78OLJmMmixe7 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/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= +github.com/bytedance/sonic v1.10.1/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= @@ -958,12 +960,12 @@ 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/ory/dockertest/v3 v3.10.0 h1:4K3z2VMe8Woe++invjaTB7VRyQXQy5UY+loujO4aNE4= github.com/ory/dockertest/v3 v3.10.0/go.mod h1:nr57ZbRWMqfsdGdFNLHz5jjNdDb7VVFnzAeW1n5N1Lg= -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/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3/go.mod h1:mFGH2RJhuZa6vBuFMNe4JN85fGtIhROtdeQIyIw9isA= github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY= github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI= -github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230908171738-9abfe2e61cf4 h1:pX9LmOgvRZTQVROZroz5sENUn0/DgdNRS5fbNIjk4Oo= -github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230908171738-9abfe2e61cf4/go.mod h1:UlftwozB+QObT3o0YfkuuyL9fsVdgoWt0dm6J7MLYnU= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d h1:b8Bz31kbzTbcSNsBOcvc2CRVJz5C3cGOQB7JqWDzdfA= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d/go.mod h1:Jj4zQ/IA8iPuHF+Hc/dTFJqAis5WYX3EcO7Xg70fAd8= github.com/osmosis-labs/osmosis/osmoutils v0.0.6 h1:VI4wPzxXpdg5XEUaBugY9lADwxzw3H6lEJ0D+TZc4oE= github.com/osmosis-labs/osmosis/osmoutils v0.0.6/go.mod h1:Pl8Nzx6O6ow/+aqfMoMSz4hX+zz6RrnDYsooptECGxM= github.com/osmosis-labs/osmosis/x/epochs v0.0.2 h1:aEeXHGCSJMgMtAvCucsD2RSaWZ8lISFLD5u4MyF9KPc= @@ -1875,4 +1877,5 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/osmomath/binary_search.go b/osmomath/binary_search.go index f2b3873887f..f71d584c314 100644 --- a/osmomath/binary_search.go +++ b/osmomath/binary_search.go @@ -16,13 +16,13 @@ import ( // * |a - b| / min(a, b) <= MultiplicativeTolerance // // Each check is respectively ignored if the entry is nil. -// So AdditiveTolerance = sdk.Int{} or sdk.ZeroInt() -// MultiplicativeTolerance = sdk.Dec{} +// So AdditiveTolerance = Int{} or ZeroInt() +// MultiplicativeTolerance = Dec{} // RoundingDir = RoundUnconstrained. // Note that if AdditiveTolerance == 0, then this is equivalent to a standard compare. type ErrTolerance struct { - AdditiveTolerance sdk.Dec - MultiplicativeTolerance sdk.Dec + AdditiveTolerance Dec + MultiplicativeTolerance Dec RoundingDir RoundingDirection } @@ -30,8 +30,8 @@ type ErrTolerance struct { // returns 0 if it is // returns 1 if not, and expected > actual. // returns -1 if not, and expected < actual -func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int { - diff := expected.ToDec().Sub(actual.ToDec()).Abs() +func (e ErrTolerance) Compare(expected Int, actual Int) int { + diff := expected.ToLegacyDec().Sub(actual.ToLegacyDec()).Abs() comparisonSign := 0 if expected.GT(actual) { @@ -69,12 +69,12 @@ func (e ErrTolerance) Compare(expected sdk.Int, actual sdk.Int) int { } // Check multiplicative tolerance equations if !e.MultiplicativeTolerance.IsNil() && !e.MultiplicativeTolerance.IsZero() { - minValue := sdk.MinInt(expected.Abs(), actual.Abs()) + minValue := MinInt(expected.Abs(), actual.Abs()) if minValue.IsZero() { return comparisonSign } - errTerm := diff.Quo(minValue.ToDec()) + errTerm := diff.Quo(minValue.ToLegacyDec()) if errTerm.GT(e.MultiplicativeTolerance) { return comparisonSign } @@ -120,20 +120,20 @@ func (e ErrTolerance) CompareBigDec(expected BigDec, actual BigDec) int { } } - if diff.GT(BigDecFromSDKDec(e.AdditiveTolerance)) { + if diff.GT(BigDecFromDec(e.AdditiveTolerance)) { return comparisonSign } } // Check multiplicative tolerance equations if !e.MultiplicativeTolerance.IsNil() && !e.MultiplicativeTolerance.IsZero() { - minValue := MinDec(expected.Abs(), actual.Abs()) + minValue := MinBigDec(expected.Abs(), actual.Abs()) if minValue.IsZero() { return comparisonSign } errTerm := diff.Quo(minValue) // fmt.Printf("err term %v\n", errTerm) - if errTerm.GT(BigDecFromSDKDec(e.MultiplicativeTolerance)) { + if errTerm.GT(BigDecFromDec(e.MultiplicativeTolerance)) { return comparisonSign } } @@ -161,15 +161,15 @@ func (e ErrTolerance) EqualCoins(expectedCoins sdk.Coins, actualCoins sdk.Coins) // Binary search inputs between [lowerbound, upperbound] to a monotonic increasing function f. // We stop once f(found_input) meets the ErrTolerance constraints. // If we perform more than maxIterations (or equivalently lowerbound = upperbound), we return an error. -func BinarySearch(f func(sdk.Int) (sdk.Int, error), - lowerbound sdk.Int, - upperbound sdk.Int, - targetOutput sdk.Int, +func BinarySearch(f func(Int) (Int, error), + lowerbound Int, + upperbound Int, + targetOutput Int, errTolerance ErrTolerance, maxIterations int, -) (sdk.Int, error) { +) (Int, error) { var ( - curEstimate, curOutput sdk.Int + curEstimate, curOutput Int err error ) @@ -178,7 +178,7 @@ func BinarySearch(f func(sdk.Int) (sdk.Int, error), curEstimate = lowerbound.Add(upperbound).QuoRaw(2) curOutput, err = f(curEstimate) if err != nil { - return sdk.Int{}, err + return Int{}, err } compRes := errTolerance.Compare(targetOutput, curOutput) @@ -191,7 +191,7 @@ func BinarySearch(f func(sdk.Int) (sdk.Int, error), } } - return sdk.Int{}, errors.New("hit maximum iterations, did not converge fast enough") + return Int{}, errors.New("hit maximum iterations, did not converge fast enough") } // SdkDec diff --git a/osmomath/binary_search_test.go b/osmomath/binary_search_test.go index e98de7779b9..33e769bac0b 100644 --- a/osmomath/binary_search_test.go +++ b/osmomath/binary_search_test.go @@ -5,41 +5,40 @@ import ( "math/rand" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) var ( - withinOne = ErrTolerance{AdditiveTolerance: sdk.OneDec()} - withinFactor8 = ErrTolerance{MultiplicativeTolerance: sdk.NewDec(8)} - zero = ZeroDec() + withinOne = ErrTolerance{AdditiveTolerance: OneDec()} + withinFactor8 = ErrTolerance{MultiplicativeTolerance: NewDec(8)} + zero = ZeroBigDec() ) func TestBinarySearch(t *testing.T) { // straight line function that returns input. Simplest to binary search on, // binary search directly reveals one bit of the answer in each iteration with this function. - lineF := func(a sdk.Int) (sdk.Int, error) { + lineF := func(a Int) (Int, error) { return a, nil } - cubicF := func(a sdk.Int) (sdk.Int, error) { - calculation := sdk.Dec(a) + cubicF := func(a Int) (Int, error) { + calculation := Dec(a) result := calculation.Power(3) - output := sdk.Int(result) + output := Int(result) return output, nil } - noErrTolerance := ErrTolerance{AdditiveTolerance: sdk.ZeroDec()} - testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: sdk.NewDec(1 << 20)} - testErrToleranceMultiplicative := ErrTolerance{AdditiveTolerance: sdk.ZeroDec(), MultiplicativeTolerance: sdk.NewDec(10)} - testErrToleranceBoth := ErrTolerance{AdditiveTolerance: sdk.NewDec(1 << 20), MultiplicativeTolerance: sdk.NewDec(1 << 3)} + noErrTolerance := ErrTolerance{AdditiveTolerance: ZeroDec()} + testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: NewDec(1 << 20)} + testErrToleranceMultiplicative := ErrTolerance{AdditiveTolerance: ZeroDec(), MultiplicativeTolerance: NewDec(10)} + testErrToleranceBoth := ErrTolerance{AdditiveTolerance: NewDec(1 << 20), MultiplicativeTolerance: NewDec(1 << 3)} tests := map[string]struct { - f func(sdk.Int) (sdk.Int, error) - lowerbound sdk.Int - upperbound sdk.Int - targetOutput sdk.Int + f func(Int) (Int, error) + lowerbound Int + upperbound Int + targetOutput Int errTolerance ErrTolerance maxIterations int - expectedSolvedInput sdk.Int + expectedSolvedInput Int expectErr bool // This binary searches inputs to a monotonic increasing function F // We stop when the answer is within error bounds stated by errTolerance @@ -49,16 +48,16 @@ func TestBinarySearch(t *testing.T) { // If it is, we return current output // Additive error bounds are solid addition / subtraction bounds to error, while multiplicative bounds take effect after dividing by the minimum between the two compared numbers. }{ - "linear f, no err tolerance, converges": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(1 + (1 << 25)), false}, - "linear f, no err tolerance, does not converge": {lineF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, - "cubic f, no err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 51, sdk.NewInt(322539792367616), false}, - "cubic f, no err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), noErrTolerance, 10, sdk.Int{}, true}, - "cubic f, large additive err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceAdditive, 51, sdk.NewInt(1 << 46), false}, - "cubic f, large additive err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceAdditive, 10, sdk.Int{}, true}, - "cubic f, large multiplicative err tolerance, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 51, sdk.NewInt(322539792367616), false}, - "cubic f, large multiplicative err tolerance, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 10, sdk.Int{}, true}, - "cubic f, both err tolerances, converges": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 15)), testErrToleranceBoth, 51, sdk.NewInt(1 << 45), false}, - "cubic f, both err tolerances, does not converge": {cubicF, sdk.ZeroInt(), sdk.NewInt(1 << 50), sdk.NewInt((1 << 30)), testErrToleranceBoth, 10, sdk.Int{}, true}, + "linear f, no err tolerance, converges": {lineF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), noErrTolerance, 51, NewInt(1 + (1 << 25)), false}, + "linear f, no err tolerance, does not converge": {lineF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), noErrTolerance, 10, Int{}, true}, + "cubic f, no err tolerance, converges": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), noErrTolerance, 51, NewInt(322539792367616), false}, + "cubic f, no err tolerance, does not converge": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), noErrTolerance, 10, Int{}, true}, + "cubic f, large additive err tolerance, converges": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt((1 << 15)), testErrToleranceAdditive, 51, NewInt(1 << 46), false}, + "cubic f, large additive err tolerance, does not converge": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt((1 << 30)), testErrToleranceAdditive, 10, Int{}, true}, + "cubic f, large multiplicative err tolerance, converges": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 51, NewInt(322539792367616), false}, + "cubic f, large multiplicative err tolerance, does not converge": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt(1 + (1 << 25)), testErrToleranceMultiplicative, 10, Int{}, true}, + "cubic f, both err tolerances, converges": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt((1 << 15)), testErrToleranceBoth, 51, NewInt(1 << 45), false}, + "cubic f, both err tolerances, does not converge": {cubicF, ZeroInt(), NewInt(1 << 50), NewInt((1 << 30)), testErrToleranceBoth, 10, Int{}, true}, } for name, tc := range tests { @@ -68,7 +67,7 @@ func TestBinarySearch(t *testing.T) { require.Error(t, err) } else { require.NoError(t, err) - require.True(sdk.IntEq(t, tc.expectedSolvedInput, actualSolvedInput)) + require.True(IntEq(t, tc.expectedSolvedInput, actualSolvedInput)) } }) } @@ -144,7 +143,7 @@ func TestBinarySearchLineIterationCounts(t *testing.T) { } } - generateExactTestCases(ZeroDec(), NewBigDec(1<<20), withinOne, 20) + generateExactTestCases(ZeroBigDec(), NewBigDec(1<<20), withinOne, 20) // we can go further than 50, if we could specify non-integer additive err tolerance. TODO: Add this. generateExactTestCases(NewBigDec(1<<20), NewBigDec(1<<50), withinOne, 50) runBinarySearchTestCases(t, tests, exactlyEqual) @@ -155,9 +154,9 @@ var fnMap = map[string]searchFn{"line": lineF, "cubic": cubicF, "neg_cubic": neg // This function tests that any value in a given range can be reached within expected num iterations. func TestIterationDepthRandValue(t *testing.T) { tests := map[string]binarySearchTestCase{} - exactEqual := ErrTolerance{AdditiveTolerance: sdk.ZeroDec()} - withinOne := ErrTolerance{AdditiveTolerance: sdk.OneDec()} - within32 := ErrTolerance{AdditiveTolerance: sdk.OneDec().Mul(sdk.NewDec(32))} + exactEqual := ErrTolerance{AdditiveTolerance: ZeroDec()} + withinOne := ErrTolerance{AdditiveTolerance: OneDec()} + within32 := ErrTolerance{AdditiveTolerance: OneDec().Mul(NewDec(32))} createRandInput := func(fnName string, lowerbound, upperbound int64, errTolerance ErrTolerance, maxNumIters int, errToleranceName string) { @@ -219,7 +218,7 @@ func runBinarySearchTestCases(t *testing.T, tests map[string]binarySearchTestCas } else if equality == errToleranceEqual { require.True(t, tc.errTolerance.CompareBigDec(tc.expectedSolvedInput, actualSolvedInput) == 0) } else { - _, valid, msg, dec1, dec2 := DecApproxEq(t, tc.expectedSolvedInput, actualSolvedInput, OneDec()) + _, valid, msg, dec1, dec2 := DecApproxEq(t, tc.expectedSolvedInput, actualSolvedInput, OneBigDec()) require.True(t, valid, msg+" \n d1 = %s, d2 = %s", dec1, dec2, tc.expectedSolvedInput, actualSolvedInput) } @@ -229,8 +228,8 @@ func runBinarySearchTestCases(t *testing.T, tests map[string]binarySearchTestCas } func TestBinarySearchBigDec(t *testing.T) { - testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: sdk.NewDec(1 << 30)} - errToleranceBoth := ErrTolerance{AdditiveTolerance: sdk.NewDec(1 << 30), MultiplicativeTolerance: sdk.NewDec(1 << 3)} + testErrToleranceAdditive := ErrTolerance{AdditiveTolerance: NewDec(1 << 30)} + errToleranceBoth := ErrTolerance{AdditiveTolerance: NewDec(1 << 30), MultiplicativeTolerance: NewDec(1 << 3)} twoTo50 := NewBigDec(1 << 50) twoTo25PlusOne := NewBigDec(1 + (1 << 25)) @@ -281,7 +280,7 @@ func TestBinarySearchBigDec(t *testing.T) { } func TestBinarySearchRoundingBehavior(t *testing.T) { - withinTwoTo30 := ErrTolerance{AdditiveTolerance: sdk.NewDec(1 << 30)} + withinTwoTo30 := ErrTolerance{AdditiveTolerance: NewDec(1 << 30)} twoTo50 := NewBigDec(1 << 50) // twoTo25PlusOne := NewBigDec(1 + (1 << 25)) @@ -320,10 +319,10 @@ func TestBinarySearchRoundingBehavior(t *testing.T) { } func TestErrTolerance_Compare(t *testing.T) { - ZeroErrTolerance := ErrTolerance{AdditiveTolerance: sdk.ZeroDec(), MultiplicativeTolerance: sdk.Dec{}} - NonZeroErrAdditive := ErrTolerance{AdditiveTolerance: sdk.NewDec(10), MultiplicativeTolerance: sdk.Dec{}} - NonZeroErrMultiplicative := ErrTolerance{AdditiveTolerance: sdk.Dec{}, MultiplicativeTolerance: sdk.NewDec(10)} - NonZeroErrBoth := ErrTolerance{AdditiveTolerance: sdk.NewDec(1), MultiplicativeTolerance: sdk.NewDec(10)} + ZeroErrTolerance := ErrTolerance{AdditiveTolerance: ZeroDec(), MultiplicativeTolerance: Dec{}} + NonZeroErrAdditive := ErrTolerance{AdditiveTolerance: NewDec(10), MultiplicativeTolerance: Dec{}} + NonZeroErrMultiplicative := ErrTolerance{AdditiveTolerance: Dec{}, MultiplicativeTolerance: NewDec(10)} + NonZeroErrBoth := ErrTolerance{AdditiveTolerance: NewDec(1), MultiplicativeTolerance: NewDec(10)} tests := []struct { name string tol ErrTolerance @@ -352,11 +351,11 @@ func TestErrTolerance_Compare(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - gotInt := tt.tol.Compare(sdk.NewInt(tt.intInput), sdk.NewInt(tt.intReference)) + gotInt := tt.tol.Compare(NewInt(tt.intInput), NewInt(tt.intReference)) if gotInt != tt.expectedCompareResult { t.Errorf("ErrTolerance.Compare() = %v, want %v", gotInt, tt.expectedCompareResult) } - gotIntRev := tt.tol.Compare(sdk.NewInt(tt.intReference), sdk.NewInt(tt.intInput)) + gotIntRev := tt.tol.Compare(NewInt(tt.intReference), NewInt(tt.intInput)) if gotIntRev != -tt.expectedCompareResult { t.Errorf("ErrTolerance.Compare() = %v, want %v", gotIntRev, -tt.expectedCompareResult) } diff --git a/osmomath/decimal.go b/osmomath/decimal.go index 317bed58856..72dcb42c55b 100644 --- a/osmomath/decimal.go +++ b/osmomath/decimal.go @@ -20,13 +20,13 @@ type BigDec struct { const ( // number of decimal places - Precision = 36 + PrecisionBigDec = 36 // bytes required to represent the above precision // Ceiling[Log2[10**Precision - 1]] - DecimalPrecisionBits = 120 + BigDecimalPrecisionBits = 120 - maxDecBitLen = maxBitLen + DecimalPrecisionBits + maxDecBitLen = maxBitLen + BigDecimalPrecisionBits // max number of iterations in ApproxRoot function maxApproxRootIterations = 100 @@ -36,8 +36,8 @@ const ( ) var ( - precisionReuse = new(big.Int).Exp(big.NewInt(10), big.NewInt(Precision), nil) - precisionReuseSDK = new(big.Int).Exp(big.NewInt(10), big.NewInt(sdk.Precision), nil) + precisionReuse = new(big.Int).Exp(big.NewInt(10), big.NewInt(PrecisionBigDec), nil) + precisionReuseSDK = new(big.Int).Exp(big.NewInt(10), big.NewInt(PrecisionDec), nil) fivePrecision = new(big.Int).Quo(precisionReuse, big.NewInt(2)) precisionMultipliers []*big.Int zeroInt = big.NewInt(0) @@ -46,14 +46,14 @@ var ( // log_2(e) // From: https://www.wolframalpha.com/input?i=log_2%28e%29+with+37+digits - logOfEbase2 = MustNewDecFromStr("1.442695040888963407359924681001892137") + logOfEbase2 = MustNewBigDecFromStr("1.442695040888963407359924681001892137") // log_2(1.0001) // From: https://www.wolframalpha.com/input?i=log_2%281.0001%29+to+33+digits - tickLogOf2 = MustNewDecFromStr("0.000144262291094554178391070900057480") + tickLogOf2 = MustNewBigDecFromStr("0.000144262291094554178391070900057480") // initialized in init() since requires // precision to be defined. - twoBigDec BigDec = MustNewDecFromStr("2") + twoBigDec BigDec = MustNewBigDecFromStr("2") ) // Decimal errors @@ -65,8 +65,8 @@ var ( // Set precision multipliers func init() { - precisionMultipliers = make([]*big.Int, Precision+1) - for i := 0; i <= Precision; i++ { + precisionMultipliers = make([]*big.Int, PrecisionBigDec+1) + for i := 0; i <= PrecisionBigDec; i++ { precisionMultipliers[i] = calcPrecisionMultiplier(int64(i)) } } @@ -75,36 +75,36 @@ func precisionInt() *big.Int { return new(big.Int).Set(precisionReuse) } -func ZeroDec() BigDec { return BigDec{new(big.Int).Set(zeroInt)} } -func OneDec() BigDec { return BigDec{precisionInt()} } -func SmallestDec() BigDec { return BigDec{new(big.Int).Set(oneInt)} } +func ZeroBigDec() BigDec { return BigDec{new(big.Int).Set(zeroInt)} } +func OneBigDec() BigDec { return BigDec{precisionInt()} } +func SmallestBigDec() BigDec { return BigDec{new(big.Int).Set(oneInt)} } // calculate the precision multiplier func calcPrecisionMultiplier(prec int64) *big.Int { - if prec > Precision { - panic(fmt.Sprintf("too much precision, maximum %v, provided %v", Precision, prec)) + if prec > PrecisionBigDec { + panic(fmt.Sprintf("too much precision, maximum %v, provided %v", PrecisionBigDec, prec)) } - zerosToAdd := Precision - prec + zerosToAdd := PrecisionBigDec - prec multiplier := new(big.Int).Exp(tenInt, big.NewInt(zerosToAdd), nil) return multiplier } // get the precision multiplier, do not mutate result func precisionMultiplier(prec int64) *big.Int { - if prec > Precision { - panic(fmt.Sprintf("too much precision, maximum %v, provided %v", Precision, prec)) + if prec > PrecisionBigDec { + panic(fmt.Sprintf("too much precision, maximum %v, provided %v", PrecisionBigDec, prec)) } return precisionMultipliers[prec] } // create a new NewBigDec from integer assuming whole number func NewBigDec(i int64) BigDec { - return NewDecWithPrec(i, 0) + return NewBigDecWithPrec(i, 0) } // create a new BigDec from integer with decimal place at prec // CONTRACT: prec <= Precision -func NewDecWithPrec(i, prec int64) BigDec { +func NewBigDecWithPrec(i, prec int64) BigDec { return BigDec{ new(big.Int).Mul(big.NewInt(i), precisionMultiplier(prec)), } @@ -112,13 +112,13 @@ func NewDecWithPrec(i, prec int64) BigDec { // create a new BigDec from big integer assuming whole numbers // CONTRACT: prec <= Precision -func NewDecFromBigInt(i *big.Int) BigDec { - return NewDecFromBigIntWithPrec(i, 0) +func NewBigDecFromBigInt(i *big.Int) BigDec { + return NewBigDecFromBigIntWithPrec(i, 0) } // create a new BigDec from big integer assuming whole numbers // CONTRACT: prec <= Precision -func NewDecFromBigIntWithPrec(i *big.Int, prec int64) BigDec { +func NewBigDecFromBigIntWithPrec(i *big.Int, prec int64) BigDec { return BigDec{ new(big.Int).Mul(i, precisionMultiplier(prec)), } @@ -126,13 +126,13 @@ func NewDecFromBigIntWithPrec(i *big.Int, prec int64) BigDec { // create a new BigDec from big integer assuming whole numbers // CONTRACT: prec <= Precision -func NewDecFromInt(i BigInt) BigDec { - return NewDecFromIntWithPrec(i, 0) +func NewBigDecFromInt(i BigInt) BigDec { + return NewBigDecFromIntWithPrec(i, 0) } // create a new BigDec from big integer with decimal place at prec // CONTRACT: prec <= Precision -func NewDecFromIntWithPrec(i BigInt, prec int64) BigDec { +func NewBigDecFromIntWithPrec(i BigInt, prec int64) BigDec { return BigDec{ new(big.Int).Mul(i.BigInt(), precisionMultiplier(prec)), } @@ -154,7 +154,7 @@ func NewDecFromIntWithPrec(i BigInt, prec int64) BigDec { // are provided in the string than the constant Precision. // // CONTRACT - This function does not mutate the input str. -func NewDecFromStr(str string) (BigDec, error) { +func NewBigDecFromStr(str string) (BigDec, error) { if len(str) == 0 { return BigDec{}, ErrEmptyDecimalStr } @@ -184,12 +184,12 @@ func NewDecFromStr(str string) (BigDec, error) { return BigDec{}, ErrInvalidDecimalStr } - if lenDecs > Precision { - return BigDec{}, fmt.Errorf("invalid precision; max: %d, got: %d", Precision, lenDecs) + if lenDecs > PrecisionBigDec { + return BigDec{}, fmt.Errorf("invalid precision; max: %d, got: %d", PrecisionBigDec, lenDecs) } // add some extra zero's to correct to the Precision factor - zerosToAdd := Precision - lenDecs + zerosToAdd := PrecisionBigDec - lenDecs zeros := fmt.Sprintf(`%0`+strconv.Itoa(zerosToAdd)+`s`, "") combinedStr += zeros @@ -208,8 +208,8 @@ func NewDecFromStr(str string) (BigDec, error) { } // Decimal from string, panic on error -func MustNewDecFromStr(s string) BigDec { - dec, err := NewDecFromStr(s) +func MustNewBigDecFromStr(s string) BigDec { + dec, err := NewBigDecFromStr(s) if err != nil { panic(err) } @@ -435,21 +435,21 @@ func (d BigDec) ApproxRoot(root uint64) (guess BigDec, err error) { return absRoot.MulInt64(-1), err } - if root == 1 || d.IsZero() || d.Equal(OneDec()) { + if root == 1 || d.IsZero() || d.Equal(OneBigDec()) { return d, nil } if root == 0 { - return OneDec(), nil + return OneBigDec(), nil } - rootInt := NewIntFromUint64(root) - guess, delta := OneDec(), OneDec() + rootInt := NewBigIntFromUint64(root) + guess, delta := OneBigDec(), OneBigDec() - for iter := 0; delta.Abs().GT(SmallestDec()) && iter < maxApproxRootIterations; iter++ { + for iter := 0; delta.Abs().GT(SmallestBigDec()) && iter < maxApproxRootIterations; iter++ { prev := guess.PowerInteger(root - 1) if prev.IsZero() { - prev = SmallestDec() + prev = SmallestBigDec() } delta = d.Quo(prev) delta = delta.Sub(guess) @@ -502,24 +502,24 @@ func (d BigDec) String() string { // TODO: Remove trailing zeros // case 1, purely decimal - if inputSize <= Precision { - bzStr = make([]byte, Precision+2) + if inputSize <= PrecisionBigDec { + bzStr = make([]byte, PrecisionBigDec+2) // 0. prefix bzStr[0] = byte('0') bzStr[1] = byte('.') // set relevant digits to 0 - for i := 0; i < Precision-inputSize; i++ { + for i := 0; i < PrecisionBigDec-inputSize; i++ { bzStr[i+2] = byte('0') } // set final digits - copy(bzStr[2+(Precision-inputSize):], bzInt) + copy(bzStr[2+(PrecisionBigDec-inputSize):], bzInt) } else { // inputSize + 1 to account for the decimal point that is being added bzStr = make([]byte, inputSize+1) - decPointPlace := inputSize - Precision + decPointPlace := inputSize - PrecisionBigDec copy(bzStr, bzInt[:decPointPlace]) // pre-decimal digits bzStr[decPointPlace] = byte('.') // decimal point @@ -549,10 +549,10 @@ func (d BigDec) MustFloat64() float64 { } } -// SdkDec returns the Sdk.Dec representation of a BigDec. +// Dec returns the osmomath.Dec representation of a BigDec. // Values in any additional decimal places are truncated. -func (d BigDec) SDKDec() sdk.Dec { - precisionDiff := Precision - sdk.Precision +func (d BigDec) Dec() Dec { + precisionDiff := PrecisionBigDec - PrecisionDec precisionFactor := new(big.Int).Exp(big.NewInt(10), big.NewInt(int64(precisionDiff)), nil) if precisionDiff < 0 { @@ -564,40 +564,40 @@ func (d BigDec) SDKDec() sdk.Dec { intRepresentation := new(big.Int).Quo(d.BigInt(), precisionFactor) // convert int representation back to SDK Dec precision - truncatedDec := sdk.NewDecFromBigIntWithPrec(intRepresentation, sdk.Precision) + truncatedDec := NewDecFromBigIntWithPrec(intRepresentation, PrecisionDec) return truncatedDec } -// SDKDecRoundUp returns the Sdk.Dec representation of a BigDec. +// DecRoundUp returns the osmomath.Dec representation of a BigDec. // Round up at precision end. // Values in any additional decimal places are truncated. -func (d BigDec) SDKDecRoundUp() sdk.Dec { - return sdk.NewDecFromBigIntWithPrec(chopPrecisionAndRoundUpSDKDec(d.i), sdk.Precision) +func (d BigDec) DecRoundUp() Dec { + return NewDecFromBigIntWithPrec(chopPrecisionAndRoundUpDec(d.i), PrecisionDec) } -// BigDecFromSdkDec returns the BigDec representation of an SDKDec. +// BigDecFromDec returns the BigDec representation of an Dec. // Values in any additional decimal places are truncated. -func BigDecFromSDKDec(d sdk.Dec) BigDec { - return NewDecFromBigIntWithPrec(d.BigInt(), sdk.Precision) +func BigDecFromDec(d Dec) BigDec { + return NewBigDecFromBigIntWithPrec(d.BigInt(), PrecisionDec) } -// BigDecFromSdkDecSlice returns the []BigDec representation of an []SDKDec. +// BigDecFromDecSlice returns the []BigDec representation of an []Dec. // Values in any additional decimal places are truncated. -func BigDecFromSDKDecSlice(ds []sdk.Dec) []BigDec { +func BigDecFromDecSlice(ds []Dec) []BigDec { result := make([]BigDec, len(ds)) for i, d := range ds { - result[i] = NewDecFromBigIntWithPrec(d.BigInt(), sdk.Precision) + result[i] = NewBigDecFromBigIntWithPrec(d.BigInt(), PrecisionDec) } return result } -// BigDecFromSdkDecSlice returns the []BigDec representation of an []SDKDec. +// BigDecFromDecSlice returns the []BigDec representation of an []Dec. // Values in any additional decimal places are truncated. -func BigDecFromSDKDecCoinSlice(ds []sdk.DecCoin) []BigDec { +func BigDecFromDecCoinSlice(ds []sdk.DecCoin) []BigDec { result := make([]BigDec, len(ds)) for i, d := range ds { - result[i] = NewDecFromBigIntWithPrec(d.Amount.BigInt(), sdk.Precision) + result[i] = NewBigDecFromBigIntWithPrec(d.Amount.BigInt(), PrecisionDec) } return result } @@ -652,8 +652,8 @@ func chopPrecisionAndRoundUpBigDec(d *big.Int) *big.Int { return chopPrecisionAndRoundUp(d, precisionReuse) } -// chopPrecisionAndRoundUpSDKDec removes sdk.Precision amount of rightmost digits and rounds up. -func chopPrecisionAndRoundUpSDKDec(d *big.Int) *big.Int { +// chopPrecisionAndRoundUpDec removes sdk.Precision amount of rightmost digits and rounds up. +func chopPrecisionAndRoundUpDec(d *big.Int) *big.Int { return chopPrecisionAndRoundUp(d, precisionReuseSDK) } @@ -696,7 +696,7 @@ func (d BigDec) RoundInt64() int64 { // RoundInt round the decimal using bankers rounding func (d BigDec) RoundInt() BigInt { - return NewIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) + return NewBigIntFromBigInt(chopPrecisionAndRoundNonMutative(d.i)) } // chopPrecisionAndTruncate is similar to chopPrecisionAndRound, @@ -716,12 +716,12 @@ func (d BigDec) TruncateInt64() int64 { // TruncateInt truncates the decimals from the number and returns an Int func (d BigDec) TruncateInt() BigInt { - return NewIntFromBigInt(chopPrecisionAndTruncate(d.i)) + return NewBigIntFromBigInt(chopPrecisionAndTruncate(d.i)) } // TruncateDec truncates the decimals from the number and returns a Dec func (d BigDec) TruncateDec() BigDec { - return NewDecFromBigInt(chopPrecisionAndTruncate(d.i)) + return NewBigDecFromBigInt(chopPrecisionAndTruncate(d.i)) } // Ceil returns the smallest interger value (as a decimal) that is greater than @@ -734,19 +734,19 @@ func (d BigDec) Ceil() BigDec { // no need to round with a zero remainder regardless of sign if rem.Cmp(zeroInt) == 0 { - return NewDecFromBigInt(quo) + return NewBigDecFromBigInt(quo) } if rem.Sign() == -1 { - return NewDecFromBigInt(quo) + return NewBigDecFromBigInt(quo) } - return NewDecFromBigInt(quo.Add(quo, oneInt)) + return NewBigDecFromBigInt(quo.Add(quo, oneInt)) } // MaxSortableDec is the largest Dec that can be passed into SortableDecBytes() // Its negative form is the least Dec that can be passed in. -var MaxSortableDec = OneDec().Quo(SmallestDec()) +var MaxSortableDec = OneBigDec().Quo(SmallestBigDec()) // ValidSortableDec ensures that a Dec is within the sortable bounds, // a BigDec can't have a precision of less than 10^-18. @@ -773,9 +773,9 @@ func SortableDecBytes(dec BigDec) []byte { } // We move the negative sign to the front of all the left padded 0s, to make negative numbers come before positive numbers if dec.IsNegative() { - return append([]byte("-"), []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.Abs().String()))...) + return append([]byte("-"), []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", PrecisionBigDec*2+1), dec.Abs().String()))...) } - return []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", Precision*2+1), dec.String())) + return []byte(fmt.Sprintf(fmt.Sprintf("%%0%ds", PrecisionBigDec*2+1), dec.String())) } // reuse nil values @@ -808,7 +808,7 @@ func (d *BigDec) UnmarshalJSON(bz []byte) error { } // TODO: Reuse dec allocation - newDec, err := NewDecFromStr(text) + newDec, err := NewBigDecFromStr(text) if err != nil { return err } @@ -898,16 +898,16 @@ func DecsEqual(d1s, d2s []BigDec) bool { return true } -// MinDec gets minimum decimal between two -func MinDec(d1, d2 BigDec) BigDec { +// MinBigDec gets minimum decimal between two +func MinBigDec(d1, d2 BigDec) BigDec { if d1.LT(d2) { return d1 } return d2 } -// MaxDec gets maximum decimal between two -func MaxDec(d1, d2 BigDec) BigDec { +// MaxBigDec gets maximum decimal between two +func MaxBigDec(d1, d2 BigDec) BigDec { if d1.LT(d2) { return d2 } @@ -939,30 +939,30 @@ func DecApproxEq(t *testing.T, d1 BigDec, d2 BigDec, tol BigDec) (*testing.T, bo func (x BigDec) LogBase2() BigDec { // create a new decimal to avoid mutating // the receiver's int buffer. - xCopy := ZeroDec() + xCopy := ZeroBigDec() xCopy.i = new(big.Int).Set(x.i) - if xCopy.LTE(ZeroDec()) { + if xCopy.LTE(ZeroBigDec()) { panic(fmt.Sprintf("log is not defined at <= 0, given (%s)", xCopy)) } // Normalize x to be 1 <= x < 2. // y is the exponent that results in a whole multiple of 2. - y := ZeroDec() + y := ZeroBigDec() // repeat until: x >= 1. - for xCopy.LT(OneDec()) { + for xCopy.LT(OneBigDec()) { xCopy.i.Lsh(xCopy.i, 1) - y = y.Sub(OneDec()) + y = y.Sub(OneBigDec()) } // repeat until: x < 2. for xCopy.GTE(twoBigDec) { xCopy.i.Rsh(xCopy.i, 1) - y = y.Add(OneDec()) + y = y.Add(OneBigDec()) } - b := OneDec().Quo(twoBigDec) + b := OneBigDec().Quo(twoBigDec) // N.B. At this point x is a positive real number representing // mantissa of the log. We estimate it using the following @@ -1005,7 +1005,7 @@ func (x BigDec) TickLog() BigDec { // log_a(x) custom base logarithm // Formula: log_a(b) = log_2(b) / log_2(a) func (x BigDec) CustomBaseLog(base BigDec) BigDec { - if base.LTE(ZeroDec()) || base.Equal(OneDec()) { + if base.LTE(ZeroBigDec()) || base.Equal(OneBigDec()) { panic(fmt.Sprintf("log is not defined at base <= 0 or base == 1, base given (%s)", base)) } @@ -1030,9 +1030,9 @@ func (d BigDec) PowerInteger(power uint64) BigDec { // algorithm for performing the calculation. func (d BigDec) PowerIntegerMut(power uint64) BigDec { if power == 0 { - return OneDec() + return OneBigDec() } - tmp := OneDec() + tmp := OneBigDec() for i := power; i > 1; { if i%2 != 0 { @@ -1069,12 +1069,12 @@ func (d BigDec) Power(power BigDec) BigDec { return d.PowerInteger(power.TruncateInt().Uint64()) } if power.IsZero() { - return OneDec() + return OneBigDec() } if d.IsZero() { - return ZeroDec() + return ZeroBigDec() } - if d.LT(OneDec()) { + if d.LT(OneBigDec()) { panic(fmt.Sprintf("Power() is not supported for base < 1, base was (%s)", d)) } if d.Equal(twoBigDec) { diff --git a/osmomath/decimal_test.go b/osmomath/decimal_test.go index 34779783cd2..84e5ec05054 100644 --- a/osmomath/decimal_test.go +++ b/osmomath/decimal_test.go @@ -7,7 +7,6 @@ import ( "math/big" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "gopkg.in/yaml.v2" @@ -21,7 +20,7 @@ type decimalTestSuite struct { var ( zeroAdditiveErrTolerance = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.ZeroDec(), + AdditiveTolerance: osmomath.ZeroDec(), } ) @@ -44,7 +43,7 @@ func (s *decimalTestSuite) assertMutResult(expectedResult, startValue, mutativeR } func (s *decimalTestSuite) TestAddMut() { - toAdd := osmomath.MustNewDecFromStr("10") + toAdd := osmomath.MustNewBigDecFromStr("10") tests := map[string]struct { startValue osmomath.BigDec expectedMutResult osmomath.BigDec @@ -68,13 +67,13 @@ func (s *decimalTestSuite) TestAddMut() { } func (s *decimalTestSuite) TestQuoMut() { - quoBy := osmomath.MustNewDecFromStr("2") + quoBy := osmomath.MustNewBigDecFromStr("2") tests := map[string]struct { startValue osmomath.BigDec expectedMutResult osmomath.BigDec }{ "0": {osmomath.NewBigDec(0), osmomath.NewBigDec(0)}, - "1": {osmomath.NewBigDec(1), osmomath.MustNewDecFromStr("0.5")}, + "1": {osmomath.NewBigDec(1), osmomath.MustNewBigDecFromStr("0.5")}, "10": {osmomath.NewBigDec(10), osmomath.NewBigDec(5)}, } @@ -92,30 +91,30 @@ func (s *decimalTestSuite) TestQuoMut() { } func TestDecApproxEq(t *testing.T) { // d1 = 0.55, d2 = 0.6, tol = 0.1 - d1 := osmomath.NewDecWithPrec(55, 2) - d2 := osmomath.NewDecWithPrec(6, 1) - tol := osmomath.NewDecWithPrec(1, 1) + d1 := osmomath.NewBigDecWithPrec(55, 2) + d2 := osmomath.NewBigDecWithPrec(6, 1) + tol := osmomath.NewBigDecWithPrec(1, 1) require.True(osmomath.DecApproxEq(t, d1, d2, tol)) // d1 = 0.55, d2 = 0.6, tol = 1E-5 - d1 = osmomath.NewDecWithPrec(55, 2) - d2 = osmomath.NewDecWithPrec(6, 1) - tol = osmomath.NewDecWithPrec(1, 5) + d1 = osmomath.NewBigDecWithPrec(55, 2) + d2 = osmomath.NewBigDecWithPrec(6, 1) + tol = osmomath.NewBigDecWithPrec(1, 5) require.False(osmomath.DecApproxEq(t, d1, d2, tol)) // d1 = 0.6, d2 = 0.61, tol = 0.01 - d1 = osmomath.NewDecWithPrec(6, 1) - d2 = osmomath.NewDecWithPrec(61, 2) - tol = osmomath.NewDecWithPrec(1, 2) + d1 = osmomath.NewBigDecWithPrec(6, 1) + d2 = osmomath.NewBigDecWithPrec(61, 2) + tol = osmomath.NewBigDecWithPrec(1, 2) require.True(osmomath.DecApproxEq(t, d1, d2, tol)) } // create a decimal from a decimal string (ex. "1234.5678") func (s *decimalTestSuite) MustNewDecFromStr(str string) (d osmomath.BigDec) { - d, err := osmomath.NewDecFromStr(str) + d, err := osmomath.NewBigDecFromStr(str) s.Require().NoError(err) return d @@ -134,18 +133,18 @@ func (s *decimalTestSuite) TestNewDecFromStr() { {"0.-75", true, osmomath.BigDec{}}, {"0", false, osmomath.NewBigDec(0)}, {"1", false, osmomath.NewBigDec(1)}, - {"1.1", false, osmomath.NewDecWithPrec(11, 1)}, - {"0.75", false, osmomath.NewDecWithPrec(75, 2)}, - {"0.8", false, osmomath.NewDecWithPrec(8, 1)}, - {"0.11111", false, osmomath.NewDecWithPrec(11111, 5)}, + {"1.1", false, osmomath.NewBigDecWithPrec(11, 1)}, + {"0.75", false, osmomath.NewBigDecWithPrec(75, 2)}, + {"0.8", false, osmomath.NewBigDecWithPrec(8, 1)}, + {"0.11111", false, osmomath.NewBigDecWithPrec(11111, 5)}, {"314460551102969.31442782343433718353144278234343371835", true, osmomath.NewBigDec(3141203149163817869)}, { "314460551102969314427823434337.18357180924882313501835718092488231350", - true, osmomath.NewDecFromBigIntWithPrec(largeBigInt, 4), + true, osmomath.NewBigDecFromBigIntWithPrec(largeBigInt, 4), }, { "314460551102969314427823434337.1835", - false, osmomath.NewDecFromBigIntWithPrec(largeBigInt, 4), + false, osmomath.NewBigDecFromBigIntWithPrec(largeBigInt, 4), }, {".", true, osmomath.BigDec{}}, {".0", true, osmomath.NewBigDec(0)}, @@ -157,7 +156,7 @@ func (s *decimalTestSuite) TestNewDecFromStr() { } for tcIndex, tc := range tests { - res, err := osmomath.NewDecFromStr(tc.decimalStr) + res, err := osmomath.NewBigDecFromStr(tc.decimalStr) if tc.expErr { s.Require().NotNil(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) } else { @@ -166,7 +165,7 @@ func (s *decimalTestSuite) TestNewDecFromStr() { } // negative tc - res, err = osmomath.NewDecFromStr("-" + tc.decimalStr) + res, err = osmomath.NewBigDecFromStr("-" + tc.decimalStr) if tc.expErr { s.Require().NotNil(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) } else { @@ -186,11 +185,11 @@ func (s *decimalTestSuite) TestDecString() { {osmomath.NewBigDec(1), "1.000000000000000000000000000000000000"}, {osmomath.NewBigDec(10), "10.000000000000000000000000000000000000"}, {osmomath.NewBigDec(12340), "12340.000000000000000000000000000000000000"}, - {osmomath.NewDecWithPrec(12340, 4), "1.234000000000000000000000000000000000"}, - {osmomath.NewDecWithPrec(12340, 5), "0.123400000000000000000000000000000000"}, - {osmomath.NewDecWithPrec(12340, 8), "0.000123400000000000000000000000000000"}, - {osmomath.NewDecWithPrec(1009009009009009009, 17), "10.090090090090090090000000000000000000"}, - {osmomath.MustNewDecFromStr("10.090090090090090090090090090090090090"), "10.090090090090090090090090090090090090"}, + {osmomath.NewBigDecWithPrec(12340, 4), "1.234000000000000000000000000000000000"}, + {osmomath.NewBigDecWithPrec(12340, 5), "0.123400000000000000000000000000000000"}, + {osmomath.NewBigDecWithPrec(12340, 8), "0.000123400000000000000000000000000000"}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 17), "10.090090090090090090000000000000000000"}, + {osmomath.MustNewBigDecFromStr("10.090090090090090090090090090090090090"), "10.090090090090090090090090090090090090"}, } for tcIndex, tc := range tests { s.Require().Equal(tc.want, tc.d.String(), "bad String(), index: %v", tcIndex) @@ -206,10 +205,10 @@ func (s *decimalTestSuite) TestDecFloat64() { {osmomath.NewBigDec(1), 1.000000000000000000}, {osmomath.NewBigDec(10), 10.000000000000000000}, {osmomath.NewBigDec(12340), 12340.000000000000000000}, - {osmomath.NewDecWithPrec(12340, 4), 1.234000000000000000}, - {osmomath.NewDecWithPrec(12340, 5), 0.123400000000000000}, - {osmomath.NewDecWithPrec(12340, 8), 0.000123400000000000}, - {osmomath.NewDecWithPrec(1009009009009009009, 17), 10.090090090090090090}, + {osmomath.NewBigDecWithPrec(12340, 4), 1.234000000000000000}, + {osmomath.NewBigDecWithPrec(12340, 5), 0.123400000000000000}, + {osmomath.NewBigDecWithPrec(12340, 8), 0.000123400000000000}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 17), 10.090090090090090090}, } for tcIndex, tc := range tests { value, err := tc.d.Float64() @@ -222,23 +221,23 @@ func (s *decimalTestSuite) TestDecFloat64() { func (s *decimalTestSuite) TestSdkDec() { tests := []struct { d osmomath.BigDec - want sdk.Dec + want osmomath.Dec expPanic bool }{ - {osmomath.NewBigDec(0), sdk.MustNewDecFromStr("0.000000000000000000"), false}, - {osmomath.NewBigDec(1), sdk.MustNewDecFromStr("1.000000000000000000"), false}, - {osmomath.NewBigDec(10), sdk.MustNewDecFromStr("10.000000000000000000"), false}, - {osmomath.NewBigDec(12340), sdk.MustNewDecFromStr("12340.000000000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 4), sdk.MustNewDecFromStr("1.234000000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 5), sdk.MustNewDecFromStr("0.123400000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 8), sdk.MustNewDecFromStr("0.000123400000000000"), false}, - {osmomath.NewDecWithPrec(1009009009009009009, 17), sdk.MustNewDecFromStr("10.090090090090090090"), false}, + {osmomath.NewBigDec(0), osmomath.MustNewDecFromStr("0.000000000000000000"), false}, + {osmomath.NewBigDec(1), osmomath.MustNewDecFromStr("1.000000000000000000"), false}, + {osmomath.NewBigDec(10), osmomath.MustNewDecFromStr("10.000000000000000000"), false}, + {osmomath.NewBigDec(12340), osmomath.MustNewDecFromStr("12340.000000000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 4), osmomath.MustNewDecFromStr("1.234000000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 5), osmomath.MustNewDecFromStr("0.123400000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 8), osmomath.MustNewDecFromStr("0.000123400000000000"), false}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 17), osmomath.MustNewDecFromStr("10.090090090090090090"), false}, } for tcIndex, tc := range tests { if tc.expPanic { - s.Require().Panics(func() { tc.d.SDKDec() }) + s.Require().Panics(func() { tc.d.Dec() }) } else { - value := tc.d.SDKDec() + value := tc.d.Dec() s.Require().Equal(tc.want, value, "bad SdkDec(), index: %v", tcIndex) } } @@ -247,76 +246,76 @@ func (s *decimalTestSuite) TestSdkDec() { func (s *decimalTestSuite) TestSdkDecRoundUp() { tests := []struct { d osmomath.BigDec - want sdk.Dec + want osmomath.Dec expPanic bool }{ - {osmomath.NewBigDec(0), sdk.MustNewDecFromStr("0.000000000000000000"), false}, - {osmomath.NewBigDec(1), sdk.MustNewDecFromStr("1.000000000000000000"), false}, - {osmomath.NewBigDec(10), sdk.MustNewDecFromStr("10.000000000000000000"), false}, - {osmomath.NewBigDec(12340), sdk.MustNewDecFromStr("12340.000000000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 4), sdk.MustNewDecFromStr("1.234000000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 5), sdk.MustNewDecFromStr("0.123400000000000000"), false}, - {osmomath.NewDecWithPrec(12340, 8), sdk.MustNewDecFromStr("0.000123400000000000"), false}, - {osmomath.NewDecWithPrec(1009009009009009009, 17), sdk.MustNewDecFromStr("10.090090090090090090"), false}, - {osmomath.NewDecWithPrec(1009009009009009009, 19), sdk.MustNewDecFromStr("0.100900900900900901"), false}, + {osmomath.NewBigDec(0), osmomath.MustNewDecFromStr("0.000000000000000000"), false}, + {osmomath.NewBigDec(1), osmomath.MustNewDecFromStr("1.000000000000000000"), false}, + {osmomath.NewBigDec(10), osmomath.MustNewDecFromStr("10.000000000000000000"), false}, + {osmomath.NewBigDec(12340), osmomath.MustNewDecFromStr("12340.000000000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 4), osmomath.MustNewDecFromStr("1.234000000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 5), osmomath.MustNewDecFromStr("0.123400000000000000"), false}, + {osmomath.NewBigDecWithPrec(12340, 8), osmomath.MustNewDecFromStr("0.000123400000000000"), false}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 17), osmomath.MustNewDecFromStr("10.090090090090090090"), false}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 19), osmomath.MustNewDecFromStr("0.100900900900900901"), false}, } for tcIndex, tc := range tests { if tc.expPanic { - s.Require().Panics(func() { tc.d.SDKDecRoundUp() }) + s.Require().Panics(func() { tc.d.DecRoundUp() }) } else { - value := tc.d.SDKDecRoundUp() + value := tc.d.DecRoundUp() s.Require().Equal(tc.want, value, "bad SdkDec(), index: %v", tcIndex) } } } -func (s *decimalTestSuite) TestBigDecFromSdkDec() { +func (s *decimalTestSuite) TestBigDecFromDec() { tests := []struct { - d sdk.Dec + d osmomath.Dec want osmomath.BigDec expPanic bool }{ - {sdk.MustNewDecFromStr("0.000000000000000000"), osmomath.NewBigDec(0), false}, - {sdk.MustNewDecFromStr("1.000000000000000000"), osmomath.NewBigDec(1), false}, - {sdk.MustNewDecFromStr("10.000000000000000000"), osmomath.NewBigDec(10), false}, - {sdk.MustNewDecFromStr("12340.000000000000000000"), osmomath.NewBigDec(12340), false}, - {sdk.MustNewDecFromStr("1.234000000000000000"), osmomath.NewDecWithPrec(12340, 4), false}, - {sdk.MustNewDecFromStr("0.123400000000000000"), osmomath.NewDecWithPrec(12340, 5), false}, - {sdk.MustNewDecFromStr("0.000123400000000000"), osmomath.NewDecWithPrec(12340, 8), false}, - {sdk.MustNewDecFromStr("10.090090090090090090"), osmomath.NewDecWithPrec(1009009009009009009, 17), false}, + {osmomath.MustNewDecFromStr("0.000000000000000000"), osmomath.NewBigDec(0), false}, + {osmomath.MustNewDecFromStr("1.000000000000000000"), osmomath.NewBigDec(1), false}, + {osmomath.MustNewDecFromStr("10.000000000000000000"), osmomath.NewBigDec(10), false}, + {osmomath.MustNewDecFromStr("12340.000000000000000000"), osmomath.NewBigDec(12340), false}, + {osmomath.MustNewDecFromStr("1.234000000000000000"), osmomath.NewBigDecWithPrec(12340, 4), false}, + {osmomath.MustNewDecFromStr("0.123400000000000000"), osmomath.NewBigDecWithPrec(12340, 5), false}, + {osmomath.MustNewDecFromStr("0.000123400000000000"), osmomath.NewBigDecWithPrec(12340, 8), false}, + {osmomath.MustNewDecFromStr("10.090090090090090090"), osmomath.NewBigDecWithPrec(1009009009009009009, 17), false}, } for tcIndex, tc := range tests { if tc.expPanic { - s.Require().Panics(func() { osmomath.BigDecFromSDKDec(tc.d) }) + s.Require().Panics(func() { osmomath.BigDecFromDec(tc.d) }) } else { - value := osmomath.BigDecFromSDKDec(tc.d) - s.Require().Equal(tc.want, value, "bad osmomath.BigDecFromSdkDec(), index: %v", tcIndex) + value := osmomath.BigDecFromDec(tc.d) + s.Require().Equal(tc.want, value, "bad osmomath.BigDecFromDec(), index: %v", tcIndex) } } } -func (s *decimalTestSuite) TestBigDecFromSdkDecSlice() { +func (s *decimalTestSuite) TestBigDecFromDecSlice() { tests := []struct { - d []sdk.Dec + d []osmomath.Dec want []osmomath.BigDec expPanic bool }{ - {[]sdk.Dec{sdk.MustNewDecFromStr("0.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(0)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("0.000000000000000000"), sdk.MustNewDecFromStr("1.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(0), osmomath.NewBigDec(1)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("1.000000000000000000"), sdk.MustNewDecFromStr("0.000000000000000000"), sdk.MustNewDecFromStr("0.000123400000000000")}, []osmomath.BigDec{osmomath.NewBigDec(1), osmomath.NewBigDec(0), osmomath.NewDecWithPrec(12340, 8)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("10.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(10)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(12340)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("1.234000000000000000"), sdk.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewDecWithPrec(12340, 4), osmomath.NewBigDec(12340)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("0.123400000000000000"), sdk.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewDecWithPrec(12340, 5), osmomath.NewBigDec(12340)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("0.000123400000000000"), sdk.MustNewDecFromStr("10.090090090090090090")}, []osmomath.BigDec{osmomath.NewDecWithPrec(12340, 8), osmomath.NewDecWithPrec(1009009009009009009, 17)}, false}, - {[]sdk.Dec{sdk.MustNewDecFromStr("10.090090090090090090"), sdk.MustNewDecFromStr("10.090090090090090090")}, []osmomath.BigDec{osmomath.NewDecWithPrec(1009009009009009009, 17), osmomath.NewDecWithPrec(1009009009009009009, 17)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("0.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(0)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("0.000000000000000000"), osmomath.MustNewDecFromStr("1.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(0), osmomath.NewBigDec(1)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("1.000000000000000000"), osmomath.MustNewDecFromStr("0.000000000000000000"), osmomath.MustNewDecFromStr("0.000123400000000000")}, []osmomath.BigDec{osmomath.NewBigDec(1), osmomath.NewBigDec(0), osmomath.NewBigDecWithPrec(12340, 8)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("10.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(10)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDec(12340)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("1.234000000000000000"), osmomath.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDecWithPrec(12340, 4), osmomath.NewBigDec(12340)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("0.123400000000000000"), osmomath.MustNewDecFromStr("12340.000000000000000000")}, []osmomath.BigDec{osmomath.NewBigDecWithPrec(12340, 5), osmomath.NewBigDec(12340)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("0.000123400000000000"), osmomath.MustNewDecFromStr("10.090090090090090090")}, []osmomath.BigDec{osmomath.NewBigDecWithPrec(12340, 8), osmomath.NewBigDecWithPrec(1009009009009009009, 17)}, false}, + {[]osmomath.Dec{osmomath.MustNewDecFromStr("10.090090090090090090"), osmomath.MustNewDecFromStr("10.090090090090090090")}, []osmomath.BigDec{osmomath.NewBigDecWithPrec(1009009009009009009, 17), osmomath.NewBigDecWithPrec(1009009009009009009, 17)}, false}, } for tcIndex, tc := range tests { if tc.expPanic { - s.Require().Panics(func() { osmomath.BigDecFromSDKDecSlice(tc.d) }) + s.Require().Panics(func() { osmomath.BigDecFromDecSlice(tc.d) }) } else { - value := osmomath.BigDecFromSDKDecSlice(tc.d) - s.Require().Equal(tc.want, value, "bad osmomath.BigDecFromSdkDec(), index: %v", tcIndex) + value := osmomath.BigDecFromDecSlice(tc.d) + s.Require().Equal(tc.want, value, "bad osmomath.BigDecFromDec(), index: %v", tcIndex) } } } @@ -327,27 +326,27 @@ func (s *decimalTestSuite) TestEqualities() { gt, lt, eq bool }{ {osmomath.NewBigDec(0), osmomath.NewBigDec(0), false, false, true}, - {osmomath.NewDecWithPrec(0, 2), osmomath.NewDecWithPrec(0, 4), false, false, true}, - {osmomath.NewDecWithPrec(100, 0), osmomath.NewDecWithPrec(100, 0), false, false, true}, - {osmomath.NewDecWithPrec(-100, 0), osmomath.NewDecWithPrec(-100, 0), false, false, true}, - {osmomath.NewDecWithPrec(-1, 1), osmomath.NewDecWithPrec(-1, 1), false, false, true}, - {osmomath.NewDecWithPrec(3333, 3), osmomath.NewDecWithPrec(3333, 3), false, false, true}, - - {osmomath.NewDecWithPrec(0, 0), osmomath.NewDecWithPrec(3333, 3), false, true, false}, - {osmomath.NewDecWithPrec(0, 0), osmomath.NewDecWithPrec(100, 0), false, true, false}, - {osmomath.NewDecWithPrec(-1, 0), osmomath.NewDecWithPrec(3333, 3), false, true, false}, - {osmomath.NewDecWithPrec(-1, 0), osmomath.NewDecWithPrec(100, 0), false, true, false}, - {osmomath.NewDecWithPrec(1111, 3), osmomath.NewDecWithPrec(100, 0), false, true, false}, - {osmomath.NewDecWithPrec(1111, 3), osmomath.NewDecWithPrec(3333, 3), false, true, false}, - {osmomath.NewDecWithPrec(-3333, 3), osmomath.NewDecWithPrec(-1111, 3), false, true, false}, - - {osmomath.NewDecWithPrec(3333, 3), osmomath.NewDecWithPrec(0, 0), true, false, false}, - {osmomath.NewDecWithPrec(100, 0), osmomath.NewDecWithPrec(0, 0), true, false, false}, - {osmomath.NewDecWithPrec(3333, 3), osmomath.NewDecWithPrec(-1, 0), true, false, false}, - {osmomath.NewDecWithPrec(100, 0), osmomath.NewDecWithPrec(-1, 0), true, false, false}, - {osmomath.NewDecWithPrec(100, 0), osmomath.NewDecWithPrec(1111, 3), true, false, false}, - {osmomath.NewDecWithPrec(3333, 3), osmomath.NewDecWithPrec(1111, 3), true, false, false}, - {osmomath.NewDecWithPrec(-1111, 3), osmomath.NewDecWithPrec(-3333, 3), true, false, false}, + {osmomath.NewBigDecWithPrec(0, 2), osmomath.NewBigDecWithPrec(0, 4), false, false, true}, + {osmomath.NewBigDecWithPrec(100, 0), osmomath.NewBigDecWithPrec(100, 0), false, false, true}, + {osmomath.NewBigDecWithPrec(-100, 0), osmomath.NewBigDecWithPrec(-100, 0), false, false, true}, + {osmomath.NewBigDecWithPrec(-1, 1), osmomath.NewBigDecWithPrec(-1, 1), false, false, true}, + {osmomath.NewBigDecWithPrec(3333, 3), osmomath.NewBigDecWithPrec(3333, 3), false, false, true}, + + {osmomath.NewBigDecWithPrec(0, 0), osmomath.NewBigDecWithPrec(3333, 3), false, true, false}, + {osmomath.NewBigDecWithPrec(0, 0), osmomath.NewBigDecWithPrec(100, 0), false, true, false}, + {osmomath.NewBigDecWithPrec(-1, 0), osmomath.NewBigDecWithPrec(3333, 3), false, true, false}, + {osmomath.NewBigDecWithPrec(-1, 0), osmomath.NewBigDecWithPrec(100, 0), false, true, false}, + {osmomath.NewBigDecWithPrec(1111, 3), osmomath.NewBigDecWithPrec(100, 0), false, true, false}, + {osmomath.NewBigDecWithPrec(1111, 3), osmomath.NewBigDecWithPrec(3333, 3), false, true, false}, + {osmomath.NewBigDecWithPrec(-3333, 3), osmomath.NewBigDecWithPrec(-1111, 3), false, true, false}, + + {osmomath.NewBigDecWithPrec(3333, 3), osmomath.NewBigDecWithPrec(0, 0), true, false, false}, + {osmomath.NewBigDecWithPrec(100, 0), osmomath.NewBigDecWithPrec(0, 0), true, false, false}, + {osmomath.NewBigDecWithPrec(3333, 3), osmomath.NewBigDecWithPrec(-1, 0), true, false, false}, + {osmomath.NewBigDecWithPrec(100, 0), osmomath.NewBigDecWithPrec(-1, 0), true, false, false}, + {osmomath.NewBigDecWithPrec(100, 0), osmomath.NewBigDecWithPrec(1111, 3), true, false, false}, + {osmomath.NewBigDecWithPrec(3333, 3), osmomath.NewBigDecWithPrec(1111, 3), true, false, false}, + {osmomath.NewBigDecWithPrec(-1111, 3), osmomath.NewBigDecWithPrec(-3333, 3), true, false, false}, } for tcIndex, tc := range tests { @@ -400,24 +399,24 @@ func (s *decimalTestSuite) TestArithmetic() { { osmomath.NewBigDec(3), osmomath.NewBigDec(7), osmomath.NewBigDec(21), osmomath.NewBigDec(21), osmomath.NewBigDec(21), - osmomath.MustNewDecFromStr("0.428571428571428571428571428571428571"), osmomath.MustNewDecFromStr("0.428571428571428571428571428571428572"), osmomath.MustNewDecFromStr("0.428571428571428571428571428571428571"), + osmomath.MustNewBigDecFromStr("0.428571428571428571428571428571428571"), osmomath.MustNewBigDecFromStr("0.428571428571428571428571428571428572"), osmomath.MustNewBigDecFromStr("0.428571428571428571428571428571428571"), osmomath.NewBigDec(10), osmomath.NewBigDec(-4), }, { - osmomath.NewBigDec(2), osmomath.NewBigDec(4), osmomath.NewBigDec(8), osmomath.NewBigDec(8), osmomath.NewBigDec(8), osmomath.NewDecWithPrec(5, 1), osmomath.NewDecWithPrec(5, 1), osmomath.NewDecWithPrec(5, 1), + osmomath.NewBigDec(2), osmomath.NewBigDec(4), osmomath.NewBigDec(8), osmomath.NewBigDec(8), osmomath.NewBigDec(8), osmomath.NewBigDecWithPrec(5, 1), osmomath.NewBigDecWithPrec(5, 1), osmomath.NewBigDecWithPrec(5, 1), osmomath.NewBigDec(6), osmomath.NewBigDec(-2), }, {osmomath.NewBigDec(100), osmomath.NewBigDec(100), osmomath.NewBigDec(10000), osmomath.NewBigDec(10000), osmomath.NewBigDec(10000), osmomath.NewBigDec(1), osmomath.NewBigDec(1), osmomath.NewBigDec(1), osmomath.NewBigDec(200), osmomath.NewBigDec(0)}, { - osmomath.NewDecWithPrec(15, 1), osmomath.NewDecWithPrec(15, 1), osmomath.NewDecWithPrec(225, 2), osmomath.NewDecWithPrec(225, 2), osmomath.NewDecWithPrec(225, 2), + osmomath.NewBigDecWithPrec(15, 1), osmomath.NewBigDecWithPrec(15, 1), osmomath.NewBigDecWithPrec(225, 2), osmomath.NewBigDecWithPrec(225, 2), osmomath.NewBigDecWithPrec(225, 2), osmomath.NewBigDec(1), osmomath.NewBigDec(1), osmomath.NewBigDec(1), osmomath.NewBigDec(3), osmomath.NewBigDec(0), }, { - osmomath.NewDecWithPrec(3333, 4), osmomath.NewDecWithPrec(333, 4), osmomath.NewDecWithPrec(1109889, 8), osmomath.NewDecWithPrec(1109889, 8), osmomath.NewDecWithPrec(1109889, 8), - osmomath.MustNewDecFromStr("10.009009009009009009009009009009009009"), osmomath.MustNewDecFromStr("10.009009009009009009009009009009009010"), osmomath.MustNewDecFromStr("10.009009009009009009009009009009009009"), - osmomath.NewDecWithPrec(3666, 4), osmomath.NewDecWithPrec(3, 1), + osmomath.NewBigDecWithPrec(3333, 4), osmomath.NewBigDecWithPrec(333, 4), osmomath.NewBigDecWithPrec(1109889, 8), osmomath.NewBigDecWithPrec(1109889, 8), osmomath.NewBigDecWithPrec(1109889, 8), + osmomath.MustNewBigDecFromStr("10.009009009009009009009009009009009009"), osmomath.MustNewBigDecFromStr("10.009009009009009009009009009009009010"), osmomath.MustNewBigDecFromStr("10.009009009009009009009009009009009009"), + osmomath.NewBigDecWithPrec(3666, 4), osmomath.NewBigDecWithPrec(3, 1), }, } @@ -453,10 +452,10 @@ func (s *decimalTestSuite) TestArithmetic() { func (s *decimalTestSuite) TestMulRoundUp_RoundingAtPrecisionEnd() { var ( - a = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000009") - b = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000009") - expectedRoundUp = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000001") - expectedTruncate = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000000") + a = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000009") + b = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000009") + expectedRoundUp = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000001") + expectedTruncate = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000000") ) actualRoundUp := a.MulRoundUp(b) @@ -520,9 +519,9 @@ func (s *decimalTestSuite) TestTruncate() { func (s *decimalTestSuite) TestStringOverflow() { // two random 64 bit primes - dec1, err := osmomath.NewDecFromStr("51643150036226787134389711697696177267") + dec1, err := osmomath.NewBigDecFromStr("51643150036226787134389711697696177267") s.Require().NoError(err) - dec2, err := osmomath.NewDecFromStr("-31798496660535729618459429845579852627") + dec2, err := osmomath.NewBigDecFromStr("-31798496660535729618459429845579852627") s.Require().NoError(err) dec3 := dec1.Add(dec2) s.Require().Equal( @@ -537,10 +536,10 @@ func (s *decimalTestSuite) TestDecMulInt() { sdkInt osmomath.BigInt want osmomath.BigDec }{ - {osmomath.NewBigDec(10), osmomath.NewInt(2), osmomath.NewBigDec(20)}, - {osmomath.NewBigDec(1000000), osmomath.NewInt(100), osmomath.NewBigDec(100000000)}, - {osmomath.NewDecWithPrec(1, 1), osmomath.NewInt(10), osmomath.NewBigDec(1)}, - {osmomath.NewDecWithPrec(1, 5), osmomath.NewInt(20), osmomath.NewDecWithPrec(2, 4)}, + {osmomath.NewBigDec(10), osmomath.NewBigInt(2), osmomath.NewBigDec(20)}, + {osmomath.NewBigDec(1000000), osmomath.NewBigInt(100), osmomath.NewBigDec(100000000)}, + {osmomath.NewBigDecWithPrec(1, 1), osmomath.NewBigInt(10), osmomath.NewBigDec(1)}, + {osmomath.NewBigDecWithPrec(1, 5), osmomath.NewBigInt(20), osmomath.NewBigDecWithPrec(2, 4)}, } for i, tc := range tests { got := tc.sdkDec.MulInt(tc.sdkInt) @@ -553,14 +552,14 @@ func (s *decimalTestSuite) TestDecCeil() { input osmomath.BigDec expected osmomath.BigDec }{ - {osmomath.MustNewDecFromStr("0.001"), osmomath.NewBigDec(1)}, // 0.001 => 1.0 - {osmomath.MustNewDecFromStr("-0.001"), osmomath.ZeroDec()}, // -0.001 => 0.0 - {osmomath.ZeroDec(), osmomath.ZeroDec()}, // 0.0 => 0.0 - {osmomath.MustNewDecFromStr("0.9"), osmomath.NewBigDec(1)}, // 0.9 => 1.0 - {osmomath.MustNewDecFromStr("4.001"), osmomath.NewBigDec(5)}, // 4.001 => 5.0 - {osmomath.MustNewDecFromStr("-4.001"), osmomath.NewBigDec(-4)}, // -4.001 => -4.0 - {osmomath.MustNewDecFromStr("4.7"), osmomath.NewBigDec(5)}, // 4.7 => 5.0 - {osmomath.MustNewDecFromStr("-4.7"), osmomath.NewBigDec(-4)}, // -4.7 => -4.0 + {osmomath.MustNewBigDecFromStr("0.001"), osmomath.NewBigDec(1)}, // 0.001 => 1.0 + {osmomath.MustNewBigDecFromStr("-0.001"), osmomath.ZeroBigDec()}, // -0.001 => 0.0 + {osmomath.ZeroBigDec(), osmomath.ZeroBigDec()}, // 0.0 => 0.0 + {osmomath.MustNewBigDecFromStr("0.9"), osmomath.NewBigDec(1)}, // 0.9 => 1.0 + {osmomath.MustNewBigDecFromStr("4.001"), osmomath.NewBigDec(5)}, // 4.001 => 5.0 + {osmomath.MustNewBigDecFromStr("-4.001"), osmomath.NewBigDec(-4)}, // -4.001 => -4.0 + {osmomath.MustNewBigDecFromStr("4.7"), osmomath.NewBigDec(5)}, // 4.7 => 5.0 + {osmomath.MustNewBigDecFromStr("-4.7"), osmomath.NewBigDec(-4)}, // -4.7 => -4.0 } for i, tc := range testCases { @@ -575,16 +574,16 @@ func (s *decimalTestSuite) TestApproxRoot() { root uint64 expected osmomath.BigDec }{ - {osmomath.OneDec(), 10, osmomath.OneDec()}, // 1.0 ^ (0.1) => 1.0 - {osmomath.NewDecWithPrec(25, 2), 2, osmomath.NewDecWithPrec(5, 1)}, // 0.25 ^ (0.5) => 0.5 - {osmomath.NewDecWithPrec(4, 2), 2, osmomath.NewDecWithPrec(2, 1)}, // 0.04 ^ (0.5) => 0.2 - {osmomath.NewDecFromInt(osmomath.NewInt(27)), 3, osmomath.NewDecFromInt(osmomath.NewInt(3))}, // 27 ^ (1/3) => 3 - {osmomath.NewDecFromInt(osmomath.NewInt(-81)), 4, osmomath.NewDecFromInt(osmomath.NewInt(-3))}, // -81 ^ (0.25) => -3 - {osmomath.NewDecFromInt(osmomath.NewInt(2)), 2, osmomath.MustNewDecFromStr("1.414213562373095048801688724209698079")}, // 2 ^ (0.5) => 1.414213562373095048801688724209698079 - {osmomath.NewDecWithPrec(1005, 3), 31536000, osmomath.MustNewDecFromStr("1.000000000158153903837946258002096839")}, // 1.005 ^ (1/31536000) ≈ 1.000000000158153903837946258002096839 - {osmomath.SmallestDec(), 2, osmomath.NewDecWithPrec(1, 18)}, // 1e-36 ^ (0.5) => 1e-18 - {osmomath.SmallestDec(), 3, osmomath.MustNewDecFromStr("0.000000000001000000000000000002431786")}, // 1e-36 ^ (1/3) => 1e-12 - {osmomath.NewDecWithPrec(1, 8), 3, osmomath.MustNewDecFromStr("0.002154434690031883721759293566519280")}, // 1e-8 ^ (1/3) ≈ 0.002154434690031883721759293566519 + {osmomath.OneBigDec(), 10, osmomath.OneBigDec()}, // 1.0 ^ (0.1) => 1.0 + {osmomath.NewBigDecWithPrec(25, 2), 2, osmomath.NewBigDecWithPrec(5, 1)}, // 0.25 ^ (0.5) => 0.5 + {osmomath.NewBigDecWithPrec(4, 2), 2, osmomath.NewBigDecWithPrec(2, 1)}, // 0.04 ^ (0.5) => 0.2 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(27)), 3, osmomath.NewBigDecFromInt(osmomath.NewBigInt(3))}, // 27 ^ (1/3) => 3 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(-81)), 4, osmomath.NewBigDecFromInt(osmomath.NewBigInt(-3))}, // -81 ^ (0.25) => -3 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(2)), 2, osmomath.MustNewBigDecFromStr("1.414213562373095048801688724209698079")}, // 2 ^ (0.5) => 1.414213562373095048801688724209698079 + {osmomath.NewBigDecWithPrec(1005, 3), 31536000, osmomath.MustNewBigDecFromStr("1.000000000158153903837946258002096839")}, // 1.005 ^ (1/31536000) ≈ 1.000000000158153903837946258002096839 + {osmomath.SmallestBigDec(), 2, osmomath.NewBigDecWithPrec(1, 18)}, // 1e-36 ^ (0.5) => 1e-18 + {osmomath.SmallestBigDec(), 3, osmomath.MustNewBigDecFromStr("0.000000000001000000000000000002431786")}, // 1e-36 ^ (1/3) => 1e-12 + {osmomath.NewBigDecWithPrec(1, 8), 3, osmomath.MustNewBigDecFromStr("0.002154434690031883721759293566519280")}, // 1e-8 ^ (1/3) ≈ 0.002154434690031883721759293566519 } // In the case of 1e-8 ^ (1/3), the result repeats every 5 iterations starting from iteration 24 @@ -594,7 +593,7 @@ func (s *decimalTestSuite) TestApproxRoot() { for i, tc := range testCases { res, err := tc.input.ApproxRoot(tc.root) s.Require().NoError(err) - s.Require().True(tc.expected.Sub(res).Abs().LTE(osmomath.SmallestDec()), "unexpected result for test case %d, input: %v", i, tc.input) + s.Require().True(tc.expected.Sub(res).Abs().LTE(osmomath.SmallestBigDec()), "unexpected result for test case %d, input: %v", i, tc.input) } } @@ -603,12 +602,12 @@ func (s *decimalTestSuite) TestApproxSqrt() { input osmomath.BigDec expected osmomath.BigDec }{ - {osmomath.OneDec(), osmomath.OneDec()}, // 1.0 => 1.0 - {osmomath.NewDecWithPrec(25, 2), osmomath.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 - {osmomath.NewDecWithPrec(4, 2), osmomath.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 - {osmomath.NewDecFromInt(osmomath.NewInt(9)), osmomath.NewDecFromInt(osmomath.NewInt(3))}, // 9 => 3 - {osmomath.NewDecFromInt(osmomath.NewInt(-9)), osmomath.NewDecFromInt(osmomath.NewInt(-3))}, // -9 => -3 - {osmomath.NewDecFromInt(osmomath.NewInt(2)), osmomath.MustNewDecFromStr("1.414213562373095048801688724209698079")}, // 2 => 1.414213562373095048801688724209698079 + {osmomath.OneBigDec(), osmomath.OneBigDec()}, // 1.0 => 1.0 + {osmomath.NewBigDecWithPrec(25, 2), osmomath.NewBigDecWithPrec(5, 1)}, // 0.25 => 0.5 + {osmomath.NewBigDecWithPrec(4, 2), osmomath.NewBigDecWithPrec(2, 1)}, // 0.09 => 0.3 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(9)), osmomath.NewBigDecFromInt(osmomath.NewBigInt(3))}, // 9 => 3 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(-9)), osmomath.NewBigDecFromInt(osmomath.NewBigInt(-3))}, // -9 => -3 + {osmomath.NewBigDecFromInt(osmomath.NewBigInt(2)), osmomath.MustNewBigDecFromStr("1.414213562373095048801688724209698079")}, // 2 => 1.414213562373095048801688724209698079 } for i, tc := range testCases { @@ -627,21 +626,23 @@ func (s *decimalTestSuite) TestDecSortableBytes() { {osmomath.NewBigDec(1), []byte("000000000000000000000000000000000001.000000000000000000000000000000000000")}, {osmomath.NewBigDec(10), []byte("000000000000000000000000000000000010.000000000000000000000000000000000000")}, {osmomath.NewBigDec(12340), []byte("000000000000000000000000000000012340.000000000000000000000000000000000000")}, - {osmomath.NewDecWithPrec(12340, 4), []byte("000000000000000000000000000000000001.234000000000000000000000000000000000")}, - {osmomath.NewDecWithPrec(12340, 5), []byte("000000000000000000000000000000000000.123400000000000000000000000000000000")}, - {osmomath.NewDecWithPrec(12340, 8), []byte("000000000000000000000000000000000000.000123400000000000000000000000000000")}, - {osmomath.NewDecWithPrec(1009009009009009009, 17), []byte("000000000000000000000000000000000010.090090090090090090000000000000000000")}, - {osmomath.NewDecWithPrec(-1009009009009009009, 17), []byte("-000000000000000000000000000000000010.090090090090090090000000000000000000")}, - {osmomath.MustNewDecFromStr("1000000000000000000000000000000000000"), []byte("max")}, - {osmomath.MustNewDecFromStr("-1000000000000000000000000000000000000"), []byte("--")}, + {osmomath.NewBigDecWithPrec(12340, 4), []byte("000000000000000000000000000000000001.234000000000000000000000000000000000")}, + {osmomath.NewBigDecWithPrec(12340, 5), []byte("000000000000000000000000000000000000.123400000000000000000000000000000000")}, + {osmomath.NewBigDecWithPrec(12340, 8), []byte("000000000000000000000000000000000000.000123400000000000000000000000000000")}, + {osmomath.NewBigDecWithPrec(1009009009009009009, 17), []byte("000000000000000000000000000000000010.090090090090090090000000000000000000")}, + {osmomath.NewBigDecWithPrec(-1009009009009009009, 17), []byte("-000000000000000000000000000000000010.090090090090090090000000000000000000")}, + {osmomath.MustNewBigDecFromStr("1000000000000000000000000000000000000"), []byte("max")}, + {osmomath.MustNewBigDecFromStr("-1000000000000000000000000000000000000"), []byte("--")}, } for tcIndex, tc := range tests { s.Require().Equal(tc.want, osmomath.SortableDecBytes(tc.d), "bad String(), index: %v", tcIndex) } - s.Require().Panics(func() { osmomath.SortableDecBytes(osmomath.MustNewDecFromStr("1000000000000000000000000000000000001")) }) s.Require().Panics(func() { - osmomath.SortableDecBytes(osmomath.MustNewDecFromStr("-1000000000000000000000000000000000001")) + osmomath.SortableDecBytes(osmomath.MustNewBigDecFromStr("1000000000000000000000000000000000001")) + }) + s.Require().Panics(func() { + osmomath.SortableDecBytes(osmomath.MustNewBigDecFromStr("-1000000000000000000000000000000000001")) }) } @@ -658,25 +659,25 @@ func (s *decimalTestSuite) TestDecEncoding() { "\"0.000000000000000000000000000000000000\"\n", }, { - osmomath.NewDecWithPrec(4, 2), + osmomath.NewBigDecWithPrec(4, 2), "3430303030303030303030303030303030303030303030303030303030303030303030", "\"0.040000000000000000000000000000000000\"", "\"0.040000000000000000000000000000000000\"\n", }, { - osmomath.NewDecWithPrec(-4, 2), + osmomath.NewBigDecWithPrec(-4, 2), "2D3430303030303030303030303030303030303030303030303030303030303030303030", "\"-0.040000000000000000000000000000000000\"", "\"-0.040000000000000000000000000000000000\"\n", }, { - osmomath.MustNewDecFromStr("1.414213562373095048801688724209698079"), + osmomath.MustNewBigDecFromStr("1.414213562373095048801688724209698079"), "31343134323133353632333733303935303438383031363838373234323039363938303739", "\"1.414213562373095048801688724209698079\"", "\"1.414213562373095048801688724209698079\"\n", }, { - osmomath.MustNewDecFromStr("-1.414213562373095048801688724209698079"), + osmomath.MustNewBigDecFromStr("-1.414213562373095048801688724209698079"), "2D31343134323133353632333733303935303438383031363838373234323039363938303739", "\"-1.414213562373095048801688724209698079\"", "\"-1.414213562373095048801688724209698079\"\n", @@ -746,7 +747,7 @@ func BenchmarkMarshalTo(b *testing.B) { } func (s *decimalTestSuite) TestLog2() { - var expectedErrTolerance = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000100") + var expectedErrTolerance = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000100") tests := map[string]struct { initialValue osmomath.BigDec @@ -755,27 +756,27 @@ func (s *decimalTestSuite) TestLog2() { expectedPanic bool }{ "log_2{-1}; invalid; panic": { - initialValue: osmomath.OneDec().Neg(), + initialValue: osmomath.OneBigDec().Neg(), expectedPanic: true, }, "log_2{0}; invalid; panic": { - initialValue: osmomath.ZeroDec(), + initialValue: osmomath.ZeroBigDec(), expectedPanic: true, }, "log_2{0.001} = -9.965784284662087043610958288468170528": { - initialValue: osmomath.MustNewDecFromStr("0.001"), + initialValue: osmomath.MustNewBigDecFromStr("0.001"), // From: https://www.wolframalpha.com/input?i=log+base+2+of+0.999912345+with+33+digits - expected: osmomath.MustNewDecFromStr("-9.965784284662087043610958288468170528"), + expected: osmomath.MustNewBigDecFromStr("-9.965784284662087043610958288468170528"), }, "log_2{0.56171821941421412902170941} = -0.832081497183140708984033250637831402": { - initialValue: osmomath.MustNewDecFromStr("0.56171821941421412902170941"), + initialValue: osmomath.MustNewBigDecFromStr("0.56171821941421412902170941"), // From: https://www.wolframalpha.com/input?i=log+base+2+of+0.56171821941421412902170941+with+36+digits - expected: osmomath.MustNewDecFromStr("-0.832081497183140708984033250637831402"), + expected: osmomath.MustNewBigDecFromStr("-0.832081497183140708984033250637831402"), }, "log_2{0.999912345} = -0.000126464976533858080645902722235833": { - initialValue: osmomath.MustNewDecFromStr("0.999912345"), + initialValue: osmomath.MustNewBigDecFromStr("0.999912345"), // From: https://www.wolframalpha.com/input?i=log+base+2+of+0.999912345+with+37+digits - expected: osmomath.MustNewDecFromStr("-0.000126464976533858080645902722235833"), + expected: osmomath.MustNewBigDecFromStr("-0.000126464976533858080645902722235833"), }, "log_2{1} = 0": { initialValue: osmomath.NewBigDec(1), @@ -788,7 +789,7 @@ func (s *decimalTestSuite) TestLog2() { "log_2{7} = 2.807354922057604107441969317231830809": { initialValue: osmomath.NewBigDec(7), // From: https://www.wolframalpha.com/input?i=log+base+2+of+7+37+digits - expected: osmomath.MustNewDecFromStr("2.807354922057604107441969317231830809"), + expected: osmomath.MustNewBigDecFromStr("2.807354922057604107441969317231830809"), }, "log_2{512} = 9": { initialValue: osmomath.NewBigDec(512), @@ -797,32 +798,32 @@ func (s *decimalTestSuite) TestLog2() { "log_2{580} = 9.179909090014934468590092754117374938": { initialValue: osmomath.NewBigDec(580), // From: https://www.wolframalpha.com/input?i=log+base+2+of+600+37+digits - expected: osmomath.MustNewDecFromStr("9.179909090014934468590092754117374938"), + expected: osmomath.MustNewBigDecFromStr("9.179909090014934468590092754117374938"), }, "log_2{1024} = 10": { initialValue: osmomath.NewBigDec(1024), expected: osmomath.NewBigDec(10), }, "log_2{1024.987654321} = 10.001390817654141324352719749259888355": { - initialValue: osmomath.NewDecWithPrec(1024987654321, 9), + initialValue: osmomath.NewBigDecWithPrec(1024987654321, 9), // From: https://www.wolframalpha.com/input?i=log+base+2+of+1024.987654321+38+digits - expected: osmomath.MustNewDecFromStr("10.001390817654141324352719749259888355"), + expected: osmomath.MustNewBigDecFromStr("10.001390817654141324352719749259888355"), }, "log_2{912648174127941279170121098210.92821920190204131121} = 99.525973560175362367047484597337715868": { - initialValue: osmomath.MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + initialValue: osmomath.MustNewBigDecFromStr("912648174127941279170121098210.92821920190204131121"), // From: https://www.wolframalpha.com/input?i=log+base+2+of+912648174127941279170121098210.92821920190204131121+38+digits - expected: osmomath.MustNewDecFromStr("99.525973560175362367047484597337715868"), + expected: osmomath.MustNewBigDecFromStr("99.525973560175362367047484597337715868"), }, "log_2{Max Spot Price} = 128": { - initialValue: osmomath.BigDecFromSDKDec(osmomath.MaxSpotPrice), // 2^128 - 1 + initialValue: osmomath.BigDecFromDec(osmomath.MaxSpotPrice), // 2^128 - 1 // From: https://www.wolframalpha.com/input?i=log+base+2+of+%28%282%5E128%29+-+1%29+38+digits - expected: osmomath.MustNewDecFromStr("128"), + expected: osmomath.MustNewBigDecFromStr("128"), }, // The value tested below is: gammtypes.MaxSpotPrice * 0.99 = (2^128 - 1) * 0.99 "log_2{336879543251729078828740861357450529340.45} = 127.98550043030488492336620207564264562": { - initialValue: osmomath.MustNewDecFromStr("336879543251729078828740861357450529340.45"), + initialValue: osmomath.MustNewBigDecFromStr("336879543251729078828740861357450529340.45"), // From: https://www.wolframalpha.com/input?i=log+base+2+of+%28%28%282%5E128%29+-+1%29*0.99%29++38+digits - expected: osmomath.MustNewDecFromStr("127.98550043030488492336620207564264562"), + expected: osmomath.MustNewBigDecFromStr("127.98550043030488492336620207564264562"), }, } @@ -842,7 +843,7 @@ func (s *decimalTestSuite) TestLog2() { } func (s *decimalTestSuite) TestLn() { - var expectedErrTolerance = osmomath.MustNewDecFromStr("0.000000000000000000000000000000000100") + var expectedErrTolerance = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000100") tests := map[string]struct { initialValue osmomath.BigDec @@ -851,61 +852,61 @@ func (s *decimalTestSuite) TestLn() { expectedPanic bool }{ "log_e{-1}; invalid; panic": { - initialValue: osmomath.OneDec().Neg(), + initialValue: osmomath.OneBigDec().Neg(), expectedPanic: true, }, "log_e{0}; invalid; panic": { - initialValue: osmomath.ZeroDec(), + initialValue: osmomath.ZeroBigDec(), expectedPanic: true, }, "log_e{0.001} = -6.90775527898213705205397436405309262": { - initialValue: osmomath.MustNewDecFromStr("0.001"), + initialValue: osmomath.MustNewBigDecFromStr("0.001"), // From: https://www.wolframalpha.com/input?i=log0.001+to+36+digits+with+36+decimals - expected: osmomath.MustNewDecFromStr("-6.90775527898213705205397436405309262"), + expected: osmomath.MustNewBigDecFromStr("-6.90775527898213705205397436405309262"), }, "log_e{0.56171821941421412902170941} = -0.576754943768592057376050794884207180": { - initialValue: osmomath.MustNewDecFromStr("0.56171821941421412902170941"), + initialValue: osmomath.MustNewBigDecFromStr("0.56171821941421412902170941"), // From: https://www.wolframalpha.com/input?i=log0.56171821941421412902170941+to+36+digits - expected: osmomath.MustNewDecFromStr("-0.576754943768592057376050794884207180"), + expected: osmomath.MustNewBigDecFromStr("-0.576754943768592057376050794884207180"), }, "log_e{0.999912345} = -0.000087658841924023373535614212850888": { - initialValue: osmomath.MustNewDecFromStr("0.999912345"), + initialValue: osmomath.MustNewBigDecFromStr("0.999912345"), // From: https://www.wolframalpha.com/input?i=log0.999912345+to+32+digits - expected: osmomath.MustNewDecFromStr("-0.000087658841924023373535614212850888"), + expected: osmomath.MustNewBigDecFromStr("-0.000087658841924023373535614212850888"), }, "log_e{1} = 0": { initialValue: osmomath.NewBigDec(1), expected: osmomath.NewBigDec(0), }, "log_e{e} = 1": { - initialValue: osmomath.MustNewDecFromStr("2.718281828459045235360287471352662498"), + initialValue: osmomath.MustNewBigDecFromStr("2.718281828459045235360287471352662498"), // From: https://www.wolframalpha.com/input?i=e+with+36+decimals expected: osmomath.NewBigDec(1), }, "log_e{7} = 1.945910149055313305105352743443179730": { initialValue: osmomath.NewBigDec(7), // From: https://www.wolframalpha.com/input?i=log7+up+to+36+decimals - expected: osmomath.MustNewDecFromStr("1.945910149055313305105352743443179730"), + expected: osmomath.MustNewBigDecFromStr("1.945910149055313305105352743443179730"), }, "log_e{512} = 6.238324625039507784755089093123589113": { initialValue: osmomath.NewBigDec(512), // From: https://www.wolframalpha.com/input?i=log512+up+to+36+decimals - expected: osmomath.MustNewDecFromStr("6.238324625039507784755089093123589113"), + expected: osmomath.MustNewBigDecFromStr("6.238324625039507784755089093123589113"), }, "log_e{580} = 6.36302810354046502061849560850445238": { initialValue: osmomath.NewBigDec(580), // From: https://www.wolframalpha.com/input?i=log580+up+to+36+decimals - expected: osmomath.MustNewDecFromStr("6.36302810354046502061849560850445238"), + expected: osmomath.MustNewBigDecFromStr("6.36302810354046502061849560850445238"), }, "log_e{1024.987654321} = 6.93243584693509415029056534690631614": { - initialValue: osmomath.NewDecWithPrec(1024987654321, 9), + initialValue: osmomath.NewBigDecWithPrec(1024987654321, 9), // From: https://www.wolframalpha.com/input?i=log1024.987654321+to+36+digits - expected: osmomath.MustNewDecFromStr("6.93243584693509415029056534690631614"), + expected: osmomath.MustNewBigDecFromStr("6.93243584693509415029056534690631614"), }, "log_e{912648174127941279170121098210.92821920190204131121} = 68.986147965719214790400745338243805015": { - initialValue: osmomath.MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + initialValue: osmomath.MustNewBigDecFromStr("912648174127941279170121098210.92821920190204131121"), // From: https://www.wolframalpha.com/input?i=log912648174127941279170121098210.92821920190204131121+to+38+digits - expected: osmomath.MustNewDecFromStr("68.986147965719214790400745338243805015"), + expected: osmomath.MustNewBigDecFromStr("68.986147965719214790400745338243805015"), }, } @@ -933,54 +934,54 @@ func (s *decimalTestSuite) TestTickLog() { expectedPanic bool }{ "log_1.0001{-1}; invalid; panic": { - initialValue: osmomath.OneDec().Neg(), + initialValue: osmomath.OneBigDec().Neg(), expectedPanic: true, }, "log_1.0001{0}; invalid; panic": { - initialValue: osmomath.ZeroDec(), + initialValue: osmomath.ZeroBigDec(), expectedPanic: true, }, "log_1.0001{0.001} = -69081.006609899112313305835611219486392199": { - initialValue: osmomath.MustNewDecFromStr("0.001"), + initialValue: osmomath.MustNewBigDecFromStr("0.001"), // From: https://www.wolframalpha.com/input?i=log_1.0001%280.001%29+to+41+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000143031879"), - expected: osmomath.MustNewDecFromStr("-69081.006609899112313305835611219486392199"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000143031879"), + expected: osmomath.MustNewBigDecFromStr("-69081.006609899112313305835611219486392199"), }, "log_1.0001{0.999912345} = -0.876632247930741919880461740717176538": { - initialValue: osmomath.MustNewDecFromStr("0.999912345"), + initialValue: osmomath.MustNewBigDecFromStr("0.999912345"), // From: https://www.wolframalpha.com/input?i=log_1.0001%280.999912345%29+to+36+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000138702"), - expected: osmomath.MustNewDecFromStr("-0.876632247930741919880461740717176538"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000138702"), + expected: osmomath.MustNewBigDecFromStr("-0.876632247930741919880461740717176538"), }, "log_1.0001{1} = 0": { initialValue: osmomath.NewBigDec(1), - expectedErrTolerance: osmomath.ZeroDec(), + expectedErrTolerance: osmomath.ZeroBigDec(), expected: osmomath.NewBigDec(0), }, "log_1.0001{1.0001} = 1": { - initialValue: osmomath.MustNewDecFromStr("1.0001"), + initialValue: osmomath.MustNewBigDecFromStr("1.0001"), - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000152500"), - expected: osmomath.OneDec(), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000152500"), + expected: osmomath.OneBigDec(), }, "log_1.0001{512} = 62386.365360724158196763710649998441051753": { initialValue: osmomath.NewBigDec(512), // From: https://www.wolframalpha.com/input?i=log_1.0001%28512%29+to+41+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000129292137"), - expected: osmomath.MustNewDecFromStr("62386.365360724158196763710649998441051753"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000129292137"), + expected: osmomath.MustNewBigDecFromStr("62386.365360724158196763710649998441051753"), }, "log_1.0001{1024.987654321} = 69327.824629506998657531621822514042777198": { - initialValue: osmomath.NewDecWithPrec(1024987654321, 9), + initialValue: osmomath.NewBigDecWithPrec(1024987654321, 9), // From: https://www.wolframalpha.com/input?i=log_1.0001%281024.987654321%29+to+41+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000143836264"), - expected: osmomath.MustNewDecFromStr("69327.824629506998657531621822514042777198"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000143836264"), + expected: osmomath.MustNewBigDecFromStr("69327.824629506998657531621822514042777198"), }, "log_1.0001{912648174127941279170121098210.92821920190204131121} = 689895.972156319183538389792485913311778672": { - initialValue: osmomath.MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + initialValue: osmomath.MustNewBigDecFromStr("912648174127941279170121098210.92821920190204131121"), // From: https://www.wolframalpha.com/input?i=log_1.0001%28912648174127941279170121098210.92821920190204131121%29+to+42+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000001429936067"), - expected: osmomath.MustNewDecFromStr("689895.972156319183538389792485913311778672"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000001429936067"), + expected: osmomath.MustNewBigDecFromStr("689895.972156319183538389792485913311778672"), }, } @@ -1034,69 +1035,69 @@ func (s *decimalTestSuite) TestCustomBaseLog() { initialValue: osmomath.NewBigDec(100), base: osmomath.NewBigDec(30), // From: https://www.wolframalpha.com/input?i=log_30%28100%29+to+37+digits - expectedErrTolerance: osmomath.ZeroDec(), - expected: osmomath.MustNewDecFromStr("1.353984985057691049642502891262784015"), + expectedErrTolerance: osmomath.ZeroBigDec(), + expected: osmomath.MustNewBigDecFromStr("1.353984985057691049642502891262784015"), }, "log_0.2(0.99) = 0.006244624769837438271878639001855450": { - initialValue: osmomath.MustNewDecFromStr("0.99"), - base: osmomath.MustNewDecFromStr("0.2"), + initialValue: osmomath.MustNewBigDecFromStr("0.99"), + base: osmomath.MustNewBigDecFromStr("0.2"), // From: https://www.wolframalpha.com/input?i=log_0.2%280.99%29+to+34+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000000013"), - expected: osmomath.MustNewDecFromStr("0.006244624769837438271878639001855450"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000013"), + expected: osmomath.MustNewBigDecFromStr("0.006244624769837438271878639001855450"), }, "log_0.0001(500000) = -1.424742501084004701196565276318876743": { initialValue: osmomath.NewBigDec(500000), - base: osmomath.NewDecWithPrec(1, 4), + base: osmomath.NewBigDecWithPrec(1, 4), // From: https://www.wolframalpha.com/input?i=log_0.0001%28500000%29+to+37+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000000003"), - expected: osmomath.MustNewDecFromStr("-1.424742501084004701196565276318876743"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000003"), + expected: osmomath.MustNewBigDecFromStr("-1.424742501084004701196565276318876743"), }, "log_500000(0.0001) = -0.701881216598197542030218906945601429": { - initialValue: osmomath.NewDecWithPrec(1, 4), + initialValue: osmomath.NewBigDecWithPrec(1, 4), base: osmomath.NewBigDec(500000), // From: https://www.wolframalpha.com/input?i=log_500000%280.0001%29+to+36+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000000001"), - expected: osmomath.MustNewDecFromStr("-0.701881216598197542030218906945601429"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000001"), + expected: osmomath.MustNewBigDecFromStr("-0.701881216598197542030218906945601429"), }, "log_10000(5000000) = 1.674742501084004701196565276318876743": { initialValue: osmomath.NewBigDec(5000000), base: osmomath.NewBigDec(10000), // From: https://www.wolframalpha.com/input?i=log_10000%285000000%29+to+37+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000000002"), - expected: osmomath.MustNewDecFromStr("1.674742501084004701196565276318876743"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000000002"), + expected: osmomath.MustNewBigDecFromStr("1.674742501084004701196565276318876743"), }, "log_0.123456789(1) = 0": { - initialValue: osmomath.OneDec(), - base: osmomath.MustNewDecFromStr("0.123456789"), + initialValue: osmomath.OneBigDec(), + base: osmomath.MustNewBigDecFromStr("0.123456789"), - expectedErrTolerance: osmomath.ZeroDec(), - expected: osmomath.ZeroDec(), + expectedErrTolerance: osmomath.ZeroBigDec(), + expected: osmomath.ZeroBigDec(), }, "log_1111(1111) = 1": { initialValue: osmomath.NewBigDec(1111), base: osmomath.NewBigDec(1111), - expectedErrTolerance: osmomath.ZeroDec(), - expected: osmomath.OneDec(), + expectedErrTolerance: osmomath.ZeroBigDec(), + expected: osmomath.OneBigDec(), }, "log_1.123{1024.987654321} = 59.760484327223888489694630378785099461": { - initialValue: osmomath.NewDecWithPrec(1024987654321, 9), - base: osmomath.NewDecWithPrec(1123, 3), + initialValue: osmomath.NewBigDecWithPrec(1024987654321, 9), + base: osmomath.NewBigDecWithPrec(1123, 3), // From: https://www.wolframalpha.com/input?i=log_1.123%281024.987654321%29+to+38+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000007686"), - expected: osmomath.MustNewDecFromStr("59.760484327223888489694630378785099461"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000007686"), + expected: osmomath.MustNewBigDecFromStr("59.760484327223888489694630378785099461"), }, "log_1.123{912648174127941279170121098210.92821920190204131121} = 594.689327867863079177915648832621538986": { - initialValue: osmomath.MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), - base: osmomath.NewDecWithPrec(1123, 3), + initialValue: osmomath.MustNewBigDecFromStr("912648174127941279170121098210.92821920190204131121"), + base: osmomath.NewBigDecWithPrec(1123, 3), // From: https://www.wolframalpha.com/input?i=log_1.123%28912648174127941279170121098210.92821920190204131121%29+to+39+digits - expectedErrTolerance: osmomath.MustNewDecFromStr("0.000000000000000000000000000000077705"), - expected: osmomath.MustNewDecFromStr("594.689327867863079177915648832621538986"), + expectedErrTolerance: osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000077705"), + expected: osmomath.MustNewBigDecFromStr("594.689327867863079177915648832621538986"), }, } for name, tc := range tests { @@ -1114,7 +1115,7 @@ func (s *decimalTestSuite) TestCustomBaseLog() { } func (s *decimalTestSuite) TestPowerInteger() { - var expectedErrTolerance = osmomath.MustNewDecFromStr("0.000000000000000000000000000000100000") + var expectedErrTolerance = osmomath.MustNewBigDecFromStr("0.000000000000000000000000000000100000") tests := map[string]struct { base osmomath.BigDec @@ -1124,78 +1125,78 @@ func (s *decimalTestSuite) TestPowerInteger() { expectedToleranceOverwrite osmomath.BigDec }{ "0^2": { - base: osmomath.ZeroDec(), + base: osmomath.ZeroBigDec(), exponent: 2, - expectedResult: osmomath.ZeroDec(), + expectedResult: osmomath.ZeroBigDec(), }, "1^2": { - base: osmomath.OneDec(), + base: osmomath.OneBigDec(), exponent: 2, - expectedResult: osmomath.OneDec(), + expectedResult: osmomath.OneBigDec(), }, "4^4": { - base: osmomath.MustNewDecFromStr("4"), + base: osmomath.MustNewBigDecFromStr("4"), exponent: 4, - expectedResult: osmomath.MustNewDecFromStr("256"), + expectedResult: osmomath.MustNewBigDecFromStr("256"), }, "5^3": { - base: osmomath.MustNewDecFromStr("5"), + base: osmomath.MustNewBigDecFromStr("5"), exponent: 4, - expectedResult: osmomath.MustNewDecFromStr("625"), + expectedResult: osmomath.MustNewBigDecFromStr("625"), }, "e^10": { base: osmomath.EulersNumber, exponent: 10, // https://www.wolframalpha.com/input?i=e%5E10+41+digits - expectedResult: osmomath.MustNewDecFromStr("22026.465794806716516957900645284244366354"), + expectedResult: osmomath.MustNewBigDecFromStr("22026.465794806716516957900645284244366354"), }, "geom twap overflow: 2^log_2{max spot price + 1}": { base: osmomath.TwoBigDec, // add 1 for simplicity of calculation to isolate overflow. - exponent: uint64(osmomath.BigDecFromSDKDec(osmomath.MaxSpotPrice).Add(osmomath.OneDec()).LogBase2().TruncateInt().Uint64()), + exponent: uint64(osmomath.BigDecFromDec(osmomath.MaxSpotPrice).Add(osmomath.OneBigDec()).LogBase2().TruncateInt().Uint64()), // https://www.wolframalpha.com/input?i=2%5E%28floor%28+log+base+2+%282%5E128%29%29%29+++39+digits - expectedResult: osmomath.MustNewDecFromStr("340282366920938463463374607431768211456"), + expectedResult: osmomath.MustNewBigDecFromStr("340282366920938463463374607431768211456"), }, "geom twap overflow: 2^log_2{max spot price}": { base: osmomath.TwoBigDec, - exponent: uint64(osmomath.BigDecFromSDKDec(osmomath.MaxSpotPrice).LogBase2().TruncateInt().Uint64()), + exponent: uint64(osmomath.BigDecFromDec(osmomath.MaxSpotPrice).LogBase2().TruncateInt().Uint64()), // https://www.wolframalpha.com/input?i=2%5E%28floor%28+log+base+2+%282%5E128+-+1%29%29%29+++39+digits - expectedResult: osmomath.MustNewDecFromStr("170141183460469231731687303715884105728"), + expectedResult: osmomath.MustNewBigDecFromStr("170141183460469231731687303715884105728"), }, "geom twap overflow: 2^log_2{max spot price / 2 - 2017}": { // 2017 is prime. base: osmomath.TwoBigDec, - exponent: uint64(osmomath.BigDecFromSDKDec(osmomath.MaxSpotPrice.Quo(sdk.NewDec(2)).Sub(sdk.NewDec(2017))).LogBase2().TruncateInt().Uint64()), + exponent: uint64(osmomath.BigDecFromDec(osmomath.MaxSpotPrice.Quo(osmomath.NewDec(2)).Sub(osmomath.NewDec(2017))).LogBase2().TruncateInt().Uint64()), // https://www.wolframalpha.com/input?i=e%5E10+41+digits - expectedResult: osmomath.MustNewDecFromStr("85070591730234615865843651857942052864"), + expectedResult: osmomath.MustNewBigDecFromStr("85070591730234615865843651857942052864"), }, - // sdk.Dec test vectors copied from osmosis-labs/cosmos-sdk: + // osmomath.Dec test vectors copied from osmosis-labs/cosmos-sdk: "1.0 ^ (10) => 1.0": { - base: osmomath.OneDec(), + base: osmomath.OneBigDec(), exponent: 10, - expectedResult: osmomath.OneDec(), + expectedResult: osmomath.OneBigDec(), }, "0.5 ^ 2 => 0.25": { - base: osmomath.NewDecWithPrec(5, 1), + base: osmomath.NewBigDecWithPrec(5, 1), exponent: 2, - expectedResult: osmomath.NewDecWithPrec(25, 2), + expectedResult: osmomath.NewBigDecWithPrec(25, 2), }, "0.2 ^ 2 => 0.04": { - base: osmomath.NewDecWithPrec(2, 1), + base: osmomath.NewBigDecWithPrec(2, 1), exponent: 2, - expectedResult: osmomath.NewDecWithPrec(4, 2), + expectedResult: osmomath.NewBigDecWithPrec(4, 2), }, "3 ^ 3 => 27": { base: osmomath.NewBigDec(3), @@ -1213,20 +1214,20 @@ func (s *decimalTestSuite) TestPowerInteger() { base: osmomath.NewBigDec(-3), exponent: 50, - expectedResult: osmomath.MustNewDecFromStr("717897987691852588770249"), + expectedResult: osmomath.MustNewBigDecFromStr("717897987691852588770249"), }, "-3 ^ 51 = -2153693963075557766310747": { base: osmomath.NewBigDec(-3), exponent: 51, - expectedResult: osmomath.MustNewDecFromStr("-2153693963075557766310747"), + expectedResult: osmomath.MustNewBigDecFromStr("-2153693963075557766310747"), }, "1.414213562373095049 ^ 2 = 2": { - base: osmomath.NewDecWithPrec(1414213562373095049, 18), + base: osmomath.NewBigDecWithPrec(1414213562373095049, 18), exponent: 2, expectedResult: osmomath.NewBigDec(2), - expectedToleranceOverwrite: osmomath.MustNewDecFromStr("0.0000000000000000006"), + expectedToleranceOverwrite: osmomath.MustNewBigDecFromStr("0.0000000000000000006"), }, } @@ -1248,7 +1249,7 @@ func (s *decimalTestSuite) TestPowerInteger() { // positive integer, we also test Power(). // Negative exponent and base are not supported for Power() if tc.exponent >= 0 && !tc.base.IsNegative() { - actualResult2 := tc.base.Power(osmomath.NewDecFromInt(osmomath.NewIntFromUint64(tc.exponent))) + actualResult2 := tc.base.Power(osmomath.NewBigDecFromInt(osmomath.NewBigIntFromUint64(tc.exponent))) require.True(osmomath.DecApproxEq(s.T(), tc.expectedResult, actualResult2, tolerance)) } }) @@ -1260,13 +1261,13 @@ func (s *decimalTestSuite) TestClone() { startValue osmomath.BigDec }{ "1.1": { - startValue: osmomath.MustNewDecFromStr("1.1"), + startValue: osmomath.MustNewBigDecFromStr("1.1"), }, "-3": { - startValue: osmomath.MustNewDecFromStr("-3"), + startValue: osmomath.MustNewBigDecFromStr("-3"), }, "0": { - startValue: osmomath.MustNewDecFromStr("-3"), + startValue: osmomath.MustNewBigDecFromStr("-3"), }, } @@ -1289,23 +1290,23 @@ func (s *decimalTestSuite) TestClone() { // while Mut is not. func (s *decimalTestSuite) TestMul_Mutation() { - mulBy := osmomath.MustNewDecFromStr("2") + mulBy := osmomath.MustNewBigDecFromStr("2") tests := map[string]struct { startValue osmomath.BigDec expectedMulResult osmomath.BigDec }{ "1.1": { - startValue: osmomath.MustNewDecFromStr("1.1"), - expectedMulResult: osmomath.MustNewDecFromStr("2.2"), + startValue: osmomath.MustNewBigDecFromStr("1.1"), + expectedMulResult: osmomath.MustNewBigDecFromStr("2.2"), }, "-3": { - startValue: osmomath.MustNewDecFromStr("-3"), - expectedMulResult: osmomath.MustNewDecFromStr("-6"), + startValue: osmomath.MustNewBigDecFromStr("-3"), + expectedMulResult: osmomath.MustNewBigDecFromStr("-6"), }, "0": { - startValue: osmomath.ZeroDec(), - expectedMulResult: osmomath.ZeroDec(), + startValue: osmomath.ZeroBigDec(), + expectedMulResult: osmomath.ZeroBigDec(), }, } @@ -1334,20 +1335,20 @@ func (s *decimalTestSuite) TestPowerInteger_Mutation() { expectedResult osmomath.BigDec }{ "1": { - startValue: osmomath.OneDec(), - expectedResult: osmomath.OneDec(), + startValue: osmomath.OneBigDec(), + expectedResult: osmomath.OneBigDec(), }, "-3": { - startValue: osmomath.MustNewDecFromStr("-3"), - expectedResult: osmomath.MustNewDecFromStr("9"), + startValue: osmomath.MustNewBigDecFromStr("-3"), + expectedResult: osmomath.MustNewBigDecFromStr("9"), }, "0": { - startValue: osmomath.ZeroDec(), - expectedResult: osmomath.ZeroDec(), + startValue: osmomath.ZeroBigDec(), + expectedResult: osmomath.ZeroBigDec(), }, "4": { - startValue: osmomath.MustNewDecFromStr("4.5"), - expectedResult: osmomath.MustNewDecFromStr("20.25"), + startValue: osmomath.MustNewBigDecFromStr("4.5"), + expectedResult: osmomath.MustNewBigDecFromStr("20.25"), }, } @@ -1384,11 +1385,11 @@ func (s *decimalTestSuite) TestPower() { errTolerance: zeroAdditiveErrTolerance, }, "2^0.5 (base of 2 and non-integer exponent)": { - base: osmomath.MustNewDecFromStr("2"), - exponent: osmomath.MustNewDecFromStr("0.5"), + base: osmomath.MustNewBigDecFromStr("2"), + exponent: osmomath.MustNewBigDecFromStr("0.5"), // https://www.wolframalpha.com/input?i=2%5E0.5+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.414213562373095048801688724209698079"), + expectedResult: osmomath.MustNewBigDecFromStr("1.414213562373095048801688724209698079"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -1396,11 +1397,11 @@ func (s *decimalTestSuite) TestPower() { }, }, "3^0.33 (integer base other than 2 and non-integer exponent)": { - base: osmomath.MustNewDecFromStr("3"), - exponent: osmomath.MustNewDecFromStr("0.33"), + base: osmomath.MustNewBigDecFromStr("3"), + exponent: osmomath.MustNewBigDecFromStr("0.33"), // https://www.wolframalpha.com/input?i=3%5E0.33+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.436977652184851654252692986409357265"), + expectedResult: osmomath.MustNewBigDecFromStr("1.436977652184851654252692986409357265"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -1409,10 +1410,10 @@ func (s *decimalTestSuite) TestPower() { }, "e^0.98999 (non-integer base and non-integer exponent)": { base: osmomath.EulersNumber, - exponent: osmomath.MustNewDecFromStr("0.9899"), + exponent: osmomath.MustNewBigDecFromStr("0.9899"), // https://www.wolframalpha.com/input?i=e%5E0.9899+37+digits - expectedResult: osmomath.MustNewDecFromStr("2.690965362357751196751808686902156603"), + expectedResult: osmomath.MustNewBigDecFromStr("2.690965362357751196751808686902156603"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -1421,10 +1422,10 @@ func (s *decimalTestSuite) TestPower() { }, "10^0.001 (small non-integer exponent)": { base: osmomath.NewBigDec(10), - exponent: osmomath.MustNewDecFromStr("0.001"), + exponent: osmomath.MustNewBigDecFromStr("0.001"), // https://www.wolframalpha.com/input?i=10%5E0.001+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.002305238077899671915404889328110554"), + expectedResult: osmomath.MustNewBigDecFromStr("1.002305238077899671915404889328110554"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -1433,10 +1434,10 @@ func (s *decimalTestSuite) TestPower() { }, "13^100.7777 (large non-integer exponent)": { base: osmomath.NewBigDec(13), - exponent: osmomath.MustNewDecFromStr("100.7777"), + exponent: osmomath.MustNewBigDecFromStr("100.7777"), // https://www.wolframalpha.com/input?i=13%5E100.7777+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.822422110233759706998600329118969132").Mul(osmomath.NewBigDec(10).PowerInteger(112)), + expectedResult: osmomath.MustNewBigDecFromStr("1.822422110233759706998600329118969132").Mul(osmomath.NewBigDec(10).PowerInteger(112)), errTolerance: osmomath.ErrTolerance{ MultiplicativeTolerance: minDecTolerance, @@ -1444,26 +1445,26 @@ func (s *decimalTestSuite) TestPower() { }, }, "large non-integer exponent with large non-integer base - panics": { - base: osmomath.MustNewDecFromStr("169.137"), - exponent: osmomath.MustNewDecFromStr("100.7777"), + base: osmomath.MustNewBigDecFromStr("169.137"), + exponent: osmomath.MustNewBigDecFromStr("100.7777"), expectPanic: true, }, "negative base - panic": { base: osmomath.NewBigDec(-3), - exponent: osmomath.MustNewDecFromStr("4"), + exponent: osmomath.MustNewBigDecFromStr("4"), expectPanic: true, }, "negative exponent - panic": { base: osmomath.NewBigDec(1), - exponent: osmomath.MustNewDecFromStr("-4"), + exponent: osmomath.MustNewBigDecFromStr("-4"), expectPanic: true, }, "base < 1 - panic (see godoc)": { - base: osmomath.NewBigDec(1).Sub(osmomath.SmallestDec()), - exponent: osmomath.OneDec(), + base: osmomath.NewBigDec(1).Sub(osmomath.SmallestBigDec()), + exponent: osmomath.OneBigDec(), expectPanic: true, }, diff --git a/osmomath/exp2.go b/osmomath/exp2.go index 39b2333ebd3..7379741ae9a 100644 --- a/osmomath/exp2.go +++ b/osmomath/exp2.go @@ -6,31 +6,31 @@ var ( // Truncated at precision end. // See scripts/approximations/main.py exponent_approximation_choice function for details. numeratorCoefficients13Param = []BigDec{ - MustNewDecFromStr("1.000000000000000000000044212244679434"), - MustNewDecFromStr("0.352032455817400196452603772766844426"), - MustNewDecFromStr("0.056507868883666405413116800969512484"), - MustNewDecFromStr("0.005343900728213034434757419480319916"), - MustNewDecFromStr("0.000317708814342353603087543715930732"), - MustNewDecFromStr("0.000011429747507407623028722262874632"), - MustNewDecFromStr("0.000000198381965651614980168744540366"), + MustNewBigDecFromStr("1.000000000000000000000044212244679434"), + MustNewBigDecFromStr("0.352032455817400196452603772766844426"), + MustNewBigDecFromStr("0.056507868883666405413116800969512484"), + MustNewBigDecFromStr("0.005343900728213034434757419480319916"), + MustNewBigDecFromStr("0.000317708814342353603087543715930732"), + MustNewBigDecFromStr("0.000011429747507407623028722262874632"), + MustNewBigDecFromStr("0.000000198381965651614980168744540366"), } // Rounded up at precision end. // See scripts/approximations/main.py exponent_approximation_choice function for details. denominatorCoefficients13Param = []BigDec{ - OneDec(), - MustNewDecFromStr("0.341114724742545112949699755780593311").Neg(), - MustNewDecFromStr("0.052724071627342653404436933178482287"), - MustNewDecFromStr("0.004760950735524957576233524801866342").Neg(), - MustNewDecFromStr("0.000267168475410566529819971616894193"), - MustNewDecFromStr("0.000008923715368802211181557353097439").Neg(), - MustNewDecFromStr("0.000000140277233177373698516010555916"), + OneBigDec(), + MustNewBigDecFromStr("0.341114724742545112949699755780593311").Neg(), + MustNewBigDecFromStr("0.052724071627342653404436933178482287"), + MustNewBigDecFromStr("0.004760950735524957576233524801866342").Neg(), + MustNewBigDecFromStr("0.000267168475410566529819971616894193"), + MustNewBigDecFromStr("0.000008923715368802211181557353097439").Neg(), + MustNewBigDecFromStr("0.000000140277233177373698516010555916"), } // maxSupportedExponent = 2^10. The value is chosen by benchmarking // when the underlying internal functions overflow. // If needed in the future, Exp2 can be reimplemented to allow for greater exponents. - maxSupportedExponent = MustNewDecFromStr("2").PowerInteger(9) + maxSupportedExponent = MustNewBigDecFromStr("2").PowerInteger(9) ) // Exp2 takes 2 to the power of a given non-negative decimal exponent @@ -77,19 +77,19 @@ func Exp2(exponent BigDec) BigDec { // Note: our Python script plots show accuracy up to a factor of 10^22. // However, in Go tests we only test up to 10^18. Therefore, this is the guarantee. func exp2ChebyshevRationalApprox(x BigDec) BigDec { - if x.LT(ZeroDec()) || x.GT(OneDec()) { + if x.LT(ZeroBigDec()) || x.GT(OneBigDec()) { panic(fmt.Sprintf("exponent must be in the range [0, 1], got %s", x)) } if x.IsZero() { - return OneDec() + return OneBigDec() } - if x.Equal(OneDec()) { + if x.Equal(OneBigDec()) { return twoBigDec } h_x := numeratorCoefficients13Param[0].Clone() p_x := denominatorCoefficients13Param[0].Clone() - x_exp_i := OneDec() + x_exp_i := OneBigDec() for i := 1; i < len(numeratorCoefficients13Param); i++ { x_exp_i.MulMut(x) diff --git a/osmomath/exp2_test.go b/osmomath/exp2_test.go index 0d62bcb3a73..7091402e63d 100644 --- a/osmomath/exp2_test.go +++ b/osmomath/exp2_test.go @@ -3,15 +3,14 @@ package osmomath_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/osmosis-labs/osmosis/osmomath" ) var ( - // minDecTolerance minimum tolerance for sdk.Dec, given its precision of 18. - minDecTolerance = sdk.MustNewDecFromStr("0.000000000000000001") + // minDecTolerance minimum tolerance for Dec, given its precision of 18. + minDecTolerance = osmomath.MustNewDecFromStr("0.000000000000000001") ) func TestExp2ChebyshevRationalApprox(t *testing.T) { @@ -23,8 +22,8 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { // // Chebyshev approximation should be able to handle this better. // Tests at the boundaries help to validate there is no Runge's phenomenon. - smallValue := osmomath.MustNewDecFromStr("0.00001") - smallerValue := osmomath.MustNewDecFromStr("0.00000000000000000001") + smallValue := osmomath.MustNewBigDecFromStr("0.00001") + smallerValue := osmomath.MustNewBigDecFromStr("0.00000000000000000001") tests := map[string]struct { exponent osmomath.BigDec @@ -33,9 +32,9 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { expectPanic bool }{ "exp2(0.5)": { - exponent: osmomath.MustNewDecFromStr("0.5"), + exponent: osmomath.MustNewBigDecFromStr("0.5"), // https://www.wolframalpha.com/input?i=2%5E0.5+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.414213562373095048801688724209698079"), + expectedResult: osmomath.MustNewBigDecFromStr("1.414213562373095048801688724209698079"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -44,29 +43,29 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { }, }, "exp2(0)": { - exponent: osmomath.ZeroDec(), - expectedResult: osmomath.OneDec(), + exponent: osmomath.ZeroBigDec(), + expectedResult: osmomath.OneBigDec(), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.ZeroDec(), - MultiplicativeTolerance: sdk.ZeroDec(), + AdditiveTolerance: osmomath.ZeroDec(), + MultiplicativeTolerance: osmomath.ZeroDec(), RoundingDir: osmomath.RoundDown, }, }, "exp2(1)": { - exponent: osmomath.OneDec(), - expectedResult: osmomath.MustNewDecFromStr("2"), + exponent: osmomath.OneBigDec(), + expectedResult: osmomath.MustNewBigDecFromStr("2"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.ZeroDec(), - MultiplicativeTolerance: sdk.ZeroDec(), + AdditiveTolerance: osmomath.ZeroDec(), + MultiplicativeTolerance: osmomath.ZeroDec(), RoundingDir: osmomath.RoundDown, }, }, "exp2(0.00001)": { exponent: smallValue, // https://www.wolframalpha.com/input?i=2%5E0.00001+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.000006931495828305653209089800561681"), + expectedResult: osmomath.MustNewBigDecFromStr("1.000006931495828305653209089800561681"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -75,20 +74,20 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { }, }, "exp2(0.99999)": { - exponent: osmomath.OneDec().Sub(smallValue), + exponent: osmomath.OneBigDec().Sub(smallValue), // https://www.wolframalpha.com/input?i=2%5E0.99999+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.999986137104433991477606830496602898"), + expectedResult: osmomath.MustNewBigDecFromStr("1.999986137104433991477606830496602898"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.00000000000000007"), - MultiplicativeTolerance: minDecTolerance.Mul(sdk.NewDec(100)), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.00000000000000007"), + MultiplicativeTolerance: minDecTolerance.Mul(osmomath.NewDec(100)), RoundingDir: osmomath.RoundDown, }, }, "exp2(0.99999...)": { - exponent: osmomath.OneDec().Sub(smallerValue), + exponent: osmomath.OneBigDec().Sub(smallerValue), // https://www.wolframalpha.com/input?i=2%5E%281+-+0.00000000000000000001%29+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.999999999999999999986137056388801094"), + expectedResult: osmomath.MustNewBigDecFromStr("1.999999999999999999986137056388801094"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -97,9 +96,9 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { }, }, "exp2(0.0000...1)": { - exponent: osmomath.ZeroDec().Add(smallerValue), + exponent: osmomath.ZeroBigDec().Add(smallerValue), // https://www.wolframalpha.com/input?i=2%5E0.00000000000000000001+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.000000000000000000006931471805599453"), + expectedResult: osmomath.MustNewBigDecFromStr("1.000000000000000000006931471805599453"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -108,31 +107,31 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { }, }, "exp2(0.3334567)": { - exponent: osmomath.MustNewDecFromStr("0.3334567"), + exponent: osmomath.MustNewBigDecFromStr("0.3334567"), // https://www.wolframalpha.com/input?i=2%5E0.3334567+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.260028791934303989065848870753742298"), + expectedResult: osmomath.MustNewBigDecFromStr("1.260028791934303989065848870753742298"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.00000000000000007"), - MultiplicativeTolerance: minDecTolerance.Mul(sdk.NewDec(10)), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.00000000000000007"), + MultiplicativeTolerance: minDecTolerance.Mul(osmomath.NewDec(10)), RoundingDir: osmomath.RoundDown, }, }, "exp2(0.84864288)": { - exponent: osmomath.MustNewDecFromStr("0.84864288"), + exponent: osmomath.MustNewBigDecFromStr("0.84864288"), // https://www.wolframalpha.com/input?i=2%5E0.84864288+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.800806138872630518880998772777747572"), + expectedResult: osmomath.MustNewBigDecFromStr("1.800806138872630518880998772777747572"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.00000000000000002"), - MultiplicativeTolerance: minDecTolerance.Mul(sdk.NewDec(10)), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.00000000000000002"), + MultiplicativeTolerance: minDecTolerance.Mul(osmomath.NewDec(10)), RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(0.999999999999999999999999999999999956)": { - exponent: osmomath.MustNewDecFromStr("0.999999999999999999999999999999999956"), + exponent: osmomath.MustNewBigDecFromStr("0.999999999999999999999999999999999956"), // https://www.wolframalpha.com/input?i=2%5E0.999999999999999999999999999999999956+37+digits - expectedResult: osmomath.MustNewDecFromStr("1.999999999999999999999999999999999939"), + expectedResult: osmomath.MustNewBigDecFromStr("1.999999999999999999999999999999999939"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -142,11 +141,11 @@ func TestExp2ChebyshevRationalApprox(t *testing.T) { }, // out of bounds. "exponent < 0 - panic": { - exponent: osmomath.ZeroDec().Sub(smallValue), + exponent: osmomath.ZeroBigDec().Sub(smallValue), expectPanic: true, }, "exponent > 1 - panic": { - exponent: osmomath.OneDec().Add(smallValue), + exponent: osmomath.OneBigDec().Add(smallValue), expectPanic: true, }, } @@ -177,9 +176,9 @@ func TestExp2(t *testing.T) { expectPanic bool }{ "exp2(28.5)": { - exponent: osmomath.MustNewDecFromStr("28.5"), + exponent: osmomath.MustNewBigDecFromStr("28.5"), // https://www.wolframalpha.com/input?i=2%5E%2828.5%29+45+digits - expectedResult: osmomath.MustNewDecFromStr("379625062.497006211556423566253288543343173698"), + expectedResult: osmomath.MustNewBigDecFromStr("379625062.497006211556423566253288543343173698"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, @@ -188,94 +187,94 @@ func TestExp2(t *testing.T) { }, }, "exp2(63.84864288)": { - exponent: osmomath.MustNewDecFromStr("63.84864288"), + exponent: osmomath.MustNewBigDecFromStr("63.84864288"), // https://www.wolframalpha.com/input?i=2%5E%2863.84864288%29+56+digits - expectedResult: osmomath.MustNewDecFromStr("16609504985074238416.013387053450559984846024066925604094"), + expectedResult: osmomath.MustNewBigDecFromStr("16609504985074238416.013387053450559984846024066925604094"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.00042"), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.00042"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(64.5)": { - exponent: osmomath.MustNewDecFromStr("64.5"), + exponent: osmomath.MustNewBigDecFromStr("64.5"), // https://www.wolframalpha.com/input?i=2%5E%2864.5%29+56+digits - expectedResult: osmomath.MustNewDecFromStr("26087635650665564424.699143612505016737766552579185717157"), + expectedResult: osmomath.MustNewBigDecFromStr("26087635650665564424.699143612505016737766552579185717157"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.000000000000000008"), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.000000000000000008"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(80.5)": { - exponent: osmomath.MustNewDecFromStr("80.5"), + exponent: osmomath.MustNewBigDecFromStr("80.5"), // https://www.wolframalpha.com/input?i=2%5E%2880.5%29+61+digits - expectedResult: osmomath.MustNewDecFromStr("1709679290002018430137083.075789128776926268789829515159631571"), + expectedResult: osmomath.MustNewBigDecFromStr("1709679290002018430137083.075789128776926268789829515159631571"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.0000000000006"), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.0000000000006"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(100.5)": { - exponent: osmomath.MustNewDecFromStr("100.5"), + exponent: osmomath.MustNewBigDecFromStr("100.5"), // https://www.wolframalpha.com/input?i=2%5E%28100.5%29+67+digits - expectedResult: osmomath.MustNewDecFromStr("1792728671193156477399422023278.661496394239222564273688025833797661"), + expectedResult: osmomath.MustNewBigDecFromStr("1792728671193156477399422023278.661496394239222564273688025833797661"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("0.0000006"), + AdditiveTolerance: osmomath.MustNewDecFromStr("0.0000006"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(128.5)": { - exponent: osmomath.MustNewDecFromStr("128.5"), + exponent: osmomath.MustNewBigDecFromStr("128.5"), // https://www.wolframalpha.com/input?i=2%5E%28128.5%29+75+digits - expectedResult: osmomath.MustNewDecFromStr("481231938336009023090067544955250113854.229961482126296754016435255422777776"), + expectedResult: osmomath.MustNewBigDecFromStr("481231938336009023090067544955250113854.229961482126296754016435255422777776"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("146.5"), + AdditiveTolerance: osmomath.MustNewDecFromStr("146.5"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "exp2(127.999999999999999999999999999999999999)": { - exponent: osmomath.MustNewDecFromStr("127.999999999999999999999999999999999999"), + exponent: osmomath.MustNewBigDecFromStr("127.999999999999999999999999999999999999"), // https://www.wolframalpha.com/input?i=2%5E%28127.999999999999999999999999999999999999%29+75+digits - expectedResult: osmomath.MustNewDecFromStr("340282366920938463463374607431768211220.134236774486705862055857235845515682"), + expectedResult: osmomath.MustNewBigDecFromStr("340282366920938463463374607431768211220.134236774486705862055857235845515682"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("15044647266406936"), + AdditiveTolerance: osmomath.MustNewDecFromStr("15044647266406936"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundDown, }, }, "exp2(127.84864288)": { - exponent: osmomath.MustNewDecFromStr("127.84864288"), + exponent: osmomath.MustNewBigDecFromStr("127.84864288"), // https://www.wolframalpha.com/input?i=2%5E%28127.84864288%29+75+digits - expectedResult: osmomath.MustNewDecFromStr("306391287650667462068703337664945630660.398687487527674545778353588077174571"), + expectedResult: osmomath.MustNewBigDecFromStr("306391287650667462068703337664945630660.398687487527674545778353588077174571"), errTolerance: osmomath.ErrTolerance{ - AdditiveTolerance: sdk.MustNewDecFromStr("7707157415597963"), + AdditiveTolerance: osmomath.MustNewDecFromStr("7707157415597963"), MultiplicativeTolerance: minDecTolerance, RoundingDir: osmomath.RoundUnconstrained, }, }, "panic, too large - positive": { - exponent: osmomath.MaxSupportedExponent.Add(osmomath.OneDec()), + exponent: osmomath.MaxSupportedExponent.Add(osmomath.OneBigDec()), expectPanic: true, }, "panic - negative exponent": { - exponent: osmomath.OneDec().Neg(), + exponent: osmomath.OneBigDec().Neg(), expectPanic: true, }, "at exponent boundary - positive": { exponent: osmomath.MaxSupportedExponent, // https://www.wolframalpha.com/input?i=2%5E%282%5E9%29 - expectedResult: osmomath.MustNewDecFromStr("13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096"), + expectedResult: osmomath.MustNewBigDecFromStr("13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096"), errTolerance: osmomath.ErrTolerance{ AdditiveTolerance: minDecTolerance, diff --git a/osmomath/export_test.go b/osmomath/export_test.go index d723e106095..011582aeef4 100644 --- a/osmomath/export_test.go +++ b/osmomath/export_test.go @@ -3,7 +3,6 @@ package osmomath import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -17,7 +16,7 @@ var ( // but we can't directly import that due to import cycles. // Hence we use the same var name, in hopes that if any change there happens, // this is caught via a CTRL+F -var MaxSpotPrice = sdk.NewDec(2).Power(128).Sub(sdk.OneDec()) +var MaxSpotPrice = NewDec(2).Power(128).Sub(OneDec()) // ConditionalPanic checks if expectPanic is true, asserts that sut (system under test) // panics. If expectPanic is false, asserts that sut does not panic. diff --git a/osmomath/go.mod b/osmomath/go.mod index 196cc2b029c..1453a486634 100644 --- a/osmomath/go.mod +++ b/osmomath/go.mod @@ -3,7 +3,8 @@ module github.com/osmosis-labs/osmosis/osmomath go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.4 + cosmossdk.io/math v1.1.3-rc.0 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/stretchr/testify v1.8.4 gopkg.in/yaml.v2 v2.4.0 ) @@ -79,6 +80,7 @@ require ( go.etcd.io/bbolt v1.3.6 // indirect go.opencensus.io v0.24.0 // indirect golang.org/x/crypto v0.12.0 // indirect + golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect @@ -92,8 +94,8 @@ require ( ) replace ( - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // use cosmos-compatible protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.24 diff --git a/osmomath/go.sum b/osmomath/go.sum index 826ec7160ab..403f76d828c 100644 --- a/osmomath/go.sum +++ b/osmomath/go.sum @@ -34,6 +34,7 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= 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= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -138,6 +139,7 @@ github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+ github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 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-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= @@ -299,8 +301,8 @@ github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vv github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= -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/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= +github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= @@ -425,6 +427,7 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -435,6 +438,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -495,6 +500,7 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -564,6 +570,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -575,6 +582,7 @@ golang.org/x/text v0.3.4/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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= 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= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -694,8 +702,11 @@ 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-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= 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= @@ -711,6 +722,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.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= @@ -742,3 +754,4 @@ honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= diff --git a/osmomath/int.go b/osmomath/int.go index c3ae4ef288e..8bd3422373c 100644 --- a/osmomath/int.go +++ b/osmomath/int.go @@ -90,21 +90,21 @@ func (i BigInt) IsNil() bool { return i.i == nil } -// NewInt constructs Int from int64 -func NewInt(n int64) BigInt { +// NewBigInt constructs Int from int64 +func NewBigInt(n int64) BigInt { return BigInt{big.NewInt(n)} } -// NewIntFromUint64 constructs an Int from a uint64. -func NewIntFromUint64(n uint64) BigInt { +// NewBigIntFromUint64 constructs an Int from a uint64. +func NewBigIntFromUint64(n uint64) BigInt { b := big.NewInt(0) b.SetUint64(n) return BigInt{b} } -// NewIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil, +// NewBigIntFromBigInt constructs Int from big.Int. If the provided big.Int is nil, // it returns an empty instance. This function panics if the bit length is > 256. -func NewIntFromBigInt(i *big.Int) BigInt { +func NewBigIntFromBigInt(i *big.Int) BigInt { if i == nil { return BigInt{} } @@ -115,8 +115,8 @@ func NewIntFromBigInt(i *big.Int) BigInt { return BigInt{i} } -// NewIntFromString constructs Int from string -func NewIntFromString(s string) (res BigInt, ok bool) { +// NewBigIntFromString constructs Int from string +func NewBigIntFromString(s string) (res BigInt, ok bool) { i, ok := newIntegerFromString(s) if !ok { return @@ -129,9 +129,9 @@ func NewIntFromString(s string) (res BigInt, ok bool) { return BigInt{i}, true } -// NewIntWithDecimal constructs Int with decimal +// NewBigIntWithDecimal constructs Int with decimal // Result value is n*10^dec -func NewIntWithDecimal(n int64, dec int) BigInt { +func NewBigIntWithDecimal(n int64, dec int) BigInt { if dec < 0 { panic("NewIntWithDecimal() decimal is negative") } @@ -146,15 +146,15 @@ func NewIntWithDecimal(n int64, dec int) BigInt { return BigInt{i} } -// ZeroInt returns Int value with zero -func ZeroInt() BigInt { return BigInt{big.NewInt(0)} } +// ZeroBigInt returns Int value with zero +func ZeroBigInt() BigInt { return BigInt{big.NewInt(0)} } -// OneInt returns Int value with one -func OneInt() BigInt { return BigInt{big.NewInt(1)} } +// OneBigInt returns Int value with one +func OneBigInt() BigInt { return BigInt{big.NewInt(1)} } // ToDec converts Int to Dec func (i BigInt) ToDec() BigDec { - return NewDecFromInt(i) + return NewBigDecFromInt(i) } // Int64 converts Int to int64 @@ -243,7 +243,7 @@ func (i BigInt) Add(i2 BigInt) (res BigInt) { // AddRaw adds int64 to Int func (i BigInt) AddRaw(i2 int64) BigInt { - return i.Add(NewInt(i2)) + return i.Add(NewBigInt(i2)) } // Sub subtracts Int from another @@ -258,7 +258,7 @@ func (i BigInt) Sub(i2 BigInt) (res BigInt) { // SubRaw subtracts int64 from Int func (i BigInt) SubRaw(i2 int64) BigInt { - return i.Sub(NewInt(i2)) + return i.Sub(NewBigInt(i2)) } // Mul multiples two Ints @@ -277,7 +277,7 @@ func (i BigInt) Mul(i2 BigInt) (res BigInt) { // MulRaw multipies Int and int64 func (i BigInt) MulRaw(i2 int64) BigInt { - return i.Mul(NewInt(i2)) + return i.Mul(NewBigInt(i2)) } // Quo divides Int with Int @@ -291,7 +291,7 @@ func (i BigInt) Quo(i2 BigInt) (res BigInt) { // QuoRaw divides Int with int64 func (i BigInt) QuoRaw(i2 int64) BigInt { - return i.Quo(NewInt(i2)) + return i.Quo(NewBigInt(i2)) } // Mod returns remainder after dividing with Int @@ -304,7 +304,7 @@ func (i BigInt) Mod(i2 BigInt) BigInt { // ModRaw returns remainder after dividing with int64 func (i BigInt) ModRaw(i2 int64) BigInt { - return i.Mod(NewInt(i2)) + return i.Mod(NewBigInt(i2)) } // Neg negates Int @@ -318,12 +318,12 @@ func (i BigInt) Abs() BigInt { } // return the minimum of the ints -func MinInt(i1, i2 BigInt) BigInt { +func MinBigInt(i1, i2 BigInt) BigInt { return BigInt{min(i1.BigInt(), i2.BigInt())} } -// MaxInt returns the maximum between two integers. -func MaxInt(i, i2 BigInt) BigInt { +// MaxBigInt returns the maximum between two integers. +func MaxBigInt(i, i2 BigInt) BigInt { return BigInt{max(i.BigInt(), i2.BigInt())} } @@ -435,6 +435,6 @@ func (i BigInt) MarshalAmino() ([]byte, error) { return i.Marshal() } func (i *BigInt) UnmarshalAmino(bz []byte) error { return i.Unmarshal(bz) } // intended to be used with require/assert: require.True(IntEq(...)) -func IntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) { +func BigIntEq(t *testing.T, exp, got BigInt) (*testing.T, bool, string, string, string) { return t, exp.Equal(got), "expected:\t%v\ngot:\t\t%v", exp.String(), got.String() } diff --git a/osmomath/int_test.go b/osmomath/int_test.go index a3e376a95d4..c33e9a48d96 100644 --- a/osmomath/int_test.go +++ b/osmomath/int_test.go @@ -8,8 +8,6 @@ import ( "testing" "github.com/stretchr/testify/suite" - - sdk "github.com/cosmos/cosmos-sdk/types" ) type intTestSuite struct { @@ -27,30 +25,30 @@ func (s *intTestSuite) SetupSuite() { func (s *intTestSuite) TestFromInt64() { for n := 0; n < 20; n++ { r := rand.Int63() - s.Require().Equal(r, NewInt(r).Int64()) + s.Require().Equal(r, NewBigInt(r).Int64()) } } func (s *intTestSuite) TestFromUint64() { for n := 0; n < 20; n++ { r := rand.Uint64() - s.Require().True(NewIntFromUint64(r).IsUint64()) - s.Require().Equal(r, NewIntFromUint64(r).Uint64()) + s.Require().True(NewBigIntFromUint64(r).IsUint64()) + s.Require().Equal(r, NewBigIntFromUint64(r).Uint64()) } } func (s *intTestSuite) TestIntPanic() { // Max Int = 2^1024-1 = 8.988466e+308 // Min Int = -(2^1024-1) = -8.988466e+308 - s.Require().NotPanics(func() { NewIntWithDecimal(4, 307) }) - i1 := NewIntWithDecimal(4, 307) - s.Require().NotPanics(func() { NewIntWithDecimal(5, 307) }) - i2 := NewIntWithDecimal(5, 307) - s.Require().NotPanics(func() { NewIntWithDecimal(92, 306) }) - i3 := NewIntWithDecimal(92, 306) + s.Require().NotPanics(func() { NewBigIntWithDecimal(4, 307) }) + i1 := NewBigIntWithDecimal(4, 307) + s.Require().NotPanics(func() { NewBigIntWithDecimal(5, 307) }) + i2 := NewBigIntWithDecimal(5, 307) + s.Require().NotPanics(func() { NewBigIntWithDecimal(92, 306) }) + i3 := NewBigIntWithDecimal(92, 306) - s.Require().Panics(func() { NewIntWithDecimal(2, 308) }) - s.Require().Panics(func() { NewIntWithDecimal(9, 340) }) + s.Require().Panics(func() { NewBigIntWithDecimal(2, 308) }) + s.Require().Panics(func() { NewBigIntWithDecimal(9, 340) }) // Overflow check s.Require().NotPanics(func() { i1.Add(i1) }) @@ -84,18 +82,18 @@ func (s *intTestSuite) TestIntPanic() { s.Require().Panics(func() { i3.Mul(i3.Neg()) }) // Bound check - intmax := NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(1024), nil), big.NewInt(1))) + intmax := NewBigIntFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(1024), nil), big.NewInt(1))) intmin := intmax.Neg() - s.Require().NotPanics(func() { intmax.Add(ZeroInt()) }) - s.Require().NotPanics(func() { intmin.Sub(ZeroInt()) }) - s.Require().Panics(func() { intmax.Add(OneInt()) }) - s.Require().Panics(func() { intmin.Sub(OneInt()) }) + s.Require().NotPanics(func() { intmax.Add(ZeroBigInt()) }) + s.Require().NotPanics(func() { intmin.Sub(ZeroBigInt()) }) + s.Require().Panics(func() { intmax.Add(OneBigInt()) }) + s.Require().Panics(func() { intmin.Sub(OneBigInt()) }) - s.Require().NotPanics(func() { NewIntFromBigInt(nil) }) - s.Require().True(NewIntFromBigInt(nil).IsNil()) + s.Require().NotPanics(func() { NewBigIntFromBigInt(nil) }) + s.Require().True(NewBigIntFromBigInt(nil).IsNil()) // Division-by-zero check - s.Require().Panics(func() { i1.Quo(NewInt(0)) }) + s.Require().Panics(func() { i1.Quo(NewBigInt(0)) }) s.Require().NotPanics(func() { BigInt{}.BigInt() }) } @@ -107,17 +105,17 @@ func (s *intTestSuite) TestIntPanic() { func (s *intTestSuite) TestIdentInt() { for d := 0; d < 1000; d++ { n := rand.Int63() - i := NewInt(n) + i := NewBigInt(n) - ifromstr, ok := NewIntFromString(strconv.FormatInt(n, 10)) + ifromstr, ok := NewBigIntFromString(strconv.FormatInt(n, 10)) s.Require().True(ok) cases := []int64{ i.Int64(), i.BigInt().Int64(), ifromstr.Int64(), - NewIntFromBigInt(big.NewInt(n)).Int64(), - NewIntWithDecimal(n, 0).Int64(), + NewBigIntFromBigInt(big.NewInt(n)).Int64(), + NewBigIntWithDecimal(n, 0).Int64(), } for tcnum, tc := range cases { @@ -143,9 +141,9 @@ func maxint(i1, i2 int64) int64 { func (s *intTestSuite) TestArithInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := NewInt(n1) + i1 := NewBigInt(n1) n2 := int64(rand.Int31()) - i2 := NewInt(n2) + i2 := NewBigInt(n2) cases := []struct { ires BigInt @@ -159,8 +157,8 @@ func (s *intTestSuite) TestArithInt() { {i1.SubRaw(n2), n1 - n2}, {i1.MulRaw(n2), n1 * n2}, {i1.QuoRaw(n2), n1 / n2}, - {MinInt(i1, i2), minint(n1, n2)}, - {MaxInt(i1, i2), maxint(n1, n2)}, + {MinBigInt(i1, i2), minint(n1, n2)}, + {MaxBigInt(i1, i2), maxint(n1, n2)}, {i1.Neg(), -n1}, {i1.Abs(), n1}, {i1.Neg().Abs(), n1}, @@ -175,9 +173,9 @@ func (s *intTestSuite) TestArithInt() { func (s *intTestSuite) TestCompInt() { for d := 0; d < 1000; d++ { n1 := int64(rand.Int31()) - i1 := NewInt(n1) + i1 := NewBigInt(n1) n2 := int64(rand.Int31()) - i2 := NewInt(n2) + i2 := NewBigInt(n2) cases := []struct { ires bool @@ -196,7 +194,7 @@ func (s *intTestSuite) TestCompInt() { } func randint() BigInt { - return NewInt(rand.Int63()) + return NewBigInt(rand.Int63()) } func (s *intTestSuite) TestImmutabilityAllInt() { @@ -221,13 +219,13 @@ func (s *intTestSuite) TestImmutabilityAllInt() { for i := 0; i < 1000; i++ { n := rand.Int63() - ni := NewInt(n) + ni := NewBigInt(n) for opnum, op := range ops { op(&ni) s.Require().Equal(n, ni.Int64(), "Int is modified by operation. tc #%d", opnum) - s.Require().Equal(NewInt(n), ni, "Int is modified by operation. tc #%d", opnum) + s.Require().Equal(NewBigInt(n), ni, "Int is modified by operation. tc #%d", opnum) } } } @@ -241,47 +239,47 @@ func (s *intTestSuite) TestEncodingTableInt() { rawBz []byte }{ { - NewInt(0), + NewBigInt(0), []byte("\"0\""), []byte{0x30}, }, { - NewInt(100), + NewBigInt(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - NewInt(-100), + NewBigInt(-100), []byte("\"-100\""), []byte{0x2d, 0x31, 0x30, 0x30}, }, { - NewInt(51842), + NewBigInt(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - NewInt(-51842), + NewBigInt(-51842), []byte("\"-51842\""), []byte{0x2d, 0x35, 0x31, 0x38, 0x34, 0x32}, }, { - NewInt(19513368), + NewBigInt(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - NewInt(-19513368), + NewBigInt(-19513368), []byte("\"-19513368\""), []byte{0x2d, 0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - NewInt(999999999999), + NewBigInt(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, { - NewInt(-999999999999), + NewBigInt(-999999999999), []byte("\"-999999999999\""), []byte{0x2d, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -307,35 +305,35 @@ func (s *intTestSuite) TestEncodingTableInt() { } func (s *intTestSuite) TestEncodingTableUint() { - var i sdk.Uint + var i Uint cases := []struct { - i sdk.Uint + i Uint jsonBz []byte rawBz []byte }{ { - sdk.NewUint(0), + NewUint(0), []byte("\"0\""), []byte{0x30}, }, { - sdk.NewUint(100), + NewUint(100), []byte("\"100\""), []byte{0x31, 0x30, 0x30}, }, { - sdk.NewUint(51842), + NewUint(51842), []byte("\"51842\""), []byte{0x35, 0x31, 0x38, 0x34, 0x32}, }, { - sdk.NewUint(19513368), + NewUint(19513368), []byte("\"19513368\""), []byte{0x31, 0x39, 0x35, 0x31, 0x33, 0x33, 0x36, 0x38}, }, { - sdk.NewUint(999999999999), + NewUint(999999999999), []byte("\"999999999999\""), []byte{0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39}, }, @@ -376,19 +374,19 @@ func (s *intTestSuite) TestIntMod() { for _, tt := range tests { if tt.wantPanic { - s.Require().Panics(func() { NewInt(tt.x).Mod(NewInt(tt.y)) }) - s.Require().Panics(func() { NewInt(tt.x).ModRaw(tt.y) }) + s.Require().Panics(func() { NewBigInt(tt.x).Mod(NewBigInt(tt.y)) }) + s.Require().Panics(func() { NewBigInt(tt.x).ModRaw(tt.y) }) return } - s.Require().True(NewInt(tt.x).Mod(NewInt(tt.y)).Equal(NewInt(tt.ret))) - s.Require().True(NewInt(tt.x).ModRaw(tt.y).Equal(NewInt(tt.ret))) + s.Require().True(NewBigInt(tt.x).Mod(NewBigInt(tt.y)).Equal(NewBigInt(tt.ret))) + s.Require().True(NewBigInt(tt.x).ModRaw(tt.y).Equal(NewBigInt(tt.ret))) } } func (s *intTestSuite) TestIntEq() { - _, resp, _, _, _ := IntEq(s.T(), ZeroInt(), ZeroInt()) + _, resp, _, _, _ := BigIntEq(s.T(), ZeroBigInt(), ZeroBigInt()) s.Require().True(resp) - _, resp, _, _, _ = IntEq(s.T(), OneInt(), ZeroInt()) + _, resp, _, _, _ = BigIntEq(s.T(), OneBigInt(), ZeroBigInt()) s.Require().False(resp) } @@ -409,7 +407,7 @@ func TestRoundTripMarshalToInt(t *testing.T) { t.Parallel() var scratch [20]byte - iv := NewInt(value) + iv := NewBigInt(value) n, err := iv.MarshalTo(scratch[:]) if err != nil { t.Fatal(err) @@ -428,7 +426,7 @@ func TestRoundTripMarshalToInt(t *testing.T) { func (s *intTestSuite) TestEncodingRandom() { for i := 0; i < 1000; i++ { n := rand.Int63() - ni := NewInt(n) + ni := NewBigInt(n) var ri BigInt str, err := ni.Marshal() @@ -450,9 +448,9 @@ func (s *intTestSuite) TestEncodingRandom() { for i := 0; i < 1000; i++ { n := rand.Uint64() - ni := sdk.NewUint(n) + ni := NewUint(n) - var ri sdk.Uint + var ri Uint str, err := ni.Marshal() s.Require().Nil(err) diff --git a/osmomath/log2_bench_test.go b/osmomath/log2_bench_test.go index d9fb3626fae..700e1bb73be 100644 --- a/osmomath/log2_bench_test.go +++ b/osmomath/log2_bench_test.go @@ -7,14 +7,14 @@ import ( func BenchmarkLog2(b *testing.B) { tests := []BigDec{ - MustNewDecFromStr("1.2"), - MustNewDecFromStr("1.234"), - MustNewDecFromStr("1024"), + MustNewBigDecFromStr("1.2"), + MustNewBigDecFromStr("1.234"), + MustNewBigDecFromStr("1024"), NewBigDec(2048 * 2048 * 2048 * 2048 * 2048), - MustNewDecFromStr("999999999999999999999999999999999999999999999999999999.9122181273612911"), - MustNewDecFromStr("0.563289239121902491248219047129047129"), - BigDecFromSDKDec(MaxSpotPrice), // 2^128 - 1 - MustNewDecFromStr("336879543251729078828740861357450529340.45"), // (2^128 - 1) * 0.99 + MustNewBigDecFromStr("999999999999999999999999999999999999999999999999999999.9122181273612911"), + MustNewBigDecFromStr("0.563289239121902491248219047129047129"), + BigDecFromDec(MaxSpotPrice), // 2^128 - 1 + MustNewBigDecFromStr("336879543251729078828740861357450529340.45"), // (2^128 - 1) * 0.99 } for i := 0; i < b.N; i++ { diff --git a/osmomath/math.go b/osmomath/math.go index 18a45f171b6..dc6b32bb4f2 100644 --- a/osmomath/math.go +++ b/osmomath/math.go @@ -2,22 +2,20 @@ package osmomath import ( "fmt" - - sdk "github.com/cosmos/cosmos-sdk/types" ) // Don't EVER change after initializing // TODO: Analyze choice here. -var powPrecision, _ = sdk.NewDecFromStr("0.00000001") +var powPrecision, _ = NewDecFromStr("0.00000001") var ( - one_half sdk.Dec = sdk.MustNewDecFromStr("0.5") - one sdk.Dec = sdk.OneDec() - two sdk.Dec = sdk.MustNewDecFromStr("2") + one_half Dec = MustNewDecFromStr("0.5") + one Dec = OneDec() + two Dec = MustNewDecFromStr("2") // https://www.wolframalpha.com/input?i=2.718281828459045235360287471352662498&assumption=%22ClashPrefs%22+-%3E+%7B%22Math%22%7D // nolint: unused - eulersNumber = MustNewDecFromStr("2.718281828459045235360287471352662498") + eulersNumber = MustNewBigDecFromStr("2.718281828459045235360287471352662498") ) // Returns the internal "power precision". @@ -26,7 +24,7 @@ var ( // *technically* the error term can be greater than this powPrecision, // but for small bases this bound applies. See comments in the PowApprox function // for more detail. -func GetPowPrecision() sdk.Dec { +func GetPowPrecision() Dec { return powPrecision.Clone() } @@ -34,7 +32,7 @@ func GetPowPrecision() sdk.Dec { // AbsDifferenceWithSign returns | a - b |, (a - b).sign() // a is mutated and returned. -func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool) { +func AbsDifferenceWithSign(a, b Dec) (Dec, bool) { if a.GTE(b) { return a.SubMut(b), false } else { @@ -42,7 +40,7 @@ func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool) { } } -// func largeBasePow(base sdk.Dec, exp sdk.Dec) sdk.Dec { +// func largeBasePow(base Dec, exp Dec) Dec { // // pow requires the base to be <= 2 // } @@ -50,7 +48,7 @@ func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool) { // However since the exponent is not an integer, we must do an approximation algorithm. // TODO: In the future, lets add some optimized routines for common exponents, e.g. for common wIn / wOut ratios // Many simple exponents like 2:1 pools. -func Pow(base sdk.Dec, exp sdk.Dec) sdk.Dec { +func Pow(base Dec, exp Dec) Dec { // Exponentiation of a negative base with an arbitrary real exponent is not closed within the reals. // You can see this by recalling that `i = (-1)^(.5)`. We have to go to complex numbers to define this. // (And would have to implement complex logarithms) @@ -83,13 +81,13 @@ func Pow(base sdk.Dec, exp sdk.Dec) sdk.Dec { // Contract: 0 < base <= 2 // 0 <= exp < 1. -func PowApprox(base sdk.Dec, exp sdk.Dec, precision sdk.Dec) sdk.Dec { +func PowApprox(base Dec, exp Dec, precision Dec) Dec { if !base.IsPositive() { panic(fmt.Errorf("base must be greater than 0")) } if exp.IsZero() { - return sdk.OneDec() + return OneDec() } // Common case optimization @@ -133,12 +131,12 @@ func PowApprox(base sdk.Dec, exp sdk.Dec, precision sdk.Dec) sdk.Dec { base = base.Clone() x, xneg := AbsDifferenceWithSign(base, one) - term := sdk.OneDec() - sum := sdk.OneDec() + term := OneDec() + sum := OneDec() negative := false a := exp.Clone() - bigK := sdk.NewDec(0) + bigK := NewDec(0) // TODO: Document this computation via taylor expansion for i := int64(1); term.GTE(precision); i++ { // At each iteration, we need two values, i and i-1. @@ -146,7 +144,7 @@ func PowApprox(base sdk.Dec, exp sdk.Dec, precision sdk.Dec) sdk.Dec { // On this line, bigK == i-1. c, cneg := AbsDifferenceWithSign(a, bigK) // On this line, bigK == i. - bigK.Set(sdk.NewDec(i)) // TODO: O(n) bigint allocation happens + bigK.Set(NewDec(i)) // TODO: O(n) bigint allocation happens term.MulMut(c).MulMut(x).QuoMut(bigK) // a is mutated on absDifferenceWithSign, reset diff --git a/osmomath/math_test.go b/osmomath/math_test.go index 742112e5035..7f37bd77c10 100644 --- a/osmomath/math_test.go +++ b/osmomath/math_test.go @@ -4,92 +4,90 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) func TestAbsDifferenceWithSign(t *testing.T) { - decA, err := sdk.NewDecFromStr("3.2") + decA, err := NewDecFromStr("3.2") require.NoError(t, err) - decB, err := sdk.NewDecFromStr("4.3432389") + decB, err := NewDecFromStr("4.3432389") require.NoError(t, err) s, b := AbsDifferenceWithSign(decA, decB) require.True(t, b) - expectedDec, err := sdk.NewDecFromStr("1.1432389") + expectedDec, err := NewDecFromStr("1.1432389") require.NoError(t, err) require.Equal(t, expectedDec, s) } func TestPowApprox(t *testing.T) { testCases := []struct { - base sdk.Dec - exp sdk.Dec - powPrecision sdk.Dec - expectedResult sdk.Dec + base Dec + exp Dec + powPrecision Dec + expectedResult Dec }{ { // medium base, small exp - base: sdk.MustNewDecFromStr("0.8"), - exp: sdk.MustNewDecFromStr("0.32"), - powPrecision: sdk.MustNewDecFromStr("0.00000001"), - expectedResult: sdk.MustNewDecFromStr("0.93108385"), + base: MustNewDecFromStr("0.8"), + exp: MustNewDecFromStr("0.32"), + powPrecision: MustNewDecFromStr("0.00000001"), + expectedResult: MustNewDecFromStr("0.93108385"), }, { // zero exp - base: sdk.MustNewDecFromStr("0.8"), - exp: sdk.ZeroDec(), - powPrecision: sdk.MustNewDecFromStr("0.00001"), - expectedResult: sdk.OneDec(), + base: MustNewDecFromStr("0.8"), + exp: ZeroDec(), + powPrecision: MustNewDecFromStr("0.00001"), + expectedResult: OneDec(), }, { // zero base, this should panic - base: sdk.ZeroDec(), - exp: sdk.OneDec(), - powPrecision: sdk.MustNewDecFromStr("0.00001"), - expectedResult: sdk.ZeroDec(), + base: ZeroDec(), + exp: OneDec(), + powPrecision: MustNewDecFromStr("0.00001"), + expectedResult: ZeroDec(), }, { // large base, small exp - base: sdk.MustNewDecFromStr("1.9999"), - exp: sdk.MustNewDecFromStr("0.23"), - powPrecision: sdk.MustNewDecFromStr("0.000000001"), - expectedResult: sdk.MustNewDecFromStr("1.172821461"), + base: MustNewDecFromStr("1.9999"), + exp: MustNewDecFromStr("0.23"), + powPrecision: MustNewDecFromStr("0.000000001"), + expectedResult: MustNewDecFromStr("1.172821461"), }, { // large base, large integer exp - base: sdk.MustNewDecFromStr("1.777"), - exp: sdk.MustNewDecFromStr("20"), - powPrecision: sdk.MustNewDecFromStr("0.000000000001"), - expectedResult: sdk.MustNewDecFromStr("98570.862372081602"), + base: MustNewDecFromStr("1.777"), + exp: MustNewDecFromStr("20"), + powPrecision: MustNewDecFromStr("0.000000000001"), + expectedResult: MustNewDecFromStr("98570.862372081602"), }, { // medium base, large exp, high precision - base: sdk.MustNewDecFromStr("1.556"), - exp: sdk.MustNewDecFromStr("20.9123"), - powPrecision: sdk.MustNewDecFromStr("0.0000000000000001"), - expectedResult: sdk.MustNewDecFromStr("10360.058421529811344618"), + base: MustNewDecFromStr("1.556"), + exp: MustNewDecFromStr("20.9123"), + powPrecision: MustNewDecFromStr("0.0000000000000001"), + expectedResult: MustNewDecFromStr("10360.058421529811344618"), }, { // high base, large exp, high precision - base: sdk.MustNewDecFromStr("1.886"), - exp: sdk.MustNewDecFromStr("31.9123"), - powPrecision: sdk.MustNewDecFromStr("0.00000000000001"), - expectedResult: sdk.MustNewDecFromStr("621110716.84727942280335811"), + base: MustNewDecFromStr("1.886"), + exp: MustNewDecFromStr("31.9123"), + powPrecision: MustNewDecFromStr("0.00000000000001"), + expectedResult: MustNewDecFromStr("621110716.84727942280335811"), }, { // base equal one - base: sdk.MustNewDecFromStr("1"), - exp: sdk.MustNewDecFromStr("123"), - powPrecision: sdk.MustNewDecFromStr("0.00000001"), - expectedResult: sdk.OneDec(), + base: MustNewDecFromStr("1"), + exp: MustNewDecFromStr("123"), + powPrecision: MustNewDecFromStr("0.00000001"), + expectedResult: OneDec(), }, } for i, tc := range testCases { - var actualResult sdk.Dec + var actualResult Dec ConditionalPanic(t, tc.base.IsZero(), func() { fmt.Println(tc.base) actualResult = PowApprox(tc.base, tc.exp, tc.powPrecision) @@ -104,56 +102,56 @@ func TestPowApprox(t *testing.T) { func TestPow(t *testing.T) { testCases := []struct { - base sdk.Dec - exp sdk.Dec - expectedResult sdk.Dec + base Dec + exp Dec + expectedResult Dec }{ { // medium base, small exp - base: sdk.MustNewDecFromStr("0.8"), - exp: sdk.MustNewDecFromStr("0.32"), - expectedResult: sdk.MustNewDecFromStr("0.93108385"), + base: MustNewDecFromStr("0.8"), + exp: MustNewDecFromStr("0.32"), + expectedResult: MustNewDecFromStr("0.93108385"), }, { // zero exp - base: sdk.MustNewDecFromStr("0.8"), - exp: sdk.ZeroDec(), - expectedResult: sdk.OneDec(), + base: MustNewDecFromStr("0.8"), + exp: ZeroDec(), + expectedResult: OneDec(), }, { // zero base, this should panic - base: sdk.ZeroDec(), - exp: sdk.OneDec(), - expectedResult: sdk.ZeroDec(), + base: ZeroDec(), + exp: OneDec(), + expectedResult: ZeroDec(), }, { // large base, small exp - base: sdk.MustNewDecFromStr("1.9999"), - exp: sdk.MustNewDecFromStr("0.23"), - expectedResult: sdk.MustNewDecFromStr("1.172821461"), + base: MustNewDecFromStr("1.9999"), + exp: MustNewDecFromStr("0.23"), + expectedResult: MustNewDecFromStr("1.172821461"), }, { // small base, large exp - base: sdk.MustNewDecFromStr("0.0000123"), - exp: sdk.MustNewDecFromStr("123"), - expectedResult: sdk.ZeroDec(), + base: MustNewDecFromStr("0.0000123"), + exp: MustNewDecFromStr("123"), + expectedResult: ZeroDec(), }, { // large base, large exp - base: sdk.MustNewDecFromStr("1.777"), - exp: sdk.MustNewDecFromStr("20"), - expectedResult: sdk.MustNewDecFromStr("98570.862372081602"), + base: MustNewDecFromStr("1.777"), + exp: MustNewDecFromStr("20"), + expectedResult: MustNewDecFromStr("98570.862372081602"), }, { // base equal one - base: sdk.MustNewDecFromStr("1"), - exp: sdk.MustNewDecFromStr("123"), - expectedResult: sdk.OneDec(), + base: MustNewDecFromStr("1"), + exp: MustNewDecFromStr("123"), + expectedResult: OneDec(), }, } for i, tc := range testCases { - var actualResult sdk.Dec + var actualResult Dec ConditionalPanic(t, tc.base.IsZero(), func() { actualResult = Pow(tc.base, tc.exp) require.True( diff --git a/osmomath/pow_bench_test.go b/osmomath/pow_bench_test.go index 51c4095ccda..4e7a49d93d7 100644 --- a/osmomath/pow_bench_test.go +++ b/osmomath/pow_bench_test.go @@ -2,55 +2,53 @@ package osmomath import ( "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" ) func BenchmarkPow(b *testing.B) { tests := []struct { - base sdk.Dec - exp sdk.Dec + base Dec + exp Dec }{ // TODO: Choose selection here more robustly { - base: sdk.MustNewDecFromStr("1.2"), - exp: sdk.MustNewDecFromStr("1.2"), + base: MustNewDecFromStr("1.2"), + exp: MustNewDecFromStr("1.2"), }, { - base: sdk.MustNewDecFromStr("0.5"), - exp: sdk.MustNewDecFromStr("11.122"), + base: MustNewDecFromStr("0.5"), + exp: MustNewDecFromStr("11.122"), }, { - base: sdk.MustNewDecFromStr("0.1"), - exp: sdk.MustNewDecFromStr("0.00000492"), + base: MustNewDecFromStr("0.1"), + exp: MustNewDecFromStr("0.00000492"), }, { - base: sdk.MustNewDecFromStr("0.0002423"), - exp: sdk.MustNewDecFromStr("0.1234"), + base: MustNewDecFromStr("0.0002423"), + exp: MustNewDecFromStr("0.1234"), }, { - base: sdk.MustNewDecFromStr("0.493"), - exp: sdk.MustNewDecFromStr("0.00000121"), + base: MustNewDecFromStr("0.493"), + exp: MustNewDecFromStr("0.00000121"), }, { - base: sdk.MustNewDecFromStr("0.000249"), - exp: sdk.MustNewDecFromStr("2.304"), + base: MustNewDecFromStr("0.000249"), + exp: MustNewDecFromStr("2.304"), }, { - base: sdk.MustNewDecFromStr("0.2342"), - exp: sdk.MustNewDecFromStr("32.2"), + base: MustNewDecFromStr("0.2342"), + exp: MustNewDecFromStr("32.2"), }, { - base: sdk.MustNewDecFromStr("0.000999"), - exp: sdk.MustNewDecFromStr("142.4"), + base: MustNewDecFromStr("0.000999"), + exp: MustNewDecFromStr("142.4"), }, { - base: sdk.MustNewDecFromStr("1.234"), - exp: sdk.MustNewDecFromStr("120.3"), + base: MustNewDecFromStr("1.234"), + exp: MustNewDecFromStr("120.3"), }, { - base: sdk.MustNewDecFromStr("0.00122"), - exp: sdk.MustNewDecFromStr("123.2"), + base: MustNewDecFromStr("0.00122"), + exp: MustNewDecFromStr("123.2"), }, } @@ -63,20 +61,20 @@ func BenchmarkPow(b *testing.B) { func BenchmarkSqrtPow(b *testing.B) { tests := []struct { - base sdk.Dec + base Dec }{ // TODO: Choose selection here more robustly { - base: sdk.MustNewDecFromStr("1.29847"), + base: MustNewDecFromStr("1.29847"), }, { - base: sdk.MustNewDecFromStr("1.313135"), + base: MustNewDecFromStr("1.313135"), }, { - base: sdk.MustNewDecFromStr("1.65976735939"), + base: MustNewDecFromStr("1.65976735939"), }, } - one_half := sdk.MustNewDecFromStr("0.5") + one_half := MustNewDecFromStr("0.5") for i := 0; i < b.N; i++ { for _, test := range tests { diff --git a/osmomath/rounding_direction.go b/osmomath/rounding_direction.go index 2685f684a16..a4cc476484b 100644 --- a/osmomath/rounding_direction.go +++ b/osmomath/rounding_direction.go @@ -16,11 +16,11 @@ const ( RoundBankers RoundingDirection = 3 ) -func DivIntByU64ToBigDec(i sdk.Int, u uint64, round RoundingDirection) (BigDec, error) { +func DivIntByU64ToBigDec(i Int, u uint64, round RoundingDirection) (BigDec, error) { if u == 0 { return BigDec{}, errors.New("div by zero") } - d := BigDecFromSDKDec(i.ToDec()) + d := BigDecFromDec(i.ToLegacyDec()) if round == RoundUp { return d.QuoRoundUp(NewBigDec(int64(u))), nil } else if round == RoundDown { diff --git a/osmomath/rounding_direction_test.go b/osmomath/rounding_direction_test.go index 2aeb2474b02..961702ac0f1 100644 --- a/osmomath/rounding_direction_test.go +++ b/osmomath/rounding_direction_test.go @@ -4,40 +4,39 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) func TestDivIntByU64ToBigDec(t *testing.T) { type testcase struct { - i sdk.Int + i Int u uint64 round RoundingDirection want BigDec expErr bool } tests := map[string]testcase{ - "div by zero": {sdk.NewInt(5), 0, RoundUp, BigDec{}, true}, - "5/3 round up": {sdk.NewInt(5), 3, RoundUp, - MustNewDecFromStr("1.666666666666666666666666666666666667"), false}, - "5/3 round down": {sdk.NewInt(5), 3, RoundDown, - MustNewDecFromStr("1.666666666666666666666666666666666666"), false}, - "5/3 round banker": {sdk.NewInt(5), 3, RoundBankers, - MustNewDecFromStr("1.666666666666666666666666666666666667"), false}, - "7/3 round up": {sdk.NewInt(7), 3, RoundUp, - MustNewDecFromStr("2.333333333333333333333333333333333334"), false}, - "7/3 round down": {sdk.NewInt(7), 3, RoundDown, - MustNewDecFromStr("2.333333333333333333333333333333333333"), false}, - "7/3 round banker": {sdk.NewInt(7), 3, RoundBankers, - MustNewDecFromStr("2.333333333333333333333333333333333333"), false}, + "div by zero": {NewInt(5), 0, RoundUp, BigDec{}, true}, + "5/3 round up": {NewInt(5), 3, RoundUp, + MustNewBigDecFromStr("1.666666666666666666666666666666666667"), false}, + "5/3 round down": {NewInt(5), 3, RoundDown, + MustNewBigDecFromStr("1.666666666666666666666666666666666666"), false}, + "5/3 round banker": {NewInt(5), 3, RoundBankers, + MustNewBigDecFromStr("1.666666666666666666666666666666666667"), false}, + "7/3 round up": {NewInt(7), 3, RoundUp, + MustNewBigDecFromStr("2.333333333333333333333333333333333334"), false}, + "7/3 round down": {NewInt(7), 3, RoundDown, + MustNewBigDecFromStr("2.333333333333333333333333333333333333"), false}, + "7/3 round banker": {NewInt(7), 3, RoundBankers, + MustNewBigDecFromStr("2.333333333333333333333333333333333333"), false}, } - addTCForAllRoundingModes := func(prefix string, i sdk.Int, u uint64, want BigDec) { + addTCForAllRoundingModes := func(prefix string, i Int, u uint64, want BigDec) { for round := 1; round < 4; round++ { tests[fmt.Sprintf("%s rounding=%d", prefix, round)] = testcase{i, u, RoundingDirection(round), want, false} } } - addTCForAllRoundingModes("odd divided by 2", sdk.NewInt(5), 2, NewDecWithPrec(25, 1)) + addTCForAllRoundingModes("odd divided by 2", NewInt(5), 2, NewBigDecWithPrec(25, 1)) for name, tt := range tests { t.Run(name, func(t *testing.T) { diff --git a/osmomath/sdk_math_alias.go b/osmomath/sdk_math_alias.go new file mode 100644 index 00000000000..ce941077ccb --- /dev/null +++ b/osmomath/sdk_math_alias.go @@ -0,0 +1,55 @@ +// This file creates type and function aliases the sdkmath.LegacyDec +// This is done for reducing verbosity and improving readability. +// +// For consistency, we also alias Int and Uint so that sdkmath does not have +// to be directly imported in files where both decimal and integer types are used. +package osmomath + +import ( + sdkmath "cosmossdk.io/math" +) + +type ( + Dec = sdkmath.LegacyDec + Int = sdkmath.Int + Uint = sdkmath.Uint +) + +const ( + PrecisionDec = sdkmath.LegacyPrecision + DecimalPrecisionBits = sdkmath.LegacyDecimalPrecisionBits +) + +var ( + // Dec + NewDec = sdkmath.LegacyNewDec + NewDecWithPrec = sdkmath.LegacyNewDecWithPrec + NewDecFromBigInt = sdkmath.LegacyNewDecFromBigInt + NewDecFromBigIntWithPrec = sdkmath.LegacyNewDecFromBigIntWithPrec + NewDecFromInt = sdkmath.LegacyNewDecFromInt + NewDecFromIntWithPrec = sdkmath.LegacyNewDecFromIntWithPrec + NewDecFromStr = sdkmath.LegacyNewDecFromStr + MustNewDecFromStr = sdkmath.LegacyMustNewDecFromStr + ZeroDec = sdkmath.LegacyZeroDec + OneDec = sdkmath.LegacyOneDec + SmallestDec = sdkmath.LegacySmallestDec + + // Int + NewInt = sdkmath.NewInt + NewIntFromUint64 = sdkmath.NewIntFromUint64 + NewIntFromBigInt = sdkmath.NewIntFromBigInt + NewIntFromString = sdkmath.NewIntFromString + NewIntWithDecimal = sdkmath.NewIntWithDecimal + ZeroInt = sdkmath.ZeroInt + OneInt = sdkmath.OneInt + IntEq = sdkmath.IntEq + MinInt = sdkmath.MinInt + MaxInt = sdkmath.MaxInt + + // Uint + NewUint = sdkmath.NewUint + NewUintFromString = sdkmath.NewUintFromString + + MinDec = sdkmath.LegacyMinDec + MaxDec = sdkmath.LegacyMaxDec +) diff --git a/osmomath/sigfig_round.go b/osmomath/sigfig_round.go index be845fb1aff..692d5c72262 100644 --- a/osmomath/sigfig_round.go +++ b/osmomath/sigfig_round.go @@ -1,11 +1,9 @@ package osmomath -import sdk "github.com/cosmos/cosmos-sdk/types" - -var pointOne = sdk.OneDec().QuoInt64(10) +var pointOne = OneDec().QuoInt64(10) // SigFigRound rounds to a specified significant figure. -func SigFigRound(d sdk.Dec, tenToSigFig sdk.Int) sdk.Dec { +func SigFigRound(d Dec, tenToSigFig Int) Dec { if d.IsZero() { return d } @@ -20,9 +18,9 @@ func SigFigRound(d sdk.Dec, tenToSigFig sdk.Int) sdk.Dec { } // d * 10^k * 10^sigfig dkSigFig := dTimesK.MulInt(tenToSigFig) - numerator := dkSigFig.RoundInt().ToDec() + numerator := dkSigFig.RoundInt().ToLegacyDec() - tenToK := sdk.NewInt(10).ToDec().Power(k) + tenToK := NewInt(10).ToLegacyDec().Power(k) denominator := tenToSigFig.Mul(tenToK.TruncateInt()) return numerator.QuoInt(denominator) } diff --git a/osmomath/sigfig_round_test.go b/osmomath/sigfig_round_test.go index 926f7334674..1f6bf1c3a1c 100644 --- a/osmomath/sigfig_round_test.go +++ b/osmomath/sigfig_round_test.go @@ -4,32 +4,30 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) func TestSigFigRound(t *testing.T) { // sigfig = 8 - tenToSigFig := sdk.NewDec(10).Power(8).TruncateInt() + tenToSigFig := NewDec(10).Power(8).TruncateInt() testCases := []struct { name string - decimal sdk.Dec - tenToSigFig sdk.Int - expectedResult sdk.Dec + decimal Dec + tenToSigFig Int + expectedResult Dec }{ { name: "Zero decimal", - decimal: sdk.ZeroDec(), + decimal: ZeroDec(), tenToSigFig: tenToSigFig, - expectedResult: sdk.ZeroDec(), + expectedResult: ZeroDec(), }, { name: "Zero tenToSigFig", - decimal: sdk.MustNewDecFromStr("2.123"), - tenToSigFig: sdk.ZeroInt(), - expectedResult: sdk.ZeroDec(), + decimal: MustNewDecFromStr("2.123"), + tenToSigFig: ZeroInt(), + expectedResult: ZeroDec(), }, // With input, decimal >= 0.1. We have: // - dTimesK = 63.045 @@ -40,9 +38,9 @@ func TestSigFigRound(t *testing.T) { // - result = numerator / denominator = 63 { name: "Big decimal, default tenToSigFig", - decimal: sdk.MustNewDecFromStr("63.045"), + decimal: MustNewDecFromStr("63.045"), tenToSigFig: tenToSigFig, - expectedResult: sdk.MustNewDecFromStr("63.045"), + expectedResult: MustNewDecFromStr("63.045"), }, // With input, decimal < 0.1. We have: // - dTimesK = 0.86724 @@ -53,9 +51,9 @@ func TestSigFigRound(t *testing.T) { // - result = numerator / denominator = 0.086724 { name: "Small decimal, default tenToSigFig", - decimal: sdk.MustNewDecFromStr("0.0867245957"), + decimal: MustNewDecFromStr("0.0867245957"), tenToSigFig: tenToSigFig, - expectedResult: sdk.MustNewDecFromStr("0.086724596"), + expectedResult: MustNewDecFromStr("0.086724596"), }, // With input, decimal < 0.1. We have: // - dTimesK = 0.86724 @@ -66,23 +64,23 @@ func TestSigFigRound(t *testing.T) { // - result = numerator / denominator = 0.087 { name: "Small decimal, random tenToSigFig", - decimal: sdk.MustNewDecFromStr("0.086724"), - tenToSigFig: sdk.NewInt(100), - expectedResult: sdk.MustNewDecFromStr("0.087"), + decimal: MustNewDecFromStr("0.086724"), + tenToSigFig: NewInt(100), + expectedResult: MustNewDecFromStr("0.087"), }, { name: "minimum decimal is still kept", - decimal: sdk.NewDecWithPrec(1, 18), - tenToSigFig: sdk.NewInt(10), - expectedResult: sdk.NewDecWithPrec(1, 18), + decimal: NewDecWithPrec(1, 18), + tenToSigFig: NewInt(10), + expectedResult: NewDecWithPrec(1, 18), }, } for i, tc := range testCases { tc := tc t.Run(tc.name, func(t *testing.T) { - var actualResult sdk.Dec - ConditionalPanic(t, tc.tenToSigFig.Equal(sdk.ZeroInt()), func() { + var actualResult Dec + ConditionalPanic(t, tc.tenToSigFig.Equal(ZeroInt()), func() { actualResult = SigFigRound(tc.decimal, tc.tenToSigFig) require.Equal( t, diff --git a/osmomath/sqrt.go b/osmomath/sqrt.go index 2f57fba47ae..dc3bc7a67c2 100644 --- a/osmomath/sqrt.go +++ b/osmomath/sqrt.go @@ -3,12 +3,9 @@ package osmomath import ( "errors" "math/big" - - sdk "github.com/cosmos/cosmos-sdk/types" ) -var smallestDec = sdk.SmallestDec() -var smallestBigDec = SmallestDec() +var smallestDec = SmallestDec() var tenTo18 = big.NewInt(1e18) var tenTo36 = big.NewInt(0).Mul(tenTo18, tenTo18) var oneBigInt = big.NewInt(1) @@ -20,7 +17,7 @@ var oneBigInt = big.NewInt(1) // This function guarantees: // the returned root r, will be such that r^2 >= d // This function is monotonic, i.e. if d1 >= d2, then sqrt(d1) >= sqrt(d2) -func MonotonicSqrt(d sdk.Dec) (sdk.Dec, error) { +func MonotonicSqrt(d Dec) (Dec, error) { if d.IsNegative() { return d, errors.New("cannot take square root of negative number") } @@ -46,7 +43,7 @@ func MonotonicSqrt(d sdk.Dec) (sdk.Dec, error) { if check.Cmp(shiftedD) == -1 { r.Add(r, oneBigInt) } - root := sdk.NewDecFromBigIntWithPrec(r, 18) + root := NewDecFromBigIntWithPrec(r, 18) return root, nil } @@ -77,13 +74,13 @@ func MonotonicSqrtBigDec(d BigDec) (BigDec, error) { if check.Cmp(shiftedD) == -1 { r.Add(r, oneBigInt) } - root := NewDecFromBigIntWithPrec(r, 36) + root := NewBigDecFromBigIntWithPrec(r, 36) return root, nil } // MustMonotonicSqrt returns the output of MonotonicSqrt, panicking on error. -func MustMonotonicSqrt(d sdk.Dec) sdk.Dec { +func MustMonotonicSqrt(d Dec) Dec { sqrt, err := MonotonicSqrt(d) if err != nil { panic(err) diff --git a/osmomath/sqrt_big_test.go b/osmomath/sqrt_big_test.go index 83b48d7cdaf..a8858072c9d 100644 --- a/osmomath/sqrt_big_test.go +++ b/osmomath/sqrt_big_test.go @@ -5,13 +5,16 @@ import ( "math/rand" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +var ( + smallestBigDec = SmallestBigDec() +) + func generateRandomDecForEachBitlenBigDec(r *rand.Rand, numPerBitlen int) []BigDec { - return generateRandomDecForEachBitlen[BigDec](r, numPerBitlen, NewDecFromBigIntWithPrec, Precision) + return generateRandomDecForEachBitlen[BigDec](r, numPerBitlen, NewBigDecFromBigIntWithPrec, PrecisionBigDec) } func TestSdkApproxSqrtVectors_BigDec(t *testing.T) { @@ -19,13 +22,13 @@ func TestSdkApproxSqrtVectors_BigDec(t *testing.T) { input BigDec expected BigDec }{ - {OneDec(), OneDec()}, // 1.0 => 1.0 - {NewDecWithPrec(25, 2), NewDecWithPrec(5, 1)}, // 0.25 => 0.5 - {NewDecWithPrec(4, 2), NewDecWithPrec(2, 1)}, // 0.09 => 0.3 - {NewDecFromInt(NewInt(9)), NewDecFromInt(NewInt(3))}, // 9 => 3 - {NewDecFromInt(NewInt(2)), MustNewDecFromStr("1.414213562373095048801688724209698079")}, // 2 => 1.414213562373095048801688724209698079 - {smallestBigDec, NewDecWithPrec(1, 18)}, // 10^-36 => 10^-18 - {smallestBigDec.MulInt64(3), NewDecWithPrec(1732050807568877294, 36)}, // 3*10^-36 => sqrt(3)*10^-18 + {OneBigDec(), OneBigDec()}, // 1.0 => 1.0 + {NewBigDecWithPrec(25, 2), NewBigDecWithPrec(5, 1)}, // 0.25 => 0.5 + {NewBigDecWithPrec(4, 2), NewBigDecWithPrec(2, 1)}, // 0.09 => 0.3 + {NewBigDecFromInt(NewBigInt(9)), NewBigDecFromInt(NewBigInt(3))}, // 9 => 3 + {NewBigDecFromInt(NewBigInt(2)), MustNewBigDecFromStr("1.414213562373095048801688724209698079")}, // 2 => 1.414213562373095048801688724209698079 + {smallestBigDec, NewBigDecWithPrec(1, 18)}, // 10^-36 => 10^-18 + {smallestBigDec.MulInt64(3), NewBigDecWithPrec(1732050807568877294, 36)}, // 3*10^-36 => sqrt(3)*10^-18 } for i, tc := range testCases { @@ -54,22 +57,22 @@ func TestSqrtMonotinicity_BigDec(t *testing.T) { bigger BigDec } testCases := []testcase{ - {MustNewDecFromStr("120.120060020005000000"), MustNewDecFromStr("120.120060020005000001")}, + {MustNewBigDecFromStr("120.120060020005000000"), MustNewBigDecFromStr("120.120060020005000001")}, {smallestBigDec, smallestBigDec.MulInt64(2)}, } // create random test vectors for every bit-length r := rand.New(rand.NewSource(rand.Int63())) - for i := 0; i < 255+sdk.DecimalPrecisionBits; i++ { + for i := 0; i < 255+DecimalPrecisionBits; i++ { upperbound := big.NewInt(1) upperbound.Lsh(upperbound, uint(i)) for j := 0; j < 100; j++ { v := big.NewInt(0).Rand(r, upperbound) - d := NewDecFromBigIntWithPrec(v, 36) + d := NewBigDecFromBigIntWithPrec(v, 36) testCases = append(testCases, testcase{d, d.Add(smallestBigDec)}) } } for i := 0; i < 1024; i++ { - d := NewDecWithPrec(int64(i), 18) + d := NewBigDecWithPrec(int64(i), 18) testCases = append(testCases, testcase{d, d.Add(smallestBigDec)}) } @@ -102,7 +105,7 @@ func TestPerfectSquares_BigDec(t *testing.T) { for j := 0; j < 100; j++ { v := big.NewInt(0).Rand(r, upperbound) dec := big.NewInt(0).Rand(r, tenToMin9) - d := NewDecFromBigInt(v).Add(NewDecFromBigIntWithPrec(dec, 9)) + d := NewBigDecFromBigInt(v).Add(NewBigDecFromBigIntWithPrec(dec, 9)) cases = append(cases, d.MulMut(d)) } } @@ -119,7 +122,7 @@ func TestPerfectSquares_BigDec(t *testing.T) { func TestSqrtRounding_BigDec(t *testing.T) { testCases := []BigDec{ - MustNewDecFromStr("11662930532952632574132537947829685675668532938920838254939577167671385459971.396347723368091000"), + MustNewBigDecFromStr("11662930532952632574132537947829685675668532938920838254939577167671385459971.396347723368091000"), } r := rand.New(rand.NewSource(rand.Int63())) testCases = append(testCases, generateRandomDecForEachBitlenBigDec(r, 10)...) diff --git a/osmomath/sqrt_test.go b/osmomath/sqrt_test.go index 9dfd9e4b194..e81bb5f0a45 100644 --- a/osmomath/sqrt_test.go +++ b/osmomath/sqrt_test.go @@ -5,18 +5,17 @@ import ( "math/rand" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func generateRandomDecForEachBitlenDec(r *rand.Rand, numPerBitlen int) []sdk.Dec { - return generateRandomDecForEachBitlen[sdk.Dec](r, numPerBitlen, sdk.NewDecFromBigIntWithPrec, sdk.Precision) +func generateRandomDecForEachBitlenDec(r *rand.Rand, numPerBitlen int) []Dec { + return generateRandomDecForEachBitlen[Dec](r, numPerBitlen, NewDecFromBigIntWithPrec, PrecisionDec) } func generateRandomDecForEachBitlen[T any](r *rand.Rand, numPerBitlen int, constructor func(*big.Int, int64) T, precision int64) []T { - res := make([]T, (255+sdk.DecimalPrecisionBits)*numPerBitlen) - for i := 0; i < 255+sdk.DecimalPrecisionBits; i++ { + res := make([]T, (255+DecimalPrecisionBits)*numPerBitlen) + for i := 0; i < 255+DecimalPrecisionBits; i++ { upperbound := big.NewInt(1) upperbound.Lsh(upperbound, uint(i)) for j := 0; j < numPerBitlen; j++ { @@ -29,16 +28,16 @@ func generateRandomDecForEachBitlen[T any](r *rand.Rand, numPerBitlen int, const func TestSdkApproxSqrtVectors(t *testing.T) { testCases := []struct { - input sdk.Dec - expected sdk.Dec + input Dec + expected Dec }{ - {sdk.OneDec(), sdk.OneDec()}, // 1.0 => 1.0 - {sdk.NewDecWithPrec(25, 2), sdk.NewDecWithPrec(5, 1)}, // 0.25 => 0.5 - {sdk.NewDecWithPrec(4, 2), sdk.NewDecWithPrec(2, 1)}, // 0.09 => 0.3 - {sdk.NewDecFromInt(sdk.NewInt(9)), sdk.NewDecFromInt(sdk.NewInt(3))}, // 9 => 3 - {sdk.NewDecFromInt(sdk.NewInt(2)), sdk.NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 - {smallestDec, sdk.NewDecWithPrec(1, 9)}, // 10^-18 => 10^-9 - {smallestDec.MulInt64(3), sdk.NewDecWithPrec(1732050808, 18)}, // 3*10^-18 => sqrt(3)*10^-9 + {OneDec(), OneDec()}, // 1.0 => 1.0 + {NewDecWithPrec(25, 2), NewDecWithPrec(5, 1)}, // 0.25 => 0.5 + {NewDecWithPrec(4, 2), NewDecWithPrec(2, 1)}, // 0.09 => 0.3 + {NewDecFromInt(NewInt(9)), NewDecFromInt(NewInt(3))}, // 9 => 3 + {NewDecFromInt(NewInt(2)), NewDecWithPrec(1414213562373095049, 18)}, // 2 => 1.414213562373095049 + {smallestDec, NewDecWithPrec(1, 9)}, // 10^-18 => 10^-9 + {smallestDec.MulInt64(3), NewDecWithPrec(1732050808, 18)}, // 3*10^-18 => sqrt(3)*10^-9 } for i, tc := range testCases { @@ -48,7 +47,7 @@ func TestSdkApproxSqrtVectors(t *testing.T) { } } -func testMonotonicityAround(t *testing.T, x sdk.Dec) { +func testMonotonicityAround(t *testing.T, x Dec) { // test that sqrt(x) is monotonic around x // i.e. sqrt(x-1) <= sqrt(x) <= sqrt(x+1) sqrtX, err := MonotonicSqrt(x) @@ -63,26 +62,26 @@ func testMonotonicityAround(t *testing.T, x sdk.Dec) { func TestSqrtMonotinicity(t *testing.T) { type testcase struct { - smaller sdk.Dec - bigger sdk.Dec + smaller Dec + bigger Dec } testCases := []testcase{ - {sdk.MustNewDecFromStr("120.120060020005000000"), sdk.MustNewDecFromStr("120.120060020005000001")}, + {MustNewDecFromStr("120.120060020005000000"), MustNewDecFromStr("120.120060020005000001")}, {smallestDec, smallestDec.MulInt64(2)}, } // create random test vectors for every bit-length r := rand.New(rand.NewSource(rand.Int63())) - for i := 0; i < 255+sdk.DecimalPrecisionBits; i++ { + for i := 0; i < 255+DecimalPrecisionBits; i++ { upperbound := big.NewInt(1) upperbound.Lsh(upperbound, uint(i)) for j := 0; j < 100; j++ { v := big.NewInt(0).Rand(r, upperbound) - d := sdk.NewDecFromBigIntWithPrec(v, 18) + d := NewDecFromBigIntWithPrec(v, 18) testCases = append(testCases, testcase{d, d.Add(smallestDec)}) } } for i := 0; i < 1024; i++ { - d := sdk.NewDecWithPrec(int64(i), 18) + d := NewDecWithPrec(int64(i), 18) testCases = append(testCases, testcase{d, d.Add(smallestDec)}) } @@ -104,8 +103,8 @@ func TestSqrtMonotinicity(t *testing.T) { // and then setting x = sqrt(v) // this is because this is the set of values whose squares are perfectly representable. func TestPerfectSquares(t *testing.T) { - cases := []sdk.Dec{ - sdk.NewDec(100), + cases := []Dec{ + NewDec(100), } r := rand.New(rand.NewSource(rand.Int63())) tenToMin9 := big.NewInt(1_000_000_000) @@ -115,7 +114,7 @@ func TestPerfectSquares(t *testing.T) { for j := 0; j < 100; j++ { v := big.NewInt(0).Rand(r, upperbound) dec := big.NewInt(0).Rand(r, tenToMin9) - d := sdk.NewDecFromBigInt(v).Add(sdk.NewDecFromBigIntWithPrec(dec, 9)) + d := NewDecFromBigInt(v).Add(NewDecFromBigIntWithPrec(dec, 9)) cases = append(cases, d.MulMut(d)) } } @@ -131,10 +130,10 @@ func TestPerfectSquares(t *testing.T) { } func TestSqrtRounding(t *testing.T) { - testCases := []sdk.Dec{ + testCases := []Dec{ // TODO: uncomment when SDK supports dec from str with bigger bitlenghths. // it works if you override the sdk panic locally. - // sdk.MustNewDecFromStr("11662930532952632574132537947829685675668532938920838254939577167671385459971.396347723368091000"), + // MustNewDecFromStr("11662930532952632574132537947829685675668532938920838254939577167671385459971.396347723368091000"), } r := rand.New(rand.NewSource(rand.Int63())) testCases = append(testCases, generateRandomDecForEachBitlenDec(r, 10)...) diff --git a/osmoutils/accum/accum.go b/osmoutils/accum/accum.go index 1e65d8945e1..5c97fd73fe6 100644 --- a/osmoutils/accum/accum.go +++ b/osmoutils/accum/accum.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) @@ -24,7 +25,7 @@ type AccumulatorObject struct { valuePerShare sdk.DecCoins // Accumulator's total shares across all positions - totalShares sdk.Dec + totalShares osmomath.Dec } // Makes a new accumulator at store/accum/{accumName} @@ -40,7 +41,7 @@ func MakeAccumulator(accumStore store.KVStore, accumName string) error { // New accumulator values start out at zero // TODO: consider whether this should be a parameter instead of always zero initAccumValue := sdk.NewDecCoins() - initTotalShares := sdk.ZeroDec() + initTotalShares := osmomath.ZeroDec() newAccum := &AccumulatorObject{accumStore, accumName, initAccumValue, initTotalShares} @@ -53,7 +54,7 @@ func MakeAccumulator(accumStore store.KVStore, accumName string) error { // * accumName already exists // * theres some overlapping keys // * Accumulator name contains "||" -func MakeAccumulatorWithValueAndShare(accumStore store.KVStore, accumName string, accumValue sdk.DecCoins, totalShares sdk.Dec) error { +func MakeAccumulatorWithValueAndShare(accumStore store.KVStore, accumName string, accumValue sdk.DecCoins, totalShares osmomath.Dec) error { if accumStore.Has(formatAccumPrefixKey(accumName)) { return errors.New("Accumulator with given name already exists in store") } @@ -101,7 +102,7 @@ func (accum AccumulatorObject) GetPosition(name string) (Record, error) { return position, nil } -func setAccumulator(accum *AccumulatorObject, value sdk.DecCoins, shares sdk.Dec) error { +func setAccumulator(accum *AccumulatorObject, value sdk.DecCoins, shares osmomath.Dec) error { if strings.Contains(accum.name, KeySeparator) { return fmt.Errorf("Accumulator name cannot contain '%s', provided name %s", KeySeparator, accum.name) } @@ -125,7 +126,7 @@ func (accum *AccumulatorObject) AddToAccumulator(amt sdk.DecCoins) { // It takes a snapshot of the current accumulator value, and sets the position's initial value to that. // The position is initialized with empty unclaimed rewards // If there is an existing position for the given address, it is overwritten. -func (accum *AccumulatorObject) NewPosition(name string, numShareUnits sdk.Dec, options *Options) error { +func (accum *AccumulatorObject) NewPosition(name string, numShareUnits osmomath.Dec, options *Options) error { return accum.NewPositionIntervalAccumulation(name, numShareUnits, accum.valuePerShare, options) } @@ -137,7 +138,7 @@ func (accum *AccumulatorObject) NewPosition(name string, numShareUnits sdk.Dec, // intervalAccumulationPerShare DecCoin values are allowed to be negative. // The position is initialized with empty unclaimed rewards // If there is an existing position for the given address, it is overwritten. -func (accum *AccumulatorObject) NewPositionIntervalAccumulation(name string, numShareUnits sdk.Dec, intervalAccumulationPerShare sdk.DecCoins, options *Options) error { +func (accum *AccumulatorObject) NewPositionIntervalAccumulation(name string, numShareUnits osmomath.Dec, intervalAccumulationPerShare sdk.DecCoins, options *Options) error { if err := options.validate(); err != nil { return err } @@ -167,7 +168,7 @@ func (accum *AccumulatorObject) NewPositionIntervalAccumulation(name string, num // - newShares are negative or zero. // - there is no existing position at the given address // - other internal or database error occurs. -func (accum *AccumulatorObject) AddToPosition(name string, newShares sdk.Dec) error { +func (accum *AccumulatorObject) AddToPosition(name string, newShares osmomath.Dec) error { return accum.AddToPositionIntervalAccumulation(name, newShares, accum.valuePerShare) } @@ -189,7 +190,7 @@ func (accum *AccumulatorObject) AddToPosition(name string, newShares sdk.Dec) er // - newShares are negative or zero. // - there is no existing position at the given address // - other internal or database error occurs. -func (accum *AccumulatorObject) AddToPositionIntervalAccumulation(name string, newShares sdk.Dec, intervalAccumulationPerShare sdk.DecCoins) error { +func (accum *AccumulatorObject) AddToPositionIntervalAccumulation(name string, newShares osmomath.Dec, intervalAccumulationPerShare sdk.DecCoins) error { if !newShares.IsPositive() { return errors.New("Attempted to add zero or negative number of shares to a position") } @@ -224,7 +225,7 @@ func (accum *AccumulatorObject) AddToPositionIntervalAccumulation(name string, n // the unclaimed and newly accrued rewards and returns them alongside the redeemed shares. Then, it // overwrites the position record with the updated number of shares. Since it accrues rewards, it // also moves up the position's accumulator value to the current accum val. -func (accum *AccumulatorObject) RemoveFromPosition(name string, numSharesToRemove sdk.Dec) error { +func (accum *AccumulatorObject) RemoveFromPosition(name string, numSharesToRemove osmomath.Dec) error { return accum.RemoveFromPositionIntervalAccumulation(name, numSharesToRemove, accum.valuePerShare) } @@ -236,7 +237,7 @@ func (accum *AccumulatorObject) RemoveFromPosition(name string, numSharesToRemov // rewards range. For example, a concentrated liquidity narrow range position. // All intervalAccumulationPerShare DecCoin values must be non-negative. They must also be a superset of the // old accumulator value associated with the position. -func (accum *AccumulatorObject) RemoveFromPositionIntervalAccumulation(name string, numSharesToRemove sdk.Dec, intervalAccumulationPerShare sdk.DecCoins) error { +func (accum *AccumulatorObject) RemoveFromPositionIntervalAccumulation(name string, numSharesToRemove osmomath.Dec, intervalAccumulationPerShare sdk.DecCoins) error { // Cannot remove zero or negative shares if !numSharesToRemove.IsPositive() { return fmt.Errorf("Attempted to remove no/negative shares (%s)", numSharesToRemove) @@ -276,7 +277,7 @@ func (accum *AccumulatorObject) RemoveFromPositionIntervalAccumulation(name stri // AddToPosition. If numShares is negative, it is equivalent to calling RemoveFromPosition. // Also, it moves up the position's accumulator value to the current accum value. // Fails with error if numShares is zero. Returns nil on success. -func (accum *AccumulatorObject) UpdatePosition(name string, numShares sdk.Dec) error { +func (accum *AccumulatorObject) UpdatePosition(name string, numShares osmomath.Dec) error { return accum.UpdatePositionIntervalAccumulation(name, numShares, accum.valuePerShare) } @@ -289,7 +290,7 @@ func (accum *AccumulatorObject) UpdatePosition(name string, numShares sdk.Dec) e // rewards range. For example, a concentrated liquidity narrow range position. // All intervalAccumulationPerShare DecCoin value must be non-negative. They must also be a superset of the // old accumulator value associated with the position. -func (accum *AccumulatorObject) UpdatePositionIntervalAccumulation(name string, numShares sdk.Dec, intervalAccumulationPerShare sdk.DecCoins) error { +func (accum *AccumulatorObject) UpdatePositionIntervalAccumulation(name string, numShares osmomath.Dec, intervalAccumulationPerShare sdk.DecCoins) error { if numShares.IsZero() { return ZeroSharesError } @@ -357,10 +358,10 @@ func (accum AccumulatorObject) deletePosition(positionName string) { // GetPositionSize returns the number of shares the position with the given // name has in the accumulator. Returns error if position does not exist // or if fails to retrieve position from state. -func (accum *AccumulatorObject) GetPositionSize(name string) (sdk.Dec, error) { +func (accum *AccumulatorObject) GetPositionSize(name string) (osmomath.Dec, error) { position, err := GetPosition(accum, name) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return position.NumShares, nil @@ -416,7 +417,7 @@ func (accum *AccumulatorObject) ClaimRewards(positionName string) (sdk.Coins, sd } // GetTotalShares returns the total number of shares in the accumulator -func (accum AccumulatorObject) GetTotalShares() sdk.Dec { +func (accum AccumulatorObject) GetTotalShares() osmomath.Dec { return accum.totalShares } diff --git a/osmoutils/accum/accum.pb.go b/osmoutils/accum/accum.pb.go index d4174f5fec4..5ab4656af58 100644 --- a/osmoutils/accum/accum.pb.go +++ b/osmoutils/accum/accum.pb.go @@ -4,6 +4,7 @@ package accum import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -30,7 +31,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // shares belonging to it from all positions. type AccumulatorContent struct { AccumValue github_com_cosmos_cosmos_sdk_types.DecCoins `protobuf:"bytes,1,rep,name=accum_value,json=accumValue,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoins" json:"accum_value"` - TotalShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=total_shares,json=totalShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"total_shares"` + TotalShares cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=total_shares,json=totalShares,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"total_shares"` } func (m *AccumulatorContent) Reset() { *m = AccumulatorContent{} } @@ -114,7 +115,7 @@ var xxx_messageInfo_Options proto.InternalMessageInfo type Record struct { // num_shares is the number of shares belonging to the position associated // with this record. - NumShares github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=num_shares,json=numShares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"num_shares"` + NumShares cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=num_shares,json=numShares,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"num_shares"` // accum_value_per_share is the subset of coins per shar of the global // accumulator value that allows to infer how much a position is entitled to // per share that it owns. @@ -205,33 +206,34 @@ func init() { func init() { proto.RegisterFile("osmosis/accum/v1beta1/accum.proto", fileDescriptor_4866f7c74a169dc2) } var fileDescriptor_4866f7c74a169dc2 = []byte{ - // 412 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x3f, 0x8f, 0xd3, 0x30, - 0x1c, 0x86, 0xe3, 0x2b, 0xba, 0x53, 0x1d, 0x26, 0x8b, 0x8a, 0xe8, 0x84, 0xdc, 0xd2, 0x01, 0x55, - 0x42, 0xe7, 0xe8, 0xae, 0x0b, 0x2b, 0x2d, 0x0b, 0x03, 0x02, 0x02, 0x62, 0x60, 0x89, 0x1c, 0xc7, - 0x6a, 0x23, 0x12, 0x3b, 0xf2, 0x9f, 0x22, 0x76, 0x16, 0x36, 0x3e, 0x04, 0x13, 0x9f, 0xa4, 0x63, - 0x47, 0x04, 0x52, 0x41, 0xed, 0x17, 0x41, 0xb1, 0x93, 0xd2, 0x81, 0x01, 0x21, 0x75, 0x72, 0x9c, - 0xbc, 0x79, 0x9e, 0x9f, 0xde, 0x38, 0xf0, 0xbe, 0xd4, 0x95, 0xd4, 0x85, 0x8e, 0x29, 0x63, 0xb6, - 0x8a, 0x57, 0xd7, 0x19, 0x37, 0xf4, 0xda, 0xef, 0x48, 0xad, 0xa4, 0x91, 0x68, 0xd0, 0x46, 0x88, - 0xbf, 0xd9, 0x46, 0x2e, 0xef, 0x2c, 0xe4, 0x42, 0xba, 0x44, 0xdc, 0x5c, 0xf9, 0xf0, 0x25, 0x66, - 0x2e, 0x1d, 0x67, 0x54, 0xf3, 0x03, 0x8d, 0xc9, 0x42, 0xf8, 0xe7, 0xe3, 0x1f, 0x00, 0xa2, 0xc7, - 0x0d, 0xc7, 0x96, 0xd4, 0x48, 0x35, 0x97, 0xc2, 0x70, 0x61, 0x90, 0x82, 0xa1, 0xa3, 0xa7, 0x2b, - 0x5a, 0x5a, 0x1e, 0x81, 0x51, 0x6f, 0x12, 0xde, 0xdc, 0x23, 0x1e, 0x46, 0x1a, 0x58, 0xe7, 0x25, - 0x4f, 0x38, 0x9b, 0xcb, 0x42, 0xcc, 0xa6, 0xeb, 0xed, 0x30, 0xf8, 0xfa, 0x73, 0xf8, 0x70, 0x51, - 0x98, 0xa5, 0xcd, 0x08, 0x93, 0x55, 0xdc, 0xca, 0xfd, 0x72, 0xa5, 0xf3, 0x77, 0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, 0xad, 0xd6, 0x14, 0x65, 0xfb, 0xef, 0x64, 0xe7, 0xee, 0x84, 0x4f, 0x7f, 0x07, - 0x00, 0x00, 0xff, 0xff, 0xd7, 0xe4, 0xc9, 0x60, 0x53, 0x03, 0x00, 0x00, + // 430 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0x73, 0x0d, 0x6a, 0x95, 0x0b, 0xd3, 0x89, 0x08, 0xab, 0x20, 0x27, 0x84, 0x25, 0x12, + 0xea, 0x9d, 0xda, 0x2e, 0xac, 0xa4, 0x15, 0x12, 0x12, 0x12, 0xc8, 0x20, 0x06, 0x16, 0xeb, 0x7c, + 0x3e, 0x25, 0xa7, 0xda, 0xf7, 0x46, 0xf7, 0xa7, 0xa8, 0x3b, 0x0b, 0x1b, 0x2b, 0x5f, 0x81, 0x4f, + 0xd2, 0x31, 0x23, 0x62, 0x28, 0x28, 0xf9, 0x22, 0xc8, 0x77, 0x76, 0xe9, 0xc0, 0xc0, 0x92, 0xe9, + 0xfc, 0xda, 0xcf, 0xfb, 0x7b, 0x5e, 0x3d, 0x7e, 0x0f, 0x3f, 0x01, 0x5b, 0x83, 0x55, 0x96, 0x71, + 0x21, 0x7c, 0xcd, 0x2e, 0x8f, 0x0b, 0xe9, 0xf8, 0x71, 0xac, 0xe8, 0xca, 0x80, 0x03, 0x32, 0x6a, + 0x25, 0x34, 0xbe, 0x6c, 0x25, 0x87, 0x0f, 0x16, 0xb0, 0x80, 0xa0, 0x60, 0xcd, 0x53, 0x14, 0x1f, + 0xa6, 0x22, 0xa8, 0x59, 0xc1, 0xad, 0xbc, 0xa5, 0x09, 0x50, 0x3a, 0x7e, 0x9f, 0xae, 0x11, 0x26, + 0x2f, 0x1a, 0x8e, 0xaf, 0xb8, 0x03, 0x73, 0x06, 0xda, 0x49, 0xed, 0x88, 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, 0x24, 0xfd, 0x5d, 0x0d, 0x32, 0xba, 0x75, 0xcc, 0xa2, 0xe1, 0xfb, 0xc6, 0x8f, 0x3c, 0xc7, + 0x07, 0x10, 0xc3, 0x4e, 0xee, 0x4d, 0xd0, 0x6c, 0x78, 0x92, 0xd2, 0x7f, 0xae, 0x27, 0x6d, 0x7f, + 0x49, 0xd6, 0xc9, 0xe7, 0xaf, 0xae, 0x37, 0x29, 0x5a, 0x6f, 0x52, 0xf4, 0x7b, 0x93, 0xa2, 0xaf, + 0xdb, 0xb4, 0xb7, 0xde, 0xa6, 0xbd, 0x1f, 0xdb, 0xb4, 0xf7, 0x91, 0xdd, 0x99, 0xab, 0x85, 0x1d, + 0x55, 0xbc, 0xb0, 0x5d, 0x11, 0x4e, 0xef, 0x54, 0xd5, 0xde, 0x92, 0x62, 0x3f, 0xec, 0xf2, 0xe9, + 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x02, 0x19, 0x52, 0x8b, 0x3d, 0x03, 0x00, 0x00, } func (m *AccumulatorContent) Marshal() (dAtA []byte, err error) { diff --git a/osmoutils/accum/accum_helpers.go b/osmoutils/accum/accum_helpers.go index f7d440696d1..44d0926a7cd 100644 --- a/osmoutils/accum/accum_helpers.go +++ b/osmoutils/accum/accum_helpers.go @@ -3,12 +3,13 @@ package accum import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) // initOrUpdatePosition creates a new position or override an existing position // at accumulator's current value with a specific number of shares and unclaimed rewards -func initOrUpdatePosition(accum *AccumulatorObject, accumulatorValuePerShare sdk.DecCoins, index string, numShareUnits sdk.Dec, unclaimedRewardsTotal sdk.DecCoins, options *Options) { +func initOrUpdatePosition(accum *AccumulatorObject, accumulatorValuePerShare sdk.DecCoins, index string, numShareUnits osmomath.Dec, unclaimedRewardsTotal sdk.DecCoins, options *Options) { position := Record{ NumShares: numShareUnits, AccumValuePerShare: accumulatorValuePerShare, diff --git a/osmoutils/accum/accum_test.go b/osmoutils/accum/accum_test.go index 4aae16fe988..433353a4ab1 100644 --- a/osmoutils/accum/accum_test.go +++ b/osmoutils/accum/accum_test.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/suite" dbm "github.com/tendermint/tm-db" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" accumPackage "github.com/osmosis-labs/osmosis/osmoutils/accum" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" @@ -37,7 +38,7 @@ func (suite *AccumTestSuite) MakeAndGetAccumulator(name string) *accumPackage.Ac return accum } -func (suite *AccumTestSuite) TotalSharesCheck(accum *accumPackage.AccumulatorObject, expected sdk.Dec) { +func (suite *AccumTestSuite) TotalSharesCheck(accum *accumPackage.AccumulatorObject, expected osmomath.Dec) { shareCount := accum.GetTotalShares() suite.Require().Equal(expected.String(), shareCount.String()) } @@ -56,41 +57,41 @@ var ( denomThree = "denomthree" emptyCoins = sdk.DecCoins(nil) - emptyDec = sdk.NewDec(0) + emptyDec = osmomath.NewDec(0) - initialValueOne = sdk.MustNewDecFromStr("100.1") + initialValueOne = osmomath.MustNewDecFromStr("100.1") initialCoinDenomOne = sdk.NewDecCoinFromDec(denomOne, initialValueOne) initialCoinDenomTwo = sdk.NewDecCoinFromDec(denomTwo, initialValueOne) initialCoinDenomThree = sdk.NewDecCoinFromDec(denomThree, initialValueOne) initialCoinsDenomOne = sdk.NewDecCoins(initialCoinDenomOne) positionOne = accumPackage.Record{ - NumShares: sdk.NewDec(100), + NumShares: osmomath.NewDec(100), AccumValuePerShare: emptyCoins, UnclaimedRewardsTotal: emptyCoins, } positionOneV2 = accumPackage.Record{ - NumShares: sdk.NewDec(150), + NumShares: osmomath.NewDec(150), AccumValuePerShare: emptyCoins, UnclaimedRewardsTotal: emptyCoins, } positionTwo = accumPackage.Record{ - NumShares: sdk.NewDec(200), + NumShares: osmomath.NewDec(200), AccumValuePerShare: emptyCoins, UnclaimedRewardsTotal: emptyCoins, } positionThree = accumPackage.Record{ - NumShares: sdk.NewDec(300), + NumShares: osmomath.NewDec(300), AccumValuePerShare: emptyCoins, UnclaimedRewardsTotal: emptyCoins, } validPositionName = testAddressThree invalidPositionName = testAddressTwo - negativeCoins = sdk.DecCoins{sdk.DecCoin{Denom: initialCoinsDenomOne[0].Denom, Amount: sdk.OneDec().Neg()}} + negativeCoins = sdk.DecCoins{sdk.DecCoin{Denom: initialCoinsDenomOne[0].Denom, Amount: osmomath.OneDec().Neg()}} ) func withInitialAccumValue(record accumPackage.Record, initialAccum sdk.DecCoins) accumPackage.Record { @@ -177,7 +178,7 @@ func (suite *AccumTestSuite) TestMakeAccumulatorWithValueAndShares() { testName string accumName string accumValue sdk.DecCoins - totalShares sdk.Dec + totalShares osmomath.Dec expAccum accumPackage.AccumulatorObject expSetPass bool expGetPass bool @@ -187,16 +188,16 @@ func (suite *AccumTestSuite) TestMakeAccumulatorWithValueAndShares() { { testName: "create valid accumulator", accumName: "spread-reward-accumulator", - accumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10)), sdk.NewDecCoin("bar", sdk.NewInt(20))), - totalShares: sdk.NewDec(30), + accumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10)), sdk.NewDecCoin("bar", osmomath.NewInt(20))), + totalShares: osmomath.NewDec(30), expSetPass: true, expGetPass: true, }, { testName: "create duplicate accumulator", accumName: "spread-reward-accumulator", - accumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10)), sdk.NewDecCoin("bar", sdk.NewInt(20))), - totalShares: sdk.NewDec(30), + accumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10)), sdk.NewDecCoin("bar", osmomath.NewInt(20))), + totalShares: osmomath.NewDec(30), expSetPass: false, expGetPass: true, }, @@ -234,7 +235,7 @@ func (suite *AccumTestSuite) TestNewPosition() { tests := map[string]struct { initialCoins sdk.DecCoins name string - numShareUnits sdk.Dec + numShareUnits osmomath.Dec options *accumPackage.Options expectedPosition accumPackage.Record }{ @@ -315,7 +316,7 @@ func (suite *AccumTestSuite) TestNewPositionIntervalAccumulation() { tests := map[string]struct { accObject *accumPackage.AccumulatorObject name string - numShareUnits sdk.Dec + numShareUnits osmomath.Dec intervalAccumulationPerShare sdk.DecCoins options *accumPackage.Options expectedPosition accumPackage.Record @@ -336,10 +337,10 @@ func (suite *AccumTestSuite) TestNewPositionIntervalAccumulation() { accObject: defaultAccObject, name: testAddressTwo, numShareUnits: positionTwo.NumShares, - intervalAccumulationPerShare: defaultAccObject.GetValue().MulDec(sdk.NewDec(2)), + intervalAccumulationPerShare: defaultAccObject.GetValue().MulDec(osmomath.NewDec(2)), expectedPosition: accumPackage.Record{ NumShares: positionTwo.NumShares, - AccumValuePerShare: defaultAccObject.GetValue().MulDec(sdk.NewDec(2)), + AccumValuePerShare: defaultAccObject.GetValue().MulDec(osmomath.NewDec(2)), UnclaimedRewardsTotal: emptyCoins, }, options: &emptyPositionOptions, @@ -348,10 +349,10 @@ func (suite *AccumTestSuite) TestNewPositionIntervalAccumulation() { accObject: defaultAccObject, name: testAddressOne, numShareUnits: positionOne.NumShares, - intervalAccumulationPerShare: defaultAccObject.GetValue().MulDec(sdk.NewDec(-1)), + intervalAccumulationPerShare: defaultAccObject.GetValue().MulDec(osmomath.NewDec(-1)), expectedPosition: accumPackage.Record{ NumShares: positionOne.NumShares, - AccumValuePerShare: defaultAccObject.GetValue().MulDec(sdk.NewDec(-1)), + AccumValuePerShare: defaultAccObject.GetValue().MulDec(osmomath.NewDec(-1)), UnclaimedRewardsTotal: emptyCoins, }, }, @@ -400,7 +401,7 @@ func (suite *AccumTestSuite) TestClaimRewards() { tripleDenomOneAndTwo = sdk.NewDecCoins( sdk.NewDecCoinFromDec(denomOne, initialValueOne), - sdk.NewDecCoinFromDec(denomTwo, sdk.NewDec(3))) + sdk.NewDecCoinFromDec(denomTwo, osmomath.NewDec(3))) ) // single output convenience wrapper. @@ -546,9 +547,9 @@ func (suite *AccumTestSuite) TestClaimRewards() { func (suite *AccumTestSuite) TestAddToPosition() { type testcase struct { - startingNumShares sdk.Dec + startingNumShares osmomath.Dec startingUnclaimedRewards sdk.DecCoins - newShares sdk.Dec + newShares osmomath.Dec // accumInit and expAccumDelta specify the initial accum value // and how much it has changed since the position being added @@ -562,9 +563,9 @@ func (suite *AccumTestSuite) TestAddToPosition() { tests := map[string]testcase{ "zero shares with no new rewards": { - startingNumShares: sdk.ZeroDec(), + startingNumShares: osmomath.ZeroDec(), startingUnclaimedRewards: sdk.NewDecCoins(), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), // unchanged accum value, so no unclaimed rewards expAccumDelta: sdk.NewDecCoins(), @@ -573,7 +574,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "non-zero shares with no new rewards": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - newShares: sdk.NewDec(10), + newShares: osmomath.NewDec(10), accumInit: sdk.NewDecCoins(), // unchanged accum value, so no unclaimed rewards expAccumDelta: sdk.NewDecCoins(), @@ -582,7 +583,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "non-zero shares with new rewards in one denom": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), // unclaimed rewards since last update expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne), @@ -591,15 +592,15 @@ func (suite *AccumTestSuite) TestAddToPosition() { "non-zero shares with new rewards in two denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, }, "non-zero shares with both existing and new rewards": { startingNumShares: initialValueOne, - startingUnclaimedRewards: sdk.NewDecCoins(sdk.NewDecCoin(denomOne, sdk.NewInt(11)), sdk.NewDecCoin(denomTwo, sdk.NewInt(11))), - newShares: sdk.OneDec(), + startingUnclaimedRewards: sdk.NewDecCoins(sdk.NewDecCoin(denomOne, osmomath.NewInt(11)), sdk.NewDecCoin(denomTwo, osmomath.NewInt(11))), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -607,7 +608,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "non-zero shares with both existing (one denom) and new rewards (two denoms)": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -615,7 +616,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "non-zero shares with both existing (one denom) and new rewards (two new denoms)": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomTwo, initialCoinDenomThree), expPass: true, @@ -623,7 +624,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "nonzero accumulator starting value, delta with same denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -631,7 +632,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "nonzero accumulator starting value, delta with new denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expAccumDelta: sdk.NewDecCoins(initialCoinDenomTwo, initialCoinDenomThree), expPass: true, @@ -639,7 +640,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "decimal shares with new rewards in two denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - newShares: sdk.NewDecWithPrec(983429874321, 5), + newShares: osmomath.NewDecWithPrec(983429874321, 5), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -650,16 +651,16 @@ func (suite *AccumTestSuite) TestAddToPosition() { addrDoesNotExist: true, expPass: false, - startingNumShares: sdk.OneDec(), + startingNumShares: osmomath.OneDec(), startingUnclaimedRewards: emptyCoins, - newShares: sdk.OneDec(), + newShares: osmomath.OneDec(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), }, "attempt to add zero shares": { startingNumShares: initialValueOne, startingUnclaimedRewards: emptyCoins, - newShares: sdk.ZeroDec(), + newShares: osmomath.ZeroDec(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), expPass: false, @@ -667,7 +668,7 @@ func (suite *AccumTestSuite) TestAddToPosition() { "attempt to add negative shares": { startingNumShares: initialValueOne, startingUnclaimedRewards: emptyCoins, - newShares: sdk.OneDec().Neg(), + newShares: osmomath.OneDec().Neg(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), expPass: false, @@ -753,7 +754,7 @@ func (suite *AccumTestSuite) TestAddToPositionIntervalAccumulation() { tests := map[string]struct { accObject *accumPackage.AccumulatorObject name string - numShareUnits sdk.Dec + numShareUnits osmomath.Dec intervalAccumulationPerShare sdk.DecCoins expectedPosition accumPackage.Record expectedError error @@ -773,10 +774,10 @@ func (suite *AccumTestSuite) TestAddToPositionIntervalAccumulation() { accObject: accObject, name: testAddressTwo, numShareUnits: positionTwo.NumShares, - intervalAccumulationPerShare: accObject.GetValue().MulDec(sdk.NewDec(2)), + intervalAccumulationPerShare: accObject.GetValue().MulDec(osmomath.NewDec(2)), expectedPosition: accumPackage.Record{ NumShares: positionTwo.NumShares, - AccumValuePerShare: accObject.GetValue().MulDec(sdk.NewDec(2)), + AccumValuePerShare: accObject.GetValue().MulDec(osmomath.NewDec(2)), UnclaimedRewardsTotal: emptyCoins, }, }, @@ -789,7 +790,7 @@ func (suite *AccumTestSuite) TestAddToPositionIntervalAccumulation() { expectedAccValue = expectedAccValue.Add(tc.numShareUnits) // Setup - err := tc.accObject.NewPositionIntervalAccumulation(tc.name, sdk.ZeroDec(), tc.accObject.GetValue(), nil) + err := tc.accObject.NewPositionIntervalAccumulation(tc.name, osmomath.ZeroDec(), tc.accObject.GetValue(), nil) suite.Require().NoError(err) // System under test. @@ -820,9 +821,9 @@ func (suite *AccumTestSuite) TestAddToPositionIntervalAccumulation() { func (suite *AccumTestSuite) TestRemoveFromPosition() { type testcase struct { - startingNumShares sdk.Dec + startingNumShares osmomath.Dec startingUnclaimedRewards sdk.DecCoins - removedShares sdk.Dec + removedShares osmomath.Dec // accumInit and expAccumDelta specify the initial accum value // and how much it has changed since the position being added @@ -838,7 +839,7 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "no new rewards": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), // unchanged accum value, so no unclaimed rewards expAccumDelta: sdk.NewDecCoins(), @@ -847,7 +848,7 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "new rewards in one denom": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), // unclaimed rewards since last update expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne), @@ -856,15 +857,15 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "new rewards in two denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, }, "both existing and new rewards": { startingNumShares: initialValueOne, - startingUnclaimedRewards: sdk.NewDecCoins(sdk.NewDecCoin(denomOne, sdk.NewInt(11)), sdk.NewDecCoin(denomTwo, sdk.NewInt(11))), - removedShares: sdk.OneDec(), + startingUnclaimedRewards: sdk.NewDecCoins(sdk.NewDecCoin(denomOne, osmomath.NewInt(11)), sdk.NewDecCoin(denomTwo, osmomath.NewInt(11))), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -872,7 +873,7 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "both existing (one denom) and new rewards (two denoms, one overlapping)": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -880,7 +881,7 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "both existing (one denom) and new rewards (two new denoms)": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomTwo, initialCoinDenomThree), expPass: true, @@ -888,7 +889,7 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "nonzero accumulator starting value, delta with same denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, @@ -896,23 +897,23 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { "nonzero accumulator starting value, delta with new denoms": { startingNumShares: initialValueOne, startingUnclaimedRewards: sdk.NewDecCoins(initialCoinDenomOne), - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expAccumDelta: sdk.NewDecCoins(initialCoinDenomTwo, initialCoinDenomThree), expPass: true, }, "remove decimal shares with new rewards in two denoms": { - startingNumShares: sdk.NewDec(1000000), + startingNumShares: osmomath.NewDec(1000000), startingUnclaimedRewards: sdk.NewDecCoins(), - removedShares: sdk.NewDecWithPrec(7489274134, 5), + removedShares: osmomath.NewDecWithPrec(7489274134, 5), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), expPass: true, }, "attempt to remove exactly numShares": { - startingNumShares: sdk.OneDec(), + startingNumShares: osmomath.OneDec(), startingUnclaimedRewards: emptyCoins, - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), expPass: true, @@ -925,22 +926,22 @@ func (suite *AccumTestSuite) TestRemoveFromPosition() { startingNumShares: initialValueOne, startingUnclaimedRewards: emptyCoins, - removedShares: sdk.OneDec(), + removedShares: osmomath.OneDec(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), }, "attempt to remove zero shares": { startingNumShares: initialValueOne, startingUnclaimedRewards: emptyCoins, - removedShares: sdk.ZeroDec(), + removedShares: osmomath.ZeroDec(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), expPass: false, }, "attempt to remove negative shares": { - startingNumShares: sdk.OneDec(), + startingNumShares: osmomath.OneDec(), startingUnclaimedRewards: emptyCoins, - removedShares: sdk.OneDec().Neg(), + removedShares: osmomath.OneDec().Neg(), accumInit: emptyCoins, expAccumDelta: sdk.NewDecCoins(), expPass: false, @@ -1031,7 +1032,7 @@ func (suite *AccumTestSuite) TestRemoveFromPositionIntervalAccumulation() { tests := map[string]struct { accObject *accumPackage.AccumulatorObject name string - numShareUnits sdk.Dec + numShareUnits osmomath.Dec intervalAccumulationPerShare sdk.DecCoins expectedPosition accumPackage.Record expectedError error @@ -1042,22 +1043,22 @@ func (suite *AccumTestSuite) TestRemoveFromPositionIntervalAccumulation() { numShareUnits: positionOne.NumShares, intervalAccumulationPerShare: baseAccumValue, expectedPosition: accumPackage.Record{ - NumShares: sdk.ZeroDec(), + NumShares: osmomath.ZeroDec(), AccumValuePerShare: baseAccumValue, // base value - 0.5 * base = base value - UnclaimedRewardsTotal: baseAccumValue.MulDec(sdk.NewDecWithPrec(5, 1)).MulDec(positionOne.NumShares), + UnclaimedRewardsTotal: baseAccumValue.MulDec(osmomath.NewDecWithPrec(5, 1)).MulDec(positionOne.NumShares), }, }, "interval acc value does not equal to acc": { accObject: accObject, name: testAddressTwo, numShareUnits: positionTwo.NumShares, - intervalAccumulationPerShare: baseAccumValue.MulDec(sdk.NewDecWithPrec(75, 2)), + intervalAccumulationPerShare: baseAccumValue.MulDec(osmomath.NewDecWithPrec(75, 2)), expectedPosition: accumPackage.Record{ - NumShares: sdk.ZeroDec(), - AccumValuePerShare: baseAccumValue.MulDec(sdk.NewDecWithPrec(75, 2)), + NumShares: osmomath.ZeroDec(), + AccumValuePerShare: baseAccumValue.MulDec(osmomath.NewDecWithPrec(75, 2)), // base value - 0.75 * base = 0.25 * base - UnclaimedRewardsTotal: baseAccumValue.MulDec(sdk.NewDecWithPrec(25, 2)).MulDec(positionTwo.NumShares), + UnclaimedRewardsTotal: baseAccumValue.MulDec(osmomath.NewDecWithPrec(25, 2)).MulDec(positionTwo.NumShares), }, }, } @@ -1070,7 +1071,7 @@ func (suite *AccumTestSuite) TestRemoveFromPositionIntervalAccumulation() { expectedGlobalAccValue := tc.accObject.GetTotalShareField() // Original position's accum is always set to 0.5 * base value. - err := tc.accObject.NewPositionIntervalAccumulation(tc.name, tc.numShareUnits, initialCoinsDenomOne.MulDec(sdk.NewDecWithPrec(5, 1)), nil) + err := tc.accObject.NewPositionIntervalAccumulation(tc.name, tc.numShareUnits, initialCoinsDenomOne.MulDec(osmomath.NewDecWithPrec(5, 1)), nil) suite.Require().NoError(err) tc.accObject.SetValue(tc.intervalAccumulationPerShare) @@ -1103,8 +1104,8 @@ func (suite *AccumTestSuite) TestRemoveFromPositionIntervalAccumulation() { func (suite *AccumTestSuite) TestGetPositionSize() { type testcase struct { - numShares sdk.Dec - changedShares sdk.Dec + numShares osmomath.Dec + changedShares osmomath.Dec // accumInit and expAccumDelta specify the initial accum value // and how much it has changed since the position being added @@ -1118,34 +1119,34 @@ func (suite *AccumTestSuite) TestGetPositionSize() { tests := map[string]testcase{ "unchanged accumulator": { - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(), - changedShares: sdk.ZeroDec(), + changedShares: osmomath.ZeroDec(), expPass: true, }, "changed accumulator": { - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(initialCoinDenomOne, initialCoinDenomTwo), - changedShares: sdk.ZeroDec(), + changedShares: osmomath.ZeroDec(), expPass: true, }, "changed number of shares": { - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(), - changedShares: sdk.OneDec(), + changedShares: osmomath.OneDec(), expPass: true, }, "account does not exist": { addrDoesNotExist: true, expPass: false, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), accumInit: sdk.NewDecCoins(), expAccumDelta: sdk.NewDecCoins(), - changedShares: sdk.ZeroDec(), + changedShares: osmomath.ZeroDec(), }, } @@ -1197,12 +1198,12 @@ func (suite *AccumTestSuite) TestMarhsalUnmarshalRecord() { suite.SetupTest() recordNoOptions := accumPackage.Record{ - NumShares: sdk.OneDec(), + NumShares: osmomath.OneDec(), AccumValuePerShare: sdk.NewDecCoins( - sdk.NewDecCoinFromDec(denomOne, sdk.OneDec()), + sdk.NewDecCoinFromDec(denomOne, osmomath.OneDec()), ), UnclaimedRewardsTotal: sdk.NewDecCoins( - sdk.NewDecCoinFromDec(denomOne, sdk.OneDec()), + sdk.NewDecCoinFromDec(denomOne, osmomath.OneDec()), ), } @@ -1227,9 +1228,9 @@ func (suite *AccumTestSuite) TestAddToAccumulator() { expectedValue: initialCoinsDenomOne, }, "negative": { - updateAmount: initialCoinsDenomOne.MulDec(sdk.NewDec(-1)), + updateAmount: initialCoinsDenomOne.MulDec(osmomath.NewDec(-1)), - expectedValue: initialCoinsDenomOne.MulDec(sdk.NewDec(-1)), + expectedValue: initialCoinsDenomOne.MulDec(osmomath.NewDec(-1)), }, "multiple coins": { updateAmount: initialCoinsDenomOne.Add(initialCoinDenomTwo), @@ -1270,33 +1271,33 @@ func (suite *AccumTestSuite) TestUpdatePosition() { tests := map[string]struct { name string - numShares sdk.Dec + numShares osmomath.Dec expectedPosition accumPackage.Record expectError error }{ "positive - acts as AddToPosition": { name: testAddressOne, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), expectedPosition: accumPackage.Record{ - NumShares: sdk.OneDec().MulInt64(2), + NumShares: osmomath.OneDec().MulInt64(2), AccumValuePerShare: initialCoinsDenomOne, UnclaimedRewardsTotal: emptyCoins, }, }, "negative - acts as RemoveFromPosition": { name: testAddressOne, - numShares: sdk.OneDec().Neg(), + numShares: osmomath.OneDec().Neg(), expectedPosition: accumPackage.Record{ - NumShares: sdk.ZeroDec(), + NumShares: osmomath.ZeroDec(), AccumValuePerShare: initialCoinsDenomOne, UnclaimedRewardsTotal: emptyCoins, }, }, "zero - error": { name: testAddressOne, - numShares: sdk.ZeroDec(), + numShares: osmomath.ZeroDec(), expectError: accumPackage.ZeroSharesError, }, @@ -1306,9 +1307,9 @@ func (suite *AccumTestSuite) TestUpdatePosition() { suite.Run(name, func() { suite.SetupTest() - expectedGlobalAccValue := accObject.GetTotalShareField().Add(tc.numShares).Add(sdk.OneDec()) + expectedGlobalAccValue := accObject.GetTotalShareField().Add(tc.numShares).Add(osmomath.OneDec()) - err := accObject.NewPosition(tc.name, sdk.OneDec(), nil) + err := accObject.NewPosition(tc.name, osmomath.OneDec(), nil) suite.Require().NoError(err) err = accObject.UpdatePosition(tc.name, tc.numShares) @@ -1343,17 +1344,17 @@ func (suite *AccumTestSuite) TestUpdatePosition() { func (suite *AccumTestSuite) TestUpdatePositionIntervalAccumulation() { tests := []struct { testName string - initialShares sdk.Dec + initialShares osmomath.Dec initialAccum sdk.DecCoins accName string - numShareUnits sdk.Dec + numShareUnits osmomath.Dec intervalAccumulationPerShare sdk.DecCoins expectedPosition accumPackage.Record expectedError error }{ { testName: "interval acc value equals to acc; positive shares -> acts as AddToPosition", - initialShares: sdk.ZeroDec(), + initialShares: osmomath.ZeroDec(), initialAccum: initialCoinsDenomOne, accName: testAddressOne, numShareUnits: positionOne.NumShares, @@ -1370,10 +1371,10 @@ func (suite *AccumTestSuite) TestUpdatePositionIntervalAccumulation() { initialAccum: initialCoinsDenomOne, accName: testAddressTwo, numShareUnits: positionTwo.NumShares.Neg(), // note: negative shares - intervalAccumulationPerShare: initialCoinsDenomOne.MulDec(sdk.NewDec(2)), + intervalAccumulationPerShare: initialCoinsDenomOne.MulDec(osmomath.NewDec(2)), expectedPosition: accumPackage.Record{ - NumShares: sdk.ZeroDec(), // results in 0 shares (200 - 200) - AccumValuePerShare: initialCoinsDenomOne.MulDec(sdk.NewDec(2)), + NumShares: osmomath.ZeroDec(), // results in 0 shares (200 - 200) + AccumValuePerShare: initialCoinsDenomOne.MulDec(osmomath.NewDec(2)), UnclaimedRewardsTotal: emptyCoins, }, }, @@ -1383,10 +1384,10 @@ func (suite *AccumTestSuite) TestUpdatePositionIntervalAccumulation() { initialAccum: initialCoinsDenomOne, accName: testAddressTwo, numShareUnits: positionOne.NumShares.Neg(), // note: negative shares - intervalAccumulationPerShare: initialCoinsDenomOne.MulDec(sdk.NewDec(2)), + intervalAccumulationPerShare: initialCoinsDenomOne.MulDec(osmomath.NewDec(2)), expectedPosition: accumPackage.Record{ NumShares: positionOne.NumShares, // results in 100 shares (200 - 100) - AccumValuePerShare: initialCoinsDenomOne.MulDec(sdk.NewDec(2)), + AccumValuePerShare: initialCoinsDenomOne.MulDec(osmomath.NewDec(2)), UnclaimedRewardsTotal: emptyCoins, }, }, @@ -1467,7 +1468,7 @@ func (suite *AccumTestSuite) TestHasPosition() { suite.Run(tc.name, func() { // Setup if tc.preCreatePosition { - err := accObject.NewPosition(defaultPositionName, sdk.ZeroDec(), nil) + err := accObject.NewPosition(defaultPositionName, osmomath.ZeroDec(), nil) suite.Require().NoError(err) } @@ -1510,7 +1511,7 @@ func (suite *AccumTestSuite) TestSetPositionIntervalAccumulation() { suite.Run(name, func() { // Setup - err := accObject.NewPositionIntervalAccumulation(validPositionName, sdk.OneDec(), initialCoinsDenomOne, nil) + err := accObject.NewPositionIntervalAccumulation(validPositionName, osmomath.OneDec(), initialCoinsDenomOne, nil) suite.Require().NoError(err) // System under test. @@ -1527,7 +1528,7 @@ func (suite *AccumTestSuite) TestSetPositionIntervalAccumulation() { position := accObject.MustGetPosition(tc.positionName) suite.Require().Equal(tc.intervalAccumulationPerShare, position.GetAccumValuePerShare()) // unchanged - suite.Require().Equal(sdk.OneDec(), position.NumShares) + suite.Require().Equal(osmomath.OneDec(), position.NumShares) suite.Require().Equal(emptyCoins, position.GetUnclaimedRewardsTotal()) }) } @@ -1544,22 +1545,22 @@ func (suite *AccumTestSuite) TestGetTotalShares() { accumOne, accumTwo := suite.MakeAndGetAccumulator(testNameOne), suite.MakeAndGetAccumulator(testNameTwo) // Sanity check initial accumulators (start at zero shares) - suite.TotalSharesCheck(accumOne, sdk.ZeroDec()) - suite.TotalSharesCheck(accumTwo, sdk.ZeroDec()) + suite.TotalSharesCheck(accumOne, osmomath.ZeroDec()) + suite.TotalSharesCheck(accumTwo, osmomath.ZeroDec()) // Create position on first accum and pull new accum objects from state - err := accumOne.NewPosition(testAddressOne, sdk.OneDec(), nil) + err := accumOne.NewPosition(testAddressOne, osmomath.OneDec(), nil) suite.Require().NoError(err) accumOne, accumTwo = suite.GetAccumulator(testNameOne), suite.GetAccumulator(testNameTwo) // Check that total shares for accum one has updated properly and accum two shares are unchanged - suite.TotalSharesCheck(accumOne, sdk.OneDec()) - suite.TotalSharesCheck(accumTwo, sdk.ZeroDec()) + suite.TotalSharesCheck(accumOne, osmomath.OneDec()) + suite.TotalSharesCheck(accumTwo, osmomath.ZeroDec()) // Run a number of NewPosition, AddToPosition, and RemoveFromPosition operations on each accum testAddresses := []string{testAddressOne, testAddressTwo, testAddressThree} accums := []*accumPackage.AccumulatorObject{accumOne, accumTwo} - expectedShares := []sdk.Dec{sdk.OneDec(), sdk.ZeroDec()} + expectedShares := []osmomath.Dec{osmomath.OneDec(), osmomath.ZeroDec()} for i := 1; i <= 10; i++ { // Cycle through accounts and accumulators @@ -1567,7 +1568,7 @@ func (suite *AccumTestSuite) TestGetTotalShares() { curAccum := accums[i%2] // We set a baseAmt that varies with the iteration to increase coverage - baseAmt := sdk.NewDec(int64(i)).Mul(sdk.NewDec(10)) + baseAmt := osmomath.NewDec(int64(i)).Mul(osmomath.NewDec(10)) // If addr doesn't have a position yet, we make one positionExists := curAccum.HasPosition(curAddr) @@ -1578,8 +1579,8 @@ func (suite *AccumTestSuite) TestGetTotalShares() { // We generate a random binary value (0 or 1) to determine // whether we will add and/or remove liquidity this loop - addShares := sdk.NewDec(int64(rand.Int()) % 2) - removeShares := sdk.NewDec(int64(rand.Int()) % 2) + addShares := osmomath.NewDec(int64(rand.Int()) % 2) + removeShares := osmomath.NewDec(int64(rand.Int()) % 2) // Half the time, we add to the new position addAmt := baseAmt.Mul(addShares) @@ -1589,7 +1590,7 @@ func (suite *AccumTestSuite) TestGetTotalShares() { } // Half the time, we remove one share from the position - amtToRemove := sdk.OneDec().Mul(removeShares) + amtToRemove := osmomath.OneDec().Mul(removeShares) if amtToRemove.IsPositive() { err = curAccum.RemoveFromPosition(curAddr, amtToRemove) suite.Require().NoError(err) @@ -1648,7 +1649,7 @@ func (suite *AccumTestSuite) TestAddToUnclaimedRewards() { for name, tc := range tests { suite.Run(name, func() { - err := accObject.NewPositionIntervalAccumulation(validPositionName, sdk.OneDec(), initialCoinsDenomOne, nil) + err := accObject.NewPositionIntervalAccumulation(validPositionName, osmomath.OneDec(), initialCoinsDenomOne, nil) suite.Require().NoError(err) // Update global accumulator. @@ -1713,7 +1714,7 @@ func (suite *AccumTestSuite) TestDeletePosition() { // Setup. accObject := accumPackage.MakeTestAccumulator(suite.store, testNameOne, initialCoinsDenomOne, emptyDec) - err := accObject.NewPosition(validPositionName, sdk.NewDec(tc.numShares), nil) + err := accObject.NewPosition(validPositionName, osmomath.NewDec(tc.numShares), nil) suite.Require().NoError(err) // Update global accumulator. @@ -1737,9 +1738,9 @@ func (suite *AccumTestSuite) TestDeletePosition() { suite.Require().Equal(tc.expectedUnclaimedRewards, unclaimedRewards) // Check that global accumulator value is updated - suite.TotalSharesCheck(accObject, sdk.ZeroDec()) + suite.TotalSharesCheck(accObject, osmomath.ZeroDec()) // Check that accumulator receiver is mutated. - suite.Require().Equal(sdk.ZeroDec().String(), accObject.GetTotalShareField().String()) + suite.Require().Equal(osmomath.ZeroDec().String(), accObject.GetTotalShareField().String()) }) } } diff --git a/osmoutils/accum/export_test.go b/osmoutils/accum/export_test.go index d477e68c5c3..bcb8b4091fb 100644 --- a/osmoutils/accum/export_test.go +++ b/osmoutils/accum/export_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/store" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) @@ -21,7 +22,7 @@ func (accum AccumulatorObject) GetAllPositions() ([]Record, error) { } // Creates an accumulator object for testing purposes -func MakeTestAccumulator(store store.KVStore, name string, value sdk.DecCoins, totalShares sdk.Dec) *AccumulatorObject { +func MakeTestAccumulator(store store.KVStore, name string, value sdk.DecCoins, totalShares osmomath.Dec) *AccumulatorObject { // We store an accumulator object in state even if unused in tests // because position operations still require GetAccumulator to work _ = MakeAccumulator(store, name) @@ -72,7 +73,7 @@ func (o *Options) Validate() error { // WARNING: only used in tests to make sure that receiver is mutated. // Do not move out of export_test.go and do not use in production code. -func (accum AccumulatorObject) GetTotalShareField() sdk.Dec { +func (accum AccumulatorObject) GetTotalShareField() osmomath.Dec { return accum.totalShares } @@ -82,6 +83,6 @@ func (accum AccumulatorObject) GetValueField() sdk.DecCoins { return accum.valuePerShare } -func InitOrUpdatePosition(accum *AccumulatorObject, accumulatorValue sdk.DecCoins, index string, numShareUnits sdk.Dec, unclaimedRewards sdk.DecCoins, options *Options) { +func InitOrUpdatePosition(accum *AccumulatorObject, accumulatorValue sdk.DecCoins, index string, numShareUnits osmomath.Dec, unclaimedRewards sdk.DecCoins, options *Options) { initOrUpdatePosition(accum, accumulatorValue, index, numShareUnits, unclaimedRewards, options) } diff --git a/osmoutils/accum/options.go b/osmoutils/accum/options.go index 51add520dde..7a6034e2a91 100644 --- a/osmoutils/accum/options.go +++ b/osmoutils/accum/options.go @@ -1,10 +1,8 @@ package accum -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import "github.com/osmosis-labs/osmosis/osmomath" -var one = sdk.OneDec() +var one = osmomath.OneDec() // validate returns nil if Options are valid. // Error otherwise. Note, that, currently, diff --git a/osmoutils/cli_helpers.go b/osmoutils/cli_helpers.go index e07c2d43a98..326f9f0dfbc 100644 --- a/osmoutils/cli_helpers.go +++ b/osmoutils/cli_helpers.go @@ -9,10 +9,12 @@ import ( "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/ed25519" + + "github.com/osmosis-labs/osmosis/osmomath" ) func DefaultFeeString(cfg network.Config) string { - feeCoins := sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, sdk.NewInt(10))) + feeCoins := sdk.NewCoins(sdk.NewCoin(cfg.BondDenom, osmomath.NewInt(10))) return fmt.Sprintf("--%s=%s", flags.FlagFees, feeCoins.String()) } @@ -35,8 +37,8 @@ func ParseUint64SliceFromString(s string, separator string) ([]uint64, error) { return parsedInts, nil } -func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error) { - var parsedInts []sdk.Int +func ParseSdkIntFromString(s string, separator string) ([]osmomath.Int, error) { + var parsedInts []osmomath.Int for _, weightStr := range strings.Split(s, separator) { weightStr = strings.TrimSpace(weightStr) @@ -44,17 +46,17 @@ func ParseSdkIntFromString(s string, separator string) ([]sdk.Int, error) { if err != nil { return parsedInts, err } - parsedInts = append(parsedInts, sdk.NewIntFromUint64(parsed)) + parsedInts = append(parsedInts, osmomath.NewIntFromUint64(parsed)) } return parsedInts, nil } -func ParseSdkDecFromString(s string, separator string) ([]sdk.Dec, error) { - var parsedDec []sdk.Dec +func ParseSdkDecFromString(s string, separator string) ([]osmomath.Dec, error) { + var parsedDec []osmomath.Dec for _, weightStr := range strings.Split(s, separator) { weightStr = strings.TrimSpace(weightStr) - parsed, err := sdk.NewDecFromStr(weightStr) + parsed, err := osmomath.NewDecFromStr(weightStr) if err != nil { return parsedDec, err } diff --git a/osmoutils/coin_helper_test.go b/osmoutils/coin_helper_test.go index ddcc8cc4b6a..2e51bf04216 100644 --- a/osmoutils/coin_helper_test.go +++ b/osmoutils/coin_helper_test.go @@ -6,20 +6,21 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" ) var ( emptyCoins = sdk.DecCoins(nil) - fiftyFoo = sdk.NewDecCoin("foo", sdk.NewInt(50)) - fiftyBar = sdk.NewDecCoin("bar", sdk.NewInt(50)) - hundredFoo = sdk.NewDecCoin("foo", sdk.NewInt(100)) - hundredBar = sdk.NewDecCoin("bar", sdk.NewInt(100)) - hundredFiftyFoo = sdk.NewDecCoin("foo", sdk.NewInt(150)) - hundredFiftyBar = sdk.NewDecCoin("bar", sdk.NewInt(150)) - twoHundredFoo = sdk.NewDecCoin("foo", sdk.NewInt(200)) - twoHundredBar = sdk.NewDecCoin("bar", sdk.NewInt(200)) + fiftyFoo = sdk.NewDecCoin("foo", osmomath.NewInt(50)) + fiftyBar = sdk.NewDecCoin("bar", osmomath.NewInt(50)) + hundredFoo = sdk.NewDecCoin("foo", osmomath.NewInt(100)) + hundredBar = sdk.NewDecCoin("bar", osmomath.NewInt(100)) + hundredFiftyFoo = sdk.NewDecCoin("foo", osmomath.NewInt(150)) + hundredFiftyBar = sdk.NewDecCoin("bar", osmomath.NewInt(150)) + twoHundredFoo = sdk.NewDecCoin("foo", osmomath.NewInt(200)) + twoHundredBar = sdk.NewDecCoin("bar", osmomath.NewInt(200)) fiftyEach = sdk.NewDecCoins(fiftyFoo, fiftyBar) hundredEach = sdk.NewDecCoins(hundredFoo, hundredBar) @@ -77,7 +78,7 @@ func TestSubDecCoins(t *testing.T) { firstInput: []sdk.DecCoins{fiftyEach}, secondInput: []sdk.DecCoins{hundredEach}, - expectedOutput: []sdk.DecCoins{{sdk.DecCoin{Denom: "bar", Amount: sdk.NewDec(-50)}, sdk.DecCoin{Denom: "foo", Amount: sdk.NewDec(-50)}}}, + expectedOutput: []sdk.DecCoins{{sdk.DecCoin{Denom: "bar", Amount: osmomath.NewDec(-50)}, sdk.DecCoin{Denom: "foo", Amount: osmomath.NewDec(-50)}}}, expectPanicUnsafe: true, }, } @@ -233,13 +234,13 @@ func TestConvertCoinsToDecCoins(t *testing.T) { }, { name: "Single coin", - inputCoins: sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(100000000))), - expectedDecCoins: sdk.NewDecCoins(sdk.NewDecCoin("atom", sdk.NewInt(100000000))), + inputCoins: sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(100000000))), + expectedDecCoins: sdk.NewDecCoins(sdk.NewDecCoin("atom", osmomath.NewInt(100000000))), }, { name: "Multiple coins", - inputCoins: sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(100000000)), sdk.NewCoin("usdc", sdk.NewInt(500000000))), - expectedDecCoins: sdk.NewDecCoins(sdk.NewDecCoin("atom", sdk.NewInt(100000000)), sdk.NewDecCoin("usdc", sdk.NewInt(500000000))), + inputCoins: sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(100000000)), sdk.NewCoin("usdc", osmomath.NewInt(500000000))), + expectedDecCoins: sdk.NewDecCoins(sdk.NewDecCoin("atom", osmomath.NewInt(100000000)), sdk.NewDecCoin("usdc", osmomath.NewInt(500000000))), }, } diff --git a/osmoutils/errors.go b/osmoutils/errors.go index 51dc951915c..54b6d10cc2f 100644 --- a/osmoutils/errors.go +++ b/osmoutils/errors.go @@ -7,5 +7,5 @@ type DecNotFoundError struct { } func (e DecNotFoundError) Error() string { - return fmt.Sprintf("no sdk.Dec at key (%s)", e.Key) + return fmt.Sprintf("no osmomath.Dec at key (%s)", e.Key) } diff --git a/osmoutils/go.mod b/osmoutils/go.mod index 31904d921fe..587347328ab 100644 --- a/osmoutils/go.mod +++ b/osmoutils/go.mod @@ -3,11 +3,13 @@ module github.com/osmosis-labs/osmosis/osmoutils go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.4 + cosmossdk.io/math v1.1.3-rc.0 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/cosmos/iavl v0.19.5 github.com/cosmos/ibc-go/v4 v4.3.1 github.com/gogo/protobuf v1.3.3 - github.com/osmosis-labs/osmosis/v17 v17.0.0-20230811221421-2e3f19d86dd4 + github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d + github.com/osmosis-labs/osmosis/v19 v19.0.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.8.4 @@ -27,7 +29,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd v0.22.3 // indirect - github.com/bytedance/sonic v1.10.0 // indirect + github.com/bytedance/sonic v1.10.1 // 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 @@ -37,8 +39,6 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect - github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.0 // indirect - github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.1.0 // indirect github.com/cosmos/ledger-cosmos-go v0.12.2 // indirect github.com/creachadair/taskgroup v0.3.2 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -92,8 +92,6 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.27.6 // indirect - github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230804142026-a81cfe3ddde7 // 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 @@ -108,7 +106,6 @@ require ( github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect @@ -128,7 +125,6 @@ require ( golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.12.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 @@ -141,8 +137,8 @@ require ( ) replace ( - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // use cosmos-compatible protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.24 diff --git a/osmoutils/go.sum b/osmoutils/go.sum index 652a6fa685d..58539856b6c 100644 --- a/osmoutils/go.sum +++ b/osmoutils/go.sum @@ -39,6 +39,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 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 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -143,7 +145,9 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +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.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= 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= @@ -158,8 +162,12 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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= @@ -189,6 +197,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -341,6 +350,7 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw 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.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= @@ -557,10 +567,12 @@ github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8 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/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/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= @@ -580,6 +592,7 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -692,12 +705,13 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 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.20230804142026-a81cfe3ddde7 h1:NTR4zfrPMP4pJ5T60zyZumBAnTWmTAQX/JSZLGrM9jI= -github.com/osmosis-labs/osmosis/v17 v17.0.0-20230811221421-2e3f19d86dd4 h1:EMbnmbZSJ1znKoN8Z4bwQxDN/Iq/n14KlH2QjzqeMSg= -github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo= -github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230807183608-16c217dedde5 h1:clEegVniz0zTTBXKfg2oymKa63IYUxcrVXM+LtsvCpA= +github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d h1:b8Bz31kbzTbcSNsBOcvc2CRVJz5C3cGOQB7JqWDzdfA= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d/go.mod h1:Jj4zQ/IA8iPuHF+Hc/dTFJqAis5WYX3EcO7Xg70fAd8= +github.com/osmosis-labs/osmosis/v19 v19.0.0 h1:gqcas/XfxtEuZXsWGTO9vNMHiY78Qs09FBQw73djIVM= +github.com/osmosis-labs/osmosis/v19 v19.0.0/go.mod h1:NEm0wCgbUUL9RoABQyR8QUCrdk7lNp5K/CNK44lapMI= +github.com/osmosis-labs/osmosis/x/epochs v0.0.2 h1:aEeXHGCSJMgMtAvCucsD2RSaWZ8lISFLD5u4MyF9KPc= +github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.8 h1:BUGowctYQT0vdPgULrvwraEsW+sS6DnbzndTLKLmWVY= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -878,6 +892,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 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 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= @@ -930,6 +945,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= 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= @@ -954,6 +970,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm 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.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 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= @@ -969,6 +986,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1046,6 +1064,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -1146,9 +1165,11 @@ golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBc 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.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 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= @@ -1159,6 +1180,7 @@ 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.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= @@ -1305,8 +1327,11 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D 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-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= @@ -1322,6 +1347,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.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= @@ -1368,10 +1394,12 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/osmoutils/osmoassert/assertions.go b/osmoutils/osmoassert/assertions.go index aad23e9915b..4efbd2eb98b 100644 --- a/osmoutils/osmoassert/assertions.go +++ b/osmoutils/osmoassert/assertions.go @@ -4,8 +4,9 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/osmomath" ) // ConditionalPanic checks if expectPanic is true, asserts that sut (system under test) @@ -32,7 +33,7 @@ func ConditionalError(t *testing.T, expectError bool, err error) { // DecApproxEq is a helper function to compare two decimals. // It validates the two decimal are within a certain tolerance. // If not, it fails with a message. -func DecApproxEq(t *testing.T, d1 sdk.Dec, d2 sdk.Dec, tol sdk.Dec, msgAndArgs ...interface{}) { +func DecApproxEq(t *testing.T, d1 osmomath.Dec, d2 osmomath.Dec, tol osmomath.Dec, msgAndArgs ...interface{}) { diff := d1.Sub(d2).Abs() msg := messageFromMsgAndArgs(msgAndArgs...) require.True(t, diff.LTE(tol), "expected |d1 - d2| <:\t%s\ngot |d1 - d2| = \t\t%s\nd1: %s, d2: %s\n%s", tol, diff, d1, d2, msg) diff --git a/osmoutils/osmocli/dynamic_test.go b/osmoutils/osmocli/dynamic_test.go index 32e60a13a5f..8e078641eff 100644 --- a/osmoutils/osmocli/dynamic_test.go +++ b/osmoutils/osmocli/dynamic_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/require" - clqueryproto "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/client/queryproto" - cltypes "github.com/osmosis-labs/osmosis/v17/x/concentrated-liquidity/types" - lockuptypes "github.com/osmosis-labs/osmosis/v17/x/lockup/types" + clqueryproto "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/client/queryproto" + cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" + lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) // test-specific helper descriptor diff --git a/osmoutils/osmocli/parsers.go b/osmoutils/osmocli/parsers.go index 25e178786c0..8e7b6c9166f 100644 --- a/osmoutils/osmocli/parsers.go +++ b/osmoutils/osmocli/parsers.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/spf13/pflag" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) @@ -252,11 +253,11 @@ func ParseFieldFromArg(fVal reflect.Value, fType reflect.StructField, arg string var err error if typeStr == "types.Coin" { v, err = ParseCoin(arg, fType.Name) - } else if typeStr == "types.Int" { + } else if typeStr == "math.Int" { v, err = ParseSdkInt(arg, fType.Name) } else if typeStr == "time.Time" { v, err = ParseUnixTime(arg, fType.Name) - } else if typeStr == "types.Dec" { + } else if typeStr == "math.LegacyDec" { v, err = ParseSdkDec(arg, fType.Name) } else { return fmt.Errorf("struct field type not recognized. Got type %v", fType) @@ -333,18 +334,18 @@ func ParseCoins(arg string, fieldName string) (sdk.Coins, error) { } // TODO: This really shouldn't be getting used in the CLI, its misdesign on the CLI ux -func ParseSdkInt(arg string, fieldName string) (sdk.Int, error) { - i, ok := sdk.NewIntFromString(arg) +func ParseSdkInt(arg string, fieldName string) (osmomath.Int, error) { + i, ok := osmomath.NewIntFromString(arg) if !ok { - return sdk.Int{}, fmt.Errorf("could not parse %s as sdk.Int for field %s", arg, fieldName) + return osmomath.Int{}, fmt.Errorf("could not parse %s as osmomath.Int for field %s", arg, fieldName) } return i, nil } -func ParseSdkDec(arg, fieldName string) (sdk.Dec, error) { - i, err := sdk.NewDecFromStr(arg) +func ParseSdkDec(arg, fieldName string) (osmomath.Dec, error) { + i, err := osmomath.NewDecFromStr(arg) if err != nil { - return sdk.Dec{}, fmt.Errorf("could not parse %s as sdk.Dec for field %s: %w", arg, fieldName, err) + return osmomath.Dec{}, fmt.Errorf("could not parse %s as osmomath.Dec for field %s: %w", arg, fieldName, err) } return i, nil } diff --git a/osmoutils/osmocli/parsers_test.go b/osmoutils/osmocli/parsers_test.go index 181af51742c..f933857341f 100644 --- a/osmoutils/osmocli/parsers_test.go +++ b/osmoutils/osmocli/parsers_test.go @@ -7,6 +7,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/osmomath" ) type testingStruct struct { @@ -18,7 +20,7 @@ type testingStruct struct { Pointer *testingStruct Slice sdk.Coins Struct interface{} - Dec sdk.Dec + Dec osmomath.Dec } func TestParseFieldFromArg(t *testing.T) { @@ -80,24 +82,24 @@ func TestParseFieldFromArg(t *testing.T) { }, "Slice change": { testingStruct: testingStruct{Slice: sdk.Coins{ - sdk.NewCoin("foo", sdk.NewInt(100)), - sdk.NewCoin("bar", sdk.NewInt(100)), + sdk.NewCoin("foo", osmomath.NewInt(100)), + sdk.NewCoin("bar", osmomath.NewInt(100)), }}, arg: "10foo,10bar", // Should be of a format suitable for ParseCoinsNormalized fieldIndex: 6, expectedStruct: testingStruct{Slice: sdk.Coins{ // swapped places due to lexicographic order - sdk.NewCoin("bar", sdk.NewInt(10)), - sdk.NewCoin("foo", sdk.NewInt(10)), + sdk.NewCoin("bar", osmomath.NewInt(10)), + sdk.NewCoin("foo", osmomath.NewInt(10)), }}, }, "Struct (sdk.Coin) change": { - testingStruct: testingStruct{Struct: sdk.NewCoin("bar", sdk.NewInt(10))}, // only supports sdk.Int, sdk.Coin or time.Time, other structs are not recognized + testingStruct: testingStruct{Struct: sdk.NewCoin("bar", osmomath.NewInt(10))}, // only supports osmomath.Int, sdk.Coin or time.Time, other structs are not recognized arg: "100bar", fieldIndex: 7, - expectedStruct: testingStruct{Struct: sdk.NewCoin("bar", sdk.NewInt(10))}, + expectedStruct: testingStruct{Struct: sdk.NewCoin("bar", osmomath.NewInt(10))}, }, "Unrecognizable struct": { - testingStruct: testingStruct{Struct: testingStruct{}}, // only supports sdk.Int, sdk.Coin or time.Time, other structs are not recognized + testingStruct: testingStruct{Struct: testingStruct{}}, // only supports osmomath.Int, sdk.Coin or time.Time, other structs are not recognized arg: "whatever", fieldIndex: 7, expectingErr: true, @@ -117,10 +119,10 @@ func TestParseFieldFromArg(t *testing.T) { Duration: time.Second, Pointer: &testingStruct{}, Slice: sdk.Coins{ - sdk.NewCoin("foo", sdk.NewInt(100)), - sdk.NewCoin("bar", sdk.NewInt(100)), + sdk.NewCoin("foo", osmomath.NewInt(100)), + sdk.NewCoin("bar", osmomath.NewInt(100)), }, - Struct: sdk.NewCoin("bar", sdk.NewInt(10)), + Struct: sdk.NewCoin("bar", osmomath.NewInt(10)), }, arg: "1foo,15bar", fieldIndex: 6, @@ -132,21 +134,22 @@ func TestParseFieldFromArg(t *testing.T) { Duration: time.Second, Pointer: &testingStruct{}, Slice: sdk.Coins{ - sdk.NewCoin("bar", sdk.NewInt(15)), - sdk.NewCoin("foo", sdk.NewInt(1)), + sdk.NewCoin("bar", osmomath.NewInt(15)), + sdk.NewCoin("foo", osmomath.NewInt(1)), }, - Struct: sdk.NewCoin("bar", sdk.NewInt(10)), + Struct: sdk.NewCoin("bar", osmomath.NewInt(10)), }, }, "Dec struct": { - testingStruct: testingStruct{Dec: sdk.MustNewDecFromStr("100")}, + testingStruct: testingStruct{Dec: osmomath.MustNewDecFromStr("100")}, arg: "10", fieldIndex: 8, - expectedStruct: testingStruct{Dec: sdk.MustNewDecFromStr("10")}, + expectedStruct: testingStruct{Dec: osmomath.MustNewDecFromStr("10")}, }, } for name, tc := range tests { + tc := tc t.Run(name, func(t *testing.T) { val := reflect.ValueOf(&tc.testingStruct).Elem() typ := reflect.TypeOf(&tc.testingStruct).Elem() diff --git a/osmoutils/store_helper.go b/osmoutils/store_helper.go index 1ba661d8d41..795f40da0dd 100644 --- a/osmoutils/store_helper.go +++ b/osmoutils/store_helper.go @@ -8,6 +8,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" db "github.com/tendermint/tm-db" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/cosmos/cosmos-sdk/store" "github.com/gogo/protobuf/proto" ) @@ -168,14 +170,14 @@ func MustGet(store store.KVStore, key []byte, result proto.Message) { } // MustSetDec sets dec value to store at key. Panics on any error. -func MustSetDec(store store.KVStore, key []byte, value sdk.Dec) { +func MustSetDec(store store.KVStore, key []byte, value osmomath.Dec) { MustSet(store, key, &sdk.DecProto{ Dec: value, }) } // MustGetDec gets dec value from store at key. Panics on any error. -func MustGetDec(store store.KVStore, key []byte) sdk.Dec { +func MustGetDec(store store.KVStore, key []byte) osmomath.Dec { result := &sdk.DecProto{} MustGet(store, key, result) return result.Dec @@ -184,14 +186,14 @@ func MustGetDec(store store.KVStore, key []byte) sdk.Dec { // GetDec gets dec value from store at key. Returns error if: // - database error occurs. // - no value at given key is found. -func GetDec(store store.KVStore, key []byte) (sdk.Dec, error) { +func GetDec(store store.KVStore, key []byte) (osmomath.Dec, error) { result := &sdk.DecProto{} isFound, err := Get(store, key, result) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } if !isFound { - return sdk.Dec{}, DecNotFoundError{Key: string(key)} + return osmomath.Dec{}, DecNotFoundError{Key: string(key)} } return result.Dec, nil } diff --git a/osmoutils/store_helper_test.go b/osmoutils/store_helper_test.go index d659650f3cb..0e51eac1a8e 100644 --- a/osmoutils/store_helper_test.go +++ b/osmoutils/store_helper_test.go @@ -16,6 +16,7 @@ import ( paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/noapptest" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" @@ -871,40 +872,38 @@ func (s *TestSuite) TestMustGet() { }{ "basic valid test": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, expectedGetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, - actualResultProto: &sdk.DecProto{}, }, "attempt to get non-existent key - panic": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, expectedGetKeyValues: map[string]proto.Message{ - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, - actualResultProto: &sdk.DecProto{}, expectPanic: true, }, "invalid proto Dec vs AuthParams- error": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, }, expectedGetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, }, actualResultProto: &authtypes.Params{}, @@ -951,31 +950,29 @@ func (s *TestSuite) TestGet() { }{ "basic valid test": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, expectedGetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, - actualResultProto: &sdk.DecProto{}, expectFound: true, }, "attempt to get non-existent key - not found & no err return": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, - keyC: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, + keyC: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, expectedGetKeyValues: map[string]proto.Message{ - keyB: &sdk.DecProto{Dec: sdk.OneDec().Add(sdk.OneDec())}, + keyB: &sdk.DecProto{Dec: osmomath.OneDec().Add(osmomath.OneDec())}, }, - actualResultProto: &sdk.DecProto{}, expectFound: false, @@ -984,11 +981,11 @@ func (s *TestSuite) TestGet() { }, "invalid proto Dec vs AuthParams - found but Unmarshal err": { preSetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, }, expectedGetKeyValues: map[string]proto.Message{ - keyA: &sdk.DecProto{Dec: sdk.OneDec()}, + keyA: &sdk.DecProto{Dec: osmomath.OneDec()}, }, actualResultProto: &authtypes.Params{}, @@ -1044,9 +1041,8 @@ func (s *TestSuite) TestMustSet() { "basic valid Dec test": { setKey: keyA, setValue: &sdk.DecProto{ - Dec: sdk.OneDec(), + Dec: osmomath.OneDec(), }, - actualResultProto: &sdk.DecProto{}, }, "basic valid AuthParams test": { @@ -1085,35 +1081,33 @@ func (s *TestSuite) TestMustSet() { // decimal values from the store and panics if an error is encountered. func (s *TestSuite) TestMustGetDec() { tests := map[string]struct { - // keys and values to preset - preSetKeyValues map[string]sdk.Dec + // keys and values to preseosmomath.Dec + preSetKeyValues map[string]osmomath.Dec - // keys and values to attempt to get and validate - expectedGetKeyValues map[string]sdk.Dec + // keys and values to attempt toosmomath.Decd validate + expectedGetKeyValues map[string]osmomath.Dec expectPanic bool }{ "valid get": { - preSetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyB: sdk.OneDec().Add(sdk.OneDec()), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + preSetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyB: osmomath.OneDec().Add(osmomath.OneDec()), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, - - expectedGetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyB: sdk.OneDec().Add(sdk.OneDec()), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + expectedGetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyB: osmomath.OneDec().Add(osmomath.OneDec()), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, }, - "attempt to get non-existent key - panic": { - preSetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + "attempt to get non-existent osmomath.Decanic": { + preSetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, - - expectedGetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), + expectedGetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), keyB: {}, // this one panics }, @@ -1149,7 +1143,7 @@ func (s *TestSuite) TestMustGetDec() { // only panic if the proto argument is invalid. // Therefore, we only test a success case here. func (s *TestSuite) TestMustSetDec() { - originalDecValue := sdk.OneDec() + originalDecValue := osmomath.OneDec() // System under test. osmoutils.MustSetDec(s.store, []byte(keyA), originalDecValue) @@ -1246,34 +1240,32 @@ func (s *TestSuite) TestHasAnyAtPrefix() { func (s *TestSuite) TestGetDec() { tests := map[string]struct { - // keys and values to preset - preSetKeyValues map[string]sdk.Dec + // keys and values to preseosmomath.Dec + preSetKeyValues map[string]osmomath.Dec - // keys and values to attempt to get and validate - expectedGetKeyValues map[string]sdk.Dec + // keys and values to attempt toosmomath.Decd validate + expectedGetKeyValues map[string]osmomath.Dec expectError error }{ "valid get": { - preSetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyB: sdk.OneDec().Add(sdk.OneDec()), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + preSetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyB: osmomath.OneDec().Add(osmomath.OneDec()), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, - - expectedGetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyB: sdk.OneDec().Add(sdk.OneDec()), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + expectedGetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyB: osmomath.OneDec().Add(osmomath.OneDec()), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, }, - "error: attempt to get non-existent key": { - preSetKeyValues: map[string]sdk.Dec{ - keyA: sdk.OneDec(), - keyC: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + "error: attempt to get non-exosmomath.Deckey": { + preSetKeyValues: map[string]osmomath.Dec{ + keyA: osmomath.OneDec(), + keyC: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, - - expectedGetKeyValues: map[string]sdk.Dec{ + expectedGetKeyValues: map[string]osmomath.Dec{ keyB: {}, }, diff --git a/osmoutils/sumtree/legacy/v101/tree.go b/osmoutils/sumtree/legacy/v101/tree.go index 356a6361bc8..7fc84ef8879 100644 --- a/osmoutils/sumtree/legacy/v101/tree.go +++ b/osmoutils/sumtree/legacy/v101/tree.go @@ -10,12 +10,13 @@ import ( stypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/sumtree" ) type Child struct { Index []byte - Acc sdk.Int + Acc osmomath.Int } type Children []Child // branch nodes @@ -35,7 +36,7 @@ func migrateBranchValue(oldValueBz []byte) *sumtree.Node { } func migrateLeafValue(index []byte, oldValueBz []byte) *sumtree.Leaf { - oldValue := sdk.ZeroInt() + oldValue := osmomath.ZeroInt() err := json.Unmarshal(oldValueBz, &oldValue) if err != nil { panic(err) diff --git a/osmoutils/sumtree/legacy/v101/tree_test.go b/osmoutils/sumtree/legacy/v101/tree_test.go index c5ed5140619..79205a6df4f 100644 --- a/osmoutils/sumtree/legacy/v101/tree_test.go +++ b/osmoutils/sumtree/legacy/v101/tree_test.go @@ -18,6 +18,7 @@ import ( iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/sumtree" v101 "github.com/osmosis-labs/osmosis/osmoutils/sumtree/legacy/v101" ) @@ -56,7 +57,7 @@ func compareBranch(oldValueBz []byte, valueBz []byte) (err error) { } func compareLeaf(oldValueBz []byte, valueBz []byte) (err error) { - oldValue := sdk.ZeroInt() + oldValue := osmomath.ZeroInt() value := sumtree.Leaf{} err = json.Unmarshal(oldValueBz, &oldValue) if err != nil { diff --git a/osmoutils/sumtree/node.go b/osmoutils/sumtree/node.go index fd62f6f3d3c..ef9c66b51a2 100644 --- a/osmoutils/sumtree/node.go +++ b/osmoutils/sumtree/node.go @@ -5,10 +5,10 @@ import ( "github.com/gogo/protobuf/proto" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) -func NewLeaf(key []byte, acc sdk.Int) *Leaf { +func NewLeaf(key []byte, acc osmomath.Int) *Leaf { return &Leaf{Leaf: &Child{ Index: key, Accumulation: acc, @@ -208,8 +208,8 @@ func (ptr *ptr) pull(key []byte) { } } -func (node Node) accumulate() (res sdk.Int) { - res = sdk.ZeroInt() +func (node Node) accumulate() (res osmomath.Int) { + res = osmomath.ZeroInt() for _, child := range node.Children { res = res.Add(child.Accumulation) } @@ -237,7 +237,7 @@ func (node Node) find(key []byte) (idx int, match bool) { return len(node.Children), false } -func (node *Node) setAcc(idx int, acc sdk.Int) *Node { +func (node *Node) setAcc(idx int, acc osmomath.Int) *Node { node.Children[idx] = &Child{node.Children[idx].Index, acc} return node } diff --git a/osmoutils/sumtree/tree.go b/osmoutils/sumtree/tree.go index 9db0c53cab6..d56b301c59a 100644 --- a/osmoutils/sumtree/tree.go +++ b/osmoutils/sumtree/tree.go @@ -9,9 +9,10 @@ import ( "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" + store "github.com/cosmos/cosmos-sdk/store" stypes "github.com/cosmos/cosmos-sdk/store/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // Tree is an augmented B+ tree implementation. @@ -28,7 +29,7 @@ type Tree struct { func NewTree(store store.KVStore, m uint8) Tree { tree := Tree{store, m} if tree.IsEmpty() { - tree.Set(nil, sdk.ZeroInt()) + tree.Set(nil, osmomath.ZeroInt()) } return tree } @@ -37,7 +38,7 @@ func (t Tree) IsEmpty() bool { return !t.store.Has(t.leafKey(nil)) } -func (t Tree) Set(key []byte, acc sdk.Int) { +func (t Tree) Set(key []byte, acc osmomath.Int) { ptr := t.ptrGet(0, key) leaf := NewLeaf(key, acc) ptr.setLeaf(leaf) @@ -55,12 +56,12 @@ func (t Tree) Remove(key []byte) { parent.pull(key) } -func (t Tree) Increase(key []byte, amt sdk.Int) { +func (t Tree) Increase(key []byte, amt osmomath.Int) { value := t.Get(key) t.Set(key, value.Add(amt)) } -func (t Tree) Decrease(key []byte, amt sdk.Int) { +func (t Tree) Decrease(key []byte, amt osmomath.Int) { t.Increase(key, amt.Neg()) } @@ -135,12 +136,12 @@ func (t Tree) root() *ptr { } } -// Get returns the (sdk.Int) accumulation value at a given leaf. -func (t Tree) Get(key []byte) sdk.Int { +// Get returns the (osmomath.Int) accumulation value at a given leaf. +func (t Tree) Get(key []byte) osmomath.Int { res := new(Leaf) keybz := t.leafKey(key) if !t.store.Has(keybz) { - return sdk.ZeroInt() + return osmomath.ZeroInt() } bz := t.store.Get(keybz) err := proto.Unmarshal(bz, res) @@ -208,8 +209,8 @@ func (t Tree) ReverseIterator(begin, end []byte) store.Iterator { // exact: leaf with key = provided key // right: all leaves under nodePointer with key > provided key // Note that the equalities here are _exclusive_. -func (ptr *ptr) accumulationSplit(key []byte) (left sdk.Int, exact sdk.Int, right sdk.Int) { - left, exact, right = sdk.ZeroInt(), sdk.ZeroInt(), sdk.ZeroInt() +func (ptr *ptr) accumulationSplit(key []byte) (left osmomath.Int, exact osmomath.Int, right osmomath.Int) { + left, exact, right = osmomath.ZeroInt(), osmomath.ZeroInt(), osmomath.ZeroInt() if ptr.isLeaf() { var leaf Leaf bz := ptr.tree.store.Get(ptr.tree.leafKey(ptr.key)) @@ -243,12 +244,12 @@ func (ptr *ptr) accumulationSplit(key []byte) (left sdk.Int, exact sdk.Int, righ } // TotalAccumulatedValue returns the sum of the weights for all leaves. -func (t Tree) TotalAccumulatedValue() sdk.Int { +func (t Tree) TotalAccumulatedValue() osmomath.Int { return t.SubsetAccumulation(nil, nil) } // Prefix sum returns the total weight of all leaves with keys <= to the provided key. -func (t Tree) PrefixSum(key []byte) sdk.Int { +func (t Tree) PrefixSum(key []byte) osmomath.Int { return t.SubsetAccumulation(nil, key) } @@ -256,7 +257,7 @@ func (t Tree) PrefixSum(key []byte) sdk.Int { // between start and end (inclusive of both ends) // if start is nil, it is the beginning of the tree. // if end is nil, it is the end of the tree. -func (t Tree) SubsetAccumulation(start []byte, end []byte) sdk.Int { +func (t Tree) SubsetAccumulation(start []byte, end []byte) osmomath.Int { if start == nil { left, exact, _ := t.root().accumulationSplit(end) return left.Add(exact) @@ -270,11 +271,11 @@ func (t Tree) SubsetAccumulation(start []byte, end []byte) sdk.Int { return leftexact.Add(leftrest).Sub(rightest) } -func (t Tree) SplitAcc(key []byte) (sdk.Int, sdk.Int, sdk.Int) { +func (t Tree) SplitAcc(key []byte) (osmomath.Int, osmomath.Int, osmomath.Int) { return t.root().accumulationSplit(key) } -func (ptr *ptr) visualize(depth int, acc sdk.Int) { +func (ptr *ptr) visualize(depth int, acc osmomath.Int) { if !ptr.exists() { return } @@ -291,5 +292,5 @@ func (ptr *ptr) visualize(depth int, acc sdk.Int) { // DebugVisualize prints the entire tree to stdout. func (t Tree) DebugVisualize() { - t.root().visualize(0, sdk.Int{}) + t.root().visualize(0, osmomath.Int{}) } diff --git a/osmoutils/sumtree/tree.pb.go b/osmoutils/sumtree/tree.pb.go index 4f007610f28..f5682676f62 100644 --- a/osmoutils/sumtree/tree.pb.go +++ b/osmoutils/sumtree/tree.pb.go @@ -4,9 +4,9 @@ package sumtree import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -70,8 +70,8 @@ func (m *Node) GetChildren() []*Child { } type Child struct { - Index []byte `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` - Accumulation github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=accumulation,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"accumulation"` + Index []byte `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + Accumulation cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=accumulation,proto3,customtype=cosmossdk.io/math.Int" json:"accumulation"` } func (m *Child) Reset() { *m = Child{} } @@ -169,26 +169,26 @@ func init() { } var fileDescriptor_31a1c5f55b935f78 = []byte{ - // 302 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xeb, 0x30, - 0x18, 0x85, 0xe3, 0x7b, 0x53, 0x04, 0xa6, 0x53, 0x54, 0xa4, 0xa8, 0x42, 0x6e, 0x94, 0x01, 0x65, - 0xa9, 0x4d, 0x60, 0xe9, 0x88, 0xca, 0x84, 0x40, 0x0c, 0x19, 0xd9, 0x1c, 0xc7, 0x4d, 0x2d, 0x92, - 0xb8, 0xc4, 0x0e, 0x82, 0xb7, 0xe0, 0xb1, 0x3a, 0x76, 0x44, 0x0c, 0x15, 0x4a, 0x5e, 0x04, 0xc5, - 0x09, 0x05, 0x24, 0x24, 0xa6, 0xdf, 0xc7, 0xfe, 0x74, 0xce, 0x91, 0x7f, 0xe8, 0x4b, 0x95, 0x4b, - 0x25, 0x14, 0x51, 0x55, 0xae, 0x4b, 0xce, 0xc9, 0x63, 0x18, 0x73, 0x4d, 0x43, 0xd2, 0x0a, 0xbc, - 0x2a, 0xa5, 0x96, 0xce, 0x51, 0xcf, 0x60, 0xa5, 0x65, 0xc9, 0x71, 0x4f, 0x8c, 0x47, 0xa9, 0x4c, - 0xa5, 0x21, 0x48, 0x7b, 0xea, 0xe0, 0x31, 0x62, 0x86, 0x26, 0x31, 0x55, 0x5f, 0x66, 0x4c, 0x8a, - 0xa2, 0x7b, 0xf7, 0x2f, 0xa0, 0x7d, 0x2b, 0x13, 0xee, 0xcc, 0xe0, 0x3e, 0x5b, 0x8a, 0x2c, 0x29, - 0x79, 0xe1, 0x02, 0xef, 0x7f, 0x70, 0x78, 0x76, 0x8c, 0x7f, 0xcd, 0xc1, 0x97, 0x2d, 0x16, 0xed, - 0x68, 0xff, 0x01, 0x0e, 0xcc, 0x95, 0x33, 0x82, 0x03, 0x51, 0x24, 0xfc, 0xc9, 0x05, 0x1e, 0x08, - 0x86, 0x51, 0x27, 0x9c, 0x08, 0x0e, 0x29, 0x63, 0x55, 0x5e, 0x65, 0x54, 0x0b, 0x59, 0xb8, 0xff, - 0x3c, 0x10, 0x1c, 0xcc, 0xf1, 0x7a, 0x3b, 0xb1, 0xde, 0xb6, 0x93, 0x93, 0x54, 0xe8, 0x65, 0x15, - 0x63, 0x26, 0x73, 0xd2, 0x37, 0xed, 0xc6, 0x54, 0x25, 0xf7, 0x44, 0x3f, 0xaf, 0xb8, 0xc2, 0x57, - 0x85, 0x8e, 0x7e, 0x78, 0xf8, 0x33, 0x68, 0xdf, 0x70, 0xba, 0x70, 0x4e, 0xa1, 0x9d, 0x71, 0xba, - 0x30, 0x81, 0x7f, 0x15, 0x36, 0xe4, 0xfc, 0x7a, 0x5d, 0x23, 0xb0, 0xa9, 0x11, 0x78, 0xaf, 0x11, - 0x78, 0x69, 0x90, 0xb5, 0x69, 0x90, 0xf5, 0xda, 0x20, 0xeb, 0x2e, 0xfc, 0xd6, 0xa4, 0xf7, 0x99, - 0x66, 0x34, 0x56, 0x9f, 0xc2, 0xcc, 0x4a, 0x8b, 0x6c, 0xb7, 0x9b, 0x78, 0xcf, 0x7c, 0xe1, 0xf9, - 0x47, 0x00, 0x00, 0x00, 0xff, 0xff, 0x30, 0x34, 0x4b, 0x32, 0xb5, 0x01, 0x00, 0x00, + // 298 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xe3, 0xff, 0x6f, 0x11, 0x98, 0x4e, 0x51, 0x2b, 0x55, 0x15, 0xb8, 0x55, 0xa6, 0x2e, + 0xd8, 0x04, 0x96, 0x8e, 0x50, 0x26, 0x04, 0x62, 0xc8, 0xc8, 0x84, 0xe3, 0xb8, 0x89, 0x45, 0x92, + 0x8b, 0x62, 0x07, 0xf1, 0x18, 0x3c, 0x56, 0xc7, 0x8e, 0x88, 0xa1, 0x42, 0xc9, 0x8b, 0xa0, 0x38, + 0xa1, 0x08, 0x09, 0x89, 0xc9, 0x3e, 0xf6, 0x77, 0xcf, 0x3d, 0xba, 0x17, 0x7b, 0xa0, 0x33, 0xd0, + 0x4a, 0x33, 0x5d, 0x66, 0xa6, 0x90, 0x92, 0x3d, 0xfb, 0xa1, 0x34, 0xdc, 0x67, 0x8d, 0xa0, 0x4f, + 0x05, 0x18, 0x70, 0x47, 0x1d, 0x43, 0xb5, 0x81, 0x42, 0xd2, 0x8e, 0x98, 0x0c, 0x63, 0x88, 0xc1, + 0x12, 0xac, 0xb9, 0xb5, 0xf0, 0x84, 0x08, 0x4b, 0xb3, 0x90, 0xeb, 0x6f, 0x33, 0x01, 0x2a, 0x6f, + 0xff, 0xbd, 0x0b, 0xdc, 0xbb, 0x83, 0x48, 0xba, 0x0b, 0xbc, 0x2f, 0x12, 0x95, 0x46, 0x85, 0xcc, + 0xc7, 0x68, 0xf6, 0x7f, 0x7e, 0x78, 0x76, 0x44, 0x7f, 0xed, 0x43, 0xaf, 0x1a, 0x2c, 0xd8, 0xd1, + 0xde, 0x03, 0xee, 0xdb, 0x27, 0x77, 0x88, 0xfb, 0x2a, 0x8f, 0xe4, 0xcb, 0x18, 0xcd, 0xd0, 0x7c, + 0x10, 0xb4, 0xc2, 0xbd, 0xc4, 0x03, 0x2e, 0x44, 0x99, 0x95, 0x29, 0x37, 0x0a, 0xf2, 0xf1, 0xbf, + 0x19, 0x9a, 0x1f, 0x2c, 0x8f, 0xd7, 0xdb, 0xa9, 0xf3, 0xbe, 0x9d, 0x8e, 0xda, 0x78, 0x3a, 0x7a, + 0xa4, 0x0a, 0x58, 0xc6, 0x4d, 0x42, 0xaf, 0x73, 0x13, 0xfc, 0x28, 0xf1, 0x16, 0xb8, 0x77, 0x2b, + 0xf9, 0xca, 0x3d, 0xc5, 0xbd, 0x54, 0xf2, 0x95, 0xf5, 0xff, 0x2b, 0x9f, 0x25, 0x97, 0x37, 0xeb, + 0x8a, 0xa0, 0x4d, 0x45, 0xd0, 0x47, 0x45, 0xd0, 0x6b, 0x4d, 0x9c, 0x4d, 0x4d, 0x9c, 0xb7, 0x9a, + 0x38, 0xf7, 0x7e, 0xac, 0x4c, 0x52, 0x86, 0x54, 0x40, 0xc6, 0x3a, 0x9f, 0x93, 0x94, 0x87, 0xfa, + 0x4b, 0xd8, 0xb3, 0x34, 0x2a, 0xdd, 0xad, 0x22, 0xdc, 0xb3, 0x13, 0x3b, 0xff, 0x0c, 0x00, 0x00, + 0xff, 0xff, 0x17, 0xd5, 0x9c, 0x4b, 0xa4, 0x01, 0x00, 0x00, } func (m *Node) Marshal() (dAtA []byte, err error) { diff --git a/osmoutils/sumtree/tree_test.go b/osmoutils/sumtree/tree_test.go index 56b6ab2205d..6e40eed6cb0 100644 --- a/osmoutils/sumtree/tree_test.go +++ b/osmoutils/sumtree/tree_test.go @@ -14,8 +14,8 @@ import ( dbm "github.com/tendermint/tm-db" iavlstore "github.com/cosmos/cosmos-sdk/store/iavl" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/sumtree" ) @@ -73,7 +73,7 @@ func (suite *TreeTestSuite) TestTreeInvariants() { suite.SetupTest() pairs := pairs{pair{[]byte("hello"), 100}} - suite.tree.Set([]byte("hello"), sdk.NewIntFromUint64(100)) + suite.tree.Set([]byte("hello"), osmomath.NewIntFromUint64(100)) seed := rand.Int63() fmt.Printf("running seed %d: \n", seed) @@ -97,7 +97,7 @@ func (suite *TreeTestSuite) TestTreeInvariants() { pairs = append(pairs, pair{key, value}) } - suite.tree.Set(key, sdk.NewIntFromUint64(value)) + suite.tree.Set(key, osmomath.NewIntFromUint64(value)) // check all is right for _, pair := range pairs { diff --git a/proto/osmosis/accum/v1beta1/accum.proto b/proto/osmosis/accum/v1beta1/accum.proto index 9ba71d424e4..c99f32b600f 100644 --- a/proto/osmosis/accum/v1beta1/accum.proto +++ b/proto/osmosis/accum/v1beta1/accum.proto @@ -15,7 +15,7 @@ message AccumulatorContent { (gogoproto.nullable) = false ]; string total_shares = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -28,7 +28,7 @@ message Record { // num_shares is the number of shares belonging to the position associated // with this record. string num_shares = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // accum_value_per_share is the subset of coins per shar of the global diff --git a/proto/osmosis/concentrated-liquidity/gov.proto b/proto/osmosis/concentrated-liquidity/gov.proto index c5c51a42bdf..5ba2294cbba 100644 --- a/proto/osmosis/concentrated-liquidity/gov.proto +++ b/proto/osmosis/concentrated-liquidity/gov.proto @@ -53,7 +53,7 @@ message PoolRecord { uint64 tick_spacing = 3 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; reserved 4; string spread_factor = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"spread_factor\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/incentive_record.proto b/proto/osmosis/concentrated-liquidity/incentive_record.proto index 85c6925a035..c1248bee768 100644 --- a/proto/osmosis/concentrated-liquidity/incentive_record.proto +++ b/proto/osmosis/concentrated-liquidity/incentive_record.proto @@ -45,7 +45,7 @@ message IncentiveRecordBody { // emission_rate is the incentive emission rate per second string emission_rate = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"emission_rate\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/params.proto b/proto/osmosis/concentrated-liquidity/params.proto index c9da80ecff0..093fa441ea0 100644 --- a/proto/osmosis/concentrated-liquidity/params.proto +++ b/proto/osmosis/concentrated-liquidity/params.proto @@ -15,7 +15,7 @@ message Params { repeated uint64 authorized_tick_spacing = 1 [ (gogoproto.moretags) = "yaml:\"authorized_tick_spacing\"" ]; repeated string authorized_spread_factors = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"authorized_spread_factors\"", (gogoproto.nullable) = false ]; @@ -26,7 +26,7 @@ message Params { // This field can range from (0,1]. If set to 1, it indicates that all // incentives stay at cl pool. string balancer_shares_reward_discount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"balancer_shares_reward_discount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/pool-model/concentrated/tx.proto b/proto/osmosis/concentrated-liquidity/pool-model/concentrated/tx.proto index e243df39e43..e676db8e7f3 100644 --- a/proto/osmosis/concentrated-liquidity/pool-model/concentrated/tx.proto +++ b/proto/osmosis/concentrated-liquidity/pool-model/concentrated/tx.proto @@ -18,7 +18,7 @@ message MsgCreateConcentratedPool { string denom1 = 3 [ (gogoproto.moretags) = "yaml:\"denom1\"" ]; uint64 tick_spacing = 4 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; string spread_factor = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"spread_factor\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/pool.proto b/proto/osmosis/concentrated-liquidity/pool.proto index c74ec852467..b9d78d945b2 100644 --- a/proto/osmosis/concentrated-liquidity/pool.proto +++ b/proto/osmosis/concentrated-liquidity/pool.proto @@ -31,7 +31,7 @@ message Pool { // Amount of total liquidity string current_tick_liquidity = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"current_tick_liquidity\"", (gogoproto.nullable) = false ]; @@ -53,7 +53,7 @@ message Pool { // spread_factor is the ratio that is charged on the amount of token in. string spread_factor = 12 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"spread_factor\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/position.proto b/proto/osmosis/concentrated-liquidity/position.proto index 2cd7fd1a004..e71792c7181 100644 --- a/proto/osmosis/concentrated-liquidity/position.proto +++ b/proto/osmosis/concentrated-liquidity/position.proto @@ -28,7 +28,7 @@ message Position { (gogoproto.moretags) = "yaml:\"join_time\"" ]; string liquidity = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/query.proto b/proto/osmosis/concentrated-liquidity/query.proto index b130aa059cc..99953d39e64 100644 --- a/proto/osmosis/concentrated-liquidity/query.proto +++ b/proto/osmosis/concentrated-liquidity/query.proto @@ -174,7 +174,7 @@ message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } message TickLiquidityNet { string liquidity_net = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_net\"", (gogoproto.nullable) = false ]; @@ -183,7 +183,7 @@ message TickLiquidityNet { message LiquidityDepthWithRange { string liquidity_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_net\"", (gogoproto.nullable) = false ]; @@ -205,7 +205,7 @@ message LiquidityNetInDirectionResponse { [ (gogoproto.nullable) = false ]; int64 current_tick = 2; string current_liquidity = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"current_liquidity\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/tickInfo.proto b/proto/osmosis/concentrated-liquidity/tickInfo.proto index 04a652c1cb6..9fbfce8d2a8 100644 --- a/proto/osmosis/concentrated-liquidity/tickInfo.proto +++ b/proto/osmosis/concentrated-liquidity/tickInfo.proto @@ -13,12 +13,12 @@ option go_package = "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidit message TickInfo { string liquidity_gross = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_gross\"", (gogoproto.nullable) = false ]; string liquidity_net = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_net\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/concentrated-liquidity/tx.proto b/proto/osmosis/concentrated-liquidity/tx.proto index 707bbbfb3eb..3e9e5ae6cda 100644 --- a/proto/osmosis/concentrated-liquidity/tx.proto +++ b/proto/osmosis/concentrated-liquidity/tx.proto @@ -42,12 +42,12 @@ message MsgCreatePosition { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; string token_min_amount0 = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_min_amount0\"", (gogoproto.nullable) = false ]; string token_min_amount1 = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_min_amount1\"", (gogoproto.nullable) = false ]; @@ -56,17 +56,17 @@ message MsgCreatePosition { message MsgCreatePositionResponse { uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ]; string amount0 = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount0\"", (gogoproto.nullable) = false ]; string amount1 = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; string liquidity_created = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_created\"", (gogoproto.nullable) = false ]; @@ -86,13 +86,13 @@ message MsgAddToPosition { string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; // amount0 represents the amount of token0 willing to put in. string amount0 = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount_0\"", (gogoproto.nullable) = false ]; // amount1 represents the amount of token1 willing to put in. string amount1 = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount_1\"", (gogoproto.nullable) = false ]; @@ -101,7 +101,7 @@ message MsgAddToPosition { // corresponding to the liquidity that is being added, not the total // liquidity of the position. string token_min_amount0 = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_min_amount0\"", (gogoproto.nullable) = false ]; @@ -110,7 +110,7 @@ message MsgAddToPosition { // corresponding to the liquidity that is being added, not the total // liquidity of the position. string token_min_amount1 = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_min_amount1\"", (gogoproto.nullable) = false ]; @@ -119,12 +119,12 @@ message MsgAddToPosition { message MsgAddToPositionResponse { uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ]; string amount0 = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount0\"", (gogoproto.nullable) = false ]; string amount1 = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; @@ -137,7 +137,7 @@ message MsgWithdrawPosition { uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ]; string sender = 2 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; string liquidity_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_amount\"", (gogoproto.nullable) = false ]; @@ -145,12 +145,12 @@ message MsgWithdrawPosition { message MsgWithdrawPositionResponse { string amount0 = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount0\"", (gogoproto.nullable) = false ]; string amount1 = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/module_query_msg.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/module_query_msg.proto index 503e238487d..ff455dd815b 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/module_query_msg.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/module_query_msg.proto @@ -16,7 +16,7 @@ message CalcOutAmtGivenIn { // swap_fee is the swap fee for this swap estimate. string swap_fee = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -42,7 +42,7 @@ message CalcInAmtGivenOut { // swap_fee is the swap fee for this swap estimate. string swap_fee = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/module_sudo_msg.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/module_sudo_msg.proto index b22167e5347..f7bc0bf599b 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/module_sudo_msg.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/module_sudo_msg.proto @@ -18,13 +18,13 @@ message SwapExactAmountIn { // token_out_min_amount is the minimum amount of token_out to be received from // the pool. string token_out_min_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // swap_fee is the swap fee for this swap estimate. string swap_fee = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -38,7 +38,7 @@ message SwapExactAmountInSudoMsg { message SwapExactAmountInSudoMsgResponse { // token_out_amount is the token out computed from this swap estimate call. string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } @@ -55,13 +55,13 @@ message SwapExactAmountOut { // token_in_max_amount is the maximum amount of token_in to be sent to the // pool. string token_in_max_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; // swap_fee is the swap fee for this swap estimate. string swap_fee = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -75,7 +75,7 @@ message SwapExactAmountOutSudoMsg { message SwapExactAmountOutSudoMsgResponse { // token_in_amount is the token in computed from this swap estimate call. string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto index ee6199779fc..f14dc72ddc3 100644 --- a/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto +++ b/proto/osmosis/cosmwasmpool/v1beta1/model/pool_query_msg.proto @@ -15,7 +15,7 @@ message GetSwapFeeQueryMsg { message GetSwapFeeQueryMsgResponse { // swap_fee is the swap fee for this swap estimate. string swap_fee = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto index 8d5911f3c0d..4a61803ba70 100644 --- a/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto +++ b/proto/osmosis/gamm/pool-models/balancer/balancerPool.proto @@ -78,7 +78,7 @@ message PoolParams { option (amino.name) = "osmosis/gamm/BalancerPoolParams"; string swap_fee = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"swap_fee\"", (gogoproto.nullable) = false ]; @@ -86,7 +86,7 @@ message PoolParams { // pools can maintain a non-zero fee. No new pool can be created with non-zero // fee anymore string exit_fee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"exit_fee\"", (gogoproto.nullable) = false ]; @@ -107,7 +107,7 @@ message PoolAsset { [ (gogoproto.moretags) = "yaml:\"token\"", (gogoproto.nullable) = false ]; // Weight that is not normalized. This weight must be less than 2^50 string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"weight\"", (gogoproto.nullable) = false ]; @@ -151,7 +151,7 @@ message Pool { ]; // sum of all non-normalized pool weights string total_weight = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"total_weight\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto index 941ff3d06ca..457961ebf3f 100644 --- a/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto +++ b/proto/osmosis/gamm/pool-models/stableswap/stableswap_pool.proto @@ -21,7 +21,7 @@ message PoolParams { option (amino.name) = "osmosis/gamm/StableswapPoolParams"; string swap_fee = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"swap_fee\"", (gogoproto.nullable) = false ]; @@ -29,7 +29,7 @@ message PoolParams { // pools can maintain a non-zero fee. No new pool can be created with non-zero // fee anymore string exit_fee = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"exit_fee\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/gamm/v1beta1/gov.proto b/proto/osmosis/gamm/v1beta1/gov.proto index 9d5b5a2e7e6..403b5a967e8 100644 --- a/proto/osmosis/gamm/v1beta1/gov.proto +++ b/proto/osmosis/gamm/v1beta1/gov.proto @@ -65,12 +65,12 @@ message PoolRecordWithCFMMLink { string denom1 = 2 [ (gogoproto.moretags) = "yaml:\"denom1\"" ]; uint64 tick_spacing = 3 [ (gogoproto.moretags) = "yaml:\"tick_spacing\"" ]; string exponent_at_price_one = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"exponent_at_price_one\"", (gogoproto.nullable) = false ]; string spread_factor = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"spread_factor\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/gamm/v1beta1/query.proto b/proto/osmosis/gamm/v1beta1/query.proto index 6b8da036903..9360814f73a 100644 --- a/proto/osmosis/gamm/v1beta1/query.proto +++ b/proto/osmosis/gamm/v1beta1/query.proto @@ -176,7 +176,7 @@ message QueryCalcJoinPoolSharesRequest { } message QueryCalcJoinPoolSharesResponse { string share_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_out_amount\"", (gogoproto.nullable) = false ]; @@ -190,7 +190,7 @@ message QueryCalcJoinPoolSharesResponse { message QueryCalcExitPoolCoinsFromSharesRequest { uint64 pool_id = 1; string share_in_amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } @@ -249,7 +249,7 @@ message QueryCalcJoinPoolNoSwapSharesResponse { (gogoproto.nullable) = false ]; string shares_out = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } @@ -306,7 +306,7 @@ message QuerySwapExactAmountInRequest { message QuerySwapExactAmountInResponse { option deprecated = true; string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -327,7 +327,7 @@ message QuerySwapExactAmountOutRequest { message QuerySwapExactAmountOutResponse { option deprecated = true; string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/gamm/v1beta1/tx.proto b/proto/osmosis/gamm/v1beta1/tx.proto index edf0070fa28..e36d1ec9780 100644 --- a/proto/osmosis/gamm/v1beta1/tx.proto +++ b/proto/osmosis/gamm/v1beta1/tx.proto @@ -33,7 +33,7 @@ message MsgJoinPool { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string share_out_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"pool_amount_out\"", (gogoproto.nullable) = false ]; @@ -45,7 +45,7 @@ message MsgJoinPool { message MsgJoinPoolResponse { string share_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_out_amount\"", (gogoproto.nullable) = false ]; @@ -62,7 +62,7 @@ message MsgExitPool { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; uint64 pool_id = 2 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string share_in_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_in_amount\"", (gogoproto.nullable) = false ]; @@ -92,7 +92,7 @@ message MsgSwapExactAmountIn { (gogoproto.nullable) = false ]; string token_out_min_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_min_amount\"", (gogoproto.nullable) = false ]; @@ -100,7 +100,7 @@ message MsgSwapExactAmountIn { message MsgSwapExactAmountInResponse { string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -113,7 +113,7 @@ message MsgSwapExactAmountOut { repeated osmosis.poolmanager.v1beta1.SwapAmountOutRoute routes = 2 [ (gogoproto.nullable) = false ]; string token_in_max_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_max_amount\"", (gogoproto.nullable) = false ]; @@ -125,7 +125,7 @@ message MsgSwapExactAmountOut { message MsgSwapExactAmountOutResponse { string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; @@ -143,7 +143,7 @@ message MsgJoinSwapExternAmountIn { (gogoproto.nullable) = false ]; string share_out_min_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_out_min_amount\"", (gogoproto.nullable) = false ]; @@ -155,7 +155,7 @@ message MsgJoinSwapExternAmountIn { message MsgJoinSwapExternAmountInResponse { string share_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_out_amount\"", (gogoproto.nullable) = false ]; @@ -170,12 +170,12 @@ message MsgJoinSwapShareAmountOut { string token_in_denom = 3 [ (gogoproto.moretags) = "yaml:\"token_in_denom\"" ]; string share_out_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_out_amount\"", (gogoproto.nullable) = false ]; string token_in_max_amount = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_max_amount\"", (gogoproto.nullable) = false ]; @@ -183,7 +183,7 @@ message MsgJoinSwapShareAmountOut { message MsgJoinSwapShareAmountOutResponse { string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; @@ -198,12 +198,12 @@ message MsgExitSwapShareAmountIn { string token_out_denom = 3 [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; string share_in_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_in_amount\"", (gogoproto.nullable) = false ]; string token_out_min_amount = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_min_amount\"", (gogoproto.nullable) = false ]; @@ -211,7 +211,7 @@ message MsgExitSwapShareAmountIn { message MsgExitSwapShareAmountInResponse { string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -228,7 +228,7 @@ message MsgExitSwapExternAmountOut { (gogoproto.nullable) = false ]; string share_in_max_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_in_max_amount\"", (gogoproto.nullable) = false ]; @@ -236,7 +236,7 @@ message MsgExitSwapExternAmountOut { message MsgExitSwapExternAmountOutResponse { string share_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"share_in_amount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/lockup/query.proto b/proto/osmosis/lockup/query.proto index 047597af46f..29ab304448c 100644 --- a/proto/osmosis/lockup/query.proto +++ b/proto/osmosis/lockup/query.proto @@ -251,7 +251,7 @@ message LockedDenomRequest { } message LockedDenomResponse { string amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/mint/v1beta1/mint.proto b/proto/osmosis/mint/v1beta1/mint.proto index f608264ab57..3c05c2df6a7 100644 --- a/proto/osmosis/mint/v1beta1/mint.proto +++ b/proto/osmosis/mint/v1beta1/mint.proto @@ -13,7 +13,7 @@ message Minter { // epoch_provisions represent rewards for the current epoch. string epoch_provisions = 1 [ (gogoproto.moretags) = "yaml:\"epoch_provisions\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -25,7 +25,7 @@ message WeightedAddress { string address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ]; string weight = 2 [ (gogoproto.moretags) = "yaml:\"weight\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } @@ -37,28 +37,28 @@ message DistributionProportions { // staking defines the proportion of the minted mint_denom that is to be // allocated as staking rewards. string staking = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"staking\"", (gogoproto.nullable) = false ]; // pool_incentives defines the proportion of the minted mint_denom that is // to be allocated as pool incentives. string pool_incentives = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"pool_incentives\"", (gogoproto.nullable) = false ]; // developer_rewards defines the proportion of the minted mint_denom that is // to be allocated to developer rewards address. string developer_rewards = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"developer_rewards\"", (gogoproto.nullable) = false ]; // community_pool defines the proportion of the minted mint_denom that is // to be allocated to the community pool. string community_pool = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"community_pool\"", (gogoproto.nullable) = false ]; @@ -73,7 +73,7 @@ message Params { // genesis_epoch_provisions epoch provisions from the first epoch. string genesis_epoch_provisions = 2 [ (gogoproto.moretags) = "yaml:\"genesis_epoch_provisions\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // epoch_identifier mint epoch identifier e.g. (day, week). @@ -87,7 +87,7 @@ message Params { // at the end of each period set by reduction_period_in_epochs. string reduction_factor = 5 [ (gogoproto.moretags) = "yaml:\"reduction_factor\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; // distribution_proportions defines the distribution proportions of the minted diff --git a/proto/osmosis/mint/v1beta1/query.proto b/proto/osmosis/mint/v1beta1/query.proto index 5fd63e47373..6a077b26ee0 100644 --- a/proto/osmosis/mint/v1beta1/query.proto +++ b/proto/osmosis/mint/v1beta1/query.proto @@ -39,7 +39,7 @@ message QueryEpochProvisionsRequest {} message QueryEpochProvisionsResponse { // epoch_provisions is the current minting per epoch provisions value. bytes epoch_provisions = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/pool-incentives/v1beta1/incentives.proto b/proto/osmosis/pool-incentives/v1beta1/incentives.proto index c7dec738700..ee3dd3118d1 100644 --- a/proto/osmosis/pool-incentives/v1beta1/incentives.proto +++ b/proto/osmosis/pool-incentives/v1beta1/incentives.proto @@ -26,7 +26,7 @@ message LockableDurationsInfo { message DistrInfo { string total_weight = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"total_weight\"", (gogoproto.nullable) = false ]; @@ -38,7 +38,7 @@ message DistrRecord { uint64 gauge_id = 1 [ (gogoproto.moretags) = "yaml:\"gauge_id\"" ]; string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/poolmanager/v1beta1/genesis.proto b/proto/osmosis/poolmanager/v1beta1/genesis.proto index 398d6967cbb..6c58c8e1272 100644 --- a/proto/osmosis/poolmanager/v1beta1/genesis.proto +++ b/proto/osmosis/poolmanager/v1beta1/genesis.proto @@ -49,7 +49,7 @@ 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 = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.customname) = "DefaultTakerFee", (gogoproto.nullable) = false ]; @@ -94,12 +94,12 @@ message TakerFeeParams { // gets distributed to the available categories. message TakerFeeDistributionPercentage { string staking_rewards = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"staking_rewards\"", (gogoproto.nullable) = false ]; string community_pool = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"community_pool\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/poolmanager/v1beta1/query.proto b/proto/osmosis/poolmanager/v1beta1/query.proto index 8ba6ba8ca83..b60d53ad0fd 100644 --- a/proto/osmosis/poolmanager/v1beta1/query.proto +++ b/proto/osmosis/poolmanager/v1beta1/query.proto @@ -146,7 +146,7 @@ message EstimateSinglePoolSwapExactAmountInRequest { message EstimateSwapExactAmountInResponse { string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -182,7 +182,7 @@ message EstimateSinglePoolSwapExactAmountOutRequest { message EstimateSwapExactAmountOutResponse { string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/poolmanager/v1beta1/swap_route.proto b/proto/osmosis/poolmanager/v1beta1/swap_route.proto index e17aa15b569..36a4e9b87c0 100644 --- a/proto/osmosis/poolmanager/v1beta1/swap_route.proto +++ b/proto/osmosis/poolmanager/v1beta1/swap_route.proto @@ -21,7 +21,7 @@ message SwapAmountInSplitRoute { repeated SwapAmountInRoute pools = 1 [ (gogoproto.moretags) = "yaml:\"pools\"", (gogoproto.nullable) = false ]; string token_in_amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; @@ -31,7 +31,7 @@ message SwapAmountOutSplitRoute { repeated SwapAmountOutRoute pools = 1 [ (gogoproto.moretags) = "yaml:\"pools\"", (gogoproto.nullable) = false ]; string token_out_amount = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/poolmanager/v1beta1/tx.proto b/proto/osmosis/poolmanager/v1beta1/tx.proto index 934e2afdbc0..16fc86e7e61 100644 --- a/proto/osmosis/poolmanager/v1beta1/tx.proto +++ b/proto/osmosis/poolmanager/v1beta1/tx.proto @@ -32,7 +32,7 @@ message MsgSwapExactAmountIn { (gogoproto.nullable) = false ]; string token_out_min_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_min_amount\"", (gogoproto.nullable) = false ]; @@ -40,7 +40,7 @@ message MsgSwapExactAmountIn { message MsgSwapExactAmountInResponse { string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -55,7 +55,7 @@ message MsgSplitRouteSwapExactAmountIn { string token_in_denom = 3 [ (gogoproto.moretags) = "yaml:\"token_in_denom\"" ]; string token_out_min_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_min_amount\"", (gogoproto.nullable) = false ]; @@ -63,7 +63,7 @@ message MsgSplitRouteSwapExactAmountIn { message MsgSplitRouteSwapExactAmountInResponse { string token_out_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_out_amount\"", (gogoproto.nullable) = false ]; @@ -76,7 +76,7 @@ message MsgSwapExactAmountOut { string sender = 1 [ (gogoproto.moretags) = "yaml:\"sender\"" ]; repeated SwapAmountOutRoute routes = 2 [ (gogoproto.nullable) = false ]; string token_in_max_amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_max_amount\"", (gogoproto.nullable) = false ]; @@ -88,7 +88,7 @@ message MsgSwapExactAmountOut { message MsgSwapExactAmountOutResponse { string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; @@ -103,7 +103,7 @@ message MsgSplitRouteSwapExactAmountOut { string token_out_denom = 3 [ (gogoproto.moretags) = "yaml:\"token_out_denom\"" ]; string token_in_max_amount = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_max_amount\"", (gogoproto.nullable) = false ]; @@ -111,7 +111,7 @@ message MsgSplitRouteSwapExactAmountOut { message MsgSplitRouteSwapExactAmountOutResponse { string token_in_amount = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"token_in_amount\"", (gogoproto.nullable) = false ]; @@ -136,7 +136,7 @@ message DenomPairTakerFee { 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.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"taker_fee\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/protorev/v1beta1/protorev.proto b/proto/osmosis/protorev/v1beta1/protorev.proto index 33030223ad2..63ee29cf3b5 100644 --- a/proto/osmosis/protorev/v1beta1/protorev.proto +++ b/proto/osmosis/protorev/v1beta1/protorev.proto @@ -36,7 +36,7 @@ message Route { // The step size that will be used to find the optimal swap amount in the // binary search string step_size = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"step_size\"" ]; @@ -65,7 +65,7 @@ message RouteStatistics { // number_of_trades is the number of trades the module has executed using this // route string number_of_trades = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"number_of_trades\"" ]; @@ -172,7 +172,7 @@ message BaseDenom { // The step size of the binary search that is used to find the optimal swap // amount string step_size = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"step_size\"" ]; diff --git a/proto/osmosis/protorev/v1beta1/query.proto b/proto/osmosis/protorev/v1beta1/query.proto index fc893a8a44d..f7d7147135f 100644 --- a/proto/osmosis/protorev/v1beta1/query.proto +++ b/proto/osmosis/protorev/v1beta1/query.proto @@ -136,7 +136,7 @@ message QueryGetProtoRevNumberOfTradesRequest {} message QueryGetProtoRevNumberOfTradesResponse { // number_of_trades is the number of trades the module has executed string number_of_trades = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"number_of_trades\"" ]; diff --git a/proto/osmosis/sumtree/v1beta1/tree.proto b/proto/osmosis/sumtree/v1beta1/tree.proto index 02f54011f10..1a408c0f8e9 100644 --- a/proto/osmosis/sumtree/v1beta1/tree.proto +++ b/proto/osmosis/sumtree/v1beta1/tree.proto @@ -11,7 +11,7 @@ message Node { repeated Child children = 1; } message Child { bytes index = 1; string accumulation = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/superfluid/params.proto b/proto/osmosis/superfluid/params.proto index 4813e373437..b3292530ef3 100644 --- a/proto/osmosis/superfluid/params.proto +++ b/proto/osmosis/superfluid/params.proto @@ -14,7 +14,7 @@ message Params { // volatilities, and have base staking be 'resistant' to volatility. string minimum_risk_factor = 1 [ (gogoproto.moretags) = "yaml:\"minimum_risk_factor\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/superfluid/query.proto b/proto/osmosis/superfluid/query.proto index 1ea41b65b8e..fa76b5750d6 100644 --- a/proto/osmosis/superfluid/query.proto +++ b/proto/osmosis/superfluid/query.proto @@ -190,12 +190,12 @@ message QueryTotalDelegationByValidatorForDenomResponse { message Delegations { string val_addr = 1; string amount_sfsd = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount_sfsd\"", (gogoproto.nullable) = false ]; string osmo_equivalent = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"osmo_equivalent\"", (gogoproto.nullable) = false ]; @@ -204,7 +204,7 @@ message TotalSuperfluidDelegationsRequest {} message TotalSuperfluidDelegationsResponse { string total_delegations = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"total_superfluid_delegations\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/superfluid/superfluid.proto b/proto/osmosis/superfluid/superfluid.proto index 8a8ed1f66ac..094124ae972 100644 --- a/proto/osmosis/superfluid/superfluid.proto +++ b/proto/osmosis/superfluid/superfluid.proto @@ -55,7 +55,7 @@ message OsmoEquivalentMultiplierRecord { string denom = 2; string multiplier = 3 [ (gogoproto.moretags) = "yaml:\"multiplier\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/superfluid/tx.proto b/proto/osmosis/superfluid/tx.proto index a61b46421a2..5026c73e5c6 100644 --- a/proto/osmosis/superfluid/tx.proto +++ b/proto/osmosis/superfluid/tx.proto @@ -178,17 +178,17 @@ message MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition { message MsgUnlockAndMigrateSharesToFullRangeConcentratedPositionResponse { string amount0 = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount0\"", (gogoproto.nullable) = false ]; string amount1 = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; string liquidity_created = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"liquidity_created\"", (gogoproto.nullable) = false ]; @@ -218,12 +218,12 @@ message MsgAddToConcentratedLiquiditySuperfluidPosition { message MsgAddToConcentratedLiquiditySuperfluidPositionResponse { uint64 position_id = 1 [ (gogoproto.moretags) = "yaml:\"position_id\"" ]; string amount0 = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount0\"", (gogoproto.nullable) = false ]; string amount1 = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"amount1\"", (gogoproto.nullable) = false ]; @@ -231,7 +231,7 @@ message MsgAddToConcentratedLiquiditySuperfluidPositionResponse { // It includes the liquidity that existed before in the position // and the new liquidity that was added to the position. string new_liquidity = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"new_liquidity\"", (gogoproto.nullable) = false ]; @@ -252,7 +252,7 @@ message MsgUnbondConvertAndStake { string val_addr = 3; // min_amt_to_stake indicates the minimum amount to stake after conversion string min_amt_to_stake = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"min_amt_to_stake\"", (gogoproto.nullable) = false ]; @@ -268,7 +268,7 @@ message MsgUnbondConvertAndStake { message MsgUnbondConvertAndStakeResponse { string total_amt_staked = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.moretags) = "yaml:\"total_amt_staked\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/twap/v1beta1/query.proto b/proto/osmosis/twap/v1beta1/query.proto index 334cab5f780..4b0883f718e 100644 --- a/proto/osmosis/twap/v1beta1/query.proto +++ b/proto/osmosis/twap/v1beta1/query.proto @@ -51,7 +51,7 @@ message ArithmeticTwapRequest { } message ArithmeticTwapResponse { string arithmetic_twap = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"arithmetic_twap\"", (gogoproto.nullable) = false ]; @@ -69,7 +69,7 @@ message ArithmeticTwapToNowRequest { } message ArithmeticTwapToNowResponse { string arithmetic_twap = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"arithmetic_twap\"", (gogoproto.nullable) = false ]; @@ -92,7 +92,7 @@ message GeometricTwapRequest { } message GeometricTwapResponse { string geometric_twap = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"geometric_twap\"", (gogoproto.nullable) = false ]; @@ -110,7 +110,7 @@ message GeometricTwapToNowRequest { } message GeometricTwapToNowResponse { string geometric_twap = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.moretags) = "yaml:\"geometric_twap\"", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/twap/v1beta1/twap_record.proto b/proto/osmosis/twap/v1beta1/twap_record.proto index 56025c9e00e..c124b8d829d 100644 --- a/proto/osmosis/twap/v1beta1/twap_record.proto +++ b/proto/osmosis/twap/v1beta1/twap_record.proto @@ -38,25 +38,25 @@ message TwapRecord { // We store the last spot prices in the struct, so that we can interpolate // accumulator values for times between when accumulator records are stored. string p0_last_spot_price = 6 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; string p1_last_spot_price = 7 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; string p0_arithmetic_twap_accumulator = 8 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; string p1_arithmetic_twap_accumulator = 9 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; string geometric_twap_accumulator = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; diff --git a/proto/osmosis/txfees/v1beta1/query.proto b/proto/osmosis/txfees/v1beta1/query.proto index 6c7e9b6aa29..e37f58d6b41 100644 --- a/proto/osmosis/txfees/v1beta1/query.proto +++ b/proto/osmosis/txfees/v1beta1/query.proto @@ -56,7 +56,7 @@ message QueryDenomSpotPriceResponse { uint64 poolID = 1 [ (gogoproto.moretags) = "yaml:\"pool_id\"" ]; string spot_price = 2 [ (gogoproto.moretags) = "yaml:\"spot_price\"", - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/proto/osmosis/valset-pref/v1beta1/state.proto b/proto/osmosis/valset-pref/v1beta1/state.proto index 54e285a460d..2beab533939 100644 --- a/proto/osmosis/valset-pref/v1beta1/state.proto +++ b/proto/osmosis/valset-pref/v1beta1/state.proto @@ -19,7 +19,7 @@ message ValidatorPreference { [ (gogoproto.moretags) = "yaml:\"val_oper_address\"" ]; // weight is decimal between 0 and 1, and they all sum to 1. string weight = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.customtype) = "cosmossdk.io/math.LegacyDec", (gogoproto.nullable) = false ]; } diff --git a/simulation/simtypes/random/sdkrand.go b/simulation/simtypes/random/sdkrand.go index a39bb7d2b71..7c6dc8f0274 100644 --- a/simulation/simtypes/random/sdkrand.go +++ b/simulation/simtypes/random/sdkrand.go @@ -9,6 +9,8 @@ import ( "unsafe" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -40,20 +42,20 @@ func RandStringOfLength(r *rand.Rand, n int) string { return *(*string)(unsafe.Pointer(&b)) } -// RandPositiveInt get a rand positive sdk.Int -func RandPositiveInt(r *rand.Rand, max sdk.Int) (sdk.Int, error) { - if !max.GTE(sdk.OneInt()) { - return sdk.Int{}, errors.New("max too small") +// RandPositiveInt get a rand positive osmomath.Int +func RandPositiveInt(r *rand.Rand, max osmomath.Int) (osmomath.Int, error) { + if !max.GTE(osmomath.OneInt()) { + return osmomath.Int{}, errors.New("max too small") } - max = max.Sub(sdk.OneInt()) + max = max.Sub(osmomath.OneInt()) - return sdk.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(sdk.OneInt()), nil + return osmomath.NewIntFromBigInt(new(big.Int).Rand(r, max.BigInt())).Add(osmomath.OneInt()), nil } // RandomAmount generates a random amount // Note: The range of RandomAmount includes max, and is, in fact, biased to return max as well as 0. -func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { +func RandomAmount(r *rand.Rand, max osmomath.Int) osmomath.Int { randInt := big.NewInt(0) switch r.Intn(10) { @@ -65,12 +67,12 @@ func RandomAmount(r *rand.Rand, max sdk.Int) sdk.Int { randInt = big.NewInt(0).Rand(r, max.BigInt()) // up to max - 1 } - return sdk.NewIntFromBigInt(randInt) + return osmomath.NewIntFromBigInt(randInt) } // RandomDecAmount generates a random decimal amount // Note: The range of RandomDecAmount includes max, and is, in fact, biased to return max as well as 0. -func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec { +func RandomDecAmount(r *rand.Rand, max osmomath.Dec) osmomath.Dec { randInt := big.NewInt(0) switch r.Intn(10) { @@ -82,7 +84,7 @@ func RandomDecAmount(r *rand.Rand, max sdk.Dec) sdk.Dec { randInt = big.NewInt(0).Rand(r, max.BigInt()) } - return sdk.NewDecFromBigIntWithPrec(randInt, sdk.Precision) + return osmomath.NewDecFromBigIntWithPrec(randInt, sdk.Precision) } // RandTimestamp generates a random timestamp diff --git a/simulation/simtypes/randutil.go b/simulation/simtypes/randutil.go index a516b35a6b1..641fee6a207 100644 --- a/simulation/simtypes/randutil.go +++ b/simulation/simtypes/randutil.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "golang.org/x/exp/constraints" + "github.com/osmosis-labs/osmosis/osmomath" sdkrand "github.com/osmosis-labs/osmosis/v19/simulation/simtypes/random" ) @@ -31,8 +32,8 @@ func (sim *SimCtx) RandStringOfLength(n int) string { return sdkrand.RandStringOfLength(r, n) } -// RandPositiveInt get a rand positive sdk.Int -func (sim *SimCtx) RandPositiveInt(max sdk.Int) sdk.Int { +// RandPositiveInt get a rand positive osmomath.Int +func (sim *SimCtx) RandPositiveInt(max osmomath.Int) osmomath.Int { r := sim.GetSeededRand("random bounded positive int") v, err := sdkrand.RandPositiveInt(r, max) if err != nil { @@ -43,14 +44,14 @@ func (sim *SimCtx) RandPositiveInt(max sdk.Int) sdk.Int { // RandomAmount generates a random amount // that is biased to return max and 0. -func (sim *SimCtx) RandomAmount(max sdk.Int) sdk.Int { +func (sim *SimCtx) RandomAmount(max osmomath.Int) osmomath.Int { r := sim.GetSeededRand("random bounded positive int") return sdkrand.RandomAmount(r, max) } // RandomDecAmount generates a random decimal amount // Note: The range of RandomDecAmount includes max, and is, in fact, biased to return max as well as 0. -func (sim *SimCtx) RandomDecAmount(max sdk.Dec) sdk.Dec { +func (sim *SimCtx) RandomDecAmount(max osmomath.Dec) osmomath.Dec { r := sim.GetSeededRand("random bounded positive int") return sdkrand.RandomDecAmount(r, max) } diff --git a/tests/cl-genesis-positions/convert.go b/tests/cl-genesis-positions/convert.go index c49abb24d8f..024c34f6a0c 100644 --- a/tests/cl-genesis-positions/convert.go +++ b/tests/cl-genesis-positions/convert.go @@ -71,8 +71,8 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, } initAmounts := sdk.NewCoins( - sdk.NewCoin(denom0, sdk.NewInt(1000000000000000000)), - sdk.NewCoin(denom1, sdk.NewInt(1000000000000000000)), + sdk.NewCoin(denom0, osmomath.NewInt(1000000000000000000)), + sdk.NewCoin(denom1, osmomath.NewInt(1000000000000000000)), ) // fund all accounts @@ -88,7 +88,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, Denom0: denom0, Denom1: denom1, TickSpacing: 100, - SpreadFactor: sdk.MustNewDecFromStr("0.0005"), + SpreadFactor: osmomath.MustNewDecFromStr("0.0005"), } err := msgCreatePool.ValidateBasic() @@ -111,7 +111,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, // Initialize first position to be 1:1 price // this is because the first position must have non-zero token0 and token1 to initialize the price // however, our data has first position with non-zero amount. - _, err = osmosis.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(osmosis.Ctx, pool.GetId(), osmosis.TestAccs[0], sdk.NewCoins(sdk.NewCoin(msgCreatePool.Denom0, sdk.NewInt(100)), sdk.NewCoin(msgCreatePool.Denom1, sdk.NewInt(100)))) + _, err = osmosis.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(osmosis.Ctx, pool.GetId(), osmosis.TestAccs[0], sdk.NewCoins(sdk.NewCoin(msgCreatePool.Denom0, osmomath.NewInt(100)), sdk.NewCoin(msgCreatePool.Denom1, osmomath.NewInt(100)))) if err != nil { panic(err) } @@ -138,7 +138,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, if err != nil { panic(err) } - lowerTickOsmosis, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrtPriceLower), pool.GetTickSpacing()) + lowerTickOsmosis, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrtPriceLower), pool.GetTickSpacing()) if err != nil { panic(err) } @@ -147,7 +147,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, if err != nil { panic(err) } - upperTickOsmosis, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrtPriceUpper), pool.GetTickSpacing()) + upperTickOsmosis, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrtPriceUpper), pool.GetTickSpacing()) if err != nil { panic(err) } @@ -185,8 +185,8 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, LowerTick: lowerTickOsmosis, UpperTick: upperTickOsmosis, TokensProvided: tokensProvided, - TokenMinAmount0: sdk.ZeroInt(), - TokenMinAmount1: sdk.ZeroInt(), + TokenMinAmount0: osmomath.ZeroInt(), + TokenMinAmount1: osmomath.ZeroInt(), }) if err != nil { fmt.Printf("\n\n\nWARNING: Failed to create position: %v\n\n\n", err) @@ -230,7 +230,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress, return clGenesis, bankGenesis } -func parsePrice(strPrice string) (result sdk.Dec) { +func parsePrice(strPrice string) (result osmomath.Dec) { defer func() { r := recover() if r != nil { @@ -250,11 +250,11 @@ func parsePrice(strPrice string) (result sdk.Dec) { result = cltypes.MinSpotPrice } }() - result = osmomath.MustNewDecFromStr(strPrice).SDKDec() + result = osmomath.MustNewBigDecFromStr(strPrice).Dec() return result } -func parseStringToInt(strInt string) (result sdk.Int, failedParsing bool) { +func parseStringToInt(strInt string) (result osmomath.Int, failedParsing bool) { defer func() { r := recover() if r != nil { @@ -262,7 +262,7 @@ func parseStringToInt(strInt string) (result sdk.Int, failedParsing bool) { failedParsing = true } }() - result = osmomath.MustNewDecFromStr(strInt).SDKDec().MulInt64(int64(osmosisPrecision)).TruncateInt() + result = osmomath.MustNewBigDecFromStr(strInt).Dec().MulInt64(int64(osmosisPrecision)).TruncateInt() return result, failedParsing } diff --git a/tests/cl-genesis-positions/go.mod b/tests/cl-genesis-positions/go.mod index 53196920413..bfd82d0fe11 100644 --- a/tests/cl-genesis-positions/go.mod +++ b/tests/cl-genesis-positions/go.mod @@ -3,25 +3,30 @@ module cl-get-positions-subgraph go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.4 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/ignite/cli v0.23.0 - 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/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d + github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d + github.com/osmosis-labs/osmosis/v19 v19.0.0 github.com/tendermint/tendermint v0.37.0-rc1 ) require ( + cosmossdk.io/errors v1.0.0 // indirect + cosmossdk.io/math v1.1.3-rc.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 github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect + github.com/CosmWasm/wasmd v0.31.0 // indirect + github.com/CosmWasm/wasmvm v1.2.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/beorn7/perks v1.0.1 // indirect 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.10.0 // indirect + github.com/bytedance/sonic v1.10.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 @@ -29,9 +34,13 @@ require ( 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 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect + 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/middleware/packet-forward-middleware/v4 v4.1.0 // indirect + github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.1.0 // 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 @@ -40,16 +49,17 @@ require ( github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/dgraph-io/badger/v3 v3.2103.2 // indirect github.com/dgraph-io/ristretto v0.1.0 // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect github.com/dustin/go-humanize v1.0.1-0.20200219035652-afde56e7acac // indirect 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/goccy/go-json v0.10.2 // indirect + github.com/go-playground/universal-translator v0.18.1 // 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 @@ -59,6 +69,8 @@ require ( github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/flatbuffers v2.0.8+incompatible // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/mux v1.8.0 // indirect @@ -72,10 +84,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.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/leodido/go-urn v1.2.4 // indirect github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -86,8 +100,9 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.27.6 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230907221024-04d6a7555f0e // indirect + github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230907221024-04d6a7555f0e // 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 @@ -102,7 +117,6 @@ require ( github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.7.0 // indirect @@ -117,12 +131,10 @@ 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.12.0 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/mod v0.12.0 // indirect @@ -131,7 +143,6 @@ require ( golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.12.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 @@ -149,8 +160,8 @@ replace ( github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 // dragonberry github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // N.B. v0.19.5 contains a breaking change to the IAVL API github.com/cosmos/iavl v0.19.5 => github.com/cosmos/iavl v0.19.4 diff --git a/tests/cl-genesis-positions/go.sum b/tests/cl-genesis-positions/go.sum index e16c9b9f0c7..f905902795f 100644 --- a/tests/cl-genesis-positions/go.sum +++ b/tests/cl-genesis-positions/go.sum @@ -38,6 +38,9 @@ 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 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -55,6 +58,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/CosmWasm/wasmvm v1.2.1 h1:si0tRsRDdUShV0k51Wn6zRKlmj3/WWP9Yr4cLmDTf+8= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -142,8 +146,7 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= 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 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= 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= @@ -158,10 +161,9 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -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/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= @@ -188,17 +190,25 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/cosmos/gogoproto v1.4.6 h1:Ee7z15dWJaGlgM2rWrK8N2IX7PQcuccu8oG68jp5RL4= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= 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/middleware/packet-forward-middleware/v4 v4.1.0 h1:96fDMIUSlSQ6dBcwhdYwTT+uTwFP+EWbSyLORcKSJZ8= +github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.0/go.mod h1:Mn/jr9pIYr1ofFuptLEi9N6MjcshTT0cpoOY4ln1DeA= +github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.1.0 h1:1iQ8/rJwkeGJe81fKyZC/ASSajoJP0jEi6IJFiKIr7Y= +github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.1.0/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= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= github.com/cosmos/ledger-cosmos-go v0.12.2/go.mod h1:ZcqYgnfNJ6lAXe4HPtWgarNEY+B74i+2/8MhZw4ziiI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -241,6 +251,7 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -327,7 +338,6 @@ 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= @@ -491,6 +501,7 @@ 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.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= 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= @@ -555,6 +566,7 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 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= @@ -574,6 +586,7 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -685,12 +698,16 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 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.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/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d h1:b8Bz31kbzTbcSNsBOcvc2CRVJz5C3cGOQB7JqWDzdfA= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d/go.mod h1:Jj4zQ/IA8iPuHF+Hc/dTFJqAis5WYX3EcO7Xg70fAd8= +github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d h1:9xBej3lldho6WlM8vFdznEjPpXf3EWL6ySvZlkoof/w= +github.com/osmosis-labs/osmosis/v19 v19.0.0 h1:gqcas/XfxtEuZXsWGTO9vNMHiY78Qs09FBQw73djIVM= +github.com/osmosis-labs/osmosis/v19 v19.0.0/go.mod h1:NEm0wCgbUUL9RoABQyR8QUCrdk7lNp5K/CNK44lapMI= +github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230907221024-04d6a7555f0e h1:SNrMWsexZZpeBkaa3yxxLBrVdOlMGxHVFWzAoo/MQnQ= +github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.9-0.20230907221024-04d6a7555f0e h1:l7qCTWdQG7myENB7w3gMAh0FsenWJrJEg+77R8VFkU4= +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= github.com/p0mvn/cli v0.23.1 h1:Y4vUUNzTmrhhlaj1FIuLDCX9Go0oTqlf88m2PtaG5Zs= github.com/p0mvn/cli v0.23.1/go.mod h1:r92KMcpaLyYii0XnlQz5nfCxAMraLgOvWCHYw4pWZ7w= @@ -862,7 +879,10 @@ github.com/tidwall/btree v1.6.0 h1:LDZfKfQIBHGHWSwckhXI0RPSXzlo+KYdjK7FWSqOzzg= github.com/tidwall/btree v1.6.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= @@ -876,6 +896,7 @@ 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= @@ -925,9 +946,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/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= @@ -951,6 +970,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm 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.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 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= @@ -966,6 +986,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -991,6 +1012,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1043,6 +1065,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -1064,6 +1087,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1143,9 +1167,11 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 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= @@ -1156,6 +1182,7 @@ 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.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= @@ -1369,10 +1396,12 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/tests/cl-go-client/go.mod b/tests/cl-go-client/go.mod index 2044a03a28a..a8023029ae3 100644 --- a/tests/cl-go-client/go.mod +++ b/tests/cl-go-client/go.mod @@ -3,14 +3,18 @@ module cl-positions go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.4 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/ignite/cli v0.23.0 - github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5 - github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 + github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d + github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d + github.com/osmosis-labs/osmosis/v19 v19.0.0 + github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230907221024-04d6a7555f0e ) require ( + cosmossdk.io/errors v1.0.0 // indirect + cosmossdk.io/math v1.1.3-rc.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 @@ -21,7 +25,7 @@ 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.10.0 // indirect + github.com/bytedance/sonic v1.10.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 @@ -29,6 +33,7 @@ require ( 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 + github.com/cosmos/cosmos-proto v1.0.0-beta.3 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect github.com/cosmos/gorocksdb v1.2.0 // indirect github.com/cosmos/iavl v0.19.5 // indirect @@ -44,12 +49,12 @@ 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/goccy/go-json v0.10.2 // indirect + github.com/go-playground/universal-translator v0.18.1 // 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 @@ -76,6 +81,7 @@ require ( 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/leodido/go-urn v1.2.4 // indirect github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -86,8 +92,6 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.27.6 // 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 @@ -102,7 +106,6 @@ require ( github.com/rs/cors v1.8.2 // indirect github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect github.com/spf13/afero v1.9.5 // indirect github.com/spf13/cast v1.5.1 // indirect github.com/spf13/cobra v1.7.0 // indirect @@ -118,12 +121,10 @@ require ( github.com/tendermint/tendermint v0.37.0-rc1 // 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.12.0 // indirect golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea // indirect golang.org/x/mod v0.12.0 // indirect @@ -132,7 +133,6 @@ require ( golang.org/x/sys v0.11.0 // indirect golang.org/x/term v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect - golang.org/x/tools v0.12.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 @@ -150,8 +150,8 @@ replace ( github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 // dragonberry github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // use cosmos-compatible protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/tests/cl-go-client/go.sum b/tests/cl-go-client/go.sum index 6d9c0a5b8cd..a599ca6a8ab 100644 --- a/tests/cl-go-client/go.sum +++ b/tests/cl-go-client/go.sum @@ -38,6 +38,9 @@ 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 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -55,6 +58,7 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03 github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= +github.com/CosmWasm/wasmvm v1.2.1 h1:si0tRsRDdUShV0k51Wn6zRKlmj3/WWP9Yr4cLmDTf+8= github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= @@ -142,8 +146,7 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= 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 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +github.com/bytedance/sonic v1.10.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= 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= @@ -158,10 +161,9 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -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/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= @@ -188,15 +190,20 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= +github.com/cosmos/gogoproto v1.4.6 h1:Ee7z15dWJaGlgM2rWrK8N2IX7PQcuccu8oG68jp5RL4= github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= +github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v4 v4.1.0 h1:96fDMIUSlSQ6dBcwhdYwTT+uTwFP+EWbSyLORcKSJZ8= +github.com/cosmos/ibc-apps/modules/async-icq/v4 v4.1.0 h1:1iQ8/rJwkeGJe81fKyZC/ASSajoJP0jEi6IJFiKIr7Y= 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/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= @@ -241,6 +248,7 @@ github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8 github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -279,6 +287,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= @@ -314,9 +323,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= @@ -339,6 +348,7 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw 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.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= @@ -490,6 +500,7 @@ 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.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= 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= @@ -554,6 +565,7 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 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= @@ -571,8 +583,10 @@ 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.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -655,7 +669,6 @@ github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -685,11 +698,15 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 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/osmoutils v0.0.0-20230807183608-16c217dedde5 h1:j4ifxomFROGROHalqWwX7VPDgxOPotMB1GiAWdb03i4= -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/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d h1:b8Bz31kbzTbcSNsBOcvc2CRVJz5C3cGOQB7JqWDzdfA= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d/go.mod h1:Jj4zQ/IA8iPuHF+Hc/dTFJqAis5WYX3EcO7Xg70fAd8= +github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d h1:9xBej3lldho6WlM8vFdznEjPpXf3EWL6ySvZlkoof/w= +github.com/osmosis-labs/osmosis/v19 v19.0.0 h1:gqcas/XfxtEuZXsWGTO9vNMHiY78Qs09FBQw73djIVM= +github.com/osmosis-labs/osmosis/v19 v19.0.0/go.mod h1:NEm0wCgbUUL9RoABQyR8QUCrdk7lNp5K/CNK44lapMI= +github.com/osmosis-labs/osmosis/x/epochs v0.0.3-0.20230907221024-04d6a7555f0e h1:SNrMWsexZZpeBkaa3yxxLBrVdOlMGxHVFWzAoo/MQnQ= +github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.8 h1:BUGowctYQT0vdPgULrvwraEsW+sS6DnbzndTLKLmWVY= +github.com/osmosis-labs/wasmd v0.31.0-osmo-v16 h1:X747cZYdnqc/+RV48iPVeGprpVb/fUWSaKGsZUWrdbg= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= github.com/p0mvn/cli v0.23.1 h1:Y4vUUNzTmrhhlaj1FIuLDCX9Go0oTqlf88m2PtaG5Zs= github.com/p0mvn/cli v0.23.1/go.mod h1:r92KMcpaLyYii0XnlQz5nfCxAMraLgOvWCHYw4pWZ7w= @@ -842,6 +859,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= @@ -875,11 +893,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= @@ -925,9 +943,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= -golang.org/x/arch v0.3.0/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= @@ -951,6 +967,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm 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.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 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= @@ -966,6 +983,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -991,6 +1009,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= +golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1043,6 +1062,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -1064,6 +1084,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= +golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1143,9 +1164,11 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 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= @@ -1156,6 +1179,7 @@ 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.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= @@ -1302,8 +1326,11 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D 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-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= @@ -1319,6 +1346,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.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= @@ -1365,10 +1393,12 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/tests/cl-go-client/main.go b/tests/cl-go-client/main.go index c9b6e764f0c..045e1058e29 100644 --- a/tests/cl-go-client/main.go +++ b/tests/cl-go-client/main.go @@ -17,6 +17,7 @@ import ( "github.com/ignite/cli/ignite/pkg/cosmosaccount" "github.com/ignite/cli/ignite/pkg/cosmosclient" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" clqueryproto "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/client/queryproto" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" @@ -85,9 +86,9 @@ const ( var ( defaultAccountName = fmt.Sprintf("%s%d", accountNamePrefix, 1) - defaultMinAmount = sdk.ZeroInt() - defaultSpreadFactor = sdk.MustNewDecFromStr("0.001") - externalGaugeCoins = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000_000_000))) + defaultMinAmount = osmomath.ZeroInt() + defaultSpreadFactor = osmomath.MustNewDecFromStr("0.001") + externalGaugeCoins = sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000_000_000))) accountMutex sync.Mutex ) @@ -178,8 +179,8 @@ func createRandomPosition(igniteClient cosmosclient.Client, poolId uint64) (stri lowerTick := roundTickDown(rand.Int63n(maxTick-minTick+1)+minTick, tickSpacing) // lowerTick <= upperTick <= maxTick upperTick := roundTickDown(maxTick-rand.Int63n(int64(math.Abs(float64(maxTick-lowerTick)))), tickSpacing) - tokenDesired0 := sdk.NewCoin(denom0, sdk.NewInt(rand.Int63n(maxAmountDeposited))) - tokenDesired1 := sdk.NewCoin(denom1, sdk.NewInt(rand.Int63n(maxAmountDeposited))) + tokenDesired0 := sdk.NewCoin(denom0, osmomath.NewInt(rand.Int63n(maxAmountDeposited))) + tokenDesired1 := sdk.NewCoin(denom1, osmomath.NewInt(rand.Int63n(maxAmountDeposited))) tokensDesired := sdk.NewCoins(tokenDesired0, tokenDesired1) runMessageWithRetries(func() error { @@ -209,7 +210,7 @@ func swapRandomSmallAmountsContinuously(igniteClient cosmosclient.Client, poolId isToken0In = rand.Intn(2) == 0 - tokenOutMinAmount = sdk.OneInt() + tokenOutMinAmount = osmomath.OneInt() ) tokenInDenom := denom0 @@ -218,7 +219,7 @@ func swapRandomSmallAmountsContinuously(igniteClient cosmosclient.Client, poolId tokenInDenom = denom1 tokenOutDenom = denom0 } - tokenInCoin := sdk.NewCoin(tokenInDenom, sdk.NewInt(rand.Int63n(maxAmountSingleSwap))) + tokenInCoin := sdk.NewCoin(tokenInDenom, osmomath.NewInt(rand.Int63n(maxAmountSingleSwap))) runMessageWithRetries(func() error { _, err := makeSwap(igniteClient, expectedPoolId, accountName, tokenInCoin, tokenOutDenom, tokenOutMinAmount) @@ -236,7 +237,7 @@ func swapGivenLargeAmountsBothDirections(igniteClient cosmosclient.Client, poolI isToken0In = rand.Intn(2) == 0 - tokenOutMinAmount = sdk.OneInt() + tokenOutMinAmount = osmomath.OneInt() ) tokenInDenom := denom0 @@ -246,7 +247,7 @@ func swapGivenLargeAmountsBothDirections(igniteClient cosmosclient.Client, poolI tokenOutDenom = denom0 } - tokenInCoin := sdk.NewCoin(tokenInDenom, sdk.NewInt(largeStartAmount)) + tokenInCoin := sdk.NewCoin(tokenInDenom, osmomath.NewInt(largeStartAmount)) for i := 0; i < numSwaps; i++ { runMessageWithRetries(func() error { @@ -258,7 +259,7 @@ func swapGivenLargeAmountsBothDirections(igniteClient cosmosclient.Client, poolI // out of funds or liquidity. tempTokenInDenom := tokenInCoin.Denom // new token in = token out / (1 - spread factor) - tokenInCoin = sdk.NewCoin(tokenOutDenom, tokenOut.ToDec().Quo(sdk.OneDec().Sub(defaultSpreadFactor)).RoundInt()) + tokenInCoin = sdk.NewCoin(tokenOutDenom, tokenOut.ToLegacyDec().Quo(osmomath.OneDec().Sub(defaultSpreadFactor)).RoundInt()) tokenOutDenom = tempTokenInDenom } @@ -360,7 +361,7 @@ func createPool(igniteClient cosmosclient.Client, accountName string) uint64 { return resp.PoolID } -func createPosition(client cosmosclient.Client, poolId uint64, senderKeyringAccountName string, lowerTick int64, upperTick int64, tokensProvided sdk.Coins, tokenMinAmount0, tokenMinAmount1 sdk.Int) (positionId uint64, amountCreated0, amountCreated1 sdk.Int, liquidityCreated sdk.Dec, err error) { +func createPosition(client cosmosclient.Client, poolId uint64, senderKeyringAccountName string, lowerTick int64, upperTick int64, tokensProvided sdk.Coins, tokenMinAmount0, tokenMinAmount1 osmomath.Int) (positionId uint64, amountCreated0, amountCreated1 osmomath.Int, liquidityCreated osmomath.Dec, err error) { accountMutex.Lock() // Lock access to getAccountAddressFromKeyring senderAddress := getAccountAddressFromKeyring(client, senderKeyringAccountName) accountMutex.Unlock() // Unlock access to getAccountAddressFromKeyring @@ -378,11 +379,11 @@ func createPosition(client cosmosclient.Client, poolId uint64, senderKeyringAcco } txResp, err := client.BroadcastTx(senderKeyringAccountName, msg) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, sdk.Dec{}, err + return 0, osmomath.Int{}, osmomath.Int{}, osmomath.Dec{}, err } resp := cltypes.MsgCreatePositionResponse{} if err := txResp.Decode(&resp); err != nil { - return 0, sdk.Int{}, sdk.Int{}, sdk.Dec{}, err + return 0, osmomath.Int{}, osmomath.Int{}, osmomath.Dec{}, err } log.Println("created position: positionId", positionId, "amt0", resp.Amount0, "amt1", resp.Amount1, "liquidity", resp.LiquidityCreated) @@ -417,8 +418,8 @@ func addToPositionsOp(igniteClient cosmosclient.Client) { for _, position := range userPositionResp.Positions { position := position.Position - randAmt0 := sdk.NewInt(rand.Int63n(maxAmountDeposited)) - randAmt1 := sdk.NewInt(rand.Int63n(maxAmountDeposited)) + randAmt0 := osmomath.NewInt(rand.Int63n(maxAmountDeposited)) + randAmt1 := osmomath.NewInt(rand.Int63n(maxAmountDeposited)) log.Println("Adding To position: position id", position.PositionId, "accountName", position.Address, "amount0", randAmt0, "amount1", randAmt1, "defaultMinAmount", defaultMinAmount) @@ -490,7 +491,7 @@ func withdrawPositionsOp(igniteClient cosmosclient.Client) { } } -func makeSwap(client cosmosclient.Client, poolId uint64, senderKeyringAccountName string, tokenInCoin sdk.Coin, tokenOutDenom string, tokenOutMinAmount sdk.Int) (sdk.Int, error) { +func makeSwap(client cosmosclient.Client, poolId uint64, senderKeyringAccountName string, tokenInCoin sdk.Coin, tokenOutDenom string, tokenOutMinAmount osmomath.Int) (osmomath.Int, error) { accountMutex.Lock() // Lock access to getAccountAddressFromKeyring senderAddress := getAccountAddressFromKeyring(client, senderKeyringAccountName) accountMutex.Unlock() // Unlock access to getAccountAddressFromKeyring @@ -510,11 +511,11 @@ func makeSwap(client cosmosclient.Client, poolId uint64, senderKeyringAccountNam } txResp, err := client.BroadcastTx(senderKeyringAccountName, msg) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } resp := poolmanagertypes.MsgSwapExactAmountInResponse{} if err := txResp.Decode(&resp); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } log.Println("swap made, token out amount: ", resp.TokenOutAmount) diff --git a/tests/e2e/configurer/chain/chain.go b/tests/e2e/configurer/chain/chain.go index 8b010c51016..99cb8c8011a 100644 --- a/tests/e2e/configurer/chain/chain.go +++ b/tests/e2e/configurer/chain/chain.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" coretypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/tests/e2e/configurer/config" @@ -262,7 +263,7 @@ func (c *Config) getNodeAtIndex(nodeIndex int) (*NodeConfig, error) { } func (c *Config) SubmitCreateConcentratedPoolProposal(chainANode *NodeConfig) (uint64, error) { - propNumber := chainANode.SubmitCreateConcentratedPoolProposal(sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit))) + propNumber := chainANode.SubmitCreateConcentratedPoolProposal(sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit))) chainANode.DepositProposal(propNumber, false) diff --git a/tests/e2e/configurer/chain/commands.go b/tests/e2e/configurer/chain/commands.go index a836e25e555..b7015a60fb5 100644 --- a/tests/e2e/configurer/chain/commands.go +++ b/tests/e2e/configurer/chain/commands.go @@ -15,6 +15,7 @@ import ( transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" "github.com/tendermint/tendermint/libs/bytes" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/tests/e2e/configurer/config" "github.com/osmosis-labs/osmosis/v19/tests/e2e/initialization" @@ -103,7 +104,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, sdk.Dec) { +func (n *NodeConfig) CreateConcentratedPosition(from, lowerTick, upperTick string, tokens string, token0MinAmt, token1MinAmt int64, poolId uint64) (uint64, osmomath.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) @@ -361,9 +362,9 @@ func (n *NodeConfig) SubmitTickSpacingReductionProposal(poolTickSpacingRecords s func (n *NodeConfig) DepositProposal(proposalNumber int, isExpedited bool) { n.LogActionF("depositing on proposal: %d", proposalNumber) - deposit := sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.MinDepositValue)).String() + deposit := sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.MinDepositValue)).String() if isExpedited { - deposit = sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.MinExpeditedDepositValue)).String() + deposit = sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.MinExpeditedDepositValue)).String() } cmd := []string{"osmosisd", "tx", "gov", "deposit", fmt.Sprintf("%d", proposalNumber), deposit, "--from=val"} _, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd) @@ -410,7 +411,7 @@ func (n *NodeConfig) LockTokens(tokens string, duration string, from string) int return lockID } -func (n *NodeConfig) AddToExistingLock(tokens sdk.Int, denom, duration, from string, lockID int) { +func (n *NodeConfig) AddToExistingLock(tokens osmomath.Int, denom, duration, from string, lockID int) { n.LogActionF("noting previous lockup amount") path := fmt.Sprintf("/osmosis/lockup/v1beta1/locked_by_id/%d", lockID) bz, err := n.QueryGRPCGateway(path) @@ -685,7 +686,7 @@ func (n *NodeConfig) SendIBC(srcChain, dstChain *Config, recipient string, token } func (n *NodeConfig) EnableSuperfluidAsset(srcChain *Config, denom string) { - propNumber := n.SubmitSuperfluidProposal(denom, sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit))) + propNumber := n.SubmitSuperfluidProposal(denom, sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit))) n.DepositProposal(propNumber, false) var wg sync.WaitGroup @@ -701,7 +702,7 @@ func (n *NodeConfig) EnableSuperfluidAsset(srcChain *Config, denom string) { wg.Wait() } -func (n *NodeConfig) LockAndAddToExistingLock(srcChain *Config, amount sdk.Int, denom, lockupWalletAddr, lockupWalletSuperfluidAddr string) { +func (n *NodeConfig) LockAndAddToExistingLock(srcChain *Config, amount osmomath.Int, denom, lockupWalletAddr, lockupWalletSuperfluidAddr string) { // lock tokens lockID := n.LockTokens(fmt.Sprintf("%v%s", amount, denom), "240s", lockupWalletAddr) @@ -866,21 +867,21 @@ func extractPositionIdFromResponse(responseBytes []byte) (uint64, error) { return positionID, nil } -func extractLiquidityFromResponse(responseBytes []byte) (sdk.Dec, error) { +func extractLiquidityFromResponse(responseBytes []byte) (osmomath.Dec, error) { var txResponse map[string]interface{} err := json.Unmarshal(responseBytes, &txResponse) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } liquidityString, err := GetLiquidity(txResponse) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } - positionID, err := sdk.NewDecFromStr(liquidityString) + positionID, err := osmomath.NewDecFromStr(liquidityString) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return positionID, nil diff --git a/tests/e2e/configurer/chain/queries.go b/tests/e2e/configurer/chain/queries.go index d2bd0808a00..52da6a93f08 100644 --- a/tests/e2e/configurer/chain/queries.go +++ b/tests/e2e/configurer/chain/queries.go @@ -19,6 +19,7 @@ import ( "github.com/stretchr/testify/require" tmabcitypes "github.com/tendermint/tendermint/abci/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/e2e/util" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/client/queryproto" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" @@ -34,19 +35,19 @@ import ( // PropTallyResult is the result of a proposal tally. type PropTallyResult struct { - Yes sdk.Int - No sdk.Int - Abstain sdk.Int - NoWithVeto sdk.Int + Yes osmomath.Int + No osmomath.Int + Abstain osmomath.Int + NoWithVeto osmomath.Int } // QueryProtoRevNumberOfTrades gets the number of trades the protorev module has executed. -func (n *NodeConfig) QueryProtoRevNumberOfTrades() (sdk.Int, error) { +func (n *NodeConfig) QueryProtoRevNumberOfTrades() (osmomath.Int, error) { path := "/osmosis/protorev/number_of_trades" bz, err := n.QueryGRPCGateway(path) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // nolint: staticcheck @@ -359,14 +360,14 @@ func (n *NodeConfig) QueryBalance(address, denom string) (sdk.Coin, error) { return *balancesResp.GetBalance(), nil } -func (n *NodeConfig) QuerySupplyOf(denom string) (sdk.Int, error) { +func (n *NodeConfig) QuerySupplyOf(denom string) (osmomath.Int, error) { path := fmt.Sprintf("cosmos/bank/v1beta1/supply/%s", denom) bz, err := n.QueryGRPCGateway(path) require.NoError(n.t, err) var supplyResp banktypes.QuerySupplyOfResponse if err := util.Cdc.UnmarshalJSON(bz, &supplyResp); err != nil { - return sdk.NewInt(0), err + return osmomath.NewInt(0), err } return supplyResp.Amount.Amount, nil } @@ -459,10 +460,10 @@ func (n *NodeConfig) QueryPropTally(proposalNumber int) (PropTallyResult, error) var balancesResp govtypes.QueryTallyResultResponse if err := util.Cdc.UnmarshalJSON(bz, &balancesResp); err != nil { return PropTallyResult{ - Yes: sdk.ZeroInt(), - No: sdk.ZeroInt(), - Abstain: sdk.ZeroInt(), - NoWithVeto: sdk.ZeroInt(), + Yes: osmomath.ZeroInt(), + No: osmomath.ZeroInt(), + Abstain: osmomath.ZeroInt(), + NoWithVeto: osmomath.ZeroInt(), }, err } noTotal := balancesResp.Tally.No @@ -537,7 +538,7 @@ func (n *NodeConfig) QueryConcentratedPooIdLinkFromCFMM(cfmmPoolId uint64) uint6 return response.ConcentratedPoolId } -func (n *NodeConfig) QueryArithmeticTwapToNow(poolId uint64, baseAsset, quoteAsset string, startTime time.Time) (sdk.Dec, error) { +func (n *NodeConfig) QueryArithmeticTwapToNow(poolId uint64, baseAsset, quoteAsset string, startTime time.Time) (osmomath.Dec, error) { path := "osmosis/twap/v1beta1/ArithmeticTwapToNow" bz, err := n.QueryGRPCGateway( @@ -548,7 +549,7 @@ func (n *NodeConfig) QueryArithmeticTwapToNow(poolId uint64, baseAsset, quoteAss "start_time", startTime.Format(time.RFC3339Nano), ) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } var response twapqueryproto.ArithmeticTwapToNowResponse @@ -557,7 +558,7 @@ func (n *NodeConfig) QueryArithmeticTwapToNow(poolId uint64, baseAsset, quoteAss return response.ArithmeticTwap, nil } -func (n *NodeConfig) QueryArithmeticTwap(poolId uint64, baseAsset, quoteAsset string, startTime time.Time, endTime time.Time) (sdk.Dec, error) { +func (n *NodeConfig) QueryArithmeticTwap(poolId uint64, baseAsset, quoteAsset string, startTime time.Time, endTime time.Time) (osmomath.Dec, error) { path := "osmosis/twap/v1beta1/ArithmeticTwap" bz, err := n.QueryGRPCGateway( @@ -569,7 +570,7 @@ func (n *NodeConfig) QueryArithmeticTwap(poolId uint64, baseAsset, quoteAsset st "end_time", endTime.Format(time.RFC3339Nano), ) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } var response twapqueryproto.ArithmeticTwapResponse @@ -578,7 +579,7 @@ func (n *NodeConfig) QueryArithmeticTwap(poolId uint64, baseAsset, quoteAsset st return response.ArithmeticTwap, nil } -func (n *NodeConfig) QueryGeometricTwapToNow(poolId uint64, baseAsset, quoteAsset string, startTime time.Time) (sdk.Dec, error) { +func (n *NodeConfig) QueryGeometricTwapToNow(poolId uint64, baseAsset, quoteAsset string, startTime time.Time) (osmomath.Dec, error) { path := "osmosis/twap/v1beta1/GeometricTwapToNow" bz, err := n.QueryGRPCGateway( @@ -589,7 +590,7 @@ func (n *NodeConfig) QueryGeometricTwapToNow(poolId uint64, baseAsset, quoteAsse "start_time", startTime.Format(time.RFC3339Nano), ) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } var response twapqueryproto.GeometricTwapToNowResponse @@ -598,7 +599,7 @@ func (n *NodeConfig) QueryGeometricTwapToNow(poolId uint64, baseAsset, quoteAsse return response.GeometricTwap, nil } -func (n *NodeConfig) QueryGeometricTwap(poolId uint64, baseAsset, quoteAsset string, startTime time.Time, endTime time.Time) (sdk.Dec, error) { +func (n *NodeConfig) QueryGeometricTwap(poolId uint64, baseAsset, quoteAsset string, startTime time.Time, endTime time.Time) (osmomath.Dec, error) { path := "osmosis/twap/v1beta1/GeometricTwap" bz, err := n.QueryGRPCGateway( @@ -610,7 +611,7 @@ func (n *NodeConfig) QueryGeometricTwap(poolId uint64, baseAsset, quoteAsset str "end_time", endTime.Format(time.RFC3339Nano), ) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } var response twapqueryproto.GeometricTwapResponse diff --git a/tests/e2e/configurer/upgrade.go b/tests/e2e/configurer/upgrade.go index 1e4a56ddf59..5db2cb2afe3 100644 --- a/tests/e2e/configurer/upgrade.go +++ b/tests/e2e/configurer/upgrade.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/tests/e2e/configurer/chain" "github.com/osmosis-labs/osmosis/v19/tests/e2e/configurer/config" @@ -263,7 +264,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error { go func() { defer wg.Done() uc.t.Logf("Lock and add to existing lock for both regular and superfluid lockups on chainA") - chainANode.LockAndAddToExistingLock(chainA, sdk.NewInt(1000000000000000000), poolShareDenom[0], config.LockupWallet[0], config.LockupWalletSuperfluid[0]) + chainANode.LockAndAddToExistingLock(chainA, osmomath.NewInt(1000000000000000000), poolShareDenom[0], config.LockupWallet[0], config.LockupWalletSuperfluid[0]) }() // Chain B @@ -284,7 +285,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error { go func() { defer wg.Done() uc.t.Logf("Lock and add to existing lock for both regular and superfluid lockups on chainB") - chainBNode.LockAndAddToExistingLock(chainB, sdk.NewInt(1000000000000000000), poolShareDenom[1], config.LockupWallet[1], config.LockupWalletSuperfluid[1]) + chainBNode.LockAndAddToExistingLock(chainB, osmomath.NewInt(1000000000000000000), poolShareDenom[1], config.LockupWallet[1], config.LockupWalletSuperfluid[1]) }() wg.Wait() @@ -345,7 +346,7 @@ func (uc *UpgradeConfigurer) runProposalUpgrade() error { return err } chainConfig.UpgradePropHeight = currentHeight + int64(chainConfig.VotingPeriod) + int64(config.PropSubmitBlocks) + int64(config.PropBufferBlocks) - propNumber := node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit))) + propNumber := node.SubmitUpgradeProposal(uc.upgradeVersion, chainConfig.UpgradePropHeight, sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit))) node.DepositProposal(propNumber, false) diff --git a/tests/e2e/containers/containers.go b/tests/e2e/containers/containers.go index 08ed25fdc19..48d7714bb8e 100644 --- a/tests/e2e/containers/containers.go +++ b/tests/e2e/containers/containers.go @@ -16,8 +16,7 @@ import ( "github.com/ory/dockertest/v3/docker" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/e2e/initialization" txfeestypes "github.com/osmosis-labs/osmosis/v19/x/txfees/types" ) @@ -33,7 +32,7 @@ const ( var ( // We set consensus min fee = .0025 uosmo / gas * 400000 gas = 1000 - Fees = txfeestypes.ConsensusMinFee.Mul(sdk.NewDec(GasLimit)).Ceil().TruncateInt64() + Fees = txfeestypes.ConsensusMinFee.Mul(osmomath.NewDec(GasLimit)).Ceil().TruncateInt64() defaultErrRegex = regexp.MustCompile(`(E|e)rror`) diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 0eb2cfdc20b..79ef6973de6 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -38,8 +38,8 @@ import ( ) var ( - // minDecTolerance minimum tolerance for sdk.Dec, given its precision of 18. - minDecTolerance = sdk.MustNewDecFromStr("0.000000000000000001") + // minDecTolerance minimum tolerance for osmomath.Dec, given its precision of 18. + minDecTolerance = osmomath.MustNewDecFromStr("0.000000000000000001") ) // TODO: Find more scalable way to do this @@ -296,7 +296,7 @@ func (s *IntegrationTestSuite) ProtoRev() { s.Require().NoError(err) s.Require().NotNil(routeStats) s.Require().Len(routeStats, 1) - s.Require().Equal(sdk.OneInt(), routeStats[0].NumberOfTrades) + s.Require().Equal(osmomath.OneInt(), routeStats[0].NumberOfTrades) s.Require().Equal([]uint64{swapPoolId1, swapPoolId2, swapPoolId3}, routeStats[0].Route) s.Require().Equal(profits, routeStats[0].Profits) } @@ -309,8 +309,8 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { denom1 = "uosmo" tickSpacing uint64 = 100 spreadFactor = "0.001" // 0.1% - spreadFactorDec = sdk.MustNewDecFromStr("0.001") - takerFee = sdk.MustNewDecFromStr("0.0015") + spreadFactorDec = osmomath.MustNewDecFromStr("0.001") + takerFee = osmomath.MustNewDecFromStr("0.0015") ) // Use chain B node since it has taker fee enabled. @@ -348,8 +348,8 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Sanity check that pool initialized with valid parameters (the ones that we haven't explicitly specified) s.Require().Equal(concentratedPool.GetCurrentTick(), int64(0)) - s.Require().Equal(concentratedPool.GetCurrentSqrtPrice(), osmomath.ZeroDec()) - s.Require().Equal(concentratedPool.GetLiquidity(), sdk.ZeroDec()) + s.Require().Equal(concentratedPool.GetCurrentSqrtPrice(), osmomath.ZeroBigDec()) + s.Require().Equal(concentratedPool.GetLiquidity(), osmomath.ZeroDec()) // Assert contents of the pool are valid (that we explicitly specified) s.Require().Equal(concentratedPool.GetId(), poolID) @@ -357,7 +357,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { s.Require().Equal(concentratedPool.GetToken1(), denom1) s.Require().Equal(concentratedPool.GetTickSpacing(), tickSpacing) s.Require().Equal(concentratedPool.GetExponentAtPriceOne(), cltypes.ExponentAtPriceOne) - s.Require().Equal(concentratedPool.GetSpreadFactor(sdk.Context{}), sdk.MustNewDecFromStr(spreadFactor)) + s.Require().Equal(concentratedPool.GetSpreadFactor(sdk.Context{}), osmomath.MustNewDecFromStr(spreadFactor)) fundTokens := []string{"100000000uosmo", "100000000uion", "100000000stake"} @@ -368,7 +368,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // 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() + totalLiquidity := osmomath.ZeroDec() // Create 2 positions for address1: overlap together, overlap with 2 address3 positions _, liquidity := chainBNode.CreateConcentratedPosition(address1, "[-120000]", "40000", fmt.Sprintf("10000000%s,10000000%s", denom0, denom1), 0, 0, poolID) @@ -423,7 +423,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { var ( // spreadRewardGrowthGlobal is a variable for tracking global spread reward growth - spreadRewardGrowthGlobal = sdk.ZeroDec() + spreadRewardGrowthGlobal = osmomath.ZeroDec() outMinAmt = "1" ) @@ -434,13 +434,13 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { var ( // Swap parameters uosmoInDec_Swap1 = osmomath.NewBigDec(3465198) - uosmoIn_Swap1 = fmt.Sprintf("%suosmo", uosmoInDec_Swap1.SDKDec().String()) + uosmoIn_Swap1 = fmt.Sprintf("%suosmo", uosmoInDec_Swap1.Dec().String()) ) // Perform swap (not crossing initialized ticks) chainBNode.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)) + uosmoInDec_Swap1_SubTakerFee := uosmoInDec_Swap1.Dec().Mul(osmomath.OneDec().Sub(takerFee)).TruncateDec() + uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor := uosmoInDec_Swap1_SubTakerFee.Mul(osmomath.OneDec().Sub(spreadFactorDec)) totalSpreadReward := uosmoInDec_Swap1_SubTakerFee.Sub(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).TruncateDec() spreadRewardGrowthGlobal.AddMut(calculateSpreadRewardGrowthGlobal(totalSpreadReward, concentratedPool.GetLiquidity())) @@ -458,7 +458,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { s.Require().Equal(liquidityAfterSwap.String(), liquidityBeforeSwap.String()) // Assert current sqrt price - expectedSqrtPriceDelta := osmomath.BigDecFromSDKDec(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).QuoTruncate(osmomath.BigDecFromSDKDec(concentratedPool.GetLiquidity())) // Δ(sqrtPrice) = Δy / L + expectedSqrtPriceDelta := osmomath.BigDecFromDec(uosmoInDec_Swap1_SubTakerFee_SubSpreadFactor).QuoTruncate(osmomath.BigDecFromDec(concentratedPool.GetLiquidity())) // Δ(sqrtPrice) = Δy / L expectedSqrtPrice := sqrtPriceBeforeSwap.Add(expectedSqrtPriceDelta) s.Require().Equal(expectedSqrtPrice.String(), sqrtPriceAfterSwap.String()) @@ -477,9 +477,9 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Calculate uncollected spread rewards for address1 position1 spreadRewardsUncollectedAddress1Position1_Swap1 := calculateUncollectedSpreadRewards( positionsAddress1[0].Position.Liquidity, - sdk.ZeroDec(), // no growth below - sdk.ZeroDec(), // no growth above - sdk.ZeroDec(), // no spreadRewardGrowthInsideLast - it is the first swap + osmomath.ZeroDec(), // no growth below + osmomath.ZeroDec(), // no growth above + osmomath.ZeroDec(), // no spreadRewardGrowthInsideLast - it is the first swap spreadRewardGrowthGlobal, ) @@ -528,8 +528,8 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Calculate Δ(sqrtPrice): // deltaSqrtPriceAfterNextInitializedTick = ΔsqrtP(40300) - ΔsqrtP(40000) // deltaSqrtPriceAtNextInitializedTick = ΔsqrtP(40000) - ΔsqrtP(currentTick) - deltaSqrtPriceAfterNextInitializedTick := sqrtPriceAfterNextInitializedTickBigDec.Sub(sqrtPriceAtNextInitializedTickBigDec).SDKDec() - deltaSqrtPriceAtNextInitializedTick := sqrtPriceAtNextInitializedTickBigDec.Sub(sqrtPriceBeforeSwap).SDKDec() + deltaSqrtPriceAfterNextInitializedTick := sqrtPriceAfterNextInitializedTickBigDec.Sub(sqrtPriceAtNextInitializedTickBigDec).Dec() + deltaSqrtPriceAtNextInitializedTick := sqrtPriceAtNextInitializedTickBigDec.Sub(sqrtPriceBeforeSwap).Dec() // Calculate the amount of osmo required to: // * amountInToGetToTickAfterInitialized - move price from next initialized tick (40000) to destination tick (40000 + tickOffset) @@ -544,12 +544,12 @@ 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% + uosmoInDec_Swap2 = uosmoInDec_Swap2_NoSpreadReward.Quo(osmomath.OneDec().Sub(spreadFactorDec)).TruncateDec() // account for spread factor of 1% spreadRewardGrowthGlobal_Swap1 = spreadRewardGrowthGlobalBeforeDustRedistribution.Clone() ) - uosmoInDec_Swap2_AddTakerFee := uosmoInDec_Swap2.Quo(sdk.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee + uosmoInDec_Swap2_AddTakerFee := uosmoInDec_Swap2.Quo(osmomath.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee uosmoIn_Swap2 := fmt.Sprintf("%suosmo", uosmoInDec_Swap2_AddTakerFee.String()) // Perform a swap @@ -573,7 +573,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Step1: amountIn is uosmo tokens that are swapped + uosmo tokens that are paid for spread reward // 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)) + spreadRewardCharge_Swap2_Step1 := amountInToGetToNextInitTick.Mul(spreadFactorDec).Quo(osmomath.OneDec().Sub(spreadFactorDec)) // Step2: hasReachedTarget in SwapStep is false (nextTick is 120000), hence, to find spread rewards, calculate: // spreadRewardCharge = amountRemaining - amountOne @@ -602,7 +602,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Calculate uncollected spread rewards for position, which liquidity will only be live part of the swap spreadRewardsUncollectedAddress1Position1_Swap2 := calculateUncollectedSpreadRewards( positionsAddress1[0].Position.Liquidity, - sdk.ZeroDec(), + osmomath.ZeroDec(), spreadRewardCharge_Swap2_Step2, spreadRewardGrowthGlobal_Swap1, spreadRewardGrowthGlobal, @@ -624,18 +624,18 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Calculate uncollected spread rewards for address3 position2 earned from Swap 1 spreadRewardsUncollectedAddress3Position2_Swap1 := calculateUncollectedSpreadRewards( positionsAddress3[1].Position.Liquidity, - sdk.ZeroDec(), - sdk.ZeroDec(), - sdk.ZeroDec(), + osmomath.ZeroDec(), + osmomath.ZeroDec(), + osmomath.ZeroDec(), spreadRewardGrowthGlobal_Swap1, ) // Calculate uncollected spread rewards for address3 position2 (was active throughout both swap steps): Swap2 spreadRewardsUncollectedAddress3Position2_Swap2 := calculateUncollectedSpreadRewards( positionsAddress3[1].Position.Liquidity, - sdk.ZeroDec(), - sdk.ZeroDec(), - calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap1, sdk.ZeroDec(), sdk.ZeroDec()), + osmomath.ZeroDec(), + osmomath.ZeroDec(), + calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap1, osmomath.ZeroDec(), osmomath.ZeroDec()), spreadRewardGrowthGlobal, ) @@ -684,23 +684,23 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { fractionAtNextInitializedTick := numeratorNextInitializedTick.Quo(denominatorNextInitializedTick) // Calculate amounts of uionIn needed - amountInToGetToTickBelowInitialized := liquidityBeforeSwap.Add(positionsAddress1[0].Position.Liquidity).Mul(fractionBelowNextInitializedTick.SDKDec()) - amountInToGetToNextInitTick = liquidityBeforeSwap.Mul(fractionAtNextInitializedTick.SDKDec()) + amountInToGetToTickBelowInitialized := liquidityBeforeSwap.Add(positionsAddress1[0].Position.Liquidity).Mul(fractionBelowNextInitializedTick.Dec()) + amountInToGetToNextInitTick = liquidityBeforeSwap.Mul(fractionAtNextInitializedTick.Dec()) // Collect spread rewards for address1 position1 to avoid overhead computations (swap2 already asserted spread rewards are aggregated correctly from multiple swaps) chainBNode.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 + 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(osmomath.OneDec().Sub(spreadFactorDec)).TruncateDec() // consider spreadFactor // Save variables from previous swaps spreadRewardGrowthGlobal_Swap2 = spreadRewardGrowthGlobal.Clone() spreadRewardGrowthInsideAddress1Position1Last = spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap2_Step2).Clone() ) - uionInDec_Swap3_AddTakerFee := uionInDec_Swap3.Quo(sdk.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee + uionInDec_Swap3_AddTakerFee := uionInDec_Swap3.Quo(osmomath.OneDec().Sub(takerFee)).TruncateDec() // account for taker fee uionIn_Swap3 := fmt.Sprintf("%suion", uionInDec_Swap3_AddTakerFee.String()) // Perform a swap @@ -725,7 +725,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Step1: amountIn is uion tokens that are swapped + uion tokens that are paid for spread reward // hasReachedTarget in SwapStep is true, hence, to find spread rewards, calculate: // spreadRewardCharge = amountIn * spreadFactor / (1 - spreadFactor) - spreadRewardCharge_Swap3_Step1 := amountInToGetToNextInitTick.Mul(spreadFactorDec).Quo(sdk.OneDec().Sub(spreadFactorDec)) + spreadRewardCharge_Swap3_Step1 := amountInToGetToNextInitTick.Mul(spreadFactorDec).Quo(osmomath.OneDec().Sub(spreadFactorDec)) // Step2: hasReachedTarget in SwapStep is false (next initialized tick is -20000), hence, to find spread rewards, calculate: // spreadRewardCharge = amountRemaining - amountZero @@ -744,7 +744,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Only collects spread rewards for second swap step spreadRewardsUncollectedAddress1Position1_Swap3 := calculateUncollectedSpreadRewards( positionsAddress1[0].Position.Liquidity, - sdk.ZeroDec(), + osmomath.ZeroDec(), spreadRewardCharge_Swap2_Step2.Add(spreadRewardCharge_Swap3_Step1), // spread rewards acquired by swap2 step2 and swap3 step1 (steps happened above upper tick of this position) spreadRewardGrowthInsideAddress1Position1Last, // spreadRewardGrowthInside from first and second swaps spreadRewardGrowthGlobal, @@ -771,19 +771,19 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { // Step 1 spreadRewardsUncollectedAddress3Position2_Swap3_Step1 := calculateUncollectedSpreadRewards( positionsAddress3[1].Position.Liquidity, - sdk.ZeroDec(), // no growth below - sdk.ZeroDec(), // no growth above - calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap2, sdk.ZeroDec(), sdk.ZeroDec()), // snapshot of spread reward growth at swap 2 - spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap3_Step2), // step 1 hasn't earned spread rewards from step 2 + osmomath.ZeroDec(), // no growth below + osmomath.ZeroDec(), // no growth above + calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap2, osmomath.ZeroDec(), osmomath.ZeroDec()), // snapshot of spread reward growth at swap 2 + spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap3_Step2), // step 1 hasn't earned spread rewards from step 2 ) // Step 2 spreadRewardsUncollectedAddress3Position2_Swap3_Step2 := calculateUncollectedSpreadRewards( positionsAddress3[1].Position.Liquidity, - sdk.ZeroDec(), // no growth below - sdk.ZeroDec(), // no growth above - calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap2, sdk.ZeroDec(), sdk.ZeroDec()), // snapshot of spread reward growth at swap 2 - spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap3_Step1), // step 2 hasn't earned spread rewards from step 1 + osmomath.ZeroDec(), // no growth below + osmomath.ZeroDec(), // no growth above + calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal_Swap2, osmomath.ZeroDec(), osmomath.ZeroDec()), // snapshot of spread reward growth at swap 2 + spreadRewardGrowthGlobal.Sub(spreadRewardCharge_Swap3_Step1), // step 2 hasn't earned spread rewards from step 1 ) // Calculate total spread rewards acquired by address3 position2 from all swap steps @@ -828,21 +828,21 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { chainBNode.WithdrawPosition(address1, defaultLiquidityRemoval, positionsAddress1[0].Position.PositionId) // assert positionsAddress1 = chainBNode.QueryConcentratedPositions(address1) - s.Require().Equal(address1position1liquidityBefore, positionsAddress1[0].Position.Liquidity.Add(sdk.MustNewDecFromStr(defaultLiquidityRemoval))) + s.Require().Equal(address1position1liquidityBefore, positionsAddress1[0].Position.Liquidity.Add(osmomath.MustNewDecFromStr(defaultLiquidityRemoval))) // address2: check removing some amount of liquidity address2position1liquidityBefore := positionsAddress2[0].Position.Liquidity chainBNode.WithdrawPosition(address2, defaultLiquidityRemoval, positionsAddress2[0].Position.PositionId) // assert positionsAddress2 = chainBNode.QueryConcentratedPositions(address2) - s.Require().Equal(address2position1liquidityBefore, positionsAddress2[0].Position.Liquidity.Add(sdk.MustNewDecFromStr(defaultLiquidityRemoval))) + s.Require().Equal(address2position1liquidityBefore, positionsAddress2[0].Position.Liquidity.Add(osmomath.MustNewDecFromStr(defaultLiquidityRemoval))) // address3: check removing some amount of liquidity address3position1liquidityBefore := positionsAddress3[0].Position.Liquidity chainBNode.WithdrawPosition(address3, defaultLiquidityRemoval, positionsAddress3[0].Position.PositionId) // assert positionsAddress3 = chainBNode.QueryConcentratedPositions(address3) - s.Require().Equal(address3position1liquidityBefore, positionsAddress3[0].Position.Liquidity.Add(sdk.MustNewDecFromStr(defaultLiquidityRemoval))) + s.Require().Equal(address3position1liquidityBefore, positionsAddress3[0].Position.Liquidity.Add(osmomath.MustNewDecFromStr(defaultLiquidityRemoval))) // Assert removing all liquidity // address2: no more positions left @@ -875,7 +875,7 @@ func (s *IntegrationTestSuite) ConcentratedLiquidity() { newTickSpacing := cltypes.AuthorizedTickSpacing[indexOfCurrentTickSpacing-1] // Run the tick spacing reduction proposal - propNumber := chainBNode.SubmitTickSpacingReductionProposal(fmt.Sprintf("%d,%d", poolID, newTickSpacing), sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinExpeditedDeposit)), true) + propNumber := chainBNode.SubmitTickSpacingReductionProposal(fmt.Sprintf("%d,%d", poolID, newTickSpacing), sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinExpeditedDeposit)), true) chainBNode.DepositProposal(propNumber, true) totalTimeChan := make(chan time.Duration, 1) @@ -1017,11 +1017,11 @@ func (s *IntegrationTestSuite) SuperfluidVoting() { // setup wallets and send gamm tokens to these wallets (both chains) superfluidVotingWallet := chainABNode.CreateWallet("TestSuperfluidVoting", chainAB) chainABNode.BankSend(fmt.Sprintf("10000000000000000000gamm/pool/%d", poolId), initialization.ValidatorWalletName, superfluidVotingWallet) - lockId := chainABNode.LockTokens(fmt.Sprintf("%v%s", sdk.NewInt(1000000000000000000), fmt.Sprintf("gamm/pool/%d", poolId)), "240s", superfluidVotingWallet) + lockId := chainABNode.LockTokens(fmt.Sprintf("%v%s", osmomath.NewInt(1000000000000000000), fmt.Sprintf("gamm/pool/%d", poolId)), "240s", superfluidVotingWallet) chainABNode.SuperfluidDelegate(lockId, chainABNode.OperatorAddress, superfluidVotingWallet) // create a text prop, deposit and vote yes - propNumber := chainABNode.SubmitTextProposal("superfluid vote overwrite test", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinDeposit)), false) + propNumber := chainABNode.SubmitTextProposal("superfluid vote overwrite test", sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinDeposit)), false) chainABNode.DepositProposal(propNumber, false) var wg sync.WaitGroup @@ -1133,7 +1133,7 @@ func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP() s.T().Log("initial twap check") initialTwapBOverA, err := chainANode.QueryGeometricTwapToNow(concentratedPool.GetId(), concentratedPool.GetToken1(), concentratedPool.GetToken0(), timeBeforePositionCreationBeforeSwap) s.Require().Error(err) - s.Require().Equal(sdk.Dec{}, initialTwapBOverA) + s.Require().Equal(osmomath.Dec{}, initialTwapBOverA) // Create a position and check that TWAP now returns a value. s.T().Log("creating first position") @@ -1142,7 +1142,7 @@ func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP() chainA.WaitForNumHeights(2) firstPositionTwapBOverA, err := chainANode.QueryGeometricTwapToNow(concentratedPool.GetId(), concentratedPool.GetToken1(), concentratedPool.GetToken0(), timeAfterPositionCreationBeforeSwap) s.Require().NoError(err) - s.Require().Equal(sdk.MustNewDecFromStr("0.5"), firstPositionTwapBOverA) + s.Require().Equal(osmomath.MustNewDecFromStr("0.5"), firstPositionTwapBOverA) // Run a swap and check that the TWAP updates. s.T().Log("run swap") @@ -1170,7 +1170,7 @@ func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP() s.T().Log("querying for the TWAP from after pool drained") afterRemoveTwapBOverA, err := chainANode.QueryGeometricTwapToNow(concentratedPool.GetId(), concentratedPool.GetToken1(), concentratedPool.GetToken0(), timeAfterSwapPlus1Height) s.Require().Error(err) - s.Require().Equal(sdk.Dec{}, afterRemoveTwapBOverA) + s.Require().Equal(osmomath.Dec{}, afterRemoveTwapBOverA) // Create a position and check that TWAP now returns a value. // Should be equal to 1 since the position contains equal amounts of both tokens. @@ -1180,7 +1180,7 @@ func (s *IntegrationTestSuite) CreateConcentratedLiquidityPoolVoting_And_TWAP() timeAfterSwapRemoveAndCreatePlus1Height := chainANode.QueryLatestBlockTime() secondTwapBOverA, err := chainANode.QueryGeometricTwapToNow(concentratedPool.GetId(), concentratedPool.GetToken1(), concentratedPool.GetToken0(), timeAfterSwapRemoveAndCreatePlus1Height) s.Require().NoError(err) - s.Require().Equal(sdk.NewDec(1), secondTwapBOverA) + s.Require().Equal(osmomath.NewDec(1), secondTwapBOverA) } func (s *IntegrationTestSuite) IBCTokenTransferRateLimiting() { @@ -1201,7 +1201,7 @@ func (s *IntegrationTestSuite) IBCTokenTransferRateLimiting() { osmoSupply, err := chainANode.QuerySupplyOf("uosmo") s.Require().NoError(err) - f, err := osmoSupply.ToDec().Float64() + f, err := osmoSupply.ToLegacyDec().Float64() s.Require().NoError(err) over := f * 0.02 @@ -1272,7 +1272,7 @@ func (s *IntegrationTestSuite) IBCWasmHooks() { transferAmount := int64(10) validatorAddr := chainBNode.GetWallet(initialization.ValidatorWalletName) fmt.Println("Sending IBC transfer IBCWasmHooks") - coin := sdk.NewCoin("uosmo", sdk.NewInt(transferAmount)) + coin := sdk.NewCoin("uosmo", osmomath.NewInt(transferAmount)) chainBNode.SendIBCTransfer(chainA, validatorAddr, contractAddr, fmt.Sprintf(`{"wasm":{"contract":"%s","msg": {"increment": {}} }}`, contractAddr), coin) @@ -1348,7 +1348,7 @@ func (s *IntegrationTestSuite) PacketForwarding() { forwardMemo, err := json.Marshal(memoData) s.NoError(err) // Send the transfer from chainA to chainB. ChainB will parse the memo and forward the packet back to chainA - coin := sdk.NewCoin("uosmo", sdk.NewInt(transferAmount)) + coin := sdk.NewCoin("uosmo", osmomath.NewInt(transferAmount)) chainANode.SendIBCTransfer(chainB, validatorAddr, validatorAddr, string(forwardMemo), coin) // check the balance of the contract @@ -1397,8 +1397,8 @@ func (s *IntegrationTestSuite) AddToExistingLockPostUpgrade() { preUpgradePoolShareDenom := fmt.Sprintf("gamm/pool/%d", config.PreUpgradePoolId[index]) lockupWalletAddr, lockupWalletSuperfluidAddr := chainABNode.GetWallet("lockup-wallet"), chainABNode.GetWallet("lockup-wallet-superfluid") - chainABNode.AddToExistingLock(sdk.NewInt(1000000000000000000), preUpgradePoolShareDenom, "240s", lockupWalletAddr, 1) - chainABNode.AddToExistingLock(sdk.NewInt(1000000000000000000), preUpgradePoolShareDenom, "240s", lockupWalletSuperfluidAddr, 2) + chainABNode.AddToExistingLock(osmomath.NewInt(1000000000000000000), preUpgradePoolShareDenom, "240s", lockupWalletAddr, 1) + chainABNode.AddToExistingLock(osmomath.NewInt(1000000000000000000), preUpgradePoolShareDenom, "240s", lockupWalletSuperfluidAddr, 2) } // TestAddToExistingLock tests lockups to both regular and superfluid locks. @@ -1419,7 +1419,7 @@ func (s *IntegrationTestSuite) AddToExistingLock() { lockupWalletSuperfluidAddr := chainABNode.CreateWalletAndFundFrom("TestAddToExistingLockSuperfluid", funder, fundTokens, chainAB) // ensure we can add to new locks and superfluid locks on chainA - chainABNode.LockAndAddToExistingLock(chainAB, sdk.NewInt(1000000000000000000), fmt.Sprintf("gamm/pool/%d", poolId), lockupWalletAddr, lockupWalletSuperfluidAddr) + chainABNode.LockAndAddToExistingLock(chainAB, osmomath.NewInt(1000000000000000000), fmt.Sprintf("gamm/pool/%d", poolId), lockupWalletAddr, lockupWalletSuperfluidAddr) } // TestArithmeticTWAP tests TWAP by creating a pool, performing a swap. @@ -1481,9 +1481,9 @@ func (s *IntegrationTestSuite) ArithmeticTWAP() { s.Require().NoError(err) // Since there were no swaps between the two queries, the TWAPs should be the same. - osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneAB, twapFromBeforeSwapToBeforeSwapTwoAB, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneBC, twapFromBeforeSwapToBeforeSwapTwoBC, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneCA, twapFromBeforeSwapToBeforeSwapTwoCA, sdk.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneAB, twapFromBeforeSwapToBeforeSwapTwoAB, osmomath.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneBC, twapFromBeforeSwapToBeforeSwapTwoBC, osmomath.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapFromBeforeSwapToBeforeSwapOneCA, twapFromBeforeSwapToBeforeSwapTwoCA, osmomath.NewDecWithPrec(1, 3)) s.T().Log("performing swaps") chainABNode.SwapExactAmountIn(coinAIn, minAmountOut, fmt.Sprintf("%d", poolId), denomB, swapWalletAddr) @@ -1549,9 +1549,9 @@ func (s *IntegrationTestSuite) ArithmeticTWAP() { // These must be equal because they are calculated over time ranges with the stable and equal spot price. // There are potential rounding errors requiring us to approximate the comparison. - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsAB, twapFromAfterToNowAB, sdk.NewDecWithPrec(2, 3)) - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsBC, twapFromAfterToNowBC, sdk.NewDecWithPrec(2, 3)) - osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsCA, twapFromAfterToNowCA, sdk.NewDecWithPrec(2, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsAB, twapFromAfterToNowAB, osmomath.NewDecWithPrec(2, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsBC, twapFromAfterToNowBC, osmomath.NewDecWithPrec(2, 3)) + osmoassert.DecApproxEq(s.T(), twapAfterSwapBeforePruning10MsCA, twapFromAfterToNowCA, osmomath.NewDecWithPrec(2, 3)) // Make sure that the pruning keep period has passed. s.T().Logf("waiting for pruning keep period of (%.f) seconds to pass", initialization.TWAPPruningKeepPeriod.Seconds()) @@ -1593,9 +1593,9 @@ func (s *IntegrationTestSuite) ArithmeticTWAP() { twapToNowPostPruningCA, err := chainABNode.QueryArithmeticTwap(poolId, denomC, denomA, timeAfterSwap, timeAfterPruning) s.Require().NoError(err) // There are potential rounding errors requiring us to approximate the comparison. - osmoassert.DecApproxEq(s.T(), twapToNowPostPruningAB, twapAfterSwapBeforePruning10MsAB, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapToNowPostPruningBC, twapAfterSwapBeforePruning10MsBC, sdk.NewDecWithPrec(1, 3)) - osmoassert.DecApproxEq(s.T(), twapToNowPostPruningCA, twapAfterSwapBeforePruning10MsCA, sdk.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapToNowPostPruningAB, twapAfterSwapBeforePruning10MsAB, osmomath.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapToNowPostPruningBC, twapAfterSwapBeforePruning10MsBC, osmomath.NewDecWithPrec(1, 3)) + osmoassert.DecApproxEq(s.T(), twapToNowPostPruningCA, twapAfterSwapBeforePruning10MsCA, osmomath.NewDecWithPrec(1, 3)) } func (s *IntegrationTestSuite) StateSync() { @@ -1699,7 +1699,7 @@ func (s *IntegrationTestSuite) ExpeditedProposals() { chainAB, chainABNode, err := s.getChainCfgs() s.Require().NoError(err) - propNumber := chainABNode.SubmitTextProposal("expedited text proposal", sdk.NewCoin(appparams.BaseCoinUnit, sdk.NewInt(config.InitialMinExpeditedDeposit)), true) + propNumber := chainABNode.SubmitTextProposal("expedited text proposal", sdk.NewCoin(appparams.BaseCoinUnit, osmomath.NewInt(config.InitialMinExpeditedDeposit)), true) chainABNode.DepositProposal(propNumber, true) totalTimeChan := make(chan time.Duration, 1) @@ -1789,14 +1789,14 @@ func (s *IntegrationTestSuite) GeometricTWAP() { initialTwapBOverA, err := chainANode.QueryGeometricTwapToNow(poolId, denomA, denomB, timeBeforeSwapPlus5ms) s.Require().NoError(err) - s.Require().Equal(sdk.NewDec(2), initialTwapBOverA) + s.Require().Equal(osmomath.NewDec(2), initialTwapBOverA) // Assume base = stake, quote = uosmo // At pool creation time, the twap should be: // quote assset supply / base asset supply = 1_000_000 / 2_000_000 = 0.5 initialTwapAOverB, err := chainANode.QueryGeometricTwapToNow(poolId, denomB, denomA, timeBeforeSwapPlus5ms) s.Require().NoError(err) - s.Require().Equal(sdk.NewDecWithPrec(5, 1), initialTwapAOverB) + s.Require().Equal(osmomath.NewDecWithPrec(5, 1), initialTwapAOverB) coinAIn := fmt.Sprintf("1000000%s", denomA) chainANode.BankSend(coinAIn, sender, swapWalletAddr) @@ -1833,7 +1833,7 @@ func (s *IntegrationTestSuite) GeometricTWAP() { // uatom = 1_000_000 // uosmo = 2_000_000 // 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)) + osmoassert.DecApproxEq(s.T(), osmomath.NewDecWithPrec(5, 1), afterSwapTwapBOverA, osmomath.NewDecWithPrec(1, 2)) } // Only set taker fee on chain B as some tests depend on the exact swap values. diff --git a/tests/e2e/helpers_e2e_test.go b/tests/e2e/helpers_e2e_test.go index 51442f8c673..4309d0d4b38 100644 --- a/tests/e2e/helpers_e2e_test.go +++ b/tests/e2e/helpers_e2e_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/e2e/configurer/chain" "github.com/osmosis-labs/osmosis/v19/tests/e2e/initialization" "github.com/osmosis-labs/osmosis/v19/tests/e2e/util" @@ -16,13 +17,13 @@ import ( gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) -var defaultFeePerTx = sdk.NewInt(1000) +var defaultFeePerTx = osmomath.NewInt(1000) // calculateSpreadRewardGrowthGlobal calculates spread reward growth global per unit of virtual liquidity based on swap parameters: // amountIn - amount being swapped // spreadFactor - pool's spread factor // poolLiquidity - current pool liquidity -func calculateSpreadRewardGrowthGlobal(spreadRewardChargeTotal, poolLiquidity sdk.Dec) sdk.Dec { +func calculateSpreadRewardGrowthGlobal(spreadRewardChargeTotal, poolLiquidity osmomath.Dec) osmomath.Dec { // 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) @@ -35,7 +36,7 @@ func calculateSpreadRewardGrowthGlobal(spreadRewardChargeTotal, poolLiquidity sd // spreadRewardGrowthBelow - spread reward growth below lower tick // spreadRewardGrowthAbove - spread reward growth above upper tick // Formula: spreadRewardGrowthGlobal - spreadRewardGrowthBelowLowerTick - spreadRewardGrowthAboveUpperTick -func calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal, spreadRewardGrowthBelow, spreadRewardGrowthAbove sdk.Dec) sdk.Dec { +func calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal, spreadRewardGrowthBelow, spreadRewardGrowthAbove osmomath.Dec) osmomath.Dec { return spreadRewardGrowthGlobal.Sub(spreadRewardGrowthBelow).Sub(spreadRewardGrowthAbove) } @@ -103,7 +104,7 @@ func (s *IntegrationTestSuite) getChainCfgs() (*chain.Config, *chain.NodeConfig, // spreadRewardGrowthAbove - spread reward growth above upper tick // spreadRewardGrowthInsideLast - amount of spread reward growth inside range at the time from which we want to calculate the amount of uncollected spread rewards // spreadRewardGrowthGlobal - variable for tracking global spread reward growth -func calculateUncollectedSpreadRewards(positionLiquidity, spreadRewardGrowthBelow, spreadRewardGrowthAbove, spreadRewardGrowthInsideLast sdk.Dec, spreadRewardGrowthGlobal sdk.Dec) sdk.Dec { +func calculateUncollectedSpreadRewards(positionLiquidity, spreadRewardGrowthBelow, spreadRewardGrowthAbove, spreadRewardGrowthInsideLast osmomath.Dec, spreadRewardGrowthGlobal osmomath.Dec) osmomath.Dec { // Calculating spread reward growth inside range [-1200; 400] spreadRewardGrowthInside := calculateSpreadRewardGrowthInside(spreadRewardGrowthGlobal, spreadRewardGrowthBelow, spreadRewardGrowthAbove) diff --git a/tests/e2e/initialization/config.go b/tests/e2e/initialization/config.go index 2efeb8fca42..6904b0480b3 100644 --- a/tests/e2e/initialization/config.go +++ b/tests/e2e/initialization/config.go @@ -18,6 +18,7 @@ import ( "github.com/gogo/protobuf/proto" tmjson "github.com/tendermint/tendermint/libs/json" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -89,9 +90,9 @@ const ( ) var ( - StakeAmountIntA = sdk.NewInt(StakeAmountA) + StakeAmountIntA = osmomath.NewInt(StakeAmountA) StakeAmountCoinA = sdk.NewCoin(OsmoDenom, StakeAmountIntA) - StakeAmountIntB = sdk.NewInt(StakeAmountB) + StakeAmountIntB = osmomath.NewInt(StakeAmountB) StakeAmountCoinB = sdk.NewCoin(OsmoDenom, StakeAmountIntB) DaiOsmoPoolBalances = fmt.Sprintf("%s%s", DaiBalanceA, DaiDenom) @@ -102,7 +103,7 @@ var ( StakeToken = sdk.NewInt64Coin(StakeDenom, IbcSendAmount) // 3,300ustake tenOsmo = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 10_000_000)} fiftyOsmo = sdk.Coins{sdk.NewInt64Coin(OsmoDenom, 50_000_000)} - WalletFeeTokens = sdk.NewCoin(E2EFeeToken, sdk.NewInt(WalletFeeBalance)) + WalletFeeTokens = sdk.NewCoin(E2EFeeToken, osmomath.NewInt(WalletFeeBalance)) ) func addAccount(path, moniker, amountStr string, accAddr sdk.AccAddress, forkHeight int) error { @@ -116,7 +117,7 @@ func addAccount(path, moniker, amountStr string, accAddr sdk.AccAddress, forkHei if err != nil { return fmt.Errorf("failed to parse coins: %w", err) } - coins = coins.Add(sdk.NewCoin(E2EFeeToken, sdk.NewInt(GenesisFeeBalance))) + coins = coins.Add(sdk.NewCoin(E2EFeeToken, osmomath.NewInt(GenesisFeeBalance))) balances := banktypes.Balance{Address: accAddr.String(), Coins: coins.Sort()} genAccount := authtypes.NewBaseAccount(accAddr, nil, 0, 0) @@ -363,7 +364,7 @@ func updateStakeGenesis(stakeGenState *staketypes.GenesisState) { MaxEntries: 7, HistoricalEntries: 10000, UnbondingTime: 240000000000, - MinCommissionRate: sdk.ZeroDec(), + MinCommissionRate: osmomath.ZeroDec(), } } @@ -487,9 +488,9 @@ func updateTWAPGenesis(appGenState map[string]json.RawMessage) func(twapGenState Time: time.Date(2023, 0o2, 1, 0, 0, 0, 0, time.UTC), // some time in the past. P0LastSpotPrice: sp0, P1LastSpotPrice: sp1, - P0ArithmeticTwapAccumulator: sdk.ZeroDec(), - P1ArithmeticTwapAccumulator: sdk.ZeroDec(), - GeometricTwapAccumulator: sdk.ZeroDec(), + P0ArithmeticTwapAccumulator: osmomath.ZeroDec(), + P1ArithmeticTwapAccumulator: osmomath.ZeroDec(), + GeometricTwapAccumulator: osmomath.ZeroDec(), LastErrorTime: time.Time{}, // no previous error } twapGenState.Twaps = append(twapGenState.Twaps, twapRecord) @@ -567,15 +568,15 @@ func setDenomMetadata(genState *banktypes.GenesisState, denom string) { // sets up a pool with 1% fee, equal weights, and given denoms with supply of 100000000000, // and a given pool id. func setupPool(poolId uint64, denomA, denomB string) *types1.Any { - feePoolParams := balancer.NewPoolParams(sdk.MustNewDecFromStr("0.01"), sdk.ZeroDec(), nil) + feePoolParams := balancer.NewPoolParams(osmomath.MustNewDecFromStr("0.01"), osmomath.ZeroDec(), nil) feePoolAssets := []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denomA, sdk.NewInt(100000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denomA, osmomath.NewInt(100000000000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denomB, sdk.NewInt(100000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denomB, osmomath.NewInt(100000000000)), }, } pool1, err := balancer.NewBalancerPool(poolId, feePoolParams, feePoolAssets, "", time.Unix(0, 0)) diff --git a/tests/e2e/initialization/node.go b/tests/e2e/initialization/node.go index bcbed1c5995..cb01d850efa 100644 --- a/tests/e2e/initialization/node.go +++ b/tests/e2e/initialization/node.go @@ -30,6 +30,7 @@ import ( "github.com/tendermint/tendermint/privval" tmtypes "github.com/tendermint/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" osmosisApp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/tests/e2e/util" ) @@ -77,13 +78,13 @@ func (n *internalNode) configDir() string { func (n *internalNode) buildCreateValidatorMsg(amount sdk.Coin) (sdk.Msg, error) { description := stakingtypes.NewDescription(n.moniker, "", "", "", "") commissionRates := stakingtypes.CommissionRates{ - Rate: sdk.MustNewDecFromStr("0.1"), - MaxRate: sdk.MustNewDecFromStr("0.2"), - MaxChangeRate: sdk.MustNewDecFromStr("0.01"), + Rate: osmomath.MustNewDecFromStr("0.1"), + MaxRate: osmomath.MustNewDecFromStr("0.2"), + MaxChangeRate: osmomath.MustNewDecFromStr("0.01"), } // get the initial validator min self delegation - minSelfDelegation, _ := sdk.NewIntFromString("1") + minSelfDelegation, _ := osmomath.NewIntFromString("1") valPubKey, err := cryptocodec.FromTmPubKeyInterface(n.consensusKey.PubKey) if err != nil { diff --git a/tests/ibc-hooks/async_acks_test.go b/tests/ibc-hooks/async_acks_test.go index b7d5ad56ebd..fa9e9d83f47 100644 --- a/tests/ibc-hooks/async_acks_test.go +++ b/tests/ibc-hooks/async_acks_test.go @@ -11,6 +11,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v4/testing" "github.com/tidwall/gjson" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/x/ibc-hooks/types" @@ -37,7 +38,7 @@ func (suite *HooksTestSuite) TestWasmHooksAsyncAcks() { // Calls that don't specify async acks work as expected memo := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"async": {"use_async": false}}}}`, contractAddr) suite.fundAccount(suite.chainB, sender) - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), sender.String(), contractAddr.String(), "channel-0", memo) + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), sender.String(), contractAddr.String(), "channel-0", memo) sendResult, receiveResult, ack, err := suite.FullSend(transferMsg, BtoA) suite.Require().NoError(err) suite.Require().NotNil(sendResult) @@ -73,7 +74,7 @@ func (suite *HooksTestSuite) TestWasmHooksAsyncAcks() { // Calls that specify async Acks work and no Acks are sent memo = fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"async": {"use_async": true}}}}`, contractAddr) suite.fundAccount(suite.chainB, sender) - transferMsg = NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), sender.String(), contractAddr.String(), "channel-0", memo) + transferMsg = NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), sender.String(), contractAddr.String(), "channel-0", memo) sendResult, err = suite.chainB.SendMsgsNoCheck(transferMsg) suite.Require().NoError(err) diff --git a/tests/ibc-hooks/ibc_middleware_test.go b/tests/ibc-hooks/ibc_middleware_test.go index e99c4bb498a..b35a50cff1c 100644 --- a/tests/ibc-hooks/ibc_middleware_test.go +++ b/tests/ibc-hooks/ibc_middleware_test.go @@ -15,6 +15,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -69,7 +70,7 @@ func TestIBCHooksTestSuite(t *testing.T) { func (suite *HooksTestSuite) SetupTest() { suite.SkipIfWSL() // TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123 - txfeetypes.ConsensusMinFee = sdk.ZeroDec() + txfeetypes.ConsensusMinFee = osmomath.ZeroDec() suite.Setup() ibctesting.DefaultTestingAppInit = osmosisibctesting.SetupTestingApp @@ -250,7 +251,7 @@ func (suite *HooksTestSuite) TestDeriveIntermediateSender() { func (suite *HooksTestSuite) TestOnRecvPacketHooks() { var ( trace transfertypes.DenomTrace - amount sdk.Int + amount osmomath.Int receiver string status testutils.Status ) @@ -280,7 +281,7 @@ func (suite *HooksTestSuite) TestOnRecvPacketHooks() { receiver = suite.chainB.SenderAccount.GetAddress().String() // must be explicitly changed in malleate status = testutils.Status{} - amount = sdk.NewInt(100) // must be explicitly changed in malleate + amount = osmomath.NewInt(100) // must be explicitly changed in malleate seq := uint64(1) trace = transfertypes.ParseDenomTrace(sdk.DefaultBondDenom) @@ -401,7 +402,7 @@ func (suite *HooksTestSuite) TestFundsAreTransferredToTheContract() { // Check that the contract has no funds localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) - suite.Require().Equal(sdk.NewInt(0), balance.Amount) + suite.Require().Equal(osmomath.NewInt(0), balance.Amount) // Execute the contract via IBC ackBytes := suite.receivePacket(addr.String(), fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"echo": {"msg": "test"} } } }`, addr)) @@ -415,7 +416,7 @@ func (suite *HooksTestSuite) TestFundsAreTransferredToTheContract() { // Check that the token has now been transferred to the contract balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) - suite.Require().Equal(sdk.NewInt(1), balance.Amount) + suite.Require().Equal(osmomath.NewInt(1), balance.Amount) } // If the wasm call wails, the contract acknowledgement should be an error and the funds returned @@ -427,7 +428,7 @@ func (suite *HooksTestSuite) TestFundsAreReturnedOnFailedContractExec() { // Check that the contract has no funds localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) - suite.Require().Equal(sdk.NewInt(0), balance.Amount) + suite.Require().Equal(osmomath.NewInt(0), balance.Amount) // Execute the contract via IBC with a message that the contract will reject ackBytes := suite.receivePacket(addr.String(), fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": {"not_echo": {"msg": "test"} } } }`, addr)) @@ -441,7 +442,7 @@ func (suite *HooksTestSuite) TestFundsAreReturnedOnFailedContractExec() { // Check that the token has now been transferred to the contract balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) fmt.Println(balance) - suite.Require().Equal(sdk.NewInt(0), balance.Amount) + suite.Require().Equal(osmomath.NewInt(0), balance.Amount) } func (suite *HooksTestSuite) TestPacketsThatShouldBeSkipped() { @@ -495,7 +496,7 @@ func (suite *HooksTestSuite) TestFundTracking() { // Check that the contract has no funds localDenom := osmoutils.MustExtractDenomFromPacketOnRecv(suite.makeMockPacket("", "", 0)) balance := suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) - suite.Require().Equal(sdk.NewInt(0), balance.Amount) + suite.Require().Equal(osmomath.NewInt(0), balance.Amount) // Execute the contract via IBC suite.receivePacket( @@ -531,7 +532,7 @@ func (suite *HooksTestSuite) TestFundTracking() { // Check that the token has now been transferred to the contract balance = suite.chainA.GetOsmosisApp().BankKeeper.GetBalance(suite.chainA.GetContext(), addr, localDenom) - suite.Require().Equal(sdk.NewInt(2), balance.Amount) + suite.Require().Equal(osmomath.NewInt(2), balance.Amount) } // custom MsgTransfer constructor that supports Memo @@ -639,7 +640,7 @@ func (suite *HooksTestSuite) TestAcks() { // Generate swap instructions for the contract callbackMemo := fmt.Sprintf(`{"ibc_callback":"%s"}`, addr) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), addr.String(), "channel-0", callbackMemo) + transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), addr.String(), "channel-0", callbackMemo) _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -664,7 +665,7 @@ func (suite *HooksTestSuite) TestTimeouts() { // Generate swap instructions for the contract callbackMemo := fmt.Sprintf(`{"ibc_callback":"%s"}`, addr) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), addr.String(), "channel-0", callbackMemo) + transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), addr.String(), "channel-0", callbackMemo) transferMsg.TimeoutTimestamp = uint64(suite.coordinator.CurrentTime.Add(time.Minute).UnixNano()) sendResult, err := suite.chainA.SendMsgsNoCheck(transferMsg) suite.Require().NoError(err) @@ -691,14 +692,14 @@ func (suite *HooksTestSuite) TestTimeouts() { func (suite *HooksTestSuite) TestSendWithoutMemo() { // Sending a packet without memo to ensure that the ibc_callback middleware doesn't interfere with a regular send - transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1000)), suite.chainA.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") _, _, ack, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) suite.Require().Contains(ack, "result") } // This is a copy of the SetupGammPoolsWithBondDenomMultiplier from the test helpers, but using chainA instead of the default -func (suite *HooksTestSuite) SetupPools(chainName Chain, multipliers []sdk.Dec) []gammtypes.CFMMPoolI { +func (suite *HooksTestSuite) SetupPools(chainName Chain, multipliers []osmomath.Dec) []gammtypes.CFMMPoolI { chain := suite.GetChain(chainName) acc1 := chain.SenderAccount.GetAddress() bondDenom := chain.GetOsmosisApp().StakingKeeper.BondDenom(chain.GetContext()) @@ -706,27 +707,27 @@ func (suite *HooksTestSuite) SetupPools(chainName Chain, multipliers []sdk.Dec) pools := []gammtypes.CFMMPoolI{} for index, multiplier := range multipliers { token := fmt.Sprintf("token%d", index) - uosmoAmount := gammtypes.InitPoolSharesSupply.ToDec().Mul(multiplier).RoundInt() + uosmoAmount := gammtypes.InitPoolSharesSupply.ToLegacyDec().Mul(multiplier).RoundInt() var ( defaultFutureGovernor = "" // pool assets defaultFooAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), Token: sdk.NewCoin(bondDenom, uosmoAmount), } defaultBarAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(token, sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(token, osmomath.NewInt(10000)), } poolAssets = []balancer.PoolAsset{defaultFooAsset, defaultBarAsset} ) poolParams := balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } msg := balancer.NewMsgCreateBalancerPool(acc1, poolParams, poolAssets, defaultFutureGovernor) @@ -755,7 +756,7 @@ func (suite *HooksTestSuite) SetupCrosschainSwaps(chainName Chain, setupForwardi // Fund the account with some uosmo and some stake bankKeeper := chain.GetOsmosisApp().BankKeeper - i, ok := sdk.NewIntFromString("20000000000000000000000") + i, ok := osmomath.NewIntFromString("20000000000000000000000") suite.Require().True(ok) amounts := sdk.NewCoins(sdk.NewCoin("uosmo", i), sdk.NewCoin(sdk.DefaultBondDenom, i), sdk.NewCoin("token0", i), sdk.NewCoin("token1", i)) err := bankKeeper.MintCoins(chain.GetContext(), minttypes.ModuleName, amounts) @@ -763,7 +764,7 @@ func (suite *HooksTestSuite) SetupCrosschainSwaps(chainName Chain, setupForwardi err = bankKeeper.SendCoinsFromModuleToAccount(chain.GetContext(), minttypes.ModuleName, owner, amounts) suite.Require().NoError(err) - suite.SetupPools(chainName, []sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + suite.SetupPools(chainName, []osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // Setup contract chain.StoreContractCode(&suite.Suite, "./bytecode/swaprouter.wasm") @@ -799,7 +800,7 @@ func (suite *HooksTestSuite) SetupCrosschainSwaps(chainName Chain, setupForwardi func (suite *HooksTestSuite) fundAccount(chain *osmosisibctesting.TestChain, owner sdk.AccAddress) { // TODO: allow this function to fund with custom token names (calling them tokenA, tokenB, etc. would make tests easier to read, I think) bankKeeper := chain.GetOsmosisApp().BankKeeper - i, ok := sdk.NewIntFromString("20000000000000000000000") + i, ok := osmomath.NewIntFromString("20000000000000000000000") suite.Require().True(ok) amounts := sdk.NewCoins(sdk.NewCoin("uosmo", i), sdk.NewCoin(sdk.DefaultBondDenom, i), sdk.NewCoin("token0", i), sdk.NewCoin("token1", i)) err := bankKeeper.MintCoins(chain.GetContext(), minttypes.ModuleName, amounts) @@ -818,7 +819,7 @@ func (suite *HooksTestSuite) SetupCrosschainRegistry(chainName Chain) (sdk.AccAd } // Setup pools - suite.SetupPools(chainName, []sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + suite.SetupPools(chainName, []osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // Setup contract chain.StoreContractCode(&suite.Suite, "./bytecode/crosschain_registry.wasm") @@ -827,19 +828,19 @@ func (suite *HooksTestSuite) SetupCrosschainRegistry(chainName Chain) (sdk.AccAd suite.Require().NoError(err) // Send some token0 tokens from C to B - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainC.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), "channel-0", "") _, _, _, err = suite.FullSend(transferMsg, CtoB) suite.Require().NoError(err) // Send some token0 tokens from B to A - transferMsg = NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") + transferMsg = NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") _, _, _, err = suite.FullSend(transferMsg, BtoA) suite.Require().NoError(err) // Send some token0 tokens from C to B to A denomTrace0CB := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", suite.pathBC.EndpointA.ChannelID, "token0")) token0CB := denomTrace0CB.IBCDenom() - transferMsg = NewMsgTransfer(sdk.NewCoin(token0CB, sdk.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") + transferMsg = NewMsgTransfer(sdk.NewCoin(token0CB, osmomath.NewInt(2000)), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccount.GetAddress().String(), "channel-0", "") _, _, _, err = suite.FullSend(transferMsg, BtoA) suite.Require().NoError(err) @@ -1045,10 +1046,10 @@ func (suite *HooksTestSuite) TestUnwrapToken() { receiverChain := suite.GetChain(tc.intoChain) receiverApp := receiverChain.GetOsmosisApp() initialSenderBalance := osmosisApp.BankKeeper.GetBalance(suite.chainA.GetContext(), owner, tc.sentToken) - sentAmount := sdk.NewInt(100) + sentAmount := osmomath.NewInt(100) suite.Require().Greater(initialSenderBalance.Amount.Int64(), sentAmount.Int64()) initialReceiverBalance := receiverApp.BankKeeper.GetBalance(receiverChain.GetContext(), receiver, tc.receivedToken) - suite.Require().Equal(sdk.NewInt(0), initialReceiverBalance.Amount) + suite.Require().Equal(osmomath.NewInt(0), initialReceiverBalance.Amount) msg := fmt.Sprintf(`{ "unwrap_coin": { @@ -1093,7 +1094,7 @@ func (suite *HooksTestSuite) TestCrosschainSwaps() { msg := fmt.Sprintf(`{"osmosis_swap":{"output_denom":"token1","slippage":{"twap": {"window_seconds": 1, "slippage_percentage":"20"}},"receiver":"chainB/%s", "on_failed_delivery": "do_nothing"}}`, suite.chainB.SenderAccount.GetAddress(), ) - res, err := contractKeeper.Execute(ctx, crosschainAddr, owner, []byte(msg), sdk.NewCoins(sdk.NewCoin("token0", sdk.NewInt(1000)))) + res, err := contractKeeper.Execute(ctx, crosschainAddr, owner, []byte(msg), sdk.NewCoins(sdk.NewCoin("token0", osmomath.NewInt(1000)))) suite.Require().NoError(err) var responseJson map[string]interface{} err = json.Unmarshal(res, &responseJson) @@ -1126,7 +1127,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCTest() { initializer := suite.chainB.SenderAccount.GetAddress() _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA, true) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -1150,7 +1151,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCTest() { // Generate full memo msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) _, receiveResult, _, err := suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back @@ -1177,7 +1178,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadAck() { initializer := suite.chainB.SenderAccount.GetAddress() _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA, true) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -1200,7 +1201,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadAck() { // Generate full memo msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) _, receiveResult, _, err := suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back @@ -1230,7 +1231,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadAck() { ) // Generate full memo msg2 := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg2) - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg2) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg2) _, receiveResult, _, err = suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back @@ -1273,7 +1274,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadSwap() { initializer := suite.chainB.SenderAccount.GetAddress() _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA, true) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -1297,7 +1298,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCBadSwap() { // Generate full memo msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) _, receiveResult, ack, err := suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back @@ -1316,7 +1317,7 @@ func (suite *HooksTestSuite) TestBadCrosschainSwapsNextMemoMessages() { initializer := suite.chainB.SenderAccount.GetAddress() _, crosschainAddr := suite.SetupCrosschainSwaps(ChainA, true) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(20000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(20000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -1352,7 +1353,7 @@ func (suite *HooksTestSuite) TestBadCrosschainSwapsNextMemoMessages() { msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, tc.memo) // Send IBC transfer with the memo with crosschain-swap instructions fmt.Println(msg) - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(10)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(10)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) _, _, ack, _ := suite.FullSend(transferMsg, BtoA) if tc.expPass { fmt.Println(ack) @@ -1363,7 +1364,7 @@ func (suite *HooksTestSuite) TestBadCrosschainSwapsNextMemoMessages() { } } -func (suite *HooksTestSuite) CreateIBCPoolOnChain(chainName Chain, denom1, denom2 string, amount1 sdk.Int) uint64 { +func (suite *HooksTestSuite) CreateIBCPoolOnChain(chainName Chain, denom1, denom2 string, amount1 osmomath.Int) uint64 { chain := suite.GetChain(chainName) acc1 := chain.SenderAccount.GetAddress() @@ -1371,19 +1372,19 @@ func (suite *HooksTestSuite) CreateIBCPoolOnChain(chainName Chain, denom1, denom // pool assets defaultFooAsset := balancer.PoolAsset{ - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), Token: sdk.NewCoin(denom1, amount1), } defaultBarAsset := balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denom2, sdk.NewInt(defaultPoolAmount)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denom2, osmomath.NewInt(defaultPoolAmount)), } poolAssets := []balancer.PoolAsset{defaultFooAsset, defaultBarAsset} poolParams := balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } msg := balancer.NewMsgCreateBalancerPool(acc1, poolParams, poolAssets, defaultFutureGovernor) poolId, err := chain.GetOsmosisApp().PoolManagerKeeper.CreatePool(chain.GetContext(), msg) @@ -1398,9 +1399,9 @@ func (suite *HooksTestSuite) CreateIBCNativePoolOnChain(chainName Chain, denom s chain := suite.GetChain(chainName) bondDenom := chain.GetOsmosisApp().StakingKeeper.BondDenom(chain.GetContext()) - multiplier := sdk.NewDec(20) + multiplier := osmomath.NewDec(20) - uosmoAmount := gammtypes.InitPoolSharesSupply.ToDec().Mul(multiplier).RoundInt() + uosmoAmount := gammtypes.InitPoolSharesSupply.ToLegacyDec().Mul(multiplier).RoundInt() return suite.CreateIBCPoolOnChain(chainName, bondDenom, denom, uosmoAmount) } @@ -1466,10 +1467,10 @@ func (suite *HooksTestSuite) TestCrosschainForwardWithMemo() { _, crosschainAddrA := suite.SetupCrosschainSwaps(ChainA, true) swaprouterAddrB, crosschainAddrB := suite.SetupCrosschainSwaps(ChainB, false) // Send some token0 and token1 tokens to B so that there are ibc token0 to send to A and crosschain-swap, and token1 to create the pool - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) - transferMsg1 := NewMsgTransfer(sdk.NewCoin("token1", sdk.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg1 := NewMsgTransfer(sdk.NewCoin("token1", osmomath.NewInt(500000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err = suite.FullSend(transferMsg1, AtoB) suite.Require().NoError(err) denom := suite.GetIBCDenom(ChainA, ChainB, "token1") @@ -1506,7 +1507,7 @@ func (suite *HooksTestSuite) TestCrosschainForwardWithMemo() { // Generate full memo msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddrA, swapMsg) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddrA.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddrA.String(), "channel-0", msg) _, receiveResult, _, err := suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back @@ -1539,7 +1540,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { // Send A's token0 all the way to B (A->C->B) transferMsg := NewMsgTransfer( - sdk.NewCoin("token0", sdk.NewInt(2000)), + sdk.NewCoin("token0", osmomath.NewInt(2000)), accountA.String(), accountC.String(), suite.pathAC.EndpointA.ChannelID, @@ -1550,7 +1551,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { token0AC := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", suite.pathAC.EndpointB.ChannelID, "token0")).IBCDenom() transferMsg = NewMsgTransfer( - sdk.NewCoin(token0AC, sdk.NewInt(2000)), + sdk.NewCoin(token0AC, osmomath.NewInt(2000)), accountC.String(), accountB.String(), suite.pathBC.EndpointB.ChannelID, @@ -1580,7 +1581,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { // Generate full memo msg := fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg) // Send IBC transfer with the memo with crosschain-swap instructions - transferMsg = NewMsgTransfer(sdk.NewCoin(token0ACB, sdk.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) + transferMsg = NewMsgTransfer(sdk.NewCoin(token0ACB, osmomath.NewInt(1000)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), "channel-0", msg) _, res, _, err := suite.FullSend(transferMsg, BtoA) // We use the receive result here because the receive adds another packet to be sent back suite.Require().NoError(err) @@ -1615,7 +1616,7 @@ func (suite *HooksTestSuite) TestCrosschainSwapsViaIBCMultiHop() { } // simple transfer -func (suite *HooksTestSuite) SimpleNativeTransfer(token string, amount sdk.Int, path []Chain) string { +func (suite *HooksTestSuite) SimpleNativeTransfer(token string, amount osmomath.Int, path []Chain) string { prev := path[0] prevPrefix := "" denom := token @@ -1662,7 +1663,7 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { swapRouterAddr, crosschainAddr := suite.SetupCrosschainSwaps(ChainA, true) - sendAmount := sdk.NewInt(100) + sendAmount := osmomath.NewInt(100) actorChainB := ChainActorDefinition{ Chain: ChainB, @@ -1700,7 +1701,7 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { receiver: actorChainB, receivedToken: suite.GetIBCDenom(ChainA, ChainB, "token0"), setupInitialToken: func() string { - suite.SimpleNativeTransfer("token0", sdk.NewInt(defaultPoolAmount), []Chain{ChainC, ChainA}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(defaultPoolAmount), []Chain{ChainC, ChainA}) denom := suite.GetIBCDenom(ChainC, ChainA, "token0") poolId := suite.CreateIBCNativePoolOnChain(ChainA, denom) @@ -1720,9 +1721,9 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { receiver: actorChainB, receivedToken: transfertypes.DenomTrace{Path: suite.GetPath(ChainA, ChainB), BaseDenom: "token0"}.IBCDenom(), setupInitialToken: func() string { - suite.SimpleNativeTransfer("token1", sdk.NewInt(defaultPoolAmount), []Chain{ChainB, ChainA}) + suite.SimpleNativeTransfer("token1", osmomath.NewInt(defaultPoolAmount), []Chain{ChainB, ChainA}) - suite.SimpleNativeTransfer("token1", sdk.NewInt(10000), []Chain{ChainB, ChainA}) + suite.SimpleNativeTransfer("token1", osmomath.NewInt(10000), []Chain{ChainB, ChainA}) denom := suite.GetIBCDenom(ChainB, ChainA, "token1") poolId := suite.CreateIBCNativePoolOnChain(ChainA, denom) suite.SetupIBCRouteOnChain(swapRouterAddr, suite.chainA.SenderAccount.GetAddress(), poolId, ChainA, denom) @@ -1741,10 +1742,10 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { receivedToken: "token1", setupInitialToken: func() string { // Send ibc token to chainB - suite.SimpleNativeTransfer("token0", sdk.NewInt(500), []Chain{ChainA, ChainB}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(500), []Chain{ChainA, ChainB}) // Setup pool - suite.SimpleNativeTransfer("token1", sdk.NewInt(defaultPoolAmount), []Chain{ChainB, ChainA}) + suite.SimpleNativeTransfer("token1", osmomath.NewInt(defaultPoolAmount), []Chain{ChainB, ChainA}) denom := suite.GetIBCDenom(ChainB, ChainA, "token1") poolId := suite.CreateIBCNativePoolOnChain(ChainA, denom) suite.SetupIBCRouteOnChain(swapRouterAddr, suite.chainA.SenderAccount.GetAddress(), poolId, ChainA, denom) @@ -1762,14 +1763,14 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { receiver: actorChainB, receivedToken: suite.GetIBCDenom(ChainC, ChainB, "token0"), setupInitialToken: func() string { - suite.SimpleNativeTransfer("token0", sdk.NewInt(12000000), []Chain{ChainC, ChainA}) - suite.SimpleNativeTransfer("token0", sdk.NewInt(12000000), []Chain{ChainB, ChainA}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainC, ChainA}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainB, ChainA}) token0BA := suite.GetIBCDenom(ChainB, ChainA, "token0") token0CA := suite.GetIBCDenom(ChainC, ChainA, "token0") // Setup pool - poolId := suite.CreateIBCPoolOnChain(ChainA, token0BA, token0CA, sdk.NewInt(defaultPoolAmount)) + poolId := suite.CreateIBCPoolOnChain(ChainA, token0BA, token0CA, osmomath.NewInt(defaultPoolAmount)) suite.SetupIBCSimpleRouteOnChain(swapRouterAddr, suite.chainA.SenderAccount.GetAddress(), poolId, ChainA, token0BA, token0CA) return "token0" @@ -1789,16 +1790,16 @@ func (suite *HooksTestSuite) TestMultiHopXCS() { }, receivedToken: suite.GetIBCDenom(ChainB, ChainC, "token0"), setupInitialToken: func() string { - suite.SimpleNativeTransfer("token0", sdk.NewInt(12000000), []Chain{ChainC, ChainA}) - suite.SimpleNativeTransfer("token0", sdk.NewInt(12000000), []Chain{ChainB, ChainA}) - suite.SimpleNativeTransfer("token0", sdk.NewInt(12000000), []Chain{ChainC, ChainB}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainC, ChainA}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainB, ChainA}) + suite.SimpleNativeTransfer("token0", osmomath.NewInt(12000000), []Chain{ChainC, ChainB}) token0BA := suite.GetIBCDenom(ChainB, ChainA, "token0") token0CB := suite.GetIBCDenom(ChainC, ChainB, "token0") token0CA := suite.GetIBCDenom(ChainC, ChainA, "token0") // Setup pool - poolId := suite.CreateIBCPoolOnChain(ChainA, token0BA, token0CA, sdk.NewInt(defaultPoolAmount)) + poolId := suite.CreateIBCPoolOnChain(ChainA, token0BA, token0CA, osmomath.NewInt(defaultPoolAmount)) suite.SetupIBCSimpleRouteOnChain(swapRouterAddr, suite.chainA.SenderAccount.GetAddress(), poolId, ChainA, token0BA, token0CA) return token0CB @@ -1868,7 +1869,7 @@ func (suite *HooksTestSuite) ExecuteOutpostSwap(initializer, receiverAddr sdk.Ac fmt.Sprintf(`{"crosschain_swaps_contract": "%s", "osmosis_channel": "channel-0"}`, crosschainAddr), 1) // Send some token0 tokens to B so that there are ibc tokens to send to A and crosschain-swap - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), suite.chainA.SenderAccount.GetAddress().String(), initializer.String(), "channel-0", "") _, _, _, err := suite.FullSend(transferMsg, AtoB) suite.Require().NoError(err) @@ -1892,7 +1893,7 @@ func (suite *HooksTestSuite) ExecuteOutpostSwap(initializer, receiverAddr sdk.Ac // Call the outpost contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(osmosisAppB.WasmKeeper) ctxB := suite.chainB.GetContext() - _, err = contractKeeper.Execute(ctxB, outpostAddr, initializer, []byte(swapMsg), sdk.NewCoins(sdk.NewCoin(token0IBC, sdk.NewInt(1000)))) + _, err = contractKeeper.Execute(ctxB, outpostAddr, initializer, []byte(swapMsg), sdk.NewCoins(sdk.NewCoin(token0IBC, osmomath.NewInt(1000)))) suite.Require().NoError(err) suite.chainB.NextBlock() err = suite.pathAB.EndpointA.UpdateClient() diff --git a/tests/ibc-hooks/path_validation_test.go b/tests/ibc-hooks/path_validation_test.go index 5c96f8fa2b7..42988fd6141 100644 --- a/tests/ibc-hooks/path_validation_test.go +++ b/tests/ibc-hooks/path_validation_test.go @@ -2,9 +2,12 @@ package ibc_hooks_test import ( "fmt" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" sdk "github.com/cosmos/cosmos-sdk/types" ibctesting "github.com/cosmos/ibc-go/v4/testing" + + "github.com/osmosis-labs/osmosis/osmomath" ) // This sets up PFM on chainB and tests that it works as expected. We assume ChainA is osmosis @@ -22,14 +25,14 @@ func (suite *HooksTestSuite) SetupAndTestPFM(chainBId Chain, chainBName string, forwarding := suite.chainA.QueryContractJson(&suite.Suite, registryAddr, []byte(pfm_msg)) suite.Require().False(forwarding.Bool()) - transferMsg := NewMsgTransfer(sdk.NewCoin("token0", sdk.NewInt(2000)), targetChain.SenderAccount.GetAddress().String(), sendFrom.String(), suite.GetSenderChannel(chainBId, ChainA), "") + transferMsg := NewMsgTransfer(sdk.NewCoin("token0", osmomath.NewInt(2000)), targetChain.SenderAccount.GetAddress().String(), sendFrom.String(), suite.GetSenderChannel(chainBId, ChainA), "") suite.FullSend(transferMsg, reverseDirection) tokenBA := suite.GetIBCDenom(chainBId, ChainA, "token0") ctx := suite.chainA.GetContext() msg := fmt.Sprintf(`{"propose_pfm":{"chain": "%s"}}`, chainBName) - _, err := contractKeeper.Execute(ctx, registryAddr, sendFrom, []byte(msg), sdk.NewCoins(sdk.NewCoin(tokenBA, sdk.NewInt(1)))) + _, err := contractKeeper.Execute(ctx, registryAddr, sendFrom, []byte(msg), sdk.NewCoins(sdk.NewCoin(tokenBA, osmomath.NewInt(1)))) suite.Require().NoError(err) forwarding = suite.chainA.QueryContractJson(&suite.Suite, registryAddr, []byte(pfm_msg)) diff --git a/tests/ibc-hooks/xcs_cw20_test.go b/tests/ibc-hooks/xcs_cw20_test.go index 6f393faf01d..7ecba993adf 100644 --- a/tests/ibc-hooks/xcs_cw20_test.go +++ b/tests/ibc-hooks/xcs_cw20_test.go @@ -9,6 +9,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types" ibctesting "github.com/cosmos/ibc-go/v4/testing" + + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/osmosisibctesting" ) @@ -72,7 +74,7 @@ func (suite *HooksTestSuite) TransferCW20Tokens(path *ibctesting.Path, cw20Addr, return result, ack } -func (suite *HooksTestSuite) setupCW20PoolAndRoutes(chain *osmosisibctesting.TestChain, swaprouterAddr sdk.AccAddress, cw20IbcDenom string, amount sdk.Int) { +func (suite *HooksTestSuite) setupCW20PoolAndRoutes(chain *osmosisibctesting.TestChain, swaprouterAddr sdk.AccAddress, cw20IbcDenom string, amount osmomath.Int) { osmosisAppA := chain.GetOsmosisApp() poolId := suite.CreateIBCPoolOnChain(ChainA, cw20IbcDenom, sdk.DefaultBondDenom, amount) @@ -88,10 +90,10 @@ func (suite *HooksTestSuite) setupCW20PoolAndRoutes(chain *osmosisibctesting.Tes suite.Require().NoError(err) } -func (suite *HooksTestSuite) getCW20Balance(chain *osmosisibctesting.TestChain, cw20Addr, addr sdk.AccAddress) sdk.Int { +func (suite *HooksTestSuite) getCW20Balance(chain *osmosisibctesting.TestChain, cw20Addr, addr sdk.AccAddress) osmomath.Int { queryMsg := fmt.Sprintf(`{"balance":{"address":"%s"}}`, addr) res := chain.QueryContractJson(&suite.Suite, cw20Addr, []byte(queryMsg)) - balance, ok := sdk.NewIntFromString(res.Get("balance").String()) + balance, ok := osmomath.NewIntFromString(res.Get("balance").String()) if !ok { panic("could not parse balance") } @@ -122,7 +124,7 @@ func (suite *HooksTestSuite) TestCW20ICS20() { osmosisAppB := chainB.GetOsmosisApp() // Send some cwtoken tokens from B to A via the new path - amount := sdk.NewInt(defaultPoolAmount) + amount := osmomath.NewInt(defaultPoolAmount) suite.TransferCW20Tokens(path, cw20Addr, cw20ics20Addr, chainA.SenderAccount.GetAddress(), amount.String(), "") // Create a pool for that token @@ -162,7 +164,7 @@ func (suite *HooksTestSuite) TestCW20ICS20() { ) xcsMsg = fmt.Sprintf(`{"wasm": {"contract": "%s", "msg": %s } }`, crosschainAddr, swapMsg) - transferMsg := NewMsgTransfer(sdk.NewCoin(stakeAB, sdk.NewInt(10)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), suite.pathAB.EndpointB.ChannelID, xcsMsg) + transferMsg := NewMsgTransfer(sdk.NewCoin(stakeAB, osmomath.NewInt(10)), suite.chainB.SenderAccount.GetAddress().String(), crosschainAddr.String(), suite.pathAB.EndpointB.ChannelID, xcsMsg) _, recvResult, _, _ := suite.FullSend(transferMsg, BtoA) packet, err = ibctesting.ParsePacketFromEvents(recvResult.GetEvents()) diff --git a/tests/simulator/sim_test.go b/tests/simulator/sim_test.go index c4bf5d88dd5..377a6728117 100644 --- a/tests/simulator/sim_test.go +++ b/tests/simulator/sim_test.go @@ -11,8 +11,8 @@ import ( dbm "github.com/tendermint/tm-db" "github.com/cosmos/cosmos-sdk/simapp/helpers" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" osmosim "github.com/osmosis-labs/osmosis/v19/simulation/executor" "github.com/osmosis-labs/osmosis/v19/simulation/simtypes/simlogger" txfeetypes "github.com/osmosis-labs/osmosis/v19/x/txfees/types" @@ -49,7 +49,7 @@ func TestFullAppSimulation(t *testing.T) { func fullAppSimulation(tb testing.TB, is_testing bool) { tb.Helper() // TODO: Get SDK simulator fixed to have min fees possible - txfeetypes.ConsensusMinFee = sdk.ZeroDec() + txfeetypes.ConsensusMinFee = osmomath.ZeroDec() config, db, logger, cleanup, err := osmosim.SetupSimulation("goleveldb-app-sim", "Simulation") if err != nil { tb.Fatalf("simulation setup failed: %s", err.Error()) @@ -85,7 +85,7 @@ func TestAppStateDeterminism(t *testing.T) { // t.Skip("skipping application simulation") // } // TODO: Get SDK simulator fixed to have min fees possible - txfeetypes.ConsensusMinFee = sdk.ZeroDec() + txfeetypes.ConsensusMinFee = osmomath.ZeroDec() config := osmosim.NewConfigFromFlags() config.ExportConfig.ExportParamsPath = "" diff --git a/tests/simulator/state.go b/tests/simulator/state.go index ca757dfdce1..1d1cbd90aef 100644 --- a/tests/simulator/state.go +++ b/tests/simulator/state.go @@ -7,6 +7,7 @@ import ( "os" "time" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app" osmosim "github.com/osmosis-labs/osmosis/v19/simulation/executor" osmosimtypes "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" @@ -78,7 +79,7 @@ func updateStakingAndBankState(appState json.RawMessage, cdc codec.JSONCodec) js panic(err) } // compute not bonded balance - notBondedTokens := sdk.ZeroInt() + notBondedTokens := osmomath.ZeroInt() for _, val := range stakingState.Validators { if val.Status != stakingtypes.Unbonded { continue diff --git a/wasmbinding/bindings/msg.go b/wasmbinding/bindings/msg.go index d91feb6bd3b..906a16e7f04 100644 --- a/wasmbinding/bindings/msg.go +++ b/wasmbinding/bindings/msg.go @@ -1,6 +1,6 @@ package bindings -import sdk "github.com/cosmos/cosmos-sdk/types" +import "github.com/osmosis-labs/osmosis/osmomath" type OsmosisMsg struct { /// Contracts can create denoms, namespaced under the contract's address. @@ -35,14 +35,14 @@ type ChangeAdmin struct { } type MintTokens struct { - Denom string `json:"denom"` - Amount sdk.Int `json:"amount"` - MintToAddress string `json:"mint_to_address"` + Denom string `json:"denom"` + Amount osmomath.Int `json:"amount"` + MintToAddress string `json:"mint_to_address"` } type BurnTokens struct { - Denom string `json:"denom"` - Amount sdk.Int `json:"amount"` + Denom string `json:"denom"` + Amount osmomath.Int `json:"amount"` // BurnFromAddress must be set to "" for now. BurnFromAddress string `json:"burn_from_address"` } diff --git a/wasmbinding/query_plugin_test.go b/wasmbinding/query_plugin_test.go index ad8acd60866..f1818d8b487 100644 --- a/wasmbinding/query_plugin_test.go +++ b/wasmbinding/query_plugin_test.go @@ -19,6 +19,7 @@ import ( "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammv2types "github.com/osmosis-labs/osmosis/v19/x/gamm/v2types" @@ -78,7 +79,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, sender, apptesting.DefaultAcctFunds) suite.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(sender, - balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), + balancer.NewPoolParams(osmomath.ZeroDec(), osmomath.ZeroDec(), nil), apptesting.DefaultPoolAssets, "") _, err = suite.app.PoolManagerKeeper.CreatePool(suite.ctx, msg) suite.NoError(err) @@ -95,7 +96,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { }, checkResponseStruct: true, responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ //nolint:staticcheck // we're intentionally using this deprecated package for testing - SpotPrice: sdk.NewDecWithPrec(5, 1).String(), + SpotPrice: osmomath.NewDecWithPrec(5, 1).String(), }, }, { @@ -107,7 +108,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { err := simapp.FundAccount(suite.app.BankKeeper, suite.ctx, sender, apptesting.DefaultAcctFunds) suite.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(sender, - balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), + balancer.NewPoolParams(osmomath.ZeroDec(), osmomath.ZeroDec(), nil), apptesting.DefaultPoolAssets, "") _, err = suite.app.PoolManagerKeeper.CreatePool(suite.ctx, msg) suite.NoError(err) @@ -124,7 +125,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { }, checkResponseStruct: true, responseProtoStruct: &gammv2types.QuerySpotPriceResponse{ //nolint:staticcheck // we're intentionally using this deprecated package for testing - SpotPrice: sdk.NewDecWithPrec(5, 1).String(), + SpotPrice: osmomath.NewDecWithPrec(5, 1).String(), }, }, { @@ -145,7 +146,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { suite.Require().NoError(err) // fund account to receive non-empty response - err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", osmomath.NewInt(10))}) suite.Require().NoError(err) wasmbinding.SetWhitelistedQuery("/cosmos.bank.v1beta1.Query/AllBalances", &banktypes.QueryAllBalancesResponse{}) @@ -168,7 +169,7 @@ func (suite *StargateTestSuite) TestStargateQuerier() { suite.Require().NoError(err) // fund account to receive non-empty response - err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", sdk.NewInt(10))}) + err = simapp.FundAccount(suite.app.BankKeeper, suite.ctx, accAddr, sdk.Coins{sdk.NewCoin("stake", osmomath.NewInt(10))}) suite.Require().NoError(err) wasmbinding.SetWhitelistedQuery("/cosmos.bank.v1beta1.Query/AllBalances", &banktypes.QueryAllBalancesResponse{}) @@ -309,7 +310,7 @@ func (suite *StargateTestSuite) TestConvertProtoToJsonMarshal() { originalResponse: "0a090a036261721202333012050a03666f6f", protoResponseStruct: &banktypes.QueryAllBalancesResponse{}, expectedProtoResponse: &banktypes.QueryAllBalancesResponse{ - Balances: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(30))), + Balances: sdk.NewCoins(sdk.NewCoin("bar", osmomath.NewInt(30))), Pagination: &query.PageResponse{ NextKey: []byte("foo"), }, @@ -398,7 +399,7 @@ func (suite *StargateTestSuite) TestDeterministicJsonMarshal() { &banktypes.QueryAllBalancesResponse{}, func() proto.Message { return &banktypes.QueryAllBalancesResponse{ - Balances: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(30))), + Balances: sdk.NewCoins(sdk.NewCoin("bar", osmomath.NewInt(30))), Pagination: &query.PageResponse{ NextKey: []byte("foo"), }, diff --git a/wasmbinding/test/custom_msg_test.go b/wasmbinding/test/custom_msg_test.go index 72fb8a5de71..6be4438d697 100644 --- a/wasmbinding/test/custom_msg_test.go +++ b/wasmbinding/test/custom_msg_test.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/stretchr/testify/require" @@ -66,7 +67,7 @@ func TestMintMsg(t *testing.T) { require.NoError(t, err) sunDenom := fmt.Sprintf("factory/%s/%s", reflect.String(), msg.CreateDenom.Subdenom) - amount, ok := sdk.NewIntFromString("808010808") + amount, ok := osmomath.NewIntFromString("808010808") require.True(t, ok) msg = bindings.OsmosisMsg{MintTokens: &bindings.MintTokens{ Denom: sunDenom, @@ -191,7 +192,7 @@ func TestBurnMsg(t *testing.T) { require.NoError(t, err) sunDenom := fmt.Sprintf("factory/%s/%s", reflect.String(), msg.CreateDenom.Subdenom) - amount, ok := sdk.NewIntFromString("808010808") + amount, ok := osmomath.NewIntFromString("808010808") require.True(t, ok) msg = bindings.OsmosisMsg{MintTokens: &bindings.MintTokens{ diff --git a/wasmbinding/test/helpers_test.go b/wasmbinding/test/helpers_test.go index 3df68dfba16..490f93647ca 100644 --- a/wasmbinding/test/helpers_test.go +++ b/wasmbinding/test/helpers_test.go @@ -13,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app" ) @@ -25,7 +26,7 @@ func CreateTestInput() (*app.OsmosisApp, sdk.Context) { func FundAccount(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp, acct sdk.AccAddress) { t.Helper() err := simapp.FundAccount(osmosis.BankKeeper, ctx, acct, sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), )) require.NoError(t, err) } diff --git a/wasmbinding/test/messages_test.go b/wasmbinding/test/messages_test.go index 12656a72304..e8f266ec132 100644 --- a/wasmbinding/test/messages_test.go +++ b/wasmbinding/test/messages_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/wasmbinding" "github.com/osmosis-labs/osmosis/v19/wasmbinding/bindings" @@ -186,7 +187,7 @@ func TestMint(t *testing.T) { balances := osmosis.BankKeeper.GetAllBalances(ctx, lucky) require.Empty(t, balances) - amount, ok := sdk.NewIntFromString("8080") + amount, ok := osmomath.NewIntFromString("8080") require.True(t, ok) specs := map[string]struct { @@ -227,7 +228,7 @@ func TestMint(t *testing.T) { "zero amount": { mint: &bindings.MintTokens{ Denom: validDenomStr, - Amount: sdk.ZeroInt(), + Amount: osmomath.ZeroInt(), MintToAddress: lucky.String(), }, expErr: true, @@ -301,7 +302,7 @@ func TestBurn(t *testing.T) { validDenomStr := fmt.Sprintf("factory/%s/%s", creator.String(), validDenom.Subdenom) emptyDenomStr := fmt.Sprintf("factory/%s/%s", creator.String(), emptyDenom.Subdenom) - mintAmount, ok := sdk.NewIntFromString("8080") + mintAmount, ok := osmomath.NewIntFromString("8080") require.True(t, ok) specs := map[string]struct { @@ -351,7 +352,7 @@ func TestBurn(t *testing.T) { "zero amount": { burn: &bindings.BurnTokens{ Denom: validDenomStr, - Amount: sdk.ZeroInt(), + Amount: osmomath.ZeroInt(), BurnFromAddress: creator.String(), }, expErr: true, diff --git a/x/concentrated-liquidity/README.md b/x/concentrated-liquidity/README.md index f039be91a4b..8f14a7ab095 100644 --- a/x/concentrated-liquidity/README.md +++ b/x/concentrated-liquidity/README.md @@ -141,7 +141,7 @@ This goes on in the negative direction until it reaches a spot price of price of 100000000000000000000000000000000000000. The minimum spot price was chosen as this is the smallest possible number -supported by the sdk.Dec type. As for the maximum spot price, the above number +supported by the osmomath.Dec type. As for the maximum spot price, the above number was based on gamm's max spot price of 340282366920938463463374607431768211455. While these numbers are not the same, the max spot price used in concentrated liquidity utilizes the same number of significant figures as gamm's max spot @@ -595,7 +595,7 @@ and token1 as a result the one that had higher liquidity will end up smaller than originally given by the user. Note that the liquidity used here does not represent an amount of a specific -token, but the liquidity of the pool itself, represented in `sdk.Dec`. +token, but the liquidity of the pool itself, represented in `osmomath.Dec`. Using the provided liquidity, now we calculate the delta amount of both token0 and token1, using the following equations, where L is the liquidity calculated above: @@ -615,7 +615,7 @@ position for a given tick, the API in the keeper layer would look like the follo ```go ctx sdk.Context, poolId uint64, owner sdk.AccAddress, amount0Desired, -amount1Desired, amount0Min, amount1Min sdk.Int, +amount1Desired, amount0Min, amount1Min osmomath.Int, lowerTick, upperTick int64, frozenUntil time.Time func createPosition( ctx sdk.Context, @@ -624,9 +624,9 @@ func createPosition( amount0Desired, amount1Desired, amount0Min, - amount1Min sdk.Int + amount1Min osmomath.Int lowerTick, - upperTick int64) (amount0, amount1 sdk.Int, sdk.Dec, error) { + upperTick int64) (amount0, amount1 osmomath.Int, osmomath.Dec, error) { ... } ``` @@ -650,8 +650,8 @@ func (k Keeper) withdrawPosition( lowerTick, upperTick int64, frozenUntil time.Time, - requestedLiquidityAmountToWithdraw sdk.Dec) - (amtDenom0, amtDenom1 sdk.Int, err error) { + requestedLiquidityAmountToWithdraw osmomath.Dec) + (amtDenom0, amtDenom1 osmomath.Int, err error) { ... } ``` @@ -774,32 +774,32 @@ type SwapState struct { // if in given out, amount of token being swapped out. // Initialized to the amount of the token specified by the user. // Updated after every swap step. - amountSpecifiedRemaining sdk.Dec + amountSpecifiedRemaining osmomath.Dec // Amount of the other token that is calculated from the specified token. // if out given in, amount of token swapped out. // if in given out, amount of token swapped in. // Initialized to zero. // Updated after every swap step. - amountCalculated sdk.Dec + amountCalculated osmomath.Dec // Current sqrt price while calculating swap. // Initialized to the pool's current sqrt price. // Updated after every swap step. - sqrtPrice sdk.Dec + sqrtPrice osmomath.Dec // Current tick while calculating swap. // Initialized to the pool's current tick. // Updated each time a tick is crossed. - tick sdk.Int + tick osmomath.Int // Current liqudiity within the active tick. // Initialized to the pool's current tick's liquidity. // Updated each time a tick is crossed. - liquidity sdk.Dec + liquidity osmomath.Dec // Global spread reward growth per-current swap. // Initialized to zero. // Updated after every swap step. - spreadRewardGrowthGlobal sdk.Dec + spreadRewardGrowthGlobal osmomath.Dec } ``` @@ -1224,7 +1224,7 @@ layers of state: // Note that this is proto-generated. type Pool struct { ... - SpreadFactor sdk.Dec + SpreadFactor osmomath.Dec } ``` @@ -1855,7 +1855,7 @@ The true price of PEPE in USDC terms is `0.0000009749`. In the "on-chain representation", this would be: `0.0000009749 * 10**6 / 10**18 = 9.749e-19` -Note that this is below the minimum precision of `sdk.Dec`. +Note that this is below the minimum precision of `osmomath.Dec`. Additionally, there is a problem with tick to sqrt price conversions where at small price levels, two sqrt prices can map to the same diff --git a/x/concentrated-liquidity/bench_test.go b/x/concentrated-liquidity/bench_test.go index 2f739925aeb..765d1cce5ca 100644 --- a/x/concentrated-liquidity/bench_test.go +++ b/x/concentrated-liquidity/bench_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" clmath "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/math" @@ -26,7 +27,7 @@ type BenchTestSuite struct { func (s *BenchTestSuite) createPosition(accountIndex int, poolId uint64, coin0, coin1 sdk.Coin, lowerTick, upperTick int64) { tokensDesired := sdk.NewCoins(coin0, coin1) - _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[accountIndex], tokensDesired, sdk.ZeroInt(), sdk.ZeroInt(), lowerTick, upperTick) + _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[accountIndex], tokensDesired, osmomath.ZeroInt(), osmomath.ZeroInt(), lowerTick, upperTick) if err != nil { // This can happen for ticks that map to the very small prices // e.g 2 * 10^(-18) ends up mapping to the same sqrt price @@ -55,16 +56,16 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p denom0 = DefaultCoin0.Denom denom1 = DefaultCoin1.Denom denomIn = denom0 - numberOfPositionsInt = sdk.NewInt(numberOfPositions) - maxAmountOfEachToken = sdk.NewInt(maxAmountDeposited).Mul(numberOfPositionsInt) + numberOfPositionsInt = osmomath.NewInt(numberOfPositions) + maxAmountOfEachToken = osmomath.NewInt(maxAmountDeposited).Mul(numberOfPositionsInt) seed = int64(1) defaultDenom0Asset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denom0, sdk.NewInt(1000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denom0, osmomath.NewInt(1000000000)), } defaultDenom1Asset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denom1, sdk.NewInt(1000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denom1, osmomath.NewInt(1000000000)), } defaultPoolAssets = []balancer.PoolAsset{defaultDenom0Asset, defaultDenom1Asset} ) @@ -87,14 +88,14 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p // Create a balancer pool gammPoolId, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.PoolParams{ - SwapFee: sdk.MustNewDecFromStr("0.001"), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.MustNewDecFromStr("0.001"), + ExitFee: osmomath.ZeroDec(), }, defaultPoolAssets, "")) noError(b, err) // Create a cl pool. clPoolId, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool( - s.TestAccs[0], denom0, denom1, tickSpacing, sdk.MustNewDecFromStr("0.001"), + s.TestAccs[0], denom0, denom1, tickSpacing, osmomath.MustNewDecFromStr("0.001"), )) noError(b, err) @@ -110,10 +111,10 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p s.Require().NoError(err) // Create first position to set a price of 1 and tick of zero. - tokenDesired0 := sdk.NewCoin(denom0, sdk.NewInt(100)) - tokenDesired1 := sdk.NewCoin(denom1, sdk.NewInt(100)) + tokenDesired0 := sdk.NewCoin(denom0, osmomath.NewInt(100)) + tokenDesired1 := sdk.NewCoin(denom1, osmomath.NewInt(100)) tokensDesired := sdk.NewCoins(tokenDesired0, tokenDesired1) - _, err = clKeeper.CreatePosition(s.Ctx, clPoolId, s.TestAccs[0], tokensDesired, sdk.ZeroInt(), sdk.ZeroInt(), types.MinInitializedTick, types.MaxTick) + _, err = clKeeper.CreatePosition(s.Ctx, clPoolId, s.TestAccs[0], tokensDesired, osmomath.ZeroInt(), osmomath.ZeroInt(), types.MinInitializedTick, types.MaxTick) noError(b, err) pool, err := clKeeper.GetPoolById(s.Ctx, clPoolId) @@ -162,8 +163,8 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p continue } - tokenDesired0 := sdk.NewCoin(denom0, sdk.NewInt(rand.Int63n(maxAmountDeposited))) - tokenDesired1 := sdk.NewCoin(denom1, sdk.NewInt(rand.Int63n(maxAmountDeposited))) + tokenDesired0 := sdk.NewCoin(denom0, osmomath.NewInt(rand.Int63n(maxAmountDeposited))) + tokenDesired1 := sdk.NewCoin(denom1, osmomath.NewInt(rand.Int63n(maxAmountDeposited))) accountIndex := rand.Intn(len(s.TestAccs)) s.createPosition(accountIndex, clPoolId, tokenDesired0, tokenDesired1, lowerTick, upperTick) @@ -171,7 +172,7 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p } createPosition := func(lowerTick, upperTick int64) { - maxAmountDepositedFullRange := sdk.NewInt(maxAmountDeposited).MulRaw(5) + maxAmountDepositedFullRange := osmomath.NewInt(maxAmountDeposited).MulRaw(5) tokenDesired0 := sdk.NewCoin(denom0, maxAmountDepositedFullRange) tokenDesired1 := sdk.NewCoin(denom1, maxAmountDepositedFullRange) tokensDesired := sdk.NewCoins(tokenDesired0, tokenDesired1) @@ -219,7 +220,7 @@ func runBenchmark(b *testing.B, testFunc func(b *testing.B, s *BenchTestSuite, p setupConcentratedPositions() } - swapAmountIn := sdk.MustNewDecFromStr(amountIn).TruncateInt() + swapAmountIn := osmomath.MustNewDecFromStr(amountIn).TruncateInt() largeSwapInCoin := sdk.NewCoin(denomIn, swapAmountIn) // Commit so that the changes are propagated to IAVL. s.Commit() @@ -233,14 +234,14 @@ func BenchmarkSwapExactAmountIn(b *testing.B) { runBenchmark(b, func(b *testing.B, s *BenchTestSuite, pool types.ConcentratedPoolExtension, largeSwapInCoin sdk.Coin, currentTick int64) { clKeeper := s.App.ConcentratedLiquidityKeeper - liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, sdk.NewInt(currentTick), sdk.Int{}) + liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, osmomath.NewInt(currentTick), osmomath.Int{}) noError(b, err) simapp.FundAccount(s.App.BankKeeper, s.Ctx, s.TestAccs[0], sdk.NewCoins(largeSwapInCoin)) b.StartTimer() // System under test - _, err = clKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, largeSwapInCoin, DefaultCoin1.Denom, sdk.NewInt(1), pool.GetSpreadFactor(s.Ctx)) + _, err = clKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, largeSwapInCoin, DefaultCoin1.Denom, osmomath.NewInt(1), pool.GetSpreadFactor(s.Ctx)) b.StopTimer() noError(b, err) @@ -256,7 +257,7 @@ func BenchmarkGetTickLiquidityNetInDirection(b *testing.B) { b.StartTimer() // System under test - liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, sdk.NewInt(currentTick), sdk.Int{}) + liquidityNet, err := clKeeper.GetTickLiquidityNetInDirection(s.Ctx, pool.GetId(), largeSwapInCoin.Denom, osmomath.NewInt(currentTick), osmomath.Int{}) b.StopTimer() noError(b, err) diff --git a/x/concentrated-liquidity/client/cli/tx.go b/x/concentrated-liquidity/client/cli/tx.go index 41d9004629e..3e5035c207f 100644 --- a/x/concentrated-liquidity/client/cli/tx.go +++ b/x/concentrated-liquidity/client/cli/tx.go @@ -15,6 +15,7 @@ import ( govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -316,7 +317,7 @@ func parsePoolRecords(cmd *cobra.Command) ([]types.PoolRecord, error) { } spreadFactorStr := poolRecords[i+3] - spreadFactor, err := sdk.NewDecFromStr(spreadFactorStr) + spreadFactor, err := osmomath.NewDecFromStr(spreadFactorStr) if err != nil { return nil, err } diff --git a/x/concentrated-liquidity/client/query_proto_wrap.go b/x/concentrated-liquidity/client/query_proto_wrap.go index 7f79de46df4..cf62b33d2d3 100644 --- a/x/concentrated-liquidity/client/query_proto_wrap.go +++ b/x/concentrated-liquidity/client/query_proto_wrap.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" clquery "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/client/queryproto" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" @@ -129,14 +130,14 @@ func (q Querier) LiquidityNetInDirection(ctx sdk.Context, req clquery.LiquidityN return nil, status.Error(codes.InvalidArgument, "tokenIn is empty") } - var startTick sdk.Int + var startTick osmomath.Int if !req.UseCurTick { - startTick = sdk.NewInt(req.StartTick) + startTick = osmomath.NewInt(req.StartTick) } - var boundTick sdk.Int + var boundTick osmomath.Int if !req.UseNoBound { - boundTick = sdk.NewInt(req.BoundTick) + boundTick = osmomath.NewInt(req.BoundTick) } liquidityDepths, err := q.Keeper.GetTickLiquidityNetInDirection( diff --git a/x/concentrated-liquidity/client/queryproto/query.pb.go b/x/concentrated-liquidity/client/queryproto/query.pb.go index 50134681987..5dc55440d00 100644 --- a/x/concentrated-liquidity/client/queryproto/query.pb.go +++ b/x/concentrated-liquidity/client/queryproto/query.pb.go @@ -5,6 +5,7 @@ package queryproto import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -420,8 +421,8 @@ func (m *ParamsResponse) GetParams() types1.Params { } type TickLiquidityNet struct { - LiquidityNet github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=liquidity_net,json=liquidityNet,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_net" yaml:"liquidity_net"` - TickIndex int64 `protobuf:"varint,2,opt,name=tick_index,json=tickIndex,proto3" json:"tick_index,omitempty" yaml:"tick_index"` + LiquidityNet cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=liquidity_net,json=liquidityNet,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_net" yaml:"liquidity_net"` + TickIndex int64 `protobuf:"varint,2,opt,name=tick_index,json=tickIndex,proto3" json:"tick_index,omitempty" yaml:"tick_index"` } func (m *TickLiquidityNet) Reset() { *m = TickLiquidityNet{} } @@ -465,9 +466,9 @@ func (m *TickLiquidityNet) GetTickIndex() int64 { } type LiquidityDepthWithRange struct { - LiquidityAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=liquidity_amount,json=liquidityAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_amount" yaml:"liquidity_net"` - LowerTick int64 `protobuf:"varint,2,opt,name=lower_tick,json=lowerTick,proto3" json:"lower_tick,omitempty" yaml:"lower_tick"` - UpperTick int64 `protobuf:"varint,3,opt,name=upper_tick,json=upperTick,proto3" json:"upper_tick,omitempty" yaml:"upper_tick"` + LiquidityAmount cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=liquidity_amount,json=liquidityAmount,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_amount" yaml:"liquidity_net"` + LowerTick int64 `protobuf:"varint,2,opt,name=lower_tick,json=lowerTick,proto3" json:"lower_tick,omitempty" yaml:"lower_tick"` + UpperTick int64 `protobuf:"varint,3,opt,name=upper_tick,json=upperTick,proto3" json:"upper_tick,omitempty" yaml:"upper_tick"` } func (m *LiquidityDepthWithRange) Reset() { *m = LiquidityDepthWithRange{} } @@ -603,9 +604,9 @@ func (m *LiquidityNetInDirectionRequest) GetUseNoBound() bool { } type LiquidityNetInDirectionResponse struct { - LiquidityDepths []TickLiquidityNet `protobuf:"bytes,1,rep,name=liquidity_depths,json=liquidityDepths,proto3" json:"liquidity_depths"` - CurrentTick int64 `protobuf:"varint,2,opt,name=current_tick,json=currentTick,proto3" json:"current_tick,omitempty"` - CurrentLiquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=current_liquidity,json=currentLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_liquidity" yaml:"current_liquidity"` + LiquidityDepths []TickLiquidityNet `protobuf:"bytes,1,rep,name=liquidity_depths,json=liquidityDepths,proto3" json:"liquidity_depths"` + CurrentTick int64 `protobuf:"varint,2,opt,name=current_tick,json=currentTick,proto3" json:"current_tick,omitempty"` + CurrentLiquidity cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=current_liquidity,json=currentLiquidity,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"current_liquidity" yaml:"current_liquidity"` } func (m *LiquidityNetInDirectionResponse) Reset() { *m = LiquidityNetInDirectionResponse{} } @@ -1659,148 +1660,142 @@ func init() { } var fileDescriptor_5c83e18b11fd607d = []byte{ - // 2254 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x5a, 0x4d, 0x6c, 0x1c, 0x49, - 0x15, 0x4e, 0x4f, 0x7e, 0xe7, 0xc5, 0x89, 0x9d, 0xb2, 0x63, 0x3b, 0x93, 0x64, 0x26, 0x5b, 0x90, - 0x5d, 0x6b, 0x13, 0xcf, 0x90, 0x1f, 0x13, 0x9c, 0x9f, 0xcd, 0x7a, 0xec, 0xb5, 0x35, 0xac, 0xe3, - 0x75, 0x7a, 0x63, 0x40, 0x1c, 0x68, 0x7a, 0xba, 0xcb, 0xe3, 0xd6, 0xf4, 0x74, 0x8d, 0xbb, 0xab, - 0xed, 0x98, 0x25, 0xd2, 0x8a, 0x3d, 0x22, 0xc1, 0x22, 0xee, 0x5c, 0x38, 0x80, 0x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0x9a, 0x81, 0xc2, 0xb2, 0x4d, 0xd4, - 0xba, 0x4e, 0xb7, 0xad, 0xf2, 0xb1, 0xe7, 0xad, 0xc2, 0x11, 0x39, 0x52, 0x8a, 0x96, 0x3a, 0x30, - 0x64, 0x38, 0x86, 0xd7, 0xf6, 0xc5, 0xe0, 0xbb, 0xd7, 0x01, 0x62, 0x05, 0x46, 0x43, 0x73, 0x3b, - 0x15, 0x3d, 0x08, 0xff, 0x1d, 0x38, 0x1d, 0x18, 0xf3, 0x82, 0x2a, 0xf1, 0xa0, 0x8e, 0xb7, 0x5b, - 0x05, 0x14, 0x04, 0x35, 0x24, 0x62, 0x19, 0x82, 0xa7, 0x8a, 0x8e, 0xb7, 0x60, 0xac, 0x53, 0x9f, - 0x08, 0xc9, 0xb7, 0xe0, 0x54, 0xc0, 0xc5, 0xb5, 0x1d, 0x4e, 0x44, 0x42, 0x9d, 0xf8, 0x6b, 0x30, - 0xb4, 0x4a, 0xa9, 0x19, 0xd6, 0xcf, 0x62, 0x42, 0x80, 0x06, 0x49, 0xf2, 0x0f, 0x25, 0x38, 0x23, - 0x14, 0x0b, 0x24, 0x33, 0x70, 0xdc, 0x2b, 0xa4, 0x20, 0xb1, 0x63, 0x45, 0xff, 0x20, 0x15, 0x83, - 0x83, 0x54, 0x9c, 0xb3, 0x76, 0xca, 0xd9, 0x3f, 0xfe, 0x6a, 0xfa, 0xb8, 0x27, 0x57, 0x91, 0x7d, - 0xee, 0xc3, 0xcb, 0xd8, 0x30, 0x9c, 0x59, 0xe5, 0x8d, 0x4b, 0xb8, 0x8b, 0xd7, 0xe0, 0x6c, 0xf0, - 0x42, 0xb8, 0x38, 0x0f, 0x27, 0xfc, 0xde, 0x26, 0x42, 0x7d, 0x75, 0x9f, 0x50, 0xfb, 0xe2, 0x22, - 0xa6, 0x42, 0x14, 0xff, 0x5a, 0x82, 0x91, 0x27, 0x86, 0x56, 0x5f, 0x0e, 0xd8, 0x56, 0x08, 0x43, - 0x75, 0x38, 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x25, 0x2e, 0x54, 0x7a, 0x2f, 0x69, 0xd0, 0x7d, 0x86, 0x3e, 0x97, 0x60, 0x3c, 0x79, - 0x34, 0x4c, 0x7d, 0xdc, 0xf7, 0x9c, 0x54, 0x53, 0x1f, 0xf7, 0xbd, 0xe7, 0x53, 0xfc, 0x98, 0x87, - 0xe4, 0x6d, 0x54, 0x49, 0x19, 0x12, 0xd7, 0x21, 0xb6, 0xe2, 0x06, 0xfa, 0x94, 0xa4, 0xbb, 0xd6, - 0x27, 0x12, 0x9c, 0xdb, 0x35, 0x53, 0xa2, 0xb4, 0xe7, 0xb7, 0xd7, 0xa8, 0x9a, 0x7b, 0x73, 0x70, - 0x05, 0x03, 0x1e, 0x8a, 0x1a, 0x61, 0x4a, 0xd7, 0xfc, 0xcb, 0xaf, 0x56, 0x3d, 0xe6, 0xb4, 0xd4, - 0x3d, 0x60, 0xef, 0xe1, 0x36, 0x75, 0x0f, 0xd8, 0x67, 0x5c, 0xec, 0xfb, 0x6a, 0xd5, 0x7b, 0x6e, - 0x2d, 0x6f, 0x3c, 0x7f, 0x91, 0x97, 0x3e, 0x7e, 0x91, 0x97, 0xfe, 0xfa, 0x22, 0x2f, 0x7d, 0xf8, - 0x32, 0x7f, 0xe4, 0xe3, 0x97, 0xf9, 0x23, 0x7f, 0x79, 0x99, 0x3f, 0xf2, 0xcd, 0x95, 0xd8, 0x8c, - 0x27, 0xcc, 0x4c, 0x9b, 0x6a, 0xd5, 0x09, 0x6d, 0x6e, 0xdd, 0x98, 0x2d, 0x3d, 0xed, 0xf5, 0x3f, - 0x50, 0x34, 0xd3, 0x20, 0x16, 0xf3, 0xff, 0x2f, 0x8e, 0xff, 0xb7, 0xfa, 0x13, 0xfc, 0x9f, 0x5b, - 0xff, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x09, 0xd7, 0xa0, 0x11, 0x91, 0x24, 0x00, 0x00, + // 2145 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 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39, 0x50, 0x4e, 0x06, 0xbc, 0xb3, 0x7c, 0x91, 0x81, 0x62, 0x4f, 0x2f, 0x64, 0x2a, + 0x9f, 0x23, 0x98, 0x4d, 0x4c, 0x25, 0x6b, 0x89, 0x7d, 0x46, 0x55, 0x23, 0x3c, 0x95, 0x54, 0xb6, + 0xae, 0x5a, 0x9a, 0xcb, 0x55, 0xee, 0x68, 0x9b, 0xd4, 0x71, 0xff, 0x9f, 0x89, 0xbe, 0xb9, 0x37, + 0xd1, 0x6f, 0x4b, 0x87, 0xa2, 0x53, 0xf2, 0xed, 0xf5, 0x15, 0xcd, 0xe5, 0x4f, 0x42, 0x67, 0xf0, + 0x33, 0x18, 0x91, 0x19, 0xe2, 0x12, 0xe5, 0xa1, 0x92, 0x5f, 0x90, 0xc9, 0x9f, 0xe8, 0x48, 0x7e, + 0xa8, 0x9a, 0x28, 0xe7, 0xbc, 0x38, 0xbb, 0x4b, 0x7e, 0x88, 0x60, 0x32, 0xda, 0x94, 0x8a, 0x98, + 0x41, 0x07, 0x4b, 0xf6, 0x51, 0x4d, 0x16, 0x9f, 0x20, 0xc8, 0xed, 0x75, 0x48, 0xe6, 0xdd, 0x84, + 0xf3, 0xdd, 0x13, 0x73, 0xd8, 0x16, 0xbf, 0x9e, 0x32, 0x5c, 0x5d, 0xba, 0xe5, 0x79, 0x37, 0x6a, + 0x76, 0x99, 0x3c, 0xba, 0xc1, 0xe4, 0x03, 0x04, 0xd7, 0x16, 0x96, 0x1e, 0x3e, 0x14, 0x63, 0x8f, + 0xb1, 0x62, 0xda, 0x8d, 0x25, 0x87, 0x35, 0x17, 0x62, 0x4e, 0x06, 0x94, 0x30, 0xea, 0x8f, 0x61, + 0x3c, 0x8e, 0x40, 0xed, 0x4c, 0x41, 0x31, 0xd6, 0xde, 0x13, 0xb8, 0x88, 0x82, 0xf5, 0x3d, 0x9a, + 0x89, 0x09, 0xd7, 0xd3, 0x79, 0x20, 0xc3, 0x3c, 0x0b, 0xc3, 0xfa, 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0xea, 0xed, 0xbe, 0xef, + 0x28, 0x92, 0x7a, 0xbb, 0xef, 0x3f, 0x80, 0x90, 0xc7, 0x22, 0x24, 0x6f, 0xe1, 0x6a, 0xca, 0x90, + 0x78, 0x2e, 0x75, 0x54, 0x2f, 0xd4, 0xa7, 0x26, 0xdd, 0xb5, 0x3e, 0x43, 0x70, 0x7e, 0xcf, 0xd0, + 0x80, 0xd3, 0xee, 0xdf, 0x5e, 0xb3, 0x48, 0xfe, 0x8d, 0xc1, 0x15, 0x0c, 0xb8, 0x29, 0xea, 0x94, + 0xab, 0x5d, 0x03, 0x4e, 0x65, 0xe3, 0xf9, 0x8b, 0x02, 0xfa, 0xf4, 0x45, 0x01, 0xfd, 0xe5, 0x45, + 0x01, 0x7d, 0xf4, 0xb2, 0x70, 0xec, 0xd3, 0x97, 0x85, 0x63, 0x7f, 0x7e, 0x59, 0x38, 0xf6, 0x9d, + 0x47, 0xb1, 0x89, 0x46, 0xea, 0x9f, 0xb6, 0xb4, 0x9a, 0x1b, 0x19, 0xdb, 0xbc, 0x31, 0x5b, 0x7e, + 0xaf, 0xd7, 0xdf, 0xd2, 0x75, 0xcb, 0xa4, 0x36, 0x0f, 0xfe, 0x57, 0x41, 0xf0, 0x57, 0xc7, 0x21, + 0xf1, 0xcf, 0xad, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xaa, 0x47, 0x4c, 0x5b, 0x21, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/concentrated-liquidity/event.go b/x/concentrated-liquidity/event.go index 56bfb16ae8c..3a29500e9dd 100644 --- a/x/concentrated-liquidity/event.go +++ b/x/concentrated-liquidity/event.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" types "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -34,9 +35,9 @@ type liquidityChangeEvent struct { lowerTick int64 upperTick int64 joinTime time.Time - liquidityDelta sdk.Dec - actualAmount0 sdk.Int - actualAmount1 sdk.Int + liquidityDelta osmomath.Dec + actualAmount0 osmomath.Int + actualAmount1 osmomath.Int } // emit emits an event for a liquidity change when creating or withdrawing a position based its field. diff --git a/x/concentrated-liquidity/export_test.go b/x/concentrated-liquidity/export_test.go index fa513af194e..fbfa3e82dbc 100644 --- a/x/concentrated-liquidity/export_test.go +++ b/x/concentrated-liquidity/export_test.go @@ -19,10 +19,10 @@ const ( var ( EmptyCoins = emptyCoins - HundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(100)) - HundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(100)) - TwoHundredFooCoins = sdk.NewDecCoin("foo", sdk.NewInt(200)) - TwoHundredBarCoins = sdk.NewDecCoin("bar", sdk.NewInt(200)) + HundredFooCoins = sdk.NewDecCoin("foo", osmomath.NewInt(100)) + HundredBarCoins = sdk.NewDecCoin("bar", osmomath.NewInt(100)) + TwoHundredFooCoins = sdk.NewDecCoin("foo", osmomath.NewInt(200)) + TwoHundredBarCoins = sdk.NewDecCoin("bar", osmomath.NewInt(200)) ) func (k Keeper) SetPool(ctx sdk.Context, pool types.ConcentratedPoolExtension) error { @@ -45,11 +45,11 @@ func (k Keeper) GetSwapAccumulators(ctx sdk.Context, poolId uint64) (*accum.Accu return k.getSwapAccumulators(ctx, poolId) } -func (k Keeper) CrossTick(ctx sdk.Context, poolId uint64, tickIndex int64, nextTickInfo *model.TickInfo, swapStateSpreadRewardGrowth sdk.DecCoin, spreadRewardAccumValue sdk.DecCoins, uptimeAccums []*accum.AccumulatorObject) (liquidityDelta sdk.Dec, err error) { +func (k Keeper) CrossTick(ctx sdk.Context, poolId uint64, tickIndex int64, nextTickInfo *model.TickInfo, swapStateSpreadRewardGrowth sdk.DecCoin, spreadRewardAccumValue sdk.DecCoins, uptimeAccums []*accum.AccumulatorObject) (liquidityDelta osmomath.Dec, err error) { return k.crossTick(ctx, poolId, tickIndex, nextTickInfo, swapStateSpreadRewardGrowth, spreadRewardAccumValue, uptimeAccums) } -func (k Keeper) SendCoinsBetweenPoolAndUser(ctx sdk.Context, denom0, denom1 string, amount0, amount1 sdk.Int, sender, receiver sdk.AccAddress) error { +func (k Keeper) SendCoinsBetweenPoolAndUser(ctx sdk.Context, denom0, denom1 string, amount0, amount1 osmomath.Int, sender, receiver sdk.AccAddress) error { return k.sendCoinsBetweenPoolAndUser(ctx, denom0, denom1, amount0, amount1, sender, receiver) } @@ -59,8 +59,8 @@ func (k Keeper) SwapOutAmtGivenIn( pool types.ConcentratedPoolExtension, tokenIn sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { return k.swapOutAmtGivenIn(ctx, sender, pool, tokenIn, tokenOutDenom, spreadFactor, priceLimit) } @@ -69,8 +69,8 @@ func (k Keeper) ComputeOutAmtGivenIn( poolId uint64, tokenInMin sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, ) (swapResult SwapResult, poolUpdates PoolUpdates, err error) { return k.computeOutAmtGivenIn(ctx, poolId, tokenInMin, tokenOutDenom, spreadFactor, priceLimit) @@ -82,8 +82,8 @@ func (k Keeper) SwapInAmtGivenOut( pool types.ConcentratedPoolExtension, desiredTokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { return k.swapInAmtGivenOut(ctx, sender, pool, desiredTokenOut, tokenInDenom, spreadFactor, priceLimit) } @@ -91,19 +91,19 @@ func (k Keeper) ComputeInAmtGivenOut( ctx sdk.Context, desiredTokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, poolId uint64, ) (swapResult SwapResult, poolUpdates PoolUpdates, err error) { return k.computeInAmtGivenOut(ctx, desiredTokenOut, tokenInDenom, spreadFactor, priceLimit, poolId) } -func (k Keeper) InitOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int64, tickIndex int64, liquidityIn sdk.Dec, upper bool) (tickIsEmpty bool, err error) { +func (k Keeper) InitOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int64, tickIndex int64, liquidityIn osmomath.Dec, upper bool) (tickIsEmpty bool, err error) { return k.initOrUpdateTick(ctx, poolId, currentTick, tickIndex, liquidityIn, upper) } -func (k Keeper) InitOrUpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) (err error) { +func (k Keeper) InitOrUpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta osmomath.Dec, joinTime time.Time, positionId uint64) (err error) { return k.initOrUpdatePosition(ctx, poolId, owner, lowerTick, upperTick, liquidityDelta, joinTime, positionId) } @@ -111,7 +111,7 @@ func (k Keeper) GetNextPositionIdAndIncrement(ctx sdk.Context) uint64 { return k.getNextPositionIdAndIncrement(ctx) } -func (k Keeper) InitializeInitialPositionForPool(ctx sdk.Context, pool types.ConcentratedPoolExtension, amount0Desired, amount1Desired sdk.Int) error { +func (k Keeper) InitializeInitialPositionForPool(ctx sdk.Context, pool types.ConcentratedPoolExtension, amount0Desired, amount1Desired osmomath.Int) error { return k.initializeInitialPositionForPool(ctx, pool, amount0Desired, amount1Desired) } @@ -131,7 +131,7 @@ func AsConcentrated(poolI poolmanagertypes.PoolI) (types.ConcentratedPoolExtensi return asConcentrated(poolI) } -func (k Keeper) ValidateSpreadFactor(ctx sdk.Context, params types.Params, spreadFactor sdk.Dec) bool { +func (k Keeper) ValidateSpreadFactor(ctx sdk.Context, params types.Params, spreadFactor osmomath.Dec) bool { return k.validateSpreadFactor(params, spreadFactor) } @@ -151,7 +151,7 @@ func (k Keeper) PositionHasActiveUnderlyingLockAndUpdate(ctx sdk.Context, positi return k.positionHasActiveUnderlyingLockAndUpdate(ctx, positionId) } -func (k Keeper) UpdateFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64, liquidity sdk.Dec) error { +func (k Keeper) UpdateFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64, liquidity osmomath.Dec) error { return k.updateFullRangeLiquidityInPool(ctx, poolId, liquidity) } @@ -172,7 +172,7 @@ func (k Keeper) CreateSpreadRewardAccumulator(ctx sdk.Context, poolId uint64) er return k.createSpreadRewardAccumulator(ctx, poolId) } -func (k Keeper) InitOrUpdatePositionSpreadRewardAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity sdk.Dec) error { +func (k Keeper) InitOrUpdatePositionSpreadRewardAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity osmomath.Dec) error { return k.initOrUpdatePositionSpreadRewardAccumulator(ctx, poolId, lowerTick, upperTick, positionId, liquidity) } @@ -200,29 +200,29 @@ func UpdatePositionToInitValuePlusGrowthOutside(accumulator *accum.AccumulatorOb return updatePositionToInitValuePlusGrowthOutside(accumulator, positionKey, growthOutside) } -func (k Keeper) AddToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0Min, amount1Min sdk.Int) (uint64, sdk.Int, sdk.Int, error) { +func (k Keeper) AddToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0Min, amount1Min osmomath.Int) (uint64, osmomath.Int, osmomath.Int, error) { return k.addToPosition(ctx, owner, positionId, amount0Added, amount1Added, amount0Min, amount1Min) } -func (ss *SwapState) UpdateSpreadRewardGrowthGlobal(spreadRewardChargeTotal sdk.Dec) { +func (ss *SwapState) UpdateSpreadRewardGrowthGlobal(spreadRewardChargeTotal osmomath.Dec) { ss.updateSpreadRewardGrowthGlobal(spreadRewardChargeTotal) } // Test helpers. -func (ss *SwapState) SetLiquidity(liquidity sdk.Dec) { +func (ss *SwapState) SetLiquidity(liquidity osmomath.Dec) { ss.liquidity = liquidity } // TODO: Refactor tests to get this deleted? -func (ss *SwapState) SetGlobalSpreadRewardGrowthPerUnitLiquidity(spreadRewardGrowthGlobal sdk.Dec) { +func (ss *SwapState) SetGlobalSpreadRewardGrowthPerUnitLiquidity(spreadRewardGrowthGlobal osmomath.Dec) { ss.globalSpreadRewardGrowthPerUnitLiquidity = spreadRewardGrowthGlobal } -func (ss *SwapState) SetGlobalSpreadRewardGrowth(spreadRewardGrowthGlobal sdk.Dec) { +func (ss *SwapState) SetGlobalSpreadRewardGrowth(spreadRewardGrowthGlobal osmomath.Dec) { ss.globalSpreadRewardGrowth = spreadRewardGrowthGlobal } -func (ss *SwapState) GetGlobalSpreadRewardGrowthPerUnitLiquidity() sdk.Dec { +func (ss *SwapState) GetGlobalSpreadRewardGrowthPerUnitLiquidity() osmomath.Dec { return ss.globalSpreadRewardGrowthPerUnitLiquidity } @@ -231,7 +231,7 @@ func (k Keeper) CreateUptimeAccumulators(ctx sdk.Context, poolId uint64) error { return k.createUptimeAccumulators(ctx, poolId) } -func CalcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, qualifyingLiquidity sdk.Dec, timeElapsed sdk.Dec, poolIncentiveRecords []types.IncentiveRecord) (sdk.DecCoins, []types.IncentiveRecord, error) { +func CalcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, qualifyingLiquidity osmomath.Dec, timeElapsed osmomath.Dec, poolIncentiveRecords []types.IncentiveRecord) (sdk.DecCoins, []types.IncentiveRecord, error) { return calcAccruedIncentivesForAccum(ctx, accumUptime, qualifyingLiquidity, timeElapsed, poolIncentiveRecords) } @@ -251,7 +251,7 @@ func (k Keeper) GetInitialUptimeGrowthOppositeDirectionOfLastTraversalForTick(ct return k.getInitialUptimeGrowthOppositeDirectionOfLastTraversalForTick(ctx, pool, tick) } -func (k Keeper) InitOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, position sdk.Dec, lowerTick, upperTick int64, liquidityDelta sdk.Dec, positionId uint64) error { +func (k Keeper) InitOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, position osmomath.Dec, lowerTick, upperTick int64, liquidityDelta osmomath.Dec, positionId uint64) error { return k.initOrUpdatePositionUptimeAccumulators(ctx, poolId, position, lowerTick, upperTick, liquidityDelta, positionId) } @@ -283,7 +283,7 @@ func (k Keeper) GetAllPositions(ctx sdk.Context) ([]model.Position, error) { return k.getAllPositions(ctx) } -func (k Keeper) UpdatePoolForSwap(ctx sdk.Context, pool types.ConcentratedPoolExtension, swapDetails SwapDetails, poolUpdates PoolUpdates, totalSpreadRewards sdk.Dec) error { +func (k Keeper) UpdatePoolForSwap(ctx sdk.Context, pool types.ConcentratedPoolExtension, swapDetails SwapDetails, poolUpdates PoolUpdates, totalSpreadRewards osmomath.Dec) error { return k.updatePoolForSwap(ctx, pool, swapDetails, poolUpdates, totalSpreadRewards) } @@ -315,7 +315,7 @@ func ValidateAuthorizedQuoteDenoms(ctx sdk.Context, denom1 string, authorizedQuo return validateAuthorizedQuoteDenoms(denom1, authorizedQuoteDenoms) } -func (k Keeper) ValidatePositionUpdateById(ctx sdk.Context, positionId uint64, updateInitiator sdk.AccAddress, lowerTickGiven int64, upperTickGiven int64, liquidityDeltaGiven sdk.Dec, joinTimeGiven time.Time, poolIdGiven uint64) error { +func (k Keeper) ValidatePositionUpdateById(ctx sdk.Context, positionId uint64, updateInitiator sdk.AccAddress, lowerTickGiven int64, upperTickGiven int64, liquidityDeltaGiven osmomath.Dec, joinTimeGiven time.Time, poolIdGiven uint64) error { return k.validatePositionUpdateById(ctx, positionId, updateInitiator, lowerTickGiven, upperTickGiven, liquidityDeltaGiven, joinTimeGiven, poolIdGiven) } @@ -328,8 +328,8 @@ func (k Keeper) GetLargestSupportedUptimeDuration(ctx sdk.Context) time.Duration } func (k Keeper) SetupSwapStrategy(ctx sdk.Context, p types.ConcentratedPoolExtension, - spreadFactor sdk.Dec, tokenInDenom string, - priceLimit sdk.Dec) (strategy swapstrategy.SwapStrategy, sqrtPriceLimit osmomath.BigDec, err error) { + spreadFactor osmomath.Dec, tokenInDenom string, + priceLimit osmomath.Dec) (strategy swapstrategy.SwapStrategy, sqrtPriceLimit osmomath.BigDec, err error) { return k.setupSwapStrategy(p, spreadFactor, tokenInDenom, priceLimit) } diff --git a/x/concentrated-liquidity/fuzz_test.go b/x/concentrated-liquidity/fuzz_test.go index ea187940b9d..091c8e1dfa4 100644 --- a/x/concentrated-liquidity/fuzz_test.go +++ b/x/concentrated-liquidity/fuzz_test.go @@ -26,7 +26,7 @@ const ( type swapAmountsMismatchErr struct { swapInFunded sdk.Coin amountInSwapResult sdk.Coin - diff sdk.Int + diff osmomath.Int } func (e swapAmountsMismatchErr) Error() string { @@ -35,7 +35,7 @@ func (e swapAmountsMismatchErr) Error() string { type positionAndLiquidity struct { positionId uint64 - liquidity sdk.Dec + liquidity osmomath.Dec accountIndex int } @@ -204,7 +204,7 @@ func (s *KeeperTestSuite) swapNearNextTickBoundary(r *rand.Rand, pool types.Conc func (s *KeeperTestSuite) swapNearInitializedTickBoundary(r *rand.Rand, pool types.ConcentratedPoolExtension, zfo bool) (didSwap bool, fatalErr bool) { fmt.Println("swap type: near initialized tick boundary") - ss := swapstrategy.New(zfo, osmomath.ZeroDec(), s.App.GetKey(types.ModuleName), sdk.ZeroDec()) + ss := swapstrategy.New(zfo, osmomath.ZeroBigDec(), s.App.GetKey(types.ModuleName), osmomath.ZeroDec()) iter := ss.InitializeNextTickIterator(s.Ctx, pool.GetId(), pool.GetCurrentTick()) defer iter.Close() @@ -248,14 +248,14 @@ func (s *KeeperTestSuite) swapNearTickBoundary(r *rand.Rand, pool types.Concentr } // change tick amount to be at, above or below the target amount -func tickAmtChange(r *rand.Rand, targetAmount sdk.Dec) sdk.Dec { +func tickAmtChange(r *rand.Rand, targetAmount osmomath.Dec) osmomath.Dec { changeType := r.Intn(3) // Generate a random percentage under 0.1% - randChangePercent := sdk.NewDec(r.Int63n(1)).QuoInt64(1000) + randChangePercent := osmomath.NewDec(r.Int63n(1)).QuoInt64(1000) change := targetAmount.Mul(randChangePercent) - change = sdk.MaxDec(sdk.NewDec(1), randChangePercent) + change = sdk.MaxDec(osmomath.NewDec(1), randChangePercent) switch changeType { case 0: @@ -269,7 +269,7 @@ func tickAmtChange(r *rand.Rand, targetAmount sdk.Dec) sdk.Dec { return targetAmount.Add(change.TruncateDec()) } - if targetAmount.LTE(sdk.OneDec()) { + if targetAmount.LTE(osmomath.OneDec()) { fmt.Printf("tick amt change type: no change, orig: %s \n", targetAmount) return targetAmount } @@ -284,11 +284,11 @@ func (s *KeeperTestSuite) swap(pool types.ConcentratedPoolExtension, swapInFunde // Reason for adding one int: // Seed 1688658883- causes an error in swap in given out due to rounding (acceptable). This is because we use // token out from "swap out given in" as an input to "in given out". "in given out" rounds by one in pool's favor - s.FundAcc(s.TestAccs[0], sdk.NewCoins(swapInFunded).Add(sdk.NewCoin(swapInFunded.Denom, sdk.OneInt()))) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(swapInFunded).Add(sdk.NewCoin(swapInFunded.Denom, osmomath.OneInt()))) // // Execute swap fmt.Printf("swap in: %s\n", swapInFunded) cacheCtx, writeOutGivenIn := s.Ctx.CacheContext() - _, tokenOut, _, err := s.clk.SwapOutAmtGivenIn(cacheCtx, s.TestAccs[0], pool, swapInFunded, swapOutDenom, pool.GetSpreadFactor(s.Ctx), sdk.ZeroDec()) + _, tokenOut, _, err := s.clk.SwapOutAmtGivenIn(cacheCtx, s.TestAccs[0], pool, swapInFunded, swapOutDenom, pool.GetSpreadFactor(s.Ctx), osmomath.ZeroDec()) if errors.As(err, &types.InvalidAmountCalculatedError{}) { // If the swap we're about to execute will not generate enough output, we skip the swap. // it would error for a real user though. This is good though, since that user would just be burning funds. @@ -307,7 +307,7 @@ func (s *KeeperTestSuite) swap(pool types.ConcentratedPoolExtension, swapInFunde // We expect the returned amountIn to be roughly equal to the original swapInFunded. cacheCtx, _ = s.Ctx.CacheContext() fmt.Printf("swap out: %s\n", tokenOut) - amountInSwapResult, _, _, err := s.clk.SwapInAmtGivenOut(cacheCtx, s.TestAccs[0], pool, tokenOut, swapInFunded.Denom, pool.GetSpreadFactor(s.Ctx), sdk.ZeroDec()) + amountInSwapResult, _, _, err := s.clk.SwapInAmtGivenOut(cacheCtx, s.TestAccs[0], pool, tokenOut, swapInFunded.Denom, pool.GetSpreadFactor(s.Ctx), osmomath.ZeroDec()) if errors.As(err, &types.InvalidAmountCalculatedError{}) { // If the swap we're about to execute will not generate enough output, we skip the swap. // it would error for a real user though. This is good though, since that user would just be burning funds. @@ -325,14 +325,14 @@ func (s *KeeperTestSuite) swap(pool types.ConcentratedPoolExtension, swapInFunde errTolerance := osmomath.ErrTolerance{ // 2% tolerance - MultiplicativeTolerance: sdk.NewDecWithPrec(2, 2), + MultiplicativeTolerance: osmomath.NewDecWithPrec(2, 2), // Expected amount in returned from swap "in given out" to be smaller // than original amount in given to "out given in". // Reason: rounding in pool's favor. RoundingDir: osmomath.RoundDown, } - result := errTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(swapInFunded.Amount.ToDec()), osmomath.BigDecFromSDKDec(amountInSwapResult.Amount.ToDec())) + result := errTolerance.CompareBigDec(osmomath.BigDecFromDec(swapInFunded.Amount.ToLegacyDec()), osmomath.BigDecFromDec(amountInSwapResult.Amount.ToLegacyDec())) if result != 0 { // Note: did some investigations into why this happens. @@ -486,8 +486,8 @@ func (s *KeeperTestSuite) addRandomPositonMinMaxOneSpacing(r *rand.Rand, poolId } func (s *KeeperTestSuite) addRandomPositon(r *rand.Rand, poolId uint64, minTick, maxTick int64, tickSpacing int64) { - tokenDesired0 := sdk.NewCoin(ETH, sdk.NewInt(r.Int63n(maxAmountDeposited))) - tokenDesired1 := sdk.NewCoin(USDC, sdk.NewInt(r.Int63n(maxAmountDeposited))) + tokenDesired0 := sdk.NewCoin(ETH, osmomath.NewInt(r.Int63n(maxAmountDeposited))) + tokenDesired1 := sdk.NewCoin(USDC, osmomath.NewInt(r.Int63n(maxAmountDeposited))) tokensDesired := sdk.NewCoins(tokenDesired0, tokenDesired1) accountIndex := r.Intn(len(s.TestAccs)) @@ -500,7 +500,7 @@ func (s *KeeperTestSuite) addRandomPositon(r *rand.Rand, poolId uint64, minTick, fmt.Println("creating position: ", "accountName", "lowerTick", lowerTick, "upperTick", upperTick, "token0Desired", tokenDesired0, "tokenDesired1", tokenDesired1) - positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[accountIndex], tokensDesired, sdk.ZeroInt(), sdk.ZeroInt(), types.MinInitializedTick, types.MaxTick) + positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[accountIndex], tokensDesired, osmomath.ZeroInt(), osmomath.ZeroInt(), types.MinInitializedTick, types.MaxTick) s.Require().NoError(err) fmt.Printf("actually created: %s%s %s%s \n", positionData.Amount0, ETH, positionData.Amount1, USDC) @@ -546,15 +546,15 @@ func (s *KeeperTestSuite) removeRandomPosition(r *rand.Rand) { } // returns multiplier of the liqudity to withdraw -func (s *KeeperTestSuite) choosePartialOrFullWithdraw(r *rand.Rand) sdk.Dec { - multiplier := sdk.OneDec() +func (s *KeeperTestSuite) choosePartialOrFullWithdraw(r *rand.Rand) osmomath.Dec { + multiplier := osmomath.OneDec() if r.Intn(2) == 0 { // full withdraw return multiplier } // partial withdraw - multiplier = multiplier.Mul(sdk.NewDec(r.Int63n(100))).QuoInt64(100) + multiplier = multiplier.Mul(osmomath.NewDec(r.Int63n(100))).QuoInt64(100) return multiplier } @@ -579,6 +579,6 @@ func roundTickDownSpacing(tickIndex int64, tickSpacing int64) int64 { return tickIndex } -func randomIntAmount(r *rand.Rand) sdk.Int { - return sdk.NewInt(r.Int63n(maxAmountDeposited)) +func randomIntAmount(r *rand.Rand) osmomath.Int { + return osmomath.NewInt(r.Int63n(maxAmountDeposited)) } diff --git a/x/concentrated-liquidity/genesis.go b/x/concentrated-liquidity/genesis.go index 6933e07a2db..c11de7e56bc 100644 --- a/x/concentrated-liquidity/genesis.go +++ b/x/concentrated-liquidity/genesis.go @@ -7,6 +7,7 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/accum" types "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -240,7 +241,7 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *genesis.GenesisState { // initOrUpdateAccumPosition creates a new position or override an existing position // at accumulator's current value with a specific number of shares and unclaimed rewards -func (k Keeper) initOrUpdateAccumPosition(ctx sdk.Context, accumumulator *accum.AccumulatorObject, accumulatorValuePerShare sdk.DecCoins, index string, numShareUnits sdk.Dec, unclaimedRewardsTotal sdk.DecCoins, options *accum.Options) { +func (k Keeper) initOrUpdateAccumPosition(ctx sdk.Context, accumumulator *accum.AccumulatorObject, accumulatorValuePerShare sdk.DecCoins, index string, numShareUnits osmomath.Dec, unclaimedRewardsTotal sdk.DecCoins, options *accum.Options) { position := accum.Record{ NumShares: numShareUnits, AccumValuePerShare: accumulatorValuePerShare, diff --git a/x/concentrated-liquidity/genesis_test.go b/x/concentrated-liquidity/genesis_test.go index 5708561735f..63aa4fb80a5 100644 --- a/x/concentrated-liquidity/genesis_test.go +++ b/x/concentrated-liquidity/genesis_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/accum" osmoapp "github.com/osmosis-labs/osmosis/v19/app" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" @@ -32,7 +33,7 @@ var ( baseGenesis = genesis.GenesisState{ Params: types.Params{ AuthorizedTickSpacing: []uint64{1, 10, 100, 1000}, - AuthorizedSpreadFactors: []sdk.Dec{sdk.MustNewDecFromStr("0.0001"), sdk.MustNewDecFromStr("0.0003"), sdk.MustNewDecFromStr("0.0005")}, + AuthorizedSpreadFactors: []osmomath.Dec{osmomath.MustNewDecFromStr("0.0001"), osmomath.MustNewDecFromStr("0.0003"), osmomath.MustNewDecFromStr("0.0005")}, AuthorizedQuoteDenoms: []string{ETH, USDC}, BalancerSharesRewardDiscount: types.DefaultBalancerSharesDiscount, AuthorizedUptimes: types.DefaultAuthorizedUptimes, @@ -43,8 +44,8 @@ var ( } testCoins = sdk.NewDecCoins(cl.HundredFooCoins) testTickInfo = model.TickInfo{ - LiquidityGross: sdk.OneDec(), - LiquidityNet: sdk.OneDec(), + LiquidityGross: osmomath.OneDec(), + LiquidityNet: osmomath.OneDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: testCoins, UptimeTrackers: model.UptimeTrackers{ List: []model.UptimeTracker{ @@ -63,22 +64,22 @@ var ( PositionId: 1, PoolId: 1, Address: testAddressOne.String(), - Liquidity: sdk.OneDec(), + Liquidity: osmomath.OneDec(), LowerTick: -1, UpperTick: 100, JoinTime: defaultBlockTime, } testSpreadRewardAccumRecord = accum.Record{ - NumShares: sdk.OneDec(), - AccumValuePerShare: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - UnclaimedRewardsTotal: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(5))), + NumShares: osmomath.OneDec(), + AccumValuePerShare: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + UnclaimedRewardsTotal: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(5))), Options: nil, } accumRecord = accum.Record{ - NumShares: sdk.OneDec(), - AccumValuePerShare: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(50))), - UnclaimedRewardsTotal: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(25))), + NumShares: osmomath.OneDec(), + AccumValuePerShare: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(50))), + UnclaimedRewardsTotal: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(25))), Options: nil, } @@ -93,7 +94,7 @@ var ( } ) -func accumRecordWithDefinedValues(accumRecord accum.Record, numShares sdk.Dec, initAccumValue, unclaimedRewards sdk.Int) accum.Record { +func accumRecordWithDefinedValues(accumRecord accum.Record, numShares osmomath.Dec, initAccumValue, unclaimedRewards osmomath.Int) accum.Record { accumRecord.NumShares = numShares accumRecord.AccumValuePerShare = sdk.NewDecCoins(sdk.NewDecCoin("uion", initAccumValue)) accumRecord.UnclaimedRewardsTotal = sdk.NewDecCoins(sdk.NewDecCoin("uosmo", unclaimedRewards)) @@ -115,43 +116,43 @@ func incentiveAccumsWithPoolId(poolId uint64) []genesis.AccumObject { { Name: types.KeyUptimeAccumulator(poolId, uint64(0)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, { Name: types.KeyUptimeAccumulator(poolId, uint64(1)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", sdk.NewInt(20))), - TotalShares: sdk.NewDec(30), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(30), }, }, { Name: types.KeyUptimeAccumulator(poolId, uint64(2)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("baz", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("baz", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, { Name: types.KeyUptimeAccumulator(poolId, uint64(3)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("qux", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("qux", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, { Name: types.KeyUptimeAccumulator(poolId, uint64(4)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("quux", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("quux", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, { Name: types.KeyUptimeAccumulator(poolId, uint64(5)), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("quuux", sdk.NewInt(10))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("quuux", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(20), }, }, } @@ -232,20 +233,20 @@ func (s *KeeperTestSuite) TestInitGenesis() { Position: withPositionId(testPositionModel, 2), SpreadRewardAccumRecord: testSpreadRewardAccumRecord, UptimeAccumRecords: []accum.Record{ - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(10000), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1000), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(100), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(10), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1), sdk.NewInt(100), sdk.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(10000), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1000), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(100), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(10), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)), }, }, }, spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(1), @@ -253,8 +254,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(15)), - EmissionRate: sdk.NewDec(20), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(15)), + EmissionRate: osmomath.NewDec(20), StartTime: defaultTime2, }, MinUptime: testUptimeOne, @@ -263,8 +264,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -294,12 +295,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { Position: withPositionId(testPositionModel, 2), SpreadRewardAccumRecord: testSpreadRewardAccumRecord, UptimeAccumRecords: []accum.Record{ - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(10000), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1000), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(100), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(10), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(1), sdk.NewInt(100), sdk.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(10000), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1000), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(100), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(10), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(1), osmomath.NewInt(100), osmomath.NewInt(50)), }, }, }, @@ -307,8 +308,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { Name: types.KeySpreadRewardPoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, }, @@ -316,8 +317,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(15)), - EmissionRate: sdk.NewDec(20), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(15)), + EmissionRate: osmomath.NewDec(20), StartTime: defaultTime2, }, MinUptime: testUptimeOne, @@ -325,8 +326,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -352,8 +353,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(1), @@ -361,8 +362,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -381,12 +382,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { LockId: 2, Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+1), UptimeAccumRecords: []accum.Record{ - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(999), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(999), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), }, }, }, @@ -394,8 +395,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(2), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(2), @@ -403,8 +404,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(2), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -430,15 +431,15 @@ func (s *KeeperTestSuite) TestInitGenesis() { { Name: types.KeySpreadRewardPoolAccumulator(1), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, { Name: types.KeySpreadRewardPoolAccumulator(2), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, }, @@ -446,8 +447,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -455,8 +456,8 @@ func (s *KeeperTestSuite) TestInitGenesis() { { PoolId: uint64(2), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -474,12 +475,12 @@ func (s *KeeperTestSuite) TestInitGenesis() { Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+1), SpreadRewardAccumRecord: testSpreadRewardAccumRecord, UptimeAccumRecords: []accum.Record{ - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(999), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(999), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), }, }, }, @@ -636,8 +637,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(poolOne.Id), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(1), @@ -645,8 +646,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(15)), - EmissionRate: sdk.NewDec(20), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(15)), + EmissionRate: osmomath.NewDec(20), StartTime: defaultTime2, }, MinUptime: testUptimeOne, @@ -655,8 +656,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -691,8 +692,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(poolOne.Id), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(10))), - TotalShares: sdk.NewDec(10), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(10))), + TotalShares: osmomath.NewDec(10), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(1), @@ -700,8 +701,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { { PoolId: uint64(1), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("foo", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("foo", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -717,8 +718,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { spreadFactorAccumValues: genesis.AccumObject{ Name: types.KeySpreadRewardPoolAccumulator(poolTwo.Id), AccumContent: &accum.AccumulatorContent{ - AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", sdk.NewInt(20))), - TotalShares: sdk.NewDec(20), + AccumValue: sdk.NewDecCoins(sdk.NewDecCoin("bar", osmomath.NewInt(20))), + TotalShares: osmomath.NewDec(20), }, }, incentiveAccumulators: incentiveAccumsWithPoolId(2), @@ -726,8 +727,8 @@ func (s *KeeperTestSuite) TestExportGenesis() { { PoolId: uint64(2), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoin("bar", sdk.NewInt(5)), - EmissionRate: sdk.NewDec(10), + RemainingCoin: sdk.NewDecCoin("bar", osmomath.NewInt(5)), + EmissionRate: osmomath.NewDec(10), StartTime: defaultTime1, }, MinUptime: testUptimeOne, @@ -739,12 +740,12 @@ func (s *KeeperTestSuite) TestExportGenesis() { Position: withPositionId(*positionWithPoolId(testPositionModel, 2), DefaultPositionId+2), SpreadRewardAccumRecord: testSpreadRewardAccumRecord, UptimeAccumRecords: []accum.Record{ - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9999), sdk.NewInt(10), sdk.NewInt(5)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(999), sdk.NewInt(100), sdk.NewInt(50)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(99), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), - accumRecordWithDefinedValues(accumRecord, sdk.NewDec(9), sdk.NewInt(50), sdk.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9999), osmomath.NewInt(10), osmomath.NewInt(5)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(999), osmomath.NewInt(100), osmomath.NewInt(50)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(99), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), + accumRecordWithDefinedValues(accumRecord, osmomath.NewDec(9), osmomath.NewInt(50), osmomath.NewInt(25)), }, }, }, diff --git a/x/concentrated-liquidity/incentives.go b/x/concentrated-liquidity/incentives.go index 87eca2f10b2..25e149fbda8 100644 --- a/x/concentrated-liquidity/incentives.go +++ b/x/concentrated-liquidity/incentives.go @@ -119,7 +119,7 @@ func (k Keeper) getInitialUptimeGrowthOppositeDirectionOfLastTraversalForTick(ct // CONTRACT: the caller validates that the pool with the given id exists. // CONTRACT: caller is responsible for the uptimeAccums to be up-to-date. // CONTRACT: uptimeAccums are associated with the given pool id. -func (k Keeper) prepareBalancerPoolAsFullRange(ctx sdk.Context, clPoolId uint64, uptimeAccums []*accum.AccumulatorObject) (uint64, sdk.Dec, error) { +func (k Keeper) prepareBalancerPoolAsFullRange(ctx sdk.Context, clPoolId uint64, uptimeAccums []*accum.AccumulatorObject) (uint64, osmomath.Dec, error) { // Get CL pool from ID clPool, err := k.getPoolById(ctx, clPoolId) if err != nil { @@ -157,13 +157,13 @@ func (k Keeper) prepareBalancerPoolAsFullRange(ctx sdk.Context, clPoolId uint64, } // Calculate portion of Balancer pool shares that are bonded - bondedShareRatio := bondedShares.ToDec().Quo(totalBalancerPoolShares.ToDec()) + bondedShareRatio := bondedShares.ToLegacyDec().Quo(totalBalancerPoolShares.ToLegacyDec()) // Calculate rough number of assets in Balancer pool that are bonded balancerPoolLiquidity := sdk.NewCoins() for _, liquidityToken := range totalBalancerPoolLiquidity { // Rounding behavior is not critical here, but for simplicity we do bankers multiplication then truncate. - bondedLiquidityAmount := liquidityToken.Amount.ToDec().Mul(bondedShareRatio).TruncateInt() + bondedLiquidityAmount := liquidityToken.Amount.ToLegacyDec().Mul(bondedShareRatio).TruncateInt() balancerPoolLiquidity = balancerPoolLiquidity.Add(sdk.NewCoin(liquidityToken.Denom, bondedLiquidityAmount)) } @@ -193,7 +193,7 @@ func (k Keeper) prepareBalancerPoolAsFullRange(ctx sdk.Context, clPoolId uint64, // Calculate the amount of liquidity the Balancer amounts qualify in the CL pool. Note that since we use the CL spot price, this is // safe against prices drifting apart between the two pools (we take the lower bound on the qualifying liquidity in this case). // The `sqrtPriceLowerTick` and `sqrtPriceUpperTick` fields are set to the appropriate values for a full range position. - qualifyingFullRangeSharesPreDiscount := math.GetLiquidityFromAmounts(clPool.GetCurrentSqrtPrice(), osmomath.BigDecFromSDKDec(types.MinSqrtPrice), osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), asset0Amount, asset1Amount) + qualifyingFullRangeSharesPreDiscount := math.GetLiquidityFromAmounts(clPool.GetCurrentSqrtPrice(), osmomath.BigDecFromDec(types.MinSqrtPrice), osmomath.BigDecFromDec(types.MaxSqrtPrice), asset0Amount, asset1Amount) // Get discount ratio from governance-set discount rate. // Note that discount rate is the amount that is being discounted by (e.g. 0.05 for a 5% discount), while discount ratio is what @@ -339,7 +339,7 @@ func (k Keeper) updatePoolUptimeAccumulatorsToNowWithPool(ctx sdk.Context, pool return nil } -var dec1e9 = sdk.NewDec(1e9) +var dec1e9 = osmomath.NewDec(1e9) // updateGivenPoolUptimeAccumulatorsToNow syncs all given uptime accumulators for a given pool id // Updates the pool last liquidity update time with the current block time and writes the updated pool to state. @@ -363,7 +363,7 @@ func (k Keeper) updateGivenPoolUptimeAccumulatorsToNow(ctx sdk.Context, pool typ // Since our base unit of time is nanoseconds, we divide with truncation by 10^9 to get // time elapsed in seconds - timeElapsedNanoSec := sdk.NewDec(int64(ctx.BlockTime().Sub(pool.GetLastLiquidityUpdate()))) + timeElapsedNanoSec := osmomath.NewDec(int64(ctx.BlockTime().Sub(pool.GetLastLiquidityUpdate()))) timeElapsedSec := timeElapsedNanoSec.Quo(dec1e9) // If no time has elapsed, this function is a no-op @@ -396,7 +396,7 @@ func (k Keeper) updateGivenPoolUptimeAccumulatorsToNow(ctx sdk.Context, pool typ // If there is no share to be incentivized for the current uptime accumulator, we leave it unchanged qualifyingLiquidity := pool.GetLiquidity().Add(qualifyingBalancerShares) - if !qualifyingLiquidity.LT(sdk.OneDec()) { + if !qualifyingLiquidity.LT(osmomath.OneDec()) { for uptimeIndex := range uptimeAccums { // Get relevant uptime-level values curUptimeDuration := types.SupportedUptimes[uptimeIndex] @@ -447,7 +447,7 @@ func (k Keeper) updateGivenPoolUptimeAccumulatorsToNow(ctx sdk.Context, pool typ // Returns the IncentivesPerLiquidity value and an updated list of IncentiveRecords that // reflect emitted incentives // Returns error if the qualifying liquidity/time elapsed are zero. -func calcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, liquidityInAccum sdk.Dec, timeElapsed sdk.Dec, poolIncentiveRecords []types.IncentiveRecord) (sdk.DecCoins, []types.IncentiveRecord, error) { +func calcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, liquidityInAccum osmomath.Dec, timeElapsed osmomath.Dec, poolIncentiveRecords []types.IncentiveRecord) (sdk.DecCoins, []types.IncentiveRecord, error) { if !liquidityInAccum.IsPositive() || !timeElapsed.IsPositive() { return sdk.DecCoins{}, []types.IncentiveRecord{}, types.QualifyingLiquidityOrTimeElapsedNotPositiveError{QualifyingLiquidity: liquidityInAccum, TimeElapsed: timeElapsed} } @@ -490,7 +490,7 @@ func calcAccruedIncentivesForAccum(ctx sdk.Context, accumUptime time.Duration, l emittedIncentivesPerLiquidity = sdk.NewDecCoinFromDec(incentiveRecordBody.RemainingCoin.Denom, remainingIncentivesPerLiquidity) incentivesToAddToCurAccum = incentivesToAddToCurAccum.Add(emittedIncentivesPerLiquidity) - copyPoolIncentiveRecords[incentiveIndex].IncentiveRecordBody.RemainingCoin.Amount = sdk.ZeroDec() + copyPoolIncentiveRecords[incentiveIndex].IncentiveRecordBody.RemainingCoin.Amount = osmomath.ZeroDec() } } @@ -722,7 +722,7 @@ func (k Keeper) GetUptimeGrowthOutsideRange(ctx sdk.Context, poolId uint64, lowe // - fails to determine if position accumulator is new or existing // - fails to create/update position uptime accumulators // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) initOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, liquidity sdk.Dec, lowerTick, upperTick int64, liquidityDelta sdk.Dec, positionId uint64) error { +func (k Keeper) initOrUpdatePositionUptimeAccumulators(ctx sdk.Context, poolId uint64, liquidity osmomath.Dec, lowerTick, upperTick int64, liquidityDelta osmomath.Dec, positionId uint64) error { // We update accumulators _prior_ to any position-related updates to ensure // past rewards aren't distributed to new liquidity. We also update pool's // LastLiquidityUpdate here. @@ -1020,7 +1020,7 @@ func (k Keeper) collectIncentives(ctx sdk.Context, sender sdk.AccAddress, positi // - minUptime is not an authorizedUptime. // - other internal database or math errors. // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveCoin sdk.Coin, emissionRate sdk.Dec, startTime time.Time, minUptime time.Duration) (types.IncentiveRecord, error) { +func (k Keeper) CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveCoin sdk.Coin, emissionRate osmomath.Dec, startTime time.Time, minUptime time.Duration) (types.IncentiveRecord, error) { pool, err := k.getPoolById(ctx, poolId) if err != nil { return types.IncentiveRecord{}, err diff --git a/x/concentrated-liquidity/incentives_test.go b/x/concentrated-liquidity/incentives_test.go index 8694bed795c..a600c6deef9 100644 --- a/x/concentrated-liquidity/incentives_test.go +++ b/x/concentrated-liquidity/incentives_test.go @@ -25,7 +25,7 @@ import ( var ( defaultPoolId = uint64(1) - defaultMultiplier = sdk.OneInt() + defaultMultiplier = osmomath.OneInt() testAddressOne = sdk.MustAccAddressFromBech32("osmo1cyyzpxplxdzkeea7kwsydadg87357qnahakaks") testAddressTwo = sdk.MustAccAddressFromBech32("osmo18s5lynnmx37hq4wlrw9gdn68sg2uxp5rgk26vv") @@ -38,13 +38,13 @@ var ( testDenomThree = "denomThree" testDenomFour = "denomFour" - defaultIncentiveAmount = sdk.NewDec(2 << 60) + defaultIncentiveAmount = osmomath.NewDec(2 << 60) defaultIncentiveRecordId = uint64(1) - testEmissionOne = sdk.MustNewDecFromStr("0.000001") - testEmissionTwo = sdk.MustNewDecFromStr("0.0783") - testEmissionThree = sdk.MustNewDecFromStr("165.4") - testEmissionFour = sdk.MustNewDecFromStr("57.93") + testEmissionOne = osmomath.MustNewDecFromStr("0.000001") + testEmissionTwo = osmomath.MustNewDecFromStr("0.0783") + testEmissionThree = osmomath.MustNewDecFromStr("165.4") + testEmissionFour = osmomath.MustNewDecFromStr("57.93") defaultBlockTime = time.Unix(1, 1).UTC() defaultTimeBuffer = time.Hour @@ -102,7 +102,7 @@ var ( emptyIncentiveRecord = types.IncentiveRecord{ PoolId: validPoolId, IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoinFromDec("emptyDenom", sdk.ZeroDec()), + RemainingCoin: sdk.NewDecCoinFromDec("emptyDenom", osmomath.ZeroDec()), EmissionRate: testEmissionFour, StartTime: defaultStartTime, }, @@ -110,14 +110,14 @@ var ( IncentiveId: defaultIncentiveRecordId + 4, } - testQualifyingDepositsOne = sdk.NewInt(50) + testQualifyingDepositsOne = osmomath.NewInt(50) defaultBalancerAssets = []balancer.PoolAsset{ - {Weight: sdk.NewInt(1), Token: sdk.NewCoin("foo", sdk.NewInt(100))}, - {Weight: sdk.NewInt(1), Token: sdk.NewCoin("bar", sdk.NewInt(100))}, + {Weight: osmomath.NewInt(1), Token: sdk.NewCoin("foo", osmomath.NewInt(100))}, + {Weight: osmomath.NewInt(1), Token: sdk.NewCoin("bar", osmomath.NewInt(100))}, } - defaultConcentratedAssets = sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)), sdk.NewCoin("bar", sdk.NewInt(100))) - defaultBalancerPoolParams = balancer.PoolParams{SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDec(0)} + defaultConcentratedAssets = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100)), sdk.NewCoin("bar", osmomath.NewInt(100))) + defaultBalancerPoolParams = balancer.PoolParams{SwapFee: osmomath.NewDec(0), ExitFee: osmomath.NewDec(0)} invalidPoolId = uint64(10) ) @@ -157,8 +157,8 @@ func getExpectedUptimes() ExpectedUptimes { expUptimes.threeHundredTokensMultiDenom = append(expUptimes.threeHundredTokensMultiDenom, sdk.NewDecCoins(cl.TwoHundredFooCoins.Add(cl.HundredFooCoins), cl.TwoHundredBarCoins.Add(cl.HundredBarCoins))) expUptimes.fourHundredTokensMultiDenom = append(expUptimes.fourHundredTokensMultiDenom, sdk.NewDecCoins(cl.TwoHundredFooCoins.Add(cl.TwoHundredFooCoins), cl.TwoHundredBarCoins.Add(cl.TwoHundredBarCoins))) expUptimes.sixHundredTokensMultiDenom = append(expUptimes.sixHundredTokensMultiDenom, sdk.NewDecCoins(cl.TwoHundredFooCoins.Add(cl.TwoHundredFooCoins).Add(cl.TwoHundredFooCoins), cl.TwoHundredBarCoins.Add(cl.TwoHundredBarCoins).Add(cl.TwoHundredBarCoins))) - expUptimes.varyingTokensSingleDenom = append(expUptimes.varyingTokensSingleDenom, sdk.NewDecCoins(cl.HundredFooCoins.Add(sdk.NewDecCoin("foo", sdk.NewInt(int64(i)))))) - expUptimes.varyingTokensMultiDenom = append(expUptimes.varyingTokensMultiDenom, sdk.NewDecCoins(cl.HundredFooCoins.Add(sdk.NewDecCoin("foo", sdk.NewInt(int64(i)))), cl.HundredBarCoins.Add(sdk.NewDecCoin("bar", sdk.NewInt(int64(i*3)))))) + expUptimes.varyingTokensSingleDenom = append(expUptimes.varyingTokensSingleDenom, sdk.NewDecCoins(cl.HundredFooCoins.Add(sdk.NewDecCoin("foo", osmomath.NewInt(int64(i)))))) + expUptimes.varyingTokensMultiDenom = append(expUptimes.varyingTokensMultiDenom, sdk.NewDecCoins(cl.HundredFooCoins.Add(sdk.NewDecCoin("foo", osmomath.NewInt(int64(i)))), cl.HundredBarCoins.Add(sdk.NewDecCoin("bar", osmomath.NewInt(int64(i*3)))))) } return expUptimes @@ -175,8 +175,8 @@ func wrapUptimeTrackers(accumValues []sdk.DecCoins) []model.UptimeTracker { } // expectedIncentivesFromRate calculates the amount of incentives we expect to accrue based on the rate and time elapsed -func expectedIncentivesFromRate(denom string, rate sdk.Dec, timeElapsed time.Duration, qualifyingLiquidity sdk.Dec) sdk.DecCoin { - timeInSec := sdk.NewDec(int64(timeElapsed)).Quo(sdk.MustNewDecFromStr("1000000000")) +func expectedIncentivesFromRate(denom string, rate osmomath.Dec, timeElapsed time.Duration, qualifyingLiquidity osmomath.Dec) sdk.DecCoin { + timeInSec := osmomath.NewDec(int64(timeElapsed)).Quo(osmomath.MustNewDecFromStr("1000000000")) amount := rate.Mul(timeInSec).QuoTruncate(qualifyingLiquidity) return sdk.NewDecCoinFromDec(denom, amount) @@ -188,12 +188,12 @@ func expectedIncentivesFromRate(denom string, rate sdk.Dec, timeElapsed time.Dur // towards result. Takes in a multiplier parameter for further versatility in testing. // // Returns value as truncated sdk.Coins as the primary use of this helper is testing higher level incentives functions such as claiming. -func expectedIncentivesFromUptimeGrowth(uptimeGrowths []sdk.DecCoins, positionShares sdk.Dec, timeInPool time.Duration, multiplier sdk.Int) sdk.Coins { +func expectedIncentivesFromUptimeGrowth(uptimeGrowths []sdk.DecCoins, positionShares osmomath.Dec, timeInPool time.Duration, multiplier osmomath.Int) sdk.Coins { // Sum up rewards from all inputs totalRewards := sdk.Coins(nil) for uptimeIndex, uptimeGrowth := range uptimeGrowths { if timeInPool >= types.SupportedUptimes[uptimeIndex] { - curRewards := uptimeGrowth.MulDecTruncate(positionShares).MulDecTruncate(multiplier.ToDec()) + curRewards := uptimeGrowth.MulDecTruncate(positionShares).MulDecTruncate(multiplier.ToLegacyDec()) totalRewards = totalRewards.Add(sdk.NormalizeCoins(curRewards)...) } } @@ -204,7 +204,7 @@ func expectedIncentivesFromUptimeGrowth(uptimeGrowths []sdk.DecCoins, positionSh // chargeIncentiveRecord updates the remaining amount of the passed in incentive record to what it would be after `timeElapsed` of emissions. func chargeIncentiveRecord(incentiveRecord types.IncentiveRecord, timeElapsed time.Duration) types.IncentiveRecord { secToNanoSec := int64(1000000000) - incentivesEmitted := incentiveRecord.IncentiveRecordBody.EmissionRate.Mul(sdk.NewDec(int64(timeElapsed)).Quo(sdk.NewDec(secToNanoSec))) + incentivesEmitted := incentiveRecord.IncentiveRecordBody.EmissionRate.Mul(osmomath.NewDec(int64(timeElapsed)).Quo(osmomath.NewDec(secToNanoSec))) incentiveRecord.IncentiveRecordBody.RemainingCoin.Amount = incentiveRecord.IncentiveRecordBody.RemainingCoin.Amount.Sub(incentivesEmitted) return incentiveRecord @@ -230,7 +230,7 @@ func withDenom(record types.IncentiveRecord, denom string) types.IncentiveRecord return record } -func withAmount(record types.IncentiveRecord, amount sdk.Dec) types.IncentiveRecord { +func withAmount(record types.IncentiveRecord, amount osmomath.Dec) types.IncentiveRecord { record.IncentiveRecordBody.RemainingCoin.Amount = amount return record @@ -248,7 +248,7 @@ func withMinUptime(record types.IncentiveRecord, minUptime time.Duration) types. return record } -func withEmissionRate(record types.IncentiveRecord, emissionRate sdk.Dec) types.IncentiveRecord { +func withEmissionRate(record types.IncentiveRecord, emissionRate osmomath.Dec) types.IncentiveRecord { record.IncentiveRecordBody.EmissionRate = emissionRate return record @@ -505,7 +505,7 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { type calcAccruedIncentivesTest struct { poolId uint64 accumUptime time.Duration - qualifyingLiquidity sdk.Dec + qualifyingLiquidity osmomath.Dec timeElapsed time.Duration poolIncentiveRecords []types.IncentiveRecord recordsCleared bool @@ -518,12 +518,12 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "one incentive record, one qualifying for incentives": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne}, expectedResult: sdk.DecCoins{ - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), }, expectedIncentiveRecords: []types.IncentiveRecord{chargeIncentiveRecord(incentiveRecordOne, time.Hour)}, expectedPass: true, @@ -531,7 +531,7 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "one incentive record, one qualifying for incentives, start time after current block time": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOneWithStartTimeAfterBlockTime}, @@ -542,13 +542,13 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "two incentive records, one with qualifying liquidity for incentives": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne, incentiveRecordTwo}, expectedResult: sdk.DecCoins{ // We only expect the first incentive record to qualify - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), }, expectedIncentiveRecords: []types.IncentiveRecord{ // We only charge the first incentive record since the second wasn't affected @@ -560,23 +560,23 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "fully emit all incentives in record, significant time elapsed": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(123), + qualifyingLiquidity: osmomath.NewDec(123), // Time elapsed is strictly greater than the time needed to emit all incentives timeElapsed: time.Duration((1 << 63) - 1), poolIncentiveRecords: []types.IncentiveRecord{ // We set the emission rate high enough to drain the record in one timestep - withEmissionRate(incentiveRecordOne, sdk.NewDec(2<<60)), + withEmissionRate(incentiveRecordOne, osmomath.NewDec(2<<60)), }, recordsCleared: true, // We expect the fully incentive amount to be emitted expectedResult: sdk.DecCoins{ - sdk.NewDecCoinFromDec(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Amount.QuoTruncate(sdk.NewDec(123))), + sdk.NewDecCoinFromDec(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Amount.QuoTruncate(osmomath.NewDec(123))), }, - // Incentive record should have zero remaining amount - expectedIncentiveRecords: []types.IncentiveRecord{withAmount(withEmissionRate(incentiveRecordOne, sdk.NewDec(2<<60)), sdk.ZeroDec())}, + // Incentive record should have zero remaining amountosmomath.ZeroDec + expectedIncentiveRecords: []types.IncentiveRecord{withAmount(withEmissionRate(incentiveRecordOne, osmomath.NewDec(2<<60)), osmomath.ZeroDec())}, expectedPass: true, }, @@ -584,7 +584,7 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "zero qualifying liquidity": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(0), + qualifyingLiquidity: osmomath.NewDec(0), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne}, @@ -595,7 +595,7 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "zero time elapsed": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Duration(0), poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne}, @@ -606,14 +606,14 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "two incentive records with same denom, different start time": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne, incentiveRecordOneWithDifferentStartTime}, expectedResult: sdk.NewDecCoins( // We expect both incentive records to qualify - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate.Add(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.EmissionRate), time.Hour, sdk.NewDec(100)), // since we have 2 records with same denom, the rate of emission went up x2 + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate.Add(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.EmissionRate), time.Hour, osmomath.NewDec(100)), // since we have 2 records with same denom, the rate of emission went up x2 ), expectedIncentiveRecords: []types.IncentiveRecord{ // We only going to charge both incentive records @@ -625,15 +625,15 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "two incentive records with different denom, different start time and same uptime": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOneWithDifferentStartTime, incentiveRecordOneWithDifferentDenom}, expectedResult: sdk.DecCoins{ // We expect both incentive record to qualify - expectedIncentivesFromRate(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), - expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), }, expectedIncentiveRecords: []types.IncentiveRecord{ // We charge both incentive record here because both minUpTime has been hit @@ -645,14 +645,14 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "two incentive records with same denom, different min up-time": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne, incentiveRecordOneWithDifferentMinUpTime}, expectedResult: sdk.DecCoins{ // We expect first incentive record to qualify - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), }, expectedIncentiveRecords: []types.IncentiveRecord{ // We only charge the first incentive record because the second minUpTime hasn't been hit yet @@ -664,15 +664,15 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "two incentive records with same accum uptime and start time across multiple records with different denoms": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne, incentiveRecordOneWithDifferentDenom}, expectedResult: sdk.DecCoins{ // We expect both incentive record to qualify - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), - expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), }, expectedIncentiveRecords: []types.IncentiveRecord{ // We charge both incentive record here because both minUpTime has been hit @@ -684,15 +684,15 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { "four incentive records with only two eligilbe for emitting incentives": { poolId: defaultPoolId, accumUptime: types.SupportedUptimes[0], - qualifyingLiquidity: sdk.NewDec(100), + qualifyingLiquidity: osmomath.NewDec(100), timeElapsed: time.Hour, poolIncentiveRecords: []types.IncentiveRecord{incentiveRecordOne, incentiveRecordOneWithDifferentStartTime, incentiveRecordOneWithDifferentDenom, incentiveRecordOneWithDifferentMinUpTime}, expectedResult: sdk.NewDecCoins( // We expect three incentive record to qualify for incentive - expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate.Add(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.EmissionRate), time.Hour, sdk.NewDec(100)), - expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, sdk.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate.Add(incentiveRecordOneWithDifferentStartTime.IncentiveRecordBody.EmissionRate), time.Hour, osmomath.NewDec(100)), + expectedIncentivesFromRate(incentiveRecordOneWithDifferentDenom.IncentiveRecordBody.RemainingCoin.Denom, incentiveRecordOne.IncentiveRecordBody.EmissionRate, time.Hour, osmomath.NewDec(100)), ), expectedIncentiveRecords: []types.IncentiveRecord{ // We only charge the first three incentive record because the fourth minUpTime hasn't been hit yet @@ -715,7 +715,7 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { s.PrepareConcentratedPool() // system under test - actualResult, updatedPoolRecords, err := cl.CalcAccruedIncentivesForAccum(s.Ctx, tc.accumUptime, tc.qualifyingLiquidity, sdk.NewDec(int64(tc.timeElapsed)).Quo(sdk.MustNewDecFromStr("1000000000")), tc.poolIncentiveRecords) + actualResult, updatedPoolRecords, err := cl.CalcAccruedIncentivesForAccum(s.Ctx, tc.accumUptime, tc.qualifyingLiquidity, osmomath.NewDec(int64(tc.timeElapsed)).Quo(osmomath.MustNewDecFromStr("1000000000")), tc.poolIncentiveRecords) if tc.expectedPass { s.Require().NoError(err) @@ -738,11 +738,11 @@ func (s *KeeperTestSuite) TestCalcAccruedIncentivesForAccum() { }) } -func (s *KeeperTestSuite) setupBalancerPoolWithFractionLocked(pa []balancer.PoolAsset, fraction sdk.Dec) uint64 { +func (s *KeeperTestSuite) setupBalancerPoolWithFractionLocked(pa []balancer.PoolAsset, fraction osmomath.Dec) uint64 { balancerPoolId := s.PrepareCustomBalancerPool(pa, defaultBalancerPoolParams) longestLockableDuration, err := s.App.PoolIncentivesKeeper.GetLongestLockableDuration(s.Ctx) s.Require().NoError(err) - lockAmt := gammtypes.InitPoolSharesSupply.ToDec().Mul(fraction).TruncateInt() + lockAmt := gammtypes.InitPoolSharesSupply.ToLegacyDec().Mul(fraction).TruncateInt() lockCoins := sdk.NewCoins(sdk.NewCoin(gammtypes.GetPoolShareDenom(balancerPoolId), lockAmt)) _, err = s.App.LockupKeeper.CreateLock(s.Ctx, s.TestAccs[0], lockCoins, longestLockableDuration) s.Require().NoError(err) @@ -1057,7 +1057,7 @@ func (s *KeeperTestSuite) TestUpdateUptimeAccumulatorsToNow() { clPool, err = clKeeper.GetPoolById(s.Ctx, clPool.GetId()) s.Require().NoError(err) if tc.canonicalBalancerPoolAssets != nil { - qualifyingBalancerLiquidityPreDiscount := math.GetLiquidityFromAmounts(clPool.GetCurrentSqrtPrice(), osmomath.BigDecFromSDKDec(types.MinSqrtPrice), osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), tc.canonicalBalancerPoolAssets[0].Token.Amount, tc.canonicalBalancerPoolAssets[1].Token.Amount) + qualifyingBalancerLiquidityPreDiscount := math.GetLiquidityFromAmounts(clPool.GetCurrentSqrtPrice(), osmomath.BigDecFromDec(types.MinSqrtPrice), osmomath.BigDecFromDec(types.MaxSqrtPrice), tc.canonicalBalancerPoolAssets[0].Token.Amount, tc.canonicalBalancerPoolAssets[1].Token.Amount) qualifyingBalancerLiquidity = (sdk.OneDec().Sub(types.DefaultBalancerSharesDiscount)).Mul(qualifyingBalancerLiquidityPreDiscount) qualifyingLiquidity = qualifyingLiquidity.Add(qualifyingBalancerLiquidity) @@ -1225,7 +1225,7 @@ func (s *KeeperTestSuite) TestGetInitialUptimeGrowthOppositeDirectionOfLastTrave // Test uptime growth inside and outside range. func (s *KeeperTestSuite) TestGetUptimeGrowthRange() { - defaultInitialLiquidity := sdk.OneDec() + defaultInitialLiquidity := osmomath.OneDec() uptimeHelper := getExpectedUptimes() type uptimeGrowthTest struct { @@ -1562,7 +1562,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { } tests := map[string]struct { - positionLiquidity sdk.Dec + positionLiquidity osmomath.Dec lowerTick tick upperTick tick @@ -1717,39 +1717,39 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { globalUptimeAccumValues: []sdk.DecCoins{ sdk.NewDecCoins( // 100 + 100 + UGI = 300 - sdk.NewDecCoin("bar", sdk.NewInt(300)), + sdk.NewDecCoin("bar", osmomath.NewInt(300)), // 100 + 100 + UGI = 300 - sdk.NewDecCoin("foo", sdk.NewInt(300)), + sdk.NewDecCoin("foo", osmomath.NewInt(300)), ), sdk.NewDecCoins( // 100 + 103 + UGI = 303 - sdk.NewDecCoin("bar", sdk.NewInt(303)), + sdk.NewDecCoin("bar", osmomath.NewInt(303)), // 100 + 101 + UGI = 301 - sdk.NewDecCoin("foo", sdk.NewInt(301)), + sdk.NewDecCoin("foo", osmomath.NewInt(301)), ), sdk.NewDecCoins( // 100 + 106 + UGI = 306 - sdk.NewDecCoin("bar", sdk.NewInt(306)), + sdk.NewDecCoin("bar", osmomath.NewInt(306)), // 100 + 102 + UGI = 302 - sdk.NewDecCoin("foo", sdk.NewInt(302)), + sdk.NewDecCoin("foo", osmomath.NewInt(302)), ), sdk.NewDecCoins( // 100 + 109 + UGI = 309 - sdk.NewDecCoin("bar", sdk.NewInt(309)), + sdk.NewDecCoin("bar", osmomath.NewInt(309)), // 100 + 103 + UGI = 303 - sdk.NewDecCoin("foo", sdk.NewInt(303)), + sdk.NewDecCoin("foo", osmomath.NewInt(303)), ), sdk.NewDecCoins( // 100 + 112 + UGI = 312 - sdk.NewDecCoin("bar", sdk.NewInt(312)), + sdk.NewDecCoin("bar", osmomath.NewInt(312)), // 100 + 104 + UGI = 304 - sdk.NewDecCoin("foo", sdk.NewInt(304)), + sdk.NewDecCoin("foo", osmomath.NewInt(304)), ), sdk.NewDecCoins( // 100 + 115 + UGI = 315 - sdk.NewDecCoin("bar", sdk.NewInt(315)), + sdk.NewDecCoin("bar", osmomath.NewInt(315)), // 100 + 105 + UGI = 305 - sdk.NewDecCoin("foo", sdk.NewInt(305)), + sdk.NewDecCoin("foo", osmomath.NewInt(305)), ), }, // Equal to 100 of foo and bar in each uptime tracker (UGI) @@ -1787,9 +1787,9 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { clPool := s.PrepareConcentratedPool() - // Initialize lower, upper, and current ticks - s.initializeTick(s.Ctx, test.currentTickIndex, test.lowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.lowerTick.uptimeTrackers, true) - s.initializeTick(s.Ctx, test.currentTickIndex, test.upperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.upperTick.uptimeTrackers, false) + // Initialize lower, upper, and current ticksosmomath.ZeroDec + s.initializeTick(s.Ctx, test.currentTickIndex, test.lowerTick.tickIndex, osmomath.ZeroDec(), cl.EmptyCoins, test.lowerTick.uptimeTrackers, true) + s.initializeTick(s.Ctx, test.currentTickIndex, test.upperTick.tickIndex, osmomath.ZeroDec(), cl.EmptyCoins, test.upperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) err := s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) s.Require().NoError(err) @@ -1804,9 +1804,8 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { s.Require().NoError(err) err = s.App.ConcentratedLiquidityKeeper.SetPosition(s.Ctx, clPool.GetId(), s.TestAccs[0], test.lowerTick.tickIndex, test.upperTick.tickIndex, DefaultJoinTime, test.positionLiquidity, DefaultPositionId, DefaultUnderlyingLockId) s.Require().NoError(err) - - s.initializeTick(s.Ctx, test.currentTickIndex, test.newLowerTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newLowerTick.uptimeTrackers, true) - s.initializeTick(s.Ctx, test.currentTickIndex, test.newUpperTick.tickIndex, sdk.ZeroDec(), cl.EmptyCoins, test.newUpperTick.uptimeTrackers, false) + s.initializeTick(s.Ctx, test.currentTickIndex, test.newLowerTick.tickIndex, osmomath.ZeroDec(), cl.EmptyCoins, test.newLowerTick.uptimeTrackers, true) + s.initializeTick(s.Ctx, test.currentTickIndex, test.newUpperTick.tickIndex, osmomath.ZeroDec(), cl.EmptyCoins, test.newUpperTick.uptimeTrackers, false) clPool.SetCurrentTick(test.currentTickIndex) err = s.App.ConcentratedLiquidityKeeper.SetPool(s.Ctx, clPool) s.Require().NoError(err) @@ -1847,7 +1846,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionUptimeAccumulators() { s.Require().Equal(test.expectedInitAccumValue[uptimeIndex], positionRecord.AccumValuePerShare) if test.existingPosition { - s.Require().Equal(sdk.NewDec(2).Mul(test.positionLiquidity), positionRecord.NumShares) + s.Require().Equal(osmomath.NewDec(2).Mul(test.positionLiquidity), positionRecord.NumShares) } else { s.Require().Equal(test.positionLiquidity, positionRecord.NumShares) } @@ -1872,7 +1871,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { owner sdk.AccAddress lowerTick int64 upperTick int64 - liquidity sdk.Dec + liquidity osmomath.Dec joinTime time.Time collectTime time.Time positionId uint64 @@ -1892,7 +1891,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { tests := map[string]struct { // setup parameters - existingAccumLiquidity []sdk.Dec + existingAccumLiquidity []osmomath.Dec addedUptimeGrowthInside []sdk.DecCoins addedUptimeGrowthOutside []sdk.DecCoins currentTick int64 @@ -2296,13 +2295,13 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { }, "other liquidity on uptime accums: (lower < curr < upper) uptime growth both inside and outside range, 1D time in position": { currentTick: 1, - existingAccumLiquidity: []sdk.Dec{ - sdk.NewDec(99900123432), - sdk.NewDec(18942), - sdk.NewDec(0), - sdk.NewDec(9981), - sdk.NewDec(1), - sdk.NewDec(778212931834), + existingAccumLiquidity: []osmomath.Dec{ + osmomath.NewDec(99900123432), + osmomath.NewDec(18942), + osmomath.NewDec(0), + osmomath.NewDec(9981), + osmomath.NewDec(1), + osmomath.NewDec(778212931834), }, addedUptimeGrowthInside: uptimeHelper.hundredTokensMultiDenom, addedUptimeGrowthOutside: uptimeHelper.hundredTokensMultiDenom, @@ -2316,13 +2315,13 @@ func (s *KeeperTestSuite) TestQueryAndCollectIncentives() { }, "multiple positions in same range: (lower < curr < upper) uptime growth both inside and outside range, 1D time in position": { currentTick: 1, - existingAccumLiquidity: []sdk.Dec{ - sdk.NewDec(99900123432), - sdk.NewDec(18942), - sdk.NewDec(0), - sdk.NewDec(9981), - sdk.NewDec(1), - sdk.NewDec(778212931834), + existingAccumLiquidity: []osmomath.Dec{ + osmomath.NewDec(99900123432), + osmomath.NewDec(18942), + osmomath.NewDec(0), + osmomath.NewDec(9981), + osmomath.NewDec(1), + osmomath.NewDec(778212931834), }, addedUptimeGrowthInside: uptimeHelper.hundredTokensMultiDenom, addedUptimeGrowthOutside: uptimeHelper.hundredTokensMultiDenom, @@ -2507,10 +2506,10 @@ func (s *KeeperTestSuite) TestCreateIncentive() { senderBalance: sdk.NewCoins( sdk.NewCoin( incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, - sdk.NewInt(8), + osmomath.NewInt(8), ), ), - recordToSet: withAmount(incentiveRecordOne, sdk.NewDec(8)), + recordToSet: withAmount(incentiveRecordOne, osmomath.NewDec(8)), }, "existing incentive records on different uptime accumulators": { poolId: defaultPoolId, @@ -2577,25 +2576,25 @@ func (s *KeeperTestSuite) TestCreateIncentive() { senderBalance: sdk.NewCoins( sdk.NewCoin( incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, - sdk.ZeroInt(), + osmomath.ZeroInt(), ), ), - recordToSet: withAmount(incentiveRecordOne, sdk.ZeroDec()), + recordToSet: withAmount(incentiveRecordOne, osmomath.ZeroDec()), - expectedError: types.InvalidIncentiveCoinError{PoolId: 1, IncentiveCoin: sdk.NewCoin(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, sdk.ZeroInt())}, + expectedError: types.InvalidIncentiveCoinError{PoolId: 1, IncentiveCoin: sdk.NewCoin(incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, osmomath.ZeroInt())}, }, "invalid incentive coin (negative)": { poolId: defaultPoolId, senderBalance: sdk.NewCoins( sdk.NewCoin( incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, - sdk.ZeroInt(), + osmomath.ZeroInt(), ), ), - recordToSet: withAmount(incentiveRecordOne, sdk.ZeroDec()), + recordToSet: withAmount(incentiveRecordOne, osmomath.ZeroDec()), useNegativeIncentiveCoin: true, - expectedError: types.InvalidIncentiveCoinError{PoolId: 1, IncentiveCoin: sdk.Coin{Denom: incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, Amount: sdk.NewInt(-1)}}, + expectedError: types.InvalidIncentiveCoinError{PoolId: 1, IncentiveCoin: sdk.Coin{Denom: incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Denom, Amount: osmomath.NewInt(-1)}}, }, "start time too early": { poolId: defaultPoolId, @@ -2617,9 +2616,8 @@ func (s *KeeperTestSuite) TestCreateIncentive() { incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Amount.Ceil().RoundInt(), ), ), - recordToSet: withEmissionRate(incentiveRecordOne, sdk.ZeroDec()), - - expectedError: types.NonPositiveEmissionRateError{PoolId: 1, EmissionRate: sdk.ZeroDec()}, + recordToSet: withEmissionRate(incentiveRecordOne, osmomath.ZeroDec()), + expectedError: types.NonPositiveEmissionRateError{PoolId: 1, EmissionRate: osmomath.ZeroDec()}, }, "negative emission rate": { poolId: defaultPoolId, @@ -2629,9 +2627,9 @@ func (s *KeeperTestSuite) TestCreateIncentive() { incentiveRecordOne.IncentiveRecordBody.RemainingCoin.Amount.Ceil().RoundInt(), ), ), - recordToSet: withEmissionRate(incentiveRecordOne, sdk.NewDec(-1)), + recordToSet: withEmissionRate(incentiveRecordOne, osmomath.NewDec(-1)), - expectedError: types.NonPositiveEmissionRateError{PoolId: 1, EmissionRate: sdk.NewDec(-1)}, + expectedError: types.NonPositiveEmissionRateError{PoolId: 1, EmissionRate: osmomath.NewDec(-1)}, }, "supported but unauthorized min uptime": { poolId: defaultPoolId, @@ -2703,7 +2701,7 @@ func (s *KeeperTestSuite) TestCreateIncentive() { incentiveCoin := sdk.NewCoin(tc.recordToSet.IncentiveRecordBody.RemainingCoin.Denom, tc.recordToSet.IncentiveRecordBody.RemainingCoin.Amount.Ceil().RoundInt()) if tc.useNegativeIncentiveCoin { - incentiveCoin = sdk.Coin{Denom: tc.recordToSet.IncentiveRecordBody.RemainingCoin.Denom, Amount: sdk.NewInt(-1)} + incentiveCoin = sdk.Coin{Denom: tc.recordToSet.IncentiveRecordBody.RemainingCoin.Denom, Amount: osmomath.NewInt(-1)} } // Set the next incentive record id. @@ -2763,8 +2761,8 @@ func (s *KeeperTestSuite) TestCreateIncentive_NewId() { pool = s.PrepareConcentratedPool() poolId = pool.GetId() sender = s.TestAccs[0] - incentiveCoin = sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1000000000000)) - emissionRate = sdk.NewDecWithPrec(1, 2) + incentiveCoin = sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1000000000000)) + emissionRate = osmomath.NewDecWithPrec(1, 2) startTime = s.Ctx.BlockTime() minUptime = types.DefaultAuthorizedUptimes[0] @@ -2843,7 +2841,7 @@ func (s *KeeperTestSuite) TestUpdateAccumAndClaimRewards() { positionKey := validPositionKey // Initialize position accumulator. - err := poolSpreadRewardsAccumulator.NewPosition(positionKey, sdk.OneDec(), nil) + err := poolSpreadRewardsAccumulator.NewPosition(positionKey, osmomath.OneDec(), nil) s.Require().NoError(err) // Record the initial position accumulator value. @@ -2888,7 +2886,7 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { uptimeHelper := getExpectedUptimes() defaultSender := s.TestAccs[0] tests := map[string]struct { - numShares sdk.Dec + numShares osmomath.Dec positionIdCreate uint64 positionIdClaim uint64 defaultJoinTime bool @@ -2903,7 +2901,7 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { defaultJoinTime: true, growthInside: uptimeHelper.hundredTokensMultiDenom, growthOutside: uptimeHelper.twoHundredTokensMultiDenom, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), }, "claim and forfeit rewards (2 shares)": { positionIdCreate: DefaultPositionId, @@ -2912,14 +2910,14 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { growthInside: uptimeHelper.hundredTokensMultiDenom, growthOutside: uptimeHelper.twoHundredTokensMultiDenom, forfeitIncentives: true, - numShares: sdk.NewDec(2), + numShares: osmomath.NewDec(2), }, "claim and forfeit rewards when no rewards have accrued": { positionIdCreate: DefaultPositionId, positionIdClaim: DefaultPositionId, defaultJoinTime: true, forfeitIncentives: true, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), }, "claim and forfeit rewards with varying amounts and different denoms": { positionIdCreate: DefaultPositionId, @@ -2928,7 +2926,7 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { growthInside: uptimeHelper.varyingTokensMultiDenom, growthOutside: uptimeHelper.varyingTokensSingleDenom, forfeitIncentives: true, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), }, // error catching @@ -2939,7 +2937,7 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { defaultJoinTime: true, growthInside: uptimeHelper.hundredTokensMultiDenom, growthOutside: uptimeHelper.twoHundredTokensMultiDenom, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), expectedError: types.PositionIdNotFoundError{PositionId: DefaultPositionId + 1}, }, @@ -2950,7 +2948,7 @@ func (s *KeeperTestSuite) TestQueryAndClaimAllIncentives() { defaultJoinTime: false, growthInside: uptimeHelper.hundredTokensMultiDenom, growthOutside: uptimeHelper.twoHundredTokensMultiDenom, - numShares: sdk.OneDec(), + numShares: osmomath.OneDec(), expectedError: types.NegativeDurationError{Duration: time.Hour * 336 * -1}, }, @@ -3075,19 +3073,19 @@ func (s *KeeperTestSuite) TestPrepareClaimAllIncentivesForPosition() { { name: "Claim after 1 minute, 1ns uptime", blockTimeElapsed: time.Minute, - expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, sdk.NewInt(59))), // after 1min = 59.999999999901820104usdc ~ 59usdc becasue 1usdc emitted every second + expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, osmomath.NewInt(59))), // after 1min = 59.999999999901820104usdc ~ 59usdc becasue 1usdc emitted every second minUptimeIncentiveRecord: time.Nanosecond, }, { name: "Claim after 1 hr, 1ns uptime", blockTimeElapsed: time.Hour, - expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, sdk.NewInt(3599))), // after 1min = 59.999999999901820104usdc ~ 59usdc becasue 1usdc emitted every second + expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, osmomath.NewInt(3599))), // after 1min = 59.999999999901820104usdc ~ 59usdc becasue 1usdc emitted every second minUptimeIncentiveRecord: time.Nanosecond, }, { name: "Claim after 24 hours, 1ns uptime", blockTimeElapsed: time.Hour * 24, - expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, sdk.NewInt(9999))), // after 24hr > 2hr46min = 9999usdc.999999999901820104 ~ 9999usdc + expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, osmomath.NewInt(9999))), // after 24hr > 2hr46min = 9999usdc.999999999901820104 ~ 9999usdc minUptimeIncentiveRecord: time.Nanosecond, }, { @@ -3111,7 +3109,7 @@ func (s *KeeperTestSuite) TestPrepareClaimAllIncentivesForPosition() { { name: "Claim after 24 hours, 1d uptime", blockTimeElapsed: time.Hour * 24, - expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, sdk.NewInt(9999))), // after 24hr > 2hr46min = 9999usdc.999999999901820104 ~ 9999usdc + expectedCoins: sdk.NewCoins(sdk.NewCoin(USDC, osmomath.NewInt(9999))), // after 24hr > 2hr46min = 9999usdc.999999999901820104 ~ 9999usdc minUptimeIncentiveRecord: time.Hour * 24, }, } @@ -3121,7 +3119,7 @@ func (s *KeeperTestSuite) TestPrepareClaimAllIncentivesForPosition() { // Init suite for the test. s.SetupTest() - requiredBalances := sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(1_000_000)), sdk.NewCoin(USDC, sdk.NewInt(5_000_000_000))) + requiredBalances := sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(1_000_000)), sdk.NewCoin(USDC, osmomath.NewInt(5_000_000_000))) s.FundAcc(s.TestAccs[0], requiredBalances) s.FundAcc(s.TestAccs[1], requiredBalances) @@ -3129,15 +3127,15 @@ func (s *KeeperTestSuite) TestPrepareClaimAllIncentivesForPosition() { pool := s.PrepareConcentratedPool() // Set up position - positionOneData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], requiredBalances, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionOneData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], requiredBalances, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) // Set incentives for pool to ensure accumulators work correctly testIncentiveRecord := types.IncentiveRecord{ PoolId: pool.GetId(), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoinFromDec(USDC, sdk.NewDec(10_000)), // 2hr 46m to emit all incentives - EmissionRate: sdk.NewDec(1), // 1 per second + RemainingCoin: sdk.NewDecCoinFromDec(USDC, osmomath.NewDec(10_000)), // 2hr 46m to emit all incentives + EmissionRate: osmomath.NewDec(1), // 1 per second StartTime: s.Ctx.BlockTime(), }, MinUptime: tc.minUptimeIncentiveRecord, @@ -3238,24 +3236,24 @@ func (s *KeeperTestSuite) TestFunctional_ClaimIncentives_LiquidityChange_Varying // Create CL pool pool := s.PrepareConcentratedPool() - expectedAmount := sdk.NewInt(60 * 60 * 24) // 1 day in seconds * 1 per second + expectedAmount := osmomath.NewInt(60 * 60 * 24) // 1 day in seconds * 1 per second - oneUUSDCCoin := sdk.NewCoin(USDC, sdk.OneInt()) + oneUUSDCCoin := sdk.NewCoin(USDC, osmomath.OneInt()) // -1 for acceptable rounding error - expectedCoinsPerFullCharge := sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.Sub(sdk.OneInt()))) - expectedHalfOfExpectedCoinsPerFullCharge := sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.QuoRaw(2).Sub(sdk.OneInt()))) + expectedCoinsPerFullCharge := sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.Sub(osmomath.OneInt()))) + expectedHalfOfExpectedCoinsPerFullCharge := sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.QuoRaw(2).Sub(osmomath.OneInt()))) // Multiplied by 3 because we change the block time 3 times and claim // 1. by directly calling CollectIncentives // 2. by calling WithdrawPosition // 3. by calling CollectIncentives - s.FundAcc(pool.GetIncentivesAddress(), sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.Mul(sdk.NewInt(3))))) + s.FundAcc(pool.GetIncentivesAddress(), sdk.NewCoins(sdk.NewCoin(USDC, expectedAmount.Mul(osmomath.NewInt(3))))) // Set incentives for pool to ensure accumulators work correctly testIncentiveRecord := types.IncentiveRecord{ PoolId: 1, IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoinFromDec(USDC, sdk.NewDec(1000000000000000000)), - EmissionRate: sdk.NewDec(1), // 1 per second + RemainingCoin: sdk.NewDecCoinFromDec(USDC, osmomath.NewDec(1000000000000000000)), + EmissionRate: osmomath.NewDec(1), // 1 per second StartTime: defaultBlockTime, }, MinUptime: time.Nanosecond, @@ -3264,7 +3262,7 @@ func (s *KeeperTestSuite) TestFunctional_ClaimIncentives_LiquidityChange_Varying s.Require().NoError(err) // Set up position - positionOneData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, defaultPoolId, defaultAddress, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionOneData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, defaultPoolId, defaultAddress, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) // Increase block time by the fully charged duration (first time) @@ -3279,7 +3277,7 @@ func (s *KeeperTestSuite) TestFunctional_ClaimIncentives_LiquidityChange_Varying s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(testFullChargeDuration)) // Create another position - positionTwoData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, defaultPoolId, defaultAddress, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionTwoData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, defaultPoolId, defaultAddress, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) // Increase block time by the fully charged duration (third time) @@ -3590,9 +3588,9 @@ func (s *KeeperTestSuite) TestPrepareBalancerPoolAsFullRange() { // Calculate balancer share amount for full range updatedClPool, err := s.clk.GetPoolById(s.Ctx, clPool.GetId()) s.Require().NoError(err) - asset0BalancerAmount := tc.balancerPoolAssets[0].Token.Amount.ToDec().Mul(tc.portionOfSharesBonded).TruncateInt() - asset1BalancerAmount := tc.balancerPoolAssets[1].Token.Amount.ToDec().Mul(tc.portionOfSharesBonded).TruncateInt() - qualifyingSharesPreDiscount := math.GetLiquidityFromAmounts(updatedClPool.GetCurrentSqrtPrice(), osmomath.BigDecFromSDKDec(types.MinSqrtPrice), osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), asset1BalancerAmount, asset0BalancerAmount) + asset0BalancerAmount := tc.balancerPoolAssets[0].Token.Amount.ToLegacyDec().Mul(tc.portionOfSharesBonded).TruncateInt() + asset1BalancerAmount := tc.balancerPoolAssets[1].Token.Amount.ToLegacyDec().Mul(tc.portionOfSharesBonded).TruncateInt() + qualifyingSharesPreDiscount := math.GetLiquidityFromAmounts(updatedClPool.GetCurrentSqrtPrice(), osmomath.BigDecFromDec(types.MinSqrtPrice), osmomath.BigDecFromDec(types.MaxSqrtPrice), asset1BalancerAmount, asset0BalancerAmount) qualifyingShares := (sdk.OneDec().Sub(types.DefaultBalancerSharesDiscount)).Mul(qualifyingSharesPreDiscount) // TODO: clean this check up (will likely require refactoring the whole test) @@ -4096,12 +4094,12 @@ func (s *KeeperTestSuite) TestMoveRewardsToNewPositionAndDeleteOldAcc() { expectedUnclaimedRewards: emptyCoins, }, "global growth outside half of global": { - growthOutside: defaultGlobalRewardGrowth.QuoDec(sdk.NewDec(2)), + growthOutside: defaultGlobalRewardGrowth.QuoDec(osmomath.NewDec(2)), numShares: 1, - expectedUnclaimedRewards: defaultGlobalRewardGrowth.QuoDec(sdk.NewDec(2)), + expectedUnclaimedRewards: defaultGlobalRewardGrowth.QuoDec(osmomath.NewDec(2)), }, "multiple shares, partial growth outside": { - growthOutside: defaultGlobalRewardGrowth.QuoDec(sdk.NewDec(2)), + growthOutside: defaultGlobalRewardGrowth.QuoDec(osmomath.NewDec(2)), numShares: 2, expectedUnclaimedRewards: defaultGlobalRewardGrowth, }, @@ -4116,11 +4114,11 @@ func (s *KeeperTestSuite) TestMoveRewardsToNewPositionAndDeleteOldAcc() { // Get accumulator. The fact that its a fee accumulator is irrelevant for this test. testAccumulator := s.prepareSpreadRewardsAccumulator() - err := testAccumulator.NewPosition(oldPos, sdk.NewDec(tc.numShares), nil) + err := testAccumulator.NewPosition(oldPos, osmomath.NewDec(tc.numShares), nil) s.Require().NoError(err) // 2 shares is chosen arbitrarily. It is not relevant for this test. - err = testAccumulator.NewPosition(newPos, sdk.NewDec(2), nil) + err = testAccumulator.NewPosition(newPos, osmomath.NewDec(2), nil) s.Require().NoError(err) // Grow the global rewards. @@ -4159,7 +4157,7 @@ func (s *KeeperTestSuite) TestMoveRewardsToSamePositionAndDeleteOldAcc() { // TestGetUptimeTrackerValues tests getter for tick-level uptime trackers. func (s *KeeperTestSuite) TestGetUptimeTrackerValues() { - foo100 := sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(100))) + foo100 := sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(100))) testCases := []struct { name string input []model.UptimeTracker @@ -4179,13 +4177,13 @@ func (s *KeeperTestSuite) TestGetUptimeTrackerValues() { name: "Multiple uptime trackers", input: []model.UptimeTracker{ {UptimeGrowthOutside: foo100}, - {UptimeGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin("fooa", sdk.NewInt(100)))}, - {UptimeGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin("foob", sdk.NewInt(100)))}, + {UptimeGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin("fooa", osmomath.NewInt(100)))}, + {UptimeGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin("foob", osmomath.NewInt(100)))}, }, expectedOutput: []sdk.DecCoins{ foo100, - sdk.NewDecCoins(sdk.NewDecCoin("fooa", sdk.NewInt(100))), - sdk.NewDecCoins(sdk.NewDecCoin("foob", sdk.NewInt(100))), + sdk.NewDecCoins(sdk.NewDecCoin("fooa", osmomath.NewInt(100))), + sdk.NewDecCoins(sdk.NewDecCoin("foob", osmomath.NewInt(100))), }, }, } @@ -4239,8 +4237,8 @@ func (s *KeeperTestSuite) TestGetIncentiveRecordSerialized() { testIncentiveRecord := types.IncentiveRecord{ PoolId: pool.GetId(), IncentiveRecordBody: types.IncentiveRecordBody{ - RemainingCoin: sdk.NewDecCoinFromDec(USDC, sdk.NewDec(1000)), - EmissionRate: sdk.NewDec(1), // 1 per second + RemainingCoin: sdk.NewDecCoinFromDec(USDC, osmomath.NewDec(1000)), + EmissionRate: osmomath.NewDec(1), // 1 per second StartTime: defaultBlockTime, }, MinUptime: time.Nanosecond, diff --git a/x/concentrated-liquidity/invariant_test.go b/x/concentrated-liquidity/invariant_test.go index 360fdd34076..9f2092716a4 100644 --- a/x/concentrated-liquidity/invariant_test.go +++ b/x/concentrated-liquidity/invariant_test.go @@ -9,8 +9,8 @@ import ( ) type ExpectedGlobalRewardValues struct { - ExpectedAdditiveSpreadRewardTolerance sdk.Dec - ExpectedAdditiveIncentivesTolerance sdk.Dec + ExpectedAdditiveSpreadRewardTolerance osmomath.Dec + ExpectedAdditiveIncentivesTolerance osmomath.Dec TotalSpreadRewards sdk.Coins TotalIncentives sdk.Coins } @@ -104,12 +104,12 @@ func (s *KeeperTestSuite) assertTotalRewardsInvariant(expectedGlobalRewardValues totalCollectedIncentives = totalCollectedIncentives.Add(collectedIncentives...) } - spreadRewardAdditiveTolerance := sdk.Dec{} + spreadRewardAdditiveTolerance := osmomath.Dec{} if !expectedGlobalRewardValues.ExpectedAdditiveSpreadRewardTolerance.IsNil() { spreadRewardAdditiveTolerance = expectedGlobalRewardValues.ExpectedAdditiveSpreadRewardTolerance } - incentivesAdditiveTolerance := sdk.Dec{} + incentivesAdditiveTolerance := osmomath.Dec{} if !expectedGlobalRewardValues.ExpectedAdditiveIncentivesTolerance.IsNil() { incentivesAdditiveTolerance = expectedGlobalRewardValues.ExpectedAdditiveSpreadRewardTolerance } diff --git a/x/concentrated-liquidity/keeper_test.go b/x/concentrated-liquidity/keeper_test.go index d1d5bdaebf7..101859f3ece 100644 --- a/x/concentrated-liquidity/keeper_test.go +++ b/x/concentrated-liquidity/keeper_test.go @@ -28,47 +28,47 @@ import ( var ( DefaultMinTick, DefaultMaxTick = types.MinInitializedTick, types.MaxTick DefaultMinCurrentTick = types.MinCurrentTick - DefaultLowerPrice = sdk.NewDec(4545) + DefaultLowerPrice = osmomath.NewDec(4545) DefaultLowerTick = int64(30545000) - DefaultUpperPrice = sdk.NewDec(5500) + DefaultUpperPrice = osmomath.NewDec(5500) DefaultUpperTick = int64(31500000) - DefaultCurrPrice = sdk.NewDec(5000) + DefaultCurrPrice = osmomath.NewDec(5000) DefaultCurrTick int64 = 31000000 DefaultCurrSqrtPrice = func() osmomath.BigDec { curSqrtPrice, _ := osmomath.MonotonicSqrt(DefaultCurrPrice) // 70.710678118654752440 - return osmomath.BigDecFromSDKDec(curSqrtPrice) + return osmomath.BigDecFromDec(curSqrtPrice) }() - DefaultZeroSpreadFactor = sdk.ZeroDec() - DefaultSpreadRewardAccumCoins = sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(50))) + DefaultZeroSpreadFactor = osmomath.ZeroDec() + DefaultSpreadRewardAccumCoins = sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(50))) DefaultPositionId = uint64(1) DefaultUnderlyingLockId = uint64(0) DefaultJoinTime = time.Unix(0, 0).UTC() ETH = "eth" - DefaultAmt0 = sdk.NewInt(1000000) - DefaultAmt0Expected = sdk.NewInt(998976) + DefaultAmt0 = osmomath.NewInt(1000000) + DefaultAmt0Expected = osmomath.NewInt(998976) DefaultCoin0 = sdk.NewCoin(ETH, DefaultAmt0) USDC = "usdc" - DefaultAmt1 = sdk.NewInt(5000000000) - DefaultAmt1Expected = sdk.NewInt(5000000000) + DefaultAmt1 = osmomath.NewInt(5000000000) + DefaultAmt1Expected = osmomath.NewInt(5000000000) DefaultCoin1 = sdk.NewCoin(USDC, DefaultAmt1) DefaultCoins = sdk.NewCoins(DefaultCoin0, DefaultCoin1) // Both of the following liquidity values are calculated in x/concentrated-liquidity/python/swap_test.py - DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510417627556287") - FullRangeLiquidityAmt = sdk.MustNewDecFromStr("70710678.118654752941000000") + DefaultLiquidityAmt = osmomath.MustNewDecFromStr("1517882343.751510417627556287") + FullRangeLiquidityAmt = osmomath.MustNewDecFromStr("70710678.118654752941000000") DefaultTickSpacing = uint64(100) PoolCreationFee = poolmanagertypes.DefaultParams().PoolCreationFee - sqrt4000 = sdk.MustNewDecFromStr("63.245553203367586640") - sqrt4994 = sdk.MustNewDecFromStr("70.668238976219012614") - sqrt4999 = sdk.MustNewDecFromStr("70.703606697254136613") - sqrt5500 = sdk.MustNewDecFromStr("74.161984870956629488") - sqrt6250 = sdk.MustNewDecFromStr("79.056941504209483300") - DefaultExponentConsecutivePositionLowerTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt5500), DefaultTickSpacing) - DefaultExponentConsecutivePositionUpperTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt6250), DefaultTickSpacing) - DefaultExponentOverlappingPositionLowerTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt4000), DefaultTickSpacing) - DefaultExponentOverlappingPositionUpperTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt4999), DefaultTickSpacing) + sqrt4000 = osmomath.MustNewDecFromStr("63.245553203367586640") + sqrt4994 = osmomath.MustNewDecFromStr("70.668238976219012614") + sqrt4999 = osmomath.MustNewDecFromStr("70.703606697254136613") + sqrt5500 = osmomath.MustNewDecFromStr("74.161984870956629488") + sqrt6250 = osmomath.MustNewDecFromStr("79.056941504209483300") + DefaultExponentConsecutivePositionLowerTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt5500), DefaultTickSpacing) + DefaultExponentConsecutivePositionUpperTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt6250), DefaultTickSpacing) + DefaultExponentOverlappingPositionLowerTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt4000), DefaultTickSpacing) + DefaultExponentOverlappingPositionUpperTick, _ = math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt4999), DefaultTickSpacing) BAR = "bar" FOO = "foo" InsufficientFundsError = fmt.Errorf("insufficient funds") @@ -82,7 +82,7 @@ func TestConstants(t *testing.T) { lowerSqrtPrice, _ := osmomath.MonotonicSqrt(DefaultLowerPrice) upperSqrtPrice, _ := osmomath.MonotonicSqrt(DefaultUpperPrice) liq := math.GetLiquidityFromAmounts(DefaultCurrSqrtPrice, - osmomath.BigDecFromSDKDec(lowerSqrtPrice), osmomath.BigDecFromSDKDec(upperSqrtPrice), DefaultAmt0, DefaultAmt1) + osmomath.BigDecFromDec(lowerSqrtPrice), osmomath.BigDecFromDec(upperSqrtPrice), DefaultAmt0, DefaultAmt1) require.Equal(t, DefaultLiquidityAmt, liq) } @@ -123,14 +123,14 @@ func (s *KeeperTestSuite) SetupDefaultPosition(poolId uint64) { s.SetupPosition(poolId, s.TestAccs[0], DefaultCoins, DefaultLowerTick, DefaultUpperTick, false) } -func (s *KeeperTestSuite) SetupPosition(poolId uint64, owner sdk.AccAddress, providedCoins sdk.Coins, lowerTick, upperTick int64, addRoundingError bool) (sdk.Dec, uint64) { +func (s *KeeperTestSuite) SetupPosition(poolId uint64, owner sdk.AccAddress, providedCoins sdk.Coins, lowerTick, upperTick int64, addRoundingError bool) (osmomath.Dec, uint64) { roundingErrorCoins := sdk.NewCoins() if addRoundingError { roundingErrorCoins = sdk.NewCoins(sdk.NewCoin(ETH, roundingError), sdk.NewCoin(USDC, roundingError)) } s.FundAcc(owner, providedCoins.Add(roundingErrorCoins...)) - positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, owner, providedCoins, sdk.ZeroInt(), sdk.ZeroInt(), lowerTick, upperTick) + positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, owner, providedCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), lowerTick, upperTick) s.Require().NoError(err) liquidity, err := s.App.ConcentratedLiquidityKeeper.GetPositionLiquidity(s.Ctx, positionData.ID) s.Require().NoError(err) @@ -179,15 +179,15 @@ func (s *KeeperTestSuite) SetupOverlappingRangePositionAcc(poolId uint64, owner } // validatePositionUpdate validates that position with given parameters has expectedRemainingLiquidity left. -func (s *KeeperTestSuite) validatePositionUpdate(ctx sdk.Context, positionId uint64, expectedRemainingLiquidity sdk.Dec) { +func (s *KeeperTestSuite) validatePositionUpdate(ctx sdk.Context, positionId uint64, expectedRemainingLiquidity osmomath.Dec) { newPositionLiquidity, err := s.App.ConcentratedLiquidityKeeper.GetPositionLiquidity(ctx, positionId) s.Require().NoError(err) s.Require().Equal(expectedRemainingLiquidity.String(), newPositionLiquidity.String()) - s.Require().True(newPositionLiquidity.GTE(sdk.ZeroDec())) + s.Require().True(newPositionLiquidity.GTE(osmomath.ZeroDec())) } // validateTickUpdates validates that ticks with the given parameters have expectedRemainingLiquidity left. -func (s *KeeperTestSuite) validateTickUpdates(poolId uint64, lowerTick int64, upperTick int64, expectedRemainingLiquidity sdk.Dec, expectedLowerSpreadRewardGrowthOppositeDirectionOfLastTraversal, expectedUpperSpreadRewardGrowthOppositeDirectionOfLastTraversal sdk.DecCoins) { +func (s *KeeperTestSuite) validateTickUpdates(poolId uint64, lowerTick int64, upperTick int64, expectedRemainingLiquidity osmomath.Dec, expectedLowerSpreadRewardGrowthOppositeDirectionOfLastTraversal, expectedUpperSpreadRewardGrowthOppositeDirectionOfLastTraversal sdk.DecCoins) { lowerTickInfo, err := s.App.ConcentratedLiquidityKeeper.GetTickInfo(s.Ctx, poolId, lowerTick) s.Require().NoError(err) s.Require().Equal(expectedRemainingLiquidity.String(), lowerTickInfo.LiquidityGross.String()) @@ -201,7 +201,7 @@ func (s *KeeperTestSuite) validateTickUpdates(poolId uint64, lowerTick int64, up s.Require().Equal(expectedUpperSpreadRewardGrowthOppositeDirectionOfLastTraversal.String(), upperTickInfo.SpreadRewardGrowthOppositeDirectionOfLastTraversal.String()) } -func (s *KeeperTestSuite) initializeTick(ctx sdk.Context, currentTick int64, tickIndex int64, initialLiquidity sdk.Dec, spreadRewardGrowthOppositeDirectionOfTraversal sdk.DecCoins, uptimeTrackers []model.UptimeTracker, isLower bool) { +func (s *KeeperTestSuite) initializeTick(ctx sdk.Context, currentTick int64, tickIndex int64, initialLiquidity osmomath.Dec, spreadRewardGrowthOppositeDirectionOfTraversal sdk.DecCoins, uptimeTrackers []model.UptimeTracker, isLower bool) { _, err := s.App.ConcentratedLiquidityKeeper.InitOrUpdateTick(ctx, validPoolId, currentTick, tickIndex, initialLiquidity, isLower) s.Require().NoError(err) @@ -217,7 +217,7 @@ func (s *KeeperTestSuite) initializeTick(ctx sdk.Context, currentTick int64, tic } // initializeSpreadRewardsAccumulatorPositionWithLiquidity initializes spread factor accumulator position with given parameters and updates it with given liquidity. -func (s *KeeperTestSuite) initializeSpreadRewardAccumulatorPositionWithLiquidity(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity sdk.Dec) { +func (s *KeeperTestSuite) initializeSpreadRewardAccumulatorPositionWithLiquidity(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidity osmomath.Dec) { err := s.App.ConcentratedLiquidityKeeper.InitOrUpdatePositionSpreadRewardAccumulator(ctx, poolId, lowerTick, upperTick, positionId, liquidity) s.Require().NoError(err) } @@ -225,7 +225,7 @@ func (s *KeeperTestSuite) initializeSpreadRewardAccumulatorPositionWithLiquidity // addLiquidityToUptimeAccumulators adds shares to all uptime accumulators as defined by the `liquidity` parameter. // This helper is primarily used to test incentive accrual for specific tick ranges, so we pass in filler values // for all other components (e.g. join time). -func (s *KeeperTestSuite) addLiquidityToUptimeAccumulators(ctx sdk.Context, poolId uint64, liquidity []sdk.Dec, positionId uint64) { +func (s *KeeperTestSuite) addLiquidityToUptimeAccumulators(ctx sdk.Context, poolId uint64, liquidity []osmomath.Dec, positionId uint64) { s.Require().Equal(len(liquidity), len(types.SupportedUptimes)) uptimeAccums, err := s.App.ConcentratedLiquidityKeeper.GetUptimeAccumulators(ctx, poolId) @@ -337,7 +337,7 @@ func (s *KeeperTestSuite) addUptimeGrowthOutsideRange(ctx sdk.Context, poolId ui // validatePositionSpreadFactorAccUpdate validates that the position's accumulator with given parameters // has been updated with liquidity. -func (s *KeeperTestSuite) validatePositionSpreadRewardAccUpdate(ctx sdk.Context, poolId uint64, positionId uint64, liquidity sdk.Dec) { +func (s *KeeperTestSuite) validatePositionSpreadRewardAccUpdate(ctx sdk.Context, poolId uint64, positionId uint64, liquidity osmomath.Dec) { accum, err := s.App.ConcentratedLiquidityKeeper.GetSpreadRewardAccumulator(ctx, poolId) s.Require().NoError(err) @@ -438,7 +438,7 @@ func (s *KeeperTestSuite) TestValidatePermissionlessPoolCreationEnabled() { // up the passed in incentive records such that they emit on the pool. It also sets the largest authorized uptime to be `fullChargeDuration`. // // Returns the pool, expected position ids and the total liquidity created on the pool. -func (s *KeeperTestSuite) runFungifySetup(address sdk.AccAddress, numPositions int, fullChargeDuration time.Duration, poolSpreadFactor sdk.Dec, incentiveRecords []types.IncentiveRecord) (types.ConcentratedPoolExtension, []uint64, sdk.Dec) { +func (s *KeeperTestSuite) runFungifySetup(address sdk.AccAddress, numPositions int, fullChargeDuration time.Duration, poolSpreadFactor osmomath.Dec, incentiveRecords []types.IncentiveRecord) (types.ConcentratedPoolExtension, []uint64, osmomath.Dec) { expectedPositionIds := make([]uint64, numPositions) for i := 0; i < numPositions; i++ { expectedPositionIds[i] = uint64(i + 1) @@ -446,7 +446,7 @@ func (s *KeeperTestSuite) runFungifySetup(address sdk.AccAddress, numPositions i s.TestAccs = apptesting.CreateRandomAccounts(5) s.SetBlockTime(defaultBlockTime) - totalPositionsToCreate := sdk.NewInt(int64(numPositions)) + totalPositionsToCreate := osmomath.NewInt(int64(numPositions)) requiredBalances := sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0.Mul(totalPositionsToCreate)), sdk.NewCoin(USDC, DefaultAmt1.Mul(totalPositionsToCreate))) // Set test authorized uptime params. @@ -465,9 +465,9 @@ func (s *KeeperTestSuite) runFungifySetup(address sdk.AccAddress, numPositions i s.Require().NoError(err) // Set up fully charged positions - totalLiquidity := sdk.ZeroDec() + totalLiquidity := osmomath.ZeroDec() for i := 0; i < numPositions; i++ { - positionData, err := s.clk.CreatePosition(s.Ctx, defaultPoolId, address, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionData, err := s.clk.CreatePosition(s.Ctx, defaultPoolId, address, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) totalLiquidity = totalLiquidity.Add(positionData.Liquidity) } diff --git a/x/concentrated-liquidity/lp.go b/x/concentrated-liquidity/lp.go index e0d44fcfcf5..dad08e52c5c 100644 --- a/x/concentrated-liquidity/lp.go +++ b/x/concentrated-liquidity/lp.go @@ -18,9 +18,9 @@ const noUnderlyingLockId = uint64(0) // CreatePositionData represents the return data from CreatePosition. type CreatePositionData struct { ID uint64 - Amount0 sdk.Int - Amount1 sdk.Int - Liquidity sdk.Dec + Amount0 osmomath.Int + Amount1 osmomath.Int + Liquidity osmomath.Dec LowerTick int64 UpperTick int64 } @@ -42,7 +42,7 @@ type CreatePositionData struct { // - the liquidity delta is zero // - the amount0 or amount1 returned from the position update is less than the given minimums // - the pool or user does not have enough tokens to satisfy the requested amount -func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, tokensProvided sdk.Coins, amount0Min, amount1Min sdk.Int, lowerTick, upperTick int64) (positionDate CreatePositionData, err error) { +func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, tokensProvided sdk.Coins, amount0Min, amount1Min osmomath.Int, lowerTick, upperTick int64) (positionDate CreatePositionData, err error) { // Use the current blockTime as the position's join time. joinTime := ctx.BlockTime() @@ -186,49 +186,49 @@ func (k Keeper) CreatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr // - if the position's underlying lock is not mature // - if tick ranges are invalid // - if attempts to withdraw an amount higher than originally provided in createPosition for a given range. -func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, requestedLiquidityAmountToWithdraw sdk.Dec) (amtDenom0, amtDenom1 sdk.Int, err error) { +func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, requestedLiquidityAmountToWithdraw osmomath.Dec) (amtDenom0, amtDenom1 osmomath.Int, err error) { position, err := k.GetPosition(ctx, positionId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // Check if the provided owner owns the position being withdrawn. if owner.String() != position.Address { - return sdk.Int{}, sdk.Int{}, types.NotPositionOwnerError{PositionId: positionId, Address: owner.String()} + return osmomath.Int{}, osmomath.Int{}, types.NotPositionOwnerError{PositionId: positionId, Address: owner.String()} } // Defense in depth, requestedLiquidityAmountToWithdraw should always be a value that is GE than 0. if requestedLiquidityAmountToWithdraw.IsNegative() { - return sdk.Int{}, sdk.Int{}, types.InsufficientLiquidityError{Actual: requestedLiquidityAmountToWithdraw, Available: position.Liquidity} + return osmomath.Int{}, osmomath.Int{}, types.InsufficientLiquidityError{Actual: requestedLiquidityAmountToWithdraw, Available: position.Liquidity} } // If underlying lock exists in state, validate unlocked conditions are met before withdrawing liquidity. // If the underlying lock for the position has been matured, remove the link between the position and the underlying lock. positionHasActiveUnderlyingLock, lockId, err := k.positionHasActiveUnderlyingLockAndUpdate(ctx, positionId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // If an underlying lock for the position exists, and the lock is not mature, return error. if positionHasActiveUnderlyingLock { - return sdk.Int{}, sdk.Int{}, types.LockNotMatureError{PositionId: position.PositionId, LockId: lockId} + return osmomath.Int{}, osmomath.Int{}, types.LockNotMatureError{PositionId: position.PositionId, LockId: lockId} } // Retrieve the pool associated with the given pool ID. pool, err := k.getPoolById(ctx, position.PoolId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // Check if the requested liquidity amount to withdraw is less than or equal to the available liquidity for the position. // If it is greater than the available liquidity, return an error. if requestedLiquidityAmountToWithdraw.GT(position.Liquidity) { - return sdk.Int{}, sdk.Int{}, types.InsufficientLiquidityError{Actual: requestedLiquidityAmountToWithdraw, Available: position.Liquidity} + return osmomath.Int{}, osmomath.Int{}, types.InsufficientLiquidityError{Actual: requestedLiquidityAmountToWithdraw, Available: position.Liquidity} } _, _, err = k.collectIncentives(ctx, owner, positionId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // Calculate the change in liquidity for the pool based on the requested amount to withdraw. @@ -238,13 +238,13 @@ func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, position // Update the position in the pool based on the provided tick range and liquidity delta. updateData, err := k.UpdatePosition(ctx, position.PoolId, owner, position.LowerTick, position.UpperTick, liquidityDelta, position.JoinTime, positionId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // Transfer the actual amounts of tokens 0 and 1 from the pool to the position owner. err = k.sendCoinsBetweenPoolAndUser(ctx, pool.GetToken0(), pool.GetToken1(), updateData.Amount0.Abs(), updateData.Amount1.Abs(), pool.GetAddress(), owner) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // If the requested liquidity amount to withdraw is equal to the available liquidity, delete the position from state. @@ -252,27 +252,27 @@ func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, position // process also clears position records from spread factor and incentive accumulators. if requestedLiquidityAmountToWithdraw.Equal(position.Liquidity) { if _, err := k.collectSpreadRewards(ctx, owner, positionId); err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } if _, _, err := k.collectIncentives(ctx, owner, positionId); err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } if err := k.deletePosition(ctx, positionId, owner, position.PoolId); err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } anyPositionsRemainingInPool, err := k.HasAnyPositionForPool(ctx, position.PoolId) if err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } if !anyPositionsRemainingInPool { // Reset the current tick and current square root price to initial values of zero since there is no // liquidity left. if err := k.uninitializePool(ctx, pool.GetId()); err != nil { - return sdk.Int{}, sdk.Int{}, err + return osmomath.Int{}, osmomath.Int{}, err } // N.B. since removing the liquidity of the last position in-full @@ -330,49 +330,49 @@ func (k Keeper) WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, position // - Creating new position with added liquidity fails // - Position with `positionId` is the last position in the pool // - Position is superfluid staked -func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0MinGiven, amount1MinGiven sdk.Int) (uint64, sdk.Int, sdk.Int, error) { +func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added, amount0MinGiven, amount1MinGiven osmomath.Int) (uint64, osmomath.Int, osmomath.Int, error) { position, err := k.GetPosition(ctx, positionId) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } // Check if the provided owner owns the position being added to. if owner.String() != position.Address { - return 0, sdk.Int{}, sdk.Int{}, types.NotPositionOwnerError{PositionId: positionId, Address: owner.String()} + return 0, osmomath.Int{}, osmomath.Int{}, types.NotPositionOwnerError{PositionId: positionId, Address: owner.String()} } // if one of the liquidity is negative, or both liquidity being added is zero, error if amount0Added.IsNegative() || amount1Added.IsNegative() { - return 0, sdk.Int{}, sdk.Int{}, types.NegativeAmountAddedError{PositionId: position.PositionId, Asset0Amount: amount0Added, Asset1Amount: amount1Added} + return 0, osmomath.Int{}, osmomath.Int{}, types.NegativeAmountAddedError{PositionId: position.PositionId, Asset0Amount: amount0Added, Asset1Amount: amount1Added} } if amount0Added.IsZero() && amount1Added.IsZero() { - return 0, sdk.Int{}, sdk.Int{}, types.ErrZeroLiquidity + return 0, osmomath.Int{}, osmomath.Int{}, types.ErrZeroLiquidity } // If the position is superfluid staked, return error. // This path is handled separately in the superfluid module. positionHasUnderlyingLock, _, err := k.positionHasActiveUnderlyingLockAndUpdate(ctx, positionId) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } if positionHasUnderlyingLock { - return 0, sdk.Int{}, sdk.Int{}, types.PositionSuperfluidStakedError{PositionId: position.PositionId} + return 0, osmomath.Int{}, osmomath.Int{}, types.PositionSuperfluidStakedError{PositionId: position.PositionId} } // Withdraw full position. amount0Withdrawn, amount1Withdrawn, err := k.WithdrawPosition(ctx, owner, positionId, position.Liquidity) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } anyPositionsRemainingInPool, err := k.HasAnyPositionForPool(ctx, position.PoolId) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } if !anyPositionsRemainingInPool { - return 0, sdk.Int{}, sdk.Int{}, types.AddToLastPositionInPoolError{PoolId: position.PoolId, PositionId: position.PositionId} + return 0, osmomath.Int{}, osmomath.Int{}, types.AddToLastPositionInPoolError{PoolId: position.PoolId, PositionId: position.PositionId} } // Create new position with updated liquidity. @@ -380,7 +380,7 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId amount1Desired := amount1Withdrawn.Add(amount1Added) pool, err := k.GetConcentratedPoolById(ctx, position.PoolId) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } tokensProvided := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), amount0Desired), sdk.NewCoin(pool.GetToken1(), amount1Desired)) minimumAmount0 := amount0Withdrawn @@ -394,7 +394,7 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId } newPositionData, err := k.CreatePosition(ctx, position.PoolId, owner, tokensProvided, minimumAmount0, minimumAmount1, position.LowerTick, position.UpperTick) if err != nil { - return 0, sdk.Int{}, sdk.Int{}, err + return 0, osmomath.Int{}, osmomath.Int{}, err } // Emit an event indicating that a position was added to. @@ -421,7 +421,7 @@ func (k Keeper) addToPosition(ctx sdk.Context, owner sdk.AccAddress, positionId // Positive returned amounts imply that tokens are added to the pool. // If the lower and/or upper ticks are being updated to have zero liquidity, a boolean is returned to flag the tick as empty to be deleted at the end of the withdrawPosition method. // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) (types.UpdatePositionData, error) { +func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta osmomath.Dec, joinTime time.Time, positionId uint64) (types.UpdatePositionData, error) { if err := k.validatePositionUpdateById(ctx, positionId, owner, lowerTick, upperTick, liquidityDelta, joinTime, poolId); err != nil { return types.UpdatePositionData{}, err } @@ -485,7 +485,7 @@ func (k Keeper) UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddr } // sendCoinsBetweenPoolAndUser takes the amounts calculated from a join/exit position and executes the send between pool and user -func (k Keeper) sendCoinsBetweenPoolAndUser(ctx sdk.Context, denom0, denom1 string, amount0, amount1 sdk.Int, sender, receiver sdk.AccAddress) error { +func (k Keeper) sendCoinsBetweenPoolAndUser(ctx sdk.Context, denom0, denom1 string, amount0, amount1 osmomath.Int, sender, receiver sdk.AccAddress) error { if amount0.IsNegative() { return types.Amount0IsNegativeError{Amount0: amount0} } @@ -504,15 +504,15 @@ func (k Keeper) sendCoinsBetweenPoolAndUser(ctx sdk.Context, denom0, denom1 stri // initializeInitialPositionForPool ensures that the first position created on this pool includes both asset0 and asset1 // This is required so we can set the pool's sqrtPrice and calculate it's initial tick from this. // Additionally, it initializes the current sqrt price and current tick from the initial reserve values. -func (k Keeper) initializeInitialPositionForPool(ctx sdk.Context, pool types.ConcentratedPoolExtension, amount0Desired, amount1Desired sdk.Int) error { +func (k Keeper) initializeInitialPositionForPool(ctx sdk.Context, pool types.ConcentratedPoolExtension, amount0Desired, amount1Desired osmomath.Int) error { // Check that the position includes some amount of both asset0 and asset1 - if !amount0Desired.GT(sdk.ZeroInt()) || !amount1Desired.GT(sdk.ZeroInt()) { + if !amount0Desired.GT(osmomath.ZeroInt()) || !amount1Desired.GT(osmomath.ZeroInt()) { return types.InitialLiquidityZeroError{Amount0: amount0Desired, Amount1: amount1Desired} } // Calculate the spot price and sqrt price from the amount provided - initialSpotPrice := amount1Desired.ToDec().Quo(amount0Desired.ToDec()) - // TODO: any concerns with this being an sdk.Dec? + initialSpotPrice := amount1Desired.ToLegacyDec().Quo(amount0Desired.ToLegacyDec()) + // TODO: any concerns with this being an osmomath.Dec? initialCurSqrtPrice, err := osmomath.MonotonicSqrt(initialSpotPrice) if err != nil { return err @@ -521,7 +521,7 @@ func (k Keeper) initializeInitialPositionForPool(ctx sdk.Context, pool types.Con // Calculate the initial tick from the initial spot price // We round down here so that the tick is rounded to // the nearest possible value given the tick spacing. - initialTick, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(initialCurSqrtPrice), pool.GetTickSpacing()) + initialTick, err := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(initialCurSqrtPrice), pool.GetTickSpacing()) if err != nil { return err } @@ -533,7 +533,7 @@ func (k Keeper) initializeInitialPositionForPool(ctx sdk.Context, pool types.Con // However, there are ticks only at 100_000_000 X/Y and 100_000_100 X/Y. // In such a case, we do not want to round the sqrt price to 100_000_000 X/Y, but rather // let it float within the possible tick range. - pool.SetCurrentSqrtPrice(osmomath.BigDecFromSDKDec(initialCurSqrtPrice)) + pool.SetCurrentSqrtPrice(osmomath.BigDecFromDec(initialCurSqrtPrice)) pool.SetCurrentTick(initialTick) err = k.setPool(ctx, pool) if err != nil { @@ -561,7 +561,7 @@ func (k Keeper) uninitializePool(ctx sdk.Context, poolId uint64) error { return types.UninitializedPoolWithLiquidityError{PoolId: poolId} } - pool.SetCurrentSqrtPrice(osmomath.ZeroDec()) + pool.SetCurrentSqrtPrice(osmomath.ZeroBigDec()) pool.SetCurrentTick(0) if err := k.setPool(ctx, pool); err != nil { @@ -606,7 +606,7 @@ func (k Keeper) isLockMature(ctx sdk.Context, underlyingLockId uint64) (bool, er // If the liquidity to withdraw is greater than the current liquidity of the position, returns types.LiquidityWithdrawalError. // If the join time provided does not match the position's join time, returns types.JoinTimeMismatchError. // If the position does not belong to the pool with the provided pool ID, returns types.PositionsNotInSamePoolError. -func (k Keeper) validatePositionUpdateById(ctx sdk.Context, positionId uint64, updateInitiator sdk.AccAddress, lowerTickGiven int64, upperTickGiven int64, liquidityDeltaGiven sdk.Dec, joinTimeGiven time.Time, poolIdGiven uint64) error { +func (k Keeper) validatePositionUpdateById(ctx sdk.Context, positionId uint64, updateInitiator sdk.AccAddress, lowerTickGiven int64, upperTickGiven int64, liquidityDeltaGiven osmomath.Dec, joinTimeGiven time.Time, poolIdGiven uint64) error { if positionId == 0 { return types.ErrZeroPositionId } diff --git a/x/concentrated-liquidity/lp_test.go b/x/concentrated-liquidity/lp_test.go index afe19f0514e..00fced69388 100644 --- a/x/concentrated-liquidity/lp_test.go +++ b/x/concentrated-liquidity/lp_test.go @@ -29,11 +29,11 @@ type lpTest struct { currentSqrtP osmomath.BigDec tokensProvided sdk.Coins customTokensProvided bool - amount0Minimum sdk.Int - amount0Expected sdk.Int - amount1Minimum sdk.Int - amount1Expected sdk.Int - liquidityAmount sdk.Dec + amount0Minimum osmomath.Int + amount0Expected osmomath.Int + amount1Minimum osmomath.Int + amount1Expected osmomath.Int + liquidityAmount osmomath.Dec tickSpacing uint64 isNotFirstPosition bool isNotFirstPositionWithSameAccount bool @@ -56,9 +56,9 @@ var ( currentSqrtP: DefaultCurrSqrtPrice, tokensProvided: DefaultCoins, customTokensProvided: false, - amount0Minimum: sdk.ZeroInt(), + amount0Minimum: osmomath.ZeroInt(), amount0Expected: DefaultAmt0Expected, - amount1Minimum: sdk.ZeroInt(), + amount1Minimum: osmomath.ZeroInt(), amount1Expected: DefaultAmt1Expected, liquidityAmount: DefaultLiquidityAmt, tickSpacing: DefaultTickSpacing, @@ -75,11 +75,11 @@ var ( } errToleranceOneRoundDown = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.OneDec(), + AdditiveTolerance: osmomath.OneDec(), RoundingDir: osmomath.RoundDown, } - roundingError = sdk.OneInt() + roundingError = osmomath.OneInt() positionCases = map[string]lpTest{ "base case": { @@ -114,7 +114,7 @@ var ( upperTick: DefaultUpperTick, currentTick: DefaultUpperTick + 100, - preSetChargeSpreadRewards: sdk.NewDecCoin(ETH, sdk.ZeroInt()), // zero spread reward + preSetChargeSpreadRewards: sdk.NewDecCoin(ETH, osmomath.ZeroInt()), // zero spread reward expectedSpreadRewardGrowthOutsideLower: oneEthCoins, // Rounding up in favor of the pool. @@ -184,22 +184,22 @@ func (s *KeeperTestSuite) TestCreatePosition() { expectedError: types.InvalidLowerUpperTickError{LowerTick: 500, UpperTick: 400}, }, "error: amount0 min is negative": { - amount0Minimum: sdk.NewInt(-1), - expectedError: types.NotPositiveRequireAmountError{Amount: sdk.NewInt(-1).String()}, + amount0Minimum: osmomath.NewInt(-1), + expectedError: types.NotPositiveRequireAmountError{Amount: osmomath.NewInt(-1).String()}, }, "error: amount1 min is negative": { - amount1Minimum: sdk.NewInt(-1), - expectedError: types.NotPositiveRequireAmountError{Amount: sdk.NewInt(-1).String()}, + amount1Minimum: osmomath.NewInt(-1), + expectedError: types.NotPositiveRequireAmountError{Amount: osmomath.NewInt(-1).String()}, }, "error: amount of token 0 is smaller than minimum; should fail and not update state": { - amount0Minimum: baseCase.amount0Expected.Mul(sdk.NewInt(2)), + amount0Minimum: baseCase.amount0Expected.Mul(osmomath.NewInt(2)), // Add one since rounding up in favor of the pool. - expectedError: types.InsufficientLiquidityCreatedError{Actual: baseCase.amount0Expected.Add(roundingError), Minimum: baseCase.amount0Expected.Mul(sdk.NewInt(2)), IsTokenZero: true}, + expectedError: types.InsufficientLiquidityCreatedError{Actual: baseCase.amount0Expected.Add(roundingError), Minimum: baseCase.amount0Expected.Mul(osmomath.NewInt(2)), IsTokenZero: true}, }, "error: amount of token 1 is smaller than minimum; should fail and not update state": { - amount1Minimum: baseCase.amount1Expected.Mul(sdk.NewInt(2)), + amount1Minimum: baseCase.amount1Expected.Mul(osmomath.NewInt(2)), - expectedError: types.InsufficientLiquidityCreatedError{Actual: baseCase.amount1Expected, Minimum: baseCase.amount1Expected.Mul(sdk.NewInt(2))}, + expectedError: types.InsufficientLiquidityCreatedError{Actual: baseCase.amount1Expected, Minimum: baseCase.amount1Expected.Mul(osmomath.NewInt(2))}, }, "error: a non first position with zero amount desired for both denoms should fail liquidity delta check": { isNotFirstPosition: true, @@ -216,12 +216,12 @@ func (s *KeeperTestSuite) TestCreatePosition() { "error: first position cannot have a zero amount for denom0": { customTokensProvided: true, tokensProvided: sdk.NewCoins(DefaultCoin1), - expectedError: types.InitialLiquidityZeroError{Amount0: sdk.ZeroInt(), Amount1: DefaultAmt1}, + expectedError: types.InitialLiquidityZeroError{Amount0: osmomath.ZeroInt(), Amount1: DefaultAmt1}, }, "error: first position cannot have a zero amount for denom1": { customTokensProvided: true, tokensProvided: sdk.NewCoins(DefaultCoin0), - expectedError: types.InitialLiquidityZeroError{Amount0: DefaultAmt0, Amount1: sdk.ZeroInt()}, + expectedError: types.InitialLiquidityZeroError{Amount0: DefaultAmt0, Amount1: osmomath.ZeroInt()}, }, "error: first position cannot have a zero amount for both denom0 and denom1": { customTokensProvided: true, @@ -255,7 +255,7 @@ func (s *KeeperTestSuite) TestCreatePosition() { s.FundAcc(s.TestAccs[0], PoolCreationFee) // Create a CL pool with custom tickSpacing - poolID, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, sdk.ZeroDec())) + poolID, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, osmomath.ZeroDec())) s.Require().NoError(err) // Set mock listener to make sure that is is called when desired. @@ -317,8 +317,8 @@ func (s *KeeperTestSuite) TestCreatePosition() { // - account balances are untouched if tc.expectedError != nil { s.Require().Error(err) - s.Require().Equal(asset0, sdk.Int{}) - s.Require().Equal(asset1, sdk.Int{}) + s.Require().Equal(asset0, osmomath.Int{}) + s.Require().Equal(asset1, osmomath.Int{}) s.Require().ErrorContains(err, tc.expectedError.Error()) // Check account balances @@ -329,7 +329,7 @@ func (s *KeeperTestSuite) TestCreatePosition() { liquidity, err := clKeeper.GetPositionLiquidity(s.Ctx, positionId) s.Require().Error(err) s.Require().ErrorAs(err, &types.PositionIdNotFoundError{PositionId: positionId}) - s.Require().Equal(sdk.Dec{}, liquidity) + s.Require().Equal(osmomath.Dec{}, liquidity) return } @@ -390,7 +390,7 @@ const ( unlocked ) -func (s *KeeperTestSuite) createPositionWithLockState(ls lockState, poolId uint64, owner sdk.AccAddress, providedCoins sdk.Coins, dur time.Duration) (uint64, sdk.Dec) { +func (s *KeeperTestSuite) createPositionWithLockState(ls lockState, poolId uint64, owner sdk.AccAddress, providedCoins sdk.Coins, dur time.Duration) (uint64, osmomath.Dec) { var ( positionData cl.CreatePositionData fullRangePositionData cltypes.CreateFullRangePositionData @@ -404,7 +404,7 @@ func (s *KeeperTestSuite) createPositionWithLockState(ls lockState, poolId uint6 } else if ls == unlocked { fullRangePositionData, _, err = s.clk.CreateFullRangePositionUnlocking(s.Ctx, poolId, owner, providedCoins, dur-time.Hour) } else { - positionData, err = s.clk.CreatePosition(s.Ctx, poolId, owner, providedCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionData, err = s.clk.CreatePosition(s.Ctx, poolId, owner, providedCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) return positionData.ID, positionData.Liquidity } @@ -437,7 +437,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { sutConfigOverwrite: &lpTest{ amount0Expected: baseCase.amount0Expected, // 0.998976 eth // Note: subtracting one due to truncations in favor of the pool when withdrawing. - amount1Expected: baseCase.amount1Expected.Sub(sdk.OneInt()), // 5000 usdc + amount1Expected: baseCase.amount1Expected.Sub(osmomath.OneInt()), // 5000 usdc }, timeElapsed: defaultTimeElapsed, isFullLiquidityWithdraw: true, @@ -452,14 +452,14 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { // * sqrtPriceB = MaxSqrtPrice // * sqrtPriceA = DefaultCurrSqrtPrice // Exact calculation: https://www.wolframalpha.com/input?i=70710678.118654752940000000+*+%2810000000000000000000.000000000000000000+-+70.710678118654752440%29+%2F+%2810000000000000000000.000000000000000000+*+70.710678118654752440%29 - amount0Expected: sdk.NewInt(999999), + amount0Expected: osmomath.NewInt(999999), // amount1Expected = liq * (sqrtPriceB - sqrtPriceA) // Where: // * liquidity = FullRangeLiquidityAmt // * sqrtPriceB = DefaultCurrSqrtPrice // * sqrtPriceA = MinSqrtPrice // Exact calculation: https://www.wolframalpha.com/input?i=70710678.118654752940000000+*+%2870.710678118654752440+-+0.000001000000000000%29 - amount1Expected: sdk.NewInt(4999999929), + amount1Expected: osmomath.NewInt(4999999929), liquidityAmount: FullRangeLiquidityAmt, underlyingLockId: 1, }, @@ -490,7 +490,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { "withdraw partial liquidity amount": { setupConfig: baseCase, sutConfigOverwrite: &lpTest{ - liquidityAmount: baseCase.liquidityAmount.QuoRoundUp(sdk.NewDec(2)), + liquidityAmount: baseCase.liquidityAmount.QuoRoundUp(osmomath.NewDec(2)), amount0Expected: baseCase.amount0Expected.QuoRaw(2), // 0.499488 amount1Expected: baseCase.amount1Expected.QuoRaw(2), // 2500 usdc }, @@ -501,7 +501,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { sutConfigOverwrite: &lpTest{ amount0Expected: baseCase.amount0Expected, // 0.998976 eth // Note: subtracting one due to truncations in favor of the pool when withdrawing. - amount1Expected: baseCase.amount1Expected.Sub(sdk.OneInt()), // 5000 usdc + amount1Expected: baseCase.amount1Expected.Sub(osmomath.OneInt()), // 5000 usdc }, timeElapsed: 0, isFullLiquidityWithdraw: true, @@ -518,16 +518,16 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { "error: insufficient liquidity": { setupConfig: baseCase, sutConfigOverwrite: &lpTest{ - liquidityAmount: baseCase.liquidityAmount.Add(sdk.OneDec()), // 1 more than available - expectedError: types.InsufficientLiquidityError{Actual: baseCase.liquidityAmount.Add(sdk.OneDec()), Available: baseCase.liquidityAmount}, + liquidityAmount: baseCase.liquidityAmount.Add(osmomath.OneDec()), // 1 more than available + expectedError: types.InsufficientLiquidityError{Actual: baseCase.liquidityAmount.Add(osmomath.OneDec()), Available: baseCase.liquidityAmount}, }, timeElapsed: defaultTimeElapsed, }, "error: try withdrawing negative liquidity": { setupConfig: baseCase, sutConfigOverwrite: &lpTest{ - liquidityAmount: baseCase.liquidityAmount.Sub(baseCase.liquidityAmount.Mul(sdk.NewDec(2))), - expectedError: types.InsufficientLiquidityError{Actual: baseCase.liquidityAmount.Sub(baseCase.liquidityAmount.Mul(sdk.NewDec(2))), Available: baseCase.liquidityAmount}, + liquidityAmount: baseCase.liquidityAmount.Sub(baseCase.liquidityAmount.Mul(osmomath.NewDec(2))), + expectedError: types.InsufficientLiquidityError{Actual: baseCase.liquidityAmount.Sub(baseCase.liquidityAmount.Mul(osmomath.NewDec(2))), Available: baseCase.liquidityAmount}, }, timeElapsed: defaultTimeElapsed, }, @@ -550,7 +550,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { var ( concentratedLiquidityKeeper = s.App.ConcentratedLiquidityKeeper - liquidityCreated = sdk.ZeroDec() + liquidityCreated = osmomath.ZeroDec() owner = s.TestAccs[0] config = *tc.setupConfig err error @@ -575,7 +575,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { store := s.Ctx.KVStore(s.App.GetKey(types.StoreKey)) // Set global spread reward growth to 1 ETH and charge the spread reward to the pool. - globalSpreadRewardGrowth := sdk.NewDecCoin(ETH, sdk.NewInt(1)) + globalSpreadRewardGrowth := sdk.NewDecCoin(ETH, osmomath.NewInt(1)) s.AddToSpreadRewardAccumulator(pool.GetId(), globalSpreadRewardGrowth) // Add global uptime growth @@ -623,8 +623,8 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { amtDenom0, amtDenom1, err := concentratedLiquidityKeeper.WithdrawPosition(s.Ctx, withdrawAccount, config.positionId, config.liquidityAmount) if config.expectedError != nil { s.Require().Error(err) - s.Require().Equal(amtDenom0, sdk.Int{}) - s.Require().Equal(amtDenom1, sdk.Int{}) + s.Require().Equal(amtDenom0, osmomath.Int{}) + s.Require().Equal(amtDenom1, osmomath.Int{}) s.Require().ErrorContains(err, config.expectedError.Error()) return } @@ -680,7 +680,7 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { positionLiquidity, err := s.App.ConcentratedLiquidityKeeper.GetPositionLiquidity(s.Ctx, config.positionId) s.Require().Error(err) s.Require().ErrorIs(err, types.PositionIdNotFoundError{PositionId: config.positionId}) - s.Require().Equal(sdk.Dec{}, positionLiquidity) + s.Require().Equal(osmomath.Dec{}, positionLiquidity) // check underlying stores were correctly deleted emptyPositionStruct := clmodel.Position{} @@ -751,8 +751,8 @@ func (s *KeeperTestSuite) TestWithdrawPosition() { // This is to be more thoroughly tested separately. if expectedRemainingLiquidity.IsZero() { // Add one USDC because we withdraw one less than originally funded due to truncation in favor of the pool. - s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, sdk.OneInt()))) - _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), owner, config.tokensProvided, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, osmomath.OneInt()))) + _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), owner, config.tokensProvided, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) } }) @@ -766,8 +766,8 @@ func (s *KeeperTestSuite) TestAddToPosition() { // These amounts are set based on the actual amounts passed in as inputs // to create position in the default config case (prior to rounding). We use them as // a reference to test rounding behavior when adding to positions. - amount0PerfectRatio := sdk.NewInt(998977) - amount1PerfectRatio := sdk.NewInt(5000000000) + amount0PerfectRatio := osmomath.NewInt(998977) + amount1PerfectRatio := osmomath.NewInt(5000000000) tests := map[string]struct { setupConfig *lpTest @@ -781,8 +781,8 @@ func (s *KeeperTestSuite) TestAddToPosition() { lastPositionInPool bool senderNotOwner bool - amount0ToAdd sdk.Int - amount1ToAdd sdk.Int + amount0ToAdd osmomath.Int + amount1ToAdd osmomath.Int }{ "add base amount to existing liquidity with perfect ratio": { // setup parameters for creating a pool and position. @@ -795,7 +795,7 @@ func (s *KeeperTestSuite) TestAddToPosition() { // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - amount1Expected: sdk.NewInt(9999998816), + amount1Expected: osmomath.NewInt(9999998816), }, timeElapsed: defaultTimeElapsed, amount0ToAdd: amount0PerfectRatio, @@ -829,7 +829,7 @@ func (s *KeeperTestSuite) TestAddToPosition() { // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - amount1Expected: sdk.NewInt(7499995358), + amount1Expected: osmomath.NewInt(7499995358), }, timeElapsed: defaultTimeElapsed, amount0ToAdd: amount0PerfectRatio.QuoRaw(2), @@ -857,13 +857,13 @@ func (s *KeeperTestSuite) TestAddToPosition() { // system under test parameters sutConfigOverwrite: &lpTest{ // 1998976eth (amount withdrawn with rounded down amounts) + 998977(token amount in) - amount0Expected: sdk.NewInt(2997953), + amount0Expected: osmomath.NewInt(2997953), // tokens Provided for token1 is 9999999999 (amount withdrawn) + 5000000000 = 14999999999usdc. // We calculate calc amount1 by using the following equation: // liq * (sqrtPriceB - sqrtPriceA), where liq is equal to the original joined liq + added liq, sqrtPriceB is current sqrt price, and sqrtPriceA is min sqrt price. // Note that these numbers were calculated using `GetLiquidityFromAmounts` and `TickToSqrtPrice` and thus assume correctness of those functions. // https://www.wolframalpha.com/input?i=212041526.154556192317664016+*+%2870.728769315114743566+-+0.000001000000000000%29 - amount1Expected: sdk.NewInt(14997435977), + amount1Expected: osmomath.NewInt(14997435977), }, timeElapsed: defaultTimeElapsed, amount0ToAdd: amount0PerfectRatio, @@ -882,7 +882,7 @@ func (s *KeeperTestSuite) TestAddToPosition() { // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - amount1Expected: sdk.NewInt(9999998816), + amount1Expected: osmomath.NewInt(9999998816), expectedError: types.PositionSuperfluidStakedError{PositionId: uint64(1)}, }, @@ -941,8 +941,8 @@ func (s *KeeperTestSuite) TestAddToPosition() { }, lastPositionInPool: true, timeElapsed: defaultTimeElapsed, - amount0ToAdd: sdk.ZeroInt(), - amount1ToAdd: sdk.ZeroInt(), + amount0ToAdd: osmomath.ZeroInt(), + amount1ToAdd: osmomath.ZeroInt(), }, "error: attempt to add to a position with underlying lock that is unlocking": { // setup parameters for creating a pool and position. @@ -955,7 +955,7 @@ func (s *KeeperTestSuite) TestAddToPosition() { // thus we cannot use the full amount of asset1. We calculate the below using the following formula and rounding up: // amount1 = L * (sqrtPriceUpper - sqrtPriceLower) // https://www.wolframalpha.com/input?i=3035764327.860030912175533748+*+%2870.710678118654752440+-+67.416615162732695594%29 - amount1Expected: sdk.NewInt(9999998816), + amount1Expected: osmomath.NewInt(9999998816), expectedError: types.PositionSuperfluidStakedError{PositionId: uint64(1)}, }, @@ -1011,11 +1011,11 @@ func (s *KeeperTestSuite) TestAddToPosition() { // system under test parameters sutConfigOverwrite: &lpTest{ - amount0Minimum: sdk.NewInt(1000000), + amount0Minimum: osmomath.NewInt(1000000), expectedError: types.InsufficientLiquidityCreatedError{ - Actual: sdk.NewInt(1997954).Sub(roundingError), + Actual: osmomath.NewInt(1997954).Sub(roundingError), // minimum amount we have input becomes default amt 0 expected (from original position withdraw) + 1000000 (input) - Minimum: DefaultAmt0Expected.Add(sdk.NewInt(1000000)), + Minimum: DefaultAmt0Expected.Add(osmomath.NewInt(1000000)), IsTokenZero: true, }, }, @@ -1029,11 +1029,11 @@ func (s *KeeperTestSuite) TestAddToPosition() { // system under test parameters sutConfigOverwrite: &lpTest{ - amount1Minimum: sdk.NewInt(10000000000), + amount1Minimum: osmomath.NewInt(10000000000), expectedError: types.InsufficientLiquidityCreatedError{ - Actual: sdk.NewInt(9999998816), + Actual: osmomath.NewInt(9999998816), // minimum amount we have input becomes default amt 1 expected (from original position withdraw) + 10000000000 (input) - 1 (rounding) - Minimum: DefaultAmt1Expected.Add(sdk.NewInt(10000000000)).Sub(sdk.OneInt()), + Minimum: DefaultAmt1Expected.Add(osmomath.NewInt(10000000000)).Sub(osmomath.OneInt()), IsTokenZero: false, }, }, @@ -1080,7 +1080,7 @@ func (s *KeeperTestSuite) TestAddToPosition() { if !tc.lastPositionInPool { s.FundAcc(s.TestAccs[1], fundCoins) - _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[1], config.tokensProvided, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[1], config.tokensProvided, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) } @@ -1103,8 +1103,8 @@ func (s *KeeperTestSuite) TestAddToPosition() { // config.amount0Minimum if config.expectedError != nil { s.Require().Error(err) - s.Require().Equal(sdk.Int{}, newAmt0) - s.Require().Equal(sdk.Int{}, newAmt1) + s.Require().Equal(osmomath.Int{}, newAmt0) + s.Require().Equal(osmomath.Int{}, newAmt1) s.Require().Equal(uint64(0), newPosId) s.Require().ErrorContains(err, config.expectedError.Error()) return @@ -1117,11 +1117,11 @@ func (s *KeeperTestSuite) TestAddToPosition() { // We expect the position ID to be 3 since we have two setup positions s.Require().Equal(uint64(3), newPosId) - expectedAmount1Delta := sdk.ZeroInt() + expectedAmount1Delta := osmomath.ZeroInt() // delta amount1 only exists if the actual amount from addToPosition is not equivilent to tokens provided. // delta amount1 is calculated via (amount1 to create initial position) + (amount1 added to position) - (actual amount 1) - if fundCoins.AmountOf(pool.GetToken1()).Add(tc.amount1ToAdd).Sub(newAmt1).GT(sdk.ZeroInt()) { + if fundCoins.AmountOf(pool.GetToken1()).Add(tc.amount1ToAdd).Sub(newAmt1).GT(osmomath.ZeroInt()) { expectedAmount1Delta = config.tokensProvided.AmountOf(pool.GetToken1()).Add(tc.amount1ToAdd).Sub(newAmt1) } @@ -1153,8 +1153,8 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { lastPositionInPool bool senderNotOwner bool - amount0ToAdd sdk.Int - amount1ToAdd sdk.Int + amount0ToAdd osmomath.Int + amount1ToAdd osmomath.Int }{ "single sided amount0 add": { // setup parameters for creating a pool and position. @@ -1169,15 +1169,15 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { // liquidity = Decimal("20004500137.498290928785113714000000000000000000") // calc_amount_zero_delta(liquidity, sqrtPriceLowerTick, sqrtPriceUpperTick, False) // Decimal('999999.999999999999999999999957642595723576') - // The value above gets rounded down to DefaultAmt0.Sub(sdk.OneInt()). Then, we add DefaultAmt0. - amount0Expected: DefaultAmt0.Sub(sdk.OneInt()).Add(DefaultAmt0), - amount1Expected: sdk.ZeroInt(), + // The value above gets rounded down to DefaultAmt0.Sub(osmomath.OneInt()). Then, we add DefaultAmt0. + amount0Expected: DefaultAmt0.Sub(osmomath.OneInt()).Add(DefaultAmt0), + amount1Expected: osmomath.ZeroInt(), // current tick is 0, so create the position completely above it lowerTick: 100, upperTick: 200, }, amount0ToAdd: DefaultAmt0, - amount1ToAdd: sdk.ZeroInt(), + amount1ToAdd: osmomath.ZeroInt(), }, "single sided amount1 add": { // setup parameters for creating a pool and position. @@ -1185,13 +1185,13 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { // system under test parameters sutConfigOverwrite: &lpTest{ - amount0Expected: sdk.ZeroInt(), - amount1Expected: DefaultAmt1.Add(DefaultAmt1).Sub(sdk.NewInt(1)), + amount0Expected: osmomath.ZeroInt(), + amount1Expected: DefaultAmt1.Add(DefaultAmt1).Sub(osmomath.NewInt(1)), // current tick is 0, so create the position completely below it lowerTick: -200, upperTick: -100, }, - amount0ToAdd: sdk.ZeroInt(), + amount0ToAdd: osmomath.ZeroInt(), amount1ToAdd: DefaultAmt1, }, } @@ -1219,15 +1219,15 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { // Fund tokens that is used to create the owners initial position if !tc.amount0ToAdd.IsZero() { - s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd.Add(sdk.NewInt(1))))) + s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd.Add(osmomath.NewInt(1))))) } if !tc.amount1ToAdd.IsZero() { - s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, tc.amount1ToAdd.Add(sdk.NewInt(1))))) + s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, tc.amount1ToAdd.Add(osmomath.NewInt(1))))) } // Create a position from the parameters in the test case. testCoins := sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd), sdk.NewCoin(USDC, tc.amount1ToAdd)) - positionData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), owner, testCoins, sdk.ZeroInt(), sdk.ZeroInt(), config.lowerTick, config.upperTick) + positionData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), owner, testCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), config.lowerTick, config.upperTick) s.Require().NoError(err) // Move the block time forward @@ -1239,25 +1239,25 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { if !tc.lastPositionInPool { s.FundAcc(s.TestAccs[0], fundCoins) - _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], config.tokensProvided, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + _, err = concentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], config.tokensProvided, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) } // now we fund the owner account again for the amount0ToAdd and amount1ToAdd coins. // only fund coins if the amount is non-negative or else test would panic here if !tc.amount0ToAdd.IsNegative() { - s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd.Add(sdk.NewInt(1))))) + s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(ETH, tc.amount0ToAdd.Add(osmomath.NewInt(1))))) } if !tc.amount1ToAdd.IsNegative() { - s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, tc.amount1ToAdd.Add(sdk.NewInt(1))))) + s.FundAcc(owner, sdk.NewCoins(sdk.NewCoin(USDC, tc.amount1ToAdd.Add(osmomath.NewInt(1))))) } // --- System under test --- newPosId, newAmt0, newAmt1, err := concentratedLiquidityKeeper.AddToPosition(s.Ctx, owner, positionData.ID, tc.amount0ToAdd, tc.amount1ToAdd, config.amount0Minimum, config.amount1Minimum) if config.expectedError != nil { s.Require().Error(err) - s.Require().Equal(sdk.Int{}, newAmt0) - s.Require().Equal(sdk.Int{}, newAmt1) + s.Require().Equal(osmomath.Int{}, newAmt0) + s.Require().Equal(osmomath.Int{}, newAmt1) s.Require().Equal(uint64(0), newPosId) s.Require().ErrorContains(err, config.expectedError.Error()) return @@ -1274,8 +1274,8 @@ func (s *KeeperTestSuite) TestSingleSidedAddToPosition() { postBalanceToken1 := s.App.BankKeeper.GetBalance(s.Ctx, owner, pool.GetToken1()) // Ensure that we utilized all the tokens we funded the account with when adding to the position. - s.Require().Equal(0, errToleranceOneRoundDown.Compare(postBalanceToken0.Amount.Sub(preBalanceToken0.Amount), sdk.ZeroInt())) - s.Require().Equal(0, errToleranceOneRoundDown.Compare(postBalanceToken1.Amount.Sub(preBalanceToken1.Amount), sdk.ZeroInt())) + s.Require().Equal(0, errToleranceOneRoundDown.Compare(postBalanceToken0.Amount.Sub(preBalanceToken0.Amount), osmomath.ZeroInt())) + s.Require().Equal(0, errToleranceOneRoundDown.Compare(postBalanceToken1.Amount.Sub(preBalanceToken1.Amount), osmomath.ZeroInt())) // now check that old position id has been successfully deleted _, err = s.App.ConcentratedLiquidityKeeper.GetPosition(s.Ctx, positionData.ID) @@ -1370,73 +1370,73 @@ func (s *KeeperTestSuite) TestSendCoinsBetweenPoolAndUser() { } tests := map[string]sendTest{ "asset0 and asset1 are positive, position creation (user to pool)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), }, "only asset0 is positive, position creation (user to pool)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(0)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(0)), }, "only asset1 is positive, position creation (user to pool)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(0)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(0)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), }, "only asset0 is greater than sender has, position creation (user to pool)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(100000000000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(100000000000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), expectedErr: InsufficientFundsError, }, "only asset1 is greater than sender has, position creation (user to pool)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(100000000000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(100000000000000)), expectedErr: InsufficientFundsError, }, "asset0 and asset1 are positive, withdraw (pool to user)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), poolToUser: true, }, "only asset0 is positive, withdraw (pool to user)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(0)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(0)), poolToUser: true, }, "only asset1 is positive, withdraw (pool to user)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(0)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(0)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), poolToUser: true, }, "only asset0 is greater than sender has, withdraw (pool to user)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(100000000000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(100000000000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), poolToUser: true, expectedErr: InsufficientFundsError, }, "only asset1 is greater than sender has, withdraw (pool to user)": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.NewInt(100000000000000)), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(100000000000000)), poolToUser: true, expectedErr: InsufficientFundsError, }, "asset0 is negative - error": { - coin0: sdk.Coin{Denom: "eth", Amount: sdk.NewInt(1000000).Neg()}, - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.Coin{Denom: "eth", Amount: osmomath.NewInt(1000000).Neg()}, + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), - expectedErr: types.Amount0IsNegativeError{Amount0: sdk.NewInt(1000000).Neg()}, + expectedErr: types.Amount0IsNegativeError{Amount0: osmomath.NewInt(1000000).Neg()}, }, "asset1 is negative - error": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.Coin{Denom: "usdc", Amount: sdk.NewInt(1000000).Neg()}, + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.Coin{Denom: "usdc", Amount: osmomath.NewInt(1000000).Neg()}, - expectedErr: types.Amount1IsNegativeError{Amount1: sdk.NewInt(1000000).Neg()}, + expectedErr: types.Amount1IsNegativeError{Amount1: osmomath.NewInt(1000000).Neg()}, }, "asset0 is zero - passes": { - coin0: sdk.NewCoin("eth", sdk.ZeroInt()), - coin1: sdk.NewCoin("usdc", sdk.NewInt(1000000)), + coin0: sdk.NewCoin("eth", osmomath.ZeroInt()), + coin1: sdk.NewCoin("usdc", osmomath.NewInt(1000000)), }, "asset1 is zero - passes": { - coin0: sdk.NewCoin("eth", sdk.NewInt(1000000)), - coin1: sdk.NewCoin("usdc", sdk.ZeroInt()), + coin0: sdk.NewCoin("eth", osmomath.NewInt(1000000)), + coin1: sdk.NewCoin("usdc", osmomath.ZeroInt()), }, } @@ -1457,8 +1457,8 @@ func (s *KeeperTestSuite) TestSendCoinsBetweenPoolAndUser() { } // fund pool address and user address - s.FundAcc(poolI.GetAddress(), sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(10000000000000)), sdk.NewCoin("usdc", sdk.NewInt(1000000000000)))) - s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(10000000000000)), sdk.NewCoin("usdc", sdk.NewInt(1000000000000)))) + s.FundAcc(poolI.GetAddress(), sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(10000000000000)), sdk.NewCoin("usdc", osmomath.NewInt(1000000000000)))) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(10000000000000)), sdk.NewCoin("usdc", osmomath.NewInt(1000000000000)))) // set sender and receiver based on test case sender := s.TestAccs[0] @@ -1505,12 +1505,12 @@ func (s *KeeperTestSuite) TestUpdatePosition() { upperTick int64 joinTime time.Time positionId uint64 - liquidityDelta sdk.Dec - amount0Expected sdk.Int - amount1Expected sdk.Int - expectedPositionLiquidity sdk.Dec - expectedTickLiquidity sdk.Dec - expectedPoolLiquidity sdk.Dec + liquidityDelta osmomath.Dec + amount0Expected osmomath.Int + amount1Expected osmomath.Int + expectedPositionLiquidity osmomath.Dec + expectedTickLiquidity osmomath.Dec + expectedPoolLiquidity osmomath.Dec numPositions int expectedError bool } @@ -1544,9 +1544,9 @@ func (s *KeeperTestSuite) TestUpdatePosition() { amount0Expected: DefaultAmt0Expected.Neg(), // Note: rounds down in favor of the pool (compared to the positive case which rounds up). amount1Expected: DefaultAmt1Expected.Sub(roundingError).Neg(), - expectedPositionLiquidity: sdk.ZeroDec(), - expectedTickLiquidity: sdk.ZeroDec(), - expectedPoolLiquidity: sdk.ZeroDec(), + expectedPositionLiquidity: osmomath.ZeroDec(), + expectedTickLiquidity: osmomath.ZeroDec(), + expectedPoolLiquidity: osmomath.ZeroDec(), numPositions: 1, expectedError: false, }, @@ -1568,7 +1568,7 @@ func (s *KeeperTestSuite) TestUpdatePosition() { lowerTick: DefaultLowerTick, upperTick: DefaultUpperTick, joinTime: DefaultJoinTime, - liquidityDelta: DefaultLiquidityAmt.Neg().Mul(sdk.NewDec(2)), + liquidityDelta: DefaultLiquidityAmt.Neg().Mul(osmomath.NewDec(2)), numPositions: 1, expectedError: true, }, @@ -1627,7 +1627,7 @@ func (s *KeeperTestSuite) TestUpdatePosition() { 1, s.TestAccs[0], DefaultCoins, - sdk.ZeroInt(), sdk.ZeroInt(), + osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick, ) s.Require().NoError(err) @@ -1650,8 +1650,8 @@ func (s *KeeperTestSuite) TestUpdatePosition() { if tc.expectedError { s.Require().Error(err) - s.Require().Equal(sdk.Int{}, updateData.Amount0) - s.Require().Equal(sdk.Int{}, updateData.Amount1) + s.Require().Equal(osmomath.Int{}, updateData.Amount0) + s.Require().Equal(osmomath.Int{}, updateData.Amount1) } else { s.Require().NoError(err) @@ -1664,8 +1664,8 @@ func (s *KeeperTestSuite) TestUpdatePosition() { } var ( - expectedAmount0 sdk.Dec - expectedAmount1 sdk.Dec + expectedAmount0 osmomath.Dec + expectedAmount1 osmomath.Dec ) // For the context of this test case, we are not testing the calculation of the amounts @@ -1677,8 +1677,8 @@ func (s *KeeperTestSuite) TestUpdatePosition() { expectedAmount0, expectedAmount1, err = pool.CalcActualAmounts(s.Ctx, tc.lowerTick, tc.upperTick, tc.liquidityDelta) s.Require().NoError(err) } else { - expectedAmount0 = tc.amount0Expected.ToDec() - expectedAmount1 = tc.amount1Expected.ToDec() + expectedAmount0 = tc.amount0Expected.ToLegacyDec() + expectedAmount1 = tc.amount1Expected.ToLegacyDec() } s.Require().Equal(expectedAmount0.TruncateInt().String(), updateData.Amount0.String()) @@ -1706,14 +1706,14 @@ func (s *KeeperTestSuite) TestUpdatePosition() { func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { sqrt := func(x int64) osmomath.BigDec { - sqrt, err := osmomath.MonotonicSqrt(sdk.NewDec(x)) + sqrt, err := osmomath.MonotonicSqrt(osmomath.NewDec(x)) s.Require().NoError(err) - return osmomath.BigDecFromSDKDec(sqrt) + return osmomath.BigDecFromDec(sqrt) } type sendTest struct { - amount0Desired sdk.Int - amount1Desired sdk.Int + amount0Desired osmomath.Int + amount1Desired osmomath.Int tickSpacing uint64 expectedCurrSqrtPrice osmomath.BigDec expectedTick int64 @@ -1728,22 +1728,22 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { expectedTick: DefaultCurrTick, }, "100_000_050 and tick spacing 100, price level where curr sqrt price does not translate to allowed tick (assumes exponent at price one of -6 and tick spacing of 100)": { - amount0Desired: sdk.OneInt(), - amount1Desired: sdk.NewInt(100_000_050), + amount0Desired: osmomath.OneInt(), + amount1Desired: osmomath.NewInt(100_000_050), tickSpacing: DefaultTickSpacing, expectedCurrSqrtPrice: sqrt(100_000_050), expectedTick: 72000000, }, "100_000_051 and tick spacing 100, price level where curr sqrt price does not translate to allowed tick (assumes exponent at price one of -6 and tick spacing of 100)": { - amount0Desired: sdk.OneInt(), - amount1Desired: sdk.NewInt(100_000_051), + amount0Desired: osmomath.OneInt(), + amount1Desired: osmomath.NewInt(100_000_051), tickSpacing: DefaultTickSpacing, expectedCurrSqrtPrice: sqrt(100_000_051), expectedTick: 72000000, }, "100_000_051 and tick spacing 1, price level where curr sqrt price translates to allowed tick (assumes exponent at price one of -6 and tick spacing of 1)": { - amount0Desired: sdk.OneInt(), - amount1Desired: sdk.NewInt(100_000_051), + amount0Desired: osmomath.OneInt(), + amount1Desired: osmomath.NewInt(100_000_051), tickSpacing: 1, expectedCurrSqrtPrice: sqrt(100_000_051), // We expect the returned tick to always be rounded down. @@ -1752,22 +1752,22 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { expectedTick: 72000000, }, "error: amount0Desired is zero": { - amount0Desired: sdk.ZeroInt(), + amount0Desired: osmomath.ZeroInt(), amount1Desired: DefaultAmt1, tickSpacing: DefaultTickSpacing, - expectedError: types.InitialLiquidityZeroError{Amount0: sdk.ZeroInt(), Amount1: DefaultAmt1}, + expectedError: types.InitialLiquidityZeroError{Amount0: osmomath.ZeroInt(), Amount1: DefaultAmt1}, }, "error: amount1Desired is zero": { amount0Desired: DefaultAmt0, - amount1Desired: sdk.ZeroInt(), + amount1Desired: osmomath.ZeroInt(), tickSpacing: DefaultTickSpacing, - expectedError: types.InitialLiquidityZeroError{Amount0: DefaultAmt0, Amount1: sdk.ZeroInt()}, + expectedError: types.InitialLiquidityZeroError{Amount0: DefaultAmt0, Amount1: osmomath.ZeroInt()}, }, "error: both amount0Desired and amount01Desired is zero": { - amount0Desired: sdk.ZeroInt(), - amount1Desired: sdk.ZeroInt(), + amount0Desired: osmomath.ZeroInt(), + amount1Desired: osmomath.ZeroInt(), tickSpacing: DefaultTickSpacing, - expectedError: types.InitialLiquidityZeroError{Amount0: sdk.ZeroInt(), Amount1: sdk.ZeroInt()}, + expectedError: types.InitialLiquidityZeroError{Amount0: osmomath.ZeroInt(), Amount1: osmomath.ZeroInt()}, }, } @@ -1777,7 +1777,7 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { s.SetupTest() // create a CL pool - pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, sdk.ZeroDec()) + pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, osmomath.ZeroDec()) // System under test err := s.App.ConcentratedLiquidityKeeper.InitializeInitialPositionForPool(s.Ctx, pool, tc.amount0Desired, tc.amount1Desired) @@ -1801,7 +1801,7 @@ func (s *KeeperTestSuite) TestInitializeInitialPositionForPool() { func (s *KeeperTestSuite) TestInverseRelation_CreatePosition_WithdrawPosition() { var ( errToleranceOneRoundUp = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.OneDec(), + AdditiveTolerance: osmomath.OneDec(), RoundingDir: osmomath.RoundUp, } ) @@ -1823,7 +1823,7 @@ func (s *KeeperTestSuite) TestInverseRelation_CreatePosition_WithdrawPosition() s.FundAcc(s.TestAccs[0], PoolCreationFee) // Create a CL pool with custom tickSpacing - poolID, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, sdk.ZeroDec())) + poolID, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], ETH, USDC, tc.tickSpacing, osmomath.ZeroDec())) s.Require().NoError(err) poolBefore, err := clKeeper.GetPool(s.Ctx, poolID) s.Require().NoError(err) @@ -1897,7 +1897,7 @@ func (s *KeeperTestSuite) TestInverseRelation_CreatePosition_WithdrawPosition() positionLiquidity, err := clKeeper.GetPositionLiquidity(s.Ctx, tc.positionId) s.Require().Error(err) s.Require().ErrorAs(err, &types.PositionIdNotFoundError{PositionId: tc.positionId}) - s.Require().Equal(sdk.Dec{}, positionLiquidity) + s.Require().Equal(osmomath.Dec{}, positionLiquidity) // 4. Check that pool has come back to original state @@ -1961,7 +1961,7 @@ func (s *KeeperTestSuite) TestUninitializePool() { actualSqrtPrice := pool.GetCurrentSqrtPrice() actualTick := pool.GetCurrentTick() - s.Require().Equal(osmomath.ZeroDec(), actualSqrtPrice) + s.Require().Equal(osmomath.ZeroBigDec(), actualSqrtPrice) s.Require().Equal(int64(0), actualTick) }) } @@ -2041,7 +2041,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex int lowerTickGiven int64 upperTickGiven int64 - liquidityDeltaGiven sdk.Dec + liquidityDeltaGiven osmomath.Dec joinTimeGiven time.Time poolIdGiven uint64 modifyPositionLiquidity bool @@ -2052,7 +2052,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, }, @@ -2061,7 +2061,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.OneDec().Neg(), // negative + liquidityDeltaGiven: osmomath.OneDec().Neg(), // negative joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, }, @@ -2070,7 +2070,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, }, @@ -2079,7 +2079,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.NewDec(2), // non negative + liquidityDeltaGiven: osmomath.NewDec(2), // non negative joinTimeGiven: DefaultJoinTime, modifyPositionLiquidity: true, // modifies position to have less liquidity than liquidity delta poolIdGiven: defaultPoolId, @@ -2089,7 +2089,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: DefaultLiquidityAmt.Add(sdk.OneDec()).Neg(), + liquidityDeltaGiven: DefaultLiquidityAmt.Add(osmomath.OneDec()).Neg(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.LiquidityWithdrawalError{}, @@ -2103,7 +2103,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 1, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.PositionOwnerMismatchError{}, @@ -2113,7 +2113,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick + 1, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.LowerTickMismatchError{}, @@ -2123,7 +2123,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick + 1, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.LowerTickMismatchError{}, @@ -2133,7 +2133,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick + 1, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.LowerTickMismatchError{}, @@ -2143,7 +2143,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick + 1, - liquidityDeltaGiven: sdk.OneDec(), + liquidityDeltaGiven: osmomath.OneDec(), joinTimeGiven: DefaultJoinTime, poolIdGiven: defaultPoolId, expectError: types.PositionsNotInSamePoolError{}, @@ -2153,7 +2153,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { updateInitiatorIndex: 0, lowerTickGiven: DefaultLowerTick, upperTickGiven: DefaultUpperTick, - liquidityDeltaGiven: sdk.NewDec(2).Neg(), + liquidityDeltaGiven: osmomath.NewDec(2).Neg(), joinTimeGiven: DefaultJoinTime, modifyPositionLiquidity: true, // modifies position to have less liquidity than liquidity delta poolIdGiven: defaultPoolId, @@ -2190,7 +2190,7 @@ func (s *KeeperTestSuite) TestValidatePositionUpdateById() { s.Require().NoError(err) owner, err := sdk.AccAddressFromBech32(position.Address) s.Require().NoError(err) - s.clk.SetPosition(s.Ctx, defaultPoolId, owner, position.LowerTick, position.UpperTick, position.JoinTime, sdk.OneDec(), position.PositionId, 0) + s.clk.SetPosition(s.Ctx, defaultPoolId, owner, position.LowerTick, position.UpperTick, position.JoinTime, osmomath.OneDec(), position.PositionId, 0) } err := clKeeper.ValidatePositionUpdateById(s.Ctx, tc.positionId, updateInitiator, tc.lowerTickGiven, tc.upperTickGiven, tc.liquidityDeltaGiven, tc.joinTimeGiven, tc.poolIdGiven) diff --git a/x/concentrated-liquidity/math/math.go b/x/concentrated-liquidity/math/math.go index 3bf2aca1fff..b1a0930411d 100644 --- a/x/concentrated-liquidity/math/math.go +++ b/x/concentrated-liquidity/math/math.go @@ -3,8 +3,6 @@ package math import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" ) @@ -13,14 +11,14 @@ import ( // sqrtPriceB is the larger of sqrtpCur and the nextPrice // Liquidity0 = amount0 * (sqrtPriceA * sqrtPriceB) / (sqrtPriceB - sqrtPriceA) // TODO: Define rounding properties we expect to hold for this function. -func Liquidity0(amount sdk.Int, sqrtPriceA, sqrtPriceB osmomath.BigDec) sdk.Dec { +func Liquidity0(amount osmomath.Int, sqrtPriceA, sqrtPriceB osmomath.BigDec) osmomath.Dec { if sqrtPriceA.GT(sqrtPriceB) { sqrtPriceA, sqrtPriceB = sqrtPriceB, sqrtPriceA } // We convert to BigDec to avoid precision loss when calculating liquidity. Without doing this, // our liquidity calculations will be off from our theoretical calculations within our tests. - amountBigDec := osmomath.BigDecFromSDKDec(amount.ToDec()) + amountBigDec := osmomath.BigDecFromDec(amount.ToLegacyDec()) product := sqrtPriceA.Mul(sqrtPriceB) diff := sqrtPriceB.Sub(sqrtPriceA) @@ -28,27 +26,27 @@ func Liquidity0(amount sdk.Int, sqrtPriceA, sqrtPriceB osmomath.BigDec) sdk.Dec panic(fmt.Sprintf("liquidity0 diff is zero: sqrtPriceA %s sqrtPriceB %s", sqrtPriceA, sqrtPriceB)) } - return amountBigDec.MulMut(product).QuoMut(diff).SDKDec() + return amountBigDec.MulMut(product).QuoMut(diff).Dec() } // Liquidity1 takes an amount of asset1 in the pool as well as the sqrtpCur and the nextPrice // sqrtPriceA is the smaller of sqrtpCur and the nextPrice // sqrtPriceB is the larger of sqrtpCur and the nextPrice // Liquidity1 = amount1 / (sqrtPriceB - sqrtPriceA) -func Liquidity1(amount sdk.Int, sqrtPriceA, sqrtPriceB osmomath.BigDec) sdk.Dec { +func Liquidity1(amount osmomath.Int, sqrtPriceA, sqrtPriceB osmomath.BigDec) osmomath.Dec { if sqrtPriceA.GT(sqrtPriceB) { sqrtPriceA, sqrtPriceB = sqrtPriceB, sqrtPriceA } // We convert to BigDec to avoid precision loss when calculating liquidity. Without doing this, // our liquidity calculations will be off from our theoretical calculations within our tests. - amountBigDec := osmomath.BigDecFromSDKDec(amount.ToDec()) + amountBigDec := osmomath.BigDecFromDec(amount.ToLegacyDec()) diff := sqrtPriceB.Sub(sqrtPriceA) if diff.IsZero() { panic(fmt.Sprintf("liquidity1 diff is zero: sqrtPriceA %s sqrtPriceB %s", sqrtPriceA, sqrtPriceB)) } - return amountBigDec.QuoMut(diff).SDKDec() + return amountBigDec.QuoMut(diff).Dec() } // CalcAmount0Delta takes the asset with the smaller liquidity in the pool as well as the sqrtpCur and the nextPrice and calculates the amount of asset 0 @@ -173,7 +171,7 @@ func GetNextSqrtPriceFromAmount1OutRoundingDown(sqrtPriceCurrent, liquidity, amo // GetLiquidityFromAmounts takes the current sqrtPrice and the sqrtPrice for the upper and lower ticks as well as the amounts of asset0 and asset1 // and returns the resulting liquidity from these inputs. -func GetLiquidityFromAmounts(sqrtPrice osmomath.BigDec, sqrtPriceA, sqrtPriceB osmomath.BigDec, amount0, amount1 sdk.Int) (liquidity sdk.Dec) { +func GetLiquidityFromAmounts(sqrtPrice osmomath.BigDec, sqrtPriceA, sqrtPriceB osmomath.BigDec, amount0, amount1 osmomath.Int) (liquidity osmomath.Dec) { // Reorder the prices so that sqrtPriceA is the smaller of the two. // todo: Remove this. if sqrtPriceA.GT(sqrtPriceB) { @@ -188,7 +186,7 @@ func GetLiquidityFromAmounts(sqrtPrice osmomath.BigDec, sqrtPriceA, sqrtPriceB o // as both would trigger a division by zero), then we use the minimum of the liquidity0 and liquidity1 formulas. liquidity0 := Liquidity0(amount0, sqrtPrice, sqrtPriceB) liquidity1 := Liquidity1(amount1, sqrtPrice, sqrtPriceA) - liquidity = sdk.MinDec(liquidity0, liquidity1) + liquidity = osmomath.MinDec(liquidity0, liquidity1) } else { // If the current price is greater than the upper tick, then we use the liquidity1 formula. liquidity = Liquidity1(amount1, sqrtPriceB, sqrtPriceA) @@ -198,11 +196,11 @@ func GetLiquidityFromAmounts(sqrtPrice osmomath.BigDec, sqrtPriceA, sqrtPriceB o } // SquareRoundUp squares and rounds up at precision end. -func SquareRoundUp(sqrtPrice sdk.Dec) sdk.Dec { +func SquareRoundUp(sqrtPrice osmomath.Dec) osmomath.Dec { return sqrtPrice.MulRoundUp(sqrtPrice) } // SquareTruncate squares and truncates at precision end. -func SquareTruncate(sqrtPrice sdk.Dec) sdk.Dec { +func SquareTruncate(sqrtPrice osmomath.Dec) osmomath.Dec { return sqrtPrice.MulTruncate(sqrtPrice) } diff --git a/x/concentrated-liquidity/math/math_test.go b/x/concentrated-liquidity/math/math_test.go index bddee589eec..930327ddbeb 100644 --- a/x/concentrated-liquidity/math/math_test.go +++ b/x/concentrated-liquidity/math/math_test.go @@ -3,7 +3,6 @@ package math_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/osmosis-labs/osmosis/osmomath" @@ -12,13 +11,13 @@ import ( ) var ( - sqrt4545 = sdk.MustNewDecFromStr("67.416615162732695594") - sqrt5000 = sdk.MustNewDecFromStr("70.710678118654752440") - sqrt5500 = sdk.MustNewDecFromStr("74.161984870956629487") + sqrt4545 = osmomath.MustNewDecFromStr("67.416615162732695594") + sqrt5000 = osmomath.MustNewDecFromStr("70.710678118654752440") + sqrt5500 = osmomath.MustNewDecFromStr("74.161984870956629487") - sqrt4545BigDec = osmomath.BigDecFromSDKDec(sqrt4545) - sqrt5000BigDec = osmomath.BigDecFromSDKDec(sqrt5000) - sqrt5500BigDec = osmomath.BigDecFromSDKDec(sqrt5500) + sqrt4545BigDec = osmomath.BigDecFromDec(sqrt4545) + sqrt5000BigDec = osmomath.BigDecFromDec(sqrt5000) + sqrt5500BigDec = osmomath.BigDecFromDec(sqrt5500) ) // liquidity1 takes an amount of asset1 in the pool as well as the sqrtpCur and the nextPrice @@ -29,13 +28,13 @@ func TestLiquidity1(t *testing.T) { testCases := map[string]struct { currentSqrtP osmomath.BigDec sqrtPLow osmomath.BigDec - amount1Desired sdk.Int + amount1Desired osmomath.Int expectedLiquidity string }{ "happy path": { currentSqrtP: sqrt5000BigDec, // 5000 sqrtPLow: sqrt4545BigDec, // 4545 - amount1Desired: sdk.NewInt(5000000000), + amount1Desired: osmomath.NewInt(5000000000), expectedLiquidity: "1517882343.751510418088349649", // https://www.wolframalpha.com/input?i=5000000000+%2F+%2870.710678118654752440+-+67.416615162732695594%29 }, @@ -59,20 +58,20 @@ func TestLiquidity0(t *testing.T) { testCases := map[string]struct { currentSqrtP osmomath.BigDec sqrtPHigh osmomath.BigDec - amount0Desired sdk.Int + amount0Desired osmomath.Int expectedLiquidity string }{ "happy path": { currentSqrtP: sqrt5000BigDec, // 5000 sqrtPHigh: sqrt5500BigDec, // 5500 - amount0Desired: sdk.NewInt(1000000), + amount0Desired: osmomath.NewInt(1000000), expectedLiquidity: "1519437308.014768571720923239", // https://www.wolframalpha.com/input?i=1000000+*+%2870.710678118654752440*+74.161984870956629487%29+%2F+%2874.161984870956629487+-+70.710678118654752440%29 }, "sqrtPriceA greater than sqrtPriceB": { currentSqrtP: sqrt5500BigDec, // 5000 sqrtPHigh: sqrt5000BigDec, - amount0Desired: sdk.NewInt(1000000), + amount0Desired: osmomath.NewInt(1000000), expectedLiquidity: "1519437308.014768571720923239", // https://www.wolframalpha.com/input?i=1000000+*+%2870.710678118654752440*+74.161984870956629487%29+%2F+%2874.161984870956629487+-+70.710678118654752440%29 }, @@ -100,27 +99,27 @@ func TestCalcAmount0Delta(t *testing.T) { amount0Expected osmomath.BigDec }{ "happy path": { - liquidity: osmomath.MustNewDecFromStr("1517882343.751510418088349649"), // we use the smaller liquidity between liq0 and liq1 - sqrtPA: sqrt5000BigDec, // 5000 - sqrtPB: sqrt5500BigDec, // 5500 + liquidity: osmomath.MustNewBigDecFromStr("1517882343.751510418088349649"), // we use the smaller liquidity between liq0 and liq1 + sqrtPA: sqrt5000BigDec, // 5000 + sqrtPB: sqrt5500BigDec, // 5500 roundUp: false, // calculated with x/concentrated-liquidity/python/clmath.py round_decimal(amount0, 36, ROUND_FLOOR) - amount0Expected: osmomath.MustNewDecFromStr("998976.618347426388356629926969277767437533"), // truncated at precision end. + amount0Expected: osmomath.MustNewBigDecFromStr("998976.618347426388356629926969277767437533"), // truncated at precision end. isWithTolerance: false, }, "happy path, sqrtPriceA greater than sqrtPrice B": { // commute prior vector - liquidity: osmomath.MustNewDecFromStr("1517882343.751510418088349649"), + liquidity: osmomath.MustNewBigDecFromStr("1517882343.751510418088349649"), sqrtPA: sqrt5500BigDec, sqrtPB: sqrt5000BigDec, roundUp: false, // calculated with x/concentrated-liquidity/python/clmath.py round_decimal(amount0, 36, ROUND_FLOOR) - amount0Expected: osmomath.MustNewDecFromStr("998976.618347426388356629926969277767437533"), + amount0Expected: osmomath.MustNewBigDecFromStr("998976.618347426388356629926969277767437533"), isWithTolerance: false, }, "round down: large liquidity amount in wide price range": { // Note the values are hand-picked to cause multiplication of 2 large numbers // causing the magnitude of truncations to be larger - // while staying under bit length of sdk.Dec + // while staying under bit length of osmomath.Dec // from decimal import * // from math import * // getcontext().prec = 100 @@ -128,20 +127,20 @@ func TestCalcAmount0Delta(t *testing.T) { // min_sqrt_p = Decimal("0.000000152731791058") // liq = Decimal("931361973132462178951297") // liq * (max_sqrt_p - min_sqrt_p) / (max_sqrt_p * min_sqrt_p) - liquidity: osmomath.MustNewDecFromStr("931361973132462178951297"), + liquidity: osmomath.MustNewBigDecFromStr("931361973132462178951297"), // price: 0.000000000000023327 - sqrtPA: osmomath.MustNewDecFromStr("0.000000152731791058"), + sqrtPA: osmomath.MustNewBigDecFromStr("0.000000152731791058"), // price: 952361284325389721913 - sqrtPB: osmomath.MustNewDecFromStr("30860351331.852813530648276680"), + sqrtPB: osmomath.MustNewBigDecFromStr("30860351331.852813530648276680"), roundUp: false, // calculated with x/concentrated-liquidity/python/clmath.py - amount0Expected: osmomath.MustNewDecFromStr("6098022989717817431593106314408.88812810159039320984467945943"), // truncated at precision end. + amount0Expected: osmomath.MustNewBigDecFromStr("6098022989717817431593106314408.88812810159039320984467945943"), // truncated at precision end. isWithTolerance: true, }, "round up: large liquidity amount in wide price range": { // Note the values are hand-picked to cause multiplication of 2 large numbers // causing the magnitude of truncations to be larger - // while staying under bit length of sdk.Dec + // while staying under bit length of osmomath.Dec // from decimal import * // from math import * // getcontext().prec = 100 @@ -149,13 +148,13 @@ func TestCalcAmount0Delta(t *testing.T) { // min_sqrt_p = Decimal("0.000000152731791058") // liq = Decimal("931361973132462178951297") // liq * (max_sqrt_p - min_sqrt_p) / (max_sqrt_p * min_sqrt_p) - liquidity: osmomath.MustNewDecFromStr("931361973132462178951297"), + liquidity: osmomath.MustNewBigDecFromStr("931361973132462178951297"), // price: 0.000000000000023327 - sqrtPA: osmomath.MustNewDecFromStr("0.000000152731791058"), + sqrtPA: osmomath.MustNewBigDecFromStr("0.000000152731791058"), // price: 952361284325389721913 - sqrtPB: osmomath.MustNewDecFromStr("30860351331.852813530648276680"), + sqrtPB: osmomath.MustNewBigDecFromStr("30860351331.852813530648276680"), roundUp: true, - amount0Expected: osmomath.MustNewDecFromStr("6098022989717817431593106314408.88812810159039320984467945943").Ceil(), // rounded up at precision end. + amount0Expected: osmomath.MustNewBigDecFromStr("6098022989717817431593106314408.88812810159039320984467945943").Ceil(), // rounded up at precision end. isWithTolerance: true, }, } @@ -177,7 +176,7 @@ func TestCalcAmount0Delta(t *testing.T) { } tolerance := osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.SmallestDec(), + MultiplicativeTolerance: osmomath.SmallestDec(), RoundingDir: roundingDir, } @@ -202,16 +201,16 @@ func TestCalcAmount1Delta(t *testing.T) { amount1Expected osmomath.BigDec }{ "round down": { - liquidity: osmomath.MustNewDecFromStr("1517882343.751510418088349649"), // we use the smaller liquidity between liq0 and liq1 - sqrtPA: sqrt5000BigDec, // 5000 - sqrtPB: sqrt4545BigDec, // 4545 + liquidity: osmomath.MustNewBigDecFromStr("1517882343.751510418088349649"), // we use the smaller liquidity between liq0 and liq1 + sqrtPA: sqrt5000BigDec, // 5000 + sqrtPB: sqrt4545BigDec, // 4545 roundUp: false, // calculated with x/concentrated-liquidity/python/clmath.py - amount1Expected: osmomath.MustNewDecFromStr("4999999999.999999999999999999696837821702147054"), + amount1Expected: osmomath.MustNewBigDecFromStr("4999999999.999999999999999999696837821702147054"), }, "round down: large liquidity amount in wide price range": { // Note the values are hand-picked to cause multiplication of 2 large numbers - // while staying under bit length of sdk.Dec + // while staying under bit length of osmomath.Dec // from decimal import * // from math import * // getcontext().prec = 100 @@ -219,18 +218,18 @@ func TestCalcAmount1Delta(t *testing.T) { // min_sqrt_p = Decimal("0.000000152731791058") // liq = Decimal("931361973132462178951297") // liq * (max_sqrt_p - min_sqrt_p) - liquidity: osmomath.MustNewDecFromStr("931361973132462178951297"), + liquidity: osmomath.MustNewBigDecFromStr("931361973132462178951297"), // price: 0.000000000000023327 - sqrtPA: osmomath.MustNewDecFromStr("0.000000152731791058"), + sqrtPA: osmomath.MustNewBigDecFromStr("0.000000152731791058"), // price: 952361284325389721913 - sqrtPB: osmomath.MustNewDecFromStr("30860351331.852813530648276680"), + sqrtPB: osmomath.MustNewBigDecFromStr("30860351331.852813530648276680"), roundUp: false, // calculated with x/concentrated-liquidity/python/clmath.py - amount1Expected: osmomath.MustNewDecFromStr("28742157707995443393876876754535992.801567623738751734"), // truncated at precision end. + amount1Expected: osmomath.MustNewBigDecFromStr("28742157707995443393876876754535992.801567623738751734"), // truncated at precision end. }, "round up: large liquidity amount in wide price range": { // Note the values are hand-picked to cause multiplication of 2 large numbers - // while staying under bit length of sdk.Dec + // while staying under bit length of osmomath.Dec // from decimal import * // from math import * // getcontext().prec = 100 @@ -238,13 +237,13 @@ func TestCalcAmount1Delta(t *testing.T) { // min_sqrt_p = Decimal("0.000000152731791058") // liq = Decimal("931361973132462178951297") // liq * (max_sqrt_p - min_sqrt_p) - liquidity: osmomath.MustNewDecFromStr("931361973132462178951297"), + liquidity: osmomath.MustNewBigDecFromStr("931361973132462178951297"), // price: 0.000000000000023327 - sqrtPA: osmomath.MustNewDecFromStr("0.000000152731791058"), + sqrtPA: osmomath.MustNewBigDecFromStr("0.000000152731791058"), // price: 952361284325389721913 - sqrtPB: osmomath.MustNewDecFromStr("30860351331.852813530648276680"), + sqrtPB: osmomath.MustNewBigDecFromStr("30860351331.852813530648276680"), roundUp: true, - amount1Expected: osmomath.MustNewDecFromStr("28742157707995443393876876754535992.801567623738751734").Ceil(), // round up at precision end. + amount1Expected: osmomath.MustNewBigDecFromStr("28742157707995443393876876754535992.801567623738751734").Ceil(), // round up at precision end. }, } @@ -260,10 +259,10 @@ func TestCalcAmount1Delta(t *testing.T) { } func TestGetLiquidityFromAmounts(t *testing.T) { - sqrt := func(x sdk.Dec) osmomath.BigDec { + sqrt := func(x osmomath.Dec) osmomath.BigDec { sqrt, err := osmomath.MonotonicSqrt(x) require.NoError(t, err) - return osmomath.BigDecFromSDKDec(sqrt) + return osmomath.BigDecFromDec(sqrt) } testCases := map[string]struct { @@ -271,87 +270,87 @@ func TestGetLiquidityFromAmounts(t *testing.T) { sqrtPHigh osmomath.BigDec sqrtPLow osmomath.BigDec // the amount of token0 that will need to be sold to move the price from P_cur to P_low - amount0Desired sdk.Int + amount0Desired osmomath.Int // the amount of token 1 that will need to be sold to move the price from P_cur to P_high. - amount1Desired sdk.Int + amount1Desired osmomath.Int expectedLiquidity string // liq0 = rate of change of reserves of token 1 for a change between sqrt(P_cur) and sqrt(P_low) // liq1 = rate of change of reserves of token 1 for a change between sqrt(P_cur) and sqrt(P_high) // price of x in terms of y - expectedLiquidity0 sdk.Dec - expectedLiquidity1 sdk.Dec + expectedLiquidity0 osmomath.Dec + expectedLiquidity1 osmomath.Dec }{ "happy path (case A)": { - currentSqrtP: osmomath.MustNewDecFromStr("67"), // 4489 - sqrtPHigh: sqrt5500BigDec, // 5500 - sqrtPLow: sqrt4545BigDec, // 4545 - amount0Desired: sdk.NewInt(1000000), - amount1Desired: sdk.ZeroInt(), + currentSqrtP: osmomath.MustNewBigDecFromStr("67"), // 4489 + sqrtPHigh: sqrt5500BigDec, // 5500 + sqrtPLow: sqrt4545BigDec, // 4545 + amount0Desired: osmomath.NewInt(1000000), + amount1Desired: osmomath.ZeroInt(), expectedLiquidity: "741212151.448720111852782017", }, "happy path (case A, but with sqrtPriceA greater than sqrtPriceB)": { - currentSqrtP: osmomath.MustNewDecFromStr("67"), // 4489 - sqrtPHigh: sqrt4545BigDec, // 4545 - sqrtPLow: sqrt5500BigDec, // 5500 - amount0Desired: sdk.NewInt(1000000), - amount1Desired: sdk.ZeroInt(), + currentSqrtP: osmomath.MustNewBigDecFromStr("67"), // 4489 + sqrtPHigh: sqrt4545BigDec, // 4545 + sqrtPLow: sqrt5500BigDec, // 5500 + amount0Desired: osmomath.NewInt(1000000), + amount1Desired: osmomath.ZeroInt(), expectedLiquidity: "741212151.448720111852782017", }, "happy path (case B)": { currentSqrtP: sqrt5000BigDec, // 5000 sqrtPHigh: sqrt5500BigDec, // 5500 sqrtPLow: sqrt4545BigDec, // 4545 - amount0Desired: sdk.NewInt(1000000), - amount1Desired: sdk.NewInt(5000000000), + amount0Desired: osmomath.NewInt(1000000), + amount1Desired: osmomath.NewInt(5000000000), expectedLiquidity: "1517882343.751510418088349649", }, "happy path (case C)": { - currentSqrtP: osmomath.MustNewDecFromStr("75"), // 5625 - sqrtPHigh: sqrt5500BigDec, // 5500 - sqrtPLow: sqrt4545BigDec, // 4545 - amount0Desired: sdk.ZeroInt(), - amount1Desired: sdk.NewInt(5000000000), + currentSqrtP: osmomath.MustNewBigDecFromStr("75"), // 5625 + sqrtPHigh: sqrt5500BigDec, // 5500 + sqrtPLow: sqrt4545BigDec, // 4545 + amount0Desired: osmomath.ZeroInt(), + amount1Desired: osmomath.NewInt(5000000000), expectedLiquidity: "741249214.836069764856625637", }, "full range, price proportional to amounts, equal liquidities (some rounding error) price of 4": { - currentSqrtP: sqrt(sdk.NewDec(4)), - sqrtPHigh: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), - sqrtPLow: osmomath.BigDecFromSDKDec(types.MinSqrtPrice), - amount0Desired: sdk.NewInt(4), - amount1Desired: sdk.NewInt(16), - - expectedLiquidity: sdk.MustNewDecFromStr("8.000000000000000001").String(), - expectedLiquidity0: sdk.MustNewDecFromStr("8.000000000000000001"), - expectedLiquidity1: sdk.MustNewDecFromStr("8.000000004000000002"), + currentSqrtP: sqrt(osmomath.NewDec(4)), + sqrtPHigh: osmomath.BigDecFromDec(types.MaxSqrtPrice), + sqrtPLow: osmomath.BigDecFromDec(types.MinSqrtPrice), + amount0Desired: osmomath.NewInt(4), + amount1Desired: osmomath.NewInt(16), + + expectedLiquidity: osmomath.MustNewDecFromStr("8.000000000000000001").String(), + expectedLiquidity0: osmomath.MustNewDecFromStr("8.000000000000000001"), + expectedLiquidity1: osmomath.MustNewDecFromStr("8.000000004000000002"), }, "full range, price proportional to amounts, equal liquidities (some rounding error) price of 2": { - currentSqrtP: sqrt(sdk.NewDec(2)), - sqrtPHigh: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), - sqrtPLow: osmomath.BigDecFromSDKDec(types.MinSqrtPrice), - amount0Desired: sdk.NewInt(1), - amount1Desired: sdk.NewInt(2), - - expectedLiquidity: sdk.MustNewDecFromStr("1.414213562373095049").String(), - expectedLiquidity0: sdk.MustNewDecFromStr("1.414213562373095049"), - expectedLiquidity1: sdk.MustNewDecFromStr("1.414213563373095049"), + currentSqrtP: sqrt(osmomath.NewDec(2)), + sqrtPHigh: osmomath.BigDecFromDec(types.MaxSqrtPrice), + sqrtPLow: osmomath.BigDecFromDec(types.MinSqrtPrice), + amount0Desired: osmomath.NewInt(1), + amount1Desired: osmomath.NewInt(2), + + expectedLiquidity: osmomath.MustNewDecFromStr("1.414213562373095049").String(), + expectedLiquidity0: osmomath.MustNewDecFromStr("1.414213562373095049"), + expectedLiquidity1: osmomath.MustNewDecFromStr("1.414213563373095049"), }, "not full range, price proportional to amounts, non equal liquidities": { - currentSqrtP: sqrt(sdk.NewDec(2)), - sqrtPHigh: sqrt(sdk.NewDec(3)), - sqrtPLow: sqrt(sdk.NewDec(1)), - amount0Desired: sdk.NewInt(1), - amount1Desired: sdk.NewInt(2), - - expectedLiquidity: sdk.MustNewDecFromStr("4.828427124746190095").String(), - expectedLiquidity0: sdk.MustNewDecFromStr("7.706742302257039729"), - expectedLiquidity1: sdk.MustNewDecFromStr("4.828427124746190095"), + currentSqrtP: sqrt(osmomath.NewDec(2)), + sqrtPHigh: sqrt(osmomath.NewDec(3)), + sqrtPLow: sqrt(osmomath.NewDec(1)), + amount0Desired: osmomath.NewInt(1), + amount1Desired: osmomath.NewInt(2), + + expectedLiquidity: osmomath.MustNewDecFromStr("4.828427124746190095").String(), + expectedLiquidity0: osmomath.MustNewDecFromStr("7.706742302257039729"), + expectedLiquidity1: osmomath.MustNewDecFromStr("4.828427124746190095"), }, "current sqrt price on upper bound": { currentSqrtP: sqrt5500BigDec, sqrtPHigh: sqrt5500BigDec, sqrtPLow: sqrt4545BigDec, - amount0Desired: sdk.ZeroInt(), - amount1Desired: sdk.NewInt(1000000), + amount0Desired: osmomath.ZeroInt(), + amount1Desired: osmomath.NewInt(1000000), // Liquidity1 = amount1 / (sqrtPriceB - sqrtPriceA) // https://www.wolframalpha.com/input?i=1000000%2F%2874.161984870956629487-67.416615162732695594%29 expectedLiquidity: "148249.842967213952971325", @@ -399,24 +398,24 @@ func TestGetNextSqrtPriceFromAmount0InRoundingUp(t *testing.T) { tests := map[string]sqrtRoundingTestCase{ "rounded up at precision end": { sqrtPriceCurrent: sqrt5000BigDec, - liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), - amountRemaining: osmomath.MustNewDecFromStr("8398"), + liquidity: osmomath.MustNewBigDecFromStr("3035764687.503020836176699298"), + amountRemaining: osmomath.MustNewBigDecFromStr("8398"), // get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, amountRemaining) - expected: osmomath.MustNewDecFromStr("70.696849053416966148695392456511981401"), + expected: osmomath.MustNewBigDecFromStr("70.696849053416966148695392456511981401"), }, "no round up due zeroes at precision end": { - sqrtPriceCurrent: osmomath.MustNewDecFromStr("2"), - liquidity: osmomath.MustNewDecFromStr("10"), - amountRemaining: osmomath.MustNewDecFromStr("15"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("2"), + liquidity: osmomath.MustNewBigDecFromStr("10"), + amountRemaining: osmomath.MustNewBigDecFromStr("15"), // liq * sqrt_cur / (liq + token_in * sqrt_cur) = 0.5 - expected: osmomath.MustNewDecFromStr("0.5"), + expected: osmomath.MustNewBigDecFromStr("0.5"), }, "happy path": { - liquidity: osmomath.MustNewDecFromStr("1517882343.751510418088349649"), // liquidity0 calculated above + liquidity: osmomath.MustNewBigDecFromStr("1517882343.751510418088349649"), // liquidity0 calculated above sqrtPriceCurrent: sqrt5000BigDec, amountRemaining: osmomath.NewBigDec(13370), // round_osmo_prec_up(liquidity / (round_osmo_prec_down(liquidity / sqrtPriceCurrent) + amountRemaining)) - expected: osmomath.MustNewDecFromStr("70.666663910857144331148691821263626767"), + expected: osmomath.MustNewBigDecFromStr("70.666663910857144331148691821263626767"), }, } runSqrtRoundingTestCase(t, "TestGetNextSqrtPriceFromAmount0InRoundingUp", math.GetNextSqrtPriceFromAmount0InRoundingUp, tests) @@ -427,17 +426,17 @@ func TestGetNextSqrtPriceFromAmount0OutRoundingUp(t *testing.T) { tests := map[string]sqrtRoundingTestCase{ "rounded up at precision end": { sqrtPriceCurrent: sqrt5000BigDec, - liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), - amountRemaining: osmomath.MustNewDecFromStr("8398"), + liquidity: osmomath.MustNewBigDecFromStr("3035764687.503020836176699298"), + amountRemaining: osmomath.MustNewBigDecFromStr("8398"), // get_next_sqrt_price_from_amount0_out_round_up(liquidity,sqrtPriceCurrent ,amountRemaining) - expected: osmomath.MustNewDecFromStr("70.724512595179305565323229510645063950"), + expected: osmomath.MustNewBigDecFromStr("70.724512595179305565323229510645063950"), }, "no round up due zeroes at precision end": { - sqrtPriceCurrent: osmomath.MustNewDecFromStr("2"), - liquidity: osmomath.MustNewDecFromStr("10"), - amountRemaining: osmomath.MustNewDecFromStr("1"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("2"), + liquidity: osmomath.MustNewBigDecFromStr("10"), + amountRemaining: osmomath.MustNewBigDecFromStr("1"), // liq * sqrt_cur / (liq + token_out * sqrt_cur) = 2.5 - expected: osmomath.MustNewDecFromStr("2.5"), + expected: osmomath.MustNewBigDecFromStr("2.5"), }, } runSqrtRoundingTestCase(t, "TestGetNextSqrtPriceFromAmount0OutRoundingUp", math.GetNextSqrtPriceFromAmount0OutRoundingUp, tests) @@ -448,25 +447,25 @@ func TestGetNextSqrtPriceFromAmount1InRoundingDown(t *testing.T) { tests := map[string]sqrtRoundingTestCase{ "rounded down at precision end": { sqrtPriceCurrent: sqrt5000BigDec, - liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), - amountRemaining: osmomath.MustNewDecFromStr("8398"), + liquidity: osmomath.MustNewBigDecFromStr("3035764687.503020836176699298"), + amountRemaining: osmomath.MustNewBigDecFromStr("8398"), - expected: osmomath.MustNewDecFromStr("70.710680885008822823343339270800000167"), + expected: osmomath.MustNewBigDecFromStr("70.710680885008822823343339270800000167"), }, "no round up due zeroes at precision end": { - sqrtPriceCurrent: osmomath.MustNewDecFromStr("2.5"), - liquidity: osmomath.MustNewDecFromStr("1"), - amountRemaining: osmomath.MustNewDecFromStr("10"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("2.5"), + liquidity: osmomath.MustNewBigDecFromStr("1"), + amountRemaining: osmomath.MustNewBigDecFromStr("10"), // sqrt_next = sqrt_cur + token_in / liq - expected: osmomath.MustNewDecFromStr("12.5"), + expected: osmomath.MustNewBigDecFromStr("12.5"), }, "happy path": { - liquidity: osmomath.MustNewDecFromStr("1519437308.014768571721000000"), // liquidity1 calculated above - sqrtPriceCurrent: sqrt5000BigDec, // 5000000000 + liquidity: osmomath.MustNewBigDecFromStr("1519437308.014768571721000000"), // liquidity1 calculated above + sqrtPriceCurrent: sqrt5000BigDec, // 5000000000 amountRemaining: osmomath.NewBigDec(42000000), // sqrt_next = sqrt_cur + token_in / liq // calculated with x/concentrated-liquidity/python/clmath.py round_decimal(sqrt_next, 36, ROUND_FLOOR) - expected: osmomath.MustNewDecFromStr("70.738319930382329008049494613660784220"), + expected: osmomath.MustNewBigDecFromStr("70.738319930382329008049494613660784220"), }, } runSqrtRoundingTestCase(t, "TestGetNextSqrtPriceFromAmount1InRoundingDown", math.GetNextSqrtPriceFromAmount1InRoundingDown, tests) @@ -476,17 +475,17 @@ func TestGetNextSqrtPriceFromAmount1OutRoundingDown(t *testing.T) { tests := map[string]sqrtRoundingTestCase{ "rounded down at precision end": { sqrtPriceCurrent: sqrt5000BigDec, - liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), - amountRemaining: osmomath.MustNewDecFromStr("8398"), + liquidity: osmomath.MustNewBigDecFromStr("3035764687.503020836176699298"), + amountRemaining: osmomath.MustNewBigDecFromStr("8398"), // round_osmo_prec_down(sqrtPriceCurrent - round_osmo_prec_up(tokenOut / liquidity)) - expected: osmomath.MustNewDecFromStr("70.710675352300682056656660729199999832"), + expected: osmomath.MustNewBigDecFromStr("70.710675352300682056656660729199999832"), }, "no round up due zeroes at precision end": { - sqrtPriceCurrent: osmomath.MustNewDecFromStr("12.5"), - liquidity: osmomath.MustNewDecFromStr("1"), - amountRemaining: osmomath.MustNewDecFromStr("10"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("12.5"), + liquidity: osmomath.MustNewBigDecFromStr("1"), + amountRemaining: osmomath.MustNewBigDecFromStr("10"), // round_osmo_prec_down(sqrtPriceCurrent - round_osmo_prec_up(tokenOut / liquidity)) - expected: osmomath.MustNewDecFromStr("2.5"), + expected: osmomath.MustNewBigDecFromStr("2.5"), }, } runSqrtRoundingTestCase(t, "TestGetNextSqrtPriceFromAmount1OutRoundingDown", math.GetNextSqrtPriceFromAmount1OutRoundingDown, tests) diff --git a/x/concentrated-liquidity/math/precompute.go b/x/concentrated-liquidity/math/precompute.go index 6a52aff9894..7e1b71c2659 100644 --- a/x/concentrated-liquidity/math/precompute.go +++ b/x/concentrated-liquidity/math/precompute.go @@ -1,17 +1,16 @@ package math import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) var ( - sdkOneDec = sdk.OneDec() - sdkTenDec = sdk.NewDec(10) - powersOfTen []sdk.Dec - negPowersOfTen []sdk.Dec + sdkOneDec = osmomath.OneDec() + sdkNineDec = osmomath.NewDec(9) + sdkTenDec = osmomath.NewDec(10) + powersOfTen []osmomath.Dec + negPowersOfTen []osmomath.Dec osmomathBigOneDec = osmomath.NewBigDec(1) osmomathBigTenDec = osmomath.NewBigDec(10) @@ -20,7 +19,7 @@ var ( // 9 * 10^(-types.ExponentAtPriceOne), where types.ExponentAtPriceOne is non-positive and is s.t. // this answer fits well within an int64. - geometricExponentIncrementDistanceInTicks = 9 * sdk.NewDec(10).PowerMut(uint64(-types.ExponentAtPriceOne)).TruncateInt64() + geometricExponentIncrementDistanceInTicks = 9 * osmomath.NewDec(10).PowerMut(uint64(-types.ExponentAtPriceOne)).TruncateInt64() ) // Builds metadata for every additive tickspacing exponent, namely: @@ -51,7 +50,7 @@ func buildTickExpCache() { // build positive indices first maxPrice := osmomathBigOneDec curExpIndex := int64(0) - for maxPrice.LT(osmomath.BigDecFromSDKDec(types.MaxSpotPrice)) { + for maxPrice.LT(osmomath.BigDecFromDec(types.MaxSpotPrice)) { tickExpCache[curExpIndex] = &tickExpIndexData{ // price range 10^curExpIndex to 10^(curExpIndex + 1). (10, 100) initialPrice: osmomathBigTenDec.PowerInteger(uint64(curExpIndex)), @@ -65,7 +64,7 @@ func buildTickExpCache() { minPrice := osmomathBigOneDec curExpIndex = -1 - for minPrice.GT(osmomath.NewDecWithPrec(1, 30)) { + for minPrice.GT(osmomath.NewBigDecWithPrec(1, 30)) { tickExpCache[curExpIndex] = &tickExpIndexData{ // price range 10^curExpIndex to 10^(curExpIndex + 1). (0.001, 0.01) initialPrice: powTenBigDec(curExpIndex), @@ -80,18 +79,18 @@ func buildTickExpCache() { // Set precision multipliers func init() { - negPowersOfTen = make([]sdk.Dec, sdk.Precision+1) - for i := 0; i <= sdk.Precision; i++ { + negPowersOfTen = make([]osmomath.Dec, osmomath.PrecisionDec+1) + for i := 0; i <= osmomath.PrecisionDec; i++ { negPowersOfTen[i] = sdkOneDec.Quo(sdkTenDec.Power(uint64(i))) } - // 10^77 < sdk.MaxInt < 10^78 - powersOfTen = make([]sdk.Dec, 78) - for i := 0; i <= 77; i++ { + // 10^77 < osmomath.MaxInt < 10^78 + powersOfTen = make([]osmomath.Dec, 77) + for i := 0; i <= 76; i++ { powersOfTen[i] = sdkTenDec.Power(uint64(i)) } - bigNegPowersOfTen = make([]osmomath.BigDec, osmomath.Precision+1) - for i := 0; i <= osmomath.Precision; i++ { + bigNegPowersOfTen = make([]osmomath.BigDec, osmomath.PrecisionBigDec+1) + for i := 0; i <= osmomath.PrecisionBigDec; i++ { bigNegPowersOfTen[i] = osmomathBigOneDec.Quo(osmomathBigTenDec.PowerInteger(uint64(i))) } // 10^308 < osmomath.MaxInt < 10^309 diff --git a/x/concentrated-liquidity/math/tick.go b/x/concentrated-liquidity/math/tick.go index 4594a90e311..be6da894001 100644 --- a/x/concentrated-liquidity/math/tick.go +++ b/x/concentrated-liquidity/math/tick.go @@ -4,8 +4,6 @@ import ( "errors" "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -29,7 +27,7 @@ func TicksToSqrtPrice(lowerTick, upperTick int64) (osmomath.BigDec, osmomath.Big } // TickToSqrtPrice returns the sqrtPrice given a tickIndex -// If tickIndex is zero, the function returns sdk.OneDec(). +// If tickIndex is zero, the function returns osmomath.OneDec(). // It is the combination of calling TickToPrice followed by Sqrt. func TickToSqrtPrice(tickIndex int64) (osmomath.BigDec, error) { priceBigDec, err := TickToPrice(tickIndex) @@ -45,13 +43,13 @@ func TickToSqrtPrice(tickIndex int64) (osmomath.BigDec, error) { // It is acceptable to truncate here as TickToPrice() function converts // from osmomath.Dec to osmomath.BigDec before returning specifically for this range. // As a result, there is no data loss. - price := priceBigDec.SDKDec() + price := priceBigDec.Dec() sqrtPrice, err := osmomath.MonotonicSqrt(price) if err != nil { return osmomath.BigDec{}, err } - return osmomath.BigDecFromSDKDec(sqrtPrice), nil + return osmomath.BigDecFromDec(sqrtPrice), nil } // For the newly extended range of [tick(MinSpotPriceV2), MinInitializedTick), we use the new math @@ -64,10 +62,10 @@ func TickToSqrtPrice(tickIndex int64) (osmomath.BigDec, error) { } // TickToPrice returns the price given a tickIndex -// If tickIndex is zero, the function returns sdk.OneDec(). +// If tickIndex is zero, the function returns osmomath.OneDec(). func TickToPrice(tickIndex int64) (osmomath.BigDec, error) { if tickIndex == 0 { - return osmomath.OneDec(), nil + return osmomath.OneBigDec(), nil } // N.B. We special case MinInitializedTickV2 and MinCurrentTickV2 since MinInitializedTickV2 @@ -115,7 +113,7 @@ func TickToPrice(tickIndex int64) (osmomath.BigDec, error) { if tickIndex < types.MinInitializedTick { price = powTenBigDec(geometricExponentDelta).Add(numAdditiveTicks.Mul(currentAdditiveIncrementInTicks)) } else { - price = osmomath.BigDecFromSDKDec(PowTenInternal(geometricExponentDelta).Add(numAdditiveTicks.Mul(currentAdditiveIncrementInTicks).SDKDec())) + price = osmomath.BigDecFromDec(PowTenInternal(geometricExponentDelta).Add(numAdditiveTicks.Mul(currentAdditiveIncrementInTicks).Dec())) } // defense in depth, this logic would not be reached due to use having checked if given tick is in between @@ -170,8 +168,8 @@ func SqrtPriceToTickRoundDownSpacing(sqrtPrice osmomath.BigDec, tickSpacing uint } // powTen treats negative exponents as 1/(10**|exponent|) instead of 10**-exponent -// This is because the sdk.Dec.Power function does not support negative exponents -func PowTenInternal(exponent int64) sdk.Dec { +// This is because the osmomath.Dec.Power function does not support negative exponents +func PowTenInternal(exponent int64) osmomath.Dec { if exponent >= 0 { return powersOfTen[exponent] } @@ -191,7 +189,7 @@ func CalculatePriceToTick(price osmomath.BigDec) (tickIndex int64, err error) { if price.IsNegative() { return 0, fmt.Errorf("price must be greater than zero") } - if price.GT(osmomath.BigDecFromSDKDec(types.MaxSpotPrice)) || price.LT(types.MinSpotPriceV2) { + if price.GT(osmomath.BigDecFromDec(types.MaxSpotPrice)) || price.LT(types.MinSpotPriceV2) { return 0, types.PriceBoundError{ProvidedPrice: price, MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice} } if price.Equal(osmomathBigOneDec) { @@ -204,7 +202,7 @@ func CalculatePriceToTick(price osmomath.BigDec) (tickIndex int64, err error) { // TODO: implement efficient big decimal truncation. // It is acceptable to truncate price as the minimum we support is // 10**-12 which is above the smallest value of sdk.Dec. - price = osmomath.BigDecFromSDKDec(price.SDKDec()) + price = osmomath.BigDecFromDec(price.Dec()) } // The approach here is to try determine which "geometric spacing" are we in. diff --git a/x/concentrated-liquidity/math/tick_test.go b/x/concentrated-liquidity/math/tick_test.go index 564904669e6..36ac4ad42c2 100644 --- a/x/concentrated-liquidity/math/tick_test.go +++ b/x/concentrated-liquidity/math/tick_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" "github.com/osmosis-labs/osmosis/osmomath" @@ -19,11 +18,11 @@ const ( var ( // spot price - (10^(spot price exponent - 6 - 1)) // Note we get spot price exponent by counting the number of digits in the max spot price and subtracting 1. - closestPriceBelowMaxPriceDefaultTickSpacing = types.MaxSpotPrice.Sub(sdk.NewDec(10).PowerMut(uint64(len(types.MaxSpotPrice.TruncateInt().String()) - 1 - int(-types.ExponentAtPriceOne) - 1))) + closestPriceBelowMaxPriceDefaultTickSpacing = types.MaxSpotPrice.Sub(osmomath.NewDec(10).PowerMut(uint64(len(types.MaxSpotPrice.TruncateInt().String()) - 1 - int(-types.ExponentAtPriceOne) - 1))) // min tick + 10 ^ -expoentAtPriceOne - closestTickAboveMinPriceDefaultTickSpacing = osmomath.NewInt(types.MinInitializedTick).Add(osmomath.NewInt(10).ToDec().PowerInteger(uint64(types.ExponentAtPriceOne * -1)).TruncateInt()) + closestTickAboveMinPriceDefaultTickSpacing = osmomath.NewInt(types.MinInitializedTick).Add(osmomath.NewInt(10).ToLegacyDec().Power(uint64(types.ExponentAtPriceOne * -1)).TruncateInt()) - smallestBigDec = osmomath.SmallestDec() + smallestBigDec = osmomath.SmallestBigDec() bigOneDec = osmomath.OneDec() bigTenDec = osmomath.NewBigDec(10) ) @@ -60,67 +59,67 @@ func TestTickToSqrtPrice(t *testing.T) { }{ "Ten billionths cent increments at the millionths place: 1": { tickIndex: -51630100, - expectedPrice: osmomath.MustNewDecFromStr("0.0000033699"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.0000033699"), }, "Ten billionths cent increments at the millionths place: 2": { tickIndex: -51630000, - expectedPrice: osmomath.MustNewDecFromStr("0.0000033700"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.0000033700"), }, "One millionths cent increments at the hundredths place: 1": { tickIndex: -11999800, - expectedPrice: osmomath.MustNewDecFromStr("0.070002"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.070002"), }, "One millionths cent increments at the hundredths place: 2": { tickIndex: -11999700, - expectedPrice: osmomath.MustNewDecFromStr("0.070003"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.070003"), }, "One hundred thousandth cent increments at the tenths place: 1": { tickIndex: -999800, - expectedPrice: osmomath.MustNewDecFromStr("0.90002"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.90002"), }, "One hundred thousandth cent increments at the tenths place: 2": { tickIndex: -999700, - expectedPrice: osmomath.MustNewDecFromStr("0.90003"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.90003"), }, "One ten thousandth cent increments at the ones place: 1": { tickIndex: 1000000, - expectedPrice: osmomath.MustNewDecFromStr("2"), + expectedPrice: osmomath.MustNewBigDecFromStr("2"), }, "One dollar increments at the ten thousands place: 2": { tickIndex: 1000100, - expectedPrice: osmomath.MustNewDecFromStr("2.0001"), + expectedPrice: osmomath.MustNewBigDecFromStr("2.0001"), }, "One thousandth cent increments at the tens place: 1": { tickIndex: 9200100, - expectedPrice: osmomath.MustNewDecFromStr("12.001"), + expectedPrice: osmomath.MustNewBigDecFromStr("12.001"), }, "One thousandth cent increments at the tens place: 2": { tickIndex: 9200200, - expectedPrice: osmomath.MustNewDecFromStr("12.002"), + expectedPrice: osmomath.MustNewBigDecFromStr("12.002"), }, "One cent increments at the hundreds place: 1": { tickIndex: 18320100, - expectedPrice: osmomath.MustNewDecFromStr("132.01"), + expectedPrice: osmomath.MustNewBigDecFromStr("132.01"), }, "One cent increments at the hundreds place: 2": { tickIndex: 18320200, - expectedPrice: osmomath.MustNewDecFromStr("132.02"), + expectedPrice: osmomath.MustNewBigDecFromStr("132.02"), }, "Ten cent increments at the thousands place: 1": { tickIndex: 27732100, - expectedPrice: osmomath.MustNewDecFromStr("1732.10"), + expectedPrice: osmomath.MustNewBigDecFromStr("1732.10"), }, "Ten cent increments at the thousands place: 2": { tickIndex: 27732200, - expectedPrice: osmomath.MustNewDecFromStr("1732.20"), + expectedPrice: osmomath.MustNewBigDecFromStr("1732.20"), }, "Dollar increments at the ten thousands place: 1": { tickIndex: 36073200, - expectedPrice: osmomath.MustNewDecFromStr("10732"), + expectedPrice: osmomath.MustNewBigDecFromStr("10732"), }, "Dollar increments at the ten thousands place: 2": { tickIndex: 36073300, - expectedPrice: osmomath.MustNewDecFromStr("10733"), + expectedPrice: osmomath.MustNewBigDecFromStr("10733"), }, "Max tick and min k": { tickIndex: 342000000, @@ -136,7 +135,7 @@ func TestTickToSqrtPrice(t *testing.T) { tickIndex: types.MinCurrentTick, // 1 order of magnitude below min spot price of 10^-12 + 6 orders of magnitude smaller // to account for exponent at price one of -6. - expectedPrice: types.MinSpotPriceBigDec.Sub(osmomath.BigDecFromSDKDec(sdk.SmallestDec()).Quo(bigTenDec)), + expectedPrice: types.MinSpotPriceBigDec.Sub(osmomath.BigDecFromDec(osmomath.SmallestDec()).Quo(bigTenDec)), }, "tickIndex is MinInitializedTickV2": { tickIndex: types.MinInitializedTickV2, @@ -164,63 +163,63 @@ func TestTickToSqrtPrice(t *testing.T) { }, "Gyen <> USD, tick -20594000 -> price 0.0074060": { tickIndex: -20594000, - expectedPrice: osmomath.MustNewDecFromStr("0.007406000000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.007406000000000000"), }, "Gyen <> USD, tick -20594000 + 100 -> price 0.0074061": { tickIndex: -20593900, - expectedPrice: osmomath.MustNewDecFromStr("0.007406100000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.007406100000000000"), }, "Spell <> USD, tick -29204000 -> price 0.00077960": { tickIndex: -29204000, - expectedPrice: osmomath.MustNewDecFromStr("0.000779600000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.000779600000000000"), }, "Spell <> USD, tick -29204000 + 100 -> price 0.00077961": { tickIndex: -29203900, - expectedPrice: osmomath.MustNewDecFromStr("0.000779610000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.000779610000000000"), }, "Atom <> Osmo, tick -12150000 -> price 0.068500": { tickIndex: -12150000, - expectedPrice: osmomath.MustNewDecFromStr("0.068500000000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.068500000000000000"), }, "Atom <> Osmo, tick -12150000 + 100 -> price 0.068501": { tickIndex: -12149900, - expectedPrice: osmomath.MustNewDecFromStr("0.068501000000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.068501000000000000"), }, "Boot <> Osmo, tick 64576000 -> price 25760000": { tickIndex: 64576000, - expectedPrice: osmomath.MustNewDecFromStr("25760000"), + expectedPrice: osmomath.MustNewBigDecFromStr("25760000"), }, "Boot <> Osmo, tick 64576000 + 100 -> price 25760000": { tickIndex: 64576100, - expectedPrice: osmomath.MustNewDecFromStr("25761000"), + expectedPrice: osmomath.MustNewBigDecFromStr("25761000"), }, "BTC <> USD, tick 38035200 -> price 30352": { tickIndex: 38035200, - expectedPrice: osmomath.MustNewDecFromStr("30352"), + expectedPrice: osmomath.MustNewBigDecFromStr("30352"), }, "BTC <> USD, tick 38035200 + 100 -> price 30353": { tickIndex: 38035300, - expectedPrice: osmomath.MustNewDecFromStr("30353"), + expectedPrice: osmomath.MustNewBigDecFromStr("30353"), }, "SHIB <> USD, tick -44821000 -> price 0.000011790": { tickIndex: -44821000, - expectedPrice: osmomath.MustNewDecFromStr("0.00001179"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.00001179"), }, "SHIB <> USD, tick -44821100 + 100 -> price 0.000011791": { tickIndex: -44820900, - expectedPrice: osmomath.MustNewDecFromStr("0.000011791"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.000011791"), }, "ETH <> BTC, tick -12104000 -> price 0.068960": { tickIndex: -12104000, - expectedPrice: osmomath.MustNewDecFromStr("0.068960"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.068960"), }, "ETH <> BTC, tick -121044000 + 1 -> price 0.068961": { tickIndex: -12103900, - expectedPrice: osmomath.MustNewDecFromStr("0.068961"), + expectedPrice: osmomath.MustNewBigDecFromStr("0.068961"), }, "one tick spacing interval smaller than max sqrt price, max tick neg six - 100 -> one tick spacing interval smaller than max sqrt price": { tickIndex: types.MaxTick - 100, - expectedPrice: osmomath.MustNewDecFromStr("99999000000000000000000000000000000000"), + expectedPrice: osmomath.MustNewBigDecFromStr("99999000000000000000000000000000000000"), }, "max sqrt price, max tick neg six -> max spot price": { tickIndex: types.MaxTick, @@ -242,7 +241,7 @@ func TestTickToSqrtPrice(t *testing.T) { if tc.expectedPrice.LT(types.MinSpotPriceBigDec) { expectedSqrtPrice = osmomath.MustMonotonicSqrtBigDec(tc.expectedPrice) } else { - expectedSqrtPrice = osmomath.BigDecFromSDKDec(osmomath.MustMonotonicSqrt(tc.expectedPrice.SDKDec())) + expectedSqrtPrice = osmomath.BigDecFromDec(osmomath.MustMonotonicSqrt(tc.expectedPrice.Dec())) require.NoError(t, err) } @@ -253,56 +252,56 @@ func TestTickToSqrtPrice(t *testing.T) { func TestTicksToSqrtPrice(t *testing.T) { testCases := map[string]struct { - lowerTickIndex sdk.Int - upperTickIndex sdk.Int - expectedLowerPrice sdk.Dec - expectedUpperPrice sdk.Dec + lowerTickIndex osmomath.Int + upperTickIndex osmomath.Int + expectedLowerPrice osmomath.Dec + expectedUpperPrice osmomath.Dec expectedError error }{ "Ten billionths cent increments at the millionths place": { - lowerTickIndex: sdk.NewInt(-51630100), - upperTickIndex: sdk.NewInt(-51630000), - expectedLowerPrice: sdk.MustNewDecFromStr("0.0000033699"), - expectedUpperPrice: sdk.MustNewDecFromStr("0.0000033700"), + lowerTickIndex: osmomath.NewInt(-51630100), + upperTickIndex: osmomath.NewInt(-51630000), + expectedLowerPrice: osmomath.MustNewDecFromStr("0.0000033699"), + expectedUpperPrice: osmomath.MustNewDecFromStr("0.0000033700"), }, "One millionths cent increments at the hundredths place:": { - lowerTickIndex: sdk.NewInt(-11999800), - upperTickIndex: sdk.NewInt(-11999700), - expectedLowerPrice: sdk.MustNewDecFromStr("0.070002"), - expectedUpperPrice: sdk.MustNewDecFromStr("0.070003"), + lowerTickIndex: osmomath.NewInt(-11999800), + upperTickIndex: osmomath.NewInt(-11999700), + expectedLowerPrice: osmomath.MustNewDecFromStr("0.070002"), + expectedUpperPrice: osmomath.MustNewDecFromStr("0.070003"), }, "One hundred thousandth cent increments at the tenths place": { - lowerTickIndex: sdk.NewInt(-999800), - upperTickIndex: sdk.NewInt(-999700), - expectedLowerPrice: sdk.MustNewDecFromStr("0.90002"), - expectedUpperPrice: sdk.MustNewDecFromStr("0.90003"), + lowerTickIndex: osmomath.NewInt(-999800), + upperTickIndex: osmomath.NewInt(-999700), + expectedLowerPrice: osmomath.MustNewDecFromStr("0.90002"), + expectedUpperPrice: osmomath.MustNewDecFromStr("0.90003"), }, "Dollar increments at the ten thousands place": { - lowerTickIndex: sdk.NewInt(36073200), - upperTickIndex: sdk.NewInt(36073300), - expectedLowerPrice: sdk.MustNewDecFromStr("10732"), - expectedUpperPrice: sdk.MustNewDecFromStr("10733"), + lowerTickIndex: osmomath.NewInt(36073200), + upperTickIndex: osmomath.NewInt(36073300), + expectedLowerPrice: osmomath.MustNewDecFromStr("10732"), + expectedUpperPrice: osmomath.MustNewDecFromStr("10733"), }, "Max tick and min k": { - lowerTickIndex: sdk.NewInt(types.MinInitializedTick), - upperTickIndex: sdk.NewInt(types.MaxTick), + lowerTickIndex: osmomath.NewInt(types.MinInitializedTick), + upperTickIndex: osmomath.NewInt(types.MaxTick), expectedUpperPrice: types.MaxSpotPrice, expectedLowerPrice: types.MinSpotPrice, }, "error: lowerTickIndex less than minimum": { - lowerTickIndex: sdk.NewInt(types.MinCurrentTickV2 - 1), - upperTickIndex: sdk.NewInt(36073300), + lowerTickIndex: osmomath.NewInt(types.MinCurrentTickV2 - 1), + upperTickIndex: osmomath.NewInt(36073300), expectedError: types.TickIndexMinimumError{MinTick: types.MinCurrentTickV2}, }, "error: upperTickIndex greater than maximum": { - lowerTickIndex: sdk.NewInt(types.MinInitializedTick), - upperTickIndex: sdk.NewInt(types.MaxTick + 1), + lowerTickIndex: osmomath.NewInt(types.MinInitializedTick), + upperTickIndex: osmomath.NewInt(types.MaxTick + 1), expectedError: types.TickIndexMaximumError{MaxTick: types.MaxTick}, }, "error: provided lower tick and upper tick are same": { - lowerTickIndex: sdk.NewInt(types.MinInitializedTick), - upperTickIndex: sdk.NewInt(types.MinInitializedTick), - expectedError: types.InvalidLowerUpperTickError{LowerTick: sdk.NewInt(types.MinInitializedTick).Int64(), UpperTick: sdk.NewInt(types.MinInitializedTick).Int64()}, + lowerTickIndex: osmomath.NewInt(types.MinInitializedTick), + upperTickIndex: osmomath.NewInt(types.MinInitializedTick), + expectedError: types.InvalidLowerUpperTickError{LowerTick: osmomath.NewInt(types.MinInitializedTick).Int64(), UpperTick: osmomath.NewInt(types.MinInitializedTick).Int64()}, }, } @@ -323,8 +322,8 @@ func TestTicksToSqrtPrice(t *testing.T) { expectedUpperSqrtPrice, err := osmomath.MonotonicSqrt(tc.expectedUpperPrice) require.NoError(t, err) - require.Equal(t, osmomath.BigDecFromSDKDec(expectedLowerSqrtPrice).String(), lowerSqrtPrice.String()) - require.Equal(t, osmomath.BigDecFromSDKDec(expectedUpperSqrtPrice).String(), upperSqrtPrice.String()) + require.Equal(t, osmomath.BigDecFromDec(expectedLowerSqrtPrice).String(), lowerSqrtPrice.String()) + require.Equal(t, osmomath.BigDecFromDec(expectedUpperSqrtPrice).String(), upperSqrtPrice.String()) }) } } @@ -340,84 +339,84 @@ func TestPriceToTick(t *testing.T) { expectedError error }{ "BTC <> USD, tick 38035200 -> price 30352": { - price: osmomath.MustNewDecFromStr("30352"), + price: osmomath.MustNewBigDecFromStr("30352"), tickExpected: 38035200, }, "BTC <> USD, tick 38035300 + 100 -> price 30353": { - price: osmomath.MustNewDecFromStr("30353"), + price: osmomath.MustNewBigDecFromStr("30353"), tickExpected: 38035300, }, "SHIB <> USD, tick -44821000 -> price 0.000011790": { - price: osmomath.MustNewDecFromStr("0.000011790"), + price: osmomath.MustNewBigDecFromStr("0.000011790"), tickExpected: -44821000, }, "SHIB <> USD, tick -44820900 -> price 0.000011791": { - price: osmomath.MustNewDecFromStr("0.000011791"), + price: osmomath.MustNewBigDecFromStr("0.000011791"), tickExpected: -44820900, }, "ETH <> BTC, tick -12104000 -> price 0.068960": { - price: osmomath.MustNewDecFromStr("0.068960"), + price: osmomath.MustNewBigDecFromStr("0.068960"), tickExpected: -12104000, }, "ETH <> BTC, tick -12104000 + 100 -> price 0.068961": { - price: osmomath.MustNewDecFromStr("0.068961"), + price: osmomath.MustNewBigDecFromStr("0.068961"), tickExpected: -12103900, }, "max sqrt price -1, max neg tick six - 100 -> max tick neg six - 100": { - price: osmomath.MustNewDecFromStr("99999000000000000000000000000000000000"), + price: osmomath.MustNewBigDecFromStr("99999000000000000000000000000000000000"), tickExpected: types.MaxTick - 100, }, "max sqrt price, max tick neg six -> max spot price": { - price: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice.Power(2)), + price: osmomath.BigDecFromDec(types.MaxSqrtPrice.Power(2)), tickExpected: types.MaxTick, }, "Gyen <> USD, tick -20594000 -> price 0.0074060": { - price: osmomath.MustNewDecFromStr("0.007406"), + price: osmomath.MustNewBigDecFromStr("0.007406"), tickExpected: -20594000, }, "Gyen <> USD, tick -20594000 + 100 -> price 0.0074061": { - price: osmomath.MustNewDecFromStr("0.0074061"), + price: osmomath.MustNewBigDecFromStr("0.0074061"), tickExpected: -20593900, }, "Spell <> USD, tick -29204000 -> price 0.00077960": { - price: osmomath.MustNewDecFromStr("0.0007796"), + price: osmomath.MustNewBigDecFromStr("0.0007796"), tickExpected: -29204000, }, "Spell <> USD, tick -29204000 + 100 -> price 0.00077961": { - price: osmomath.MustNewDecFromStr("0.00077961"), + price: osmomath.MustNewBigDecFromStr("0.00077961"), tickExpected: -29203900, }, "Atom <> Osmo, tick -12150000 -> price 0.068500": { - price: osmomath.MustNewDecFromStr("0.0685"), + price: osmomath.MustNewBigDecFromStr("0.0685"), tickExpected: -12150000, }, "Atom <> Osmo, tick -12150000 + 100 -> price 0.068501": { - price: osmomath.MustNewDecFromStr("0.068501"), + price: osmomath.MustNewBigDecFromStr("0.068501"), tickExpected: -12149900, }, "Boot <> Osmo, tick 64576000 -> price 25760000": { - price: osmomath.MustNewDecFromStr("25760000"), + price: osmomath.MustNewBigDecFromStr("25760000"), tickExpected: 64576000, }, "Boot <> Osmo, tick 64576000 + 100 -> price 25761000": { - price: osmomath.MustNewDecFromStr("25761000"), + price: osmomath.MustNewBigDecFromStr("25761000"), tickExpected: 64576100, }, "price is one Dec": { - price: osmomath.OneDec(), + price: osmomath.OneBigDec(), tickExpected: 0, }, "price is negative decimal": { - price: osmomath.OneDec().Neg(), + price: osmomath.OneBigDec().Neg(), expectedError: fmt.Errorf("price must be greater than zero"), }, "price is greater than max spot price": { - price: osmomath.BigDecFromSDKDec(types.MaxSpotPrice.Add(sdk.OneDec())), - expectedError: types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromSDKDec(types.MaxSpotPrice.Add(sdk.OneDec())), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice}, + price: osmomath.BigDecFromDec(types.MaxSpotPrice.Add(osmomath.OneDec())), + expectedError: types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromDec(types.MaxSpotPrice.Add(osmomath.OneDec())), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice}, }, "price is smaller than min spot price": { - price: osmomath.ZeroDec(), - expectedError: types.PriceBoundError{ProvidedPrice: osmomath.ZeroDec(), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice}, + price: osmomath.ZeroBigDec(), + expectedError: types.PriceBoundError{ProvidedPrice: osmomath.ZeroBigDec(), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice}, }, } for name, tc := range testCases { @@ -448,39 +447,39 @@ func TestPriceToTickRoundDown(t *testing.T) { tickExpected int64 }{ "tick spacing 100, price of 1": { - price: osmomath.OneDec(), + price: osmomath.OneBigDec(), tickSpacing: defaultTickSpacing, tickExpected: 0, }, "tick spacing 100, price of 1.000030, tick 30 -> 0": { - price: osmomath.MustNewDecFromStr("1.000030"), + price: osmomath.MustNewBigDecFromStr("1.000030"), tickSpacing: defaultTickSpacing, tickExpected: 0, }, "tick spacing 100, price of 0.9999970, tick -30 -> -100": { - price: osmomath.MustNewDecFromStr("0.9999970"), + price: osmomath.MustNewBigDecFromStr("0.9999970"), tickSpacing: defaultTickSpacing, tickExpected: -100, }, "tick spacing 50, price of 0.9999730, tick -270 -> -300": { - price: osmomath.MustNewDecFromStr("0.9999730"), + price: osmomath.MustNewBigDecFromStr("0.9999730"), tickSpacing: 50, tickExpected: -300, }, "tick spacing 100, MinSpotPrice, MinTick": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice), + price: osmomath.BigDecFromDec(types.MinSpotPrice), tickSpacing: defaultTickSpacing, tickExpected: types.MinInitializedTick, }, "tick spacing 100, Spot price one tick above min, one tick above min -> MinTick": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice.Add(sdk.SmallestDec())), + price: osmomath.BigDecFromDec(types.MinSpotPrice.Add(osmomath.SmallestDec())), tickSpacing: defaultTickSpacing, // Since the tick should always be the closest tick below (and `smallestDec` isn't sufficient // to push us into the next tick), we expect MinTick to be returned here. tickExpected: types.MinInitializedTick, }, "tick spacing 100, Spot price one tick below max, one tick below max -> MaxTick - 1": { - price: osmomath.BigDecFromSDKDec(closestPriceBelowMaxPriceDefaultTickSpacing), + price: osmomath.BigDecFromDec(closestPriceBelowMaxPriceDefaultTickSpacing), tickSpacing: defaultTickSpacing, tickExpected: types.MaxTick - 100, }, @@ -528,84 +527,84 @@ func TestTickToSqrtPricePriceToTick_InverseRelationship(t *testing.T) { } testCases := map[string]testcase{ "50000 to tick": { - price: osmomath.MustNewDecFromStr("50000"), + price: osmomath.MustNewBigDecFromStr("50000"), tickExpected: 40000000, }, "5.01 to tick": { - price: osmomath.MustNewDecFromStr("5.01"), + price: osmomath.MustNewBigDecFromStr("5.01"), tickExpected: 4010000, }, "50000.01 to tick": { - price: osmomath.MustNewDecFromStr("50000.01"), + price: osmomath.MustNewBigDecFromStr("50000.01"), tickExpected: 40000001, }, "0.090001 to tick": { - price: osmomath.MustNewDecFromStr("0.090001"), + price: osmomath.MustNewBigDecFromStr("0.090001"), tickExpected: -9999900, }, "0.9998 to tick": { - price: osmomath.MustNewDecFromStr("0.9998"), + price: osmomath.MustNewBigDecFromStr("0.9998"), tickExpected: -2000, }, "53030 to tick": { - price: osmomath.MustNewDecFromStr("53030"), + price: osmomath.MustNewBigDecFromStr("53030"), tickExpected: 40303000, }, "max spot price": { - price: osmomath.BigDecFromSDKDec(types.MaxSpotPrice), + price: osmomath.BigDecFromDec(types.MaxSpotPrice), tickExpected: types.MaxTick, }, "max spot price - smallest price delta given exponent at price one of -6": { // 37 - 6 is calculated by counting the exponent of max spot price and subtracting exponent at price one - price: osmomath.BigDecFromSDKDec(types.MaxSpotPrice.Sub(sdk.NewDec(10).PowerMut(37 - 6))), + price: osmomath.BigDecFromDec(types.MaxSpotPrice.Sub(osmomath.NewDec(10).PowerMut(37 - 6))), tickExpected: types.MaxTick - 1, // still max }, "min spot price": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice), + price: osmomath.BigDecFromDec(types.MinSpotPrice), tickExpected: types.MinInitializedTick, }, "smallest + min price + tick": { - price: osmomath.MustNewDecFromStr("0.000000000001000001"), + price: osmomath.MustNewBigDecFromStr("0.000000000001000001"), tickExpected: types.MinInitializedTick + 1, }, "at price level of 0.01 - odd": { - price: osmomath.MustNewDecFromStr("0.012345670000000000"), + price: osmomath.MustNewBigDecFromStr("0.012345670000000000"), tickExpected: -17765433, }, "at price level of 0.01 - even": { - price: osmomath.MustNewDecFromStr("0.01234568000000000"), + price: osmomath.MustNewBigDecFromStr("0.01234568000000000"), tickExpected: -17765432, }, "at min price level of 0.01 - odd": { - price: osmomath.MustNewDecFromStr("0.000000000001234567"), + price: osmomath.MustNewBigDecFromStr("0.000000000001234567"), tickExpected: -107765433, }, "at min price level of 0.01 - even": { - price: osmomath.MustNewDecFromStr("0.000000000001234568"), + price: osmomath.MustNewBigDecFromStr("0.000000000001234568"), tickExpected: -107765432, }, "at price level of 1_000_000_000 - odd end": { - price: osmomath.MustNewDecFromStr("1234567000"), + price: osmomath.MustNewBigDecFromStr("1234567000"), tickExpected: 81234567, }, "at price level of 1_000_000_000 - in-between supported": { - price: osmomath.MustNewDecFromStr("1234567500"), + price: osmomath.MustNewBigDecFromStr("1234567500"), tickExpected: 81234567, - truncatedPrice: osmomath.MustNewDecFromStr("1234567000"), + truncatedPrice: osmomath.MustNewBigDecFromStr("1234567000"), }, "at price level of 1_000_000_000 - even end": { - price: osmomath.MustNewDecFromStr("1234568000"), + price: osmomath.MustNewBigDecFromStr("1234568000"), tickExpected: 81234568, }, "inverse testing with 1": { - price: osmomath.OneDec(), + price: osmomath.OneBigDec(), tickExpected: 0, }, } var powTen int64 = 10 for i := 1; i < 13; i++ { testCases[fmt.Sprintf("min spot price * 10^%d", i)] = testcase{ - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice.MulInt64(powTen)), + price: osmomath.BigDecFromDec(types.MinSpotPrice.MulInt64(powTen)), tickExpected: types.MinInitializedTick + (int64(i) * 9e6), } powTen *= 10 @@ -657,13 +656,13 @@ func TestPriceToTick_ErrorCases(t *testing.T) { price osmomath.BigDec }{ "use negative price": { - price: osmomath.OneDec().Neg(), + price: osmomath.OneBigDec().Neg(), }, "price is greater than max spot price": { - price: osmomath.BigDecFromSDKDec(types.MaxSpotPrice.Add(sdk.OneDec())), + price: osmomath.BigDecFromDec(types.MaxSpotPrice.Add(osmomath.OneDec())), }, "price is less than min spot price": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice.Sub(sdk.OneDec())), + price: osmomath.BigDecFromDec(types.MinSpotPrice.Sub(osmomath.OneDec())), }, } for name, tc := range testCases { @@ -685,19 +684,19 @@ func TestTickToPrice_SuccessCases(t *testing.T) { }{ "tick index is Max tick": { tickIndex: types.MaxTick, - expectedPrice: osmomath.BigDecFromSDKDec(types.MaxSpotPrice), + expectedPrice: osmomath.BigDecFromDec(types.MaxSpotPrice), }, "tick index is between Min tick V1 and Max tick": { tickIndex: 123456, - expectedPrice: osmomath.OneDec().Add(osmomath.NewBigDec(123456).Mul(osmomath.NewDecWithPrec(1, 6))), + expectedPrice: osmomath.OneBigDec().Add(osmomath.NewBigDec(123456).Mul(osmomath.NewBigDecWithPrec(1, 6))), }, "tick index is V1 MinInitializedTick": { tickIndex: types.MinInitializedTick, - expectedPrice: osmomath.BigDecFromSDKDec(types.MinSpotPrice), + expectedPrice: osmomath.BigDecFromDec(types.MinSpotPrice), }, "tick index is V1 MinCurrentTick": { tickIndex: types.MinCurrentTick, - expectedPrice: osmomath.BigDecFromSDKDec(types.MinSpotPrice).Sub(osmomath.NewDecWithPrec(1, 13+(-types.ExponentAtPriceOne))), + expectedPrice: osmomath.BigDecFromDec(types.MinSpotPrice).Sub(osmomath.NewBigDecWithPrec(1, 13+(-types.ExponentAtPriceOne))), }, "tick index is V2 MinInitializedTick": { tickIndex: types.MinInitializedTickV2, @@ -726,7 +725,7 @@ func TestTickToPrice_SuccessCases(t *testing.T) { // 9.876544e-19 "tick index is between V2 MinInitializedTick and V1 MinInitializedTick": { tickIndex: -9000000*18 - 123456, - expectedPrice: osmomath.NewDecWithPrec(9876544, 6+19), // 6 for number of digits after, 18 for geometric multiplier and 1 for negative ticks + expectedPrice: osmomath.NewBigDecWithPrec(9876544, 6+19), // 6 for number of digits after, 18 for geometric multiplier and 1 for negative ticks }, } for name, tc := range testCases { @@ -774,11 +773,11 @@ func TestCalculatePriceToTick(t *testing.T) { expectedTickIndex int64 }{ "Price greater than 1": { - price: osmomath.MustNewDecFromStr("9.78"), + price: osmomath.MustNewBigDecFromStr("9.78"), expectedTickIndex: 8780000, }, "Price less than 1": { - price: osmomath.MustNewDecFromStr("0.71"), + price: osmomath.MustNewBigDecFromStr("0.71"), expectedTickIndex: -2900000, }, "100_000_000 -> 72000000": { @@ -798,11 +797,11 @@ func TestCalculatePriceToTick(t *testing.T) { expectedTickIndex: 72000001, }, "MinSpotPrice V1 -> MinInitializedTick": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice), + price: osmomath.BigDecFromDec(types.MinSpotPrice), expectedTickIndex: types.MinInitializedTick, }, "MinSpotPrice V1 - 10^-19 -> MinCurrentTick": { - price: osmomath.BigDecFromSDKDec(types.MinSpotPrice).Sub(osmomath.NewDecWithPrec(1, 19)), + price: types.MinSpotPriceBigDec.Sub(osmomath.NewBigDecWithPrec(1, 19)), expectedTickIndex: types.MinCurrentTick, }, "MinSpotPrice V2 -> MinInitializedTick V2": { @@ -821,7 +820,7 @@ func TestCalculatePriceToTick(t *testing.T) { require.Equal(t, tc.expectedTickIndex, tickIndex) // Only run tests on the BigDec version on range [MinCurrentTickV2, MinCurrentTick] - if tc.price.LT(osmomath.BigDecFromSDKDec(types.MinSpotPrice)) { + if tc.price.LT(osmomath.BigDecFromDec(types.MinSpotPrice)) { return } @@ -854,13 +853,13 @@ func TestSqrtPriceToTick_MinInitializedTickV1(t *testing.T) { minSqrtPrice, err := osmomath.MonotonicSqrt(types.MinSpotPrice) require.NoError(t, err) - minSpotPrice := osmomath.BigDecFromSDKDec(minSqrtPrice) + minSpotPrice := osmomath.BigDecFromDec(minSqrtPrice) tickIndex, err := math.CalculateSqrtPriceToTick(minSpotPrice) require.NoError(t, err) require.Equal(t, types.MinInitializedTick, tickIndex) // Subtract one ULP given exponent at price one of -6. - minSpotPriceMinusULP := minSpotPrice.Sub(osmomath.NewDecWithPrec(1, 19+6)) + minSpotPriceMinusULP := minSpotPrice.Sub(osmomath.NewBigDecWithPrec(1, 19+6)) tickIndex, err = math.CalculateSqrtPriceToTick(minSpotPriceMinusULP) require.NoError(t, err) @@ -871,19 +870,19 @@ func TestSqrtPriceToTick_MinInitializedTickV1(t *testing.T) { func TestPowTenInternal(t *testing.T) { testCases := map[string]struct { exponent int64 - expectedPowTenResult sdk.Dec + expectedPowTenResult osmomath.Dec }{ "Power by 5": { exponent: 5, - expectedPowTenResult: sdk.NewDec(100000), + expectedPowTenResult: osmomath.NewDec(100000), }, "Power by 0": { exponent: 0, - expectedPowTenResult: sdk.NewDec(1), + expectedPowTenResult: osmomath.NewDec(1), }, "Power by -5": { exponent: -5, - expectedPowTenResult: sdk.MustNewDecFromStr("0.00001"), + expectedPowTenResult: osmomath.MustNewDecFromStr("0.00001"), }, } for name, tc := range testCases { @@ -895,7 +894,7 @@ func TestPowTenInternal(t *testing.T) { } func TestSqrtPriceToTickRoundDownSpacing(t *testing.T) { - sdkULP := osmomath.BigDecFromSDKDec(sdk.SmallestDec()) + sdkULP := osmomath.BigDecFromDec(osmomath.SmallestDec()) // Compute reference values that need to be satisfied sqp1, err := math.TickToSqrtPrice(1) @@ -921,7 +920,7 @@ func TestSqrtPriceToTickRoundDownSpacing(t *testing.T) { tickExpected int64 }{ "sqrt price of 1 (tick spacing 1)": { - sqrtPrice: osmomath.OneDec(), + sqrtPrice: osmomath.OneBigDec(), tickSpacing: 1, tickExpected: 0, }, @@ -966,17 +965,17 @@ func TestSqrtPriceToTickRoundDownSpacing(t *testing.T) { tickExpected: -200, }, "sqrt price exactly equal to max sqrt price": { - sqrtPrice: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), + sqrtPrice: osmomath.BigDecFromDec(types.MaxSqrtPrice), tickSpacing: defaultTickSpacing, tickExpected: types.MaxTick, }, "sqrt price exactly equal to min sqrt price": { - sqrtPrice: osmomath.BigDecFromSDKDec(types.MinSqrtPrice), + sqrtPrice: osmomath.BigDecFromDec(types.MinSqrtPrice), tickSpacing: defaultTickSpacing, tickExpected: types.MinInitializedTick, }, "sqrt price equal to max sqrt price minus one ULP": { - sqrtPrice: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice).Sub(sdkULP), + sqrtPrice: osmomath.BigDecFromDec(types.MaxSqrtPrice).Sub(sdkULP), tickSpacing: defaultTickSpacing, tickExpected: types.MaxTick - defaultTickSpacing, }, @@ -1061,7 +1060,7 @@ func TestSqrtPriceToTickRoundDownSpacing(t *testing.T) { // In the future, for price range [10^-30, 10^-12), we will use non-truncated BigDec // with 36 decimal TickToSqrt function. func TestCalculateSqrtPriceToTick_NearMinSpotPriceV1Bound(t *testing.T) { - sqrtPrice := osmomath.MustNewDecFromStr("0.000001000049998750999999999999999999") + sqrtPrice := osmomath.MustNewBigDecFromStr("0.000001000049998750999999999999999999") _, err := math.CalculateSqrtPriceToTick(sqrtPrice) require.NoError(t, err) } diff --git a/x/concentrated-liquidity/model/msgs.go b/x/concentrated-liquidity/model/msgs.go index 1bc5934ae8d..b33e1a37653 100644 --- a/x/concentrated-liquidity/model/msgs.go +++ b/x/concentrated-liquidity/model/msgs.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -24,7 +25,7 @@ func NewMsgCreateConcentratedPool( denom0 string, denom1 string, tickSpacing uint64, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) MsgCreateConcentratedPool { return MsgCreateConcentratedPool{ Sender: sender.String(), diff --git a/x/concentrated-liquidity/model/msgs_test.go b/x/concentrated-liquidity/model/msgs_test.go index 0520c8c9ff5..c9391938369 100644 --- a/x/concentrated-liquidity/model/msgs_test.go +++ b/x/concentrated-liquidity/model/msgs_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" appParams "github.com/osmosis-labs/osmosis/v19/app/params" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -82,7 +83,7 @@ func TestMsgCreateConcentratedPool(t *testing.T) { Denom0: ETH, Denom1: USDC, TickSpacing: DefaultTickSpacing, - SpreadFactor: sdk.ZeroDec().Sub(sdk.SmallestDec()), + SpreadFactor: osmomath.ZeroDec().Sub(osmomath.SmallestDec()), }, expectPass: false, }, @@ -93,7 +94,7 @@ func TestMsgCreateConcentratedPool(t *testing.T) { Denom0: ETH, Denom1: USDC, TickSpacing: DefaultTickSpacing, - SpreadFactor: sdk.OneDec(), + SpreadFactor: osmomath.OneDec(), }, expectPass: false, }, diff --git a/x/concentrated-liquidity/model/pool.go b/x/concentrated-liquidity/model/pool.go index fb085dfd682..3ee8792deb2 100644 --- a/x/concentrated-liquidity/model/pool.go +++ b/x/concentrated-liquidity/model/pool.go @@ -21,12 +21,12 @@ const ( var ( _ types.ConcentratedPoolExtension = &Pool{} - one = sdk.OneDec() + one = osmomath.OneDec() ) // 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 osmomath.Dec) (Pool, error) { // Ensure that the two denoms are different if denom0 == denom1 { return Pool{}, types.MatchingDenomError{Denom: denom0} @@ -43,9 +43,9 @@ func NewConcentratedLiquidityPool(poolId uint64, denom0, denom1 string, tickSpac IncentivesAddress: osmoutils.NewModuleAddressWithPrefix(types.ModuleName, incentivesAddressPrefix, sdk.Uint64ToBigEndian(poolId)).String(), SpreadRewardsAddress: osmoutils.NewModuleAddressWithPrefix(types.ModuleName, spreadRewardsAddressPrefix, sdk.Uint64ToBigEndian(poolId)).String(), Id: poolId, - CurrentSqrtPrice: osmomath.ZeroDec(), + CurrentSqrtPrice: osmomath.ZeroBigDec(), CurrentTick: 0, - CurrentTickLiquidity: sdk.ZeroDec(), + CurrentTickLiquidity: osmomath.ZeroDec(), Token0: denom0, Token1: denom1, TickSpacing: tickSpacing, @@ -96,7 +96,7 @@ func (p Pool) String() string { } // GetSpreadFactor returns the spread factor of the pool -func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { +func (p Pool) GetSpreadFactor(ctx sdk.Context) osmomath.Dec { return p.SpreadFactor } @@ -108,20 +108,20 @@ func (p Pool) IsActive(ctx sdk.Context) bool { // SpotPrice returns the spot price of the pool. // If base asset is the Token0 of the pool, we use the current sqrt price of the pool. // If not, we calculate the inverse of the current sqrt price of the pool. -func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (sdk.Dec, error) { +func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (osmomath.Dec, error) { // validate base asset is in pool if baseAssetDenom != p.Token0 && baseAssetDenom != p.Token1 { - return sdk.Dec{}, fmt.Errorf("base asset denom (%s) is not in pool with (%s, %s) pair", baseAssetDenom, p.Token0, p.Token1) + return osmomath.Dec{}, fmt.Errorf("base asset denom (%s) is not in pool with (%s, %s) pair", baseAssetDenom, p.Token0, p.Token1) } // validate quote asset is in pool if quoteAssetDenom != p.Token0 && quoteAssetDenom != p.Token1 { - return sdk.Dec{}, fmt.Errorf("quote asset denom (%s) is not in pool with (%s, %s) pair", quoteAssetDenom, p.Token0, p.Token1) + return osmomath.Dec{}, fmt.Errorf("quote asset denom (%s) is not in pool with (%s, %s) pair", quoteAssetDenom, p.Token0, p.Token1) } if baseAssetDenom == p.Token0 { - return p.CurrentSqrtPrice.PowerInteger(2).SDKDec(), nil + return p.CurrentSqrtPrice.PowerInteger(2).Dec(), nil } - return osmomath.OneDec().Quo(p.CurrentSqrtPrice.PowerInteger(2)).SDKDec(), nil + return osmomath.OneBigDec().Quo(p.CurrentSqrtPrice.PowerInteger(2)).Dec(), nil } // GetToken0 returns the token0 of the pool @@ -155,7 +155,7 @@ func (p Pool) GetExponentAtPriceOne() int64 { } // GetLiquidity returns the liquidity of the pool -func (p Pool) GetLiquidity() sdk.Dec { +func (p Pool) GetLiquidity() osmomath.Dec { return p.CurrentTickLiquidity } @@ -169,7 +169,7 @@ func (p Pool) GetType() poolmanagertypes.PoolType { } // UpdateLiquidity updates the liquidity of the pool. Note that this method is mutative. -func (p *Pool) UpdateLiquidity(newLiquidity sdk.Dec) { +func (p *Pool) UpdateLiquidity(newLiquidity osmomath.Dec) { p.CurrentTickLiquidity = p.CurrentTickLiquidity.Add(newLiquidity) } @@ -195,7 +195,7 @@ func (p *Pool) SetLastLiquidityUpdate(newTime time.Time) { // 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 { +func (p *Pool) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta osmomath.Dec) bool { if p.IsCurrentTickInRange(lowerTick, upperTick) { p.CurrentTickLiquidity = p.CurrentTickLiquidity.Add(liquidityDelta) return true @@ -222,15 +222,15 @@ func (p *Pool) UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upper // we request a user to add more liquidity in favor of the pool. // If negative, we assume, liquidity being removed. As a result, we round down so that // we request a user to remove less liquidity in favor of the pool. -func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) (sdk.Dec, sdk.Dec, error) { +func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta osmomath.Dec) (osmomath.Dec, osmomath.Dec, error) { if liquidityDelta.IsZero() { - return sdk.Dec{}, sdk.Dec{}, types.ErrZeroLiquidity + return osmomath.Dec{}, osmomath.Dec{}, types.ErrZeroLiquidity } // Transform the provided ticks into their corresponding sqrtPrices. sqrtPriceLowerTick, sqrtPriceUpperTick, err := math.TicksToSqrtPrice(lowerTick, upperTick) if err != nil { - return sdk.Dec{}, sdk.Dec{}, err + return osmomath.Dec{}, osmomath.Dec{}, err } // When liquidity delta is positive, that means that we are adding liquidity. @@ -242,9 +242,10 @@ func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liq roundUp := liquidityDelta.IsPositive() var ( - liquidityDeltaBigDec = osmomath.BigDecFromSDKDec(liquidityDelta) - actualAmountDenom0 osmomath.BigDec - actualAmountDenom1 osmomath.BigDec + liquidityDeltaBigDec = osmomath.BigDecFromDec(liquidityDelta) + + actualAmountDenom0 osmomath.BigDec + actualAmountDenom1 osmomath.BigDec ) if p.IsCurrentTickInRange(lowerTick, upperTick) { @@ -257,21 +258,21 @@ func (p Pool) CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liq } else if p.CurrentTick < lowerTick { // outcome two: position is below current price // this means position is solely made up of asset0 - actualAmountDenom1 = osmomath.ZeroDec() + actualAmountDenom1 = osmomath.ZeroBigDec() actualAmountDenom0 = math.CalcAmount0Delta(liquidityDeltaBigDec, sqrtPriceLowerTick, sqrtPriceUpperTick, roundUp) } else { // outcome three: position is above current price // this means position is solely made up of asset1 - actualAmountDenom0 = osmomath.ZeroDec() + actualAmountDenom0 = osmomath.ZeroBigDec() actualAmountDenom1 = math.CalcAmount1Delta(liquidityDeltaBigDec, sqrtPriceLowerTick, sqrtPriceUpperTick, roundUp) } if roundUp { - return actualAmountDenom0.SDKDecRoundUp(), actualAmountDenom1.SDKDecRoundUp(), nil + return actualAmountDenom0.DecRoundUp(), actualAmountDenom1.DecRoundUp(), nil } // Note that these truncate at precision end in pool's favor. - return actualAmountDenom0.SDKDec(), actualAmountDenom1.SDKDec(), nil + return actualAmountDenom0.Dec(), actualAmountDenom1.Dec(), nil } // isCurrentTickInRange returns true if pool's current tick is within @@ -283,7 +284,7 @@ func (p Pool) IsCurrentTickInRange(lowerTick, upperTick int64) bool { // ApplySwap state of pool after swap. // It specifically overwrites the pool's liquidity, curr tick and the curr sqrt price. // Note that this method is mutative. -func (p *Pool) ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error { +func (p *Pool) ApplySwap(newLiquidity osmomath.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error { // Check if the new liquidity provided is not negative. if newLiquidity.IsNegative() { return types.NegativeLiquidityError{Liquidity: newLiquidity} diff --git a/x/concentrated-liquidity/model/pool.pb.go b/x/concentrated-liquidity/model/pool.pb.go index 7d0845f563c..ae8b726dc94 100644 --- a/x/concentrated-liquidity/model/pool.pb.go +++ b/x/concentrated-liquidity/model/pool.pb.go @@ -9,9 +9,9 @@ package model import ( + cosmossdk_io_math "cosmossdk.io/math" 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" @@ -44,7 +44,7 @@ type Pool struct { SpreadRewardsAddress string `protobuf:"bytes,3,opt,name=spread_rewards_address,json=spreadRewardsAddress,proto3" json:"spread_rewards_address,omitempty" yaml:"spread_rewards_address"` Id uint64 `protobuf:"varint,4,opt,name=id,proto3" json:"id,omitempty"` // Amount of total liquidity - CurrentTickLiquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=current_tick_liquidity,json=currentTickLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"current_tick_liquidity" yaml:"current_tick_liquidity"` + CurrentTickLiquidity cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=current_tick_liquidity,json=currentTickLiquidity,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"current_tick_liquidity" yaml:"current_tick_liquidity"` Token0 string `protobuf:"bytes,6,opt,name=token0,proto3" json:"token0,omitempty"` Token1 string `protobuf:"bytes,7,opt,name=token1,proto3" json:"token1,omitempty"` CurrentSqrtPrice github_com_osmosis_labs_osmosis_osmomath.BigDec `protobuf:"bytes,8,opt,name=current_sqrt_price,json=currentSqrtPrice,proto3,customtype=github.com/osmosis-labs/osmosis/osmomath.BigDec" json:"current_sqrt_price" yaml:"spot_price"` @@ -54,7 +54,7 @@ type Pool struct { TickSpacing uint64 `protobuf:"varint,10,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` ExponentAtPriceOne int64 `protobuf:"varint,11,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3" json:"exponent_at_price_one,omitempty" yaml:"exponent_at_price_one"` // spread_factor is the ratio that is charged on the amount of token in. - SpreadFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,12,opt,name=spread_factor,json=spreadFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spread_factor" yaml:"spread_factor"` + SpreadFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,12,opt,name=spread_factor,json=spreadFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spread_factor" yaml:"spread_factor"` // 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"` @@ -102,47 +102,47 @@ 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, 0x27, 0x7b, 0xeb, 0x22, 0x05, 0xa1, 0xd0, 0x92, 0x56, 0x04, 0x11, 0xc2, 0x6c, - 0x32, 0x4d, 0x87, 0x4d, 0x32, 0x69, 0x66, 0xb6, 0xb6, 0xde, 0x05, 0x8f, 0x3d, 0x7a, 0xec, 0x87, - 0xf0, 0x43, 0x14, 0x4f, 0x3d, 0x8a, 0x87, 0x28, 0x2d, 0xf8, 0x01, 0xf6, 0x13, 0x48, 0x66, 0x26, - 0xbb, 0x91, 0xae, 0x88, 0xa7, 0xec, 0xfb, 0xbd, 0xdf, 0xfb, 0xcd, 0xef, 0xbd, 0x79, 0xb3, 0xe0, - 0x31, 0x65, 0x11, 0x65, 0x84, 0xd9, 0x1e, 0x8d, 0x3d, 0x1c, 0xf3, 0x14, 0x71, 0xec, 0xb7, 0x42, - 0x72, 0xdc, 0x27, 0x3e, 0xe1, 0x67, 0x76, 0x42, 0x69, 0x68, 0x25, 0x29, 0xe5, 0x14, 0x3e, 0x54, - 0x54, 0xab, 0x4c, 0x1d, 0x32, 0xad, 0x93, 0x76, 0x17, 0x73, 0xd4, 0x5e, 0x5f, 0xf3, 0x04, 0xcf, - 0x15, 0x45, 0xb6, 0x0c, 0xa4, 0xc2, 0x7a, 0x2d, 0xa0, 0x01, 0x95, 0x78, 0xfe, 0x4b, 0xa1, 0x46, - 0x40, 0x69, 0x10, 0x62, 0x5b, 0x44, 0xdd, 0xfe, 0xa1, 0xcd, 0x49, 0x84, 0x19, 0x47, 0x51, 0x22, - 0x09, 0xe6, 0xaf, 0x59, 0x30, 0xb5, 0x47, 0x69, 0x08, 0x9f, 0x80, 0x59, 0xe4, 0xfb, 0x29, 0x66, - 0x4c, 0xd7, 0x1a, 0x5a, 0x73, 0xae, 0x03, 0x07, 0x99, 0xb1, 0x78, 0x86, 0xa2, 0x70, 0xd3, 0x54, - 0x09, 0xd3, 0x29, 0x28, 0x70, 0x07, 0x40, 0x22, 0x8c, 0x92, 0x13, 0xcc, 0xdc, 0xa2, 0x70, 0x42, - 0x14, 0x6e, 0x0c, 0x32, 0x63, 0x4d, 0x16, 0xde, 0xe6, 0x98, 0xce, 0xd2, 0x08, 0xdc, 0x52, 0x6a, - 0x6f, 0xc0, 0x2a, 0x4b, 0x52, 0x8c, 0x7c, 0x37, 0xc5, 0xef, 0x51, 0xea, 0x8f, 0x14, 0x27, 0x85, - 0xe2, 0x83, 0x41, 0x66, 0x6c, 0x48, 0xc5, 0xf1, 0x3c, 0xd3, 0xa9, 0xc9, 0x84, 0x23, 0xf1, 0x42, - 0x78, 0x11, 0x4c, 0x10, 0x5f, 0x9f, 0x6a, 0x68, 0xcd, 0x29, 0x67, 0x82, 0xf8, 0xf0, 0xa3, 0x06, - 0x56, 0xbd, 0x7e, 0x9a, 0xe2, 0x98, 0xbb, 0x9c, 0x78, 0x3d, 0x77, 0x38, 0x62, 0x7d, 0x5a, 0x9c, - 0xb4, 0x7b, 0x99, 0x19, 0x95, 0xef, 0x99, 0xf1, 0x28, 0x20, 0xfc, 0xa8, 0xdf, 0xb5, 0x3c, 0x1a, - 0xa9,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, 0x3b, 0x00, 0x52, 0x69, 0x94, 0x1e, 0x13, 0xee, 0x14, 0x85, 0x13, + 0xb2, 0x70, 0x63, 0x90, 0x1a, 0x6b, 0xaa, 0xf0, 0x36, 0xc7, 0x44, 0x4b, 0x23, 0x70, 0x3b, 0x57, + 0x7b, 0x03, 0x56, 0x79, 0x9c, 0x10, 0xec, 0x39, 0x09, 0xf9, 0x80, 0x13, 0x6f, 0xa4, 0x38, 0x29, + 0x15, 0xef, 0x0f, 0x52, 0x63, 0x43, 0x29, 0x8e, 0xe7, 0x99, 0xa8, 0xa6, 0x12, 0x48, 0xe1, 0x85, + 0xf0, 0x22, 0x98, 0xa0, 0x9e, 0x3e, 0xd5, 0xd0, 0x9a, 0x53, 0x68, 0x82, 0x7a, 0xf0, 0x0c, 0xac, + 0xba, 0xfd, 0x24, 0x21, 0x91, 0x70, 0x04, 0x75, 0x7b, 0xce, 0x70, 0xc2, 0xfa, 0xb4, 0x7c, 0x68, + 0xe7, 0x32, 0x35, 0x2a, 0xdf, 0x53, 0xe3, 0xae, 0x1a, 0x2d, 0xf7, 0x7a, 0x16, 0x65, 0x76, 0x88, + 0xc5, 0xa1, 0xd5, 0x21, 0x3e, 0x76, 0x4f, 0x77, 0x88, 0x3b, 0xf2, 0x32, 0x5e, 0xca, 0x44, 0xb5, + 0x3c, 0xb1, 0x4f, 0xdd, 0x5e, 0xa7, 0x80, 0xe1, 0x2a, 0x98, 0x11, 0xac, 0x47, 0xa2, 0xc7, 0xfa, + 0x4c, 0xf6, 0x16, 0xca, 0xa3, 0x21, 0xde, 0xd2, 0x67, 0x4b, 0x78, 0x0b, 0x9e, 0x01, 0x58, 0x3c, + 0xc0, 0x8f, 0x12, 0xe1, 0xc4, 0x09, 0x75, 0x89, 0xfe, 0x9f, 0xf4, 0xd9, 0xc9, 0x7d, 0xda, 0x3e, + 0x15, 0x87, 0xfd, 0xae, 0xe5, 0xb2, 0xd0, 0xce, 0x37, 0x68, 0x33, 0xc0, 0x5d, 0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, 0xcc, 0xd6, 0xd2, 0xc7, 0x0b, 0xa3, 0xf2, 0xe9, 0xc2, 0xa8, 0x7c, + 0xf9, 0xbc, 0x39, 0x9d, 0xdd, 0xf1, 0xcb, 0xf6, 0xbb, 0xcb, 0xeb, 0xba, 0x76, 0x75, 0x5d, 0xd7, + 0x7e, 0x5e, 0xd7, 0xb5, 0xf3, 0x9b, 0x7a, 0xe5, 0xea, 0xa6, 0x5e, 0xf9, 0x76, 0x53, 0xaf, 0xbc, + 0x6d, 0xff, 0x6d, 0x5b, 0x8e, 0x5b, 0xcf, 0xec, 0x93, 0x3f, 0xfd, 0x5b, 0x85, 0xcc, 0x23, 0x41, + 0x77, 0x46, 0xf6, 0xf0, 0xf4, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x80, 0x60, 0x95, 0xdc, 0x04, 0x00, 0x00, } diff --git a/x/concentrated-liquidity/model/pool_test.go b/x/concentrated-liquidity/model/pool_test.go index 19eb9b69313..08f73e12c60 100644 --- a/x/concentrated-liquidity/model/pool_test.go +++ b/x/concentrated-liquidity/model/pool_test.go @@ -26,21 +26,21 @@ const ( ) var ( - DefaultSpotPrice = sdk.MustNewDecFromStr("0.2") - DefaultReverseSpotPrice = sdk.NewDec(1).Quo(DefaultSpotPrice) + DefaultSpotPrice = osmomath.MustNewDecFromStr("0.2") + DefaultReverseSpotPrice = osmomath.NewDec(1).Quo(DefaultSpotPrice) DefaultSqrtSpotPrice = func() osmomath.BigDec { sqrtPrice, _ := osmomath.MonotonicSqrt(DefaultSpotPrice) - return osmomath.BigDecFromSDKDec(sqrtPrice) + return osmomath.BigDecFromDec(sqrtPrice) }() - DefaultLiquidityAmt = sdk.MustNewDecFromStr("1517882343.751510418088349649") + DefaultLiquidityAmt = osmomath.MustNewDecFromStr("1517882343.751510418088349649") DefaultCurrTick int64 = 310000 - DefaultCurrPrice = sdk.NewDec(5000) + DefaultCurrPrice = osmomath.NewDec(5000) DefaultCurrSqrtPrice = func() osmomath.BigDec { sqrtPrice, _ := osmomath.MonotonicSqrt(DefaultCurrPrice) - return osmomath.BigDecFromSDKDec(sqrtPrice) + return osmomath.BigDecFromDec(sqrtPrice) }() // 70.710678118654752440 - DefaultSpreadFactor = sdk.MustNewDecFromStr("0.01") + DefaultSpreadFactor = osmomath.MustNewDecFromStr("0.01") ) type ConcentratedPoolTestSuite struct { @@ -141,7 +141,7 @@ func (s *ConcentratedPoolTestSuite) TestString() { pool, err := model.NewConcentratedLiquidityPool(1, "foo", "bar", DefaultTickSpacing, DefaultSpreadFactor) s.Require().NoError(err) poolString := pool.String() - 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) + 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\"}") } // TestSpotPrice tests the SpotPrice method of the ConcentratedPoolTestSuite. @@ -154,7 +154,7 @@ func (s *ConcentratedPoolTestSuite) TestSpotPrice() { tests := []struct { name string param param - expectedSpotPrice sdk.Dec + expectedSpotPrice osmomath.Dec expectedErr error }{ { @@ -179,7 +179,7 @@ func (s *ConcentratedPoolTestSuite) TestSpotPrice() { baseDenom: ETH, quoteDenom: DAI, }, - expectedSpotPrice: sdk.ZeroDec(), + expectedSpotPrice: osmomath.ZeroDec(), expectedErr: fmt.Errorf("quote asset denom (%s) is not in the pool", DAI), }, { @@ -188,7 +188,7 @@ func (s *ConcentratedPoolTestSuite) TestSpotPrice() { baseDenom: DAI, quoteDenom: ETH, }, - expectedSpotPrice: sdk.ZeroDec(), + expectedSpotPrice: osmomath.ZeroDec(), expectedErr: fmt.Errorf("base asset denom (%s) is not in the pool", DAI), }, } @@ -215,7 +215,7 @@ func (s *ConcentratedPoolTestSuite) TestSpotPrice() { s.Require().NoError(err) // We use elipson due to sqrt approximation - elipson := sdk.MustNewDecFromStr("0.0000000000000001") + elipson := osmomath.MustNewDecFromStr("0.0000000000000001") s.Require().True(spotPriceFromMethod.Sub(tc.expectedSpotPrice).Abs().LT(elipson)) } }) @@ -228,17 +228,17 @@ func (s *ConcentratedPoolTestSuite) TestUpdateLiquidity() { CurrentTickLiquidity: DefaultLiquidityAmt, } - // Try updating the liquidity with a zero sdk.Dec value. - mock_pool.UpdateLiquidity(sdk.ZeroDec()) + // Try updating the liquidity with a zero osmomath.Dec value. + mock_pool.UpdateLiquidity(osmomath.ZeroDec()) // Assert that the liquidity has not changed. s.Require().Equal(DefaultLiquidityAmt, mock_pool.CurrentTickLiquidity) // Try adding 10 to the pool liquidity. - mock_pool.UpdateLiquidity(sdk.NewDec(10)) + mock_pool.UpdateLiquidity(osmomath.NewDec(10)) // Assert that the liquidity has increased by 10. - s.Require().Equal(DefaultLiquidityAmt.Add(sdk.NewDec(10)), mock_pool.CurrentTickLiquidity) + s.Require().Equal(DefaultLiquidityAmt.Add(osmomath.NewDec(10)), mock_pool.CurrentTickLiquidity) } func (s *ConcentratedPoolTestSuite) TestIsCurrentTickInRange() { @@ -325,15 +325,15 @@ func (s *ConcentratedPoolTestSuite) TestApplySwap() { var ( negativeOne = osmomath.NewBigDec(-1) - negativeOneDec = sdk.OneDec().Neg() + negativeOneDec = osmomath.OneDec().Neg() ) tests := []struct { name string - currentLiquidity sdk.Dec + currentLiquidity osmomath.Dec currentTick int64 currentSqrtPrice osmomath.BigDec - newLiquidity sdk.Dec + newLiquidity osmomath.Dec newTick int64 newSqrtPrice osmomath.BigDec expectErr error @@ -461,7 +461,7 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { denom0 string denom1 string tickSpacing uint64 - spreadFactor sdk.Dec + spreadFactor osmomath.Dec } tests := []struct { @@ -494,7 +494,7 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { denom0: USDC, denom1: ETH, tickSpacing: DefaultTickSpacing, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, expectedPoolId: DefaultValidPoolID, expectedDenom0: USDC, @@ -520,9 +520,9 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { denom0: ETH, denom1: USDC, tickSpacing: DefaultTickSpacing, - spreadFactor: sdk.ZeroDec().Sub(sdk.SmallestDec()), + spreadFactor: osmomath.ZeroDec().Sub(osmomath.SmallestDec()), }, - expectedErr: types.InvalidSpreadFactorError{ActualSpreadFactor: sdk.ZeroDec().Sub(sdk.SmallestDec())}, + expectedErr: types.InvalidSpreadFactorError{ActualSpreadFactor: osmomath.ZeroDec().Sub(osmomath.SmallestDec())}, }, { name: "Error: spread factor == 1", @@ -531,9 +531,9 @@ func (s *ConcentratedPoolTestSuite) TestNewConcentratedLiquidityPool() { denom0: ETH, denom1: USDC, tickSpacing: DefaultTickSpacing, - spreadFactor: sdk.OneDec(), + spreadFactor: osmomath.OneDec(), }, - expectedErr: types.InvalidSpreadFactorError{ActualSpreadFactor: sdk.OneDec()}, + expectedErr: types.InvalidSpreadFactorError{ActualSpreadFactor: osmomath.OneDec()}, }, } @@ -572,7 +572,7 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { return sqrtPrice } - defaultLiquidityDelta = sdk.NewDec(1000) + defaultLiquidityDelta = osmomath.NewDec(1000) defaultLiquidityDeltaBigDec = osmomath.NewBigDec(1000) lowerTick = int64(-99) @@ -589,12 +589,12 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { currentTick int64 lowerTick int64 upperTick int64 - liquidityDelta sdk.Dec + liquidityDelta osmomath.Dec shouldTestRoundingInvariant bool expectError error - expectedAmount0 sdk.Dec - expectedAmount1 sdk.Dec + expectedAmount0 osmomath.Dec + expectedAmount1 osmomath.Dec }{ "current in range, positive liquidity": { currentTick: midtick, @@ -603,8 +603,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { liquidityDelta: defaultLiquidityDelta, shouldTestRoundingInvariant: true, - expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, upperSqrtPriceBigDec, true).SDKDec(), - expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, lowerSqrtPriceBigDec, true).SDKDec(), + expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, upperSqrtPriceBigDec, true).Dec(), + expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, lowerSqrtPriceBigDec, true).Dec(), }, "current in range, negative liquidity": { currentTick: midtick, @@ -612,8 +612,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { upperTick: uppertick, liquidityDelta: defaultLiquidityDelta.Neg(), - expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, upperSqrtPriceBigDec, false).SDKDec(), - expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, lowerSqrtPriceBigDec, false).SDKDec(), + expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, upperSqrtPriceBigDec, false).Dec(), + expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, lowerSqrtPriceBigDec, false).Dec(), }, "current below range, positive liquidity": { currentTick: lowerTick, @@ -621,8 +621,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { upperTick: uppertick, liquidityDelta: defaultLiquidityDelta, - expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, upperSqrtPriceBigDec, true).SDKDec(), - expectedAmount1: sdk.ZeroDec(), + expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec, midSqrtPriceBigDec, upperSqrtPriceBigDec, true).Dec(), + expectedAmount1: osmomath.ZeroDec(), }, "current below range, negative liquidity": { currentTick: lowerTick, @@ -630,8 +630,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { upperTick: uppertick, liquidityDelta: defaultLiquidityDelta.Neg(), - expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, upperSqrtPriceBigDec, false).SDKDec(), - expectedAmount1: sdk.ZeroDec(), + expectedAmount0: clmath.CalcAmount0Delta(defaultLiquidityDeltaBigDec.Neg(), midSqrtPriceBigDec, upperSqrtPriceBigDec, false).Dec(), + expectedAmount1: osmomath.ZeroDec(), }, "current above range, positive liquidity": { currentTick: uppertick, @@ -639,8 +639,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { upperTick: midtick, liquidityDelta: defaultLiquidityDelta, - expectedAmount0: sdk.ZeroDec(), - expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec, lowerSqrtPriceBigDec, midSqrtPriceBigDec, true).SDKDec(), + expectedAmount0: osmomath.ZeroDec(), + expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec, lowerSqrtPriceBigDec, midSqrtPriceBigDec, true).Dec(), }, "current above range, negative liquidity": { currentTick: uppertick, @@ -648,8 +648,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { upperTick: midtick, liquidityDelta: defaultLiquidityDelta.Neg(), - expectedAmount0: sdk.ZeroDec(), - expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec.Neg(), lowerSqrtPriceBigDec, midSqrtPriceBigDec, false).SDKDec(), + expectedAmount0: osmomath.ZeroDec(), + expectedAmount1: clmath.CalcAmount1Delta(defaultLiquidityDeltaBigDec.Neg(), lowerSqrtPriceBigDec, midSqrtPriceBigDec, false).Dec(), }, // errors @@ -657,7 +657,7 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { currentTick: midtick, lowerTick: lowerTick, upperTick: uppertick, - liquidityDelta: sdk.ZeroDec(), + liquidityDelta: osmomath.ZeroDec(), expectError: types.ErrZeroLiquidity, }, @@ -719,8 +719,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { amt1Diff := actualAmount1.Sub(actualAmount1Neg.Neg()) // Difference is between 0 and 1 due to positive liquidity rounding up and negative liquidity performing math normally. - suite.Require().True(amt0Diff.IsPositive() && amt0Diff.LT(sdk.OneDec())) - suite.Require().True(amt1Diff.IsPositive() && amt1Diff.LT(sdk.OneDec())) + suite.Require().True(amt0Diff.IsPositive() && amt0Diff.LT(osmomath.OneDec())) + suite.Require().True(amt1Diff.IsPositive() && amt1Diff.LT(osmomath.OneDec())) } }) } @@ -728,8 +728,8 @@ func (suite *ConcentratedPoolTestSuite) TestCalcActualAmounts() { func (suite *ConcentratedPoolTestSuite) TestUpdateLiquidityIfActivePosition() { var ( - defaultLiquidityDelta = sdk.NewDec(1000) - defaultLiquidityAmt = sdk.NewDec(1000) + defaultLiquidityDelta = osmomath.NewDec(1000) + defaultLiquidityAmt = osmomath.NewDec(1000) lowerTick = int64(-99) midtick = int64(2) @@ -740,7 +740,7 @@ func (suite *ConcentratedPoolTestSuite) TestUpdateLiquidityIfActivePosition() { currentTick int64 lowerTick int64 upperTick int64 - liquidityDelta sdk.Dec + liquidityDelta osmomath.Dec expectError error }{ "current in range, positive liquidity": { diff --git a/x/concentrated-liquidity/model/position.pb.go b/x/concentrated-liquidity/model/position.pb.go index 075e8c18b13..6a17a1551a8 100644 --- a/x/concentrated-liquidity/model/position.pb.go +++ b/x/concentrated-liquidity/model/position.pb.go @@ -9,9 +9,9 @@ package model import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -39,13 +39,13 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Position contains position's id, address, pool id, lower tick, upper tick // join time, and liquidity. type Position struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - LowerTick int64 `protobuf:"varint,4,opt,name=lower_tick,json=lowerTick,proto3" json:"lower_tick,omitempty"` - UpperTick int64 `protobuf:"varint,5,opt,name=upper_tick,json=upperTick,proto3" json:"upper_tick,omitempty"` - JoinTime time.Time `protobuf:"bytes,6,opt,name=join_time,json=joinTime,proto3,stdtime" json:"join_time" yaml:"join_time"` - Liquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=liquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity" yaml:"liquidity"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + PoolId uint64 `protobuf:"varint,3,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + LowerTick int64 `protobuf:"varint,4,opt,name=lower_tick,json=lowerTick,proto3" json:"lower_tick,omitempty"` + UpperTick int64 `protobuf:"varint,5,opt,name=upper_tick,json=upperTick,proto3" json:"upper_tick,omitempty"` + JoinTime time.Time `protobuf:"bytes,6,opt,name=join_time,json=joinTime,proto3,stdtime" json:"join_time" yaml:"join_time"` + Liquidity cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=liquidity,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity" yaml:"liquidity"` } func (m *Position) Reset() { *m = Position{} } @@ -277,51 +277,52 @@ func init() { } var fileDescriptor_ffdfd7b30d37d326 = []byte{ - // 697 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcf, 0x6e, 0xd3, 0x30, - 0x1c, 0x6e, 0xe8, 0x9f, 0xad, 0xae, 0x84, 0x50, 0x36, 0xa6, 0xac, 0x40, 0x53, 0x05, 0xc1, 0x2a, - 0x41, 0x13, 0x3a, 0x24, 0x10, 0x1c, 0x03, 0x42, 0x9a, 0xc4, 0x61, 0x84, 0x21, 0x24, 0x84, 0x54, - 0x9c, 0xd8, 0xeb, 0x4c, 0x93, 0x3a, 0x8b, 0x9d, 0x8d, 0x49, 0x3c, 0xc4, 0x2e, 0xf0, 0x02, 0xdc, - 0x78, 0x92, 0x1d, 0x77, 0x44, 0x1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 0xd9, 0x2e, 0xf4, 0xb2, 0x97, - 0xcc, 0x2e, 0xdd, 0x15, 0x35, 0x2b, 0x77, 0xdf, 0x1f, 0x1c, 0x77, 0xb4, 0xc3, 0xe3, 0x8e, 0xf6, - 0xeb, 0xb8, 0xa3, 0xed, 0x9f, 0x74, 0x2a, 0x87, 0x27, 0x9d, 0xca, 0x8f, 0x93, 0x4e, 0xe5, 0x9d, - 0x3b, 0x33, 0x54, 0x4a, 0xac, 0x1f, 0x42, 0x9f, 0xe5, 0x0b, 0x67, 0x67, 0xf0, 0xc4, 0xf9, 0x74, - 0xde, 0x3f, 0x42, 0x44, 0x11, 0x0e, 0xfd, 0x86, 0x7c, 0x3a, 0x1e, 0xfe, 0x0e, 0x00, 0x00, 0xff, - 0xff, 0x6c, 0x6a, 0x9a, 0xed, 0x40, 0x06, 0x00, 0x00, + // 709 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0x8d, 0xc9, 0xa3, 0xed, 0x44, 0x42, 0xc8, 0x2d, 0x95, 0x9b, 0x42, 0x1c, 0x19, 0xa1, 0x46, + 0x82, 0xd8, 0xa4, 0x48, 0x54, 0xb0, 0x0c, 0x08, 0xa9, 0x52, 0x17, 0xc5, 0x14, 0x21, 0x21, 0xa4, + 0x68, 0xec, 0x99, 0xa6, 0x43, 0xec, 0x8c, 0xeb, 0x99, 0xb4, 0x44, 0xe2, 0x0b, 0x58, 0x75, 0xc5, + 0x0f, 0xb0, 0xe3, 0x4b, 0xba, 0xec, 0x12, 0xb1, 0x48, 0x51, 0xfb, 0x07, 0xfd, 0x02, 0x34, 0x0f, + 0xdb, 0x51, 0x45, 0x79, 0x2c, 0xba, 0x8a, 0xe7, 0x9e, 0x7b, 0xce, 0x99, 0x99, 0x73, 0x35, 0x01, + 0x1d, 0xca, 0x62, 0xca, 0x08, 0xf3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 0x35, 0x8d, 0x9f, 0x67, 0x4d, 0xe3, 0xe8, + 0xbc, 0x59, 0x3a, 0x39, 0x6f, 0x96, 0xbe, 0x9f, 0x37, 0x4b, 0xef, 0x7a, 0x33, 0x43, 0xa5, 0xc5, + 0x3a, 0x11, 0x0c, 0x58, 0xb6, 0xf0, 0x0e, 0xba, 0x4f, 0xbd, 0x8f, 0x57, 0xfd, 0x0d, 0xc4, 0x14, + 0xe1, 0x28, 0xa8, 0xc9, 0xf7, 0xe2, 0xf1, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x87, 0x6c, 0xc9, + 0x46, 0x35, 0x06, 0x00, 0x00, } func (m *Position) Marshal() (dAtA []byte, err error) { diff --git a/x/concentrated-liquidity/model/tickInfo.pb.go b/x/concentrated-liquidity/model/tickInfo.pb.go index f70a90cd93e..f4f8ee2d73a 100644 --- a/x/concentrated-liquidity/model/tickInfo.pb.go +++ b/x/concentrated-liquidity/model/tickInfo.pb.go @@ -9,6 +9,7 @@ package model import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" @@ -32,8 +33,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type TickInfo struct { - LiquidityGross github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=liquidity_gross,json=liquidityGross,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_gross" yaml:"liquidity_gross"` - LiquidityNet github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=liquidity_net,json=liquidityNet,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_net" yaml:"liquidity_net"` + LiquidityGross cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=liquidity_gross,json=liquidityGross,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_gross" yaml:"liquidity_gross"` + LiquidityNet cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=liquidity_net,json=liquidityNet,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_net" yaml:"liquidity_net"` // Total spread rewards accumulated in the opposite direction that the tick // was last crossed. i.e. if the current tick is to the right of this tick // (meaning its currently a greater price), then this is the total spread @@ -203,41 +204,41 @@ func init() { } var fileDescriptor_1ccb7e45032b943a = []byte{ - // 530 bytes of a gzipped FileDescriptorProto + // 543 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x41, 0x8b, 0xd3, 0x40, - 0x14, 0xc7, 0x3b, 0xee, 0x22, 0x3a, 0x75, 0xbb, 0x90, 0x5d, 0x25, 0x2e, 0x92, 0x96, 0x80, 0x52, - 0x90, 0x26, 0xb4, 0xab, 0x87, 0xf5, 0x18, 0x17, 0x57, 0x41, 0x5c, 0x08, 0xf5, 0x22, 0x4a, 0x98, - 0x24, 0xd3, 0xee, 0xd0, 0x24, 0x93, 0x9d, 0x79, 0xe9, 0xda, 0x8b, 0x37, 0xef, 0xde, 0xfc, 0x0e, - 0xde, 0xfd, 0x0e, 0x3d, 0xee, 0x51, 0x3c, 0x54, 0x69, 0xbf, 0x81, 0x9f, 0x40, 0x92, 0x4c, 0xba, - 0xdb, 0x82, 0xb0, 0x0a, 0x9e, 0x92, 0x79, 0xf9, 0xbf, 0xff, 0xff, 0xc7, 0x7b, 0x49, 0x70, 0x87, - 0xcb, 0x98, 0x4b, 0x26, 0xed, 0x80, 0x27, 0x01, 0x4d, 0x40, 0x10, 0xa0, 0x61, 0x27, 0x62, 0xa7, - 0x19, 0x0b, 0x19, 0x4c, 0x6c, 0x60, 0xc1, 0xe8, 0x45, 0x32, 0xe0, 0x56, 0x2a, 0x38, 0x70, 0xed, - 0xbe, 0x92, 0x5b, 0x97, 0xe5, 0x4b, 0xb5, 0x35, 0xee, 0xfa, 0x14, 0x48, 0x77, 0xef, 0x6e, 0x50, - 0xe8, 0xbc, 0xa2, 0xc9, 0x2e, 0x0f, 0xa5, 0xc3, 0xde, 0xee, 0x90, 0x0f, 0x79, 0x59, 0xcf, 0xef, - 0x54, 0xd5, 0x28, 0x35, 0xb6, 0x4f, 0x24, 0xb5, 0x95, 0x8b, 0x1d, 0x70, 0x96, 0x94, 0xcf, 0xcd, - 0xaf, 0x9b, 0xf8, 0x46, 0x5f, 0xa1, 0x68, 0xa7, 0x78, 0x7b, 0x19, 0xe9, 0x0d, 0x05, 0x97, 0x52, - 0x47, 0x2d, 0xd4, 0xbe, 0xe9, 0x3c, 0x9f, 0xce, 0x9a, 0xb5, 0xef, 0xb3, 0xe6, 0x83, 0x21, 0x83, - 0x93, 0xcc, 0xb7, 0x02, 0x1e, 0xab, 0x70, 0x75, 0xe9, 0xc8, 0x70, 0x64, 0xc3, 0x24, 0xa5, 0xd2, - 0x3a, 0xa4, 0xc1, 0xaf, 0x59, 0xf3, 0xce, 0x84, 0xc4, 0xd1, 0x13, 0x73, 0xcd, 0xce, 0x74, 0x1b, - 0xcb, 0xca, 0x51, 0x5e, 0xd0, 0x46, 0x78, 0xeb, 0x42, 0x93, 0x50, 0xd0, 0xaf, 0x15, 0x81, 0xcf, - 0xfe, 0x3a, 0x70, 0x77, 0x3d, 0x30, 0xa1, 0x60, 0xba, 0xb7, 0x96, 0xe7, 0x57, 0x14, 0xb4, 0x29, - 0xc2, 0x07, 0x32, 0x15, 0x94, 0x84, 0x9e, 0xa0, 0x67, 0x44, 0x84, 0x39, 0xd5, 0x19, 0x9c, 0x78, - 0x3c, 0x4d, 0xb9, 0x64, 0x40, 0xbd, 0x90, 0x09, 0x1a, 0x00, 0xe3, 0x89, 0xc7, 0x07, 0x5e, 0x44, - 0x24, 0x78, 0x20, 0xc8, 0x98, 0x0a, 0x49, 0x22, 0x7d, 0xa3, 0xb5, 0xd1, 0xae, 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0xab, 0x83, 0x3d, 0xee, 0x1e, 0xd8, 0xef, 0xff, 0xf4, 0x87, 0x88, 0x79, 0x48, 0x23, 0xff, - 0x7a, 0xf1, 0x9d, 0xee, 0xff, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x13, 0xc7, 0xc2, 0x67, 0x50, 0x04, - 0x00, 0x00, + 0x14, 0xc7, 0x1b, 0x77, 0x11, 0x4d, 0xdd, 0x2e, 0x64, 0x57, 0xa9, 0xab, 0xa4, 0x25, 0x20, 0x14, + 0xa4, 0x09, 0xed, 0xea, 0x61, 0x15, 0x2f, 0xb1, 0xb0, 0x08, 0x8b, 0x0b, 0xa1, 0x5e, 0x44, 0x89, + 0xd3, 0xc9, 0xb4, 0x1d, 0x9a, 0x64, 0xe2, 0xbc, 0xd7, 0xae, 0xbd, 0x78, 0xf3, 0xee, 0xcd, 0xa3, + 0x77, 0x3f, 0x49, 0x8f, 0x7b, 0x14, 0x0f, 0x55, 0xda, 0x6f, 0xe0, 0x27, 0x90, 0x24, 0x93, 0xee, + 0xb6, 0x20, 0x2c, 0x82, 0xa7, 0x64, 0x5e, 0xfe, 0xef, 0xff, 0x7e, 0xbc, 0x7f, 0x12, 0xbd, 0x29, + 0x20, 0x12, 0xc0, 0xc1, 0xa1, 0x22, 0xa6, 0x2c, 0x46, 0x49, 0x90, 0x05, 0xcd, 0x90, 0xbf, 0x1f, + 0xf3, 0x80, 0xe3, 0xd4, 0x41, 0x4e, 0x47, 0x2f, 0xe2, 0xbe, 0xb0, 0x13, 0x29, 0x50, 0x18, 0x0f, + 0x94, 0xdc, 0xbe, 0x2c, 0x5f, 0xa9, 0xed, 0x49, 0xab, 0xc7, 0x90, 0xb4, 0x0e, 0xee, 0xd2, 0x4c, + 0xe7, 0x67, 0x4d, 0x4e, 0x7e, 0xc8, 0x1d, 0x0e, 0xf6, 0x07, 0x62, 0x20, 0xf2, 0x7a, 0x7a, 0xa7, + 0xaa, 0x66, 0xae, 0x71, 0x7a, 0x04, 0x98,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 0x13, 0x00, 0x00, 0xff, 0xff, 0xb7, 0xc6, 0x5a, 0x9b, 0x3a, 0x04, 0x00, 0x00, } func (m *TickInfo) Marshal() (dAtA []byte, err error) { diff --git a/x/concentrated-liquidity/model/tx.pb.go b/x/concentrated-liquidity/model/tx.pb.go index 0f457c6942d..7ff9e85731c 100644 --- a/x/concentrated-liquidity/model/tx.pb.go +++ b/x/concentrated-liquidity/model/tx.pb.go @@ -5,9 +5,9 @@ package model import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -32,11 +32,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgCreateConcentratedPool type MsgCreateConcentratedPool struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Denom0 string `protobuf:"bytes,2,opt,name=denom0,proto3" json:"denom0,omitempty" yaml:"denom0"` - Denom1 string `protobuf:"bytes,3,opt,name=denom1,proto3" json:"denom1,omitempty" yaml:"denom1"` - TickSpacing uint64 `protobuf:"varint,4,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` - SpreadFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spread_factor" yaml:"spread_factor"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Denom0 string `protobuf:"bytes,2,opt,name=denom0,proto3" json:"denom0,omitempty" yaml:"denom0"` + Denom1 string `protobuf:"bytes,3,opt,name=denom1,proto3" json:"denom1,omitempty" yaml:"denom1"` + TickSpacing uint64 `protobuf:"varint,4,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + SpreadFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spread_factor" yaml:"spread_factor"` } func (m *MsgCreateConcentratedPool) Reset() { *m = MsgCreateConcentratedPool{} } @@ -155,36 +155,36 @@ func init() { } var fileDescriptor_dde1ce763867060f = []byte{ - // 455 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x41, 0x6b, 0xd4, 0x40, - 0x14, 0xc7, 0x37, 0xed, 0xba, 0xe2, 0xd8, 0x1e, 0x8c, 0x45, 0xe3, 0x1e, 0x92, 0x1a, 0x41, 0xea, - 0x61, 0x67, 0x8c, 0x9e, 0x2c, 0x82, 0x90, 0x96, 0x62, 0x0f, 0x05, 0x89, 0x07, 0x41, 0x84, 0x65, - 0x32, 0x33, 0xc6, 0x61, 0x93, 0xbc, 0x98, 0x99, 0x96, 0xee, 0xb7, 0xf0, 0x4b, 0x09, 0x3d, 0x16, - 0x4f, 0xd2, 0x43, 0x90, 0xdd, 0x6f, 0xb0, 0x9f, 0x40, 0x92, 0xc9, 0x96, 0x54, 0xcc, 0x49, 0x3c, - 0xed, 0xfe, 0xe7, 0xff, 0x7b, 0xff, 0xbc, 0xbc, 0x37, 0x41, 0x6f, 0x40, 0x65, 0xa0, 0xa4, 0x22, - 0x0c, 0x72, 0x26, 0x72, 0x5d, 0x52, 0x2d, 0xf8, 0x24, 0x95, 0x5f, 0x4f, 0x25, 0x97, 0x7a, 0x4e, - 0x0a, 0x80, 0x74, 0x92, 0x01, 0x17, 0xe9, 0x0d, 0x82, 0xe8, 0x73, 0x5c, 0x94, 0xa0, 0xc1, 0x7e, - 0xdd, 0x06, 0xe0,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0x21, 0x14, 0x3e, 0x14, 0x6c, 0x55, 0x79, 0x3b, - 0xed, 0x1b, 0x77, 0xc3, 0xfc, 0x68, 0xcb, 0xe8, 0x23, 0x23, 0xdf, 0xa2, 0xc7, 0xbd, 0x63, 0x8c, - 0x84, 0x2a, 0x20, 0x57, 0xc2, 0x7e, 0x82, 0x6e, 0xd7, 0x4b, 0x9c, 0x4a, 0xde, 0xcc, 0x73, 0x18, - 0xa2, 0x45, 0xe5, 0x8d, 0x6a, 0xe4, 0xf8, 0x30, 0x1a, 0xd5, 0xd6, 0x31, 0x7f, 0x71, 0x65, 0xa1, - 0xcd, 0x13, 0x95, 0xd8, 0x3f, 0x2c, 0xf4, 0xa0, 0x67, 0x2d, 0x1f, 0xf0, 0xbf, 0xdc, 0x14, 0xdc, - 0xdb, 0xe8, 0x78, 0xfa, 0x9f, 0x82, 0xd7, 0x13, 0x08, 0x3f, 0x5d, 0x2c, 0x5c, 0xeb, 0x72, 0xe1, - 0x5a, 0xbf, 0x16, 0xae, 0xf5, 0x6d, 0xe9, 0x0e, 0x2e, 0x97, 0xee, 0xe0, 0xe7, 0xd2, 0x1d, 0x7c, - 0x0c, 0x3b, 0xeb, 0x68, 0x9b, 0x98, 0xa4, 0x34, 0x56, 0x6b, 0x41, 0xce, 0x82, 0x57, 0xe4, 0xbc, - 0xef, 0xdb, 0x6a, 0x9a, 0x8a, 0x47, 0xcd, 0x9d, 0x7e, 0xf9, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x39, - 0x15, 0x7d, 0x7f, 0x8a, 0x03, 0x00, 0x00, + // 457 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xc1, 0x6a, 0xd4, 0x40, + 0x18, 0xc7, 0x37, 0xed, 0xba, 0xe2, 0xd8, 0x1e, 0x8c, 0x45, 0xe3, 0x0a, 0x49, 0x8d, 0x97, 0x7a, + 0xd8, 0x19, 0xa3, 0x27, 0xab, 0x20, 0xa4, 0x45, 0x2c, 0x58, 0x90, 0x78, 0x10, 0x44, 0x58, 0x27, + 0x33, 0x63, 0x3a, 0x34, 0xc9, 0x17, 0x33, 0xd3, 0xd2, 0x7d, 0x0b, 0x9f, 0xc7, 0x27, 0xe8, 0xb1, + 0x78, 0x92, 0x1e, 0x82, 0xec, 0xbe, 0xc1, 0x3e, 0x81, 0x24, 0x93, 0x2d, 0xbb, 0x62, 0x4e, 0xd2, + 0x5b, 0xfe, 0xf3, 0xff, 0x7d, 0xff, 0x7c, 0xf9, 0xe6, 0x0b, 0x7a, 0x0d, 0x2a, 0x03, 0x25, 0x15, + 0x61, 0x90, 0x33, 0x91, 0xeb, 0x92, 0x6a, 0xc1, 0x47, 0xa9, 0xfc, 0x76, 0x22, 0xb9, 0xd4, 0x13, + 0x52, 0x00, 0xa4, 0xa3, 0x0c, 0xb8, 0x48, 0x57, 0x08, 0xa2, 0xcf, 0x70, 0x51, 0x82, 0x06, 0xfb, + 0x55, 0x1b, 0x80, 0x97, 0xed, 0xab, 0x7a, 0x5c, 0xd7, 0x37, 0xe5, 0x2b, 0x3e, 0x3e, 0x0d, 0x62, + 0xa1, 0x69, 0x30, 0xdc, 0x4a, 0x20, 0x81, 0x26, 0x88, 0xd4, 0x4f, 0x26, 0x73, 0xe8, 0xb2, 0x26, + 0x94, 0xc4, 0x54, 0x09, 0xd2, 0xa2, 0x84, 0x81, 0xcc, 0x8d, 0xef, 0xff, 0x58, 0x43, 0x0f, 0x0e, + 0x55, 0xb2, 0x57, 0x0a, 0xaa, 0xc5, 0xde, 0x52, 0xee, 0x7b, 0x80, 0xd4, 0x7e, 0x82, 0x06, 0x4a, + 0xe4, 0x5c, 0x94, 0x8e, 0xb5, 0x6d, 0xed, 0xdc, 0x0a, 0xef, 0xcc, 0x2b, 0x6f, 0x73, 0x42, 0xb3, + 0x74, 0xd7, 0x37, 0xe7, 0x7e, 0xd4, 0x02, 0x35, 0xca, 0x45, 0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x7b, 0xea, + 0x5a, 0xdf, 0x67, 0x6e, 0xef, 0x62, 0xe6, 0xf6, 0x7e, 0xcd, 0xdc, 0xde, 0xa7, 0x30, 0x91, 0xfa, + 0xe8, 0x24, 0xc6, 0x0c, 0x32, 0xd2, 0x36, 0x31, 0x4a, 0x69, 0xac, 0x16, 0x82, 0x9c, 0x06, 0x2f, + 0xc8, 0x59, 0xd7, 0x0f, 0xd5, 0x34, 0x15, 0x0f, 0x9a, 0x45, 0x7e, 0xfe, 0x27, 0x00, 0x00, 0xff, + 0xff, 0x16, 0xd7, 0x80, 0x4d, 0x7f, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/concentrated-liquidity/msg_server.go b/x/concentrated-liquidity/msg_server.go index b96c74318f8..1af37cf0aba 100644 --- a/x/concentrated-liquidity/msg_server.go +++ b/x/concentrated-liquidity/msg_server.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -79,10 +80,10 @@ func (server msgServer) AddToPosition(goCtx context.Context, msg *types.MsgAddTo } if msg.TokenMinAmount0.IsNil() { - msg.TokenMinAmount0 = sdk.ZeroInt() + msg.TokenMinAmount0 = osmomath.ZeroInt() } if msg.TokenMinAmount1.IsNil() { - msg.TokenMinAmount1 = sdk.ZeroInt() + msg.TokenMinAmount1 = osmomath.ZeroInt() } positionId, actualAmount0, actualAmount1, err := server.keeper.addToPosition(ctx, sender, msg.PositionId, msg.Amount0, msg.Amount1, msg.TokenMinAmount0, msg.TokenMinAmount1) diff --git a/x/concentrated-liquidity/msg_server_test.go b/x/concentrated-liquidity/msg_server_test.go index b529162fa63..88f9c6c4ebe 100644 --- a/x/concentrated-liquidity/msg_server_test.go +++ b/x/concentrated-liquidity/msg_server_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -94,16 +95,16 @@ func (s *KeeperTestSuite) TestCreatePositionMsg() { expectedError: types.InvalidLowerUpperTickError{LowerTick: DefaultUpperTick, UpperTick: DefaultUpperTick}, }, "error: tokens provided is three": { - tokensProvided: DefaultCoins.Add(sdk.NewCoin("foo", sdk.NewInt(10))), + tokensProvided: DefaultCoins.Add(sdk.NewCoin("foo", osmomath.NewInt(10))), expectedError: types.CoinLengthError{Length: 3, MaxLength: 2}, }, "error: token min amount 0 is negative": { - amount0Minimum: sdk.NewInt(-10), - expectedError: types.NotPositiveRequireAmountError{Amount: sdk.NewInt(-10).String()}, + amount0Minimum: osmomath.NewInt(-10), + expectedError: types.NotPositiveRequireAmountError{Amount: osmomath.NewInt(-10).String()}, }, "error: token min amount 1 is negative": { - amount1Minimum: sdk.NewInt(-10), - expectedError: types.NotPositiveRequireAmountError{Amount: sdk.NewInt(-10).String()}, + amount1Minimum: osmomath.NewInt(-10), + expectedError: types.NotPositiveRequireAmountError{Amount: osmomath.NewInt(-10).String()}, }, } for name, tc := range testcases { @@ -296,7 +297,7 @@ func (s *KeeperTestSuite) TestCollectSpreadRewards_Events() { // Add spread rewards to the pool's accum so we aren't just claiming 0 rewards. // Claiming 0 rewards is still a valid message, but is not as valuable for testing. - s.AddToSpreadRewardAccumulator(validPoolId, sdk.NewDecCoin(ETH, sdk.NewInt(1))) + s.AddToSpreadRewardAccumulator(validPoolId, sdk.NewDecCoin(ETH, osmomath.NewInt(1))) // Determine expected rewards from all provided positions without modifying state. expectedTotalSpreadRewards := sdk.Coins(nil) @@ -419,7 +420,7 @@ func (s *KeeperTestSuite) TestCollectIncentives_Events() { err = addToUptimeAccums(ctx, pool.GetId(), s.App.ConcentratedLiquidityKeeper, uptimeHelper.hundredTokensMultiDenom) s.Require().NoError(err) - numPositions := sdk.NewInt(int64(len(tc.positionIds))) + numPositions := osmomath.NewInt(int64(len(tc.positionIds))) // Fund the incentives address with the amount of incentives we expect the positions to both claim and forfeit. // The claim amount must be funded to the incentives address in order for the rewards to be sent to the user. // The forfeited about must be funded to the incentives address in order for the forfeited rewards to be sent to the community pool. diff --git a/x/concentrated-liquidity/pool.go b/x/concentrated-liquidity/pool.go index bfd5f319967..ba97a3a5244 100644 --- a/x/concentrated-liquidity/pool.go +++ b/x/concentrated-liquidity/pool.go @@ -144,31 +144,31 @@ func (k Keeper) CalculateSpotPrice( poolId uint64, quoteAssetDenom string, baseAssetDenom string, -) (spotPrice sdk.Dec, err error) { +) (spotPrice osmomath.Dec, err error) { concentratedPool, err := k.getPoolById(ctx, poolId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } hasPositions, err := k.HasAnyPositionForPool(ctx, poolId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } if !hasPositions { - return sdk.Dec{}, types.NoSpotPriceWhenNoLiquidityError{PoolId: poolId} + return osmomath.Dec{}, types.NoSpotPriceWhenNoLiquidityError{PoolId: poolId} } price, err := concentratedPool.SpotPrice(ctx, quoteAssetDenom, baseAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } if price.IsZero() { - return sdk.Dec{}, types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromSDKDec(price), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice} + return osmomath.Dec{}, types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromDec(price), MinSpotPrice: types.MinSpotPriceV2, MaxSpotPrice: types.MaxSpotPrice} } if price.GT(types.MaxSpotPrice) || price.LT(types.MinSpotPrice) { - return sdk.Dec{}, types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromSDKDec(price), MinSpotPrice: types.MinSpotPriceBigDec, MaxSpotPrice: types.MaxSpotPrice} + return osmomath.Dec{}, types.PriceBoundError{ProvidedPrice: osmomath.BigDecFromDec(price), MinSpotPrice: types.MinSpotPriceBigDec, MaxSpotPrice: types.MaxSpotPrice} } return price, nil @@ -311,7 +311,7 @@ func (k Keeper) validateTickSpacingUpdate(pool types.ConcentratedPoolExtension, // validateSpreadFactor returns true if the given spread factor is one of the authorized spread factors set in the // params. False otherwise. -func (k Keeper) validateSpreadFactor(params types.Params, spreadFactor sdk.Dec) bool { +func (k Keeper) validateSpreadFactor(params types.Params, spreadFactor osmomath.Dec) bool { for _, authorizedSpreadFactor := range params.AuthorizedSpreadFactors { if spreadFactor.Equal(authorizedSpreadFactor) { return true diff --git a/x/concentrated-liquidity/pool_test.go b/x/concentrated-liquidity/pool_test.go index d0159b9f173..80cd46917a4 100644 --- a/x/concentrated-liquidity/pool_test.go +++ b/x/concentrated-liquidity/pool_test.go @@ -29,7 +29,7 @@ func (s *KeeperTestSuite) TestInitializePool() { s.Require().NoError(err) // Create a concentrated liquidity pool with unauthorized spread factor - invalidSpreadFactor := sdk.MustNewDecFromStr("0.1") + invalidSpreadFactor := osmomath.MustNewDecFromStr("0.1") invalidSpreadFactorConcentratedPool, err := clmodel.NewConcentratedLiquidityPool(3, ETH, USDC, DefaultTickSpacing, invalidSpreadFactor) s.Require().NoError(err) @@ -245,7 +245,7 @@ func (s *KeeperTestSuite) TestCalculateSpotPrice() { spotPrice, err := s.App.ConcentratedLiquidityKeeper.CalculateSpotPrice(s.Ctx, poolId, ETH, USDC) s.Require().Error(err) s.Require().ErrorAs(err, &types.NoSpotPriceWhenNoLiquidityError{PoolId: poolId}) - s.Require().Equal(sdk.Dec{}, spotPrice) + s.Require().Equal(osmomath.Dec{}, spotPrice) // set up default position to have proper spot price s.SetupDefaultPosition(defaultPoolId) @@ -253,12 +253,12 @@ func (s *KeeperTestSuite) TestCalculateSpotPrice() { // ETH is token0 so its price will be the DefaultCurrSqrtPrice squared spotPriceBaseETH, err := s.App.ConcentratedLiquidityKeeper.CalculateSpotPrice(s.Ctx, poolId, USDC, ETH) s.Require().NoError(err) - s.Require().Equal(spotPriceBaseETH, DefaultCurrSqrtPrice.PowerInteger(2).SDKDec()) + s.Require().Equal(spotPriceBaseETH, DefaultCurrSqrtPrice.PowerInteger(2).Dec()) // test that we have correct values for reversed quote asset and base asset spotPriceBaseUSDC, err := s.App.ConcentratedLiquidityKeeper.CalculateSpotPrice(s.Ctx, poolId, ETH, USDC) s.Require().NoError(err) - s.Require().Equal(spotPriceBaseUSDC, osmomath.OneDec().Quo(DefaultCurrSqrtPrice.PowerInteger(2)).SDKDec()) + s.Require().Equal(spotPriceBaseUSDC, osmomath.OneBigDec().Quo(DefaultCurrSqrtPrice.PowerInteger(2)).Dec()) // try getting spot price from a non-existent pool spotPrice, err = s.App.ConcentratedLiquidityKeeper.CalculateSpotPrice(s.Ctx, poolId+1, USDC, ETH) @@ -271,7 +271,7 @@ func (s *KeeperTestSuite) TestValidateSpreadFactor() { params := s.App.ConcentratedLiquidityKeeper.GetParams(s.Ctx) tests := []struct { name string - spreadFactor sdk.Dec + spreadFactor osmomath.Dec expectValid bool }{ { @@ -281,7 +281,7 @@ func (s *KeeperTestSuite) TestValidateSpreadFactor() { }, { name: "Invalid spread factor", - spreadFactor: params.AuthorizedSpreadFactors[0].Add(sdk.SmallestDec()), + spreadFactor: params.AuthorizedSpreadFactors[0].Add(osmomath.SmallestDec()), expectValid: false, }, } @@ -332,14 +332,14 @@ func (s *KeeperTestSuite) TestSetPool() { Address: s.TestAccs[0].String(), IncentivesAddress: s.TestAccs[1].String(), Id: 1, - CurrentTickLiquidity: sdk.ZeroDec(), + CurrentTickLiquidity: osmomath.ZeroDec(), Token0: ETH, Token1: USDC, - CurrentSqrtPrice: osmomath.OneDec(), + CurrentSqrtPrice: osmomath.OneBigDec(), CurrentTick: 0, TickSpacing: DefaultTickSpacing, ExponentAtPriceOne: -6, - SpreadFactor: sdk.MustNewDecFromStr("0.003"), + SpreadFactor: osmomath.MustNewDecFromStr("0.003"), LastLiquidityUpdate: s.Ctx.BlockTime(), } tests := []struct { @@ -470,11 +470,11 @@ func (s *KeeperTestSuite) TestDecreaseConcentratedPoolTickSpacing() { concentratedPool := s.PrepareConcentratedPoolWithCoinsAndFullRangePosition(ETH, USDC) // Create a position in the pool that is divisible by the tick spacing - _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), -100, 100) + _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), -100, 100) s.Require().NoError(err) // Attempt to create a position that is not divisible by the tick spacing - _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), test.position.lowerTick, test.position.upperTick) + _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), test.position.lowerTick, test.position.upperTick) s.Require().Error(err) // Alter the tick spacing of the pool @@ -487,7 +487,7 @@ func (s *KeeperTestSuite) TestDecreaseConcentratedPoolTickSpacing() { s.Require().NoError(err) // Attempt to create a position that was previously not divisible by the tick spacing but now is - _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), test.position.lowerTick, test.position.upperTick) + _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, concentratedPool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), test.position.lowerTick, test.position.upperTick) if test.expectedCreatePositionErr != nil { s.Require().Error(err) s.Require().ErrorContains(err, test.expectedCreatePositionErr.Error()) @@ -500,9 +500,9 @@ func (s *KeeperTestSuite) TestDecreaseConcentratedPoolTickSpacing() { func (s *KeeperTestSuite) TestGetTotalPoolLiquidity() { var ( - defaultPoolCoinOne = sdk.NewCoin(USDC, sdk.OneInt()) - defaultPoolCoinTwo = sdk.NewCoin(ETH, sdk.NewInt(2)) - nonPoolCool = sdk.NewCoin("uosmo", sdk.NewInt(3)) + defaultPoolCoinOne = sdk.NewCoin(USDC, osmomath.OneInt()) + defaultPoolCoinTwo = sdk.NewCoin(ETH, osmomath.NewInt(2)) + nonPoolCool = sdk.NewCoin("uosmo", osmomath.NewInt(3)) defaultCoins = sdk.NewCoins(defaultPoolCoinOne, defaultPoolCoinTwo) ) @@ -620,18 +620,18 @@ func (s *KeeperTestSuite) TestValidateTickSpacingUpdate() { func (s *KeeperTestSuite) TestGetUserUnbondingPositions() { var ( defaultFooAsset balancer.PoolAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), } defaultBondDenomAsset balancer.PoolAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10000)), } defaultPoolAssets []balancer.PoolAsset = []balancer.PoolAsset{defaultFooAsset, defaultBondDenomAsset} defaultAddress = s.TestAccs[0] - defaultFunds = sdk.NewCoins(defaultPoolAssets[0].Token, sdk.NewCoin("stake", sdk.NewInt(5000000000))) + defaultFunds = sdk.NewCoins(defaultPoolAssets[0].Token, sdk.NewCoin("stake", osmomath.NewInt(5000000000))) defaultBlockTime = time.Unix(1, 1).UTC() - defaultLockedAmt = sdk.NewCoins(sdk.NewCoin("cl/pool/1", sdk.NewInt(10000))) + defaultLockedAmt = sdk.NewCoins(sdk.NewCoin("cl/pool/1", osmomath.NewInt(10000))) ) tests := []struct { @@ -652,7 +652,7 @@ func (s *KeeperTestSuite) TestGetUserUnbondingPositions() { LowerTick: types.MinInitializedTick, UpperTick: types.MaxTick, JoinTime: defaultBlockTime, - Liquidity: sdk.MustNewDecFromStr("10000.000000000000001000"), + Liquidity: osmomath.MustNewDecFromStr("10000.000000000000001000"), }, Locks: lockuptypes.PeriodLock{ diff --git a/x/concentrated-liquidity/position.go b/x/concentrated-liquidity/position.go index 5c3558fef2b..0f4844cb41a 100644 --- a/x/concentrated-liquidity/position.go +++ b/x/concentrated-liquidity/position.go @@ -11,6 +11,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/accum" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" @@ -27,15 +28,15 @@ var emptyOptions = &accum.Options{} func (k Keeper) getOrInitPosition( ctx sdk.Context, positionId uint64, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { if k.hasPosition(ctx, positionId) { positionLiquidity, err := k.GetPositionLiquidity(ctx, positionId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return positionLiquidity, nil } - return sdk.ZeroDec(), nil + return osmomath.ZeroDec(), nil } // initOrUpdatePosition checks to see if the specified owner has an existing position at the given tick range. @@ -49,7 +50,7 @@ func (k Keeper) initOrUpdatePosition( poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, - liquidityDelta sdk.Dec, + liquidityDelta osmomath.Dec, joinTime time.Time, positionId uint64, ) (err error) { @@ -141,10 +142,10 @@ func (k Keeper) GetAllPositionIdsForPoolId(ctx sdk.Context, prefix []byte, poolI } // GetPositionLiquidity checks if the provided positionId exists. Returns position liquidity if found. Error otherwise. -func (k Keeper) GetPositionLiquidity(ctx sdk.Context, positionId uint64) (sdk.Dec, error) { +func (k Keeper) GetPositionLiquidity(ctx sdk.Context, positionId uint64) (osmomath.Dec, error) { position, err := k.GetPosition(ctx, positionId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return position.Liquidity, nil @@ -288,7 +289,7 @@ func (k Keeper) SetPosition(ctx sdk.Context, owner sdk.AccAddress, lowerTick, upperTick int64, joinTime time.Time, - liquidity sdk.Dec, + liquidity osmomath.Dec, positionId uint64, underlyingLockId uint64, ) error { @@ -404,15 +405,15 @@ func (k Keeper) CreateFullRangePosition(ctx sdk.Context, poolId uint64, owner sd } // Defense in depth, ensure coins provided match the pool's token denominations. - if coins.AmountOf(concentratedPool.GetToken0()).LTE(sdk.ZeroInt()) { + if coins.AmountOf(concentratedPool.GetToken0()).LTE(osmomath.ZeroInt()) { return types.CreateFullRangePositionData{}, types.Amount0IsNegativeError{Amount0: coins.AmountOf(concentratedPool.GetToken0())} } - if coins.AmountOf(concentratedPool.GetToken1()).LTE(sdk.ZeroInt()) { + if coins.AmountOf(concentratedPool.GetToken1()).LTE(osmomath.ZeroInt()) { return types.CreateFullRangePositionData{}, types.Amount1IsNegativeError{Amount1: coins.AmountOf(concentratedPool.GetToken1())} } // Create a full range (min to max tick) concentrated liquidity position. - positionData, err := k.CreatePosition(ctx, concentratedPool.GetId(), owner, coins, sdk.ZeroInt(), sdk.ZeroInt(), types.MinInitializedTick, types.MaxTick) + positionData, err := k.CreatePosition(ctx, concentratedPool.GetId(), owner, coins, osmomath.ZeroInt(), osmomath.ZeroInt(), types.MinInitializedTick, types.MaxTick) if err != nil { return types.CreateFullRangePositionData{}, err } @@ -509,7 +510,7 @@ func CalculateUnderlyingAssetsFromPosition(ctx sdk.Context, position model.Posit token1 := pool.GetToken1() if position.Liquidity.IsZero() { - return sdk.NewCoin(token0, sdk.ZeroInt()), sdk.NewCoin(token1, sdk.ZeroInt()), nil + return sdk.NewCoin(token0, osmomath.ZeroInt()), sdk.NewCoin(token1, osmomath.ZeroInt()), nil } // Calculate the amount of underlying assets in the position @@ -631,18 +632,18 @@ func (k Keeper) positionHasActiveUnderlyingLockAndUpdate(ctx sdk.Context, positi // Returns error if: // - fails to retrieve data from the store. // - there is no full range liquidity in the pool. -func (k Keeper) GetFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64) (sdk.Dec, error) { +func (k Keeper) GetFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64) (osmomath.Dec, error) { store := ctx.KVStore(k.storeKey) poolIdLiquidityKey := types.KeyFullRangeLiquidityPrefix(poolId) currentTotalFullRangeLiquidity, err := osmoutils.GetDec(store, poolIdLiquidityKey) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return currentTotalFullRangeLiquidity, nil } // updateFullRangeLiquidityInPool updates the total liquidity store that is currently in the full range of the pool. -func (k Keeper) updateFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64, liquidity sdk.Dec) error { +func (k Keeper) updateFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64, liquidity osmomath.Dec) error { store := ctx.KVStore(k.storeKey) // Get previous total liquidity. poolIdLiquidityKey := types.KeyFullRangeLiquidityPrefix(poolId) @@ -654,7 +655,7 @@ func (k Keeper) updateFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64, l currentTotalFullRangeLiquidity := currentTotalFullRangeLiquidityDecProto.Dec // If position not found error, then we are creating the first full range liquidity position for a pool. if !found { - currentTotalFullRangeLiquidity = sdk.ZeroDec() + currentTotalFullRangeLiquidity = osmomath.ZeroDec() } // Add the liquidity of the new position to the total liquidity. diff --git a/x/concentrated-liquidity/position_test.go b/x/concentrated-liquidity/position_test.go index 8b2a551999a..6c46b7d08db 100644 --- a/x/concentrated-liquidity/position_test.go +++ b/x/concentrated-liquidity/position_test.go @@ -26,7 +26,7 @@ const ( var ( DefaultIncentiveRecords = []types.IncentiveRecord{incentiveRecordOne, incentiveRecordTwo, incentiveRecordThree, incentiveRecordFour} DefaultBlockTime = time.Unix(1, 1).UTC() - DefaultSpreadFactor = sdk.NewDecWithPrec(2, 3) + DefaultSpreadFactor = osmomath.NewDecWithPrec(2, 3) ) // AssertPositionsDoNotExist checks that the positions with the given IDs do not exist on uptime accumulators. @@ -110,7 +110,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { upperTick int64 joinTime time.Time positionId uint64 - liquidityDelta sdk.Dec + liquidityDelta osmomath.Dec } tests := []struct { @@ -119,7 +119,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { positionExists bool timeElapsedSinceInit time.Duration incentiveRecords []types.IncentiveRecord - expectedLiquidity sdk.Dec + expectedLiquidity osmomath.Dec expectedErr error }{ { @@ -206,7 +206,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { s.Require().NoError(err) // If positionExists set, initialize the specified position with defaultLiquidityAmt - preexistingLiquidity := sdk.ZeroDec() + preexistingLiquidity := osmomath.ZeroDec() if test.positionExists { // We let some fixed amount of time to elapse so we can ensure LastLiquidityUpdate time is // tracked properly even with no liquidity. @@ -287,7 +287,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePosition() { // Setup for checks actualUptimeAccumDelta, expectedUptimeAccumValueGrowth, expectedIncentiveRecords, _ := emptyAccumValues, emptyAccumValues, test.incentiveRecords, sdk.DecCoins{} - timeElapsedSec := sdk.NewDec(int64(test.timeElapsedSinceInit)).Quo(sdk.NewDec(10e8)) + timeElapsedSec := osmomath.NewDec(int64(test.timeElapsedSinceInit)).Quo(osmomath.NewDec(10e8)) positionName := string(types.KeyPositionId(test.param.positionId)) // Loop through each supported uptime for pool and ensure that: @@ -339,7 +339,7 @@ func (s *KeeperTestSuite) TestGetPosition() { tests := []struct { name string positionId uint64 - expectedPositionLiquidity sdk.Dec + expectedPositionLiquidity osmomath.Dec expectedErr error }{ { @@ -372,7 +372,7 @@ func (s *KeeperTestSuite) TestGetPosition() { if test.expectedErr != nil { s.Require().Error(err) s.Require().ErrorIs(err, test.expectedErr) - s.Require().Equal(sdk.Dec{}, position.Liquidity) + s.Require().Equal(osmomath.Dec{}, position.Liquidity) } else { s.Require().NoError(err) s.Require().Equal(test.expectedPositionLiquidity, position.Liquidity) @@ -757,7 +757,7 @@ func (s *KeeperTestSuite) TestDeletePosition() { positionLiquidity, err := s.App.ConcentratedLiquidityKeeper.GetPositionLiquidity(s.Ctx, test.positionId) s.Require().Error(err) s.Require().ErrorIs(err, types.PositionIdNotFoundError{PositionId: test.positionId}) - s.Require().Equal(sdk.Dec{}, positionLiquidity) + s.Require().Equal(osmomath.Dec{}, positionLiquidity) // Check that stores were deleted // Retrieve the position from the store via position ID and compare to expected values. @@ -825,20 +825,20 @@ func (s *KeeperTestSuite) TestCalculateUnderlyingAssetsFromPosition() { // prepare concentrated pool with a default position s.PrepareConcentratedPool() s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0), sdk.NewCoin(USDC, DefaultAmt1))) - _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, 1, s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, 1, s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) // create a position from the test case s.FundAcc(s.TestAccs[1], sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0), sdk.NewCoin(USDC, DefaultAmt1))) - positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, tc.position.PoolId, s.TestAccs[1], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), tc.position.LowerTick, tc.position.UpperTick) + positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, tc.position.PoolId, s.TestAccs[1], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), tc.position.LowerTick, tc.position.UpperTick) s.Require().NoError(err) tc.position.Liquidity = positionData.Liquidity if tc.isZeroLiquidity { // set the position liquidity to zero - tc.position.Liquidity = sdk.ZeroDec() - positionData.Amount0 = sdk.ZeroInt() - positionData.Amount1 = sdk.ZeroInt() + tc.position.Liquidity = osmomath.ZeroDec() + positionData.Amount0 = osmomath.ZeroInt() + positionData.Amount1 = osmomath.ZeroInt() } // calculate underlying assets from the position @@ -957,8 +957,8 @@ func (s *KeeperTestSuite) TestCreateFullRangePosition() { err error ) invalidCoinsAmount := sdk.NewCoins(DefaultCoin0) - invalidCoin0Denom := sdk.NewCoins(sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000)), DefaultCoin1) - invalidCoin1Denom := sdk.NewCoins(DefaultCoin0, sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000))) + invalidCoin0Denom := sdk.NewCoins(sdk.NewCoin("invalidDenom", osmomath.NewInt(1000000000000000000)), DefaultCoin1) + invalidCoin1Denom := sdk.NewCoins(DefaultCoin0, sdk.NewCoin("invalidDenom", osmomath.NewInt(1000000000000000000))) tests := []struct { name string @@ -1006,12 +1006,12 @@ func (s *KeeperTestSuite) TestCreateFullRangePosition() { { name: "err: wrong denom 0 provided for a full range", coinsForPosition: invalidCoin0Denom, - expectedErr: types.Amount0IsNegativeError{Amount0: sdk.ZeroInt()}, + expectedErr: types.Amount0IsNegativeError{Amount0: osmomath.ZeroInt()}, }, { name: "err: wrong denom 1 provided for a full range", coinsForPosition: invalidCoin1Denom, - expectedErr: types.Amount1IsNegativeError{Amount1: sdk.ZeroInt()}, + expectedErr: types.Amount1IsNegativeError{Amount1: osmomath.ZeroInt()}, }, } @@ -1126,7 +1126,7 @@ func (s *KeeperTestSuite) TestMintSharesAndLock() { // Create a position positionId := uint64(0) - liquidity := sdk.ZeroDec() + liquidity := osmomath.ZeroDec() if test.createFullRangePosition { var err error positionData, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, clPool.GetId(), test.owner, DefaultCoins) @@ -1135,7 +1135,7 @@ func (s *KeeperTestSuite) TestMintSharesAndLock() { liquidity = positionData.Liquidity } else { var err error - positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPool.GetId(), test.owner, defaultPositionCoins, sdk.ZeroInt(), sdk.ZeroInt(), test.lowerTick, test.upperTick) + positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPool.GetId(), test.owner, defaultPositionCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), test.lowerTick, test.upperTick) s.Require().NoError(err) positionId = positionData.ID liquidity = positionData.Liquidity @@ -1514,7 +1514,7 @@ func (s *KeeperTestSuite) TestSetPosition() { lowerTick int64 upperTick int64 joinTime time.Time - liquidity sdk.Dec + liquidity osmomath.Dec positionId uint64 underlyingLockId uint64 }{ @@ -1601,21 +1601,21 @@ func (s *KeeperTestSuite) TestGetAndUpdateFullRangeLiquidity() { name string positionCoins sdk.Coins lowerTick, upperTick int64 - updateLiquidity sdk.Dec + updateLiquidity osmomath.Dec }{ { name: "full range + position overlapping min tick. update liquidity upwards", positionCoins: sdk.NewCoins(DefaultCoin0, DefaultCoin1), lowerTick: DefaultMinTick, upperTick: DefaultUpperTick, // max tick doesn't overlap, should not count towards full range liquidity - updateLiquidity: sdk.NewDec(100), + updateLiquidity: osmomath.NewDec(100), }, { name: "full range + position overlapping max tick. update liquidity downwards", positionCoins: sdk.NewCoins(DefaultCoin0, DefaultCoin1), lowerTick: DefaultLowerTick, // min tick doesn't overlap, should not count towards full range liquidity upperTick: DefaultMaxTick, - updateLiquidity: sdk.NewDec(-100), + updateLiquidity: osmomath.NewDec(-100), }, } @@ -1628,7 +1628,7 @@ func (s *KeeperTestSuite) TestGetAndUpdateFullRangeLiquidity() { // Create a new pool. clPool := s.PrepareConcentratedPool() clPoolId := clPool.GetId() - actualFullRangeLiquidity := sdk.ZeroDec() + actualFullRangeLiquidity := osmomath.ZeroDec() // Create a full range position. positionData, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, clPool.GetId(), owner, tc.positionCoins) @@ -1645,7 +1645,7 @@ func (s *KeeperTestSuite) TestGetAndUpdateFullRangeLiquidity() { // Create a new position that overlaps with the min tick, but is not full range and therefore should not count towards the full range liquidity. s.FundAcc(owner, tc.positionCoins) - _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPoolId, owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), tc.lowerTick, tc.upperTick) + _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPoolId, owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), tc.lowerTick, tc.upperTick) s.Require().NoError(err) clPool, err = s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, clPoolId) @@ -1693,8 +1693,8 @@ func (s *KeeperTestSuite) TestGetAllPositionIdsForPoolId() { func (s *KeeperTestSuite) TestCreateFullRangePositionLocked() { invalidCoinsAmount := sdk.NewCoins(DefaultCoin0) - invalidCoin0Denom := sdk.NewCoins(sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000)), DefaultCoin1) - invalidCoin1Denom := sdk.NewCoins(DefaultCoin0, sdk.NewCoin("invalidDenom", sdk.NewInt(1000000000000000000))) + invalidCoin0Denom := sdk.NewCoins(sdk.NewCoin("invalidDenom", osmomath.NewInt(1000000000000000000)), DefaultCoin1) + invalidCoin1Denom := sdk.NewCoins(DefaultCoin0, sdk.NewCoin("invalidDenom", osmomath.NewInt(1000000000000000000))) zeroCoins := sdk.NewCoins() defaultRemainingLockDuration := s.App.StakingKeeper.GetParams(s.Ctx).UnbondingTime @@ -1714,13 +1714,13 @@ func (s *KeeperTestSuite) TestCreateFullRangePositionLocked() { name: "invalid coin0 denom", remainingLockDuration: defaultRemainingLockDuration, coinsForPosition: invalidCoin0Denom, - expectedErr: types.Amount0IsNegativeError{Amount0: sdk.ZeroInt()}, + expectedErr: types.Amount0IsNegativeError{Amount0: osmomath.ZeroInt()}, }, { name: "invalid coin1 denom", remainingLockDuration: defaultRemainingLockDuration, coinsForPosition: invalidCoin1Denom, - expectedErr: types.Amount1IsNegativeError{Amount1: sdk.ZeroInt()}, + expectedErr: types.Amount1IsNegativeError{Amount1: osmomath.ZeroInt()}, }, { name: "invalid coins amount", @@ -1787,16 +1787,16 @@ func (s *KeeperTestSuite) TestTickRoundingEdgeCase() { secondPositionAddr := testAccs[1] // Create two identical positions with the initial assets set such that both positions are fully in one asset - firstPositionAssets := sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(9823358512)), sdk.NewCoin(USDC, sdk.NewInt(8985893232))) + firstPositionAssets := sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(9823358512)), sdk.NewCoin(USDC, osmomath.NewInt(8985893232))) firstPosLiq, firstPosId := s.SetupPosition(pool.GetId(), firstPositionAddr, firstPositionAssets, -68720000, -68710000, true) - secondPositionAssets := sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(9823358512)), sdk.NewCoin(USDC, sdk.NewInt(8985893232))) + secondPositionAssets := sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(9823358512)), sdk.NewCoin(USDC, osmomath.NewInt(8985893232))) secondPosLiq, secondPosId := s.SetupPosition(pool.GetId(), secondPositionAddr, secondPositionAssets, -68720000, -68710000, true) // Execute a swap that brings the price close enough to the edge of a tick to trigger bankers rounding swapAddr := testAccs[2] - desiredTokenOut := sdk.NewCoin(USDC, sdk.NewInt(10000)) - s.FundAcc(swapAddr, sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(1000000000000000000)))) - _, _, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddr, pool, desiredTokenOut, ETH, sdk.ZeroDec(), sdk.ZeroDec()) + desiredTokenOut := sdk.NewCoin(USDC, osmomath.NewInt(10000)) + s.FundAcc(swapAddr, sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(1000000000000000000)))) + _, _, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddr, pool, desiredTokenOut, ETH, osmomath.ZeroDec(), osmomath.ZeroDec()) s.Require().NoError(err) // Both positions should be able to withdraw successfully @@ -2012,15 +2012,15 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { var ( // Initialize pool with non-zero spread factor. - spreadFactor = sdk.NewDecWithPrec(3, 3) + spreadFactor = osmomath.NewDecWithPrec(3, 3) pool = s.PrepareCustomConcentratedPool(s.TestAccs[0], DefaultCoin0.Denom, DefaultCoin1.Denom, 1, spreadFactor) poolId = pool.GetId() denom0 = pool.GetToken0() denom1 = pool.GetToken1() - rewardsPerSecond = sdk.NewDec(1000) + rewardsPerSecond = osmomath.NewDec(1000) ) - _, err := s.clk.CreateIncentive(s.Ctx, poolId, s.TestAccs[0], sdk.NewCoin("uosmo", sdk.NewInt(1_000_000)), rewardsPerSecond, s.Ctx.BlockTime(), time.Nanosecond) + _, err := s.clk.CreateIncentive(s.Ctx, poolId, s.TestAccs[0], sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000)), rewardsPerSecond, s.Ctx.BlockTime(), time.Nanosecond) s.Require().NoError(err) // Estimates how much to swap in to approximately reach the given tick @@ -2033,8 +2033,8 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { s.Require().True(toTick < pool.GetCurrentTick()) - amountZeroIn := math.CalcAmount0Delta(osmomath.BigDecFromSDKDec(pool.GetLiquidity()), pool.GetCurrentSqrtPrice(), s.tickToSqrtPrice(toTick), true) - coinZeroIn := sdk.NewCoin(denom0, amountZeroIn.SDKDec().TruncateInt()) + amountZeroIn := math.CalcAmount0Delta(osmomath.BigDecFromDec(pool.GetLiquidity()), pool.GetCurrentSqrtPrice(), s.tickToSqrtPrice(toTick), true) + coinZeroIn := sdk.NewCoin(denom0, amountZeroIn.Dec().TruncateInt()) return coinZeroIn } @@ -2049,8 +2049,8 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { s.Require().True(toTick > pool.GetCurrentTick()) - amountOneIn := math.CalcAmount1Delta(osmomath.BigDecFromSDKDec(pool.GetLiquidity()), pool.GetCurrentSqrtPrice(), s.tickToSqrtPrice(toTick), true) - coinOneIn := sdk.NewCoin(denom1, amountOneIn.SDKDec().TruncateInt()) + amountOneIn := math.CalcAmount1Delta(osmomath.BigDecFromDec(pool.GetLiquidity()), pool.GetCurrentSqrtPrice(), s.tickToSqrtPrice(toTick), true) + coinOneIn := sdk.NewCoin(denom1, amountOneIn.Dec().TruncateInt()) return coinOneIn } @@ -2060,18 +2060,18 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { s.CreateFullRangePosition(pool, DefaultCoins) expectedTotalSpreadRewards := sdk.NewCoins() - expectedTotalIncentiveRewards := sdk.ZeroDec() + expectedTotalIncentiveRewards := osmomath.ZeroDec() // Initialize position at a higher range s.FundAcc(s.TestAccs[0], DefaultCoins) - _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultCurrTick+50, DefaultCurrTick+100) + _, err = s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultCurrTick+50, DefaultCurrTick+100) s.Require().NoError(err) // Estimate how much to swap in to approximately DefaultCurrTick - 50 coinZeroIn := estimateCoinZeroIn(DefaultCurrTick - 50) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2088,7 +2088,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { coinOneIn := estimateCoinOneIn(DefaultCurrTick + 150) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom1, coinOneIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom1, coinOneIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2107,7 +2107,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { // We initialized the lower tick's accumulator (DefaultCurrTick - 25) to be greater than the upper tick's accumulator (DefaultCurrTick + 50) // Whenever the current tick is above the position's range, we compute in range accumulator as upper tick accumulator - lower tick accumulator // In this case, it ends up being negative, which is now supported. - negativeIntervalAccumPositionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultCurrTick-25, DefaultCurrTick+50) + negativeIntervalAccumPositionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, poolId, s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultCurrTick-25, DefaultCurrTick+50) s.Require().NoError(err) // Increase block time @@ -2119,7 +2119,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { // Assert global invariants s.assertGlobalInvariants(ExpectedGlobalRewardValues{ // Additive tolerance of 1 for each position. - ExpectedAdditiveSpreadRewardTolerance: sdk.OneDec().MulInt64(3), + ExpectedAdditiveSpreadRewardTolerance: osmomath.OneDec().MulInt64(3), TotalSpreadRewards: expectedTotalSpreadRewards, TotalIncentives: sdk.NewCoins(sdk.NewCoin("uosmo", expectedTotalIncentiveRewards.Ceil().TruncateInt())), }) @@ -2135,7 +2135,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { coinZeroIn = estimateCoinZeroIn(DefaultCurrTick - 50) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2148,7 +2148,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { // Assert global invariants s.assertGlobalInvariants(ExpectedGlobalRewardValues{ // Additive tolerance of 1 for each position. - ExpectedAdditiveSpreadRewardTolerance: sdk.OneDec().MulInt64(3), + ExpectedAdditiveSpreadRewardTolerance: osmomath.OneDec().MulInt64(3), TotalSpreadRewards: expectedTotalSpreadRewards, TotalIncentives: sdk.NewCoins(sdk.NewCoin("uosmo", expectedTotalIncentiveRewards.Ceil().TruncateInt())), }) @@ -2164,7 +2164,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { coinZeroIn = estimateCoinZeroIn(DefaultCurrTick - 10) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2177,7 +2177,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { // Assert global invariants s.assertGlobalInvariants(ExpectedGlobalRewardValues{ // Additive tolerance of 1 for each position. - ExpectedAdditiveSpreadRewardTolerance: sdk.OneDec().MulInt64(3), + ExpectedAdditiveSpreadRewardTolerance: osmomath.OneDec().MulInt64(3), TotalSpreadRewards: expectedTotalSpreadRewards, TotalIncentives: sdk.NewCoins(sdk.NewCoin("uosmo", expectedTotalIncentiveRewards.Ceil().TruncateInt())), }) @@ -2193,7 +2193,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { coinZeroIn = estimateCoinZeroIn(DefaultCurrTick - 50) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom0, coinZeroIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2207,7 +2207,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { coinOneIn := estimateCoinOneIn(DefaultCurrTick + 150) // Update expected spread rewards - expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom1, coinOneIn.Amount.ToDec().Mul(spreadFactor).Ceil().TruncateInt())) + expectedTotalSpreadRewards = expectedTotalSpreadRewards.Add(sdk.NewCoin(denom1, coinOneIn.Amount.ToLegacyDec().Mul(spreadFactor).Ceil().TruncateInt())) // Increase block time s.Ctx = s.Ctx.WithBlockTime(s.Ctx.BlockTime().Add(time.Second)) @@ -2220,7 +2220,7 @@ func (s *KeeperTestSuite) TestNegativeTickRange_SpreadFactor() { // Assert global invariants s.assertGlobalInvariants(ExpectedGlobalRewardValues{ // Additive tolerance of 1 for each position. - ExpectedAdditiveSpreadRewardTolerance: sdk.OneDec().MulInt64(3), + ExpectedAdditiveSpreadRewardTolerance: osmomath.OneDec().MulInt64(3), TotalSpreadRewards: expectedTotalSpreadRewards, TotalIncentives: sdk.NewCoins(sdk.NewCoin("uosmo", expectedTotalIncentiveRewards.Ceil().TruncateInt())), }) diff --git a/x/concentrated-liquidity/query.go b/x/concentrated-liquidity/query.go index b1fe66320a6..9eecbd2ab5c 100644 --- a/x/concentrated-liquidity/query.go +++ b/x/concentrated-liquidity/query.go @@ -23,7 +23,7 @@ import ( func (k Keeper) GetTickLiquidityForFullRange(ctx sdk.Context, poolId uint64) ([]queryproto.LiquidityDepthWithRange, error) { // use false for zeroForOne since we're going from lower tick -> upper tick zeroForOne := false - swapStrategy := swapstrategy.New(zeroForOne, osmomath.ZeroDec(), k.storeKey, sdk.ZeroDec()) + swapStrategy := swapstrategy.New(zeroForOne, osmomath.ZeroBigDec(), k.storeKey, osmomath.ZeroDec()) // set current tick to min tick, and find the first initialized tick starting from min tick -1. // we do -1 to make min tick inclusive. @@ -95,8 +95,8 @@ func (k Keeper) GetTickLiquidityForFullRange(ctx sdk.Context, poolId uint64) ([] // * ctx (sdk.Context): The context for the SDK. // * poolId (uint64): The ID of the pool for which the liquidity needs to be checked. // * tokenIn (string): The token denom that determines the swap direction and strategy. -// * userGivenStartTick (sdk.Int): The starting tick for grabbing liquidities. If not provided, the current tick of the pool is used. -// * boundTick (sdk.Int): An optional bound tick to limit the range of the queryproto. If not provided, the minimum or maximum tick will be used, depending on the strategy. +// * userGivenStartTick (osmomath.Int): The starting tick for grabbing liquidities. If not provided, the current tick of the pool is used. +// * boundTick (osmomath.Int): An optional bound tick to limit the range of the queryproto. If not provided, the minimum or maximum tick will be used, depending on the strategy. // // Returns: @@ -109,7 +109,7 @@ func (k Keeper) GetTickLiquidityForFullRange(ctx sdk.Context, poolId uint64) ([] // Errors: // * types.PoolNotFoundError: If the given pool does not exist. // * types.TokenInDenomNotInPoolError: If the given tokenIn is not an asset in the pool. -func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, tokenIn string, userGivenStartTick sdk.Int, boundTick sdk.Int) ([]queryproto.TickLiquidityNet, error) { +func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, tokenIn string, userGivenStartTick osmomath.Int, boundTick osmomath.Int) ([]queryproto.TickLiquidityNet, error) { // get min and max tick for the pool p, err := k.getPoolById(ctx, poolId) if err != nil { @@ -142,14 +142,14 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t if boundTick.IsNil() { if zeroForOne { - boundTick = sdk.NewInt(types.MinInitializedTick) + boundTick = osmomath.NewInt(types.MinInitializedTick) } else { - boundTick = sdk.NewInt(types.MaxTick) + boundTick = osmomath.NewInt(types.MaxTick) } } liquidityDepths := []queryproto.TickLiquidityNet{} - swapStrategy := swapstrategy.New(zeroForOne, osmomath.ZeroDec(), k.storeKey, sdk.ZeroDec()) + swapStrategy := swapstrategy.New(zeroForOne, osmomath.ZeroBigDec(), k.storeKey, osmomath.ZeroDec()) currentTick := p.GetCurrentTick() currentTickSqrtPrice, err := math.TickToSqrtPrice(currentTick) @@ -161,7 +161,7 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t // function to validate that start tick and bound tick are // between current tick and the min/max tick depending on the swap direction. - validateTickIsInValidRange := func(validateTick sdk.Int) error { + validateTickIsInValidRange := func(validateTick osmomath.Int) error { validateSqrtPrice, err := math.TickToSqrtPrice(validateTick.Int64()) if err != nil { return err @@ -181,7 +181,7 @@ func (k Keeper) GetTickLiquidityNetInDirection(ctx sdk.Context, poolId uint64, t } ctx.Logger().Debug("validating start tick") - if err := validateTickIsInValidRange(sdk.NewInt(startTick)); err != nil { + if err := validateTickIsInValidRange(osmomath.NewInt(startTick)); err != nil { return []queryproto.TickLiquidityNet{}, fmt.Errorf("failed validating start tick (%d) with current sqrt price of (%s): %w", startTick, currentTickSqrtPrice, err) } diff --git a/x/concentrated-liquidity/query_test.go b/x/concentrated-liquidity/query_test.go index 4283f4b075a..f07e1d70df1 100644 --- a/x/concentrated-liquidity/query_test.go +++ b/x/concentrated-liquidity/query_test.go @@ -1,8 +1,6 @@ package concentrated_liquidity_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/client/queryproto" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/math" @@ -21,12 +19,12 @@ func (s *KeeperTestSuite) TestGetTickLiquidityForFullRange() { { name: "one full range position, testing range in between", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, expectedLiquidityDepthForRange: []queryproto.LiquidityDepthWithRange{ { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: DefaultMinTick, UpperTick: DefaultMaxTick, }, @@ -35,12 +33,12 @@ func (s *KeeperTestSuite) TestGetTickLiquidityForFullRange() { { name: "one ranged position, testing range with greater range than initialized ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(-10)), }, expectedLiquidityDepthForRange: []queryproto.LiquidityDepthWithRange{ { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: DefaultMinTick, UpperTick: 5, }, @@ -51,24 +49,24 @@ func (s *KeeperTestSuite) TestGetTickLiquidityForFullRange() { { name: "two ranged positions, testing overlapping positions", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -20, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, 20, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(50)), - withLiquidityNetandTickIndex(defaultTick, 30, sdk.NewDec(-50)), + withLiquidityNetandTickIndex(defaultTick, -20, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, 20, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(50)), + withLiquidityNetandTickIndex(defaultTick, 30, osmomath.NewDec(-50)), }, expectedLiquidityDepthForRange: []queryproto.LiquidityDepthWithRange{ { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: -20, UpperTick: 10, }, { - LiquidityAmount: sdk.NewDec(60), + LiquidityAmount: osmomath.NewDec(60), LowerTick: 10, UpperTick: 20, }, { - LiquidityAmount: sdk.NewDec(50), + LiquidityAmount: osmomath.NewDec(50), LowerTick: 20, UpperTick: 30, }, @@ -79,24 +77,24 @@ func (s *KeeperTestSuite) TestGetTickLiquidityForFullRange() { { name: "one full ranged position, one narrow position", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(50)), - withLiquidityNetandTickIndex(defaultTick, 30, sdk.NewDec(-50)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(50)), + withLiquidityNetandTickIndex(defaultTick, 30, osmomath.NewDec(-50)), }, expectedLiquidityDepthForRange: []queryproto.LiquidityDepthWithRange{ { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: DefaultMinTick, UpperTick: 10, }, { - LiquidityAmount: sdk.NewDec(60), + LiquidityAmount: osmomath.NewDec(60), LowerTick: 10, UpperTick: 30, }, { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: 30, UpperTick: DefaultMaxTick, }, @@ -108,36 +106,36 @@ func (s *KeeperTestSuite) TestGetTickLiquidityForFullRange() { { name: "three ranged positions, testing overlapping positions", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -20, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, 20, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(50)), - withLiquidityNetandTickIndex(defaultTick, 30, sdk.NewDec(-50)), - withLiquidityNetandTickIndex(defaultTick, 11, sdk.NewDec(100)), - withLiquidityNetandTickIndex(defaultTick, 13, sdk.NewDec(-100)), + withLiquidityNetandTickIndex(defaultTick, -20, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, 20, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(50)), + withLiquidityNetandTickIndex(defaultTick, 30, osmomath.NewDec(-50)), + withLiquidityNetandTickIndex(defaultTick, 11, osmomath.NewDec(100)), + withLiquidityNetandTickIndex(defaultTick, 13, osmomath.NewDec(-100)), }, expectedLiquidityDepthForRange: []queryproto.LiquidityDepthWithRange{ { - LiquidityAmount: sdk.NewDec(10), + LiquidityAmount: osmomath.NewDec(10), LowerTick: -20, UpperTick: 10, }, { - LiquidityAmount: sdk.NewDec(60), + LiquidityAmount: osmomath.NewDec(60), LowerTick: 10, UpperTick: 11, }, { - LiquidityAmount: sdk.NewDec(160), + LiquidityAmount: osmomath.NewDec(160), LowerTick: 11, UpperTick: 13, }, { - LiquidityAmount: sdk.NewDec(60), + LiquidityAmount: osmomath.NewDec(60), LowerTick: 13, UpperTick: 20, }, { - LiquidityAmount: sdk.NewDec(50), + LiquidityAmount: osmomath.NewDec(50), LowerTick: 20, UpperTick: 30, }, @@ -174,8 +172,8 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { poolId uint64 tokenIn string currentPoolTick int64 - startTick sdk.Int - boundTick sdk.Int + startTick osmomath.Int + boundTick osmomath.Int // expected values expectedLiquidityDepths []queryproto.TickLiquidityNet @@ -184,16 +182,16 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -201,16 +199,16 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -218,18 +216,18 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, one range position above current tick, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -237,26 +235,26 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, one range position above current tick, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: 5, }, { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -264,18 +262,18 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, one range position above current tick, zero for one false, bound tick below with non-empty ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.NewInt(-15), + boundTick: osmomath.NewInt(-15), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -10, }, }, @@ -283,30 +281,30 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one ranged position, returned empty array", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.NewInt(-5), + boundTick: osmomath.NewInt(-5), expectedLiquidityDepths: []queryproto.TickLiquidityNet{}, }, { name: "one full range position, one range position above current tick, zero for one false, bound tick below with non-empty ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.NewInt(10), + boundTick: osmomath.NewInt(10), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, }, @@ -314,24 +312,24 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, two ranged positions, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(-20)), - withLiquidityNetandTickIndex(defaultTick, 2, sdk.NewDec(40)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-40)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, 2, osmomath.NewDec(40)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-40)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -5, }, { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -339,32 +337,32 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "one full range position, two ranged positions, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(-20)), - withLiquidityNetandTickIndex(defaultTick, 2, sdk.NewDec(40)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-40)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, 2, osmomath.NewDec(40)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-40)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.Int{}, + boundTick: osmomath.Int{}, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(40), + LiquidityNet: osmomath.NewDec(40), TickIndex: 2, }, { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 5, }, { - LiquidityNet: sdk.NewDec(-40), + LiquidityNet: osmomath.NewDec(-40), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -372,21 +370,21 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "current pool tick == start tick, zero for one", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: ETH, currentPoolTick: 10, - startTick: sdk.NewInt(10), - boundTick: sdk.NewInt(-15), + startTick: osmomath.NewInt(10), + boundTick: osmomath.NewInt(-15), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -10, }, }, @@ -394,23 +392,23 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "current pool tick != start tick, zero for one", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: ETH, currentPoolTick: 21, - startTick: sdk.NewInt(10), - boundTick: sdk.NewInt(-15), + startTick: osmomath.NewInt(10), + boundTick: osmomath.NewInt(-15), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -10, }, }, @@ -418,17 +416,17 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "current pool tick == start tick, one for zero", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: USDC, currentPoolTick: 5, - startTick: sdk.NewInt(5), - boundTick: sdk.NewInt(15), + startTick: osmomath.NewInt(5), + boundTick: osmomath.NewInt(15), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, }, @@ -436,17 +434,17 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "current pool tick != start tick, one for zero", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: USDC, currentPoolTick: -50, - startTick: sdk.NewInt(5), - boundTick: sdk.NewInt(15), + startTick: osmomath.NewInt(5), + boundTick: osmomath.NewInt(15), expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, }, @@ -456,89 +454,89 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { { name: "error: invalid pool id", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: 5, tokenIn: "invalid_token", - boundTick: sdk.NewInt(-5), + boundTick: osmomath.NewInt(-5), expectedError: true, }, { name: "error: invalid token in", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, tokenIn: "invalid_token", - boundTick: sdk.NewInt(-5), + boundTick: osmomath.NewInt(-5), expectedError: true, }, { name: "error: wrong direction of bound ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.NewInt(-5), + boundTick: osmomath.NewInt(-5), expectedError: true, }, { name: "error: bound tick is greater than max tick", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, tokenIn: USDC, - boundTick: sdk.NewInt(DefaultMaxTick + 1), + boundTick: osmomath.NewInt(DefaultMaxTick + 1), expectedError: true, }, { name: "error: bound tick is greater than min tick", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, tokenIn: ETH, - boundTick: sdk.NewInt(DefaultMinCurrentTick - 1), + boundTick: osmomath.NewInt(DefaultMinCurrentTick - 1), expectedError: true, }, { name: "start tick is in invalid range relative to current pool tick, zero for one", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: ETH, currentPoolTick: 10, - startTick: sdk.NewInt(21), - boundTick: sdk.NewInt(-15), + startTick: osmomath.NewInt(21), + boundTick: osmomath.NewInt(-15), expectedError: true, }, { name: "start tick is in invalid range relative to current pool tick, one for zero", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, tokenIn: USDC, currentPoolTick: 5, - startTick: sdk.NewInt(-50), - boundTick: sdk.NewInt(15), + startTick: osmomath.NewInt(-50), + boundTick: osmomath.NewInt(15), expectedError: true, }, } @@ -561,12 +559,12 @@ func (s *KeeperTestSuite) TestGetTickLiquidityNetInDirection() { // Force initialize current sqrt price to 1. // Normally, initialized during position creation. // We only initialize ticks in this test for simplicity. - curPrice := sdk.OneDec() + curPrice := osmomath.OneDec() // TODO: consider adding tests for GetTickLiquidityNetInDirection // with tick spacing > 1, requiring price to tick conversion with rounding. - curTick, err := math.CalculateSqrtPriceToTick(osmomath.BigDecFromSDKDec(osmomath.MustMonotonicSqrt(curPrice))) + curTick, err := math.CalculateSqrtPriceToTick(osmomath.BigDecFromDec(osmomath.MustMonotonicSqrt(curPrice))) s.Require().NoError(err) - var curSqrtPrice osmomath.BigDec = osmomath.OneDec() + var curSqrtPrice osmomath.BigDec = osmomath.OneBigDec() if test.currentPoolTick > 0 { sqrtPrice, err := math.TickToSqrtPrice(test.currentPoolTick) s.Require().NoError(err) @@ -613,8 +611,8 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, @@ -622,7 +620,7 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 1, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -630,8 +628,8 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, @@ -639,7 +637,7 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 1, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -647,10 +645,10 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, one range position above current tick, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, @@ -658,7 +656,7 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 1, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -666,10 +664,10 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, one range position above current tick, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, @@ -677,15 +675,15 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 3, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: 5, }, { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -693,10 +691,10 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, one range position above current tick, zero for one false, bound num ticks below with non-empty ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, @@ -704,7 +702,7 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 1, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -10, }, }, @@ -712,8 +710,8 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one ranged position, returned empty array", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, @@ -724,10 +722,10 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, one range position above current tick, zero for one false, bound num ticks below with non-empty ticks", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -10, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -10, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-20)), }, poolId: defaultPoolId, @@ -735,7 +733,7 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 1, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 10, }, }, @@ -743,12 +741,12 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, two ranged positions, zero for one true", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(-20)), - withLiquidityNetandTickIndex(defaultTick, 2, sdk.NewDec(40)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-40)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, 2, osmomath.NewDec(40)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-40)), }, poolId: defaultPoolId, @@ -756,11 +754,11 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 2, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(20), + LiquidityNet: osmomath.NewDec(20), TickIndex: -5, }, { - LiquidityNet: sdk.NewDec(10), + LiquidityNet: osmomath.NewDec(10), TickIndex: DefaultMinTick, }, }, @@ -768,12 +766,12 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "one full range position, two ranged positions, zero for one false", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), - withLiquidityNetandTickIndex(defaultTick, -5, sdk.NewDec(20)), - withLiquidityNetandTickIndex(defaultTick, 5, sdk.NewDec(-20)), - withLiquidityNetandTickIndex(defaultTick, 2, sdk.NewDec(40)), - withLiquidityNetandTickIndex(defaultTick, 10, sdk.NewDec(-40)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, -5, osmomath.NewDec(20)), + withLiquidityNetandTickIndex(defaultTick, 5, osmomath.NewDec(-20)), + withLiquidityNetandTickIndex(defaultTick, 2, osmomath.NewDec(40)), + withLiquidityNetandTickIndex(defaultTick, 10, osmomath.NewDec(-40)), }, poolId: defaultPoolId, @@ -781,19 +779,19 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { numberOfNextInitializedTicks: 4, expectedLiquidityDepths: []queryproto.TickLiquidityNet{ { - LiquidityNet: sdk.NewDec(40), + LiquidityNet: osmomath.NewDec(40), TickIndex: 2, }, { - LiquidityNet: sdk.NewDec(-20), + LiquidityNet: osmomath.NewDec(-20), TickIndex: 5, }, { - LiquidityNet: sdk.NewDec(-40), + LiquidityNet: osmomath.NewDec(-40), TickIndex: 10, }, { - LiquidityNet: sdk.NewDec(-10), + LiquidityNet: osmomath.NewDec(-10), TickIndex: DefaultMaxTick, }, }, @@ -803,8 +801,8 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "error: invalid pool id", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: 5, @@ -815,8 +813,8 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { { name: "error: invalid token in", presetTicks: []genesis.FullTick{ - withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, sdk.NewDec(10)), - withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, sdk.NewDec(-10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMinTick, osmomath.NewDec(10)), + withLiquidityNetandTickIndex(defaultTick, DefaultMaxTick, osmomath.NewDec(-10)), }, poolId: defaultPoolId, @@ -844,10 +842,10 @@ func (s *KeeperTestSuite) TestGetNumNextInitializedTicks() { // Force initialize current sqrt price to 1. // Normally, initialized during position creation. // We only initialize ticks in this test for simplicity. - curPrice := sdk.OneDec() - curTick, err := math.CalculateSqrtPriceToTick(osmomath.BigDecFromSDKDec(osmomath.MustMonotonicSqrt(curPrice))) + curPrice := osmomath.OneDec() + curTick, err := math.CalculateSqrtPriceToTick(osmomath.BigDecFromDec(osmomath.MustMonotonicSqrt(curPrice))) s.Require().NoError(err) - var curSqrtPrice osmomath.BigDec = osmomath.OneDec() + var curSqrtPrice osmomath.BigDec = osmomath.OneBigDec() if test.currentPoolTick > 0 { sqrtPrice, err := math.TickToSqrtPrice(test.currentPoolTick) s.Require().NoError(err) diff --git a/x/concentrated-liquidity/range_test.go b/x/concentrated-liquidity/range_test.go index 0a18f74bed6..06be6e088e8 100644 --- a/x/concentrated-liquidity/range_test.go +++ b/x/concentrated-liquidity/range_test.go @@ -21,13 +21,13 @@ type RangeTestParams struct { // Base number of positions for each range baseNumPositions int // Base amount to swap for each swap - baseSwapAmount sdk.Int + baseSwapAmount osmomath.Int // Base amount to add after each new position baseTimeBetweenJoins time.Duration // Base incentive amount to have on each incentive record - baseIncentiveAmount sdk.Int + baseIncentiveAmount osmomath.Int // Base emission rate per second for incentive - baseEmissionRate sdk.Dec + baseEmissionRate osmomath.Dec // Base denom for each incentive record (ID appended to this) baseIncentiveDenom string // List of addresses to swap from (randomly selected for each swap) @@ -35,7 +35,7 @@ type RangeTestParams struct { // -- Pool params -- - spreadFactor sdk.Dec + spreadFactor osmomath.Dec tickSpacing uint64 // -- Fuzz params -- @@ -67,12 +67,12 @@ var ( DefaultRangeTestParams = RangeTestParams{ // Base amounts baseNumPositions: 10, - baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(5000000000)), sdk.NewCoin(USDC, sdk.NewInt(5000000000))), + baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(5000000000)), sdk.NewCoin(USDC, osmomath.NewInt(5000000000))), baseTimeBetweenJoins: time.Hour, - baseSwapAmount: sdk.NewInt(10000000), + baseSwapAmount: osmomath.NewInt(10000000), numSwapAddresses: 10, - baseIncentiveAmount: sdk.NewInt(1000000000000000000), - baseEmissionRate: sdk.NewDec(1), + baseIncentiveAmount: osmomath.NewInt(1000000000000000000), + baseEmissionRate: osmomath.NewDec(1), baseIncentiveDenom: "incentiveDenom", // Pool params @@ -88,12 +88,12 @@ var ( RangeTestParamsLargeSwap = RangeTestParams{ // Base amounts baseNumPositions: 10, - baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(5000000000)), sdk.NewCoin(USDC, sdk.NewInt(5000000000))), + baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(5000000000)), sdk.NewCoin(USDC, osmomath.NewInt(5000000000))), baseTimeBetweenJoins: time.Hour, - baseSwapAmount: sdk.Int(sdk.MustNewDecFromStr("100000000000000000000000000000000000000")), + baseSwapAmount: osmomath.Int(osmomath.MustNewDecFromStr("100000000000000000000000000000000000000")), numSwapAddresses: 10, - baseIncentiveAmount: sdk.NewInt(1000000000000000000), - baseEmissionRate: sdk.NewDec(1), + baseIncentiveAmount: osmomath.NewInt(1000000000000000000), + baseEmissionRate: osmomath.NewDec(1), baseIncentiveDenom: "incentiveDenom", // Pool params @@ -108,10 +108,10 @@ var ( RangeTestParamsNoFuzzNoSwap = RangeTestParams{ // Base amounts baseNumPositions: 1, - baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(5000000000)), sdk.NewCoin(USDC, sdk.NewInt(5000000000))), + baseAssets: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(5000000000)), sdk.NewCoin(USDC, osmomath.NewInt(5000000000))), baseTimeBetweenJoins: time.Hour, - baseIncentiveAmount: sdk.NewInt(1000000000000000000), - baseEmissionRate: sdk.NewDec(1), + baseIncentiveAmount: osmomath.NewInt(1000000000000000000), + baseEmissionRate: osmomath.NewDec(1), baseIncentiveDenom: "incentiveDenom", // Pool params @@ -136,7 +136,7 @@ func withTickSpacing(params RangeTestParams, tickSpacing uint64) RangeTestParams } func withNoSwap(params RangeTestParams) RangeTestParams { - params.baseSwapAmount = sdk.Int{} + params.baseSwapAmount = osmomath.Int{} return params } @@ -162,7 +162,7 @@ func (s *KeeperTestSuite) setupRangesAndAssertInvariants(pool types.Concentrated // --- Incentive setup --- - if testParams.baseIncentiveAmount != (sdk.Int{}) { + if testParams.baseIncentiveAmount != (osmomath.Int{}) { incentiveAddr := apptesting.CreateRandomAccounts(1)[0] incentiveAmt := testParams.baseIncentiveAmount emissionRate := testParams.baseEmissionRate @@ -178,7 +178,7 @@ func (s *KeeperTestSuite) setupRangesAndAssertInvariants(pool types.Concentrated // 1. Set up a position // 2. Let time elapse // 3. Execute a swap - totalLiquidity, totalAssets, totalTimeElapsed, allPositionIds, lastVisitedBlockIndex, cumulativeEmittedIncentives, lastIncentiveTrackerUpdate := sdk.ZeroDec(), sdk.NewCoins(), time.Duration(0), []uint64{}, 0, sdk.DecCoins{}, s.Ctx.BlockTime() + totalLiquidity, totalAssets, totalTimeElapsed, allPositionIds, lastVisitedBlockIndex, cumulativeEmittedIncentives, lastIncentiveTrackerUpdate := osmomath.ZeroDec(), sdk.NewCoins(), time.Duration(0), []uint64{}, 0, sdk.DecCoins{}, s.Ctx.BlockTime() for curRange := range ranges { curBlock := 0 startNumPositions := len(allPositionIds) @@ -202,7 +202,7 @@ func (s *KeeperTestSuite) setupRangesAndAssertInvariants(pool types.Concentrated curAssets = s.getInitialPositionAssets(pool, testParams.startingCurrentTick) } - roundingError := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), sdk.OneInt()), sdk.NewCoin(pool.GetToken1(), sdk.OneInt())) + roundingError := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), osmomath.OneInt()), sdk.NewCoin(pool.GetToken1(), osmomath.OneInt())) s.FundAcc(curAddr, curAssets.Add(roundingError...)) // Double fund LP address if applicable @@ -216,7 +216,7 @@ func (s *KeeperTestSuite) setupRangesAndAssertInvariants(pool types.Concentrated cumulativeEmittedIncentives, lastIncentiveTrackerUpdate = s.trackEmittedIncentives(cumulativeEmittedIncentives, lastIncentiveTrackerUpdate) // Set up position - positionData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), curAddr, curAssets, sdk.ZeroInt(), sdk.ZeroInt(), ranges[curRange][0], ranges[curRange][1]) + positionData, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), curAddr, curAssets, osmomath.ZeroInt(), osmomath.ZeroInt(), ranges[curRange][0], ranges[curRange][1]) s.Require().NoError(err) // Ensure position was set up correctly and didn't break global invariants @@ -234,7 +234,7 @@ func (s *KeeperTestSuite) setupRangesAndAssertInvariants(pool types.Concentrated // Track changes to state actualAddedCoins := sdk.NewCoins(sdk.NewCoin(pool.GetToken0(), positionData.Amount0), sdk.NewCoin(pool.GetToken1(), positionData.Amount1)) totalAssets = totalAssets.Add(actualAddedCoins...) - if testParams.baseSwapAmount != (sdk.Int{}) { + if testParams.baseSwapAmount != (osmomath.Int{}) { totalAssets = totalAssets.Add(swappedIn).Sub(sdk.NewCoins(swappedOut)) } totalLiquidity = totalLiquidity.Add(positionData.Liquidity) @@ -302,9 +302,9 @@ func (s *KeeperTestSuite) prepareNumPositionSlice(ranges [][]int64, baseNumPosit // The direction of the swap is chosen randomly, but the swap function used is always SwapInGivenOut to // ensure it is always possible to swap against the pool without having to use lower level calc functions. // TODO: Make swaps that target getting to a tick boundary exactly -func (s *KeeperTestSuite) executeRandomizedSwap(pool types.ConcentratedPoolExtension, swapAddresses []sdk.AccAddress, baseSwapAmount sdk.Int, fuzzSwap bool) (sdk.Coin, sdk.Coin) { +func (s *KeeperTestSuite) executeRandomizedSwap(pool types.ConcentratedPoolExtension, swapAddresses []sdk.AccAddress, baseSwapAmount osmomath.Int, fuzzSwap bool) (sdk.Coin, sdk.Coin) { // Quietly skip if no swap assets or swap addresses provided - if (baseSwapAmount == sdk.Int{}) || len(swapAddresses) == 0 { + if (baseSwapAmount == osmomath.Int{}) || len(swapAddresses) == 0 { return sdk.Coin{}, sdk.Coin{} } @@ -332,13 +332,13 @@ func (s *KeeperTestSuite) executeRandomizedSwap(pool types.ConcentratedPoolExten } // TODO: pick a more granular amount to fund without losing ability to swap at really high/low ticks - swapInFunded := sdk.NewCoin(swapInDenom, sdk.Int(sdk.MustNewDecFromStr("10000000000000000000000000000000000000000"))) + swapInFunded := sdk.NewCoin(swapInDenom, osmomath.Int(osmomath.MustNewDecFromStr("10000000000000000000000000000000000000000"))) s.FundAcc(swapAddress, sdk.NewCoins(swapInFunded)) - baseSwapOutAmount := sdk.MinInt(baseSwapAmount, poolLiquidity.AmountOf(swapOutDenom).ToDec().Mul(sdk.MustNewDecFromStr("0.5")).TruncateInt()) + baseSwapOutAmount := osmomath.MinInt(baseSwapAmount, poolLiquidity.AmountOf(swapOutDenom).ToLegacyDec().Mul(osmomath.MustNewDecFromStr("0.5")).TruncateInt()) if fuzzSwap { // Fuzz +/- 100% of base swap amount - baseSwapOutAmount = sdk.NewInt(fuzzInt64(baseSwapOutAmount.Int64(), 2)) + baseSwapOutAmount = osmomath.NewInt(fuzzInt64(baseSwapOutAmount.Int64(), 2)) } swapOutCoin := sdk.NewCoin(swapOutDenom, baseSwapOutAmount) @@ -349,7 +349,7 @@ func (s *KeeperTestSuite) executeRandomizedSwap(pool types.ConcentratedPoolExten s.Require().NoError(err) poolSpotPrice := pool.GetCurrentSqrtPrice().PowerInteger(2) - minSwapOutAmount := poolSpotPrice.Mul(osmomath.SmallestDec()).TruncateDec().SDKDec().TruncateInt() + minSwapOutAmount := poolSpotPrice.Mul(osmomath.SmallestBigDec()).TruncateDec().Dec().TruncateInt() poolBalances := s.App.BankKeeper.GetAllBalances(s.Ctx, pool.GetAddress()) if poolBalances.AmountOf(swapOutDenom).LTE(minSwapOutAmount) { return sdk.Coin{}, sdk.Coin{} @@ -357,7 +357,7 @@ func (s *KeeperTestSuite) executeRandomizedSwap(pool types.ConcentratedPoolExten } // Note that we set the price limit to zero to ensure that the swap can execute in either direction (gets automatically set to correct limit) - swappedIn, swappedOut, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddress, pool, swapOutCoin, swapInDenom, pool.GetSpreadFactor(s.Ctx), sdk.ZeroDec()) + swappedIn, swappedOut, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddress, pool, swapOutCoin, swapInDenom, pool.GetSpreadFactor(s.Ctx), osmomath.ZeroDec()) s.Require().NoError(err) return swappedIn, swappedOut @@ -409,15 +409,15 @@ func (s *KeeperTestSuite) trackEmittedIncentives(cumulativeTrackedIncentives sdk continue } - secondsEmitted := sdk.ZeroDec() + secondsEmitted := osmomath.ZeroDec() if recordStartTime.Before(lastTrackerUpdateTime) { // If the record started emitting prior to the last incentiveCreationTime (the last time we checkpointed), // then we assume it has been emitting for the whole period since then. - secondsEmitted = sdk.NewDec(int64(s.Ctx.BlockTime().Sub(lastTrackerUpdateTime))).QuoInt64(int64(time.Second)) + secondsEmitted = osmomath.NewDec(int64(s.Ctx.BlockTime().Sub(lastTrackerUpdateTime))).QuoInt64(int64(time.Second)) } else if recordStartTime.Before(s.Ctx.BlockTime()) { // If the record started emitting between the last incentiveCreationTime and now, then we only track the // emissions between when it started and now. - secondsEmitted = sdk.NewDec(int64(s.Ctx.BlockTime().Sub(recordStartTime))).QuoInt64(int64(time.Second)) + secondsEmitted = osmomath.NewDec(int64(s.Ctx.BlockTime().Sub(recordStartTime))).QuoInt64(int64(time.Second)) } emissionRate := incentiveRecord.IncentiveRecordBody.EmissionRate @@ -438,8 +438,8 @@ func (s *KeeperTestSuite) getInitialPositionAssets(pool types.ConcentratedPoolEx s.Require().NoError(err) // Calculate asset amounts that would be required to get the required spot price (rounding up on asset1 to ensure we stay in the intended tick) - asset0Amount := sdk.NewInt(100000000000000) - asset1Amount := sdk.NewDecFromInt(asset0Amount).Mul(requiredPrice.SDKDec()).Ceil().TruncateInt() + asset0Amount := osmomath.NewInt(100000000000000) + asset1Amount := osmomath.NewDecFromInt(asset0Amount).Mul(requiredPrice.Dec()).Ceil().TruncateInt() assetCoins := sdk.NewCoins( sdk.NewCoin(pool.GetToken0(), asset0Amount), @@ -457,7 +457,7 @@ func getRandomizedAssets(baseAssets sdk.Coins, fuzzAssets bool) sdk.Coins { for coinIndex, coin := range baseAssets { // Fuzz +/- 100% of current amount newAmount := fuzzInt64(coin.Amount.Int64(), 2) - fuzzedAssets[coinIndex] = sdk.NewCoin(coin.Denom, sdk.NewInt(newAmount)) + fuzzedAssets[coinIndex] = sdk.NewCoin(coin.Denom, osmomath.NewInt(newAmount)) } finalAssets = fuzzedAssets diff --git a/x/concentrated-liquidity/simulation/sim_msgs.go b/x/concentrated-liquidity/simulation/sim_msgs.go index 533c0c82ac5..df8f3ab63fa 100644 --- a/x/concentrated-liquidity/simulation/sim_msgs.go +++ b/x/concentrated-liquidity/simulation/sim_msgs.go @@ -8,6 +8,7 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/osmomath" appParams "github.com/osmosis-labs/osmosis/v19/app/params" osmosimtypes "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" sdkrand "github.com/osmosis-labs/osmosis/v19/simulation/simtypes/random" @@ -24,7 +25,7 @@ type preparePoolConfig struct { coin0 sdk.Coin coin1 sdk.Coin tickSpacing uint64 - spreadFactor sdk.Dec + spreadFactor osmomath.Dec } // preparePositionConfig defines the parameters for creating a new position @@ -62,7 +63,7 @@ func RandomMsgCreateConcentratedPool(k clkeeper.Keeper, sim *osmosimtypes.SimCtx } sim.BankKeeper().SetDenomMetaData(ctx, denomMetaData) - err = sim.BankKeeper().MintCoins(ctx, minttypes.ModuleName, sdk.NewCoins(sdk.NewCoin(appParams.BaseCoinUnit, sdk.NewInt(10000000)))) + err = sim.BankKeeper().MintCoins(ctx, minttypes.ModuleName, sdk.NewCoins(sdk.NewCoin(appParams.BaseCoinUnit, osmomath.NewInt(10000000)))) if err != nil { return nil, err } @@ -197,15 +198,15 @@ func RandMsgCollectSpreadRewards(k clkeeper.Keeper, sim *osmosimtypes.SimCtx, ct // we must use cacheCtx when calling a mutative method within a simulator method // otherwise, if this errors, it will partially commit and lead to unrealistic state cacheCtx, write := ctx.CacheContext() - for remainingSwapOwnerToken0Amt.GT(sdk.ZeroInt()) { + for remainingSwapOwnerToken0Amt.GT(osmomath.ZeroInt()) { randToken0Amt := sim.RandPositiveInt(remainingSwapOwnerToken0Amt) - if randToken0Amt.LTE(sdk.ZeroInt()) { + if randToken0Amt.LTE(osmomath.ZeroInt()) { return nil, fmt.Errorf("invalid amount to swap") } // perform swap from token0 to token1 until either token0 or token1 fund runs out - _, err = k.SwapExactAmountIn(cacheCtx, swapOwner.Address, poolI, sdk.NewCoin(swapOwnerTokens[0].Denom, randToken0Amt), swapOwnerTokens[1].Denom, sdk.OneInt(), sdk.NewDecWithPrec(1, 2)) + _, err = k.SwapExactAmountIn(cacheCtx, swapOwner.Address, poolI, sdk.NewCoin(swapOwnerTokens[0].Denom, randToken0Amt), swapOwnerTokens[1].Denom, osmomath.OneInt(), osmomath.NewDecWithPrec(1, 2)) if err != nil { return nil, err } @@ -316,11 +317,11 @@ func getRandomTickPositions(sim *osmosimtypes.SimCtx, minTick, maxTick int64, ti return lowerTick, upperTick, nil } -func RandomMinAmount(sim *osmosimtypes.SimCtx, token0Desired, token1Desired sdk.Int) (sdk.Int, sdk.Int) { +func RandomMinAmount(sim *osmosimtypes.SimCtx, token0Desired, token1Desired osmomath.Int) (osmomath.Int, osmomath.Int) { rand := sim.GetRand() - percent := sdk.NewDec(int64(sdkrand.RandIntBetween(rand, 0, 100) / 100)) - minAmount0 := sdk.NewDecFromInt(token0Desired).Mul(percent).TruncateInt() - minAmount1 := sdk.NewDecFromInt(token1Desired).Mul(percent).TruncateInt() + percent := osmomath.NewDec(int64(sdkrand.RandIntBetween(rand, 0, 100) / 100)) + minAmount0 := osmomath.NewDecFromInt(token0Desired).Mul(percent).TruncateInt() + minAmount1 := osmomath.NewDecFromInt(token1Desired).Mul(percent).TruncateInt() return minAmount0, minAmount1 } diff --git a/x/concentrated-liquidity/spread_rewards.go b/x/concentrated-liquidity/spread_rewards.go index d2fc0299acf..af5e84ac1df 100644 --- a/x/concentrated-liquidity/spread_rewards.go +++ b/x/concentrated-liquidity/spread_rewards.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/accum" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -43,7 +44,7 @@ func (k Keeper) GetSpreadRewardAccumulator(ctx sdk.Context, poolId uint64) (*acc // - fails to create a new position. // - fails to prepare the accumulator for update. // - fails to update the position's accumulator. -func (k Keeper) initOrUpdatePositionSpreadRewardAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidityDelta sdk.Dec) error { +func (k Keeper) initOrUpdatePositionSpreadRewardAccumulator(ctx sdk.Context, poolId uint64, lowerTick, upperTick int64, positionId uint64, liquidityDelta osmomath.Dec) error { // Get the spread reward accumulator for the position's pool. spreadRewardAccumulator, err := k.GetSpreadRewardAccumulator(ctx, poolId) if err != nil { diff --git a/x/concentrated-liquidity/spread_rewards_test.go b/x/concentrated-liquidity/spread_rewards_test.go index 1cff1d044e6..4f8c55184a1 100644 --- a/x/concentrated-liquidity/spread_rewards_test.go +++ b/x/concentrated-liquidity/spread_rewards_test.go @@ -27,11 +27,11 @@ type positionFields struct { lowerTick int64 upperTick int64 positionId uint64 - liquidity sdk.Dec + liquidity osmomath.Dec } var ( - oneEth = sdk.NewDecCoin(ETH, sdk.OneInt()) + oneEth = sdk.NewDecCoin(ETH, osmomath.OneInt()) oneEthCoins = sdk.NewDecCoins(oneEth) onlyUSDC = [][]string{{USDC}, {USDC}, {USDC}, {USDC}} onlyETH = [][]string{{ETH}, {ETH}, {ETH}, {ETH}} @@ -125,7 +125,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionSpreadRewardAccumulator() { return posFields } - withLiquidity := func(posFields positionFields, liquidity sdk.Dec) positionFields { + withLiquidity := func(posFields positionFields, liquidity osmomath.Dec) positionFields { posFields.liquidity = liquidity return posFields } @@ -137,7 +137,7 @@ func (s *KeeperTestSuite) TestInitOrUpdatePositionSpreadRewardAccumulator() { name string positionFields positionFields - expectedLiquidity sdk.Dec + expectedLiquidity osmomath.Dec expectedError error } tests := []initSpreadRewardAccumTest{ @@ -257,9 +257,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { expectedError bool } - defaultAccumCoins := sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))) + defaultAccumCoins := sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))) defaultPoolId := uint64(1) - defaultInitialLiquidity := sdk.OneDec() + defaultInitialLiquidity := osmomath.OneDec() defaultUpperTickIndex := int64(5) defaultLowerTickIndex := int64(3) @@ -278,9 +278,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: 2, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -289,9 +289,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 2, currentTick: 3, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -300,9 +300,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: 0, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -311,9 +311,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 1, upperTick: 2, currentTick: 0, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -322,9 +322,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: 1, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -338,9 +338,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: 0, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -349,9 +349,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: 1, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -360,9 +360,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: 0, upperTick: 1, currentTick: -1, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -371,9 +371,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: -1, upperTick: 1, currentTick: 0, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -382,9 +382,9 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { lowerTick: -1, upperTick: 1, currentTick: 2, - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, sdk.NewInt(10)), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoin(ETH, osmomath.NewInt(10)), expectedSpreadRewardGrowthOutside: defaultAccumCoins, expectedError: false, }, @@ -427,8 +427,8 @@ func (s *KeeperTestSuite) TestGetSpreadRewardGrowthOutside() { } func (s *KeeperTestSuite) TestCalculateSpreadRewardGrowth() { - defaultGeeFrowthGlobal := sdk.NewDecCoins(sdk.NewDecCoin("uosmo", sdk.NewInt(10))) - defaultGeeFrowthOutside := sdk.NewDecCoins(sdk.NewDecCoin("uosmo", sdk.NewInt(3))) + defaultGeeFrowthGlobal := sdk.NewDecCoins(sdk.NewDecCoin("uosmo", osmomath.NewInt(10))) + defaultGeeFrowthOutside := sdk.NewDecCoins(sdk.NewDecCoin("uosmo", osmomath.NewInt(3))) defaultSmallerTargetTick := int64(1) defaultCurrentTick := int64(2) @@ -504,8 +504,8 @@ func (s *KeeperTestSuite) TestGetInitialSpreadRewardGrowthOppositeDirectionOfLas } func (s *KeeperTestSuite) TestGetInitialSpreadRewardGrowthOppositeDirectionOfLastTraversalForTick() { - sqrtPrice := osmomath.MustMonotonicSqrt(DefaultAmt1.ToDec().Quo(DefaultAmt0.ToDec())) - initialPoolTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrtPrice), DefaultTickSpacing) + sqrtPrice := osmomath.MustMonotonicSqrt(DefaultAmt1.ToLegacyDec().Quo(DefaultAmt0.ToLegacyDec())) + initialPoolTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrtPrice), DefaultTickSpacing) s.Require().NoError(err) initialGlobalSpreadRewardGrowth := oneEth @@ -551,7 +551,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { tests := map[string]struct { // setup parameters. - initialLiquidity sdk.Dec + initialLiquidity osmomath.Dec lowerTickSpreadRewardGrowthOutside sdk.DecCoins upperTickSpreadRewardGrowthOutside sdk.DecCoins globalSpreadRewardGrowth sdk.DecCoins @@ -575,12 +575,12 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { // Since we track spread rewards accrued below a tick, upper tick is updated // while lower tick is zero. "single swap left -> right: 2 ticks, one share, current tick > upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -589,15 +589,15 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 2, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(10))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(10))), }, "single swap left -> right: 3 ticks, two shares, current tick > upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -606,15 +606,15 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 3, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(20))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(20))), }, "single swap left -> right: 3 ticks, two shares, current tick is in between lower and upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -623,15 +623,15 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 1, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(20))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(20))), }, "single swap left -> right: 2 ticks, one share, current tick == upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -640,7 +640,7 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 1, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(10))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(10))), }, // imagine single swap over entire position @@ -649,13 +649,13 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { // Since we track spread rewards accrued below a tick, both upper and lower position // ticks are zero "single swap right -> left: 2 ticks, one share, current tick == lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), // lower tick accumulator is not updated yet. - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -664,16 +664,16 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 0, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(10))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(10))), }, "single swap right -> left: 2 ticks, one share, current tick < lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), // lower tick accumulator updated when crossed. - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -682,15 +682,15 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: -1, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(10))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(10))), }, "single swap right -> left: 2 ticks, two shares, current tick is in between lower and upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -699,19 +699,19 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { currentTick: 1, - expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(20))), + expectedSpreadRewardsClaimed: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(20))), }, // imagine swap occurring outside of the position // As a result, lower and upper ticks are not updated. "swap occurs above the position, current tick > upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), // none are updated. lowerTickSpreadRewardGrowthOutside: cl.EmptyCoins, upperTickSpreadRewardGrowthOutside: cl.EmptyCoins, - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -723,13 +723,13 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { expectedSpreadRewardsClaimed: sdk.NewCoins(), }, "swap occurs below the position, current tick < lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), // none are updated. lowerTickSpreadRewardGrowthOutside: cl.EmptyCoins, upperTickSpreadRewardGrowthOutside: cl.EmptyCoins, - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: -10, @@ -744,12 +744,12 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { // error cases. "position does not exist": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: ownerWithValidPosition, lowerTick: 0, @@ -761,12 +761,12 @@ func (s *KeeperTestSuite) TestQueryAndCollectSpreadRewards() { expectedError: types.PositionIdNotFoundError{PositionId: 2}, }, "non owner attempts to collect": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), owner: s.TestAccs[1], // different owner from the one who initialized the position. lowerTick: 0, @@ -865,11 +865,11 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { tests := map[string]struct { // setup parameters. - initialLiquidity sdk.Dec + initialLiquidity osmomath.Dec lowerTickSpreadRewardGrowthOutside sdk.DecCoins upperTickSpreadRewardGrowthOutside sdk.DecCoins globalSpreadRewardGrowth sdk.DecCoins - expectedReinvestedDustAmount sdk.Dec + expectedReinvestedDustAmount osmomath.Dec currentTick int64 isInvalidPoolIdGiven bool @@ -883,12 +883,12 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { expectedError error }{ "single swap left -> right: 2 ticks, one share, current tick > upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -896,15 +896,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 2, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap left -> right: 3 ticks, two shares, current tick > upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 2, @@ -912,15 +912,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 3, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap left -> right: 3 ticks, two shares, current tick in between lower and upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 2, @@ -928,15 +928,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 1, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap left -> right: 2 ticks, one share, current tick == upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -944,16 +944,16 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 1, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap right -> left: 2 ticks, one share, current tick == lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), // lower tick accumulator is not updated yet. - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -961,15 +961,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 0, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap right -> left: 2 ticks, one share, current tick < lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -977,15 +977,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: -1, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "single swap right -> left: 2 ticks, two shares, current tick in between lower and upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 2, @@ -993,15 +993,15 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 1, - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), }, "dust reinvested: single swap right -> left: 2 ticks, two shares, current tick in between lower and upper tick": { - initialLiquidity: sdk.NewDec(2), + initialLiquidity: osmomath.NewDec(2), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoinFromDec(ETH, sdk.MustNewDecFromStr("3.3"))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoinFromDec(ETH, osmomath.MustNewDecFromStr("3.3"))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 2, @@ -1010,19 +1010,19 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { currentTick: 1, // expected = global - below lower - above upper = 10 - 3.3 = 6.7 - expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoinFromDec(ETH, sdk.MustNewDecFromStr("6.7"))), + expectedInitAccumValue: sdk.NewDecCoins(sdk.NewDecCoinFromDec(ETH, osmomath.MustNewDecFromStr("6.7"))), // expected reinvested dust = (6.7 * 2 % floor(6.7 * 2)) / 2 // This can be thought of as the diffence between the non-truncated total amount of spread rewards and the truncated toal amount of spread rewards // divided by the number of shares. - expectedReinvestedDustAmount: sdk.MustNewDecFromStr("0.2"), + expectedReinvestedDustAmount: osmomath.MustNewDecFromStr("0.2"), }, "swap occurs above the position, current tick > upper tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), lowerTickSpreadRewardGrowthOutside: cl.EmptyCoins, upperTickSpreadRewardGrowthOutside: cl.EmptyCoins, - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -1033,12 +1033,12 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { expectedInitAccumValue: sdk.DecCoins(nil), }, "swap occurs below the position, current tick < lower tick": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), lowerTickSpreadRewardGrowthOutside: cl.EmptyCoins, upperTickSpreadRewardGrowthOutside: cl.EmptyCoins, - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: -10, upperTick: -4, @@ -1051,12 +1051,12 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { // error cases. "position does not exist": { - initialLiquidity: sdk.OneDec(), + initialLiquidity: osmomath.OneDec(), - lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(0))), - upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + lowerTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(0))), + upperTickSpreadRewardGrowthOutside: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), - globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, sdk.NewInt(10))), + globalSpreadRewardGrowth: sdk.NewDecCoins(sdk.NewDecCoin(ETH, osmomath.NewInt(10))), lowerTick: 0, upperTick: 1, @@ -1124,7 +1124,7 @@ func (s *KeeperTestSuite) TestPrepareClaimableSpreadRewards() { s.Require().Equal(expectedSpreadRewardClaimAmount, actualSpreadRewardsClaimed.AmountOf(ETH)) // validate that truncated dust amount is reinvested back into the global accumulator - if expectedClaimedAmountDec.GT(expectedSpreadRewardClaimAmount.ToDec()) { + if expectedClaimedAmountDec.GT(expectedSpreadRewardClaimAmount.ToLegacyDec()) { accumDelta, _ := accum.GetValue().SafeSub(originalAccumValue) s.Require().Equal(tc.expectedReinvestedDustAmount, accumDelta.AmountOf(ETH)) } @@ -1284,7 +1284,7 @@ func (s *KeeperTestSuite) TestUpdatePosValueToInitValuePlusGrowthOutside() { positionKey := validPositionKey // Initialize position accumulator. - err = poolSpreadRewardAccumulator.NewPosition(positionKey, sdk.OneDec(), nil) + err = poolSpreadRewardAccumulator.NewPosition(positionKey, osmomath.OneDec(), nil) s.Require().NoError(err) // Record the initial position accumulator value. @@ -1342,7 +1342,7 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_Swaps() { s.TestAccs = apptesting.CreateRandomAccounts(positions.numAccounts) // Create a default CL pool, but with a 0.3 percent spread factor. - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, sdk.MustNewDecFromStr("0.002")) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, osmomath.MustNewDecFromStr("0.002")) positionIds := make([][]uint64, 4) // Setup full range position across all four accounts @@ -1408,23 +1408,23 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_LP() { ) // Create pool with 0.2% spread factor. - pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, sdk.MustNewDecFromStr("0.002")) + pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, osmomath.MustNewDecFromStr("0.002")) fundCoins := sdk.NewCoins(sdk.NewCoin(ETH, DefaultAmt0.MulRaw(2)), sdk.NewCoin(USDC, DefaultAmt1.MulRaw(2))) s.FundAcc(owner, fundCoins) // Errors since no position. - _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn(s.Ctx, owner, pool, sdk.NewCoin(ETH, sdk.OneInt()), USDC, pool.GetSpreadFactor(s.Ctx), types.MaxSpotPrice) + _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn(s.Ctx, owner, pool, sdk.NewCoin(ETH, osmomath.OneInt()), USDC, pool.GetSpreadFactor(s.Ctx), types.MaxSpotPrice) s.Require().Error(err) // Create position in the default range 1. - positionDataOne, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionDataOne, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) // Swap once. ticksActivatedAfterEachSwap, totalSpreadRewardsExpected, _, _ := s.swapAndTrackXTimesInARow(pool.GetId(), DefaultCoin1, ETH, types.MaxSpotPrice, 1) // Withdraw half. - halfLiquidity := positionDataOne.Liquidity.Mul(sdk.NewDecWithPrec(5, 1)) + halfLiquidity := positionDataOne.Liquidity.Mul(osmomath.NewDecWithPrec(5, 1)) _, _, err = concentratedLiquidityKeeper.WithdrawPosition(ctx, owner, positionDataOne.ID, halfLiquidity) s.Require().NoError(err) @@ -1433,7 +1433,7 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_LP() { expectedSpreadRewardsTruncated := totalSpreadRewardsExpected for i, spreadRewardToken := range totalSpreadRewardsExpected { // We run expected spread rewards through a cycle of divison and multiplication by liquidity to capture appropriate rounding behavior - expectedSpreadRewardsTruncated[i] = sdk.NewCoin(spreadRewardToken.Denom, spreadRewardToken.Amount.ToDec().QuoTruncate(positionDataOne.Liquidity).MulTruncate(positionDataOne.Liquidity).TruncateInt()) + expectedSpreadRewardsTruncated[i] = sdk.NewCoin(spreadRewardToken.Denom, spreadRewardToken.Amount.ToLegacyDec().QuoTruncate(positionDataOne.Liquidity).MulTruncate(positionDataOne.Liquidity).TruncateInt()) } s.Require().Equal(expectedSpreadRewardsTruncated, spreadRewardsCollected) @@ -1441,7 +1441,7 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_LP() { s.validatePositionSpreadRewardGrowth(pool.GetId(), positionDataOne.ID, cl.EmptyCoins) // Create position in the default range 2. - positionDataTwo, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionDataTwo, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) fullLiquidity := positionDataTwo.Liquidity @@ -1456,7 +1456,7 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_LP() { // Validate that the correct amount of ETH was collected in withdraw for position two. // total spread rewards * full liquidity / (full liquidity + half liquidity) - expectedPositionToWithdraw := totalSpreadRewardsExpected.AmountOf(ETH).ToDec().Mul(fullLiquidity.Quo(fullLiquidity.Add(halfLiquidity))).TruncateInt() + expectedPositionToWithdraw := totalSpreadRewardsExpected.AmountOf(ETH).ToLegacyDec().Mul(fullLiquidity.Quo(fullLiquidity.Add(halfLiquidity))).TruncateInt() s.Require().Equal(expectedPositionToWithdraw.String(), balanceAfterWithdraw.Sub(balanceBeforeWithdraw).Amount.Sub(amtDenom0).String()) // Validate cannot claim for withdrawn position. @@ -1466,11 +1466,11 @@ func (s *KeeperTestSuite) TestFunctional_SpreadRewards_LP() { spreadRewardsCollected = s.collectSpreadRewardsAndCheckInvariance(ctx, 0, DefaultMinTick, DefaultMaxTick, positionDataOne.ID, sdk.NewCoins(), []string{ETH}, [][]int64{ticksActivatedAfterEachSwap}) // total spread rewards * half liquidity / (full liquidity + half liquidity) - expectesSpreadRewardsCollected := totalSpreadRewardsExpected.AmountOf(ETH).ToDec().Mul(halfLiquidity.Quo(fullLiquidity.Add(halfLiquidity))).TruncateInt() + expectesSpreadRewardsCollected := totalSpreadRewardsExpected.AmountOf(ETH).ToLegacyDec().Mul(halfLiquidity.Quo(fullLiquidity.Add(halfLiquidity))).TruncateInt() s.Require().Equal(expectesSpreadRewardsCollected.String(), spreadRewardsCollected.AmountOf(ETH).String()) // Create position in the default range 3. - positionDataThree, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + positionDataThree, err := concentratedLiquidityKeeper.CreatePosition(ctx, pool.GetId(), owner, DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) collectedThree, err := s.App.ConcentratedLiquidityKeeper.CollectSpreadRewards(ctx, owner, positionDataThree.ID) @@ -1505,7 +1505,7 @@ func (s *KeeperTestSuite) CollectAndAssertSpreadRewards(ctx sdk.Context, poolId // Define error tolerance var errTolerance osmomath.ErrTolerance - errTolerance.AdditiveTolerance = sdk.NewDec(10) + errTolerance.AdditiveTolerance = osmomath.NewDec(10) errTolerance.RoundingDir = osmomath.RoundDown // Check that the total spread rewards collected is equal to the total spread rewards (within a tolerance) @@ -1531,7 +1531,7 @@ func (s *KeeperTestSuite) tickStatusInvariance(ticksActivatedAfterEachSwap [][]i if positionWasActive { // If the position was active, check that the spread rewards collected are non-zero if expectedSpreadRewardDenoms[i] != NoUSDCExpected && expectedSpreadRewardDenoms[i] != NoETHExpected { - s.Require().True(coins.AmountOf(expectedSpreadRewardDenoms[i]).GT(sdk.ZeroInt()), "denom: %s", expectedSpreadRewardDenoms[i]) + s.Require().True(coins.AmountOf(expectedSpreadRewardDenoms[i]).GT(osmomath.ZeroInt()), "denom: %s", expectedSpreadRewardDenoms[i]) } } else { // If the position was not active, check that the spread rewards collected are zero @@ -1542,25 +1542,25 @@ func (s *KeeperTestSuite) tickStatusInvariance(ticksActivatedAfterEachSwap [][]i // swapAndTrackXTimesInARow performs `numSwaps` swaps and tracks the tick activated after each swap. // It also returns the total spread rewards collected, the total token in, and the total token out. -func (s *KeeperTestSuite) swapAndTrackXTimesInARow(poolId uint64, coinIn sdk.Coin, coinOutDenom string, priceLimit sdk.Dec, numSwaps int) (ticksActivatedAfterEachSwap []int64, totalSpreadRewards sdk.Coins, totalTokenIn sdk.Coin, totalTokenOut sdk.Coin) { +func (s *KeeperTestSuite) swapAndTrackXTimesInARow(poolId uint64, coinIn sdk.Coin, coinOutDenom string, priceLimit osmomath.Dec, numSwaps int) (ticksActivatedAfterEachSwap []int64, totalSpreadRewards sdk.Coins, totalTokenIn sdk.Coin, totalTokenOut sdk.Coin) { // Retrieve pool clPool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) // Determine amount needed to fulfill swap numSwaps times and fund account that much - amountNeededForSwap := coinIn.Amount.Mul(sdk.NewInt(int64(numSwaps))) + amountNeededForSwap := coinIn.Amount.Mul(osmomath.NewInt(int64(numSwaps))) swapCoin := sdk.NewCoin(coinIn.Denom, amountNeededForSwap) s.FundAcc(s.TestAccs[4], sdk.NewCoins(swapCoin)) ticksActivatedAfterEachSwap = append(ticksActivatedAfterEachSwap, clPool.GetCurrentTick()) - totalSpreadRewards = sdk.NewCoins(sdk.NewCoin(USDC, sdk.ZeroInt()), sdk.NewCoin(ETH, sdk.ZeroInt())) + totalSpreadRewards = sdk.NewCoins(sdk.NewCoin(USDC, osmomath.ZeroInt()), sdk.NewCoin(ETH, osmomath.ZeroInt())) // Swap numSwaps times, recording the tick activated after and swap and spread rewards we expect to collect based on the amount in - totalTokenIn = sdk.NewCoin(coinIn.Denom, sdk.ZeroInt()) - totalTokenOut = sdk.NewCoin(coinOutDenom, sdk.ZeroInt()) + totalTokenIn = sdk.NewCoin(coinIn.Denom, osmomath.ZeroInt()) + totalTokenOut = sdk.NewCoin(coinOutDenom, osmomath.ZeroInt()) for i := 0; i < numSwaps; i++ { coinIn, coinOut, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn(s.Ctx, s.TestAccs[4], clPool, coinIn, coinOutDenom, clPool.GetSpreadFactor(s.Ctx), priceLimit) s.Require().NoError(err) - spreadReward := coinIn.Amount.ToDec().Mul(clPool.GetSpreadFactor(s.Ctx)) + spreadReward := coinIn.Amount.ToLegacyDec().Mul(clPool.GetSpreadFactor(s.Ctx)) totalSpreadRewards = totalSpreadRewards.Add(sdk.NewCoin(coinIn.Denom, spreadReward.TruncateInt())) clPool, err = s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, clPool.GetId()) s.Require().NoError(err) diff --git a/x/concentrated-liquidity/swaps.go b/x/concentrated-liquidity/swaps.go index 1cfe4c9c92e..77edbb16651 100644 --- a/x/concentrated-liquidity/swaps.go +++ b/x/concentrated-liquidity/swaps.go @@ -27,14 +27,14 @@ type SwapState struct { // if in given out, amount of token being swapped out. // Initialized to the amount of the token specified by the user. // Updated after every swap step. - amountSpecifiedRemaining sdk.Dec + amountSpecifiedRemaining osmomath.Dec // Amount of the other token that is calculated from the specified token. // if out given in, amount of token swapped out. // if in given out, amount of token swapped in. // Initialized to zero. // Updated after every swap step. - amountCalculated sdk.Dec + amountCalculated osmomath.Dec // Current sqrt price while calculating swap. // Initialized to the pool's current sqrt price. @@ -49,14 +49,14 @@ type SwapState struct { // Current liqudiity within the active tick. // Initialized to the pool's current tick's liquidity. // Updated each time a tick is crossed. - liquidity sdk.Dec + liquidity osmomath.Dec // Global spread reward growth per-current swap. // Initialized to zero. // Updated after every swap step. - globalSpreadRewardGrowthPerUnitLiquidity sdk.Dec + globalSpreadRewardGrowthPerUnitLiquidity osmomath.Dec // global spread reward growth - globalSpreadRewardGrowth sdk.Dec + globalSpreadRewardGrowth osmomath.Dec swapStrategy swapstrategy.SwapStrategy } @@ -64,9 +64,9 @@ type SwapState struct { // SwapResult represents the result from computing // the swap state. type SwapResult struct { - AmountIn sdk.Int - AmountOut sdk.Int - SpreadRewards sdk.Dec + AmountIn osmomath.Int + AmountOut osmomath.Int + SpreadRewards osmomath.Dec } // swapNoProgressLimit is the maximum number of iterations that can be performed @@ -77,15 +77,15 @@ type SwapResult struct { // progress. However, we leave a buffer of 1_000 to account for any unforeseen edge cases. const swapNoProgressLimit = 100 -func newSwapState(specifiedAmount sdk.Int, p types.ConcentratedPoolExtension, strategy swapstrategy.SwapStrategy) SwapState { +func newSwapState(specifiedAmount osmomath.Int, p types.ConcentratedPoolExtension, strategy swapstrategy.SwapStrategy) SwapState { return SwapState{ - amountSpecifiedRemaining: specifiedAmount.ToDec(), - amountCalculated: sdk.ZeroDec(), + amountSpecifiedRemaining: specifiedAmount.ToLegacyDec(), + amountCalculated: osmomath.ZeroDec(), sqrtPrice: p.GetCurrentSqrtPrice(), tick: p.GetCurrentTick(), liquidity: p.GetLiquidity(), - globalSpreadRewardGrowthPerUnitLiquidity: sdk.ZeroDec(), - globalSpreadRewardGrowth: sdk.ZeroDec(), + globalSpreadRewardGrowthPerUnitLiquidity: osmomath.ZeroDec(), + globalSpreadRewardGrowth: osmomath.ZeroDec(), swapStrategy: strategy, } } @@ -98,12 +98,12 @@ type SwapDetails struct { type PoolUpdates struct { NewCurrentTick int64 - NewLiquidity sdk.Dec + NewLiquidity osmomath.Dec NewSqrtPrice osmomath.BigDec } var ( - smallestDec = sdk.SmallestDec() + smallestDec = osmomath.SmallestDec() ) // updateSpreadRewardGrowthGlobal updates the swap state's spread reward growth global per unit of liquidity @@ -113,7 +113,7 @@ var ( // between the ticks. This is possible when there are only 2 positions with no overlapping ranges. // As a result, the range from the end of position one to the beginning of position // two has no liquidity and can be skipped. -func (ss *SwapState) updateSpreadRewardGrowthGlobal(spreadRewardChargeTotal sdk.Dec) { +func (ss *SwapState) updateSpreadRewardGrowthGlobal(spreadRewardChargeTotal osmomath.Dec) { ss.globalSpreadRewardGrowth = ss.globalSpreadRewardGrowth.Add(spreadRewardChargeTotal) if ss.liquidity.IsZero() { return @@ -130,17 +130,17 @@ func (k Keeper) SwapExactAmountIn( poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - spreadFactor sdk.Dec, -) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int, + spreadFactor osmomath.Dec, +) (tokenOutAmount osmomath.Int, err error) { if tokenIn.Denom == tokenOutDenom { - return sdk.Int{}, types.DenomDuplicatedError{TokenInDenom: tokenIn.Denom, TokenOutDenom: tokenOutDenom} + return osmomath.Int{}, types.DenomDuplicatedError{TokenInDenom: tokenIn.Denom, TokenOutDenom: tokenOutDenom} } // Convert pool interface to CL pool type pool, err := asConcentrated(poolI) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Determine if we are swapping asset0 for asset1 or vice versa @@ -150,13 +150,13 @@ func (k Keeper) SwapExactAmountIn( priceLimit := swapstrategy.GetPriceLimit(zeroForOne) tokenIn, tokenOut, _, err := k.swapOutAmtGivenIn(ctx, sender, pool, tokenIn, tokenOutDenom, spreadFactor, priceLimit) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmount = tokenOut.Amount // price impact protection. if tokenOutAmount.LT(tokenOutMinAmount) { - return sdk.Int{}, types.AmountLessThanMinError{TokenAmount: tokenOutAmount, TokenMin: tokenOutMinAmount} + return osmomath.Int{}, types.AmountLessThanMinError{TokenAmount: tokenOutAmount, TokenMin: tokenOutMinAmount} } k.RecordTotalLiquidityIncrease(ctx, sdk.NewCoins(tokenIn)) @@ -172,17 +172,17 @@ func (k Keeper) SwapExactAmountOut( sender sdk.AccAddress, poolI poolmanagertypes.PoolI, tokenInDenom string, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, - spreadFactor sdk.Dec, -) (tokenInAmount sdk.Int, err error) { + spreadFactor osmomath.Dec, +) (tokenInAmount osmomath.Int, err error) { if tokenOut.Denom == tokenInDenom { - return sdk.Int{}, types.DenomDuplicatedError{TokenInDenom: tokenInDenom, TokenOutDenom: tokenOut.Denom} + return osmomath.Int{}, types.DenomDuplicatedError{TokenInDenom: tokenInDenom, TokenOutDenom: tokenOut.Denom} } pool, err := asConcentrated(poolI) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } zeroForOne := getZeroForOne(tokenInDenom, pool.GetToken0()) @@ -192,13 +192,13 @@ func (k Keeper) SwapExactAmountOut( priceLimit := swapstrategy.GetPriceLimit(zeroForOne) tokenIn, tokenOut, _, err := k.swapInAmtGivenOut(ctx, sender, pool, tokenOut, tokenInDenom, spreadFactor, priceLimit) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenInAmount = tokenIn.Amount // price impact protection. if tokenInAmount.GT(tokenInMaxAmount) { - return sdk.Int{}, types.AmountGreaterThanMaxError{TokenAmount: tokenInAmount, TokenMax: tokenInMaxAmount} + return osmomath.Int{}, types.AmountGreaterThanMaxError{TokenAmount: tokenInAmount, TokenMax: tokenInMaxAmount} } k.RecordTotalLiquidityIncrease(ctx, sdk.NewCoins(tokenIn)) @@ -215,8 +215,8 @@ func (k Keeper) swapOutAmtGivenIn( pool types.ConcentratedPoolExtension, tokenIn sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, ) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { swapResult, poolUpdates, err := k.computeOutAmtGivenIn(ctx, pool.GetId(), tokenIn, tokenOutDenom, spreadFactor, priceLimit) if err != nil { @@ -246,8 +246,8 @@ func (k *Keeper) swapInAmtGivenOut( pool types.ConcentratedPoolExtension, desiredTokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, ) (calcTokenIn, calcTokenOut sdk.Coin, poolUpdates PoolUpdates, err error) { swapResult, poolUpdates, err := k.computeInAmtGivenOut(ctx, desiredTokenOut, tokenInDenom, spreadFactor, priceLimit, pool.GetId()) if err != nil { @@ -275,10 +275,10 @@ func (k Keeper) CalcOutAmtGivenIn( poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (tokenOut sdk.Coin, err error) { cacheCtx, _ := ctx.CacheContext() - swapResult, _, err := k.computeOutAmtGivenIn(cacheCtx, poolI.GetId(), tokenIn, tokenOutDenom, spreadFactor, sdk.ZeroDec()) + swapResult, _, err := k.computeOutAmtGivenIn(cacheCtx, poolI.GetId(), tokenIn, tokenOutDenom, spreadFactor, osmomath.ZeroDec()) if err != nil { return sdk.Coin{}, err } @@ -290,10 +290,10 @@ func (k Keeper) CalcInAmtGivenOut( poolI poolmanagertypes.PoolI, tokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (sdk.Coin, error) { cacheCtx, _ := ctx.CacheContext() - swapResult, _, err := k.computeInAmtGivenOut(cacheCtx, tokenOut, tokenInDenom, spreadFactor, sdk.ZeroDec(), poolI.GetId()) + swapResult, _, err := k.computeInAmtGivenOut(cacheCtx, tokenOut, tokenInDenom, spreadFactor, osmomath.ZeroDec(), poolI.GetId()) if err != nil { return sdk.Coin{}, err } @@ -353,8 +353,8 @@ func (k Keeper) computeOutAmtGivenIn( poolId uint64, tokenInMin sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, ) (swapResult SwapResult, poolUpdates PoolUpdates, err error) { p, spreadRewardAccumulator, uptimeAccums, err := k.swapSetup(ctx, poolId, tokenInMin.Denom, tokenOutDenom) if err != nil { @@ -458,7 +458,7 @@ func (k Keeper) computeOutAmtGivenIn( // Coin amounts require int values // Round amountIn up to avoid under charging - amountIn := (tokenInMin.Amount.ToDec().Sub(swapState.amountSpecifiedRemaining)).Ceil().TruncateInt() + amountIn := (tokenInMin.Amount.ToLegacyDec().Sub(swapState.amountSpecifiedRemaining)).Ceil().TruncateInt() // Round amountOut down to avoid over distributing. amountOut := swapState.amountCalculated.TruncateInt() @@ -480,8 +480,8 @@ func (k Keeper) computeInAmtGivenOut( ctx sdk.Context, desiredTokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, - priceLimit sdk.Dec, + spreadFactor osmomath.Dec, + priceLimit osmomath.Dec, poolId uint64, ) (swapResult SwapResult, poolUpdates PoolUpdates, err error) { p, spreadRewardAccumulator, uptimeAccums, err := k.swapSetup(ctx, poolId, tokenInDenom, desiredTokenOut.Denom) @@ -582,7 +582,7 @@ func (k Keeper) computeInAmtGivenOut( amountIn := swapState.amountCalculated.Ceil().TruncateInt() // Round amount out down to avoid over charging the pool. - amountOut := desiredTokenOut.Amount.ToDec().Sub(swapState.amountSpecifiedRemaining).TruncateInt() + amountOut := desiredTokenOut.Amount.ToLegacyDec().Sub(swapState.amountSpecifiedRemaining).TruncateInt() ctx.Logger().Debug("final amount in", amountIn) ctx.Logger().Debug("final amount out", amountOut) @@ -594,7 +594,7 @@ func (k Keeper) computeInAmtGivenOut( }, PoolUpdates{swapState.tick, swapState.liquidity, swapState.sqrtPrice}, nil } -func emitSwapDebugLogs(ctx sdk.Context, swapState SwapState, reachedPrice osmomath.BigDec, amountIn, amountOut, spreadCharge sdk.Dec) { +func emitSwapDebugLogs(ctx sdk.Context, swapState SwapState, reachedPrice osmomath.BigDec, amountIn, amountOut, spreadCharge osmomath.Dec) { ctx.Logger().Debug("start sqrt price", swapState.sqrtPrice) ctx.Logger().Debug("reached sqrt price", reachedPrice) ctx.Logger().Debug("liquidity", swapState.liquidity) @@ -654,7 +654,7 @@ func (k Keeper) updatePoolForSwap( pool types.ConcentratedPoolExtension, swapDetails SwapDetails, poolUpdates PoolUpdates, - totalSpreadFactors sdk.Dec, + totalSpreadFactors osmomath.Dec, ) error { // Fixed gas consumption per swap to prevent spam poolId := pool.GetId() @@ -734,7 +734,7 @@ func checkDenomValidity(inDenom, outDenom, asset0, asset1 string) error { return nil } -func (k Keeper) setupSwapStrategy(p types.ConcentratedPoolExtension, spreadFactor sdk.Dec, tokenInDenom string, priceLimit sdk.Dec) (strategy swapstrategy.SwapStrategy, sqrtPriceLimit osmomath.BigDec, err error) { +func (k Keeper) setupSwapStrategy(p types.ConcentratedPoolExtension, spreadFactor osmomath.Dec, tokenInDenom string, priceLimit osmomath.Dec) (strategy swapstrategy.SwapStrategy, sqrtPriceLimit osmomath.BigDec, err error) { zeroForOne := getZeroForOne(tokenInDenom, p.GetToken0()) // take provided price limit and turn this into a sqrt price limit since formulas use sqrtPrice @@ -794,7 +794,7 @@ func (k Keeper) getSwapAccumulators(ctx sdk.Context, poolId uint64) (*accum.Accu // is swapping one for zero (right) directly to the tick. Then, immediately swapping zero for one (left). // After the first swap, our sqrtPriceCurrent is the crossed tick's sqrt price. Also sqrtPriceTarget is the crossed tick's sqrt price. // In such a case, no amounts are consumed and the swap step is allowed to succeed. -func validateSwapProgressAndAmountConsumption(computedSqrtPrice, sqrtPriceStart osmomath.BigDec, amountIn, amountOut sdk.Dec) error { +func validateSwapProgressAndAmountConsumption(computedSqrtPrice, sqrtPriceStart osmomath.BigDec, amountIn, amountOut osmomath.Dec) error { if computedSqrtPrice.Equal(sqrtPriceStart) && !(amountIn.IsZero() && amountOut.IsZero()) { return types.SwapNoProgressWithConsumptionError{ComputedSqrtPrice: computedSqrtPrice, AmountIn: amountIn, AmountOut: amountOut} } @@ -838,7 +838,7 @@ func (k Keeper) ComputeMaxInAmtGivenMaxTicksCrossed( } // Setup the swap strategy - swapStrategy, _, err := k.setupSwapStrategy(p, p.GetSpreadFactor(cacheCtx), tokenInDenom, sdk.ZeroDec()) + swapStrategy, _, err := k.setupSwapStrategy(p, p.GetSpreadFactor(cacheCtx), tokenInDenom, osmomath.ZeroDec()) if err != nil { return sdk.Coin{}, sdk.Coin{}, err } @@ -852,7 +852,7 @@ func (k Keeper) ComputeMaxInAmtGivenMaxTicksCrossed( nextInitTickIter := swapStrategy.InitializeNextTickIterator(cacheCtx, poolId, swapState.tick) defer nextInitTickIter.Close() - totalTokenOut := sdk.ZeroDec() + totalTokenOut := osmomath.ZeroDec() for i := uint64(0); i < maxTicksCrossed; i++ { // Check if the iterator is valid diff --git a/x/concentrated-liquidity/swaps_test.go b/x/concentrated-liquidity/swaps_test.go index 98b527924c6..b27d047ec9d 100644 --- a/x/concentrated-liquidity/swaps_test.go +++ b/x/concentrated-liquidity/swaps_test.go @@ -32,10 +32,10 @@ type SwapTest struct { tokenInDenom string // Shared. - priceLimit sdk.Dec - spreadFactor sdk.Dec - secondPositionLowerPrice sdk.Dec - secondPositionUpperPrice sdk.Dec + priceLimit osmomath.Dec + spreadFactor osmomath.Dec + secondPositionLowerPrice osmomath.Dec + secondPositionUpperPrice osmomath.Dec expectedTokenIn sdk.Coin expectedTokenOut sdk.Coin @@ -43,15 +43,15 @@ type SwapTest struct { expectedSqrtPrice osmomath.BigDec expectedLowerTickSpreadRewardGrowth sdk.DecCoins expectedUpperTickSpreadRewardGrowth sdk.DecCoins - expectedSpreadRewardGrowthAccumulatorValue sdk.Dec + expectedSpreadRewardGrowthAccumulatorValue osmomath.Dec // since we use different values for the seondary position's tick, save (tick, expectedSpreadRewardGrowth) tuple expectedSecondLowerTickSpreadRewardGrowth secondPosition expectedSecondUpperTickSpreadRewardGrowth secondPosition - newLowerPrice sdk.Dec - newUpperPrice sdk.Dec - poolLiqAmount0 sdk.Int - poolLiqAmount1 sdk.Int + newLowerPrice osmomath.Dec + newUpperPrice osmomath.Dec + poolLiqAmount0 osmomath.Int + poolLiqAmount1 osmomath.Int expectErr bool } @@ -61,20 +61,20 @@ type positionMeta struct { positionId uint64 lowerTick int64 upperTick int64 - liquidity sdk.Dec + liquidity osmomath.Dec } var ( - swapFundCoins = sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(10000000000000)), sdk.NewCoin("usdc", sdk.NewInt(1000000000000))) + swapFundCoins = sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(10000000000000)), sdk.NewCoin("usdc", osmomath.NewInt(1000000000000))) // Allow 0.01% margin of error. multiplicativeTolerance = osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.MustNewDecFromStr("0.0001"), + MultiplicativeTolerance: osmomath.MustNewDecFromStr("0.0001"), } // Allow additive margin equal of 1. It may stem from round up token in and rounding down // tokenOut in favor of the pool. oneAdditiveTolerance = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.OneDec(), + AdditiveTolerance: osmomath.OneDec(), } swapOutGivenInCases = map[string]SwapTest{ // One price range @@ -82,10 +82,10 @@ var ( // 5000 // 4545 -----|----- 5500 "single position within one tick: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(5004), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(5004), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * @@ -115,18 +115,18 @@ var ( // print(sqrt_next) // print(token_in) // print(token_out) - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(8396)), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(8396)), expectedTick: 31003913, // Corresponds to sqrt_next in script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.738348247484497718514800000003600626"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.738348247484497718514800000003600626"), // tick's accum coins stay same since crossing tick does not occur in this case }, "single position within one tick: usdc -> eth, with zero price limit": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), tokenOutDenom: "eth", - priceLimit: sdk.ZeroDec(), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * @@ -156,18 +156,18 @@ var ( // print(sqrt_next) // print(token_in) // print(token_out) - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(8396)), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(8396)), expectedTick: 31003913, // Corresponds to sqrt_next in script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.738348247484497718514800000003600626"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.738348247484497718514800000003600626"), // tick's accum coins stay same since crossing tick does not occur in this case }, "single position within one tick: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4993), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4993), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * @@ -195,16 +195,16 @@ var ( // print(sqrt_next) // print(token_out) // print(token_in) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(66808388)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(66808388)), expectedTick: 30993777, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.666663910857144332134093938182290274"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.666663910857144332134093938182290274"), }, "single position within one tick: eth -> usdc, with zero price limit": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.ZeroDec(), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * @@ -226,12 +226,12 @@ var ( // print(sqrt_next) // print(expectedTokenIn) // print(expectedTokenOut) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(66808388)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(66808388)), expectedTick: 30993777, // True value with arbitrary precision: 70.6666639108571443321... // Expected value due to our monotonic sqrt's >= true value guarantee: 70.666663910857144333 - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.666663910857144332134093938182290274"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.666663910857144332134093938182290274"), }, // Two equal price ranges // @@ -239,10 +239,10 @@ var ( // 4545 -----|----- 5500 // 4545 -----|----- 5500 "two positions within one tick: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(5002), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(5002), + spreadFactor: osmomath.ZeroDec(), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, // from math import * @@ -265,20 +265,20 @@ var ( // print(sqrt_next) // print(token_in) // print(token_out) - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(8398)), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(8398)), expectedTick: 31001956, // Corresponds to sqrt_next in script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.724513183069625079757400000001800313"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.724513183069625079757400000001800313"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), }, "two positions within one tick: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4996), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4996), + spreadFactor: osmomath.ZeroDec(), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, // from math import * @@ -302,15 +302,15 @@ var ( // print(sqrt_next) // print(expectedTokenIn) // print(expectedTokenOut) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(66829187)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(66829187)), expectedTick: 30996887, // True value with arbitrary precision: 70.6886641634088363202... // Expected value due to our monotonic sqrt's >= true value guarantee: 70.688664163408836321 - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.688664163408836320215015370847179540"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.688664163408836320215015370847179540"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), }, // Consecutive price ranges @@ -319,12 +319,12 @@ var ( // 5500 ----------- 6250 "two positions with consecutive price ranges: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6255), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5500), - secondPositionUpperPrice: sdk.NewDec(6250), + priceLimit: osmomath.NewDec(6255), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5500), + secondPositionUpperPrice: osmomath.NewDec(6250), // from math import * // from decimal import * // # Range 1: From 5000 to 5500 @@ -356,16 +356,16 @@ var ( // print(sqrt_next_2) // print(token_in) // print(token_out) - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1820630)), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1820630)), expectedTick: 32105414, // Equivalent to sqrt_next_2 in the script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.137149196095607130096044752300452857"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.137149196095607130096044752300452857"), // second positions both have greater tick than the current tick, thus never initialized expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 315000, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5500), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5500), + newUpperPrice: osmomath.NewDec(6250), }, // Consecutive price ranges // @@ -374,14 +374,14 @@ var ( // 4000 ----------- 4545 // "two positions with consecutive price ranges: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(3900), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4545), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(9103422788)), + priceLimit: osmomath.NewDec(3900), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4545), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9103422788)), // crosses one tick with spread reward growth outside expectedTick: 30095166, // from math import * @@ -413,16 +413,16 @@ var ( // print(sqrt_next_2) // print(token_out) - expectedSqrtPrice: osmomath.MustNewDecFromStr("63.993489023323078692803734142129673908"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("63.993489023323078692803734142129673908"), // crossing tick happens single time for each upper tick and lower tick. // Thus the tick's spread reward growth is DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), // second positions both have greater tick than the current tick, thus never initialized expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 305450, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4545), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4545), }, // Partially overlapping price ranges @@ -431,14 +431,14 @@ var ( // 5001 ----------- 6250 // "two positions with partially overlapping price ranges: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1864161)), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1864161)), expectedTick: 32055919, // from math import * // from decimal import * @@ -476,19 +476,19 @@ var ( // print(sqrt_next_3) // print(token_out) - expectedSqrtPrice: osmomath.MustNewDecFromStr("77.819789636800169393792766394158739007"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("77.819789636800169393792766394158739007"), expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 310010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), }, "two positions with partially overlapping price ranges, not utilizing full liquidity of second position: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(8500000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(8500000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * // getcontext().prec = 60 @@ -530,19 +530,19 @@ var ( // print(sqrt_next_3) // print(token_in) // print(token_out) - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(8500000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1609138)), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(8500000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1609138)), expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 310010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedTick: 31712695, // Corresponds to sqrt_next_3 in the script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("75.582373164412551492069079174313215667"), - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("75.582373164412551492069079174313215667"), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), }, // Partially overlapping price ranges // @@ -551,10 +551,10 @@ var ( // 4000 ----------- 4999 // "two positions with partially overlapping price ranges: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * // getcontext().prec = 60 @@ -595,34 +595,34 @@ var ( // print(sqrt_next_2) // print(token_in) // print(token_out) - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(9321276930)), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9321276930)), expectedTick: 30129083, // Corresponds to sqrt_next_2 in the script above - expectedSqrtPrice: osmomath.MustNewDecFromStr("64.257943794993248953756640624575523292"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("64.257943794993248953756640624575523292"), // Started from DefaultSpreadRewardAccumCoins * 3, crossed tick once, thus becoming // DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins = DefaultSpreadRewardAccumCoins * 2 - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 309990, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), }, // 5000 // 4545 -----|----- 5500 // 4000 ---------- 4999 "two positions with partially overlapping price ranges, not utilizing full liquidity of second position: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(1800000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(1800000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(1800000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(8479320318)), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(1800000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(8479320318)), expectedTick: 30292059, // from math import * // from decimal import * @@ -659,15 +659,15 @@ var ( // print(sqrt_next_3) // print(token_out) - expectedSqrtPrice: osmomath.MustNewDecFromStr("65.513815285481060959469337552596846421"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("65.513815285481060959469337552596846421"), // Started from DefaultSpreadRewardAccumCoins * 3, crossed tick once, thus becoming // DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins = DefaultSpreadRewardAccumCoins * 2 - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 309990, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), }, // Sequential price ranges with a gap // @@ -676,14 +676,14 @@ var ( // 5501 ----------- 6250 // "two sequential positions with a gap": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6106), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5501), - secondPositionUpperPrice: sdk.NewDec(6250), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1820545)), + priceLimit: osmomath.NewDec(6106), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5501), + secondPositionUpperPrice: osmomath.NewDec(6250), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1820545)), expectedTick: 32105555, // from math import * // from decimal import * @@ -720,22 +720,22 @@ var ( // print(sqrt_next_3) // print(token_out) - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.138055169663761658508234345605157554"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.138055169663761658508234345605157554"), expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins, expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5501), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5501), + newUpperPrice: osmomath.NewDec(6250), }, // Slippage protection doesn't cause a failure but interrupts early. // 5000 // 4545 ---!-|----- 5500 "single position within one tick, trade completes but slippage protection interrupts trade early: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4994), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4994), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * // @@ -755,14 +755,14 @@ var ( // print(sqrt_next) // print(expectedTokenIn) // print(expectedTokenOut) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(12892)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(64417624)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(12892)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(64417624)), expectedTick: func() int64 { - tick, _ := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt4994), DefaultTickSpacing) + tick, _ := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt4994), DefaultTickSpacing) return tick }(), // Since the next sqrt price is based on the price limit, we can calculate this directly. - expectedSqrtPrice: osmomath.BigDecFromSDKDec(osmomath.MustMonotonicSqrt(sdk.NewDec(4994))), + expectedSqrtPrice: osmomath.BigDecFromDec(osmomath.MustMonotonicSqrt(osmomath.NewDec(4994))), }, } @@ -772,15 +772,15 @@ var ( "spread factor 1 - single position within one tick: usdc -> eth (1% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(5004), - spreadFactor: sdk.MustNewDecFromStr("0.01"), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(42000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(8312)), + priceLimit: osmomath.NewDec(5004), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(42000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(8312)), expectedTick: 31003800, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.738071546196200264"), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000276701288297452"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.738071546196200264"), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000276701288297452"), }, // 5000 // 4545 -----|----- 5500 @@ -788,20 +788,20 @@ var ( "spread factor 2 - two positions within one tick: eth -> usdc (3% spread factor) ": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4990), - spreadFactor: sdk.MustNewDecFromStr("0.03"), + priceLimit: osmomath.NewDec(4990), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(64824917)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(64824917)), expectedTick: 30996900, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.689324382628080102"), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000000132091924532"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.689324382628080102"), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000000132091924532"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), }, // 5000 // 4545 -----|----- 5500 @@ -809,19 +809,19 @@ var ( "spread factor 3 - two positions with consecutive price ranges: eth -> usdc (5% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4094), - spreadFactor: sdk.MustNewDecFromStr("0.05"), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4545), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(8691708221)), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000073738597832046"), + priceLimit: osmomath.NewDec(4094), + spreadFactor: osmomath.MustNewDecFromStr("0.05"), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4545), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(8691708221)), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000073738597832046"), expectedTick: 30139200, - expectedSqrtPrice: osmomath.MustNewDecFromStr("64.336946417392457832"), - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4545), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("64.336946417392457832"), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4545), }, // 5000 // 4545 -----|----- 5500 @@ -829,19 +829,19 @@ var ( "spread factor 4 - two positions with partially overlapping price ranges: usdc -> eth (10% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.MustNewDecFromStr("0.1"), - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1695807)), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.624166726347032857"), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.MustNewDecFromStr("0.1"), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1695807)), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.624166726347032857"), expectedTick: 31825900, - expectedSqrtPrice: osmomath.MustNewDecFromStr("76.328178655208424124"), - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("76.328178655208424124"), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), }, // 5000 // 4545 -----|----- 5500 @@ -849,19 +849,19 @@ var ( "spread factor 5 - two positions with partially overlapping price ranges, not utilizing full liquidity of second position: eth -> usdc (0.5% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("eth", sdk.NewInt(1800000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(1800000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.MustNewDecFromStr("0.005"), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(1800000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(8440657775)), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000005569829831408"), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.MustNewDecFromStr("0.005"), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(1800000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(8440657775)), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000005569829831408"), expectedTick: 30299600, - expectedSqrtPrice: osmomath.MustNewDecFromStr("65.571484748647169032"), - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("65.571484748647169032"), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), }, // 5000 // 4545 -----|----- 5500 @@ -869,53 +869,53 @@ var ( "spread factor 6 - two sequential positions with a gap usdc -> eth (3% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6106), - secondPositionLowerPrice: sdk.NewDec(5501), - secondPositionUpperPrice: sdk.NewDec(6250), - spreadFactor: sdk.MustNewDecFromStr("0.03"), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000000000)), - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(1771252)), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.221769187794051751"), + priceLimit: osmomath.NewDec(6106), + secondPositionLowerPrice: osmomath.NewDec(5501), + secondPositionUpperPrice: osmomath.NewDec(6250), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000000000)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(1771252)), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.221769187794051751"), expectedTick: 32066500, - expectedSqrtPrice: osmomath.MustNewDecFromStr("77.887956882326389372"), - newLowerPrice: sdk.NewDec(5501), - newUpperPrice: sdk.NewDec(6250), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("77.887956882326389372"), + newLowerPrice: osmomath.NewDec(5501), + newUpperPrice: osmomath.NewDec(6250), }, // 5000 // 4545 ---!-|----- 5500 "spread factor 7: single position within one tick, trade completes but slippage protection interrupts trade early: eth -> usdc (1% spread factor)": { // parameters and results of this test case // are estimated by utilizing scripts from scripts/cl/main.py - tokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4994), - spreadFactor: sdk.MustNewDecFromStr("0.01"), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13023)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(64417624)), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000000085792039652"), + priceLimit: osmomath.NewDec(4994), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13023)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(64417624)), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000000085792039652"), expectedTick: func() int64 { - tick, _ := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(sqrt4994), DefaultTickSpacing) + tick, _ := math.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(sqrt4994), DefaultTickSpacing) return tick }(), - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.668238976219012614"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.668238976219012614"), }, } swapOutGivenInErrorCases = map[string]SwapTest{ "single position within one tick, trade does not complete due to lack of liquidity: usdc -> eth": { - tokenIn: sdk.NewCoin("usdc", sdk.NewInt(5300000000)), + tokenIn: sdk.NewCoin("usdc", osmomath.NewInt(5300000000)), tokenOutDenom: "eth", - priceLimit: sdk.NewDec(6000), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(6000), + spreadFactor: osmomath.ZeroDec(), expectErr: true, }, "single position within one tick, trade does not complete due to lack of liquidity: eth -> usdc": { - tokenIn: sdk.NewCoin("eth", sdk.NewInt(1100000)), + tokenIn: sdk.NewCoin("eth", osmomath.NewInt(1100000)), tokenOutDenom: "usdc", - priceLimit: sdk.NewDec(4000), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4000), + spreadFactor: osmomath.ZeroDec(), expectErr: true, }, } @@ -927,10 +927,10 @@ var ( // 5000 // 4545 -----|----- 5500 "single position within one tick: eth (in) -> usdc (out) | zfo": { - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenInDenom: ETH, - priceLimit: sdk.NewDec(4993), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4993), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * @@ -950,16 +950,16 @@ var ( // token_in = token_in = liq * (sqrt_cur - sqrt_next) / (sqrt_cur * sqrt_next) // print(sqrt_next) // print(token_in) - expectedTokenOut: sdk.NewCoin(USDC, sdk.NewInt(42000000)), - expectedTokenIn: sdk.NewCoin(ETH, sdk.NewInt(8404)), + expectedTokenOut: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), + expectedTokenIn: sdk.NewCoin(ETH, osmomath.NewInt(8404)), expectedTick: 30996087, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.683007989825007163485199999996399373"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.683007989825007163485199999996399373"), }, "single position within one tick: usdc (in) -> eth (out) ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(5010), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(5010), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * // import sys @@ -974,10 +974,10 @@ var ( // token_in = ceil(liq * abs(sqrt_cur - sqrt_next)) // print(sqrt_next) // print(token_in) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(66891663)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(66891663)), expectedTick: 31006234, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.754747188468900467378792612053774781"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.754747188468900467378792612053774781"), }, // Two equal price ranges // @@ -985,10 +985,10 @@ var ( // 4545 -----|----- 5500 // 4545 -----|----- 5500 "two positions within one tick: eth (in) -> usdc (out) | zfo": { - tokenOut: sdk.NewCoin("usdc", sdk.NewInt(66829187)), + tokenOut: sdk.NewCoin("usdc", osmomath.NewInt(66829187)), tokenInDenom: "eth", - priceLimit: sdk.NewDec(4990), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4990), + spreadFactor: osmomath.ZeroDec(), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, // from math import * @@ -1011,21 +1011,21 @@ var ( // token_in = token_in = liq * (sqrt_cur - sqrt_next) / (sqrt_cur * sqrt_next) // print(sqrt_next) // print(token_in) - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(66829187)), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(13370)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(66829187)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(13370)), expectedTick: 30996887, // This value is the direct output of sqrt_next in the script above. // The precision is exact because we properly handle rounding behavior in intermediate steps. - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.688664163727643651554720661097135393"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.688664163727643651554720661097135393"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), }, "two positions within one tick: usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin("eth", sdk.NewInt(8398)), + tokenOut: sdk.NewCoin("eth", osmomath.NewInt(8398)), tokenInDenom: "usdc", - priceLimit: sdk.NewDec(5020), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(5020), + spreadFactor: osmomath.ZeroDec(), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, // from math import * @@ -1042,13 +1042,13 @@ var ( // token_in = ceil(liq * abs(sqrt_cur - sqrt_next)) // print(sqrt_next) // print(token_in) - expectedTokenOut: sdk.NewCoin("eth", sdk.NewInt(8398)), - expectedTokenIn: sdk.NewCoin("usdc", sdk.NewInt(41998216)), + expectedTokenOut: sdk.NewCoin("eth", osmomath.NewInt(8398)), + expectedTokenIn: sdk.NewCoin("usdc", osmomath.NewInt(41998216)), expectedTick: 31001956, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.724512595179305566327821490232558005"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.724512595179305566327821490232558005"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), }, // Consecutive price ranges // @@ -1056,12 +1056,12 @@ var ( // 4545 -----|----- 5500 // 4000 ----------- 4545 "two positions with consecutive price ranges: eth (in) -> usdc (out) | zfo": { - tokenOut: sdk.NewCoin("usdc", sdk.NewInt(9103422788)), + tokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9103422788)), tokenInDenom: "eth", - priceLimit: sdk.NewDec(3900), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4545), + priceLimit: osmomath.NewDec(3900), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4545), // from math import * // from decimal import * @@ -1098,17 +1098,17 @@ var ( // print(sqrt_next_2) // print(token_in) // print(token_out_2) - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(9103422788)), - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9103422788)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), expectedTick: 30095166, - expectedSqrtPrice: osmomath.MustNewDecFromStr("63.993489023888951975210711246458277671"), - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("63.993489023888951975210711246458277671"), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4545), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4545), }, // Consecutive price ranges // @@ -1117,12 +1117,12 @@ var ( // 5500 ----------- 6250 // "two positions with consecutive price ranges: usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820630)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820630)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6106), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5500), // 315000 - secondPositionUpperPrice: sdk.NewDec(6250), // 322500 + priceLimit: osmomath.NewDec(6106), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5500), // 315000 + secondPositionUpperPrice: osmomath.NewDec(6250), // 322500 // from math import * // from decimal import * @@ -1159,14 +1159,14 @@ var ( // print(sqrt_next_2) // print(token_in) // print(token_out_2) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820630)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(9999999570)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820630)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(9999999570)), expectedTick: 32105414, - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.137148837036751554352224945360339905"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.137148837036751554352224945360339905"), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5500), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5500), + newUpperPrice: osmomath.NewDec(6250), }, // Partially overlapping price ranges // @@ -1175,12 +1175,12 @@ var ( // 4000 ----------- 4999 // "two positions with partially overlapping price ranges: eth (in) -> usdc (out) | zfo": { - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(9321276930)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(9321276930)), tokenInDenom: ETH, - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), // from math import * // from decimal import * @@ -1227,29 +1227,29 @@ var ( // print(sqrt_next_3) // print(token_in) // print(token_out_2) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2000000)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(9321276930)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2000000)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9321276930)), expectedTick: 30129083, - expectedSqrtPrice: osmomath.MustNewDecFromStr("64.257943796086567725876595411582357676"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("64.257943796086567725876595411582357676"), // Started from DefaultSpreadRewardAccumCoins * 3, crossed tick once, thus becoming // DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins = DefaultSpreadRewardAccumCoins * 2 - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 309990, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), }, // 5000 // 4545 -----|----- 5500 // 4000 ---------- 4999 "two positions with partially overlapping price ranges, not utilizing full liquidity of second position: eth (in) -> usdc (out) | zfo": { - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(8479320318)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(8479320318)), tokenInDenom: ETH, - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), // from math import * // from decimal import * @@ -1295,18 +1295,18 @@ var ( // print(sqrt_next_3) // print(token_in) // print(token_out_2) - expectedTokenIn: sdk.NewCoin(ETH, sdk.NewInt(1800000)), - expectedTokenOut: sdk.NewCoin(USDC, sdk.NewInt(8479320318)), + expectedTokenIn: sdk.NewCoin(ETH, osmomath.NewInt(1800000)), + expectedTokenOut: sdk.NewCoin(USDC, osmomath.NewInt(8479320318)), expectedTick: 30292059, - expectedSqrtPrice: osmomath.MustNewDecFromStr("65.513815286452064191403749708246274698"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("65.513815286452064191403749708246274698"), // Started from DefaultSpreadRewardAccumCoins * 3, crossed tick once, thus becoming // DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins = DefaultSpreadRewardAccumCoins * 2 - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 309990, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), }, // Partially overlapping price ranges @@ -1315,12 +1315,12 @@ var ( // 5001 ----------- 6250 // "two positions with partially overlapping price ranges: usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1864161)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1864161)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), // from math import * // from decimal import * @@ -1366,22 +1366,22 @@ var ( // print(sqrt_next_3) // print(token_in) // print(token_out_2) - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(9999994688)), - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1864161)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(9999994688)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1864161)), expectedTick: 32055918, - expectedSqrtPrice: osmomath.MustNewDecFromStr("77.819781711876553578435870496972242531"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("77.819781711876553578435870496972242531"), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 310010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), }, "two positions with partially overlapping price ranges, not utilizing full liquidity of second position: usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1609138)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1609138)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), // from math import * // from decimal import * @@ -1433,14 +1433,14 @@ var ( // print(token_in) // print(spread_rewards_growth) // print(token_out_2) - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(8499999458)), - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1609138)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(8499999458)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1609138)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 310010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedTick: 31712695, - expectedSqrtPrice: osmomath.MustNewDecFromStr("75.582372355128594342857800328292876450"), - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("75.582372355128594342857800328292876450"), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), }, // Sequential price ranges with a gap // @@ -1449,12 +1449,12 @@ var ( // 5501 ----------- 6250 // "two sequential positions with a gap usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6106), - spreadFactor: sdk.ZeroDec(), - secondPositionLowerPrice: sdk.NewDec(5501), // 315010 - secondPositionUpperPrice: sdk.NewDec(6250), // 322500 + priceLimit: osmomath.NewDec(6106), + spreadFactor: osmomath.ZeroDec(), + secondPositionLowerPrice: osmomath.NewDec(5501), // 315010 + secondPositionUpperPrice: osmomath.NewDec(6250), // 322500 // from math import * // from decimal import * @@ -1491,21 +1491,21 @@ var ( // print(sqrt_next_2) // print(token_in_2) // print(token_out_2) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(9999994756)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(9999994756)), expectedTick: 32105554, - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.138050797173647031951910080474560428"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.138050797173647031951910080474560428"), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5501), - newUpperPrice: sdk.NewDec(6250), + newLowerPrice: osmomath.NewDec(5501), + newUpperPrice: osmomath.NewDec(6250), }, // Slippage protection doesn't cause a failure but interrupts early. "single position within one tick, trade completes but slippage protection interrupts trade early: usdc (in) -> eth (out) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(5002), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(5002), + spreadFactor: osmomath.ZeroDec(), // from math import * // from decimal import * // # Range 1: From 5000 to 5002 @@ -1520,20 +1520,20 @@ var ( // # Summary: // print(sqrt_next_1) // print(token_in_1) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(4291)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(21463952)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(4291)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(21463952)), expectedTick: 31002000, // Since we know we're going up to the price limit, we can calculate the sqrt price exactly. - expectedSqrtPrice: osmomath.BigDecFromSDKDec(osmomath.MustMonotonicSqrt(sdk.NewDec(5002))), + expectedSqrtPrice: osmomath.BigDecFromDec(osmomath.MustMonotonicSqrt(osmomath.NewDec(5002))), }, } swapInGivenOutSpreadRewardTestCases = map[string]SwapTest{ "spread factor 1: single position within one tick: eth (in) -> usdc (out) (1% spread factor) | zfo": { - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenInDenom: ETH, - priceLimit: sdk.NewDec(4993), - spreadFactor: sdk.MustNewDecFromStr("0.01"), + priceLimit: osmomath.NewDec(4993), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), // from math import * // from decimal import * @@ -1558,19 +1558,19 @@ var ( // print(sqrt_next) // print(token_in) // print(spread_rewards_growth) - expectedTokenOut: sdk.NewCoin(USDC, sdk.NewInt(42000000)), - expectedTokenIn: sdk.NewCoin(ETH, sdk.NewInt(8489)), + expectedTokenOut: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), + expectedTokenIn: sdk.NewCoin(ETH, osmomath.NewInt(8489)), expectedTick: 30996087, // This value is the direct output of sqrt_next in the script above. // The precision is exact because we properly handle rounding behavior in intermediate steps. - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.683007989825007163485199999996399373"), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000000055925868851"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.683007989825007163485199999996399373"), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000000055925868851"), }, "spread factor 2: two positions within one tick: usdc (in) -> eth (out) (3% spread factor) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(8398)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(8398)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(5020), - spreadFactor: sdk.MustNewDecFromStr("0.03"), + priceLimit: osmomath.NewDec(5020), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), secondPositionLowerPrice: DefaultLowerPrice, secondPositionUpperPrice: DefaultUpperPrice, // from math import * @@ -1600,22 +1600,22 @@ var ( // print(sqrt_next) // print(token_in) // print(spread_rewards_growth) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(8398)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(43297130)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(8398)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(43297130)), expectedTick: 31001956, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.724512595179305566327821490232558005"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.724512595179305566327821490232558005"), // two positions with same liquidity entered - poolLiqAmount0: sdk.NewInt(1000000).MulRaw(2), - poolLiqAmount1: sdk.NewInt(5000000000).MulRaw(2), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000427870415073442"), + poolLiqAmount0: osmomath.NewInt(1000000).MulRaw(2), + poolLiqAmount1: osmomath.NewInt(5000000000).MulRaw(2), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000427870415073442"), }, "spread factor 3: two positions with consecutive price ranges: usdc (in) -> eth (out) (0.1% spread factor) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820630)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820630)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6106), - spreadFactor: sdk.MustNewDecFromStr("0.001"), - secondPositionLowerPrice: sdk.NewDec(5500), // 315000 - secondPositionUpperPrice: sdk.NewDec(6250), // 322500 + priceLimit: osmomath.NewDec(6106), + spreadFactor: osmomath.MustNewDecFromStr("0.001"), + secondPositionLowerPrice: osmomath.NewDec(5500), // 315000 + secondPositionUpperPrice: osmomath.NewDec(6250), // 322500 // from math import * // from decimal import * @@ -1658,23 +1658,23 @@ var ( // print(sqrt_next_2) // print(token_in) // print(spread_rewards_growth) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820630)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(10010009580)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820630)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(10010009580)), expectedTick: 32105414, - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.137148837036751554352224945360339905"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.137148837036751554352224945360339905"), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5500), - newUpperPrice: sdk.NewDec(6250), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.007433904623597252"), + newLowerPrice: osmomath.NewDec(5500), + newUpperPrice: osmomath.NewDec(6250), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.007433904623597252"), }, "spread factor 4: two positions with partially overlapping price ranges: eth (in) -> usdc (out) (10% spread factor) | zfo": { - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(9321276930)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(9321276930)), tokenInDenom: ETH, - priceLimit: sdk.NewDec(4128), - spreadFactor: sdk.MustNewDecFromStr("0.1"), - secondPositionLowerPrice: sdk.NewDec(4000), - secondPositionUpperPrice: sdk.NewDec(4999), + priceLimit: osmomath.NewDec(4128), + spreadFactor: osmomath.MustNewDecFromStr("0.1"), + secondPositionLowerPrice: osmomath.NewDec(4000), + secondPositionUpperPrice: osmomath.NewDec(4999), // from math import * // from decimal import * @@ -1726,27 +1726,27 @@ var ( // print(token_in) // print(spread_rewards_growth) // print(token_out_2) - expectedTokenIn: sdk.NewCoin("eth", sdk.NewInt(2222223)), - expectedTokenOut: sdk.NewCoin("usdc", sdk.NewInt(9321276930)), + expectedTokenIn: sdk.NewCoin("eth", osmomath.NewInt(2222223)), + expectedTokenOut: sdk.NewCoin("usdc", osmomath.NewInt(9321276930)), expectedTick: 30129083, - expectedSqrtPrice: osmomath.MustNewDecFromStr("64.257943796086567725876595411582357676"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("64.257943796086567725876595411582357676"), // Started from DefaultSpreadRewardAccumCoins * 3, crossed tick once, thus becoming // DefaultSpreadRewardAccumCoins * 3 - DefaultSpreadRewardAccumCoins = DefaultSpreadRewardAccumCoins * 2 - expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), - expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2)), + expectedLowerTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), + expectedUpperTickSpreadRewardGrowth: DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 300000, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 309990, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(4000), - newUpperPrice: sdk.NewDec(4999), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000157793641388331"), + newLowerPrice: osmomath.NewDec(4000), + newUpperPrice: osmomath.NewDec(4999), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000157793641388331"), }, "spread factor 5: two positions with partially overlapping price ranges, not utilizing full liquidity of second position: usdc (in) -> eth (out) (5% spread factor) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1609138)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1609138)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6056), - spreadFactor: sdk.MustNewDecFromStr("0.05"), - secondPositionLowerPrice: sdk.NewDec(5001), - secondPositionUpperPrice: sdk.NewDec(6250), + priceLimit: osmomath.NewDec(6056), + spreadFactor: osmomath.MustNewDecFromStr("0.05"), + secondPositionLowerPrice: osmomath.NewDec(5001), + secondPositionUpperPrice: osmomath.NewDec(6250), // from math import * // from decimal import * @@ -1798,23 +1798,23 @@ var ( // print(token_in) // print(spread_rewards_growth) // print(token_out_2) - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(8947367851)), - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1609138)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(8947367851)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1609138)), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 310010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedTick: 31712695, - expectedSqrtPrice: osmomath.MustNewDecFromStr("75.582372355128594342857800328292876450"), - newLowerPrice: sdk.NewDec(5001), - newUpperPrice: sdk.NewDec(6250), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.256404959888119530"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("75.582372355128594342857800328292876450"), + newLowerPrice: osmomath.NewDec(5001), + newUpperPrice: osmomath.NewDec(6250), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.256404959888119530"), }, "spread factor 6: two sequential positions with a gap usdc (in) -> eth (out) (0.03% spread factor) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(6106), - spreadFactor: sdk.MustNewDecFromStr("0.0003"), - secondPositionLowerPrice: sdk.NewDec(5501), // 315010 - secondPositionUpperPrice: sdk.NewDec(6250), // 322500 + priceLimit: osmomath.NewDec(6106), + spreadFactor: osmomath.MustNewDecFromStr("0.0003"), + secondPositionLowerPrice: osmomath.NewDec(5501), // 315010 + secondPositionUpperPrice: osmomath.NewDec(6250), // 322500 // from math import * // from decimal import * @@ -1856,21 +1856,21 @@ var ( // print(token_in) // print(spread_rewards_growth) // print(token_out_2) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(10002995655)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(10002995655)), expectedTick: 32105554, - expectedSqrtPrice: osmomath.MustNewDecFromStr("78.138050797173647031951910080474560428"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("78.138050797173647031951910080474560428"), expectedSecondLowerTickSpreadRewardGrowth: secondPosition{tickIndex: 315010, expectedSpreadRewardGrowth: cl.EmptyCoins}, expectedSecondUpperTickSpreadRewardGrowth: secondPosition{tickIndex: 322500, expectedSpreadRewardGrowth: cl.EmptyCoins}, - newLowerPrice: sdk.NewDec(5501), - newUpperPrice: sdk.NewDec(6250), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.002226857353494143"), + newLowerPrice: osmomath.NewDec(5501), + newUpperPrice: osmomath.NewDec(6250), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.002226857353494143"), }, "spread factor 7: single position within one tick, trade completes but slippage protection interrupts trade early: usdc (in) -> eth (out) (1% spread factor) | ofz": { - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(1820545)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(1820545)), tokenInDenom: USDC, - priceLimit: sdk.NewDec(5002), - spreadFactor: sdk.MustNewDecFromStr("0.01"), + priceLimit: osmomath.NewDec(5002), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), // from math import * // from decimal import * // # Range 1: From 5000 to 5002 @@ -1890,34 +1890,34 @@ var ( // print(sqrt_next_1) // print(token_in) // print(spread_rewards_growth) - expectedTokenOut: sdk.NewCoin(ETH, sdk.NewInt(4291)), - expectedTokenIn: sdk.NewCoin(USDC, sdk.NewInt(21680760)), + expectedTokenOut: sdk.NewCoin(ETH, osmomath.NewInt(4291)), + expectedTokenIn: sdk.NewCoin(USDC, osmomath.NewInt(21680760)), expectedTick: 31002000, - expectedSqrtPrice: osmomath.MustNewDecFromStr("70.724818840347693040"), - expectedSpreadRewardGrowthAccumulatorValue: sdk.MustNewDecFromStr("0.000142835574082604"), + expectedSqrtPrice: osmomath.MustNewBigDecFromStr("70.724818840347693040"), + expectedSpreadRewardGrowthAccumulatorValue: osmomath.MustNewDecFromStr("0.000142835574082604"), }, } swapInGivenOutErrorTestCases = map[string]SwapTest{ "single position within one tick, trade does not complete due to lack of liquidity: usdc -> eth ": { - tokenOut: sdk.NewCoin("usdc", sdk.NewInt(5300000000)), + tokenOut: sdk.NewCoin("usdc", osmomath.NewInt(5300000000)), tokenInDenom: "eth", - priceLimit: sdk.NewDec(6000), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(6000), + spreadFactor: osmomath.ZeroDec(), expectErr: true, }, "single position within one tick, trade does not complete due to lack of liquidity: eth -> usdc ": { - tokenOut: sdk.NewCoin("eth", sdk.NewInt(1100000)), + tokenOut: sdk.NewCoin("eth", osmomath.NewInt(1100000)), tokenInDenom: "usdc", - priceLimit: sdk.NewDec(4000), - spreadFactor: sdk.ZeroDec(), + priceLimit: osmomath.NewDec(4000), + spreadFactor: osmomath.ZeroDec(), expectErr: true, }, } additiveSpreadRewardGrowthGlobalErrTolerance = osmomath.ErrTolerance{ // 2 * 10^-18 - AdditiveTolerance: sdk.SmallestDec().Mul(sdk.NewDec(2)), + AdditiveTolerance: osmomath.SmallestDec().Mul(osmomath.NewDec(2)), } ) @@ -1959,7 +1959,7 @@ func (s *KeeperTestSuite) preparePoolAndDefaultPositions(test SwapTest) types.Co return pool } -func (s *KeeperTestSuite) preparePoolWithCustSpread(spread sdk.Dec) types.ConcentratedPoolExtension { +func (s *KeeperTestSuite) preparePoolWithCustSpread(spread osmomath.Dec) types.ConcentratedPoolExtension { clParams := s.App.ConcentratedLiquidityKeeper.GetParams(s.Ctx) clParams.AuthorizedSpreadFactors = append(clParams.AuthorizedSpreadFactors, spread) s.App.ConcentratedLiquidityKeeper.SetParams(s.Ctx, clParams) @@ -2006,8 +2006,8 @@ func (s *KeeperTestSuite) assertSpreadRewardAccum(test SwapTest, poolId uint64) s.Require().Equal(1, spreadRewardAccumValue.Len(), "spread reward accumulator should only have one denom, was (%s)", spreadRewardAccumValue) s.Require().Equal(0, additiveSpreadRewardGrowthGlobalErrTolerance.CompareBigDec( - osmomath.BigDecFromSDKDec(test.expectedSpreadRewardGrowthAccumulatorValue), - osmomath.BigDecFromSDKDec(spreadRewardVal), + osmomath.BigDecFromDec(test.expectedSpreadRewardGrowthAccumulatorValue), + osmomath.BigDecFromDec(spreadRewardVal), ), fmt.Sprintf("expected %s, got %s", test.expectedSpreadRewardGrowthAccumulatorValue.String(), spreadRewardVal.String()), ) @@ -2019,7 +2019,7 @@ func (s *KeeperTestSuite) assertZeroSpreadRewards(poolId uint64) { s.Require().Equal(0, spreadRewardAccum.GetValue().Len()) } -func (s *KeeperTestSuite) getExpectedLiquidity(test SwapTest, pool types.ConcentratedPoolExtension) sdk.Dec { +func (s *KeeperTestSuite) getExpectedLiquidity(test SwapTest, pool types.ConcentratedPoolExtension) osmomath.Dec { if test.newLowerPrice.IsNil() && test.newUpperPrice.IsNil() { test.newLowerPrice = DefaultLowerPrice test.newUpperPrice = DefaultUpperPrice @@ -2041,12 +2041,12 @@ func (s *KeeperTestSuite) getExpectedLiquidity(test SwapTest, pool types.Concent return expectedLiquidity } -func (s *KeeperTestSuite) lowerUpperPricesToTick(lowerPrice, upperPrice sdk.Dec, tickSpacing uint64) (int64, int64) { +func (s *KeeperTestSuite) lowerUpperPricesToTick(lowerPrice, upperPrice osmomath.Dec, tickSpacing uint64) (int64, int64) { lowerSqrtPrice := osmomath.MustMonotonicSqrt(lowerPrice) - newLowerTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(lowerSqrtPrice), tickSpacing) + newLowerTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(lowerSqrtPrice), tickSpacing) s.Require().NoError(err) upperSqrtPrice := osmomath.MustMonotonicSqrt(upperPrice) - newUpperTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromSDKDec(upperSqrtPrice), tickSpacing) + newUpperTick, err := clmath.SqrtPriceToTickRoundDownSpacing(osmomath.BigDecFromDec(upperSqrtPrice), tickSpacing) s.Require().NoError(err) return newLowerTick, newUpperTick } @@ -2084,7 +2084,7 @@ func (s *KeeperTestSuite) TestComputeAndSwapOutAmtGivenIn() { } else { s.testSwapResult(test, pool, swapResult.AmountIn, swapResult.AmountOut, poolUpdates, err) - expectedSpreadFactors := swapResult.AmountIn.ToDec().Mul(pool.GetSpreadFactor(s.Ctx)).TruncateInt() + expectedSpreadFactors := swapResult.AmountIn.ToLegacyDec().Mul(pool.GetSpreadFactor(s.Ctx)).TruncateInt() s.Require().Equal(expectedSpreadFactors.String(), swapResult.SpreadRewards.TruncateInt().String()) // check that the pool has not been modified after performing calc @@ -2115,7 +2115,7 @@ func (s *KeeperTestSuite) TestSwap_NoPositions() { _, _, _, err := s.App.ConcentratedLiquidityKeeper.SwapInAmtGivenOut( s.Ctx, s.TestAccs[0], pool, DefaultCoin0, DefaultCoin1.Denom, - sdk.ZeroDec(), sdk.ZeroDec(), + osmomath.ZeroDec(), osmomath.ZeroDec(), ) s.Require().Error(err) s.Require().ErrorIs(err, types.NoSpotPriceWhenNoLiquidityError{PoolId: pool.GetId()}) @@ -2123,7 +2123,7 @@ func (s *KeeperTestSuite) TestSwap_NoPositions() { _, _, _, err = s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn( s.Ctx, s.TestAccs[0], pool, DefaultCoin0, DefaultCoin1.Denom, - sdk.ZeroDec(), sdk.ZeroDec(), + osmomath.ZeroDec(), osmomath.ZeroDec(), ) s.Require().Error(err) @@ -2138,7 +2138,7 @@ func (s *KeeperTestSuite) TestSwapOutAmtGivenIn_TickUpdates() { s.setupAndFundSwapTest() // Create default CL pool - pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, sdk.ZeroDec()) + pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, osmomath.ZeroDec()) // manually update spread factor accumulator for the pool spreadFactorAccum, err := s.App.ConcentratedLiquidityKeeper.GetSpreadRewardAccumulator(s.Ctx, 1) @@ -2152,7 +2152,7 @@ func (s *KeeperTestSuite) TestSwapOutAmtGivenIn_TickUpdates() { // add 2*DefaultSpreadRewardAccumCoins to spread factor accumulator, now spread factor accumulator has 3*DefaultSpreadRewardAccumCoins as its value spreadFactorAccum, err = s.App.ConcentratedLiquidityKeeper.GetSpreadRewardAccumulator(s.Ctx, 1) s.Require().NoError(err) - spreadFactorAccum.AddToAccumulator(DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2))) + spreadFactorAccum.AddToAccumulator(DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2))) // perform swap _, _, _, err = s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn( @@ -2192,7 +2192,7 @@ func (s *KeeperTestSuite) TestSwapOutAmtGivenIn_TickUpdates() { } } -func (s *KeeperTestSuite) testSwapResult(test SwapTest, pool types.ConcentratedPoolExtension, amountIn, amountOut sdk.Int, poolUpdates cl.PoolUpdates, err error) { +func (s *KeeperTestSuite) testSwapResult(test SwapTest, pool types.ConcentratedPoolExtension, amountIn, amountOut osmomath.Int, poolUpdates cl.PoolUpdates, err error) { s.Require().NoError(err) // check that tokenIn, tokenOut, tick, and sqrtPrice from CalcOut are all what we expected @@ -2228,7 +2228,7 @@ func (s *KeeperTestSuite) TestComputeAndSwapInAmtGivenOut() { } else { s.testSwapResult(test, pool, swapResult.AmountIn, swapResult.AmountOut, poolUpdates, err) - expectedSpreadRewards := swapResult.AmountIn.ToDec().Mul(pool.GetSpreadFactor(s.Ctx)).TruncateInt() + expectedSpreadRewards := swapResult.AmountIn.ToLegacyDec().Mul(pool.GetSpreadFactor(s.Ctx)).TruncateInt() s.Require().Equal(expectedSpreadRewards.String(), swapResult.SpreadRewards.TruncateInt().String()) } @@ -2286,7 +2286,7 @@ func (s *KeeperTestSuite) TestSwapInAmtGivenOut_TickUpdates() { // add 2*DefaultSpreadRewardAccumCoins to spread factor accumulator, now spread factor accumulator has 3*DefaultSpreadRewardAccumCoins as its value spreadFactorAccum, err = s.App.ConcentratedLiquidityKeeper.GetSpreadRewardAccumulator(s.Ctx, 1) s.Require().NoError(err) - spreadFactorAccum.AddToAccumulator(DefaultSpreadRewardAccumCoins.MulDec(sdk.NewDec(2))) + spreadFactorAccum.AddToAccumulator(DefaultSpreadRewardAccumCoins.MulDec(osmomath.NewDec(2))) // perform swap _, _, _, err = s.App.ConcentratedLiquidityKeeper.SwapInAmtGivenOut( @@ -2329,9 +2329,9 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { type param struct { tokenIn sdk.Coin tokenOutDenom string - underFundBy sdk.Int - tokenOutMinAmount sdk.Int - expectedTokenOut sdk.Int + underFundBy osmomath.Int + tokenOutMinAmount osmomath.Int + expectedTokenOut osmomath.Int } // liquidity and sqrtPriceCurrent for all tests are: @@ -2365,10 +2365,10 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { // print(expectedTokenIn) // print(expectedTokenOut) param: param{ - tokenIn: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenOutDenom: ETH, tokenOutMinAmount: types.MinSpotPrice.RoundInt(), - expectedTokenOut: sdk.NewInt(8396), + expectedTokenOut: osmomath.NewInt(8396), }, }, { @@ -2392,25 +2392,25 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { // print(expectedTokenIn) // print(expectedTokenOut) param: param{ - tokenIn: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenIn: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenOutDenom: USDC, tokenOutMinAmount: types.MinSpotPrice.RoundInt(), - expectedTokenOut: sdk.NewInt(66808388), + expectedTokenOut: osmomath.NewInt(66808388), }, }, { name: "out is lesser than min amount", param: param{ - tokenIn: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenOutDenom: ETH, - tokenOutMinAmount: sdk.NewInt(8397), + tokenOutMinAmount: osmomath.NewInt(8397), }, - expectedErr: &types.AmountLessThanMinError{TokenAmount: sdk.NewInt(8396), TokenMin: sdk.NewInt(8397)}, + expectedErr: &types.AmountLessThanMinError{TokenAmount: osmomath.NewInt(8396), TokenMin: osmomath.NewInt(8397)}, }, { name: "in and out denom are same", param: param{ - tokenIn: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenIn: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenOutDenom: ETH, tokenOutMinAmount: types.MinSpotPrice.RoundInt(), }, @@ -2419,7 +2419,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { { name: "unknown in denom", param: param{ - tokenIn: sdk.NewCoin("etha", sdk.NewInt(13370)), + tokenIn: sdk.NewCoin("etha", osmomath.NewInt(13370)), tokenOutDenom: ETH, tokenOutMinAmount: types.MinSpotPrice.RoundInt(), }, @@ -2428,7 +2428,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { { name: "unknown out denom", param: param{ - tokenIn: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenIn: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenOutDenom: "etha", tokenOutMinAmount: types.MinSpotPrice.RoundInt(), }, @@ -2437,20 +2437,20 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { { name: "insufficient user balance", param: param{ - tokenIn: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenIn: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenOutDenom: ETH, tokenOutMinAmount: types.MinSpotPrice.RoundInt(), - expectedTokenOut: sdk.NewInt(8396), - underFundBy: sdk.OneInt(), + expectedTokenOut: osmomath.NewInt(8396), + underFundBy: osmomath.OneInt(), }, expectedErr: &types.InsufficientUserBalanceError{}, }, { name: "calculates zero due to small amount in", param: param{ - tokenIn: sdk.NewCoin(USDC, sdk.NewInt(1)), + tokenIn: sdk.NewCoin(USDC, osmomath.NewInt(1)), tokenOutDenom: ETH, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), }, expectedErr: &types.InvalidAmountCalculatedError{}, }, @@ -2470,7 +2470,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { // The logic below is to trigger a specific error branch // where user does not have enough funds. - underFundBy := sdk.ZeroInt() + underFundBy := osmomath.ZeroInt() if !test.param.underFundBy.IsNil() { underFundBy = test.param.underFundBy } @@ -2512,15 +2512,15 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn() { spotPriceAfter := pool.GetCurrentSqrtPrice().PowerInteger(2) // Ratio of the token out should be between the before spot price and after spot price. - tradeAvgPrice := tokenOutAmount.ToDec().Quo(test.param.tokenIn.Amount.ToDec()) + tradeAvgPrice := tokenOutAmount.ToLegacyDec().Quo(test.param.tokenIn.Amount.ToLegacyDec()) if zeroForOne { - s.Require().True(tradeAvgPrice.LT(spotPriceBefore.SDKDec())) - s.Require().True(tradeAvgPrice.GT(spotPriceAfter.SDKDec())) + s.Require().True(tradeAvgPrice.LT(spotPriceBefore.Dec())) + s.Require().True(tradeAvgPrice.GT(spotPriceAfter.Dec())) } else { - tradeAvgPrice = sdk.OneDec().Quo(tradeAvgPrice) - s.Require().True(tradeAvgPrice.GT(spotPriceBefore.SDKDec())) - s.Require().True(tradeAvgPrice.LT(spotPriceAfter.SDKDec())) + tradeAvgPrice = osmomath.OneDec().Quo(tradeAvgPrice) + s.Require().True(tradeAvgPrice.GT(spotPriceBefore.Dec())) + s.Require().True(tradeAvgPrice.LT(spotPriceAfter.Dec())) } // Validate that listeners were called the desired number of times @@ -2533,13 +2533,13 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { // this is used for the test case with price impact protection // to ensure that the balances always have enough funds to cover // the swap and trigger the desired error branch - differenceFromMax := sdk.OneInt() + differenceFromMax := osmomath.OneInt() type param struct { tokenOut sdk.Coin tokenInDenom string - tokenInMaxAmount sdk.Int - expectedTokenIn sdk.Int + tokenInMaxAmount osmomath.Int + expectedTokenIn osmomath.Int } tests := []struct { @@ -2551,7 +2551,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { name: "Proper swap eth > usdc", param: param{ - tokenOut: sdk.NewCoin(USDC, sdk.NewInt(42000000)), + tokenOut: sdk.NewCoin(USDC, osmomath.NewInt(42000000)), tokenInDenom: ETH, tokenInMaxAmount: types.MaxSpotPrice.RoundInt(), // from math import * @@ -2561,7 +2561,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { // sqrt_next = sqrt_cur - token_out / liq // token_in = math.ceil(liq * (sqrt_cur - sqrt_next) / (sqrt_cur * sqrt_next)) // print(token_in) - expectedTokenIn: sdk.NewInt(8404), + expectedTokenIn: osmomath.NewInt(8404), }, }, { @@ -2575,36 +2575,36 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { // token_in = ceil(liq * abs(sqrt_cur - sqrt_next)) // print(token_in) param: param{ - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: USDC, tokenInMaxAmount: types.MaxSpotPrice.RoundInt(), - expectedTokenIn: sdk.NewInt(66891663), + expectedTokenIn: osmomath.NewInt(66891663), }, }, { name: "out is more than max amount", param: param{ - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: USDC, - tokenInMaxAmount: sdk.NewInt(66891663).Sub(differenceFromMax), - expectedTokenIn: sdk.NewInt(66891663), + tokenInMaxAmount: osmomath.NewInt(66891663).Sub(differenceFromMax), + expectedTokenIn: osmomath.NewInt(66891663), }, - expectedErr: &types.AmountGreaterThanMaxError{TokenAmount: sdk.NewInt(66891663), TokenMax: sdk.NewInt(66891663).Sub(differenceFromMax)}, + expectedErr: &types.AmountGreaterThanMaxError{TokenAmount: osmomath.NewInt(66891663), TokenMax: osmomath.NewInt(66891663).Sub(differenceFromMax)}, }, { name: "insufficient user balance", param: param{ - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: USDC, - tokenInMaxAmount: sdk.NewInt(66891663).Sub(differenceFromMax.Mul(sdk.NewInt(2))), - expectedTokenIn: sdk.NewInt(66891663), + tokenInMaxAmount: osmomath.NewInt(66891663).Sub(differenceFromMax.Mul(osmomath.NewInt(2))), + expectedTokenIn: osmomath.NewInt(66891663), }, expectedErr: &types.InsufficientUserBalanceError{}, }, { name: "in and out denom are same", param: param{ - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: ETH, tokenInMaxAmount: types.MaxSpotPrice.RoundInt(), }, @@ -2613,7 +2613,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { { name: "unknown out denom", param: param{ - tokenOut: sdk.NewCoin("etha", sdk.NewInt(13370)), + tokenOut: sdk.NewCoin("etha", osmomath.NewInt(13370)), tokenInDenom: ETH, tokenInMaxAmount: types.MaxSpotPrice.RoundInt(), }, @@ -2622,7 +2622,7 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { { name: "unknown in denom", param: param{ - tokenOut: sdk.NewCoin(ETH, sdk.NewInt(13370)), + tokenOut: sdk.NewCoin(ETH, osmomath.NewInt(13370)), tokenInDenom: "etha", tokenInMaxAmount: types.MaxSpotPrice.RoundInt(), }, @@ -2682,17 +2682,17 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut() { spotPriceAfter := pool.GetCurrentSqrtPrice().PowerInteger(2) // Ratio of the token out should be between the before spot price and after spot price. - tradeAvgPrice := tokenIn.ToDec().Quo(test.param.tokenOut.Amount.ToDec()) + tradeAvgPrice := tokenIn.ToLegacyDec().Quo(test.param.tokenOut.Amount.ToLegacyDec()) if zeroForOne { // token in is token zero, token out is token one - tradeAvgPrice = sdk.OneDec().Quo(tradeAvgPrice) - s.Require().True(tradeAvgPrice.LT(spotPriceBefore.SDKDec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceBefore: %s", tradeAvgPrice, spotPriceBefore)) - s.Require().True(tradeAvgPrice.GT(spotPriceAfter.SDKDec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceAfter: %s", tradeAvgPrice, spotPriceAfter)) + tradeAvgPrice = osmomath.OneDec().Quo(tradeAvgPrice) + s.Require().True(tradeAvgPrice.LT(spotPriceBefore.Dec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceBefore: %s", tradeAvgPrice, spotPriceBefore)) + s.Require().True(tradeAvgPrice.GT(spotPriceAfter.Dec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceAfter: %s", tradeAvgPrice, spotPriceAfter)) } else { // token in is token one, token out is token zero - s.Require().True(tradeAvgPrice.GT(spotPriceBefore.SDKDec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceBefore: %s", tradeAvgPrice, spotPriceBefore)) - s.Require().True(tradeAvgPrice.LT(spotPriceAfter.SDKDec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceAfter: %s", tradeAvgPrice, spotPriceAfter)) + s.Require().True(tradeAvgPrice.GT(spotPriceBefore.Dec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceBefore: %s", tradeAvgPrice, spotPriceBefore)) + s.Require().True(tradeAvgPrice.LT(spotPriceAfter.Dec()), fmt.Sprintf("tradeAvgPrice: %s, spotPriceAfter: %s", tradeAvgPrice, spotPriceAfter)) } // Validate that listeners were called the desired number of times @@ -2761,7 +2761,7 @@ func (s *KeeperTestSuite) setupSecondPosition(test SwapTest, pool types.Concentr if !test.secondPositionLowerPrice.IsNil() { newLowerTick, newUpperTick := s.lowerUpperPricesToTick(test.secondPositionLowerPrice, test.secondPositionUpperPrice, pool.GetTickSpacing()) - _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[1], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), newLowerTick, newUpperTick) + _, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[1], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), newLowerTick, newUpperTick) s.Require().NoError(err) } } @@ -2837,7 +2837,7 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapOutAmtGivenIn() { secondTokenIn, secondTokenOut, _, err := s.App.ConcentratedLiquidityKeeper.SwapOutAmtGivenIn( s.Ctx, s.TestAccs[0], poolBefore, firstTokenOut, firstTokenIn.Denom, - DefaultZeroSpreadFactor, sdk.ZeroDec(), + DefaultZeroSpreadFactor, osmomath.ZeroDec(), ) s.Require().NoError(err) @@ -2848,29 +2848,29 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapOutAmtGivenIn() { } func (s *KeeperTestSuite) TestUpdateSpreadRewardGrowthGlobal() { - ten := sdk.NewDec(10) + ten := osmomath.NewDec(10) tests := map[string]struct { - liquidity sdk.Dec - spreadRewardChargeTotal sdk.Dec - expectedSpreadRewardGrowthGlobal sdk.Dec + liquidity osmomath.Dec + spreadRewardChargeTotal osmomath.Dec + expectedSpreadRewardGrowthGlobal osmomath.Dec }{ "zero liquidity -> no-op": { - liquidity: sdk.ZeroDec(), + liquidity: osmomath.ZeroDec(), spreadRewardChargeTotal: ten, - expectedSpreadRewardGrowthGlobal: sdk.ZeroDec(), + expectedSpreadRewardGrowthGlobal: osmomath.ZeroDec(), }, "non-zero liquidity -> updated": { liquidity: ten, spreadRewardChargeTotal: ten, // 10 / 10 = 1 - expectedSpreadRewardGrowthGlobal: sdk.OneDec(), + expectedSpreadRewardGrowthGlobal: osmomath.OneDec(), }, "rounding test: boundary spread reward growth": { - liquidity: ten.Add(ten).Mul(sdk.NewDec(1e18)), + liquidity: ten.Add(ten).Mul(osmomath.NewDec(1e18)), spreadRewardChargeTotal: ten, // 10 / (20 * 10^18) = 5 * 10^-19, which we expect to truncate and leave 0. - expectedSpreadRewardGrowthGlobal: sdk.ZeroDec(), + expectedSpreadRewardGrowthGlobal: osmomath.ZeroDec(), }, } @@ -2882,8 +2882,8 @@ func (s *KeeperTestSuite) TestUpdateSpreadRewardGrowthGlobal() { // Setup. swapState := cl.SwapState{} swapState.SetLiquidity(tc.liquidity) - swapState.SetGlobalSpreadRewardGrowthPerUnitLiquidity(sdk.ZeroDec()) - swapState.SetGlobalSpreadRewardGrowth(sdk.ZeroDec()) + swapState.SetGlobalSpreadRewardGrowthPerUnitLiquidity(osmomath.ZeroDec()) + swapState.SetGlobalSpreadRewardGrowth(osmomath.ZeroDec()) // System under test. swapState.UpdateSpreadRewardGrowthGlobal(tc.spreadRewardChargeTotal) @@ -2914,7 +2914,7 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapInAmtGivenOut() { secondTokenIn, secondTokenOut, _, err := s.App.ConcentratedLiquidityKeeper.SwapInAmtGivenOut( s.Ctx, s.TestAccs[0], poolBefore, firstTokenIn, firstTokenOut.Denom, - DefaultZeroSpreadFactor, sdk.ZeroDec(), + DefaultZeroSpreadFactor, osmomath.ZeroDec(), ) s.Require().NoError(err) @@ -2926,8 +2926,8 @@ func (s *KeeperTestSuite) TestInverseRelationshipSwapInAmtGivenOut() { func (s *KeeperTestSuite) TestUpdatePoolForSwap() { var ( - oneHundredETH = sdk.NewCoin(ETH, sdk.NewInt(100_000_000)) - oneHundredUSDC = sdk.NewCoin(USDC, sdk.NewInt(100_000_000)) + oneHundredETH = sdk.NewCoin(ETH, osmomath.NewInt(100_000_000)) + oneHundredUSDC = sdk.NewCoin(USDC, osmomath.NewInt(100_000_000)) defaultInitialBalance = sdk.NewCoins(oneHundredETH, oneHundredUSDC) ) @@ -2936,9 +2936,9 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { poolInitialBalance sdk.Coins tokenIn sdk.Coin tokenOut sdk.Coin - spreadFactor sdk.Dec + spreadFactor osmomath.Dec newCurrentTick int64 - newLiquidity sdk.Dec + newLiquidity osmomath.Dec newSqrtPrice osmomath.BigDec expectError error }{ @@ -2947,9 +2947,9 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { poolInitialBalance: defaultInitialBalance, tokenIn: oneHundredETH, tokenOut: oneHundredUSDC, - spreadFactor: sdk.MustNewDecFromStr("0.003"), // 0.3% + spreadFactor: osmomath.MustNewDecFromStr("0.003"), // 0.3% newCurrentTick: 2, - newLiquidity: sdk.NewDec(2), + newLiquidity: osmomath.NewDec(2), newSqrtPrice: osmomath.NewBigDec(2), }, "success case with different/uneven numbers": { @@ -2957,9 +2957,9 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { poolInitialBalance: defaultInitialBalance, tokenIn: oneHundredETH.Add(oneHundredETH), tokenOut: oneHundredUSDC, - spreadFactor: sdk.MustNewDecFromStr("0.002"), // 0.2% + spreadFactor: osmomath.MustNewDecFromStr("0.002"), // 0.2% newCurrentTick: 8, - newLiquidity: sdk.NewDec(37), + newLiquidity: osmomath.NewDec(37), newSqrtPrice: osmomath.NewBigDec(91), }, "sender does not have enough balance": { @@ -2967,9 +2967,9 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { poolInitialBalance: defaultInitialBalance, tokenIn: oneHundredETH.Add(oneHundredETH), tokenOut: oneHundredUSDC, - spreadFactor: sdk.MustNewDecFromStr("0.003"), + spreadFactor: osmomath.MustNewDecFromStr("0.003"), newCurrentTick: 2, - newLiquidity: sdk.NewDec(2), + newLiquidity: osmomath.NewDec(2), newSqrtPrice: osmomath.NewBigDec(2), expectError: types.InsufficientUserBalanceError{}, }, @@ -2978,9 +2978,9 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { poolInitialBalance: defaultInitialBalance, tokenIn: oneHundredETH, tokenOut: oneHundredUSDC.Add(oneHundredUSDC), - spreadFactor: sdk.MustNewDecFromStr("0.003"), + spreadFactor: osmomath.MustNewDecFromStr("0.003"), newCurrentTick: 2, - newLiquidity: sdk.NewDec(2), + newLiquidity: osmomath.NewDec(2), newSqrtPrice: osmomath.NewBigDec(2), expectError: types.InsufficientPoolBalanceError{}, }, @@ -2998,7 +2998,7 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { s.FundAcc(sender, tc.senderInitialBalance) // Default pool values are initialized to one. - err := pool.ApplySwap(sdk.OneDec(), 1, osmomath.OneDec()) + err := pool.ApplySwap(osmomath.OneDec(), 1, osmomath.OneBigDec()) s.Require().NoError(err) // Write default pool to state. @@ -3008,7 +3008,7 @@ func (s *KeeperTestSuite) TestUpdatePoolForSwap() { // Set mock listener to make sure that is is called when desired. s.setListenerMockOnConcentratedLiquidityKeeper() - expectedSpreadFactors := tc.tokenIn.Amount.ToDec().Mul(pool.GetSpreadFactor(s.Ctx)).Ceil() + expectedSpreadFactors := tc.tokenIn.Amount.ToLegacyDec().Mul(pool.GetSpreadFactor(s.Ctx)).Ceil() expectedSpreadFactorsCoins := sdk.NewCoins(sdk.NewCoin(tc.tokenIn.Denom, expectedSpreadFactors.TruncateInt())) swapDetails := cl.SwapDetails{sender, tc.tokenIn, tc.tokenOut} poolUpdates := cl.PoolUpdates{tc.newCurrentTick, tc.newLiquidity, tc.newSqrtPrice} @@ -3086,7 +3086,7 @@ func (s *KeeperTestSuite) inverseRelationshipInvariants(firstTokenIn, firstToken newSpotPrice, err := poolAfter.SpotPrice(s.Ctx, pool.GetToken1(), pool.GetToken0()) s.Require().NoError(err) multiplicativeTolerance = osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.MustNewDecFromStr("0.001"), + MultiplicativeTolerance: osmomath.MustNewDecFromStr("0.001"), } s.Require().Equal(0, multiplicativeTolerance.Compare(oldSpotPrice.RoundInt(), newSpotPrice.RoundInt())) @@ -3109,7 +3109,7 @@ func (s *KeeperTestSuite) inverseRelationshipInvariants(firstTokenIn, firstToken // validateAmountsWithTolerance validates the given amounts a and b, allowing // a negligible multiplicative error and an additive error of 1. -func (s *KeeperTestSuite) validateAmountsWithTolerance(amountA sdk.Int, amountB sdk.Int) { +func (s *KeeperTestSuite) validateAmountsWithTolerance(amountA osmomath.Int, amountB osmomath.Int) { multCompare := multiplicativeTolerance.Compare(amountA, amountB) if multCompare != 0 { // If the multiplicative comparison fails, try again with additive tolerance of one. @@ -3136,14 +3136,14 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { // Determine amount of ETH and USDC to swap per swap. // These values were chosen as to not deplete the entire liquidity, but enough to move the price considerably. - swapCoin0 := sdk.NewCoin(ETH, DefaultAmt0.Quo(sdk.NewInt(int64(positions.numSwaps)))) - swapCoin1 := sdk.NewCoin(USDC, DefaultAmt1.Quo(sdk.NewInt(int64(positions.numSwaps)))) + swapCoin0 := sdk.NewCoin(ETH, DefaultAmt0.Quo(osmomath.NewInt(int64(positions.numSwaps)))) + swapCoin1 := sdk.NewCoin(USDC, DefaultAmt1.Quo(osmomath.NewInt(int64(positions.numSwaps)))) // Default setup only creates 3 accounts, but we need 5 for this test. s.TestAccs = apptesting.CreateRandomAccounts(positions.numAccounts) // Create a default CL pool, but with a 0.3 percent swap spread factor. - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, sdk.MustNewDecFromStr("0.003")) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, DefaultTickSpacing, osmomath.MustNewDecFromStr("0.003")) positionIds := make([][]uint64, 4) // Setup full range position across all four accounts @@ -3208,10 +3208,10 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { // print(token_out) # 982676.1324268988579833395181 // Get expected values from the calculations above - expectedSqrtPrice := osmomath.MustNewDecFromStr("71.74138432587113364823838192") + expectedSqrtPrice := osmomath.MustNewBigDecFromStr("71.74138432587113364823838192") actualSqrtPrice := clPool.GetCurrentSqrtPrice() - expectedTokenIn := swapCoin1.Amount.Mul(sdk.NewInt(int64(positions.numSwaps))) - expectedTokenOut := sdk.NewInt(982676) + expectedTokenIn := swapCoin1.Amount.Mul(osmomath.NewInt(int64(positions.numSwaps))) + expectedTokenOut := osmomath.NewInt(982676) // Compare the expected and actual values with a multiplicative tolerance of 0.0001% s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(expectedSqrtPrice, actualSqrtPrice), "expected sqrt price: %s, actual sqrt price: %s", expectedSqrtPrice, actualSqrtPrice) @@ -3268,10 +3268,10 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { // print(token_out) # 5052068983.121266708067570832 // Get expected values from the calculations above - expectedSqrtPrice = osmomath.MustNewDecFromStr("70.64112736841825140176332377") + expectedSqrtPrice = osmomath.MustNewBigDecFromStr("70.64112736841825140176332377") actualSqrtPrice = clPool.GetCurrentSqrtPrice() - expectedTokenIn = swapCoin0.Amount.Mul(sdk.NewInt(int64(positions.numSwaps))) - expectedTokenOut = sdk.NewInt(5052068983) + expectedTokenIn = swapCoin0.Amount.Mul(osmomath.NewInt(int64(positions.numSwaps))) + expectedTokenOut = osmomath.NewInt(5052068983) // Compare the expected and actual values with a multiplicative tolerance of 0.0001% s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(expectedSqrtPrice, actualSqrtPrice)) @@ -3328,10 +3328,10 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { // print(token_out) # 882804.6589413517320313885494 // Get expected values from the calculations above - expectedSqrtPrice = osmomath.MustNewDecFromStr("76.22545423006231767390422658") + expectedSqrtPrice = osmomath.MustNewBigDecFromStr("76.22545423006231767390422658") actualSqrtPrice = clPool.GetCurrentSqrtPrice() - expectedTokenIn = swapCoin1.Amount.Mul(sdk.NewInt(int64(positions.numSwaps))) - expectedTokenOut = sdk.NewInt(882804) + expectedTokenIn = swapCoin1.Amount.Mul(osmomath.NewInt(int64(positions.numSwaps))) + expectedTokenOut = osmomath.NewInt(882804) // Compare the expected and actual values with a multiplicative tolerance of 0.0001% s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(expectedSqrtPrice, actualSqrtPrice)) @@ -3374,10 +3374,10 @@ func (s *KeeperTestSuite) TestFunctionalSwaps() { // print(token_out) # 4509814620.762503497903902725 // Get expected values from the calculations above - expectedSqrtPrice = osmomath.MustNewDecFromStr("63.97671895942244949922335999") + expectedSqrtPrice = osmomath.MustNewBigDecFromStr("63.97671895942244949922335999") actualSqrtPrice = clPool.GetCurrentSqrtPrice() - expectedTokenIn = swapCoin0.Amount.Mul(sdk.NewInt(int64(positions.numSwaps))) - expectedTokenOut = sdk.NewInt(4509814620) + expectedTokenIn = swapCoin0.Amount.Mul(osmomath.NewInt(int64(positions.numSwaps))) + expectedTokenOut = osmomath.NewInt(4509814620) // Compare the expected and actual values with a multiplicative tolerance of 0.0001% s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(expectedSqrtPrice, actualSqrtPrice)) @@ -3396,19 +3396,19 @@ func (s *KeeperTestSuite) TestInfiniteSwapLoop_OutGivenIn() { // Create position near min tick s.FundAcc(positionOwner, DefaultRangeTestParams.baseAssets.Add(DefaultRangeTestParams.baseAssets...)) - _, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), positionOwner, DefaultRangeTestParams.baseAssets, sdk.ZeroInt(), sdk.ZeroInt(), -108000000, -107999900) + _, err := s.clk.CreatePosition(s.Ctx, pool.GetId(), positionOwner, DefaultRangeTestParams.baseAssets, osmomath.ZeroInt(), osmomath.ZeroInt(), -108000000, -107999900) s.Require().NoError(err) // Swap small amount to get current tick to position above, triggering the problematic function/branch (CalcAmount0Delta) swapAddress := testAccs[1] - swapEthFunded := sdk.NewCoin(ETH, sdk.Int(sdk.MustNewDecFromStr("10000000000000000000000000000000000000000"))) - swapUSDCFunded := sdk.NewCoin(USDC, sdk.Int(sdk.MustNewDecFromStr("10000"))) + swapEthFunded := sdk.NewCoin(ETH, osmomath.Int(osmomath.MustNewDecFromStr("10000000000000000000000000000000000000000"))) + swapUSDCFunded := sdk.NewCoin(USDC, osmomath.Int(osmomath.MustNewDecFromStr("10000"))) s.FundAcc(swapAddress, sdk.NewCoins(swapEthFunded, swapUSDCFunded)) - _, tokenOut, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddress, pool, sdk.NewCoin(USDC, sdk.NewInt(10000)), ETH, pool.GetSpreadFactor(s.Ctx), sdk.ZeroDec()) + _, tokenOut, _, err := s.clk.SwapInAmtGivenOut(s.Ctx, swapAddress, pool, sdk.NewCoin(USDC, osmomath.NewInt(10000)), ETH, pool.GetSpreadFactor(s.Ctx), osmomath.ZeroDec()) s.Require().NoError(err) // Swap back in the amount that was swapped out to test the inverse relationship - _, _, _, err = s.clk.SwapOutAmtGivenIn(s.Ctx, swapAddress, pool, tokenOut, ETH, pool.GetSpreadFactor(s.Ctx), sdk.ZeroDec()) + _, _, _, err = s.clk.SwapOutAmtGivenIn(s.Ctx, swapAddress, pool, tokenOut, ETH, pool.GetSpreadFactor(s.Ctx), osmomath.ZeroDec()) s.Require().NoError(err) } @@ -3469,7 +3469,7 @@ func (s *KeeperTestSuite) TestComputeMaxInAmtGivenMaxTicksCrossed() { s.Run(test.name, func() { s.SetupTest() clPool := s.PrepareConcentratedPool() - expectedResultingTokenOutAmount := sdk.ZeroInt() + expectedResultingTokenOutAmount := osmomath.ZeroInt() // Create positions and calculate expected resulting tokens positions := []struct { @@ -3498,22 +3498,22 @@ func (s *KeeperTestSuite) TestComputeMaxInAmtGivenMaxTicksCrossed() { } else { s.Require().NoError(err) - errTolerance := osmomath.ErrTolerance{AdditiveTolerance: sdk.NewDec(int64(test.maxTicksCrossed))} + errTolerance := osmomath.ErrTolerance{AdditiveTolerance: osmomath.NewDec(int64(test.maxTicksCrossed))} s.Require().Equal(0, errTolerance.Compare(expectedResultingTokenOutAmount, resultingTokenOut.Amount), "expected: %s, got: %s", expectedResultingTokenOutAmount, resultingTokenOut.Amount) } }) } } -func (s *KeeperTestSuite) createPositionAndFundAcc(clPool types.ConcentratedPoolExtension, lowerTick, upperTick int64) (amt0, amt1 sdk.Int) { +func (s *KeeperTestSuite) createPositionAndFundAcc(clPool types.ConcentratedPoolExtension, lowerTick, upperTick int64) (amt0, amt1 osmomath.Int) { s.FundAcc(s.TestAccs[0], DefaultCoins) - positionData, _ := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPool.GetId(), s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), lowerTick, upperTick) + positionData, _ := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, clPool.GetId(), s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), lowerTick, upperTick) amt0 = positionData.Amount0 amt1 = positionData.Amount1 return } -func (s *KeeperTestSuite) calculateExpectedTokens(tokenInDenom string, testMaxTicks, positionMaxTicks uint64, amt0, amt1, currentTotal sdk.Int) sdk.Int { +func (s *KeeperTestSuite) calculateExpectedTokens(tokenInDenom string, testMaxTicks, positionMaxTicks uint64, amt0, amt1, currentTotal osmomath.Int) osmomath.Int { if tokenInDenom == ETH && testMaxTicks > positionMaxTicks { return currentTotal.Add(amt1) } else if tokenInDenom == USDC && testMaxTicks > positionMaxTicks { diff --git a/x/concentrated-liquidity/swaps_tick_cross_test.go b/x/concentrated-liquidity/swaps_tick_cross_test.go index ae0c165b30c..c6e2b71291f 100644 --- a/x/concentrated-liquidity/swaps_tick_cross_test.go +++ b/x/concentrated-liquidity/swaps_tick_cross_test.go @@ -32,7 +32,7 @@ var ( // this is chosen arbitrarily to allow tests to pass. Thee tests in this suite do not // intend to validate the correctness of the slippage bound. As a result, it is irrelevant here // and we can choose any value that works. - defaultTokenInMaxAmount = sdk.MustNewDecFromStr("707106781186547528576662335").TruncateInt() + defaultTokenInMaxAmount = osmomath.MustNewDecFromStr("707106781186547528576662335").TruncateInt() ) // CreatePositionTickSpacingsFromCurrentTick creates a position with the passed in tick spacings away from the current tick. @@ -50,7 +50,7 @@ func (s *KeeperTestSuite) CreatePositionTickSpacingsFromCurrentTick(poolId uint6 lowerTick := currentTick - int64(tickSpacingsAwayFromCurrentTick)*tickSpacing upperTick := currentTick + int64(tickSpacingsAwayFromCurrentTick)*tickSpacing s.FundAcc(s.TestAccs[0], DefaultCoins) - positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), lowerTick, upperTick) + positionData, err := s.App.ConcentratedLiquidityKeeper.CreatePosition(s.Ctx, pool.GetId(), s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), lowerTick, upperTick) s.Require().NoError(err) return positionMeta{ @@ -74,7 +74,7 @@ func (s *KeeperTestSuite) validateIteratorLeftZeroForOne(poolId uint64, expected pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) - zeroForOneSwapStrategy, _, err := s.App.ConcentratedLiquidityKeeper.SetupSwapStrategy(s.Ctx, pool, sdk.ZeroDec(), pool.GetToken0(), types.MinSqrtPrice) + zeroForOneSwapStrategy, _, err := s.App.ConcentratedLiquidityKeeper.SetupSwapStrategy(s.Ctx, pool, osmomath.ZeroDec(), pool.GetToken0(), types.MinSqrtPrice) s.Require().NoError(err) initializedTickValue := pool.GetCurrentTick() iter := zeroForOneSwapStrategy.InitializeNextTickIterator(s.Ctx, pool.GetId(), initializedTickValue) @@ -93,7 +93,7 @@ func (s *KeeperTestSuite) validateIteratorRightOneForZero(poolId uint64, expecte s.Require().NoError(err) // Setup swap strategy directly as it would fail validation if constructed via SetupSwapStrategy(...) - oneForZeroSwapStrategy := swapstrategy.New(false, osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), s.App.GetKey(types.ModuleName), sdk.ZeroDec()) + oneForZeroSwapStrategy := swapstrategy.New(false, osmomath.BigDecFromDec(types.MaxSqrtPrice), s.App.GetKey(types.ModuleName), osmomath.ZeroDec()) s.Require().NoError(err) initializedTickValue := pool.GetCurrentTick() iter := oneForZeroSwapStrategy.InitializeNextTickIterator(s.Ctx, pool.GetId(), initializedTickValue) @@ -136,32 +136,32 @@ func (s *KeeperTestSuite) assertPositionRangeConditional(poolId uint64, isOutOfR // swapZeroForOneLeft swaps amount in the left (zfo) direction of the swap. // Asserts that no error is returned. func (s *KeeperTestSuite) swapZeroForOneLeft(poolId uint64, amount sdk.Coin) { - s.swapZeroForOneLeftWithSpread(poolId, amount, sdk.ZeroDec()) + s.swapZeroForOneLeftWithSpread(poolId, amount, osmomath.ZeroDec()) } // swapZeroForOneLeftWithSpread functions exactly as swapZeroForOneLeft but with a spread factor. -func (s *KeeperTestSuite) swapZeroForOneLeftWithSpread(poolId uint64, amount sdk.Coin, spreadFactor sdk.Dec) { +func (s *KeeperTestSuite) swapZeroForOneLeftWithSpread(poolId uint64, amount sdk.Coin, spreadFactor osmomath.Dec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) s.FundAcc(s.TestAccs[0], sdk.NewCoins(amount)) - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, amount, pool.GetToken1(), sdk.ZeroInt(), spreadFactor) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, amount, pool.GetToken1(), osmomath.ZeroInt(), spreadFactor) s.Require().NoError(err) } // swapOneForZeroRight swaps amount in the right (ofz) direction of the swap. // Asserts that no error is returned. func (s *KeeperTestSuite) swapOneForZeroRight(poolId uint64, amount sdk.Coin) { - s.swapOneForZeroRightWithSpread(poolId, amount, sdk.ZeroDec()) + s.swapOneForZeroRightWithSpread(poolId, amount, osmomath.ZeroDec()) } // swapOneForZeroRightWithSpread functions exactly as swapOneForZeroRight but with a spread factor. -func (s *KeeperTestSuite) swapOneForZeroRightWithSpread(poolId uint64, amount sdk.Coin, spreadFactor sdk.Dec) { +func (s *KeeperTestSuite) swapOneForZeroRightWithSpread(poolId uint64, amount sdk.Coin, spreadFactor osmomath.Dec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) s.FundAcc(s.TestAccs[0], sdk.NewCoins(amount)) - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, amount, pool.GetToken0(), sdk.ZeroInt(), spreadFactor) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, amount, pool.GetToken0(), osmomath.ZeroInt(), spreadFactor) s.Require().NoError(err) } @@ -169,26 +169,26 @@ func (s *KeeperTestSuite) swapOneForZeroRightWithSpread(poolId uint64, amount sd // Asserts that no error is returned. // When swapping in given out, we provide token to swap out but eventually get charged token in. // Therefore we must also estimate the token in amount and pre-fund the account with it. -func (s *KeeperTestSuite) swapInGivenOutZeroForOneLeft(poolId uint64, tokenOut sdk.Coin, estimatedTokenIn sdk.Dec) { +func (s *KeeperTestSuite) swapInGivenOutZeroForOneLeft(poolId uint64, tokenOut sdk.Coin, estimatedTokenIn osmomath.Dec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) tokenInDenom := pool.GetToken0() s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, estimatedTokenIn.Ceil().TruncateInt()))) - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, tokenInDenom, defaultTokenInMaxAmount, tokenOut, sdk.ZeroDec()) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, tokenInDenom, defaultTokenInMaxAmount, tokenOut, osmomath.ZeroDec()) s.Require().NoError(err) } // swapInGivenOutOneForZeroRight swaps in given out in the right (ofz) direction of the swap. // When swapping in given out, we provide token to swap out but eventually get charged token in. // Therefore we must also estimate the token in amount and pre-fund the account with it. -func (s *KeeperTestSuite) swapInGivenOutOneForZeroRight(poolId uint64, tokenOut sdk.Coin, estimatedTokenIn sdk.Dec) { +func (s *KeeperTestSuite) swapInGivenOutOneForZeroRight(poolId uint64, tokenOut sdk.Coin, estimatedTokenIn osmomath.Dec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) tokenInDenom := pool.GetToken1() s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, estimatedTokenIn.Ceil().TruncateInt()))) - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, tokenInDenom, defaultTokenInMaxAmount, tokenOut, sdk.ZeroDec()) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, tokenInDenom, defaultTokenInMaxAmount, tokenOut, osmomath.ZeroDec()) s.Require().NoError(err) } @@ -199,7 +199,7 @@ func (s *KeeperTestSuite) swapInGivenOutOneForZeroRight(poolId uint64, tokenOut // // Returns the pool id and the narrow range position metadata. func (s *KeeperTestSuite) setupPoolAndPositions(testTickSpacing uint64, positionTickSpacingsFromCurrTick []uint64, initialCoins sdk.Coins) (uint64, []positionMeta) { - pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, testTickSpacing, sdk.ZeroDec()) + pool := s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, testTickSpacing, osmomath.ZeroDec()) poolId := pool.GetId() // Create a full range position @@ -234,7 +234,7 @@ func (s *KeeperTestSuite) setupPoolAndPositions(testTickSpacing uint64, position } // assertPoolLiquidityEquals a helper to assert that the liquidity of a pool is equal to the expected value. -func (s *KeeperTestSuite) assertPoolLiquidityEquals(poolId uint64, expectedLiquidity sdk.Dec) { +func (s *KeeperTestSuite) assertPoolLiquidityEquals(poolId uint64, expectedLiquidity osmomath.Dec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) @@ -252,13 +252,13 @@ func (s *KeeperTestSuite) assertPoolTickEquals(poolId uint64, expectedTick int64 // computeSwapAmounts computes the amountIn that should be swapped to reach the expectedTickToSwapTo // given the direction of the swap (as defined by isZeroForOne) and the current sqrt price. // if shouldStayWithinTheSameBucket is true, the amountIn is computed such that the swap does not cross the tick. -// curSqrtPrice can be a nil dec (sdk.Dec{}). In such a case, the system converts the current tick to a current sqrt price. +// curSqrtPrice can be a nil dec (osmomath.Dec{}). In such a case, the system converts the current tick to a current sqrt price. // The reason why user might want to provide a current sqrt price is when going in zero for one direction of a second swap. // In that case, the current sqrt price is still in the domain of the previous bucket but the current tick is already in the next // bucket. // // Note, that this logic runs quote estimation. Our frontend logic runs a similar algorithm. -func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomath.BigDec, expectedTickToSwapTo int64, isZeroForOne bool, shouldStayWithinTheSameBucket bool) (sdk.Dec, sdk.Dec, osmomath.BigDec) { +func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomath.BigDec, expectedTickToSwapTo int64, isZeroForOne bool, shouldStayWithinTheSameBucket bool) (osmomath.Dec, osmomath.Dec, osmomath.BigDec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) @@ -270,7 +270,7 @@ func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomat } // Get liquidity net amounts for tokenIn estimation. - liquidityNetAmounts, err := s.App.ConcentratedLiquidityKeeper.GetTickLiquidityNetInDirection(s.Ctx, poolId, tokenInDenom, sdk.Int{}, sdk.Int{}) + liquidityNetAmounts, err := s.App.ConcentratedLiquidityKeeper.GetTickLiquidityNetInDirection(s.Ctx, poolId, tokenInDenom, osmomath.Int{}, osmomath.Int{}) s.Require().NoError(err) currentTick := originalCurrentTick @@ -281,7 +281,7 @@ func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomat // Start from current pool liquidity and zero amount in. currentLiquidity := pool.GetLiquidity() - amountIn := sdk.ZeroDec() + amountIn := osmomath.ZeroDec() for i, liquidityNetEntry := range liquidityNetAmounts { // Initialize the next initialized tick and its sqrt price. @@ -293,7 +293,7 @@ func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomat var isWithinDesiredBucketAfterSwap bool if isZeroForOne { // Round up so that we cross the tick by default. - curAmountIn := math.CalcAmount0Delta(osmomath.BigDecFromSDKDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).SDKDecRoundUp() + curAmountIn := math.CalcAmount0Delta(osmomath.BigDecFromDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).DecRoundUp() amountIn = amountIn.Add(curAmountIn) @@ -316,12 +316,12 @@ func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomat nextInitTickSqrtPrice := s.tickToSqrtPrice(liquidityNetAmounts[i+1].TickIndex) // We discount by half so that we do no cross any tick and remain in the same bucket. - curAmountIn := math.CalcAmount0Delta(osmomath.BigDecFromSDKDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).QuoInt64(2).SDKDecRoundUp() + curAmountIn := math.CalcAmount0Delta(osmomath.BigDecFromDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).QuoInt64(2).DecRoundUp() amountIn = amountIn.Add(curAmountIn) } } else { // Round up so that we cross the tick by default. - curAmountIn := math.CalcAmount1Delta(osmomath.BigDecFromSDKDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).SDKDec() + curAmountIn := math.CalcAmount1Delta(osmomath.BigDecFromDec(currentLiquidity), curSqrtPrice, nextInitTickSqrtPrice, true).Dec() amountIn = amountIn.Add(curAmountIn) // The tick should be crossed if currentTick <= expectedTickToSwapTo, unless the intention @@ -346,7 +346,7 @@ func (s *KeeperTestSuite) computeSwapAmounts(poolId uint64, curSqrtPrice osmomat return amountIn, currentLiquidity, curSqrtPrice } -func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPrice osmomath.BigDec, expectedTickToSwapTo int64, isZeroForOne bool, shouldStayWithinTheSameBucket bool) (sdk.Dec, osmomath.BigDec, osmomath.BigDec) { +func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPrice osmomath.BigDec, expectedTickToSwapTo int64, isZeroForOne bool, shouldStayWithinTheSameBucket bool) (osmomath.Dec, osmomath.BigDec, osmomath.BigDec) { pool, err := s.App.ConcentratedLiquidityKeeper.GetPoolById(s.Ctx, poolId) s.Require().NoError(err) @@ -358,7 +358,7 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri } // Get liquidity net amounts for tokenIn estimation. - liquidityNetAmounts, err := s.App.ConcentratedLiquidityKeeper.GetTickLiquidityNetInDirection(s.Ctx, poolId, tokenOutDenom, sdk.Int{}, sdk.Int{}) + liquidityNetAmounts, err := s.App.ConcentratedLiquidityKeeper.GetTickLiquidityNetInDirection(s.Ctx, poolId, tokenOutDenom, osmomath.Int{}, osmomath.Int{}) s.Require().NoError(err) currentTick := originalCurrentTick @@ -368,8 +368,8 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri } // Start from current pool liquidity and zero amount in. - currentLiquidity := osmomath.BigDecFromSDKDec(pool.GetLiquidity()) - amountOut := sdk.ZeroDec() + currentLiquidity := osmomath.BigDecFromDec(pool.GetLiquidity()) + amountOut := osmomath.ZeroDec() for i, liquidityNetEntry := range liquidityNetAmounts { // Initialize the next initialized tick and its sqrt price. @@ -383,7 +383,7 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri // Round up so that we cross the tick by default. curAmountOut := math.CalcAmount1Delta(currentLiquidity, curSqrtPrice, nextInitTickSqrtPrice, false) - amountOut = amountOut.Add(curAmountOut.SDKDec()) + amountOut = amountOut.Add(curAmountOut.Dec()) // The tick should be crossed if currentTick > expectedTickToSwapTo, unless the intention // is to stay within the same bucket. @@ -391,7 +391,7 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri if shouldCrossTick { // Runs regular tick crossing logic. curSqrtPrice = s.tickToSqrtPrice(nextInitializedTick) - currentLiquidity = currentLiquidity.Sub(osmomath.BigDecFromSDKDec(liquidityNetEntry.LiquidityNet)) + currentLiquidity = currentLiquidity.Sub(osmomath.BigDecFromDec(liquidityNetEntry.LiquidityNet)) currentTick = nextInitializedTick - 1 } @@ -405,12 +405,12 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri // We discound by two so that we do no cross any tick and remain in the same bucket. curAmountIn := math.CalcAmount1Delta(currentLiquidity, curSqrtPrice, nextInitTickSqrtPrice, false).QuoInt64(2) - amountOut = amountOut.Add(curAmountIn.SDKDecRoundUp()) + amountOut = amountOut.Add(curAmountIn.DecRoundUp()) } } else { // Round up so that we cross the tick by default. curAmountOut := math.CalcAmount0Delta(currentLiquidity, curSqrtPrice, nextInitTickSqrtPrice, false) - amountOut = amountOut.Add(curAmountOut.SDKDec()) + amountOut = amountOut.Add(curAmountOut.Dec()) // The tick should be crossed if currentTick <= expectedTickToSwapTo, unless the intention // is to stay within the same bucket. @@ -418,7 +418,7 @@ func (s *KeeperTestSuite) computeSwapAmountsInGivenOut(poolId uint64, curSqrtPri if shouldCrossTick { // Runs regular tick crossing logic. curSqrtPrice = s.tickToSqrtPrice(nextInitializedTick) - currentLiquidity = currentLiquidity.Add(osmomath.BigDecFromSDKDec(liquidityNetEntry.LiquidityNet)) + currentLiquidity = currentLiquidity.Add(osmomath.BigDecFromDec(liquidityNetEntry.LiquidityNet)) currentTick = nextInitializedTick } @@ -528,7 +528,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() // computed expected outputs expectedTickAfterFirstSwap int64 - expectedLiquidityAfterFirstAndSecondSwap sdk.Dec + expectedLiquidityAfterFirstAndSecondSwap osmomath.Dec doesFirstSwapCrossTick bool expectedNextTickAfterFirstSwapZFOLeft int64 expectedNextTickAfterFirstSwapOFZRight int64 @@ -634,7 +634,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() s.Require().True(isNarrowInRange) var ( - amountZeroIn sdk.Dec = sdk.ZeroDec() + amountZeroIn osmomath.Dec = osmomath.ZeroDec() sqrtPriceStart osmomath.BigDec = pool.GetCurrentSqrtPrice() liquidity = pool.GetLiquidity() @@ -643,7 +643,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() if tickToSwapTo < nr1Position.lowerTick { sqrtPriceLowerTickOne := s.tickToSqrtPrice(nr1Position.lowerTick) - amountZeroIn = math.CalcAmount0Delta(osmomath.BigDecFromSDKDec(liquidity), sqrtPriceLowerTickOne, sqrtPriceStart, true).SDKDec() + amountZeroIn = math.CalcAmount0Delta(osmomath.BigDecFromDec(liquidity), sqrtPriceLowerTickOne, sqrtPriceStart, true).Dec() sqrtPriceStart = sqrtPriceLowerTickOne @@ -652,7 +652,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() // This is the total amount necessary to cross the lower tick of narrow position. // Note it is rounded up to ensure that the tick is crossed. - amountZeroIn = math.CalcAmount0Delta(osmomath.BigDecFromSDKDec(liquidity), sqrtPriceTarget, sqrtPriceStart, true).SDKDecRoundUp().Add(amountZeroIn) + amountZeroIn = math.CalcAmount0Delta(osmomath.BigDecFromDec(liquidity), sqrtPriceTarget, sqrtPriceStart, true).DecRoundUp().Add(amountZeroIn) tokenZeroIn := sdk.NewCoin(pool.GetToken0(), amountZeroIn.Ceil().TruncateInt()) @@ -696,7 +696,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() doesFirstSwapCrossUpperTickOne := expectedTickAfterFirstSwap >= nr1Position.upperTick var ( - expectedLiquidityAfterFirstAndSecondSwap sdk.Dec + expectedLiquidityAfterFirstAndSecondSwap osmomath.Dec expectedNextTickAfterFirstSwapZFOLeft int64 expectedNextTickAfterFirstSwapOFZRight int64 ) @@ -726,7 +726,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() s.Require().NoError(err) var ( - amountOneIn sdk.Dec = sdk.ZeroDec() + amountOneIn osmomath.Dec = osmomath.ZeroDec() sqrtPriceStart osmomath.BigDec = pool.GetCurrentSqrtPrice() liquidity = pool.GetLiquidity() ) @@ -734,7 +734,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() if tickToSwapTo >= nr1Position.upperTick { sqrtPriceUpperOne := s.tickToSqrtPrice(nr1Position.upperTick) - amountOneIn = math.CalcAmount1Delta(osmomath.BigDecFromSDKDec(liquidity), sqrtPriceUpperOne, sqrtPriceStart, true).SDKDecRoundUp() + amountOneIn = math.CalcAmount1Delta(osmomath.BigDecFromDec(liquidity), sqrtPriceUpperOne, sqrtPriceStart, true).DecRoundUp() sqrtPriceStart = sqrtPriceUpperOne @@ -743,7 +743,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() // This is the total amount necessary to cross the lower tick of narrow position. // Note it is rounded up to ensure that the tick is crossed. - amountOneIn = math.CalcAmount1Delta(osmomath.BigDecFromSDKDec(liquidity), sqrtPriceTarget, sqrtPriceStart, true).SDKDecRoundUp().Add(amountOneIn) + amountOneIn = math.CalcAmount1Delta(osmomath.BigDecFromDec(liquidity), sqrtPriceTarget, sqrtPriceStart, true).DecRoundUp().Add(amountOneIn) tokenOneIn := sdk.NewCoin(pool.GetToken1(), amountOneIn.Ceil().TruncateInt()) @@ -869,7 +869,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() // If we swap a small amount in the same direction again, we do not expect // any tick to be crossed again. - smallAmount := sdk.NewCoin(expectedAndComputedValues.tokenIn.Denom, sdk.NewInt(10)) + smallAmount := sdk.NewCoin(expectedAndComputedValues.tokenIn.Denom, osmomath.NewInt(10)) s.swapZeroForOneLeft(poolId, smallAmount) // Perform validation after the second swap. @@ -983,7 +983,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_Tick_Initialization_And_Crossing() // If we swap a small amount in the same direction again, we do not expect // any tick to be crossed again. - smallAmount := sdk.NewCoin(expectedAndComputedValues.tokenIn.Denom, sdk.NewInt(10000)) + smallAmount := sdk.NewCoin(expectedAndComputedValues.tokenIn.Denom, osmomath.NewInt(10000)) s.swapOneForZeroRight(poolId, smallAmount) // Perform validation after the second swap. @@ -1057,7 +1057,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // The only exception is when performing a second swap in the same direction within the same tick. // In such a case, we need to run our estimate logic one tick further to ensure that our estimate is non-zero. // However, we discount the amountIn by half to ensure that the tick is not crossed. - computeNextTickToReachAndMultiplier := func(isZeroForOne bool, expectedSwapEndTick int64, shouldStayWithinTheSameTickInCompute bool) (int64, sdk.Dec) { + computeNextTickToReachAndMultiplier := func(isZeroForOne bool, expectedSwapEndTick int64, shouldStayWithinTheSameTickInCompute bool) (int64, osmomath.Dec) { if shouldStayWithinTheSameTickInCompute { nextTickToReachInCompute := expectedSwapEndTick if isZeroForOne { @@ -1069,7 +1069,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { return nextTickToReachInCompute, sdk.NewDecWithPrec(5, 1) } - return expectedSwapEndTick, sdk.OneDec() + return expectedSwapEndTick, osmomath.OneDec() } validateActivePositions := func(poolId uint64, positionMeta []positionMeta, expectedIsPositionActiveFlags []bool) { @@ -1201,9 +1201,9 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // estimateAmountInFromRounding is a helper to estimate the impact of amountOut rounding on the amountIn and next sqrt price. // This is necessary for correct amount in estimation to pre-fund the swapper account to. It is also required for updating // the "current sqrt price" for the next swap in the sequence as defined by our test configuration. - estimateAmountInFromRounding := func(isZeroForOne bool, nextSqrtPrice osmomath.BigDec, liq osmomath.BigDec, amountOutDifference osmomath.BigDec) (sdk.Dec, osmomath.BigDec) { + estimateAmountInFromRounding := func(isZeroForOne bool, nextSqrtPrice osmomath.BigDec, liq osmomath.BigDec, amountOutDifference osmomath.BigDec) (osmomath.Dec, osmomath.BigDec) { if !liq.IsPositive() { - return sdk.ZeroDec(), nextSqrtPrice + return osmomath.ZeroDec(), nextSqrtPrice } if isZeroForOne { @@ -1212,7 +1212,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // Since amount in is overestimated, this done in favor of the pool. updatedNextCurSqrtPrice := math.GetNextSqrtPriceFromAmount1OutRoundingDown(nextSqrtPrice, liq, amountOutDifference) // Round up since we want to overestimate the amount in in favor of the pool. - return math.CalcAmount0Delta(liq, updatedNextCurSqrtPrice, nextSqrtPrice, true).SDKDecRoundUp(), updatedNextCurSqrtPrice + return math.CalcAmount0Delta(liq, updatedNextCurSqrtPrice, nextSqrtPrice, true).DecRoundUp(), updatedNextCurSqrtPrice } // Round up since we want to overestimate the change in sqrt price stemming from the amount out going left-to-right @@ -1220,7 +1220,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // Since amount in is overestimated, this is done in favor of the pool. updatedNextCurSqrtPrice := math.GetNextSqrtPriceFromAmount0OutRoundingUp(nextSqrtPrice, liq, amountOutDifference) // Round up since we want to overestimate the amount in in favor of the pool. - return math.CalcAmount1Delta(liq, updatedNextCurSqrtPrice, nextSqrtPrice, true).SDKDecRoundUp(), updatedNextCurSqrtPrice + return math.CalcAmount1Delta(liq, updatedNextCurSqrtPrice, nextSqrtPrice, true).DecRoundUp(), updatedNextCurSqrtPrice } for name, tc := range testcases { @@ -1266,7 +1266,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { amountOut, expectedLiquidity, nextSqrtPrice := s.computeSwapAmountsInGivenOut(poolId, curSqrtPrice, nextTickToReachInCompute, isZeroForOne, shouldStayWithinTheSameTickInCompute) amountIn, _, _ := s.computeSwapAmounts(poolId, curSqrtPrice, nextTickToReachInCompute, isZeroForOne, shouldStayWithinTheSameTickInCompute) - s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, amountIn.Ceil().TruncateInt().Add(sdk.OneInt())))) + s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, amountIn.Ceil().TruncateInt().Add(osmomath.OneInt())))) // Discount the amount in by 50% if we are swapping within the same tick. amountOutRoundedUp := amountOut.Mul(withinTheSameTickDiscount).Ceil().TruncateInt() @@ -1276,8 +1276,8 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // impact of the rounding to correctly update the "curSqrtPrice" at the end of this loop for // properly estimating the next swap. This also allows us to precisely calculate by how many tokens in we need // to pre-fund the swapper account. - amountOutDifference := amountOutRoundedUp.ToDec().Sub(amountOut) - amountInFromRounding, updatedNextCurSqrtPrice := estimateAmountInFromRounding(isZeroForOne, nextSqrtPrice, expectedLiquidity, osmomath.BigDecFromSDKDec(amountOutDifference)) + amountOutDifference := amountOutRoundedUp.ToLegacyDec().Sub(amountOut) + amountInFromRounding, updatedNextCurSqrtPrice := estimateAmountInFromRounding(isZeroForOne, nextSqrtPrice, expectedLiquidity, osmomath.BigDecFromDec(amountOutDifference)) amountInToPreFund := amountIn.Add(amountInFromRounding) // Perform the swap in the desired direction. @@ -1285,7 +1285,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { amountOutCoin := sdk.NewCoin(pool.GetToken1(), amountOutRoundedUp) s.swapInGivenOutZeroForOneLeft(poolId, amountOutCoin, amountInToPreFund) } else { - // s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, sdk.NewInt(amountInFromRounding.Ceil().TruncateInt64())))) + // s.FundAcc(s.TestAccs[0], sdk.NewCoins(sdk.NewCoin(tokenInDenom, osmomath.NewInt(amountInFromRounding.Ceil().TruncateInt64())))) amountInCoin := sdk.NewCoin(pool.GetToken0(), amountOutRoundedUp) s.swapInGivenOutOneForZeroRight(poolId, amountInCoin, amountInToPreFund) @@ -1293,7 +1293,7 @@ func (s *KeeperTestSuite) TestSwaps_Contiguous_Initialized_TickSpacingOne() { // Validate that current tick and current liquidity are as expected. s.assertPoolTickEquals(poolId, expectedSwapEndTick) - s.assertPoolLiquidityEquals(poolId, expectedLiquidity.SDKDec()) + s.assertPoolLiquidityEquals(poolId, expectedLiquidity.Dec()) // Update the current sqrt price and tick for next swap. curSqrtPrice = updatedNextCurSqrtPrice @@ -1315,8 +1315,8 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_SwapToAllowedBoundaries() { var ( tokenZeroDenom = DefaultCoin0.Denom tokeOneDenom = DefaultCoin1.Denom - smallTokenOneCoinIn = sdk.NewCoin(tokeOneDenom, sdk.NewInt(100)) - smallTokenZeroCoinIn = sdk.NewCoin(tokenZeroDenom, sdk.NewInt(100)) + smallTokenOneCoinIn = sdk.NewCoin(tokeOneDenom, osmomath.NewInt(100)) + smallTokenZeroCoinIn = sdk.NewCoin(tokenZeroDenom, osmomath.NewInt(100)) ) // tests tick crossing behavior around min tick @@ -1341,7 +1341,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_SwapToAllowedBoundaries() { // Assert that min tick is crossed and liquidity is zero. s.assertPoolTickEquals(poolId, types.MinCurrentTick) - s.assertPoolLiquidityEquals(poolId, sdk.ZeroDec()) + s.assertPoolLiquidityEquals(poolId, osmomath.ZeroDec()) // Assert that full range positions are now inactive. s.assertPositionOutOfRange(poolId, types.MinInitializedTick, types.MaxTick) @@ -1351,9 +1351,9 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_SwapToAllowedBoundaries() { s.Require().NoError(err) // Validate cannot swap left again - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, smallTokenZeroCoinIn, tokeOneDenom, sdk.ZeroInt(), sdk.ZeroDec()) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, smallTokenZeroCoinIn, tokeOneDenom, osmomath.ZeroInt(), osmomath.ZeroDec()) s.Require().Error(err) - s.Require().ErrorContains(err, types.InvalidAmountCalculatedError{Amount: sdk.ZeroInt()}.Error()) + s.Require().ErrorContains(err, types.InvalidAmountCalculatedError{Amount: osmomath.ZeroInt()}.Error()) // Validate the ability to swap right s.swapOneForZeroRight(poolId, smallTokenOneCoinIn) @@ -1384,7 +1384,7 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_SwapToAllowedBoundaries() { // the liquidity net amounts on MaxTick are always negative. Therefore, when swapping one // for zero and crossing a max tick to be "within in", we always end up with a current liquidity of zero. s.assertPoolTickEquals(poolId, types.MaxTick) - s.assertPoolLiquidityEquals(poolId, sdk.ZeroDec()) + s.assertPoolLiquidityEquals(poolId, osmomath.ZeroDec()) // Assert that full range positions are now inactive. s.assertPositionOutOfRange(poolId, types.MinInitializedTick, types.MaxTick) @@ -1394,9 +1394,9 @@ func (s *KeeperTestSuite) TestSwapOutGivenIn_SwapToAllowedBoundaries() { s.Require().NoError(err) // Validate cannot swap right again - _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, smallTokenOneCoinIn, tokenZeroDenom, sdk.ZeroInt(), sdk.ZeroDec()) + _, err = s.App.ConcentratedLiquidityKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, smallTokenOneCoinIn, tokenZeroDenom, osmomath.ZeroInt(), osmomath.ZeroDec()) s.Require().Error(err) - s.Require().ErrorContains(err, types.InvalidAmountCalculatedError{Amount: sdk.ZeroInt()}.Error()) + s.Require().ErrorContains(err, types.InvalidAmountCalculatedError{Amount: osmomath.ZeroInt()}.Error()) // Validate the ability to swap left s.swapZeroForOneLeft(poolId, smallTokenZeroCoinIn) diff --git a/x/concentrated-liquidity/swapstrategy/export_test.go b/x/concentrated-liquidity/swapstrategy/export_test.go index 86bbe5e8e63..25b40459a51 100644 --- a/x/concentrated-liquidity/swapstrategy/export_test.go +++ b/x/concentrated-liquidity/swapstrategy/export_test.go @@ -1,11 +1,11 @@ package swapstrategy -import sdk "github.com/cosmos/cosmos-sdk/types" +import "github.com/osmosis-labs/osmosis/osmomath" -func ComputeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amountIn, amountSpecifiedRemaining, spreadFactor sdk.Dec) sdk.Dec { +func ComputeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amountIn, amountSpecifiedRemaining, spreadFactor osmomath.Dec) osmomath.Dec { return computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget, amountIn, amountSpecifiedRemaining, spreadFactor) } -func ComputeSpreadRewardChargeFromAmountIn(amountIn, spreadFactor sdk.Dec) sdk.Dec { +func ComputeSpreadRewardChargeFromAmountIn(amountIn, spreadFactor osmomath.Dec) osmomath.Dec { return computeSpreadRewardChargeFromAmountIn(amountIn, spreadFactor) } diff --git a/x/concentrated-liquidity/swapstrategy/one_for_zero.go b/x/concentrated-liquidity/swapstrategy/one_for_zero.go index 3e355d3148b..656ae7e1326 100644 --- a/x/concentrated-liquidity/swapstrategy/one_for_zero.go +++ b/x/concentrated-liquidity/swapstrategy/one_for_zero.go @@ -21,7 +21,7 @@ import ( type oneForZeroStrategy struct { sqrtPriceLimit osmomath.BigDec storeKey sdk.StoreKey - spreadFactor sdk.Dec + spreadFactor osmomath.Dec } var _ SwapStrategy = (*oneForZeroStrategy)(nil) @@ -57,15 +57,15 @@ func (s oneForZeroStrategy) GetSqrtTargetPrice(nextTickSqrtPrice osmomath.BigDec // // OneForZero details: // - oneForZeroStrategy assumes moving to the right of the current square root price. -func (s oneForZeroStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountOneInRemaining sdk.Dec) (osmomath.BigDec, sdk.Dec, sdk.Dec, sdk.Dec) { - liquidityBigDec := osmomath.BigDecFromSDKDec(liquidity) - amountOneInRemainingBigDec := osmomath.BigDecFromSDKDec(amountOneInRemaining) +func (s oneForZeroStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountOneInRemaining osmomath.Dec) (osmomath.BigDec, osmomath.Dec, osmomath.Dec, osmomath.Dec) { + liquidityBigDec := osmomath.BigDecFromDec(liquidity) + amountOneInRemainingBigDec := osmomath.BigDecFromDec(amountOneInRemaining) // Estimate the amount of token one needed until the target sqrt price is reached. amountOneIn := math.CalcAmount1Delta(liquidityBigDec, sqrtPriceTarget, sqrtPriceCurrent, true) // Calculate sqrtPriceNext on the amount of token remaining after spread reward. - amountOneInRemainingLessSpreadReward := amountOneInRemainingBigDec.MulTruncate(oneBigDec.Sub(osmomath.BigDecFromSDKDec(s.spreadFactor))) + amountOneInRemainingLessSpreadReward := amountOneInRemainingBigDec.MulTruncate(oneBigDec.Sub(osmomath.BigDecFromDec(s.spreadFactor))) var sqrtPriceNext osmomath.BigDec // If have more of the amount remaining after spread reward than estimated until target, @@ -90,14 +90,14 @@ func (s oneForZeroStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, amountZeroOut := math.CalcAmount0Delta(liquidityBigDec, sqrtPriceNext, sqrtPriceCurrent, false) // Round up to charge user more in pool's favor. - amountInDecFinal := amountOneIn.SDKDecRoundUp() + amountInDecFinal := amountOneIn.DecRoundUp() // Handle spread rewards. // Note that spread reward is always charged on the amount in. spreadRewardChargeTotal := computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget, amountInDecFinal, amountOneInRemaining, s.spreadFactor) // Round down amount out to give user less in pool's favor. - return sqrtPriceNext, amountInDecFinal, amountZeroOut.SDKDec(), spreadRewardChargeTotal + return sqrtPriceNext, amountInDecFinal, amountZeroOut.Dec(), spreadRewardChargeTotal } // ComputeSwapWithinBucketInGivenOut calculates the next sqrt price, the amount of token out consumed, the amount in to charge to the user for requested out, and total spread reward charge on token in. @@ -120,9 +120,9 @@ func (s oneForZeroStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, // // OneForZero details: // - oneForZeroStrategy assumes moving to the right of the current square root price. -func (s oneForZeroStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountZeroRemainingOut sdk.Dec) (osmomath.BigDec, sdk.Dec, sdk.Dec, sdk.Dec) { - liquidityBigDec := osmomath.BigDecFromSDKDec(liquidity) - amountZeroRemainingOutBigDec := osmomath.BigDecFromSDKDec(amountZeroRemainingOut) +func (s oneForZeroStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountZeroRemainingOut osmomath.Dec) (osmomath.BigDec, osmomath.Dec, osmomath.Dec, osmomath.Dec) { + liquidityBigDec := osmomath.BigDecFromDec(liquidity) + amountZeroRemainingOutBigDec := osmomath.BigDecFromDec(amountZeroRemainingOut) // Estimate the amount of token zero needed until the target sqrt price is reached. // N.B.: contrary to out given in, we do not round up because we do not want to exceed the initial amount out at the end. @@ -155,7 +155,7 @@ func (s oneForZeroStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, amountOneIn := math.CalcAmount1Delta(liquidityBigDec, sqrtPriceNext, sqrtPriceCurrent, true) // Round up to charge user more in pool's favor. - amountOneInFinal := amountOneIn.SDKDecRoundUp() + amountOneInFinal := amountOneIn.DecRoundUp() // Handle spread rewards. // Note that spread reward is always charged on the amount in. @@ -177,7 +177,7 @@ func (s oneForZeroStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, } // Round down amount out to give user less in pool's favor. - return sqrtPriceNext, amountZeroOut.SDKDec(), amountOneInFinal, spreadRewardChargeTotal + return sqrtPriceNext, amountZeroOut.Dec(), amountOneInFinal, spreadRewardChargeTotal } // InitializeNextTickIterator returns iterator that seeks to the next tick from the given tickIndex. @@ -230,7 +230,7 @@ func (s oneForZeroStrategy) InitializeNextTickIterator(ctx sdk.Context, poolId u // When we move to the right, we must be crossing lower ticks first where // liqudiity delta tracks the amount of liquidity being added. So the sign must be // positive. -func (s oneForZeroStrategy) SetLiquidityDeltaSign(deltaLiquidity sdk.Dec) sdk.Dec { +func (s oneForZeroStrategy) SetLiquidityDeltaSign(deltaLiquidity osmomath.Dec) osmomath.Dec { return deltaLiquidity } diff --git a/x/concentrated-liquidity/swapstrategy/one_for_zero_test.go b/x/concentrated-liquidity/swapstrategy/one_for_zero_test.go index 70e37c0c7bc..2c70a86af4b 100644 --- a/x/concentrated-liquidity/swapstrategy/one_for_zero_test.go +++ b/x/concentrated-liquidity/swapstrategy/one_for_zero_test.go @@ -1,29 +1,27 @@ package swapstrategy_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/math" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/swapstrategy" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) -func (suite *StrategyTestSuite) setupNewOneForZeroSwapStrategy(sqrtPriceLimit sdk.Dec, spread sdk.Dec) swapstrategy.SwapStrategy { +func (suite *StrategyTestSuite) setupNewOneForZeroSwapStrategy(sqrtPriceLimit osmomath.Dec, spread osmomath.Dec) swapstrategy.SwapStrategy { suite.SetupTest() - return swapstrategy.New(false, osmomath.BigDecFromSDKDec(sqrtPriceLimit), suite.App.GetKey(types.ModuleName), spread) + return swapstrategy.New(false, osmomath.BigDecFromDec(sqrtPriceLimit), suite.App.GetKey(types.ModuleName), spread) } func (suite *StrategyTestSuite) TestGetSqrtTargetPrice_OneForZero() { tests := map[string]struct { - sqrtPriceLimit sdk.Dec - nextTickSqrtPrice sdk.Dec - expectedResult sdk.Dec + sqrtPriceLimit osmomath.Dec + nextTickSqrtPrice osmomath.Dec + expectedResult osmomath.Dec }{ "nextTickSqrtPrice == sqrtPriceLimit -> returns either": { - sqrtPriceLimit: sdk.OneDec(), - nextTickSqrtPrice: sdk.OneDec(), - expectedResult: sdk.OneDec(), + sqrtPriceLimit: osmomath.OneDec(), + nextTickSqrtPrice: osmomath.OneDec(), + expectedResult: osmomath.OneDec(), }, "nextTickSqrtPrice > sqrtPriceLimit -> sqrtPriceLimit": { sqrtPriceLimit: three, @@ -40,8 +38,8 @@ func (suite *StrategyTestSuite) TestGetSqrtTargetPrice_OneForZero() { for name, tc := range tests { suite.Run(name, func() { strategy := suite.setupNewOneForZeroSwapStrategy(tc.sqrtPriceLimit, zero) - actualSqrtTargetPrice := strategy.GetSqrtTargetPrice(osmomath.BigDecFromSDKDec(tc.nextTickSqrtPrice)) - suite.Require().Equal(osmomath.BigDecFromSDKDec(tc.expectedResult), actualSqrtTargetPrice) + actualSqrtTargetPrice := strategy.GetSqrtTargetPrice(osmomath.BigDecFromDec(tc.nextTickSqrtPrice)) + suite.Require().Equal(osmomath.BigDecFromDec(tc.expectedResult), actualSqrtTargetPrice) }) } } @@ -53,10 +51,10 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_OneForZero() { sqrtPriceNext = defaultSqrtPriceUpper // liquidity * (sqrtPriceNext - sqrtPriceCurrent) / (sqrtPriceNext * sqrtPriceCurrent) - actualAmountZeroTargetNotReachedBigDec = osmomath.MustNewDecFromStr("13369.979999999989602986240259440383244931") + actualAmountZeroTargetNotReachedBigDec = osmomath.MustNewBigDecFromStr("13369.979999999989602986240259440383244931") - sqrt = func(x int64) sdk.Dec { - sqrt, _ := osmomath.MonotonicSqrt(sdk.NewDec(x)) + sqrt = func(x int64) osmomath.Dec { + sqrt, _ := osmomath.MonotonicSqrt(osmomath.NewDec(x)) return sqrt } ) @@ -64,117 +62,117 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_OneForZero() { tests := map[string]struct { // TODO revisit each test case and review values sqrtPriceCurrent osmomath.BigDec - sqrtPriceTarget sdk.Dec - liquidity sdk.Dec - amountOneInRemaining sdk.Dec - spreadFactor sdk.Dec + sqrtPriceTarget osmomath.Dec + liquidity osmomath.Dec + amountOneInRemaining osmomath.Dec + spreadFactor osmomath.Dec expectedSqrtPriceNext osmomath.BigDec - expectedAmountInConsumed sdk.Dec - expectedAmountOut sdk.Dec - expectedSpreadRewardChargeTotal sdk.Dec + expectedAmountInConsumed osmomath.Dec + expectedAmountOut osmomath.Dec + expectedSpreadRewardChargeTotal osmomath.Dec }{ "1: no spread factor - reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sqrtPriceCurrent), + sqrtPriceCurrent: osmomath.BigDecFromDec(sqrtPriceCurrent), sqrtPriceTarget: sqrtPriceNext, liquidity: defaultLiquidity, // Add 100. - amountOneInRemaining: defaultAmountOne.Add(sdk.NewDec(100)), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: defaultAmountOne.Add(osmomath.NewDec(100)), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: osmomath.BigDecFromSDKDec(sqrtPriceNext), + expectedSqrtPriceNext: osmomath.BigDecFromDec(sqrtPriceNext), // Reached target, so 100 is not consumed. expectedAmountInConsumed: defaultAmountOne.Ceil(), // liquidity * (sqrtPriceNext - sqrtPriceCurrent) / (sqrtPriceNext * sqrtPriceCurrent) - expectedAmountOut: defaultAmountZeroBigDec.SDKDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOut: defaultAmountZeroBigDec.Dec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "2: no spread factor - do not reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sqrtPriceCurrent), + sqrtPriceCurrent: osmomath.BigDecFromDec(sqrtPriceCurrent), sqrtPriceTarget: sqrtPriceNext, liquidity: defaultLiquidity, - amountOneInRemaining: defaultAmountOne.Sub(sdk.NewDec(100)), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: defaultAmountOne.Sub(osmomath.NewDec(100)), + spreadFactor: osmomath.ZeroDec(), // sqrtPriceCurrent + round_osmo_prec_down(token_in / liquidity) // sqrtPriceCurrent + token_in / liquidity - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("70.710678085714122880779431539932994712"), - expectedAmountInConsumed: defaultAmountOne.Sub(sdk.NewDec(100)).Ceil(), - expectedAmountOut: actualAmountZeroTargetNotReachedBigDec.SDKDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("70.710678085714122880779431539932994712"), + expectedAmountInConsumed: defaultAmountOne.Sub(osmomath.NewDec(100)).Ceil(), + expectedAmountOut: actualAmountZeroTargetNotReachedBigDec.Dec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "3: 3% spread factor - reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sqrtPriceCurrent), + sqrtPriceCurrent: osmomath.BigDecFromDec(sqrtPriceCurrent), sqrtPriceTarget: sqrtPriceNext, liquidity: defaultLiquidity, - amountOneInRemaining: defaultAmountOne.Add(sdk.NewDec(100)).Quo(sdk.OneDec().Sub(defaultSpreadReward)), + amountOneInRemaining: defaultAmountOne.Add(osmomath.NewDec(100)).Quo(osmomath.OneDec().Sub(defaultSpreadReward)), spreadFactor: defaultSpreadReward, - expectedSqrtPriceNext: osmomath.BigDecFromSDKDec(sqrtPriceNext), + expectedSqrtPriceNext: osmomath.BigDecFromDec(sqrtPriceNext), expectedAmountInConsumed: defaultAmountOne.Ceil(), // liquidity * (sqrtPriceNext - sqrtPriceCurrent) / (sqrtPriceNext * sqrtPriceCurrent) - expectedAmountOut: defaultAmountZeroBigDec.SDKDec(), // subtracting smallest dec to account for truncations in favor of the pool. + expectedAmountOut: defaultAmountZeroBigDec.Dec(), // subtracting smallest dec to account for truncations in favor of the pool. expectedSpreadRewardChargeTotal: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(defaultAmountOne.Ceil(), defaultSpreadReward), }, "4: 3% spread factor - do not reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sqrtPriceCurrent), + sqrtPriceCurrent: osmomath.BigDecFromDec(sqrtPriceCurrent), sqrtPriceTarget: sqrtPriceNext, liquidity: defaultLiquidity, - amountOneInRemaining: defaultAmountOne.Sub(sdk.NewDec(100)).QuoRoundUp(sdk.OneDec().Sub(defaultSpreadReward)), + amountOneInRemaining: defaultAmountOne.Sub(osmomath.NewDec(100)).QuoRoundUp(osmomath.OneDec().Sub(defaultSpreadReward)), spreadFactor: defaultSpreadReward, // sqrtPriceCurrent + round_osmo_prec_down(round_osmo_prec_down(round_sdk_prec_up(token_in / (1 - spreadFactor )) * (1 - spreadFactor)) / liquidity) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("70.710678085714122880779431540005464097"), - expectedAmountInConsumed: defaultAmountOne.Sub(sdk.NewDec(100)).Ceil(), - expectedAmountOut: actualAmountZeroTargetNotReachedBigDec.SDKDec(), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("70.710678085714122880779431540005464097"), + expectedAmountInConsumed: defaultAmountOne.Sub(osmomath.NewDec(100)).Ceil(), + expectedAmountOut: actualAmountZeroTargetNotReachedBigDec.Dec(), // Difference between given amount remaining in and amount in actually consumed which qpproximately equals to spread factor. - expectedSpreadRewardChargeTotal: defaultAmountOne.Sub(sdk.NewDec(100)).Quo(sdk.OneDec().Sub(defaultSpreadReward)).Sub(defaultAmountOne.Sub(sdk.NewDec(100)).Ceil()), + expectedSpreadRewardChargeTotal: defaultAmountOne.Sub(osmomath.NewDec(100)).Quo(osmomath.OneDec().Sub(defaultSpreadReward)).Sub(defaultAmountOne.Sub(osmomath.NewDec(100)).Ceil()), }, "5: custom amounts at high price levels - reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sqrt(100_000_000)), + sqrtPriceCurrent: osmomath.BigDecFromDec(sqrt(100_000_000)), sqrtPriceTarget: sqrt(100_000_100), - liquidity: math.GetLiquidityFromAmounts(osmomath.OneDec(), osmomath.BigDecFromSDKDec(sqrt(100_000_000)), osmomath.BigDecFromSDKDec(sqrt(100_000_100)), defaultAmountZero.TruncateInt(), defaultAmountOne.TruncateInt()), + liquidity: math.GetLiquidityFromAmounts(osmomath.OneBigDec(), osmomath.BigDecFromDec(sqrt(100_000_000)), osmomath.BigDecFromDec(sqrt(100_000_100)), defaultAmountZero.TruncateInt(), defaultAmountOne.TruncateInt()), // this value is exactly enough to reach the target - amountOneInRemaining: sdk.NewDec(1336900668450), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: osmomath.NewDec(1336900668450), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: osmomath.BigDecFromSDKDec(sqrt(100_000_100)), + expectedSqrtPriceNext: osmomath.BigDecFromDec(sqrt(100_000_100)), - expectedAmountInConsumed: sdk.NewDec(1336900668450), + expectedAmountInConsumed: osmomath.NewDec(1336900668450), // subtracting smallest dec as a rounding error in favor of the pool. - expectedAmountOut: defaultAmountZero.TruncateDec().Sub(sdk.SmallestDec()), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOut: defaultAmountZero.TruncateDec().Sub(osmomath.SmallestDec()), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "6: valid zero difference between sqrt price current and sqrt price next, amount zero in is charged": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sdk.MustNewDecFromStr("70.710663976517714496")), - sqrtPriceTarget: sdk.MustNewDecFromStr("70.710663976517714496"), - liquidity: sdk.MustNewDecFromStr("412478955692135.521499519343199632"), + sqrtPriceCurrent: osmomath.BigDecFromDec(osmomath.MustNewDecFromStr("70.710663976517714496")), + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.710663976517714496"), + liquidity: osmomath.MustNewDecFromStr("412478955692135.521499519343199632"), - amountOneInRemaining: sdk.NewDec(5416667230), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: osmomath.NewDec(5416667230), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("70.710663976517714496"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("70.710663976517714496"), - expectedAmountInConsumed: sdk.ZeroDec(), - expectedAmountOut: sdk.ZeroDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountInConsumed: osmomath.ZeroDec(), + expectedAmountOut: osmomath.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "7: invalid zero difference between sqrt price current and sqrt price next due to precision loss, full amount remaining in is charged and amount out calculated from sqrt price": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(sdk.MustNewDecFromStr("0.000001000049998750")), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998751"), - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + sqrtPriceCurrent: osmomath.BigDecFromDec(osmomath.MustNewDecFromStr("0.000001000049998750")), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998751"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountOneInRemaining: sdk.NewDec(99), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: osmomath.NewDec(99), + spreadFactor: osmomath.ZeroDec(), // computed with x/concentrated-liquidity/python/clmath.py // sqrtPriceCurrent + token_in / liquidity - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.0000010000499987509899752698"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.0000010000499987509899752698"), - expectedAmountInConsumed: sdk.NewDec(99), + expectedAmountInConsumed: osmomath.NewDec(99), // liquidity * (sqrtPriceNext - sqrtPriceCurrent) / (sqrtPriceNext * sqrtPriceCurrent) // calculated with x/concentrated-liquidity/python/clmath.py // diff = (sqrtPriceNext - sqrtPriceCurrent) @@ -182,25 +180,25 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_OneForZero() { // mul = (sqrtPriceNext * sqrtPriceCurrent) // mul = round_decimal(mul, 36, ROUND_CEILING) (0.000000000001000100000000865026329827) // round_decimal(liquidity * diff / mul, 36, ROUND_FLOOR) - expectedAmountOut: osmomath.MustNewDecFromStr("98990100989815.389417309844929293132374729779331247").SDKDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOut: osmomath.MustNewBigDecFromStr("98990100989815.389417309844929293132374729779331247").Dec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "8: invalid zero difference between sqrt price current and sqrt price next due to precision loss. Returns 0 for amounts out. Note that the caller should detect this and fail.": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(types.MaxSqrtPrice).Sub(osmomath.SmallestDec()), + sqrtPriceCurrent: osmomath.BigDecFromDec(types.MaxSqrtPrice).Sub(osmomath.SmallestBigDec()), sqrtPriceTarget: types.MaxSqrtPrice, - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountOneInRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountOneInRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestDec()), + expectedSqrtPriceNext: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestBigDec()), // Note, this case would lead to an infinite loop or no progress made in swaps. // As a result, the caller should detect this and fail. - expectedAmountInConsumed: sdk.ZeroDec(), - expectedAmountOut: sdk.ZeroDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountInConsumed: osmomath.ZeroDec(), + expectedAmountOut: osmomath.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, } @@ -208,7 +206,7 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_OneForZero() { tc := tc suite.Run(name, func() { strategy := suite.setupNewOneForZeroSwapStrategy(types.MaxSqrtPrice, tc.spreadFactor) - sqrtPriceNext, amountInConsumed, amountZeroOut, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketOutGivenIn(tc.sqrtPriceCurrent, osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountOneInRemaining) + sqrtPriceNext, amountInConsumed, amountZeroOut, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketOutGivenIn(tc.sqrtPriceCurrent, osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountOneInRemaining) suite.Require().Equal(tc.expectedSqrtPriceNext, sqrtPriceNext) suite.Require().Equal(tc.expectedAmountInConsumed, amountInConsumed) @@ -224,35 +222,35 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { // than expected. As a result, we recalculate the amount out and amount in // necessary to reach the earlier target. // sqrtPriceNext = liquidity * sqrtPriceCurrent / (liquidity - tokenOut * sqrtPriceCurrent) - sqrtPriceTargetNotReached = osmomath.MustNewDecFromStr("70.709031125539448609385160972133434677") + sqrtPriceTargetNotReached = osmomath.MustNewBigDecFromStr("70.709031125539448609385160972133434677") // liq * (sqrtPriceNext - sqrtPriceCurrent) - amountOneTargetNotReached = sdk.MustNewDecFromStr("61829304.427824073089251659") + amountOneTargetNotReached = osmomath.MustNewDecFromStr("61829304.427824073089251659") ) // sqrtPriceCurrent, sqrtPriceTarget, liquidity are all set to defaults defined above. tests := map[string]struct { sqrtPriceCurrent osmomath.BigDec - sqrtPriceTarget sdk.Dec - liquidity sdk.Dec + sqrtPriceTarget osmomath.Dec + liquidity osmomath.Dec - amountZeroOutRemaining sdk.Dec - spreadFactor sdk.Dec + amountZeroOutRemaining osmomath.Dec + spreadFactor osmomath.Dec expectedSqrtPriceNext osmomath.BigDec - expectedAmountZeroOutConsumed sdk.Dec - expectedAmountOneIn sdk.Dec - expectedSpreadRewardChargeTotal sdk.Dec + expectedAmountZeroOutConsumed osmomath.Dec + expectedAmountOneIn osmomath.Dec + expectedSpreadRewardChargeTotal osmomath.Dec }{ "1: no spread reward - reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(defaultSqrtPriceLower), + sqrtPriceCurrent: osmomath.BigDecFromDec(defaultSqrtPriceLower), sqrtPriceTarget: defaultSqrtPriceUpper, liquidity: defaultLiquidity, // Add 100. - amountZeroOutRemaining: defaultAmountZero.Add(sdk.NewDec(100)), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: defaultAmountZero.Add(osmomath.NewDec(100)), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: osmomath.BigDecFromSDKDec(defaultSqrtPriceUpper), + expectedSqrtPriceNext: osmomath.BigDecFromDec(defaultSqrtPriceUpper), // Reached target, so 100 is not consumed. // computed with x/concentrated-liquidity/python/clmath.py // (liquidity * (sqrtPriceTarget - sqrtPriceCurrent)) / (sqrtPriceCurrent * sqrtPriceTarget) @@ -267,32 +265,32 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { // Added 1 ULP per calculations above expectedAmountZeroOutConsumed: defaultAmountZero.Add(oneULPDec), expectedAmountOneIn: defaultAmountOne.Ceil(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "2: no spread reward - do not reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(defaultSqrtPriceLower), + sqrtPriceCurrent: osmomath.BigDecFromDec(defaultSqrtPriceLower), sqrtPriceTarget: defaultSqrtPriceUpper, liquidity: defaultLiquidity, - amountZeroOutRemaining: defaultAmountZero.Sub(sdk.NewDec(1000)), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: defaultAmountZero.Sub(osmomath.NewDec(1000)), + spreadFactor: osmomath.ZeroDec(), expectedSqrtPriceNext: sqrtPriceTargetNotReached, - expectedAmountZeroOutConsumed: defaultAmountZero.Sub(sdk.NewDec(1000)), + expectedAmountZeroOutConsumed: defaultAmountZero.Sub(osmomath.NewDec(1000)), expectedAmountOneIn: amountOneTargetNotReached.Ceil(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "3: 3% spread reward - reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(defaultSqrtPriceLower), + sqrtPriceCurrent: osmomath.BigDecFromDec(defaultSqrtPriceLower), sqrtPriceTarget: defaultSqrtPriceUpper, liquidity: defaultLiquidity, - amountZeroOutRemaining: defaultAmountZero.Quo(sdk.OneDec().Sub(defaultSpreadReward)), + amountZeroOutRemaining: defaultAmountZero.Quo(osmomath.OneDec().Sub(defaultSpreadReward)), spreadFactor: defaultSpreadReward, - expectedSqrtPriceNext: osmomath.BigDecFromSDKDec(defaultSqrtPriceUpper), + expectedSqrtPriceNext: osmomath.BigDecFromDec(defaultSqrtPriceUpper), // Reached target, so 100 is not consumed. // computed with x/concentrated-liquidity/python/clmath.py // (liquidity * (sqrtPriceTarget - sqrtPriceCurrent)) / (sqrtPriceCurrent * sqrtPriceTarget) @@ -310,45 +308,45 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { expectedSpreadRewardChargeTotal: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(defaultAmountOne.Ceil(), defaultSpreadReward), }, "4: 3% spread reward - do not reach target": { - sqrtPriceCurrent: osmomath.BigDecFromSDKDec(defaultSqrtPriceLower), + sqrtPriceCurrent: osmomath.BigDecFromDec(defaultSqrtPriceLower), sqrtPriceTarget: defaultSqrtPriceUpper, liquidity: defaultLiquidity, - amountZeroOutRemaining: defaultAmountZero.Sub(sdk.NewDec(1000)), + amountZeroOutRemaining: defaultAmountZero.Sub(osmomath.NewDec(1000)), spreadFactor: defaultSpreadReward, expectedSqrtPriceNext: sqrtPriceTargetNotReached, - expectedAmountZeroOutConsumed: defaultAmountZero.Sub(sdk.NewDec(1000)), + expectedAmountZeroOutConsumed: defaultAmountZero.Sub(osmomath.NewDec(1000)), expectedAmountOneIn: amountOneTargetNotReached.Ceil(), expectedSpreadRewardChargeTotal: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(amountOneTargetNotReached.Ceil(), defaultSpreadReward), }, "6: valid zero difference between sqrt price current and sqrt price next, amount zero in is charged": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("70.710663976517714496"), - sqrtPriceTarget: sdk.MustNewDecFromStr("70.710663976517714496"), - liquidity: sdk.MustNewDecFromStr("412478955692135.521499519343199632"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("70.710663976517714496"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.710663976517714496"), + liquidity: osmomath.MustNewDecFromStr("412478955692135.521499519343199632"), - amountZeroOutRemaining: sdk.NewDec(5416667230), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: osmomath.NewDec(5416667230), + spreadFactor: osmomath.ZeroDec(), - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("70.710663976517714496"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("70.710663976517714496"), - expectedAmountZeroOutConsumed: sdk.ZeroDec(), - expectedAmountOneIn: sdk.ZeroDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountZeroOutConsumed: osmomath.ZeroDec(), + expectedAmountOneIn: osmomath.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "7: difference between sqrt prices is under BigDec ULP. Rounding causes amount consumed be greater than amount remaining": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("0.000001000049998750"), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998751"), - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("0.000001000049998750"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998751"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountZeroOutRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), // computed with x/concentrated-liquidity/python/clmath.py // get_next_sqrt_price_from_amount0_round_up(liquidity, sqrtPriceCurrent, tokenOut) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.000001000049998750000000000000000001"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.000001000049998750000000000000000001"), // computed with x/concentrated-liquidity/python/clmath.py // calc_amount_zero_delta(liquidity, sqrtPriceCurrent, Decimal("0.000001000049998750000000000000000001"), False) @@ -365,20 +363,20 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { // This can lead to negative amount zero in swaps. // As a result, force the amountOut to be amountZeroOutRemaining. // See code comments in ComputeSwapWithinBucketInGivenOut(...) - expectedAmountZeroOutConsumed: sdk.SmallestDec(), + expectedAmountZeroOutConsumed: osmomath.SmallestDec(), // calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, True) // math.ceil(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, True)) - expectedAmountOneIn: sdk.OneDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneIn: osmomath.OneDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, - "8: swapping 1 ULP of sdk.Dec leads to zero out being consumed (no progress made)": { + "8: swapping 1 ULP of osmomath.Dec leads to zero out being consumed (no progress made)": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestDec()), + sqrtPriceCurrent: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestBigDec()), sqrtPriceTarget: types.MaxSqrtPrice, - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountZeroOutRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), // product_num = liquidity * sqrtPriceCurrent // product_den = tokenOut * sqrtPriceCurrent @@ -386,20 +384,20 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { // round_osmo_prec_up(product_num / (liquidity - product_den)) expectedSqrtPriceNext: types.MaxSqrtPriceBigDec, - expectedAmountZeroOutConsumed: sdk.ZeroDec(), + expectedAmountZeroOutConsumed: osmomath.ZeroDec(), // Rounded up to 1. - expectedAmountOneIn: sdk.NewDec(1), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneIn: osmomath.NewDec(1), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, - "9: swapping 1 ULP of sdk.Dec with high liquidity leads to an amount consumed being greater than amount remaining": { + "9: swapping 1 ULP of osmomath.Dec with high liquidity leads to an amount consumed being greater than amount remaining": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestDec()), + sqrtPriceCurrent: types.MaxSqrtPriceBigDec.Sub(osmomath.SmallestBigDec()), sqrtPriceTarget: types.MaxSqrtPrice, // Choose large liquidity on purpose - liquidity: sdk.MustNewDecFromStr("9999999999999999999999999999999999999999999999999999999999.937822606808718081"), + liquidity: osmomath.MustNewDecFromStr("9999999999999999999999999999999999999999999999999999999999.937822606808718081"), - amountZeroOutRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountZeroOutRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), // product_num = liquidity * sqrtPriceCurrent // product_den = tokenOut * sqrtPriceCurrent @@ -413,18 +411,18 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_OneForZero() { // Results in 0.0000000000000001 // Note, that this amount is greater than the amount remaining but amountRemaining gets chosen over it // See code comments in ComputeSwapWithinBucketInGivenOut(...) - expectedAmountZeroOutConsumed: sdk.SmallestDec(), + expectedAmountZeroOutConsumed: osmomath.SmallestDec(), // calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, True) - expectedAmountOneIn: sdk.MustNewDecFromStr("10000000000000000000000"), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneIn: osmomath.MustNewDecFromStr("10000000000000000000000"), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, } for name, tc := range tests { suite.Run(name, func() { strategy := suite.setupNewOneForZeroSwapStrategy(types.MaxSqrtPrice, tc.spreadFactor) - sqrtPriceNext, amountZeroOutConsumed, amountOneIn, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketInGivenOut(tc.sqrtPriceCurrent, osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountZeroOutRemaining) + sqrtPriceNext, amountZeroOutConsumed, amountOneIn, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketInGivenOut(tc.sqrtPriceCurrent, osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountZeroOutRemaining) suite.Require().Equal(tc.expectedSqrtPriceNext, sqrtPriceNext) suite.Require().Equal(tc.expectedAmountZeroOutConsumed.String(), amountZeroOutConsumed.String()) diff --git a/x/concentrated-liquidity/swapstrategy/spread_rewards.go b/x/concentrated-liquidity/swapstrategy/spread_rewards.go index c792776a21a..a99e31d894a 100644 --- a/x/concentrated-liquidity/swapstrategy/spread_rewards.go +++ b/x/concentrated-liquidity/swapstrategy/spread_rewards.go @@ -3,7 +3,7 @@ package swapstrategy import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) // computeSpreadRewardChargePerSwapStepOutGivenIn returns the total spread factor charge per swap step given the parameters. @@ -22,8 +22,8 @@ import ( // // If spread factor is negative, it panics. // If spread factor is 0, returns 0. Otherwise, computes and returns the spread factor charge per step. -func computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amountIn, amountSpecifiedRemaining, spreadFactor sdk.Dec) sdk.Dec { - spreadRewardChargeTotal := sdk.ZeroDec() +func computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amountIn, amountSpecifiedRemaining, spreadFactor osmomath.Dec) osmomath.Dec { + spreadRewardChargeTotal := osmomath.ZeroDec() if spreadFactor.IsNegative() { // This should never happen but is added as a defense-in-depth measure. @@ -61,6 +61,6 @@ func computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget bool, amoun // Computes amountIn * spreadFactor / (1 - spreadFactor) where math operations round up // at precision end. This is necessary to ensure that the spread factor charge is always // rounded in favor of the pool. -func computeSpreadRewardChargeFromAmountIn(amountIn sdk.Dec, spreadFactor sdk.Dec) sdk.Dec { - return amountIn.MulRoundUp(spreadFactor).QuoRoundupMut(sdk.OneDec().SubMut(spreadFactor)) +func computeSpreadRewardChargeFromAmountIn(amountIn osmomath.Dec, spreadFactor osmomath.Dec) osmomath.Dec { + return amountIn.MulRoundUp(spreadFactor).QuoRoundupMut(osmomath.OneDec().SubMut(spreadFactor)) } diff --git a/x/concentrated-liquidity/swapstrategy/spread_rewards_test.go b/x/concentrated-liquidity/swapstrategy/spread_rewards_test.go index 934fd8f2a64..847d305017c 100644 --- a/x/concentrated-liquidity/swapstrategy/spread_rewards_test.go +++ b/x/concentrated-liquidity/swapstrategy/spread_rewards_test.go @@ -1,62 +1,60 @@ package swapstrategy_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/swapstrategy" ) -var onePercentSpreadFactor = sdk.NewDecWithPrec(1, 2) +var onePercentSpreadFactor = osmomath.NewDecWithPrec(1, 2) func (suite *StrategyTestSuite) TestComputespreadRewardChargePerSwapStepOutGivenIn() { tests := map[string]struct { - currentSqrtPrice sdk.Dec + currentSqrtPrice osmomath.Dec hasReachedTarget bool - amountIn sdk.Dec - amountSpecifiedRemaining sdk.Dec - spreadFactor sdk.Dec + amountIn osmomath.Dec + amountSpecifiedRemaining osmomath.Dec + spreadFactor osmomath.Dec - expectedspreadRewardCharge sdk.Dec + expectedspreadRewardCharge osmomath.Dec expectPanic bool }{ "reached target -> charge spread factor on amount in": { hasReachedTarget: true, - amountIn: sdk.NewDec(100), + amountIn: osmomath.NewDec(100), amountSpecifiedRemaining: five, spreadFactor: onePercentSpreadFactor, // amount in * spread factor / (1 - spread factor) - expectedspreadRewardCharge: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(sdk.NewDec(100), onePercentSpreadFactor), + expectedspreadRewardCharge: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(osmomath.NewDec(100), onePercentSpreadFactor), }, "did not reach target -> charge spread factor on the difference between amount remaining and amount in": { hasReachedTarget: false, amountIn: five, - amountSpecifiedRemaining: sdk.NewDec(100), + amountSpecifiedRemaining: osmomath.NewDec(100), spreadFactor: onePercentSpreadFactor, - expectedspreadRewardCharge: sdk.MustNewDecFromStr("95"), + expectedspreadRewardCharge: osmomath.MustNewDecFromStr("95"), }, "zero spread factor": { - hasReachedTarget: true, - amountIn: five, - amountSpecifiedRemaining: sdk.NewDec(100), - spreadFactor: sdk.ZeroDec(), - - expectedspreadRewardCharge: sdk.ZeroDec(), + hasReachedTarget: true, + amountIn: five, + amountSpecifiedRemaining: osmomath.NewDec(100), + spreadFactor: osmomath.ZeroDec(), + expectedspreadRewardCharge: osmomath.ZeroDec(), }, "negative spread factor - panic": { hasReachedTarget: false, - amountIn: sdk.NewDec(100), + amountIn: osmomath.NewDec(100), amountSpecifiedRemaining: five, - spreadFactor: sdk.OneDec().Neg(), + spreadFactor: osmomath.OneDec().Neg(), expectPanic: true, }, "amount specified remaining < amount in leads to negative spread factor - panic": { hasReachedTarget: false, - amountIn: sdk.NewDec(102), - amountSpecifiedRemaining: sdk.NewDec(101), + amountIn: osmomath.NewDec(102), + amountSpecifiedRemaining: osmomath.NewDec(101), spreadFactor: onePercentSpreadFactor, // 101 - 102 = -1 -> panic diff --git a/x/concentrated-liquidity/swapstrategy/swap_strategy.go b/x/concentrated-liquidity/swapstrategy/swap_strategy.go index 66e2e41d3fe..fa2a02ec0f3 100644 --- a/x/concentrated-liquidity/swapstrategy/swap_strategy.go +++ b/x/concentrated-liquidity/swapstrategy/swap_strategy.go @@ -34,7 +34,7 @@ type SwapStrategy interface { // * amountOutComputed is the amount of token out computed. It is the amount of token out to return to the user. // * spreadRewardChargeTotal is the total spread reward charge. The spread reward is charged on the amount of token in. // See oneForZeroStrategy or zeroForOneStrategy for implementation details. - ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountRemainingIn sdk.Dec) (sqrtPriceNext osmomath.BigDec, amountInConsumed, amountOutComputed, spreadRewardChargeTotal sdk.Dec) + ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountRemainingIn osmomath.Dec) (sqrtPriceNext osmomath.BigDec, amountInConsumed, amountOutComputed, spreadRewardChargeTotal osmomath.Dec) // ComputeSwapWithinBucketInGivenOut calculates the next sqrt price, the amount of token out consumed, the amount in to charge to the user for requested out, and total spread reward charge on token in. // This assumes swapping over a single bucket where the liqudiity stays constant until we cross the next initialized tick of the next bucket. // Parameters: @@ -52,7 +52,7 @@ type SwapStrategy interface { // * amountInComputed is the amount of token in computed. It is the amount of token in to charge to the user for the desired amount out. // * spreadRewardChargeTotal is the total spread reward charge. The spread reward is charged on the amount of token in. // See oneForZeroStrategy or zeroForOneStrategy for implementation details. - ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountRemainingOut sdk.Dec) (sqrtPriceNext osmomath.BigDec, amountOutConsumed, amountInComputed, spreadRewardChargeTotal sdk.Dec) + ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountRemainingOut osmomath.Dec) (sqrtPriceNext osmomath.BigDec, amountOutConsumed, amountInComputed, spreadRewardChargeTotal osmomath.Dec) // InitializeNextTickIterator returns iterator that seeks to the next tick from the given tickIndex. // If nex tick relative to tickINdex does not exist in the store, it will return an invalid iterator. // See oneForZeroStrategy or zeroForOneStrategy for implementation details. @@ -65,7 +65,7 @@ type SwapStrategy interface { // going up, and subtracted when the price crosses the upper tick // going up. As a result, the sign depends on the direction we are moving. // See oneForZeroStrategy or zeroForOneStrategy for implementation details. - SetLiquidityDeltaSign(liquidityDelta sdk.Dec) sdk.Dec + SetLiquidityDeltaSign(liquidityDelta osmomath.Dec) osmomath.Dec // UpdateTickAfterCrossing updates the next tick after crossing // to satisfy our "position in-range" invariant which is: // lower tick <= current tick < upper tick @@ -88,13 +88,13 @@ type SwapStrategy interface { } var ( - oneBigDec = osmomath.OneDec() + oneBigDec = osmomath.OneBigDec() ) // New returns a swap strategy based on the provided zeroForOne parameter // with sqrtPriceLimit for the maximum square root price until which to perform // the swap and the stor key of the module that stores swap data. -func New(zeroForOne bool, sqrtPriceLimit osmomath.BigDec, storeKey sdk.StoreKey, spreadFactor sdk.Dec) SwapStrategy { +func New(zeroForOne bool, sqrtPriceLimit osmomath.BigDec, storeKey sdk.StoreKey, spreadFactor osmomath.Dec) SwapStrategy { if zeroForOne { return &zeroForOneStrategy{sqrtPriceLimit: sqrtPriceLimit, storeKey: storeKey, spreadFactor: spreadFactor} } @@ -104,19 +104,19 @@ func New(zeroForOne bool, sqrtPriceLimit osmomath.BigDec, storeKey sdk.StoreKey, // GetPriceLimit returns the price limit based on which token is being swapped in. // If zero in for one out, the price is decreasing. Therefore, min spot price is the limit. // If one in for zero out, the price is increasing. Therefore, max spot price is the limit. -func GetPriceLimit(zeroForOne bool) sdk.Dec { +func GetPriceLimit(zeroForOne bool) osmomath.Dec { if zeroForOne { return types.MinSpotPrice } return types.MaxSpotPrice } -func GetSqrtPriceLimit(priceLimit sdk.Dec, zeroForOne bool) (osmomath.BigDec, error) { +func GetSqrtPriceLimit(priceLimit osmomath.Dec, zeroForOne bool) (osmomath.BigDec, error) { if priceLimit.IsZero() { if zeroForOne { - return osmomath.BigDecFromSDKDec(types.MinSqrtPrice), nil + return osmomath.BigDecFromDec(types.MinSqrtPrice), nil } - return osmomath.BigDecFromSDKDec(types.MaxSqrtPrice), nil + return osmomath.BigDecFromDec(types.MaxSqrtPrice), nil } sqrtPriceLimit, err := osmomath.MonotonicSqrt(priceLimit) @@ -124,5 +124,5 @@ func GetSqrtPriceLimit(priceLimit sdk.Dec, zeroForOne bool) (osmomath.BigDec, er return osmomath.BigDec{}, err } - return osmomath.BigDecFromSDKDec(sqrtPriceLimit), nil + return osmomath.BigDecFromDec(sqrtPriceLimit), nil } diff --git a/x/concentrated-liquidity/swapstrategy/swap_strategy_test.go b/x/concentrated-liquidity/swapstrategy/swap_strategy_test.go index 9567e034e4a..7b5133e408f 100644 --- a/x/concentrated-liquidity/swapstrategy/swap_strategy_test.go +++ b/x/concentrated-liquidity/swapstrategy/swap_strategy_test.go @@ -31,24 +31,24 @@ const ( ) var ( - zero = sdk.NewDec(0) - one = sdk.NewDec(1) - two = sdk.NewDec(2) - three = sdk.NewDec(3) - four = sdk.NewDec(4) - five = sdk.NewDec(5) - sqrt5000 = sdk.MustNewDecFromStr("70.710678118654752440") // 5000 - defaultSqrtPriceLower = sdk.MustNewDecFromStr("70.688664163408836321") // approx 4996.89 + zero = osmomath.NewDec(0) + one = osmomath.NewDec(1) + two = osmomath.NewDec(2) + three = osmomath.NewDec(3) + four = osmomath.NewDec(4) + five = osmomath.NewDec(5) + sqrt5000 = osmomath.MustNewDecFromStr("70.710678118654752440") // 5000 + defaultSqrtPriceLower = osmomath.MustNewDecFromStr("70.688664163408836321") // approx 4996.89 defaultSqrtPriceUpper = sqrt5000 - defaultAmountOne = sdk.MustNewDecFromStr("66829187.967824033199646915") - defaultAmountZero = sdk.MustNewDecFromStr("13369.999999999998920002") - defaultAmountZeroBigDec = osmomath.MustNewDecFromStr("13369.999999999998920003259839786649584880") - defaultLiquidity = sdk.MustNewDecFromStr("3035764687.503020836176699298") - defaultSpreadReward = sdk.MustNewDecFromStr("0.03") + defaultAmountOne = osmomath.MustNewDecFromStr("66829187.967824033199646915") + defaultAmountZero = osmomath.MustNewDecFromStr("13369.999999999998920002") + defaultAmountZeroBigDec = osmomath.MustNewBigDecFromStr("13369.999999999998920003259839786649584880") + defaultLiquidity = osmomath.MustNewDecFromStr("3035764687.503020836176699298") + defaultSpreadReward = osmomath.MustNewDecFromStr("0.03") defaultTickSpacing = uint64(100) - defaultAmountReserves = sdk.NewInt(1_000_000_000) + defaultAmountReserves = osmomath.NewInt(1_000_000_000) DefaultCoins = sdk.NewCoins(sdk.NewCoin(ETH, defaultAmountReserves), sdk.NewCoin(USDC, defaultAmountReserves)) - oneULPDec = sdk.SmallestDec() + oneULPDec = osmomath.SmallestDec() oneULPBigDec = osmomath.SmallestDec() ) @@ -71,7 +71,7 @@ type tickIteratorTest struct { } func (suite *StrategyTestSuite) runTickIteratorTest(strategy swapstrategy.SwapStrategy, tc tickIteratorTest) { - pool := suite.PrepareCustomConcentratedPool(suite.TestAccs[0], ETH, USDC, tc.tickSpacing, sdk.ZeroDec()) + pool := suite.PrepareCustomConcentratedPool(suite.TestAccs[0], ETH, USDC, tc.tickSpacing, osmomath.ZeroDec()) suite.setupPresetPositions(pool.GetId(), tc.preSetPositions) // refetch pool @@ -101,9 +101,9 @@ func (suite *StrategyTestSuite) setupPresetPositions(poolId uint64, positions [] Sender: suite.TestAccs[0].String(), LowerTick: pos.lowerTick, UpperTick: pos.upperTick, - TokensProvided: DefaultCoins.Add(sdk.NewCoin(USDC, sdk.OneInt())), - TokenMinAmount0: sdk.ZeroInt(), - TokenMinAmount1: sdk.ZeroInt(), + TokensProvided: DefaultCoins.Add(sdk.NewCoin(USDC, osmomath.OneInt())), + TokenMinAmount0: osmomath.ZeroInt(), + TokenMinAmount1: osmomath.ZeroInt(), }) suite.Require().NoError(err) } @@ -118,131 +118,131 @@ func (suite *StrategyTestSuite) setupPresetPositions(poolId uint64, positions [] func (suite *StrategyTestSuite) TestComputeSwapState_Inverse() { var ( errToleranceOne = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.OneDec(), + AdditiveTolerance: osmomath.OneDec(), RoundingDir: osmomath.RoundUp, } errToleranceSmall = osmomath.ErrTolerance{ - AdditiveTolerance: sdk.NewDecFromIntWithPrec(sdk.OneInt(), 5), + AdditiveTolerance: osmomath.NewDecFromIntWithPrec(osmomath.OneInt(), 5), } ) testCases := map[string]struct { - sqrtPriceCurrent sdk.Dec - sqrtPriceTarget sdk.Dec - liquidity sdk.Dec - amountIn sdk.Dec - amountOut sdk.Dec + sqrtPriceCurrent osmomath.Dec + sqrtPriceTarget osmomath.Dec + liquidity osmomath.Dec + amountIn osmomath.Dec + amountOut osmomath.Dec zeroForOne bool - spreadFactor sdk.Dec + spreadFactor osmomath.Dec expectedSqrtPriceNextOutGivenIn osmomath.BigDec expectedSqrtPriceNextInGivenOut osmomath.BigDec - expectedAmountIn sdk.Dec - expectedAmountOut sdk.Dec + expectedAmountIn osmomath.Dec + expectedAmountOut osmomath.Dec }{ "1: one_for_zero__not_equal_target__no_spread_reward": { - sqrtPriceCurrent: sqrt5000, // 5000 - sqrtPriceTarget: sdk.MustNewDecFromStr("70.724818840347693039"), // 5002 - liquidity: sdk.MustNewDecFromStr("3035764687.503020836176699298"), - amountIn: sdk.NewDec(42000000), - amountOut: sdk.NewDec(8398), + sqrtPriceCurrent: sqrt5000, // 5000 + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.724818840347693039"), // 5002 + liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), + amountIn: osmomath.NewDec(42000000), + amountOut: osmomath.NewDec(8398), zeroForOne: false, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), // get_next_sqrt_price_from_amount1_in_round_down(liquidity, sqrtPriceCurrent, tokenIn) - expectedSqrtPriceNextOutGivenIn: osmomath.MustNewDecFromStr("70.724513183069625078753200000000838853"), // approx 5001.96 + expectedSqrtPriceNextOutGivenIn: osmomath.MustNewBigDecFromStr("70.724513183069625078753200000000838853"), // approx 5001.96 // tokenOut = round_sdk_prec_down(calc_amount_zero_delta(liquidity, Decimal('70.724513183069625078753200000000838853'), sqrtPriceCurrent, False)) // get_next_sqrt_price_from_amount0_out_round_up(liquidity, sqrtPriceCurrent, tokenOut) - expectedSqrtPriceNextInGivenOut: osmomath.MustNewDecFromStr("70.724513183069625078753199315615320286"), // approx 5001.96 + expectedSqrtPriceNextInGivenOut: osmomath.MustNewBigDecFromStr("70.724513183069625078753199315615320286"), // approx 5001.96 - expectedAmountIn: sdk.NewDec(42000000), - expectedAmountOut: sdk.NewDec(8398), + expectedAmountIn: osmomath.NewDec(42000000), + expectedAmountOut: osmomath.NewDec(8398), }, "2: zero_for_one__not_equal_target_no_spread_reward": { - sqrtPriceCurrent: sqrt5000, // 5000 - sqrtPriceTarget: sdk.MustNewDecFromStr("70.682388188289167342"), // 4996 - liquidity: sdk.MustNewDecFromStr("3035764687.503020836176699298"), - amountIn: sdk.NewDec(13370), - amountOut: sdk.NewDec(66829187), + sqrtPriceCurrent: sqrt5000, // 5000 + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.682388188289167342"), // 4996 + liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), + amountIn: osmomath.NewDec(13370), + amountOut: osmomath.NewDec(66829187), zeroForOne: true, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), // get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, tokenIn) - expectedSqrtPriceNextOutGivenIn: osmomath.MustNewDecFromStr("70.688664163408836319222318760848762802"), // approx 4996.89 + expectedSqrtPriceNextOutGivenIn: osmomath.MustNewBigDecFromStr("70.688664163408836319222318760848762802"), // approx 4996.89 // tokenOut = round_sdk_prec_down(calc_amount_one_delta(liquidity, Decimal('70.688664163408836319222318760848762802'), sqrtPriceCurrent, False)) // get_next_sqrt_price_from_amount1_out_round_down(liquidity, sqrtPriceCurrent, tokenOut) - expectedSqrtPriceNextInGivenOut: osmomath.MustNewDecFromStr("70.688664163408836319222318761064639455"), // approx 4996.89 + expectedSqrtPriceNextInGivenOut: osmomath.MustNewBigDecFromStr("70.688664163408836319222318761064639455"), // approx 4996.89 - expectedAmountIn: sdk.NewDec(13370), - expectedAmountOut: sdk.NewDec(66829187), + expectedAmountIn: osmomath.NewDec(13370), + expectedAmountOut: osmomath.NewDec(66829187), }, "3: one_for_zero__equal_target__no_spread_reward": { - sqrtPriceCurrent: sqrt5000, // 5000 - sqrtPriceTarget: sdk.MustNewDecFromStr("70.724513183069625078"), // approx 5001.96 - liquidity: sdk.MustNewDecFromStr("3035764687.503020836176699298"), - amountIn: sdk.NewDec(42000000), - amountOut: sdk.NewDec(8398), - spreadFactor: sdk.ZeroDec(), + sqrtPriceCurrent: sqrt5000, // 5000 + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.724513183069625078"), // approx 5001.96 + liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), + amountIn: osmomath.NewDec(42000000), + amountOut: osmomath.NewDec(8398), + spreadFactor: osmomath.ZeroDec(), zeroForOne: false, // same as target - expectedSqrtPriceNextOutGivenIn: osmomath.MustNewDecFromStr("70.724513183069625078"), // approx 5001.96 + expectedSqrtPriceNextOutGivenIn: osmomath.MustNewBigDecFromStr("70.724513183069625078"), // approx 5001.96 // tokenOut = round_sdk_prec_down(calc_amount_zero_delta(liquidity, Decimal('70.724513183069625078'), sqrtPriceCurrent, False)) // get_next_sqrt_price_from_amount0_out_round_up(liquidity, sqrtPriceCurrent, tokenOut) - expectedSqrtPriceNextInGivenOut: osmomath.MustNewDecFromStr("70.724513183069625077999998811165066229"), // approx 5001.96 + expectedSqrtPriceNextInGivenOut: osmomath.MustNewBigDecFromStr("70.724513183069625077999998811165066229"), // approx 5001.96 - expectedAmountIn: sdk.NewDec(42000000), - expectedAmountOut: sdk.NewDec(8398), + expectedAmountIn: osmomath.NewDec(42000000), + expectedAmountOut: osmomath.NewDec(8398), }, "4: zero_for_one__equal_target__no_spread_reward": { - sqrtPriceCurrent: sqrt5000, // 5000 - sqrtPriceTarget: sdk.MustNewDecFromStr("70.688664163408836320"), // approx 4996.89 - liquidity: sdk.MustNewDecFromStr("3035764687.503020836176699298"), - amountIn: sdk.NewDec(13370), - amountOut: sdk.NewDec(66829187), + sqrtPriceCurrent: sqrt5000, // 5000 + sqrtPriceTarget: osmomath.MustNewDecFromStr("70.688664163408836320"), // approx 4996.89 + liquidity: osmomath.MustNewDecFromStr("3035764687.503020836176699298"), + amountIn: osmomath.NewDec(13370), + amountOut: osmomath.NewDec(66829187), zeroForOne: true, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), // same as target - expectedSqrtPriceNextOutGivenIn: osmomath.MustNewDecFromStr("70.688664163408836320"), // approx 4996.89 + expectedSqrtPriceNextOutGivenIn: osmomath.MustNewBigDecFromStr("70.688664163408836320"), // approx 4996.89 // tokenOut = round_sdk_prec_down(calc_amount_one_delta(liquidity, Decimal('70.688664163408836320'), sqrtPriceCurrent, False)) // get_next_sqrt_price_from_amount1_out_round_down(liquidity, sqrtPriceCurrent, tokenOut) - expectedSqrtPriceNextInGivenOut: osmomath.MustNewDecFromStr("70.688664163408836320000000000232703515"), // approx 4996.89 + expectedSqrtPriceNextInGivenOut: osmomath.MustNewBigDecFromStr("70.688664163408836320000000000232703515"), // approx 4996.89 - expectedAmountIn: sdk.NewDec(13370), - expectedAmountOut: sdk.NewDec(66829187), + expectedAmountIn: osmomath.NewDec(13370), + expectedAmountOut: osmomath.NewDec(66829187), }, } for name, tc := range testCases { tc := tc suite.Run(name, func() { - sut := swapstrategy.New(tc.zeroForOne, osmomath.ZeroDec(), suite.App.GetKey(types.ModuleName), sdk.ZeroDec()) - sqrtPriceNextOutGivenIn, amountInOutGivenIn, amountOutOutGivenIn, _ := sut.ComputeSwapWithinBucketOutGivenIn(osmomath.BigDecFromSDKDec(tc.sqrtPriceCurrent), osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountIn) + sut := swapstrategy.New(tc.zeroForOne, osmomath.ZeroBigDec(), suite.App.GetKey(types.ModuleName), osmomath.ZeroDec()) + sqrtPriceNextOutGivenIn, amountInOutGivenIn, amountOutOutGivenIn, _ := sut.ComputeSwapWithinBucketOutGivenIn(osmomath.BigDecFromDec(tc.sqrtPriceCurrent), osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountIn) suite.Require().Equal(tc.expectedSqrtPriceNextOutGivenIn.String(), sqrtPriceNextOutGivenIn.String()) fmt.Println("amountOutOutGivenIn", amountOutOutGivenIn) - sqrtPriceNextInGivenOut, amountOutInGivenOut, amountInInGivenOut, _ := sut.ComputeSwapWithinBucketInGivenOut(osmomath.BigDecFromSDKDec(tc.sqrtPriceCurrent), osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, amountOutOutGivenIn) + sqrtPriceNextInGivenOut, amountOutInGivenOut, amountInInGivenOut, _ := sut.ComputeSwapWithinBucketInGivenOut(osmomath.BigDecFromDec(tc.sqrtPriceCurrent), osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, amountOutOutGivenIn) suite.Require().Equal(tc.expectedSqrtPriceNextInGivenOut.String(), sqrtPriceNextInGivenOut.String()) // Tolerance of 1 with rounding up because we round up for in given out. // This is to ensure that inflow into the pool is rounded in favor of the pool. suite.Require().Equal(0, errToleranceOne.CompareBigDec( - osmomath.BigDecFromSDKDec(amountInOutGivenIn), - osmomath.BigDecFromSDKDec(amountInInGivenOut)), + osmomath.BigDecFromDec(amountInOutGivenIn), + osmomath.BigDecFromDec(amountInInGivenOut)), fmt.Sprintf("amount in out given in: %s, amount in in given out: %s", amountInOutGivenIn, amountInInGivenOut)) // These should be approximately equal. The difference stems from minor roundings and truncations in the intermediary calculations. suite.Require().Equal(0, errToleranceSmall.CompareBigDec( - osmomath.BigDecFromSDKDec(amountOutOutGivenIn), - osmomath.BigDecFromSDKDec(amountOutInGivenOut)), + osmomath.BigDecFromDec(amountOutOutGivenIn), + osmomath.BigDecFromDec(amountOutInGivenOut)), fmt.Sprintf("amount out out given in: %s, amount out in given out: %s", amountOutOutGivenIn, amountOutInGivenOut)) }) } @@ -251,7 +251,7 @@ func (suite *StrategyTestSuite) TestComputeSwapState_Inverse() { func (suite *StrategyTestSuite) TestGetPriceLimit() { tests := map[string]struct { zeroForOne bool - expected sdk.Dec + expected osmomath.Dec }{ "zero for one -> min": { zeroForOne: true, diff --git a/x/concentrated-liquidity/swapstrategy/zero_for_one.go b/x/concentrated-liquidity/swapstrategy/zero_for_one.go index a1f3ea5bdda..92f7358c9d5 100644 --- a/x/concentrated-liquidity/swapstrategy/zero_for_one.go +++ b/x/concentrated-liquidity/swapstrategy/zero_for_one.go @@ -21,7 +21,7 @@ import ( type zeroForOneStrategy struct { sqrtPriceLimit osmomath.BigDec storeKey sdk.StoreKey - spreadFactor sdk.Dec + spreadFactor osmomath.Dec } var _ SwapStrategy = (*zeroForOneStrategy)(nil) @@ -57,15 +57,15 @@ func (s zeroForOneStrategy) GetSqrtTargetPrice(nextTickSqrtPrice osmomath.BigDec // // ZeroForOne details: // - zeroForOneStrategy assumes moving to the left of the current square root price. -func (s zeroForOneStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountZeroInRemaining sdk.Dec) (osmomath.BigDec, sdk.Dec, sdk.Dec, sdk.Dec) { - liquidityBigDec := osmomath.BigDecFromSDKDec(liquidity) - amountZeroInRemainingBigDec := osmomath.BigDecFromSDKDec(amountZeroInRemaining) +func (s zeroForOneStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountZeroInRemaining osmomath.Dec) (osmomath.BigDec, osmomath.Dec, osmomath.Dec, osmomath.Dec) { + liquidityBigDec := osmomath.BigDecFromDec(liquidity) + amountZeroInRemainingBigDec := osmomath.BigDecFromDec(amountZeroInRemaining) // Estimate the amount of token zero needed until the target sqrt price is reached. amountZeroIn := math.CalcAmount0Delta(liquidityBigDec, sqrtPriceTarget, sqrtPriceCurrent, true) // N.B.: if this is false, causes infinite loop // Calculate sqrtPriceNext on the amount of token remaining after spread reward. - amountZeroInRemainingLessSpreadReward := amountZeroInRemainingBigDec.Mul(oneBigDec.Sub(osmomath.BigDecFromSDKDec(s.spreadFactor))) + amountZeroInRemainingLessSpreadReward := amountZeroInRemainingBigDec.Mul(oneBigDec.Sub(osmomath.BigDecFromDec(s.spreadFactor))) var sqrtPriceNext osmomath.BigDec // If have more of the amount remaining after spread reward than estimated until target, @@ -90,14 +90,14 @@ func (s zeroForOneStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, amountOneOut := math.CalcAmount1Delta(liquidityBigDec, sqrtPriceNext, sqrtPriceCurrent, false) // Round up to charge user more in pool's favor. - amountZeroInFinal := amountZeroIn.SDKDecRoundUp() + amountZeroInFinal := amountZeroIn.DecRoundUp() // Handle spread rewards. // Note that spread reward is always charged on the amount in. spreadRewardChargeTotal := computeSpreadRewardChargePerSwapStepOutGivenIn(hasReachedTarget, amountZeroInFinal, amountZeroInRemaining, s.spreadFactor) // Round down amount out to give user less in pool's favor. - return sqrtPriceNext, amountZeroInFinal, amountOneOut.SDKDec(), spreadRewardChargeTotal + return sqrtPriceNext, amountZeroInFinal, amountOneOut.Dec(), spreadRewardChargeTotal } // ComputeSwapWithinBucketInGivenOut calculates the next sqrt price, the amount of token out consumed, the amount in to charge to the user for requested out, and total spread reward charge on token in. @@ -120,9 +120,9 @@ func (s zeroForOneStrategy) ComputeSwapWithinBucketOutGivenIn(sqrtPriceCurrent, // // ZeroForOne details: // - zeroForOneStrategy assumes moving to the left of the current square root price. -func (s zeroForOneStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountOneRemainingOut sdk.Dec) (osmomath.BigDec, sdk.Dec, sdk.Dec, sdk.Dec) { - liquidityBigDec := osmomath.BigDecFromSDKDec(liquidity) - amountOneRemainingOutBigDec := osmomath.BigDecFromSDKDec(amountOneRemainingOut) +func (s zeroForOneStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, sqrtPriceTarget osmomath.BigDec, liquidity, amountOneRemainingOut osmomath.Dec) (osmomath.BigDec, osmomath.Dec, osmomath.Dec, osmomath.Dec) { + liquidityBigDec := osmomath.BigDecFromDec(liquidity) + amountOneRemainingOutBigDec := osmomath.BigDecFromDec(amountOneRemainingOut) // Estimate the amount of token one needed until the target sqrt price is reached. amountOneOut := math.CalcAmount1Delta(liquidityBigDec, sqrtPriceTarget, sqrtPriceCurrent, false) @@ -153,7 +153,7 @@ func (s zeroForOneStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, amountZeroIn := math.CalcAmount0Delta(liquidityBigDec, sqrtPriceNext, sqrtPriceCurrent, true) // Round up to charge user more in pool's favor. - amountZeroInFinal := amountZeroIn.SDKDecRoundUp() + amountZeroInFinal := amountZeroIn.DecRoundUp() // Handle spread rewards. // Note that spread reward is always charged on the amount in. @@ -175,7 +175,7 @@ func (s zeroForOneStrategy) ComputeSwapWithinBucketInGivenOut(sqrtPriceCurrent, } // Round down amount out to give user less in pool's favor. - return sqrtPriceNext, amountOneOut.SDKDec(), amountZeroInFinal, spreadRewardChargeTotal + return sqrtPriceNext, amountOneOut.Dec(), amountZeroInFinal, spreadRewardChargeTotal } // InitializeNextTickIterator returns iterator that searches for the next tick given currentTickIndex. @@ -228,7 +228,7 @@ func (s zeroForOneStrategy) InitializeNextTickIterator(ctx sdk.Context, poolId u // When we move to the left, we must be crossing upper ticks first where // liquidity delta tracks the amount of liquidity being removed. So the sign must be // negative. -func (s zeroForOneStrategy) SetLiquidityDeltaSign(deltaLiquidity sdk.Dec) sdk.Dec { +func (s zeroForOneStrategy) SetLiquidityDeltaSign(deltaLiquidity osmomath.Dec) osmomath.Dec { return deltaLiquidity.Neg() } @@ -252,7 +252,7 @@ func (s zeroForOneStrategy) UpdateTickAfterCrossing(nextTick int64) int64 { // types.MinSqrtRatio <= sqrtPrice <= current square root price func (s zeroForOneStrategy) ValidateSqrtPrice(sqrtPrice osmomath.BigDec, currentSqrtPrice osmomath.BigDec) error { // check that the price limit is below the current sqrt price but not lower than the minimum sqrt price if we are swapping asset0 for asset1 - if sqrtPrice.GT(currentSqrtPrice) || sqrtPrice.LT(osmomath.BigDecFromSDKDec(types.MinSqrtPrice)) { + if sqrtPrice.GT(currentSqrtPrice) || sqrtPrice.LT(osmomath.BigDecFromDec(types.MinSqrtPrice)) { return types.SqrtPriceValidationError{SqrtPriceLimit: sqrtPrice, LowerBound: types.MinSqrtPriceBigDec, UpperBound: currentSqrtPrice} } return nil diff --git a/x/concentrated-liquidity/swapstrategy/zero_for_one_test.go b/x/concentrated-liquidity/swapstrategy/zero_for_one_test.go index 19710b0a29a..2dec6cc12ac 100644 --- a/x/concentrated-liquidity/swapstrategy/zero_for_one_test.go +++ b/x/concentrated-liquidity/swapstrategy/zero_for_one_test.go @@ -1,29 +1,27 @@ package swapstrategy_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/swapstrategy" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) -func (suite *StrategyTestSuite) setupNewZeroForOneSwapStrategy(sqrtPriceLimit sdk.Dec, spread sdk.Dec) swapstrategy.SwapStrategy { +func (suite *StrategyTestSuite) setupNewZeroForOneSwapStrategy(sqrtPriceLimit osmomath.Dec, spread osmomath.Dec) swapstrategy.SwapStrategy { suite.SetupTest() - return swapstrategy.New(true, osmomath.BigDecFromSDKDec(sqrtPriceLimit), suite.App.GetKey(types.ModuleName), spread) + return swapstrategy.New(true, osmomath.BigDecFromDec(sqrtPriceLimit), suite.App.GetKey(types.ModuleName), spread) } func (suite *StrategyTestSuite) TestGetSqrtTargetPrice_ZeroForOne() { tests := map[string]struct { isZeroForOne bool - sqrtPriceLimit sdk.Dec - nextTickSqrtPrice sdk.Dec - expectedResult sdk.Dec + sqrtPriceLimit osmomath.Dec + nextTickSqrtPrice osmomath.Dec + expectedResult osmomath.Dec }{ "nextTickSqrtPrice == sqrtPriceLimit -> returns either": { - sqrtPriceLimit: sdk.OneDec(), - nextTickSqrtPrice: sdk.OneDec(), - expectedResult: sdk.OneDec(), + sqrtPriceLimit: osmomath.OneDec(), + nextTickSqrtPrice: osmomath.OneDec(), + expectedResult: osmomath.OneDec(), }, "nextTickSqrtPrice > sqrtPriceLimit -> nextTickSqrtPrice": { sqrtPriceLimit: three, @@ -41,8 +39,8 @@ func (suite *StrategyTestSuite) TestGetSqrtTargetPrice_ZeroForOne() { tc := tc suite.Run(name, func() { sut := suite.setupNewZeroForOneSwapStrategy(tc.sqrtPriceLimit, zero) - actualSqrtTargetPrice := sut.GetSqrtTargetPrice(osmomath.BigDecFromSDKDec(tc.nextTickSqrtPrice)) - suite.Require().Equal(osmomath.BigDecFromSDKDec(tc.expectedResult), actualSqrtTargetPrice) + actualSqrtTargetPrice := sut.GetSqrtTargetPrice(osmomath.BigDecFromDec(tc.nextTickSqrtPrice)) + suite.Require().Equal(osmomath.BigDecFromDec(tc.expectedResult), actualSqrtTargetPrice) }) } } @@ -50,29 +48,29 @@ func (suite *StrategyTestSuite) TestGetSqrtTargetPrice_ZeroForOne() { // Estimates are computed using x/concentrated-liquidity/python/clmath.py func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { var ( - sqrtPriceCurrent = osmomath.BigDecFromSDKDec(defaultSqrtPriceUpper) - sqrtPriceNext = osmomath.BigDecFromSDKDec(defaultSqrtPriceLower) - sqrtPriceTarget = sqrtPriceNext.SDKDec() + sqrtPriceCurrent = osmomath.BigDecFromDec(defaultSqrtPriceUpper) + sqrtPriceNext = osmomath.BigDecFromDec(defaultSqrtPriceLower) + sqrtPriceTarget = sqrtPriceNext.Dec() // get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, tokenIn) - sqrtPriceTargetNotReached = osmomath.MustNewDecFromStr("70.688828764403676329447109466419851492") + sqrtPriceTargetNotReached = osmomath.MustNewBigDecFromStr("70.688828764403676329447109466419851492") // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) - amountOneTargetNotReached = sdk.MustNewDecFromStr("66329498.080160868611070352") + amountOneTargetNotReached = osmomath.MustNewDecFromStr("66329498.080160868611070352") ) // sqrtPriceCurrent, sqrtPriceTarget, liquidity are all set to defaults defined above. tests := map[string]struct { sqrtPriceCurrent osmomath.BigDec - sqrtPriceTarget sdk.Dec - liquidity sdk.Dec + sqrtPriceTarget osmomath.Dec + liquidity osmomath.Dec - amountZeroInRemaining sdk.Dec - spreadFactor sdk.Dec + amountZeroInRemaining osmomath.Dec + spreadFactor osmomath.Dec expectedSqrtPriceNext osmomath.BigDec - amountZeroInConsumed sdk.Dec - expectedAmountOneOut sdk.Dec - expectedSpreadRewardChargeTotal sdk.Dec + amountZeroInConsumed osmomath.Dec + expectedAmountOneOut osmomath.Dec + expectedSpreadRewardChargeTotal osmomath.Dec }{ "1: no spread reward - reach target": { sqrtPriceCurrent: sqrtPriceCurrent, @@ -80,29 +78,29 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { liquidity: defaultLiquidity, // add 100 more - amountZeroInRemaining: defaultAmountZero.Add(sdk.NewDec(100)), - spreadFactor: sdk.ZeroDec(), + amountZeroInRemaining: defaultAmountZero.Add(osmomath.NewDec(100)), + spreadFactor: osmomath.ZeroDec(), expectedSqrtPriceNext: sqrtPriceNext, // consumed without 100 since reached target. amountZeroInConsumed: defaultAmountZero.Ceil(), // liquidity * (sqrtPriceNext - sqrtPriceCurrent) expectedAmountOneOut: defaultAmountOne, - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "2: no spread reward - do not reach target": { sqrtPriceCurrent: sqrtPriceCurrent, sqrtPriceTarget: sqrtPriceTarget, liquidity: defaultLiquidity, - amountZeroInRemaining: defaultAmountZero.Sub(sdk.NewDec(100)), - spreadFactor: sdk.ZeroDec(), + amountZeroInRemaining: defaultAmountZero.Sub(osmomath.NewDec(100)), + spreadFactor: osmomath.ZeroDec(), expectedSqrtPriceNext: sqrtPriceTargetNotReached, - amountZeroInConsumed: defaultAmountZero.Sub(sdk.NewDec(100)).Ceil(), + amountZeroInConsumed: defaultAmountZero.Sub(osmomath.NewDec(100)).Ceil(), expectedAmountOneOut: amountOneTargetNotReached, - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "3: 3% spread reward - reach target": { sqrtPriceCurrent: sqrtPriceCurrent, @@ -110,7 +108,7 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { liquidity: defaultLiquidity, // add 100 more - amountZeroInRemaining: defaultAmountZero.Add(sdk.NewDec(100)).Quo(one.Sub(defaultSpreadReward)), + amountZeroInRemaining: defaultAmountZero.Add(osmomath.NewDec(100)).Quo(one.Sub(defaultSpreadReward)), spreadFactor: defaultSpreadReward, expectedSqrtPriceNext: sqrtPriceNext, @@ -125,34 +123,34 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { sqrtPriceTarget: sqrtPriceTarget, liquidity: defaultLiquidity, - amountZeroInRemaining: defaultAmountZero.Sub(sdk.NewDec(100)).Quo(one.Sub(defaultSpreadReward)), + amountZeroInRemaining: defaultAmountZero.Sub(osmomath.NewDec(100)).Quo(one.Sub(defaultSpreadReward)), spreadFactor: defaultSpreadReward, // tokenIn = Decimal("13269.999999999998920002290000000000000000") // sqrtPriceNext = get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, tokenIn) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("70.688828764403676329447108989075854947"), - amountZeroInConsumed: defaultAmountZero.Sub(sdk.NewDec(100)).Ceil(), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("70.688828764403676329447108989075854947"), + amountZeroInConsumed: defaultAmountZero.Sub(osmomath.NewDec(100)).Ceil(), // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) - expectedAmountOneOut: sdk.MustNewDecFromStr("66329498.080160868611071801"), + expectedAmountOneOut: osmomath.MustNewDecFromStr("66329498.080160868611071801"), // Difference between amount in given and actually consumed. - expectedSpreadRewardChargeTotal: defaultAmountZero.Sub(sdk.NewDec(100)).Quo(one.Sub(defaultSpreadReward)).Sub(defaultAmountZero.Sub(sdk.NewDec(100)).Ceil()), + expectedSpreadRewardChargeTotal: defaultAmountZero.Sub(osmomath.NewDec(100)).Quo(one.Sub(defaultSpreadReward)).Sub(defaultAmountZero.Sub(osmomath.NewDec(100)).Ceil()), }, - "5: sub sdk.Dec ULP precision movement. Supported by osmomath.BigDec ULP": { + "5: sub osmomath.Dec ULP precision movement. Supported by osmomath.BigDec ULP": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("0.000001000049998751"), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998750"), - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("0.000001000049998751"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998750"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountZeroInRemaining: sdk.NewDec(99), - spreadFactor: sdk.ZeroDec(), + amountZeroInRemaining: osmomath.NewDec(99), + spreadFactor: osmomath.ZeroDec(), // sqrtPriceNext = get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, 99) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.000001000049998750999999999999009926"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.000001000049998750999999999999009926"), - amountZeroInConsumed: sdk.NewDec(99), + amountZeroInConsumed: osmomath.NewDec(99), // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) - expectedAmountOneOut: sdk.MustNewDecFromStr("0.000000000099009873"), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneOut: osmomath.MustNewDecFromStr("0.000000000099009873"), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, // If such swap leads to an infinite loop in swap logic, it should be detected and failed. We have such logic implemented // If such swap leads to amounts consumed being non-zero, the swap should be failed for security purposes. For example, @@ -160,49 +158,49 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { // this and fail the swap. "6: sub osmomath.BigDec ULP precision movement. Nothing charged for amountIn due to precision loss. No amounts consumed": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("0.000001000049998751"), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998750"), - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("0.000001000049998751"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998750"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountZeroInRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountZeroInRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), // sqrtPriceNext = get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, 99) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.000001000049998751"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.000001000049998751"), - amountZeroInConsumed: sdk.ZeroDec(), + amountZeroInConsumed: osmomath.ZeroDec(), // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) - expectedAmountOneOut: sdk.ZeroDec(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneOut: osmomath.ZeroDec(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, "7: precisely osmomath.BigDec ULP precision movement. Amounts in and out are consumed.": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("0.000001000049998751"), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998750"), - liquidity: sdk.MustNewDecFromStr("100002498062401598791.937822606808718081"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("0.000001000049998751"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998750"), + liquidity: osmomath.MustNewDecFromStr("100002498062401598791.937822606808718081"), - amountZeroInRemaining: sdk.SmallestDec().MulInt64(100000000000000), - spreadFactor: sdk.ZeroDec(), + amountZeroInRemaining: osmomath.SmallestDec().MulInt64(100000000000000), + spreadFactor: osmomath.ZeroDec(), // sqrtPriceNext = get_next_sqrt_price_from_amount0_in_round_up(liquidity, sqrtPriceCurrent, oneULPDec * 100000000000000) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.000001000049998750999999999999999999"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.000001000049998750999999999999999999"), // ceil(calc_amount_zero_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) // Note that amount consumed ends up being greater than amount remaining. After subtracting the amount consumed // from amount remaining at the end of the swap, we might end up with negative amount in remaining. This is acceptable // As this then gets subtracted from the minimum amount in given by user and rounded up. Therefore, in the worst case, // we upcharge the user by 1 unit due to rounding. - amountZeroInConsumed: sdk.OneDec(), + amountZeroInConsumed: osmomath.OneDec(), // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) - expectedAmountOneOut: sdk.SmallestDec().MulInt64(100), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountOneOut: osmomath.SmallestDec().MulInt64(100), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, } for name, tc := range tests { suite.Run(name, func() { strategy := suite.setupNewZeroForOneSwapStrategy(types.MaxSqrtPrice, tc.spreadFactor) - sqrtPriceNext, amountZeroIn, amountOneOut, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketOutGivenIn(tc.sqrtPriceCurrent, osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountZeroInRemaining) + sqrtPriceNext, amountZeroIn, amountOneOut, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketOutGivenIn(tc.sqrtPriceCurrent, osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountZeroInRemaining) suite.Require().Equal(tc.expectedSqrtPriceNext, sqrtPriceNext) suite.Require().Equal(tc.expectedAmountOneOut, amountOneOut) @@ -215,35 +213,35 @@ func (suite *StrategyTestSuite) TestComputeSwapStepOutGivenIn_ZeroForOne() { // Estimates are computed using x/concentrated-liquidity/python/clmath.py func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_ZeroForOne() { var ( - sqrtPriceCurrent = osmomath.BigDecFromSDKDec(defaultSqrtPriceUpper) - sqrtPriceNext = osmomath.BigDecFromSDKDec(defaultSqrtPriceLower) - sqrtPriceTarget = sqrtPriceNext.SDKDec() + sqrtPriceCurrent = osmomath.BigDecFromDec(defaultSqrtPriceUpper) + sqrtPriceNext = osmomath.BigDecFromDec(defaultSqrtPriceLower) + sqrtPriceTarget = sqrtPriceNext.Dec() // get_next_sqrt_price_from_amount1_out_round_down(liquidity, sqrtPriceCurrent, tokenOut) - sqrtPriceTargetNotReached = osmomath.MustNewDecFromStr("70.688667457471792243056846000067005485") + sqrtPriceTargetNotReached = osmomath.MustNewBigDecFromStr("70.688667457471792243056846000067005485") // round_sdk_prec_up(calc_amount_zero_delta(liquidity, sqrtPriceCurrent, Decimal("70.688667457471792243056846000067005485"), True)) - amountZeroTargetNotReached = sdk.MustNewDecFromStr("13367.998754214114788303") + amountZeroTargetNotReached = osmomath.MustNewDecFromStr("13367.998754214114788303") - // N.B.: approx eq = defaultAmountOneZfo.Sub(sdk.NewDec(10000)) + // N.B.: approx eq = defaultAmountOneZfo.Sub(osmomath.NewDec(10000)) // slight variance due to recomputing amount out when target is not reached. // liq * (sqrt_cur - sqrt_next) // round_sdk_prec_down(calc_amount_one_delta(liquidity, sqrtPriceCurrent, Decimal("70.688667457471792243056846000067005485"), False)) - amountOneOutTargetNotReached = sdk.MustNewDecFromStr("66819187.967824033199646915") + amountOneOutTargetNotReached = osmomath.MustNewDecFromStr("66819187.967824033199646915") ) // sqrtPriceCurrent, sqrtPriceTarget, liquidity are all set to defaults defined above. tests := map[string]struct { sqrtPriceCurrent osmomath.BigDec - sqrtPriceTarget sdk.Dec - liquidity sdk.Dec + sqrtPriceTarget osmomath.Dec + liquidity osmomath.Dec - amountOneOutRemaining sdk.Dec - spreadFactor sdk.Dec + amountOneOutRemaining osmomath.Dec + spreadFactor osmomath.Dec expectedSqrtPriceNext osmomath.BigDec - amountOneOutConsumed sdk.Dec - expectedAmountInZero sdk.Dec - expectedSpreadRewardChargeTotal sdk.Dec + amountOneOutConsumed osmomath.Dec + expectedAmountInZero osmomath.Dec + expectedSpreadRewardChargeTotal osmomath.Dec }{ "1: no spread reward - reach target": { sqrtPriceCurrent: sqrtPriceCurrent, @@ -251,7 +249,7 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_ZeroForOne() { liquidity: defaultLiquidity, // Add 100. - amountOneOutRemaining: defaultAmountOne.Add(sdk.NewDec(100)), + amountOneOutRemaining: defaultAmountOne.Add(osmomath.NewDec(100)), spreadFactor: zero, expectedSqrtPriceNext: sqrtPriceNext, @@ -265,7 +263,7 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_ZeroForOne() { sqrtPriceTarget: sqrtPriceTarget, liquidity: defaultLiquidity, - amountOneOutRemaining: defaultAmountOne.Sub(sdk.NewDec(10000)), + amountOneOutRemaining: defaultAmountOne.Sub(osmomath.NewDec(10000)), spreadFactor: zero, // sqrt_cur - amt_one / liq quo round up @@ -295,7 +293,7 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_ZeroForOne() { sqrtPriceTarget: sqrtPriceTarget, liquidity: defaultLiquidity, - amountOneOutRemaining: defaultAmountOne.Sub(sdk.NewDec(10000)), + amountOneOutRemaining: defaultAmountOne.Sub(osmomath.NewDec(10000)), spreadFactor: defaultSpreadReward, expectedSqrtPriceNext: sqrtPriceTargetNotReached, @@ -303,37 +301,37 @@ func (suite *StrategyTestSuite) TestComputeSwapStepInGivenOut_ZeroForOne() { expectedAmountInZero: amountZeroTargetNotReached.Ceil(), expectedSpreadRewardChargeTotal: swapstrategy.ComputeSpreadRewardChargeFromAmountIn(amountZeroTargetNotReached.Ceil(), defaultSpreadReward), }, - "5: sdk.Dec ULP swap out, within moves sqrt price by 1 osmomath.BigDec ULP, amountOut consumed is greater than remaining": { + "5: osmomath.Dec ULP swap out, within moves sqrt price by 1 osmomath.BigDec ULP, amountOut consumed is greater than remaining": { // Note the numbers are hand-picked to reproduce this specific case. - sqrtPriceCurrent: osmomath.MustNewDecFromStr("0.000001000049998751"), - sqrtPriceTarget: sdk.MustNewDecFromStr("0.000001000049998750"), + sqrtPriceCurrent: osmomath.MustNewBigDecFromStr("0.000001000049998751"), + sqrtPriceTarget: osmomath.MustNewDecFromStr("0.000001000049998750"), // Chosen to be large with the goal of making sqrt price next be equal to sqrt price current. // This is due to the fact that sqrtPriceNext = sqrtPriceCurrent - tokenOut / liquidity (quo round up). - liquidity: sdk.MustNewDecFromStr("10000000000000000000.937822606808718081"), + liquidity: osmomath.MustNewDecFromStr("10000000000000000000.937822606808718081"), // Chosen to be small with the goal of making sqrt price next be equal to sqrt price current. // This is due to the fact that sqrtPriceNext = sqrtPriceCurrent - tokenOut / liquidity (quo round up). - amountOneOutRemaining: sdk.SmallestDec(), - spreadFactor: sdk.ZeroDec(), + amountOneOutRemaining: osmomath.SmallestDec(), + spreadFactor: osmomath.ZeroDec(), // sqrtPriceNext = get_next_sqrt_price_from_amount1_out_round_down(liquidity, sqrtPriceCurrent, oneULPDec) - expectedSqrtPriceNext: osmomath.MustNewDecFromStr("0.000001000049998750999999999999999999"), + expectedSqrtPriceNext: osmomath.MustNewBigDecFromStr("0.000001000049998750999999999999999999"), // round_sdk_prec_up(calc_amount_one_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, False)) // Results in 0.000000000000000010. However, notice that this value is greater than amountRemaining. // Therefore, the amountOut consumed gets reset to amountOutRemaining. // See code comments in ComputeSwapWithinBucketInGivenOut(...) - amountOneOutConsumed: sdk.SmallestDec(), + amountOneOutConsumed: osmomath.SmallestDec(), // round_sdk_prec_down(calc_amount_zero_delta(liquidity, sqrtPriceCurrent, sqrtPriceNext, True)) - expectedAmountInZero: sdk.MustNewDecFromStr("0.000099992498812332").Ceil(), - expectedSpreadRewardChargeTotal: sdk.ZeroDec(), + expectedAmountInZero: osmomath.MustNewDecFromStr("0.000099992498812332").Ceil(), + expectedSpreadRewardChargeTotal: osmomath.ZeroDec(), }, } for name, tc := range tests { suite.Run(name, func() { strategy := suite.setupNewZeroForOneSwapStrategy(types.MaxSqrtPrice, tc.spreadFactor) - sqrtPriceNext, amountOneOut, amountZeroIn, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketInGivenOut(tc.sqrtPriceCurrent, osmomath.BigDecFromSDKDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountOneOutRemaining) + sqrtPriceNext, amountOneOut, amountZeroIn, spreadRewardChargeTotal := strategy.ComputeSwapWithinBucketInGivenOut(tc.sqrtPriceCurrent, osmomath.BigDecFromDec(tc.sqrtPriceTarget), tc.liquidity, tc.amountOneOutRemaining) suite.Require().Equal(tc.expectedSqrtPriceNext, sqrtPriceNext) suite.Require().Equal(tc.amountOneOutConsumed, amountOneOut) diff --git a/x/concentrated-liquidity/tick.go b/x/concentrated-liquidity/tick.go index 045545be27b..06456159c7f 100644 --- a/x/concentrated-liquidity/tick.go +++ b/x/concentrated-liquidity/tick.go @@ -22,7 +22,7 @@ import ( // if we are initializing or updating an upper tick, we subtract the liquidityIn from the LiquidityNet // if we are initializing or updating a lower tick, we add the liquidityIn from the LiquidityNet // WARNING: this method may mutate the pool, make sure to refetch the pool after calling this method. -func (k Keeper) initOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int64, tickIndex int64, liquidityDelta sdk.Dec, upper bool) (tickIsEmpty bool, err error) { +func (k Keeper) initOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int64, tickIndex int64, liquidityDelta osmomath.Dec, upper bool) (tickIsEmpty bool, err error) { tickInfo, err := k.GetTickInfo(ctx, poolId, tickIndex) if err != nil { return false, err @@ -78,9 +78,9 @@ func (k Keeper) initOrUpdateTick(ctx sdk.Context, poolId uint64, currentTick int // CONTRACT: the caller validates that the pool with the given id exists. // CONTRACT: caller is responsible for the uptimeAccums to be up-to-date. // CONTRACT: uptimeAccums are associated with the given pool id. -func (k Keeper) crossTick(ctx sdk.Context, poolId uint64, tickIndex int64, tickInfo *model.TickInfo, swapStateSpreadRewardGrowth sdk.DecCoin, spreadRewardAccumValue sdk.DecCoins, uptimeAccums []*accum.AccumulatorObject) (liquidityDelta sdk.Dec, err error) { +func (k Keeper) crossTick(ctx sdk.Context, poolId uint64, tickIndex int64, tickInfo *model.TickInfo, swapStateSpreadRewardGrowth sdk.DecCoin, spreadRewardAccumValue sdk.DecCoins, uptimeAccums []*accum.AccumulatorObject) (liquidityDelta osmomath.Dec, err error) { if tickInfo == nil { - return sdk.Dec{}, types.ErrNextTickInfoNil + return osmomath.Dec{}, types.ErrNextTickInfoNil } // subtract tick's spread reward growth opposite direction of last traversal from current spread reward growth global, including the spread reward growth of the current swap. @@ -153,7 +153,7 @@ func (k Keeper) makeInitialTickInfo(ctx sdk.Context, poolId uint64, tickIndex in initialUptimeTrackers = append(initialUptimeTrackers, model.UptimeTracker{UptimeGrowthOutside: uptimeTrackerValue}) } - return model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: initialSpreadRewardGrowthOppositeDirectionOfLastTraversal, UptimeTrackers: model.UptimeTrackers{List: initialUptimeTrackers}}, nil + return model.TickInfo{LiquidityGross: osmomath.ZeroDec(), LiquidityNet: osmomath.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: initialSpreadRewardGrowthOppositeDirectionOfLastTraversal, UptimeTrackers: model.UptimeTrackers{List: initialUptimeTrackers}}, nil } func (k Keeper) SetTickInfo(ctx sdk.Context, poolId uint64, tickIndex int64, tickInfo *model.TickInfo) { diff --git a/x/concentrated-liquidity/tick_test.go b/x/concentrated-liquidity/tick_test.go index 91b57795745..ab17c63b9be 100644 --- a/x/concentrated-liquidity/tick_test.go +++ b/x/concentrated-liquidity/tick_test.go @@ -7,6 +7,7 @@ import ( "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/accum" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" @@ -26,7 +27,7 @@ func withPoolId(tick genesis.FullTick, poolId uint64) genesis.FullTick { return tick } -func withLiquidityNetandTickIndex(tick genesis.FullTick, tickIndex int64, liquidityNet sdk.Dec) genesis.FullTick { +func withLiquidityNetandTickIndex(tick genesis.FullTick, tickIndex int64, liquidityNet osmomath.Dec) genesis.FullTick { tick.TickIndex = tickIndex tick.Info.LiquidityNet = liquidityNet @@ -87,7 +88,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { type param struct { poolId uint64 tickIndex int64 - liquidityIn sdk.Dec + liquidityIn osmomath.Dec initLiquidityNet bool upper bool } @@ -96,8 +97,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { name string param param tickExists bool - expectedLiquidityNet sdk.Dec - expectedLiquidityGross sdk.Dec + expectedLiquidityNet osmomath.Dec + expectedLiquidityGross osmomath.Dec minimumGasConsumed bool expectedErr error }{ @@ -124,7 +125,7 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { initLiquidityNet: true, }, tickExists: false, - expectedLiquidityNet: sdk.ZeroDec(), + expectedLiquidityNet: osmomath.ZeroDec(), expectedLiquidityGross: DefaultLiquidityAmt, minimumGasConsumed: false, }, @@ -150,8 +151,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: true, }, tickExists: true, - expectedLiquidityNet: DefaultLiquidityAmt.Mul(sdk.NewDec(2)).Neg(), - expectedLiquidityGross: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), + expectedLiquidityNet: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)).Neg(), + expectedLiquidityGross: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), minimumGasConsumed: false, }, { @@ -163,8 +164,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: false, }, tickExists: true, - expectedLiquidityNet: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), - expectedLiquidityGross: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), + expectedLiquidityNet: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), + expectedLiquidityGross: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), minimumGasConsumed: false, }, { @@ -202,8 +203,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: true, }, tickExists: true, - expectedLiquidityNet: DefaultLiquidityAmt.Mul(sdk.NewDec(2)).Neg(), - expectedLiquidityGross: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), + expectedLiquidityNet: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)).Neg(), + expectedLiquidityGross: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), minimumGasConsumed: false, }, { @@ -215,8 +216,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: false, }, tickExists: true, - expectedLiquidityNet: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), - expectedLiquidityGross: DefaultLiquidityAmt.Mul(sdk.NewDec(2)), + expectedLiquidityNet: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), + expectedLiquidityGross: DefaultLiquidityAmt.Mul(osmomath.NewDec(2)), minimumGasConsumed: false, }, { @@ -241,8 +242,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: true, }, tickExists: true, - expectedLiquidityNet: sdk.ZeroDec(), - expectedLiquidityGross: sdk.ZeroDec(), + expectedLiquidityNet: osmomath.ZeroDec(), + expectedLiquidityGross: osmomath.ZeroDec(), minimumGasConsumed: false, }, { @@ -254,8 +255,8 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { upper: false, }, tickExists: true, - expectedLiquidityNet: sdk.ZeroDec(), - expectedLiquidityGross: sdk.ZeroDec(), + expectedLiquidityNet: osmomath.ZeroDec(), + expectedLiquidityGross: osmomath.ZeroDec(), minimumGasConsumed: false, }, { @@ -286,11 +287,11 @@ func (s *KeeperTestSuite) TestInitOrUpdateTick() { s.Require().NoError(err) // manually update accumulator for testing - defaultAccumCoins := sdk.NewDecCoins(sdk.NewDecCoin("foo", sdk.NewInt(50))) + defaultAccumCoins := sdk.NewDecCoins(sdk.NewDecCoin("foo", osmomath.NewInt(50))) spreadFactorAccum.AddToAccumulator(defaultAccumCoins) // If tickExists set, initialize the specified tick with defaultLiquidityAmt - preexistingLiquidity := sdk.ZeroDec() + preexistingLiquidity := osmomath.ZeroDec() if test.tickExists { tickInfoBefore, err := s.App.ConcentratedLiquidityKeeper.GetTickInfo(s.Ctx, 1, test.param.tickIndex) s.Require().NoError(err) @@ -411,7 +412,7 @@ func (s *KeeperTestSuite) TestGetTickInfo() { preInitUptimeAccumValues: expectedUptimes.varyingTokensMultiDenom, // Note that both SpreadRewardGrowthOutside and UptimeGrowthOutsides are updated. // We expect uptime trackers to be initialized to global accums since tick <= active tick - expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: varyingTokensAndDenomsModel}, + expectedTickInfo: model.TickInfo{LiquidityGross: osmomath.ZeroDec(), LiquidityNet: osmomath.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: varyingTokensAndDenomsModel}, }, { name: "Get tick info for active tick on existing pool with existing tick", @@ -419,21 +420,21 @@ func (s *KeeperTestSuite) TestGetTickInfo() { tickToGet: DefaultCurrTick, preInitUptimeAccumValues: expectedUptimes.varyingTokensMultiDenom, // Both spread reward growth and uptime trackers are set to global since tickToGet <= current tick - expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: varyingTokensAndDenomsModel}, + expectedTickInfo: model.TickInfo{LiquidityGross: osmomath.ZeroDec(), LiquidityNet: osmomath.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: varyingTokensAndDenomsModel}, }, { name: "Get tick info on existing pool with no existing tick (cur pool tick > tick)", poolToGet: validPoolId, tickToGet: DefaultCurrTick + 1, // Note that SpreadRewardGrowthOutside and UptimeGrowthOutside(s) are not initialized. - expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), UptimeTrackers: emptyUptimeTrackersModel}, + expectedTickInfo: model.TickInfo{LiquidityGross: osmomath.ZeroDec(), LiquidityNet: osmomath.ZeroDec(), UptimeTrackers: emptyUptimeTrackersModel}, }, { name: "Get tick info on existing pool with no existing tick (cur pool tick == tick), initialized spread reward growth outside", poolToGet: validPoolId, tickToGet: DefaultCurrTick, // Note that SpreadRewardGrowthOutside and UptimeGrowthOutside(s) are initialized. - expectedTickInfo: model.TickInfo{LiquidityGross: sdk.ZeroDec(), LiquidityNet: sdk.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: emptyUptimeTrackersModel}, + expectedTickInfo: model.TickInfo{LiquidityGross: osmomath.ZeroDec(), LiquidityNet: osmomath.ZeroDec(), SpreadRewardGrowthOppositeDirectionOfLastTraversal: sdk.NewDecCoins(oneEth), UptimeTrackers: emptyUptimeTrackersModel}, }, { name: "Get tick info on a non-existing pool with no existing tick", @@ -489,7 +490,7 @@ func (s *KeeperTestSuite) TestCrossTick() { preInitializedTickIndex = DefaultCurrTick - 2 expectedUptimes = getExpectedUptimes() emptyUptimeTrackers = wrapUptimeTrackers(expectedUptimes.emptyExpectedAccumValues) - defaultAdditiveSpreadFactor = sdk.NewDecCoinFromDec(USDC, sdk.NewDec(1000)) + defaultAdditiveSpreadFactor = sdk.NewDecCoinFromDec(USDC, osmomath.NewDec(1000)) ) tests := []struct { @@ -501,7 +502,7 @@ func (s *KeeperTestSuite) TestCrossTick() { globalUptimeAccumDelta []sdk.DecCoins expectedUptimeTrackers []model.UptimeTracker additiveSpreadFactor sdk.DecCoin - expectedLiquidityDelta sdk.Dec + expectedLiquidityDelta osmomath.Dec expectedTickSpreadRewardGrowthOppositeDirectionOfLastTraversal sdk.DecCoins expectedErr error }{ @@ -560,7 +561,7 @@ func (s *KeeperTestSuite) TestCrossTick() { // This is because we init them to zero (since target tick is above current tick), // so when we cross the tick and "flip" it, we expect it to be the global value - 0 = global value. expectedUptimeTrackers: wrapUptimeTrackers(expectedUptimes.threeHundredTokensMultiDenom), - expectedLiquidityDelta: sdk.ZeroDec(), + expectedLiquidityDelta: osmomath.ZeroDec(), expectedTickSpreadRewardGrowthOppositeDirectionOfLastTraversal: DefaultSpreadRewardAccumCoins.Add(defaultAdditiveSpreadFactor).Add(DefaultSpreadRewardAccumCoins...), }, { @@ -610,13 +611,13 @@ func (s *KeeperTestSuite) TestCrossTick() { if test.poolToGet == validPoolId { s.FundAcc(s.TestAccs[0], sdk.NewCoins(DefaultCoin0, DefaultCoin1)) - _, err := s.clk.CreatePosition(s.Ctx, test.poolToGet, s.TestAccs[0], DefaultCoins, sdk.ZeroInt(), sdk.ZeroInt(), DefaultLowerTick, DefaultUpperTick) + _, err := s.clk.CreatePosition(s.Ctx, test.poolToGet, s.TestAccs[0], DefaultCoins, osmomath.ZeroInt(), osmomath.ZeroInt(), DefaultLowerTick, DefaultUpperTick) s.Require().NoError(err) } // Charge spread factor to make sure that the global spread factor accumulator is always updated. // This is to test that the per-tick spread reward growth accumulator gets initialized. - defaultAccumCoins := sdk.NewDecCoin("foo", sdk.NewInt(50)) + defaultAccumCoins := sdk.NewDecCoin("foo", osmomath.NewInt(50)) s.AddToSpreadRewardAccumulator(validPoolId, defaultAccumCoins) // Initialize global uptime accums @@ -679,7 +680,7 @@ func (s *KeeperTestSuite) TestCrossTick() { s.Require().NoError(err) // accum value should not have changed - s.Require().Equal(accum.GetValue(), sdk.NewDecCoins(defaultAccumCoins).MulDec(sdk.NewDec(2))) + s.Require().Equal(accum.GetValue(), sdk.NewDecCoins(defaultAccumCoins).MulDec(osmomath.NewDec(2))) // check if the tick spread reward growth outside has been correctly subtracted tickInfo, err := s.App.ConcentratedLiquidityKeeper.GetTickInfo(s.Ctx, test.poolToGet, test.tickToGet) diff --git a/x/concentrated-liquidity/total_liquidity.go b/x/concentrated-liquidity/total_liquidity.go index 3fcd2616fa2..248b540acb0 100644 --- a/x/concentrated-liquidity/total_liquidity.go +++ b/x/concentrated-liquidity/total_liquidity.go @@ -6,6 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -24,7 +25,7 @@ func (k Keeper) setTotalLiquidity(ctx sdk.Context, coins sdk.Coins) { } } -func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount sdk.Int) { +func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount osmomath.Int) { store := ctx.KVStore(k.storeKey) bz, err := amount.Marshal() if err != nil { @@ -33,14 +34,14 @@ func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount sdk.Int) store.Set(types.GetDenomPrefix(denom), bz) } -func (k Keeper) GetDenomLiquidity(ctx sdk.Context, denom string) sdk.Int { +func (k Keeper) GetDenomLiquidity(ctx sdk.Context, denom string) osmomath.Int { store := ctx.KVStore(k.storeKey) bz := store.Get(types.GetDenomPrefix(denom)) if bz == nil { - return sdk.NewInt(0) + return osmomath.NewInt(0) } - var amount sdk.Int + var amount osmomath.Int if err := amount.Unmarshal(bz); err != nil { panic(err) } @@ -55,7 +56,7 @@ func (k Keeper) IterateDenomLiquidity(ctx sdk.Context, cb func(sdk.Coin) bool) { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amount sdk.Int + var amount osmomath.Int fmt.Println(iterator.Value()) if err := amount.Unmarshal(iterator.Value()); err != nil { panic(err) diff --git a/x/concentrated-liquidity/types/cl.go b/x/concentrated-liquidity/types/cl.go index 825c1002f20..887c2b6c63c 100644 --- a/x/concentrated-liquidity/types/cl.go +++ b/x/concentrated-liquidity/types/cl.go @@ -3,7 +3,7 @@ package types import ( fmt "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) // GetConcentratedLockupDenomFromPoolId returns the concentrated lockup denom for a given pool id. @@ -16,17 +16,17 @@ func GetConcentratedLockupDenomFromPoolId(poolId uint64) string { // account for varying locking scenarios. type CreateFullRangePositionData struct { ID uint64 - Amount0 sdk.Int - Amount1 sdk.Int - Liquidity sdk.Dec + Amount0 osmomath.Int + Amount1 osmomath.Int + Liquidity osmomath.Dec } // UpdatePositionData represents the return data from updating a position. // Tick flags are used to signal if tick is not referenced by any liquidity after the update // for removal purposes. type UpdatePositionData struct { - Amount0 sdk.Int - Amount1 sdk.Int + Amount0 osmomath.Int + Amount1 osmomath.Int LowerTickIsEmpty bool UpperTickIsEmpty bool } diff --git a/x/concentrated-liquidity/types/cl_pool_extensionI.go b/x/concentrated-liquidity/types/cl_pool_extensionI.go index 6e1b07af7de..5da01916e6a 100644 --- a/x/concentrated-liquidity/types/cl_pool_extensionI.go +++ b/x/concentrated-liquidity/types/cl_pool_extensionI.go @@ -21,15 +21,15 @@ type ConcentratedPoolExtension interface { GetCurrentTick() int64 GetExponentAtPriceOne() int64 GetTickSpacing() uint64 - GetLiquidity() sdk.Dec + GetLiquidity() osmomath.Dec GetLastLiquidityUpdate() time.Time SetCurrentSqrtPrice(newSqrtPrice osmomath.BigDec) SetCurrentTick(newTick int64) SetTickSpacing(newTickSpacing uint64) SetLastLiquidityUpdate(newTime time.Time) - UpdateLiquidity(newLiquidity sdk.Dec) - ApplySwap(newLiquidity sdk.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error - CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) (actualAmountDenom0 sdk.Dec, actualAmountDenom1 sdk.Dec, err error) - UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta sdk.Dec) bool + UpdateLiquidity(newLiquidity osmomath.Dec) + ApplySwap(newLiquidity osmomath.Dec, newCurrentTick int64, newCurrentSqrtPrice osmomath.BigDec) error + CalcActualAmounts(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta osmomath.Dec) (actualAmountDenom0 osmomath.Dec, actualAmountDenom1 osmomath.Dec, err error) + UpdateLiquidityIfActivePosition(ctx sdk.Context, lowerTick, upperTick int64, liquidityDelta osmomath.Dec) bool } diff --git a/x/concentrated-liquidity/types/constants.go b/x/concentrated-liquidity/types/constants.go index 2e3f13670aa..2b0d4aa0bd9 100644 --- a/x/concentrated-liquidity/types/constants.go +++ b/x/concentrated-liquidity/types/constants.go @@ -3,8 +3,6 @@ package types import ( "time" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" ) @@ -32,30 +30,30 @@ const ( ) var ( - MaxSpotPrice = sdk.MustNewDecFromStr("100000000000000000000000000000000000000") - MaxSpotPriceBigDec = osmomath.BigDecFromSDKDec(MaxSpotPrice) + MaxSpotPrice = osmomath.MustNewDecFromStr("100000000000000000000000000000000000000") + MaxSpotPriceBigDec = osmomath.BigDecFromDec(MaxSpotPrice) // TODO: remove when https://github.com/osmosis-labs/osmosis/issues/5726 is complete. - MinSpotPrice = sdk.MustNewDecFromStr("0.000000000001") // 10^-12 + MinSpotPrice = osmomath.MustNewDecFromStr("0.000000000001") // 10^-12 // Note: this is the at launch min spot price that is getting lowered to 10^-30 - MinSpotPriceBigDec = osmomath.BigDecFromSDKDec(MinSpotPrice) - MinSpotPriceV2 = osmomath.NewDecWithPrec(1, 30) + MinSpotPriceBigDec = osmomath.BigDecFromDec(MinSpotPrice) + MinSpotPriceV2 = osmomath.NewBigDecWithPrec(1, 30) MaxSqrtPrice = osmomath.MustMonotonicSqrt(MaxSpotPrice) MinSqrtPrice = osmomath.MustMonotonicSqrt(MinSpotPrice) - MaxSqrtPriceBigDec = osmomath.BigDecFromSDKDec(MaxSqrtPrice) - MinSqrtPriceBigDec = osmomath.BigDecFromSDKDec(MinSqrtPrice) + MaxSqrtPriceBigDec = osmomath.BigDecFromDec(MaxSqrtPrice) + MinSqrtPriceBigDec = osmomath.BigDecFromDec(MinSqrtPrice) // Supported uptimes preset to 1 ns, 1 min, 1 hr, 1D, 1W, 2W SupportedUptimes = []time.Duration{time.Nanosecond, time.Minute, time.Hour, time.Hour * 24, time.Hour * 24 * 7, time.Hour * 24 * 7 * 2} AuthorizedTickSpacing = []uint64{1, 10, 100, 1000} - AuthorizedSpreadFactors = []sdk.Dec{ - sdk.ZeroDec(), - sdk.MustNewDecFromStr("0.0001"), // 0.01% - sdk.MustNewDecFromStr("0.0005"), // 0.05% - sdk.MustNewDecFromStr("0.001"), // 0.1% - sdk.MustNewDecFromStr("0.002"), // 0.2% - sdk.MustNewDecFromStr("0.003"), // 0.3% - sdk.MustNewDecFromStr("0.005"), // 0.5% + AuthorizedSpreadFactors = []osmomath.Dec{ + osmomath.ZeroDec(), + osmomath.MustNewDecFromStr("0.0001"), // 0.01% + osmomath.MustNewDecFromStr("0.0005"), // 0.05% + osmomath.MustNewDecFromStr("0.001"), // 0.1% + osmomath.MustNewDecFromStr("0.002"), // 0.2% + osmomath.MustNewDecFromStr("0.003"), // 0.3% + osmomath.MustNewDecFromStr("0.005"), // 0.5% } - DefaultBalancerSharesDiscount = sdk.MustNewDecFromStr("0.05") + DefaultBalancerSharesDiscount = osmomath.MustNewDecFromStr("0.05") // By default, we only authorize one nanosecond (one block) uptime as an option DefaultAuthorizedUptimes = []time.Duration{time.Nanosecond} ) diff --git a/x/concentrated-liquidity/types/errors.go b/x/concentrated-liquidity/types/errors.go index 451a96c04f3..fcff58c65d6 100644 --- a/x/concentrated-liquidity/types/errors.go +++ b/x/concentrated-liquidity/types/errors.go @@ -50,8 +50,8 @@ func (e NotPositiveRequireAmountError) Error() string { } type QualifyingLiquidityOrTimeElapsedNotPositiveError struct { - QualifyingLiquidity sdk.Dec - TimeElapsed sdk.Dec + QualifyingLiquidity osmomath.Dec + TimeElapsed osmomath.Dec } func (e QualifyingLiquidityOrTimeElapsedNotPositiveError) Error() string { @@ -59,7 +59,7 @@ func (e QualifyingLiquidityOrTimeElapsedNotPositiveError) Error() string { } type TimeElapsedNotPositiveError struct { - TimeElapsed sdk.Dec + TimeElapsed osmomath.Dec } func (e TimeElapsedNotPositiveError) Error() string { @@ -117,8 +117,8 @@ func (e InvalidTickError) Error() string { } type InsufficientLiquidityError struct { - Actual sdk.Dec - Available sdk.Dec + Actual osmomath.Dec + Available osmomath.Dec } func (e InsufficientLiquidityError) Error() string { @@ -126,8 +126,8 @@ func (e InsufficientLiquidityError) Error() string { } type InsufficientLiquidityCreatedError struct { - Actual sdk.Int - Minimum sdk.Int + Actual osmomath.Int + Minimum osmomath.Int IsTokenZero bool } @@ -140,7 +140,7 @@ func (e InsufficientLiquidityCreatedError) Error() string { } type NegativeLiquidityError struct { - Liquidity sdk.Dec + Liquidity osmomath.Dec } func (e NegativeLiquidityError) Error() string { @@ -157,8 +157,8 @@ func (e DenomDuplicatedError) Error() string { } type AmountLessThanMinError struct { - TokenAmount sdk.Int - TokenMin sdk.Int + TokenAmount osmomath.Int + TokenMin osmomath.Int } func (e AmountLessThanMinError) Error() string { @@ -166,8 +166,8 @@ func (e AmountLessThanMinError) Error() string { } type AmountGreaterThanMaxError struct { - TokenAmount sdk.Int - TokenMax sdk.Int + TokenAmount osmomath.Int + TokenMax osmomath.Int } func (e AmountGreaterThanMaxError) Error() string { @@ -221,8 +221,8 @@ func (e TickSpacingBoundaryError) Error() string { } type InitialLiquidityZeroError struct { - Amount0 sdk.Int - Amount1 sdk.Int + Amount0 osmomath.Int + Amount1 osmomath.Int } func (e InitialLiquidityZeroError) Error() string { @@ -266,7 +266,7 @@ func (e TickNotFoundError) Error() string { type PriceBoundError struct { ProvidedPrice osmomath.BigDec MinSpotPrice osmomath.BigDec - MaxSpotPrice sdk.Dec + MaxSpotPrice osmomath.Dec } func (e PriceBoundError) Error() string { @@ -274,7 +274,7 @@ func (e PriceBoundError) Error() string { } type SpotPriceNegativeError struct { - ProvidedPrice sdk.Dec + ProvidedPrice osmomath.Dec } func (e SpotPriceNegativeError) Error() string { @@ -290,7 +290,7 @@ func (e SqrtPriceNegativeError) Error() string { } type InvalidSpreadFactorError struct { - ActualSpreadFactor sdk.Dec + ActualSpreadFactor osmomath.Dec } func (e InvalidSpreadFactorError) Error() string { @@ -331,7 +331,7 @@ func (e StartTimeTooEarlyError) Error() string { type IncentiveInsufficientBalanceError struct { PoolId uint64 IncentiveDenom string - IncentiveAmount sdk.Int + IncentiveAmount osmomath.Int } func (e IncentiveInsufficientBalanceError) Error() string { @@ -379,7 +379,7 @@ func (e InvalidIncentiveCoinError) Error() string { type NonPositiveEmissionRateError struct { PoolId uint64 - EmissionRate sdk.Dec + EmissionRate osmomath.Dec } func (e NonPositiveEmissionRateError) Error() string { @@ -406,8 +406,8 @@ func (e InvalidUptimeIndexError) Error() string { } type QueryRangeUnsupportedError struct { - RequestedRange sdk.Int - MaxRange sdk.Int + RequestedRange osmomath.Int + MaxRange osmomath.Int } func (e QueryRangeUnsupportedError) Error() string { @@ -493,7 +493,7 @@ func (e InsufficientUserBalanceError) Error() string { func (e *InsufficientUserBalanceError) Unwrap() error { return e.Err } type InvalidAmountCalculatedError struct { - Amount sdk.Int + Amount osmomath.Int } func (e InvalidAmountCalculatedError) Error() string { @@ -608,7 +608,7 @@ func (e PositionsNotInSameTickRangeError) Error() string { } type InvalidDiscountRateError struct { - DiscountRate sdk.Dec + DiscountRate osmomath.Dec } func (e InvalidDiscountRateError) Error() string { @@ -667,8 +667,8 @@ func (e AddToLastPositionInPoolError) Error() string { type NegativeAmountAddedError struct { PositionId uint64 - Asset0Amount sdk.Int - Asset1Amount sdk.Int + Asset0Amount osmomath.Int + Asset1Amount osmomath.Int } func (e NegativeAmountAddedError) Error() string { @@ -693,8 +693,8 @@ func (e UnauthorizedQuoteDenomError) Error() string { } type UnauthorizedSpreadFactorError struct { - ProvidedSpreadFactor sdk.Dec - AuthorizedSpreadFactors []sdk.Dec + ProvidedSpreadFactor osmomath.Dec + AuthorizedSpreadFactors []osmomath.Dec } func (e UnauthorizedSpreadFactorError) Error() string { @@ -711,7 +711,7 @@ func (e UnauthorizedTickSpacingError) Error() string { } type NonPositiveLiquidityForNewPositionError struct { - LiquidityDelta sdk.Dec + LiquidityDelta osmomath.Dec PositionId uint64 } @@ -721,8 +721,8 @@ func (e NonPositiveLiquidityForNewPositionError) Error() string { type LiquidityWithdrawalError struct { PositionID uint64 - RequestedAmount sdk.Dec - CurrentLiquidity sdk.Dec + RequestedAmount osmomath.Dec + CurrentLiquidity osmomath.Dec } func (e LiquidityWithdrawalError) Error() string { @@ -779,7 +779,7 @@ func (e PositionNotFullRangeError) Error() string { } type Amount0IsNegativeError struct { - Amount0 sdk.Int + Amount0 osmomath.Int } func (e Amount0IsNegativeError) Error() string { @@ -787,7 +787,7 @@ func (e Amount0IsNegativeError) Error() string { } type Amount1IsNegativeError struct { - Amount1 sdk.Int + Amount1 osmomath.Int } func (e Amount1IsNegativeError) Error() string { @@ -854,8 +854,8 @@ func (e SwapNoProgressError) Error() string { type SwapNoProgressWithConsumptionError struct { ComputedSqrtPrice osmomath.BigDec - AmountIn sdk.Dec - AmountOut sdk.Dec + AmountIn osmomath.Dec + AmountOut osmomath.Dec } func (e SwapNoProgressWithConsumptionError) Error() string { @@ -871,7 +871,7 @@ func (e SqrtPriceToTickError) Error() string { } type OverChargeSwapOutGivenInError struct { - AmountSpecifiedRemaining sdk.Dec + AmountSpecifiedRemaining osmomath.Dec } func (e OverChargeSwapOutGivenInError) Error() string { diff --git a/x/concentrated-liquidity/types/expected_keepers.go b/x/concentrated-liquidity/types/expected_keepers.go index 8746040bbba..70c2a5790a3 100644 --- a/x/concentrated-liquidity/types/expected_keepers.go +++ b/x/concentrated-liquidity/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/osmomath" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -40,7 +41,7 @@ type PoolManagerKeeper interface { type GAMMKeeper interface { GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins, error) GetLinkedBalancerPoolID(ctx sdk.Context, poolIdEntering uint64) (uint64, error) - GetTotalPoolShares(ctx sdk.Context, poolId uint64) (sdk.Int, error) + GetTotalPoolShares(ctx sdk.Context, poolId uint64) (osmomath.Int, error) } type PoolIncentivesKeeper interface { @@ -62,7 +63,7 @@ type LockupKeeper interface { CreateLock(ctx sdk.Context, owner sdk.AccAddress, coins sdk.Coins, duration time.Duration) (lockuptypes.PeriodLock, error) CreateLockNoSend(ctx sdk.Context, owner sdk.AccAddress, coins sdk.Coins, duration time.Duration) (lockuptypes.PeriodLock, error) SlashTokensFromLockByID(ctx sdk.Context, lockID uint64, coins sdk.Coins) (*lockuptypes.PeriodLock, error) - GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) sdk.Int + GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) osmomath.Int } // CommunityPoolKeeper defines the contract needed to be fulfilled for distribution keeper. diff --git a/x/concentrated-liquidity/types/gov.go b/x/concentrated-liquidity/types/gov.go index cf921b8eb94..f7b0ef01cf8 100644 --- a/x/concentrated-liquidity/types/gov.go +++ b/x/concentrated-liquidity/types/gov.go @@ -6,6 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -72,7 +74,7 @@ func (p *CreateConcentratedLiquidityPoolsProposal) ValidateBasic() error { } spreadFactor := record.SpreadFactor - if spreadFactor.IsNegative() || spreadFactor.GTE(sdk.OneDec()) { + if spreadFactor.IsNegative() || spreadFactor.GTE(osmomath.OneDec()) { return InvalidSpreadFactorError{ActualSpreadFactor: spreadFactor} } } diff --git a/x/concentrated-liquidity/types/gov.pb.go b/x/concentrated-liquidity/types/gov.pb.go index 20577df9042..37411f29193 100644 --- a/x/concentrated-liquidity/types/gov.pb.go +++ b/x/concentrated-liquidity/types/gov.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -164,10 +164,10 @@ func (m *PoolIdToTickSpacingRecord) GetNewTickSpacing() uint64 { } type PoolRecord struct { - 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"` - TickSpacing uint64 `protobuf:"varint,3,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` - SpreadFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spread_factor" yaml:"spread_factor"` + 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"` + TickSpacing uint64 `protobuf:"varint,3,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + SpreadFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spread_factor" yaml:"spread_factor"` } func (m *PoolRecord) Reset() { *m = PoolRecord{} } @@ -236,41 +236,42 @@ func init() { } var fileDescriptor_e6d167276ceeedc2 = []byte{ - // 541 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0x3f, 0x6f, 0xd3, 0x4c, - 0x18, 0xb7, 0x1b, 0x27, 0xef, 0xcb, 0x25, 0x45, 0xc5, 0x44, 0x6a, 0x68, 0x25, 0x3b, 0xb2, 0x04, - 0x0a, 0x43, 0x6c, 0x0c, 0x13, 0x99, 0x50, 0x5a, 0x55, 0x02, 0x31, 0x54, 0xa6, 0x13, 0x42, 0x8a, - 0x9c, 0xf3, 0x11, 0x4e, 0x71, 0xfc, 0xb8, 0x77, 0xd7, 0x94, 0x7c, 0x03, 0x24, 0x16, 0x36, 0x18, - 0xf3, 0x71, 0x3a, 0x76, 0x44, 0x0c, 0x11, 0x4a, 0x16, 0x56, 0xf2, 0x09, 0x50, 0xee, 0x9c, 0xc4, - 0x29, 0x8a, 0x04, 0x62, 0xb2, 0x9f, 0xbb, 0xdf, 0xf3, 0xfb, 0xf3, 0xdc, 0x1d, 0x6a, 0x00, 0x1f, - 0x00, 0xa7, 0xdc, 0xc3, 0x90, 0x60, 0x92, 0x08, 0x16, 0x0a, 0x12, 0x35, 0x63, 0x7a, 0x7e, 0x41, - 0x23, 0x2a, 0x46, 0x5e, 0x0f, 0x86, 0x6e, 0xca, 0x40, 0x80, 0x79, 0x3f, 0x43, 0xba, 0x79, 0xe4, - 0x0a, 0xe8, 0x0e, 0xfd, 0x2e, 0x11, 0xa1, 0x7f, 0x50, 0xed, 0x41, 0x0f, 0x64, 0x87, 0xb7, 0xf8, - 0x53, 0xcd, 0xce,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 0x1b, 0xfa, 0x4f, 0xbd, 0xf7, 0xdb, 0x1e, 0xbe, 0xf4, 0xd4, 0x2d, 0xc9, 0xe7, 0xfb, 0xe4, 0x57, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xf3, 0xd8, 0xa2, 0x9a, 0x27, 0x04, 0x00, 0x00, + // 545 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xb5, 0x5b, 0x27, 0xdf, 0xc7, 0x24, 0x45, 0xc5, 0x44, 0x6a, 0x68, 0x24, 0x3b, 0xb2, 0x84, + 0x14, 0x16, 0xb5, 0x31, 0xac, 0x08, 0x1b, 0x94, 0x56, 0x48, 0xa0, 0x2e, 0x2a, 0xd3, 0x15, 0x42, + 0x0a, 0x93, 0xf1, 0xe0, 0x8e, 0xe2, 0xf8, 0xba, 0x9e, 0x69, 0x4a, 0xde, 0x00, 0x09, 0x16, 0x2c, + 0x59, 0xe6, 0x71, 0xba, 0xec, 0x12, 0xb1, 0x88, 0x50, 0xb2, 0x61, 0x4b, 0x9e, 0x00, 0x65, 0x26, + 0x3f, 0x4e, 0x51, 0x24, 0x10, 0x3b, 0x5f, 0xcf, 0x39, 0xe7, 0x9e, 0x73, 0xef, 0x0c, 0x6a, 0x00, + 0xef, 0x01, 0x67, 0xdc, 0x23, 0x90, 0x10, 0x9a, 0x88, 0x0c, 0x0b, 0x1a, 0x1e, 0xc4, 0xec, 0xfc, + 0x82, 0x85, 0x4c, 0x0c, 0xbc, 0x08, 0xfa, 0x6e, 0x9a, 0x81, 0x00, 0xf3, 0xfe, 0x1c, 0xe9, 0xe6, + 0x91, 0x4b, 0xa0, 0xdb, 0xf7, 0x3b, 0x54, 0x60, 0x7f, 0xbf, 0x12, 0x41, 0x04, 0x92, 0xe1, 0xcd, + 0xbe, 0x14, 0xd9, 0x99, 0xe8, 0xa8,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b, + 0x7c, 0x51, 0x78, 0x7d, 0xff, 0x89, 0xf7, 0x7e, 0xd3, 0x6b, 0x17, 0x83, 0x94, 0xf2, 0x4e, 0x51, + 0xbe, 0xd9, 0xc7, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x93, 0xc7, 0xda, 0x05, 0x1c, 0x04, 0x00, + 0x00, } func (this *CreateConcentratedLiquidityPoolsProposal) Equal(that interface{}) bool { diff --git a/x/concentrated-liquidity/types/gov_test.go b/x/concentrated-liquidity/types/gov_test.go index 3b088a12c23..f4bee24da87 100644 --- a/x/concentrated-liquidity/types/gov_test.go +++ b/x/concentrated-liquidity/types/gov_test.go @@ -3,10 +3,10 @@ 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/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -16,20 +16,20 @@ func TestCreateConcentratedLiquidityPoolsProposalMarshalUnmarshal(t *testing.T) Denom0: "uion", Denom1: "uosmo", TickSpacing: 100, - SpreadFactor: sdk.MustNewDecFromStr("0.01"), + SpreadFactor: osmomath.MustNewDecFromStr("0.01"), }, { Denom0: "stake", Denom1: "uosmo", TickSpacing: 1000, - SpreadFactor: sdk.MustNewDecFromStr("0.02"), + SpreadFactor: osmomath.MustNewDecFromStr("0.02"), }, { Denom0: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", Denom1: "uosmo", TickSpacing: 10, - SpreadFactor: sdk.MustNewDecFromStr("0.05"), + SpreadFactor: osmomath.MustNewDecFromStr("0.05"), }, } @@ -112,7 +112,7 @@ func TestCreateConcentratedLiquidityPoolsProposal_ValidateBasic(t *testing.T) { Denom0: "uion", Denom1: "uosmo", TickSpacing: 100, - SpreadFactor: sdk.MustNewDecFromStr("0.01"), + SpreadFactor: osmomath.MustNewDecFromStr("0.01"), } withInvalidTickSpacing := func(record types.PoolRecord) types.PoolRecord { @@ -136,7 +136,7 @@ func TestCreateConcentratedLiquidityPoolsProposal_ValidateBasic(t *testing.T) { } withInvalidSpreadFactor := func(record types.PoolRecord) types.PoolRecord { - record.SpreadFactor = sdk.MustNewDecFromStr("1.01") + record.SpreadFactor = osmomath.MustNewDecFromStr("1.01") return record } diff --git a/x/concentrated-liquidity/types/incentive_record.pb.go b/x/concentrated-liquidity/types/incentive_record.pb.go index 9d86d044ca5..39e477c177f 100644 --- a/x/concentrated-liquidity/types/incentive_record.pb.go +++ b/x/concentrated-liquidity/types/incentive_record.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -113,7 +113,7 @@ type IncentiveRecordBody struct { // remaining_coin is the total amount of incentives to be distributed RemainingCoin types1.DecCoin `protobuf:"bytes,1,opt,name=remaining_coin,json=remainingCoin,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.DecCoin" json:"remaining_coin" yaml:"remaining_coins"` // emission_rate is the incentive emission rate per second - EmissionRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=emission_rate,json=emissionRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"emission_rate" yaml:"emission_rate"` + EmissionRate cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=emission_rate,json=emissionRate,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"emission_rate" yaml:"emission_rate"` // start_time is the time when the incentive starts distributing StartTime time.Time `protobuf:"bytes,3,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time" yaml:"start_time"` } @@ -175,42 +175,43 @@ func init() { } var fileDescriptor_9d38bf94e42ee434 = []byte{ - // 548 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xd1, 0x6a, 0x13, 0x41, - 0x14, 0xcd, 0xc6, 0x5a, 0xe9, 0xa4, 0x55, 0xdc, 0x54, 0x9b, 0x86, 0xba, 0x5b, 0x16, 0x95, 0x22, - 0x64, 0x86, 0x54, 0x7c, 0x30, 0x8f, 0x6b, 0x11, 0x02, 0x3e, 0x2d, 0x8a, 0x22, 0xc2, 0x32, 0xbb, - 0x33, 0xae, 0x43, 0xb3, 0x3b, 0x71, 0x67, 0x12, 0xcc, 0x5f, 0x54, 0xf0, 0xc1, 0x6f, 0xf0, 0x4b, - 0xfa, 0xd8, 0x27, 0x11, 0x1f, 0x52, 0x49, 0x7e, 0x40, 0xf2, 0x05, 0x32, 0xb3, 0xb3, 0x49, 0x9a, - 0x5a, 0xe8, 0x53, 0x72, 0x66, 0xee, 0xb9, 0xf7, 0x9c, 0x33, 0x77, 0xc1, 0x33, 0x2e, 0x52, 0x2e, - 0x98, 0x40, 0x31, 0xcf, 0x62, 0x9a, 0xc9, 0x1c, 0x4b, 0x4a, 0x5a, 0x3d, 0xf6, 0x79, 0xc0, 0x08, - 0x93, 0x23, 0xc4, 0xf4, 0x29, 0x1b, 0xd2, 0x30, 0xa7, 0x31, 0xcf, 0x09, 0xec, 0xe7, 0x5c, 0x72, - 0xfb, 0x91, 0xa1, 0xc1, 0x65, 0xda, 0x9c, 0x05, 0x87, 0xed, 0x88, 0x4a, 0xdc, 0x6e, 0xee, 0xc6, - 0xba, 0x2e, 0xd4, 0x24, 0x54, 0x80, 0xa2, 0x43, 0x73, 0x3b, 0xe1, 0x09, 0x2f, 0xce, 0xd5, 0x3f, - 0x73, 0xea, 0x26, 0x9c, 0x27, 0x3d, 0x8a, 0x34, 0x8a, 0x06, 0x1f, 0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 0x00, 0x00, 0xff, 0xff, 0x23, 0xd3, 0x25, 0x13, - 0x22, 0x04, 0x00, 0x00, + // 564 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xcf, 0x6e, 0xd3, 0x30, + 0x1c, 0xc7, 0x9b, 0x32, 0x86, 0xe6, 0x6e, 0x20, 0xd2, 0xc1, 0xba, 0x32, 0x92, 0x29, 0x02, 0x69, + 0x42, 0xaa, 0xad, 0x0e, 0x71, 0xa0, 0xdc, 0x42, 0x2f, 0x95, 0x76, 0x8a, 0x40, 0x20, 0x84, 0x14, + 0x9c, 0xc4, 0x64, 0xd6, 0x9a, 0xb8, 0xc4, 0x6e, 0x45, 0xde, 0x62, 0x48, 0x1c, 0x78, 0x06, 0x9e, + 0x64, 0xc7, 0x9d, 0x10, 0xe2, 0xd0, 0xa1, 0x56, 0xbc, 0x40, 0x9f, 0x00, 0xd9, 0x71, 0xda, 0xae, + 0x03, 0x69, 0xa7, 0xf6, 0x6b, 0xff, 0xbe, 0xbf, 0x3f, 0x1f, 0xff, 0x02, 0x9e, 0x31, 0x9e, 0x30, + 0x4e, 0x39, 0x0a, 0x59, 0x1a, 0x92, 0x54, 0x64, 0x58, 0x90, 0xa8, 0xd5, 0xa7, 0x9f, 0x86, 0x34, + 0xa2, 0x22, 0x47, 0x54, 0x9d, 0xd2, 0x11, 0xf1, 0x33, 0x12, 0xb2, 0x2c, 0x82, 0x83, 0x8c, 0x09, + 0x66, 0x3e, 0xd6, 0x36, 0xb8, 0x6c, 0x9b, 0xbb, 0xe0, 0xa8, 0x1d, 0x10, 0x81, 0xdb, 0xcd, 0xdd, + 0x50, 0xc5, 0xf9, 0xca, 0x84, 0x0a, 0x51, 0x64, 0x68, 0x6e, 0xc7, 0x2c, 0x66, 0xc5, 0xb9, 0xfc, + 0xa7, 0x4f, 0xed, 0x98, 0xb1, 0xb8, 0x4f, 0x90, 0x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56, 0x1f, 0x07, 0xbc, 0x14, 0x68, 0xd4, 0x7e, 0x8e, 0x3e, 0xff, 0xef, 0x43, 0x57, + 0xc0, 0x82, 0x75, 0xd5, 0xdb, 0xd3, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x98, 0x15, 0x4d, 0x6c, + 0x17, 0x04, 0x00, 0x00, } func (m *IncentiveRecord) Marshal() (dAtA []byte, err error) { diff --git a/x/concentrated-liquidity/types/msgs.go b/x/concentrated-liquidity/types/msgs.go index e910ae18524..429cd028c1c 100644 --- a/x/concentrated-liquidity/types/msgs.go +++ b/x/concentrated-liquidity/types/msgs.go @@ -5,6 +5,8 @@ import ( "strconv" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // constants. @@ -44,7 +46,7 @@ func (msg MsgCreatePosition) ValidateBasic() error { } for _, coin := range msg.TokensProvided { - if coin.Amount.LTE(sdk.ZeroInt()) { + if coin.Amount.LTE(osmomath.ZeroInt()) { return NotPositiveRequireAmountError{Amount: coin.Amount.String()} } } diff --git a/x/concentrated-liquidity/types/msgs_test.go b/x/concentrated-liquidity/types/msgs_test.go index bdbd167d0c5..f2fe1f505c8 100644 --- a/x/concentrated-liquidity/types/msgs_test.go +++ b/x/concentrated-liquidity/types/msgs_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" appParams "github.com/osmosis-labs/osmosis/v19/app/params" @@ -56,9 +57,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()), sdk.NewCoin("osmo", sdk.OneInt())), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.OneInt()), sdk.NewCoin("osmo", osmomath.OneInt())), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: true, }, @@ -69,9 +70,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: invalidAddr.String(), LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()), sdk.NewCoin("osmo", sdk.OneInt())), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.OneInt()), sdk.NewCoin("osmo", osmomath.OneInt())), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -82,9 +83,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 10, UpperTick: 1, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()), sdk.NewCoin("osmo", sdk.OneInt())), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.OneInt()), sdk.NewCoin("osmo", osmomath.OneInt())), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -95,9 +96,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.Coins{sdk.Coin{Denom: "stake", Amount: sdk.NewInt(-10)}, sdk.NewCoin("osmo", sdk.OneInt())}, - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.Coins{sdk.Coin{Denom: "stake", Amount: osmomath.NewInt(-10)}, sdk.NewCoin("osmo", osmomath.OneInt())}, + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -108,9 +109,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.Coins{sdk.NewCoin("stake", sdk.OneInt()), sdk.Coin{Denom: "osmo", Amount: sdk.NewInt(-10)}}, - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.Coins{sdk.NewCoin("stake", osmomath.OneInt()), sdk.Coin{Denom: "osmo", Amount: osmomath.NewInt(-10)}}, + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -121,9 +122,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt()), sdk.NewCoin("osmo", sdk.ZeroInt())), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.ZeroInt()), sdk.NewCoin("osmo", osmomath.ZeroInt())), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -134,9 +135,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 10, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.ZeroInt()), sdk.NewCoin("osmo", sdk.ZeroInt())), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.ZeroInt()), sdk.NewCoin("osmo", osmomath.ZeroInt())), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, expectPass: false, }, @@ -147,9 +148,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()), sdk.NewCoin("osmo", sdk.OneInt())), - TokenMinAmount0: sdk.NewInt(-1), - TokenMinAmount1: sdk.NewInt(-1), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.OneInt()), sdk.NewCoin("osmo", osmomath.OneInt())), + TokenMinAmount0: osmomath.NewInt(-1), + TokenMinAmount1: osmomath.NewInt(-1), }, expectPass: false, }, @@ -160,9 +161,9 @@ func TestMsgCreatePosition(t *testing.T) { Sender: addr1, LowerTick: 1, UpperTick: 10, - TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", sdk.OneInt()), sdk.NewCoin("osmo", sdk.OneInt())), - TokenMinAmount0: sdk.ZeroInt(), - TokenMinAmount1: sdk.ZeroInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("stake", osmomath.OneInt()), sdk.NewCoin("osmo", osmomath.OneInt())), + TokenMinAmount0: osmomath.ZeroInt(), + TokenMinAmount1: osmomath.ZeroInt(), }, expectPass: true, }, @@ -177,10 +178,10 @@ func TestMsgAddToPosition(t *testing.T) { baseMsg := types.MsgAddToPosition{ PositionId: 1, Sender: addr1, - Amount0: sdk.OneInt(), - Amount1: sdk.OneInt(), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + Amount0: osmomath.OneInt(), + Amount1: osmomath.OneInt(), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), } tests := []struct { @@ -205,22 +206,30 @@ func TestMsgAddToPosition(t *testing.T) { }, { name: "amount0 is negative", - msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.Amount0 = sdk.OneInt().Neg(); return copy }, + msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.Amount0 = osmomath.OneInt().Neg(); return copy }, expectPass: false, }, { name: "amount1 is negative", - msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.Amount1 = sdk.OneInt().Neg(); return copy }, + msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.Amount1 = osmomath.OneInt().Neg(); return copy }, expectPass: false, }, { - name: "token min amount0 is negative", - msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.TokenMinAmount0 = sdk.OneInt().Neg(); return copy }, + name: "token min amount0 is negative", + msgFn: func() types.MsgAddToPosition { + copy := baseMsg + copy.TokenMinAmount0 = osmomath.OneInt().Neg() + return copy + }, expectPass: false, }, { - name: "token min amount1 is negative", - msgFn: func() types.MsgAddToPosition { copy := baseMsg; copy.TokenMinAmount1 = sdk.OneInt().Neg(); return copy }, + name: "token min amount1 is negative", + msgFn: func() types.MsgAddToPosition { + copy := baseMsg + copy.TokenMinAmount1 = osmomath.OneInt().Neg() + return copy + }, expectPass: false, }, { @@ -286,7 +295,7 @@ func TestMsgWithdrawPosition(t *testing.T) { msg: types.MsgWithdrawPosition{ PositionId: 1, Sender: addr1, - LiquidityAmount: sdk.OneDec(), + LiquidityAmount: osmomath.OneDec(), }, expectPass: true, }, @@ -295,7 +304,7 @@ func TestMsgWithdrawPosition(t *testing.T) { msg: types.MsgWithdrawPosition{ PositionId: 1, Sender: invalidAddr.String(), - LiquidityAmount: sdk.OneDec(), + LiquidityAmount: osmomath.OneDec(), }, expectPass: false, }, @@ -326,7 +335,7 @@ func TestConcentratedLiquiditySerialization(t *testing.T) { clMsg: &types.MsgWithdrawPosition{ PositionId: 1, Sender: addr1, - LiquidityAmount: sdk.NewDec(100), + LiquidityAmount: osmomath.NewDec(100), }, }, { @@ -336,9 +345,9 @@ func TestConcentratedLiquiditySerialization(t *testing.T) { Sender: addr1, LowerTick: int64(10000), UpperTick: int64(20000), - TokensProvided: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000)), sdk.NewCoin("bar", sdk.NewInt(1000))), - TokenMinAmount0: sdk.OneInt(), - TokenMinAmount1: sdk.OneInt(), + TokensProvided: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1000)), sdk.NewCoin("bar", osmomath.NewInt(1000))), + TokenMinAmount0: osmomath.OneInt(), + TokenMinAmount1: osmomath.OneInt(), }, }, { diff --git a/x/concentrated-liquidity/types/params.go b/x/concentrated-liquidity/types/params.go index 2014f45b26e..bc375ad34ce 100644 --- a/x/concentrated-liquidity/types/params.go +++ b/x/concentrated-liquidity/types/params.go @@ -6,6 +6,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // Parameter store keys. @@ -25,7 +27,7 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(authorizedTickSpacing []uint64, authorizedSpreadFactors []sdk.Dec, discountRate sdk.Dec, authorizedQuoteDenoms []string, authorizedUptimes []time.Duration, isPermissionlessPoolCreationEnabled bool) Params { +func NewParams(authorizedTickSpacing []uint64, authorizedSpreadFactors []osmomath.Dec, discountRate osmomath.Dec, authorizedQuoteDenoms []string, authorizedUptimes []time.Duration, isPermissionlessPoolCreationEnabled bool) Params { return Params{ AuthorizedTickSpacing: authorizedTickSpacing, AuthorizedSpreadFactors: authorizedSpreadFactors, @@ -126,11 +128,11 @@ func validateTicks(i interface{}) error { return nil } -// validateSpreadFactors validates that the given parameter is a slice of strings that can be converted to sdk.Decs. +// validateSpreadFactors validates that the given parameter is a slice of strings that can be converted to osmomath.Decs. // If the parameter is not of the correct type or any of the strings cannot be converted, an error is returned. func validateSpreadFactors(i interface{}) error { - // Convert the given parameter to a slice of sdk.Decs. - _, ok := i.([]sdk.Dec) + // Convert the given parameter to a slice of osmomath.Decs. + _, ok := i.([]osmomath.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -177,17 +179,17 @@ func validateIsPermissionLessPoolCreationEnabled(i interface{}) error { return nil } -// validateBalancerSharesDiscount validates that the given parameter is a sdk.Dec. Returns error if the parameter is not of the correct type. +// validateBalancerSharesDiscount validates that the given parameter is a osmomath.Dec. Returns error if the parameter is not of the correct type. func validateBalancerSharesDiscount(i interface{}) error { - // Convert the given parameter to sdk.Dec. - balancerSharesRewardDiscount, ok := i.(sdk.Dec) + // Convert the given parameter to osmomath.Dec. + balancerSharesRewardDiscount, ok := i.(osmomath.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } // Ensure that the passed in discount rate is between 0 and 1. - if balancerSharesRewardDiscount.IsNegative() || balancerSharesRewardDiscount.GT(sdk.OneDec()) { + if balancerSharesRewardDiscount.IsNegative() || balancerSharesRewardDiscount.GT(osmomath.OneDec()) { return InvalidDiscountRateError{DiscountRate: balancerSharesRewardDiscount} } diff --git a/x/concentrated-liquidity/types/params.pb.go b/x/concentrated-liquidity/types/params.pb.go index 787d26e99bf..a69d99a2303 100644 --- a/x/concentrated-liquidity/types/params.pb.go +++ b/x/concentrated-liquidity/types/params.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" 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" @@ -34,15 +34,15 @@ type Params struct { // spacing values concentrated-liquidity pools can be created with. For // example, an authorized_tick_spacing of [1, 10, 30] allows for pools // to be created with tick spacing of 1, 10, or 30. - AuthorizedTickSpacing []uint64 `protobuf:"varint,1,rep,packed,name=authorized_tick_spacing,json=authorizedTickSpacing,proto3" json:"authorized_tick_spacing,omitempty" yaml:"authorized_tick_spacing"` - AuthorizedSpreadFactors []github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,rep,name=authorized_spread_factors,json=authorizedSpreadFactors,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"authorized_spread_factors" yaml:"authorized_spread_factors"` + AuthorizedTickSpacing []uint64 `protobuf:"varint,1,rep,packed,name=authorized_tick_spacing,json=authorizedTickSpacing,proto3" json:"authorized_tick_spacing,omitempty" yaml:"authorized_tick_spacing"` + AuthorizedSpreadFactors []cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,rep,name=authorized_spread_factors,json=authorizedSpreadFactors,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"authorized_spread_factors" yaml:"authorized_spread_factors"` // balancer_shares_reward_discount is the rate by which incentives flowing // from CL to Balancer pools will be discounted to encourage LPs to migrate. // e.g. a rate of 0.05 means Balancer LPs get 5% less incentives than full // range CL LPs. // This field can range from (0,1]. If set to 1, it indicates that all // incentives stay at cl pool. - BalancerSharesRewardDiscount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=balancer_shares_reward_discount,json=balancerSharesRewardDiscount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"balancer_shares_reward_discount" yaml:"balancer_shares_reward_discount"` + BalancerSharesRewardDiscount cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=balancer_shares_reward_discount,json=balancerSharesRewardDiscount,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"balancer_shares_reward_discount" yaml:"balancer_shares_reward_discount"` // authorized_quote_denoms is a list of quote denoms that can be used as // token1 when creating a pool. We limit the quote assets to a small set for // the purposes of having convinient price increments stemming from tick to @@ -130,42 +130,42 @@ func init() { } var fileDescriptor_cd3784445b6f6ba7 = []byte{ - // 546 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x93, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x63, 0x52, 0x22, 0x6a, 0x26, 0x2c, 0x10, 0x4e, 0x05, 0xb6, 0x65, 0xa4, 0x12, 0x09, - 0x6a, 0x8b, 0x32, 0x01, 0x9b, 0x09, 0xcc, 0xc5, 0x01, 0x09, 0x55, 0x48, 0xa7, 0xf3, 0xf9, 0xea, - 0x9c, 0x62, 0xfb, 0xb9, 0x77, 0x67, 0x20, 0xec, 0x20, 0x26, 0xc4, 0xc8, 0xc6, 0xd7, 0xe9, 0xd8, - 0x11, 0x31, 0x18, 0x94, 0x6c, 0x8c, 0xf9, 0x04, 0x28, 0x67, 0x87, 0x3a, 0x94, 0x0a, 0x98, 0xec, - 0xf7, 0xfe, 0xbf, 0xf7, 0xee, 0xdd, 0x7b, 0xef, 0xf4, 0x5b, 0x20, 0x32, 0x10, 0x4c, 0xf8, 0x04, - 0x72, 0x42, 0x73, 0xc9, 0xb1, 0xa4, 0xf1, 0x4e, 0xca, 0x0e, 0x4b, 0x16, 0x33, 0x39, 0xf5, 0x0b, - 0xcc, 0x71, 0x26, 0xbc, 0x82, 0x83, 0x04, 0xe3, 0x7a, 0x03, 0x7b, 0x6d, 0xf8, 0x17, 0xbb, 0x75, - 0x39, 0x81, 0x04, 0x14, 0xe9, 0x2f, 0xff, 0xea, 0xa0, 0xad, 0x3e, 0x51, 0x51, 0xa8, 0x16, 0x6a, - 0xa3, 0x91, 0xac, 0x04, 0x20, 0x49, 0xa9, 0xaf, 0xac, 0xa8, 0x3c, 0xf0, 0xe3, 0x92, 0x63, 0xc9, - 0x20, 0xaf, 0x75, 0xf7, 0x5d, 0x4f, 0xef, 0xed, 0xa9, 0x02, 0x8c, 0x7d, 0xfd, 0x2a, 0x2e, 0xe5, - 0x18, 0x38, 0x7b, 0x43, 0x63, 0x24, 0x19, 0x99, 0x20, 0x51, 0x60, 0xc2, 0xf2, 0xc4, 0xd4, 0x9c, - 0xee, 0x60, 0x23, 0x70, 0x17, 0x95, 0x6d, 0x4d, 0x71, 0x96, 0xde, 0x77, 0xcf, 0x00, 0xdd, 0xf0, - 0xca, 0x89, 0xf2, 0x94, 0x91, 0xc9, 0xa8, 0xf6, 0x1b, 0x1f, 0x34, 0xbd, 0xdf, 0x8a, 0x11, 0x05, - 0xa7, 0x38, 0x46, 0x07, 0x98, 0x48, 0xe0, 0xc2, 0x3c, 0xe7, 0x74, 0x07, 0x9b, 0x41, 0x78, 0x54, - 0xd9, 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0xc6, 0x7b, 0x4d, 0xbf, 0xc9, 0x04, 0x2a, 0x28, - 0xcf, 0x98, 0x10, 0x0c, 0xf2, 0x94, 0x0a, 0x81, 0x0a, 0x80, 0x14, 0x11, 0x4e, 0xd5, 0x09, 0x88, - 0xe6, 0x38, 0x4a, 0x69, 0x6c, 0xf6, 0x1c, 0x6d, 0x70, 0x21, 0xd8, 0x5d, 0x54, 0xb6, 0x57, 0x9f, - 0xf3, 0x8f, 0x81, 0x6e, 0x78, 0x83, 0x89, 0xbd, 0x35, 0x70, 0x0f, 0x20, 0x7d, 0xd8, 0x60, 0x8f, - 0x6a, 0x2a, 0x78, 0x71, 0x34, 0xb3, 0xb4, 0xe3, 0x99, 0xa5, 0x7d, 0x9f, 0x59, 0xda, 0xc7, 0xb9, - 0xd5, 0x39, 0x9e, 0x5b, 0x9d, 0x2f, 0x73, 0xab, 0xb3, 0x1f, 0xb4, 0x06, 0xdf, 0xbc, 0xce, 0x9d, - 0x14, 0x47, 0x62, 0x65, 0xf8, 0x2f, 0xef, 0xdc, 0xf3, 0x5f, 0x9f, 0xf5, 0xba, 0xd5, 0x62, 0x44, - 0x3d, 0xd5, 0xcb, 0xbb, 0x3f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xfa, 0x5f, 0x9a, 0x0c, 0x04, - 0x00, 0x00, + // 552 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0xb1, 0x6f, 0xd3, 0x4e, + 0x14, 0xc7, 0xe3, 0x5f, 0xda, 0xe8, 0x57, 0x33, 0x61, 0x81, 0x70, 0x0a, 0xd8, 0x96, 0x91, 0x20, + 0x12, 0xd4, 0x16, 0x65, 0x02, 0x36, 0x13, 0x60, 0x01, 0x29, 0x38, 0xb0, 0x54, 0x48, 0xa7, 0xf3, + 0xf9, 0xea, 0x9c, 0x62, 0xfb, 0xb9, 0x77, 0x67, 0x20, 0xac, 0x08, 0x89, 0x91, 0x81, 0x81, 0x3f, + 0xa9, 0x63, 0x47, 0xc4, 0x60, 0x50, 0xb2, 0x31, 0xa1, 0xfc, 0x05, 0x28, 0x3e, 0x87, 0x26, 0x94, + 0x8a, 0x6e, 0xf7, 0xde, 0xf7, 0xf3, 0xde, 0xbd, 0xfb, 0xea, 0x9d, 0x7e, 0x13, 0x44, 0x06, 0x82, + 0x09, 0x9f, 0x40, 0x4e, 0x68, 0x2e, 0x39, 0x96, 0x34, 0xde, 0x49, 0xd9, 0x41, 0xc9, 0x62, 0x26, + 0x27, 0x7e, 0x81, 0x39, 0xce, 0x84, 0x57, 0x70, 0x90, 0x60, 0x5c, 0x6d, 0x60, 0x6f, 0x15, 0xfe, + 0xcd, 0x6e, 0x5f, 0x48, 0x20, 0x81, 0x9a, 0xf4, 0x17, 0x27, 0x55, 0xb4, 0xdd, 0x25, 0x75, 0x15, + 0x52, 0x82, 0x0a, 0x1a, 0xc9, 0x4a, 0x00, 0x92, 0x94, 0xfa, 0x75, 0x14, 0x95, 0xfb, 0x7e, 0x5c, + 0x72, 0x2c, 0x19, 0xe4, 0x4a, 0x77, 0x7f, 0x6e, 0xea, 0x9d, 0x41, 0x3d, 0x80, 0xb1, 0xa7, 0x5f, + 0xc2, 0xa5, 0x1c, 0x01, 0x67, 0x6f, 0x69, 0x8c, 0x24, 0x23, 0x63, 0x24, 0x0a, 0x4c, 0x58, 0x9e, + 0x98, 0x9a, 0xd3, 0xee, 0x6d, 0x04, 0xee, 0xbc, 0xb2, 0xad, 0x09, 0xce, 0xd2, 0x7b, 0xee, 0x29, + 0xa0, 0x1b, 0x5e, 0x3c, 0x56, 0x9e, 0x33, 0x32, 0x1e, 0xaa, 0xbc, 0xf1, 0x4e, 0xd3, 0xbb, 0x2b, + 0x35, 0xa2, 0xe0, 0x14, 0xc7, 0x68, 0x1f, 0x13, 0x09, 0x5c, 0x98, 0xff, 0x39, 0xed, 0xde, 0x56, + 0xf0, 0xf8, 0xb0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, 0x0f, 0x9a, 0x7e, 0x83, 0x09, 0x54, 0x50, 0x9e, + 0x31, 0x21, 0x18, 0xe4, 0x29, 0x15, 0x02, 0x15, 0x00, 0x29, 0x22, 0x9c, 0xd6, 0x37, 0x20, 0x9a, + 0xe3, 0x28, 0xa5, 0xb1, 0xd9, 0x71, 0xb4, 0xde, 0xff, 0xc1, 0xee, 0xbc, 0xb2, 0x3d, 0x75, 0xcf, + 0x19, 0x0b, 0xdd, 0xf0, 0x1a, 0x13, 0x83, 0x35, 0x70, 0x00, 0x90, 0x3e, 0x68, 0xb0, 0x87, 0x8a, + 0x0a, 0x5e, 0x1e, 0x4e, 0x2d, 0xed, 0x68, 0x6a, 0x69, 0xdf, 0xa7, 0x96, 0xf6, 0x71, 0x66, 0xb5, + 0x8e, 0x66, 0x56, 0xeb, 0xcb, 0xcc, 0x6a, 0xed, 0x05, 0x09, 0x93, 0xa3, 0x32, 0xf2, 0x08, 0x64, + 0x7e, 0xf3, 0x0f, 0x77, 0x52, 0x1c, 0x89, 0x65, 0xe0, 0xbf, 0xba, 0x7d, 0xd7, 0x7f, 0x73, 0xda, + 0x3f, 0x96, 0x93, 0x82, 0x8a, 0xa8, 0x53, 0x7b, 0x79, 0xe7, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x2d, 0x6c, 0x62, 0xc6, 0xf6, 0x03, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -455,7 +455,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - var v github_com_cosmos_cosmos_sdk_types.Dec + var v cosmossdk_io_math.LegacyDec m.AuthorizedSpreadFactors = append(m.AuthorizedSpreadFactors, v) if err := m.AuthorizedSpreadFactors[len(m.AuthorizedSpreadFactors)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/x/concentrated-liquidity/types/params_test.go b/x/concentrated-liquidity/types/params_test.go index 2f933be751f..788a384375e 100644 --- a/x/concentrated-liquidity/types/params_test.go +++ b/x/concentrated-liquidity/types/params_test.go @@ -3,9 +3,9 @@ package types_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -74,22 +74,22 @@ func TestValidateBalancerSharesDiscount(t *testing.T) { i: types.DefaultBalancerSharesDiscount, }, "zero discount rate": { - i: sdk.NewDec(0), + i: osmomath.NewDec(0), }, "error: negative discount rate": { - i: sdk.NewDec(-1), + i: osmomath.NewDec(-1), expectError: true, }, "error: negative discount rate on boundary": { - i: sdk.NewDecWithPrec(-1, 18), + i: osmomath.NewDecWithPrec(-1, 18), expectError: true, }, "error: discount rate > 1": { - i: sdk.NewDec(2), + i: osmomath.NewDec(2), expectError: true, }, "error: discount rate > 1 on boundary": { - i: sdk.NewDec(1).Add(sdk.NewDecWithPrec(1, 18)), + i: osmomath.NewDec(1).Add(osmomath.NewDecWithPrec(1, 18)), expectError: true, }, } diff --git a/x/concentrated-liquidity/types/tx.pb.go b/x/concentrated-liquidity/types/tx.pb.go index 545051ce379..e15a0cef088 100644 --- a/x/concentrated-liquidity/types/tx.pb.go +++ b/x/concentrated-liquidity/types/tx.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -43,8 +44,8 @@ type MsgCreatePosition struct { // and at a maximum be of length 2 (for a position that straddles the current // tick). TokensProvided github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,5,rep,name=tokens_provided,json=tokensProvided,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_provided"` - TokenMinAmount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=token_min_amount0,json=tokenMinAmount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount0" yaml:"token_min_amount0"` - TokenMinAmount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=token_min_amount1,json=tokenMinAmount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount1" yaml:"token_min_amount1"` + TokenMinAmount0 cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=token_min_amount0,json=tokenMinAmount0,proto3,customtype=cosmossdk.io/math.Int" json:"token_min_amount0" yaml:"token_min_amount0"` + TokenMinAmount1 cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=token_min_amount1,json=tokenMinAmount1,proto3,customtype=cosmossdk.io/math.Int" json:"token_min_amount1" yaml:"token_min_amount1"` } func (m *MsgCreatePosition) Reset() { *m = MsgCreatePosition{} } @@ -116,10 +117,10 @@ func (m *MsgCreatePosition) GetTokensProvided() github_com_cosmos_cosmos_sdk_typ } type MsgCreatePositionResponse struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` - LiquidityCreated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=liquidity_created,json=liquidityCreated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_created" yaml:"liquidity_created"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount0"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount1"` + LiquidityCreated cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=liquidity_created,json=liquidityCreated,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_created" yaml:"liquidity_created"` // the lower and upper tick are in the response because there are // instances in which multiple ticks represent the same price, so // we may move their provided tick to the canonical tick that represents @@ -187,19 +188,19 @@ type MsgAddToPosition struct { PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` // amount0 represents the amount of token0 willing to put in. - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount_0"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount_0"` // amount1 represents the amount of token1 willing to put in. - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount_1"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount_1"` // token_min_amount0 represents the minimum amount of token0 desired from the // new position being created. Note that this field indicates the min amount0 // corresponding to the liquidity that is being added, not the total // liquidity of the position. - TokenMinAmount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=token_min_amount0,json=tokenMinAmount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount0" yaml:"token_min_amount0"` + TokenMinAmount0 cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=token_min_amount0,json=tokenMinAmount0,proto3,customtype=cosmossdk.io/math.Int" json:"token_min_amount0" yaml:"token_min_amount0"` // token_min_amount1 represents the minimum amount of token1 desired from the // new position being created. Note that this field indicates the min amount1 // corresponding to the liquidity that is being added, not the total // liquidity of the position. - TokenMinAmount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,6,opt,name=token_min_amount1,json=tokenMinAmount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_min_amount1" yaml:"token_min_amount1"` + TokenMinAmount1 cosmossdk_io_math.Int `protobuf:"bytes,6,opt,name=token_min_amount1,json=tokenMinAmount1,proto3,customtype=cosmossdk.io/math.Int" json:"token_min_amount1" yaml:"token_min_amount1"` } func (m *MsgAddToPosition) Reset() { *m = MsgAddToPosition{} } @@ -250,9 +251,9 @@ func (m *MsgAddToPosition) GetSender() string { } type MsgAddToPositionResponse struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount0"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount1"` } func (m *MsgAddToPositionResponse) Reset() { *m = MsgAddToPositionResponse{} } @@ -297,9 +298,9 @@ func (m *MsgAddToPositionResponse) GetPositionId() uint64 { // ===================== MsgWithdrawPosition type MsgWithdrawPosition struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - LiquidityAmount github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=liquidity_amount,json=liquidityAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_amount" yaml:"liquidity_amount"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + LiquidityAmount cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=liquidity_amount,json=liquidityAmount,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_amount" yaml:"liquidity_amount"` } func (m *MsgWithdrawPosition) Reset() { *m = MsgWithdrawPosition{} } @@ -350,8 +351,8 @@ func (m *MsgWithdrawPosition) GetSender() string { } type MsgWithdrawPositionResponse struct { - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount0"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount1"` } func (m *MsgWithdrawPositionResponse) Reset() { *m = MsgWithdrawPositionResponse{} } @@ -706,80 +707,81 @@ func init() { } var fileDescriptor_1f1fff802923d7db = []byte{ - // 1156 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x58, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0xae, 0x93, 0x34, 0x55, 0xa7, 0xf4, 0x23, 0x6e, 0x69, 0xd3, 0xec, 0x12, 0x97, 0x11, 0x1f, - 0x59, 0x50, 0xe2, 0xcd, 0x82, 0x04, 0x04, 0x09, 0xb6, 0x29, 0x5a, 0x29, 0x48, 0x11, 0x2b, 0xef, - 0x4a, 0x48, 0xbb, 0x48, 0x91, 0x63, 0x4f, 0xdd, 0x51, 0x13, 0x8f, 0xf1, 0x38, 0xcd, 0xf6, 0x27, - 0xf0, 0x71, 0x40, 0x2b, 0x71, 0x04, 0xc1, 0x0d, 0x71, 0x40, 0xfc, 0x05, 0x6e, 0x7b, 0xe0, 0xb0, - 0x17, 0x24, 0xc4, 0xc1, 0xa0, 0xf6, 0xc0, 0x0d, 0x89, 0xfc, 0x02, 0x64, 0x8f, 0x3d, 0x76, 0x9d, - 0x14, 0xea, 0xb4, 0x74, 0x0f, 0x7b, 0x69, 0xe3, 0x99, 0xf7, 0x7d, 0xe6, 0x99, 0xe7, 0x7d, 0xe6, - 0x1d, 0x27, 0xe0, 0x65, 0x42, 0xfb, 0x84, 0x62, 0x2a, 0x6b, 0xc4, 0xd4, 0x90, 0xe9, 0xd8, 0xaa, - 0x83, 0xf4, 0x6a, 0x0f, 0x7f, 0x3c, 0xc0, 0x3a, 0x76, 0x0e, 0x65, 0xe7, 0x41, 0xcd, 0xb2, 0x89, - 0x43, 0xc4, 0x17, 0x83, 0xc0, 0x5a, 0x3c, 0x90, 0xc7, 0xd5, 0x0e, 0xea, 0x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, 0xbe, 0x7c, 0x4e, 0xf0, 0x4b, 0x01, 0x14, - 0xc6, 0xbb, 0xee, 0xdb, 0xa9, 0xd1, 0xa3, 0xe4, 0xd2, 0xce, 0x39, 0x92, 0x43, 0x5e, 0xcd, 0x8f, - 0x1e, 0x1d, 0x95, 0x85, 0xc7, 0x47, 0x65, 0xe1, 0x8f, 0xa3, 0xb2, 0xf0, 0xc5, 0x71, 0x79, 0xe6, - 0xf1, 0x71, 0x79, 0xe6, 0xd7, 0xe3, 0xf2, 0xcc, 0xbd, 0x66, 0xac, 0xc9, 0x04, 0x0b, 0x55, 0x7b, - 0x6a, 0x97, 0x86, 0x0f, 0xf2, 0x41, 0xfd, 0x2d, 0xf9, 0xc1, 0xa9, 0x3f, 0x14, 0x79, 0x4d, 0xa8, - 0x9b, 0xf7, 0x7f, 0x7b, 0x79, 0xed, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa6, 0x4e, 0x2a, 0x3e, - 0x57, 0x12, 0x00, 0x00, + // 1174 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x58, 0xcf, 0x6f, 0xe3, 0x44, + 0x1b, 0xee, 0x34, 0xdd, 0x54, 0x3b, 0xfd, 0xfa, 0x23, 0x6e, 0xb7, 0x4d, 0xd3, 0xfd, 0xe2, 0x32, + 0x02, 0x91, 0x05, 0x25, 0x6e, 0x16, 0x24, 0xd8, 0x20, 0xed, 0xb2, 0x29, 0x5a, 0x29, 0x2b, 0x22, + 0x56, 0xde, 0x95, 0x90, 0x10, 0x52, 0xe4, 0x78, 0xa6, 0xee, 0xa8, 0x89, 0x27, 0x78, 0x9c, 0x76, + 0xfb, 0x17, 0x20, 0x10, 0x07, 0x84, 0xc4, 0x11, 0x04, 0x37, 0xc4, 0x01, 0x21, 0x71, 0xe5, 0xc8, + 0x61, 0x0f, 0x1c, 0xf6, 0x88, 0x38, 0x18, 0xd4, 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24, 0x52, 0x01, 0x48, 0x9f, 0xb7, 0x89, 0xec, 0x96, 0x0d, 0x7c, 0xf3, 0x8f, 0x2b, + 0x30, 0xd3, 0xe4, 0x96, 0xf2, 0x11, 0x80, 0x0b, 0xa9, 0x2f, 0x52, 0xaf, 0x56, 0xce, 0xf5, 0x85, + 0xb0, 0x32, 0x74, 0x87, 0x2e, 0xbc, 0x3e, 0x69, 0xa6, 0xdc, 0xda, 0x27, 0x00, 0x2e, 0x0d, 0xbd, + 0xe5, 0x6a, 0xe7, 0x87, 0x4d, 0xe7, 0x16, 0xea, 0x93, 0xe7, 0x4a, 0x52, 0x1f, 0x00, 0x38, 0x9f, + 0xba, 0x66, 0x9e, 0x1f, 0xf5, 0x44, 0x62, 0xe1, 0xce, 0x84, 0x89, 0x92, 0xcb, 0xe7, 0x00, 0xae, + 0x8c, 0x7c, 0x8d, 0xdc, 0x1e, 0x43, 0xfb, 0x11, 0xf9, 0x85, 0x7b, 0x17, 0xcb, 0x97, 0x04, 0x3f, + 0x05, 0x30, 0x37, 0xdc, 0x75, 0x5f, 0x1b, 0x1b, 0x3d, 0x4e, 0x2e, 0x6c, 0x5f, 0x20, 0x39, 0xe2, + 0x55, 0x7f, 0xf7, 0xc9, 0x51, 0x11, 0x3c, 0x3d, 0x2a, 0x82, 0x5f, 0x8f, 0x8a, 0xe0, 0xe3, 0xe3, + 0xe2, 0xd4, 0xd3, 0xe3, 0xe2, 0xd4, 0x4f, 0xc7, 0xc5, 0xa9, 0x77, 0xea, 0x89, 0x26, 0x13, 0x2e, + 0x54, 0xee, 0x18, 0x6d, 0x1e, 0x3d, 0x68, 0xfb, 0xd5, 0x5b, 0xda, 0xe3, 0x53, 0x7f, 0x46, 0xf1, + 0x9b, 0x50, 0x3b, 0x1b, 0xfc, 0x32, 0xf1, 0xd2, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x28, 0x46, + 0xa1, 0x3c, 0x75, 0x11, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/cosmwasmpool/cosmwasm/msg/module_query_msg.go b/x/cosmwasmpool/cosmwasm/msg/module_query_msg.go index d4bff80797a..c6f7521f129 100644 --- a/x/cosmwasmpool/cosmwasm/msg/module_query_msg.go +++ b/x/cosmwasmpool/cosmwasm/msg/module_query_msg.go @@ -2,10 +2,14 @@ // the cosmwasm pool contract from the cosmwasm pool module. package msg -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" +) // CalcOutAmtGivenIn -func NewCalcOutAmtGivenInRequest(tokenIn sdk.Coin, tokenOutDenom string, swapFee sdk.Dec) CalcOutAmtGivenInRequest { +func NewCalcOutAmtGivenInRequest(tokenIn sdk.Coin, tokenOutDenom string, swapFee osmomath.Dec) CalcOutAmtGivenInRequest { return CalcOutAmtGivenInRequest{ CalcOutAmtGivenIn: CalcOutAmtGivenIn{ TokenIn: tokenIn, @@ -16,7 +20,7 @@ func NewCalcOutAmtGivenInRequest(tokenIn sdk.Coin, tokenOutDenom string, swapFee } // CalcInAmtGivenOut -func NewCalcInAmtGivenOutRequest(tokenInDenom string, tokenOut sdk.Coin, swapFee sdk.Dec) CalcInAmtGivenOutRequest { +func NewCalcInAmtGivenOutRequest(tokenInDenom string, tokenOut sdk.Coin, swapFee osmomath.Dec) CalcInAmtGivenOutRequest { return CalcInAmtGivenOutRequest{ CalcInAmtGivenOut: CalcInAmtGivenOut{ TokenInDenom: tokenInDenom, diff --git a/x/cosmwasmpool/cosmwasm/msg/module_query_msg.pb.go b/x/cosmwasmpool/cosmwasm/msg/module_query_msg.pb.go index 8dfe7665132..480e28cb1dc 100644 --- a/x/cosmwasmpool/cosmwasm/msg/module_query_msg.pb.go +++ b/x/cosmwasmpool/cosmwasm/msg/module_query_msg.pb.go @@ -4,8 +4,8 @@ package msg import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -32,7 +32,7 @@ type CalcOutAmtGivenIn struct { // token_out_denom is the token denom to be received from the pool. TokenOutDenom string `protobuf:"bytes,2,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty"` // swap_fee is the swap fee for this swap estimate. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee"` } func (m *CalcOutAmtGivenIn) Reset() { *m = CalcOutAmtGivenIn{} } @@ -180,7 +180,7 @@ type CalcInAmtGivenOut struct { // token_in_denom is the token denom to be sentt to the pool. TokenInDenom string `protobuf:"bytes,2,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty"` // swap_fee is the swap fee for this swap estimate. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee"` } func (m *CalcInAmtGivenOut) Reset() { *m = CalcInAmtGivenOut{} } @@ -335,36 +335,37 @@ func init() { } var fileDescriptor_4e43e2b40a371ec3 = []byte{ - // 464 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0x13, 0x41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b, 0x06, 0x94, 0x1a, 0xb6, 0x8b, - 0x94, 0x1a, 0x85, 0xee, 0xc7, 0x92, 0xd2, 0x52, 0x13, 0x15, 0xa5, 0x5b, 0xfc, 0xef, 0xfb, 0x87, - 0xe7, 0xd3, 0x90, 0x5c, 0x4c, 0x43, 0xf2, 0x7b, 0x1a, 0x92, 0xef, 0xb3, 0xb0, 0x75, 0x31, 0x0b, - 0x5b, 0x3f, 0x67, 0x61, 0xeb, 0xd3, 0xdb, 0x85, 0x49, 0x55, 0x31, 0x76, 0x33, 0x11, 0x9b, 0x7a, - 0xc1, 0x27, 0xbd, 0x3d, 0xfe, 0xb5, 0xf9, 0x42, 0xa8, 0x17, 0x5c, 0x99, 0x24, 0xbe, 0x5f, 0x3c, - 0xab, 0xaf, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0xce, 0x9c, 0xb1, 0x03, 0x3c, 0x04, 0x00, 0x00, + // 465 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x93, 0x4d, 0x6b, 0x13, 0x41, + 0x18, 0xc7, 0xb3, 0x2a, 0x36, 0x1d, 0xdf, 0xe8, 0xa2, 0x90, 0x56, 0xd9, 0x96, 0x28, 0xd2, 0x8b, + 0x33, 0x44, 0x4f, 0x15, 0x51, 0x4c, 0x8b, 0x12, 0x10, 0x02, 0xb9, 0x48, 0xbd, 0x2c, 0xb3, 0x93, + 0xc7, 0xed, 0xd0, 0x9d, 0x79, 0xd2, 0xce, 0x4c, 0x6a, 0xcf, 0x7e, 0x01, 0xbf, 0x8d, 0x5f, 0xa1, + 0xc7, 0x1e, 0xc5, 0x43, 0x91, 0xe4, 0x8b, 0xc8, 0xec, 0x4b, 0x9a, 0x4d, 0x45, 0x0a, 0xed, 0x65, + 0xd9, 0x99, 0x67, 0xfe, 0xff, 0xe7, 0xe5, 0x37, 0x43, 0xb6, 0xd0, 0x28, 0x34, 0xd2,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ff, 0xc0, 0x45, 0xe7, 0x44, 0x26, 0x04, 0x00, + 0x00, } func (m *CalcOutAmtGivenIn) Marshal() (dAtA []byte, err error) { diff --git a/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.go b/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.go index fcb5e5a3ee1..b96e8bca2ff 100644 --- a/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.go +++ b/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.go @@ -4,10 +4,12 @@ package msg import ( sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // SwapExactAmountIn -func NewSwapExactAmountInSudoMsg(sender string, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMin sdk.Int, swapFee sdk.Dec) SwapExactAmountInSudoMsg { +func NewSwapExactAmountInSudoMsg(sender string, tokenIn sdk.Coin, tokenOutDenom string, tokenOutMin osmomath.Int, swapFee osmomath.Dec) SwapExactAmountInSudoMsg { return SwapExactAmountInSudoMsg{ SwapExactAmountIn: SwapExactAmountIn{ Sender: sender, @@ -20,7 +22,7 @@ func NewSwapExactAmountInSudoMsg(sender string, tokenIn sdk.Coin, tokenOutDenom } // SwapExactAmountOut -func NewSwapExactAmountOutSudoMsg(sender string, tokenInDenom string, tokenOut sdk.Coin, tokenInMaxAmount sdk.Int, swapFee sdk.Dec) SwapExactAmountOutSudoMsg { +func NewSwapExactAmountOutSudoMsg(sender string, tokenInDenom string, tokenOut sdk.Coin, tokenInMaxAmount osmomath.Int, swapFee osmomath.Dec) SwapExactAmountOutSudoMsg { return SwapExactAmountOutSudoMsg{ SwapExactAmountOut: SwapExactAmountOut{ Sender: sender, diff --git a/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.pb.go b/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.pb.go index 2bd3095ed42..cfdd333b857 100644 --- a/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.pb.go +++ b/x/cosmwasmpool/cosmwasm/msg/module_sudo_msg.pb.go @@ -4,8 +4,8 @@ package msg import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -34,9 +34,9 @@ type SwapExactAmountIn struct { TokenOutDenom string `protobuf:"bytes,3,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty"` // token_out_min_amount is the minimum amount of token_out to be received from // the pool. - TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount"` + TokenOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_min_amount"` // swap_fee is the swap fee for this swap estimate. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee"` } func (m *SwapExactAmountIn) Reset() { *m = SwapExactAmountIn{} } @@ -141,7 +141,7 @@ func (m *SwapExactAmountInSudoMsg) GetSwapExactAmountIn() SwapExactAmountIn { type SwapExactAmountInSudoMsgResponse struct { // token_out_amount is the token out computed from this swap estimate call. - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount"` } func (m *SwapExactAmountInSudoMsgResponse) Reset() { *m = SwapExactAmountInSudoMsgResponse{} } @@ -186,9 +186,9 @@ type SwapExactAmountOut struct { TokenInDenom string `protobuf:"bytes,3,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty"` // token_in_max_amount is the maximum amount of token_in to be sent to the // pool. - TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount"` + TokenInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_max_amount"` // swap_fee is the swap fee for this swap estimate. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee"` } func (m *SwapExactAmountOut) Reset() { *m = SwapExactAmountOut{} } @@ -293,7 +293,7 @@ func (m *SwapExactAmountOutSudoMsg) GetSwapExactAmountOut() SwapExactAmountOut { type SwapExactAmountOutSudoMsgResponse struct { // token_in_amount is the token in computed from this swap estimate call. - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount"` } func (m *SwapExactAmountOutSudoMsgResponse) Reset() { *m = SwapExactAmountOutSudoMsgResponse{} } @@ -343,42 +343,43 @@ func init() { } var fileDescriptor_e3b9879c5388a3a5 = []byte{ - // 560 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x41, 0x6f, 0xd3, 0x30, - 0x14, 0x6e, 0xca, 0xd8, 0x3a, 0xc3, 0xc6, 0x6a, 0x0a, 0xca, 0x26, 0x94, 0x95, 0x0a, 0x4d, 0xbb, - 0xcc, 0xa6, 0x70, 0x01, 0x84, 0x84, 0x28, 0x03, 0xa9, 0x87, 0xaa, 0x52, 0x27, 0x21, 0x40, 0x42, - 0x51, 0x9a, 0x78, 0x21, 0x5a, 0xed, 0x17, 0xcd, 0xce, 0x5a, 0x04, 0x27, 0x0e, 0x9c, 0xf9, 0x3d, - 0xf0, 0x07, 0x76, 0xdc, 0x11, 0x71, 0x98, 0x50, 0xfb, 0x47, 0x50, 0x62, 0xa7, 0xdd, 0x56, 0x15, - 0xb1, 0xb1, 0x4b, 0x12, 0xfb, 0xbd, 0xef, 0x7d, 0xef, 0x7d, 0xf9, 0x6c, 0xf4, 0x08, 0x24, 0x07, - 0x19, 0x49, 0xea, 0x83, 0xe4, 0x7d, 0x4f, 0xf2, 0x18, 0xa0, 0x47, 0x0f, 0xea, 0x5d, 0xa6, 0xbc, - 0x3a, 0xe5, 0x10, 0xb0, 0x5e, 0xfa, 0x4c, 0x7a, 0xcc, 0x95, 0x49, 0x00, 0x2e, 0x97, 0x21, 0x89, - 0xf7, 0x41, 0x01, 0xbe, 0x63, 0x90, 0xe4, 0x24, 0x92, 0x18, 0xe4, 0x5a, 0x25, 0x84, 0x10, 0xb2, - 0x44, 0x9a, 0x7e, 0x69, 0xcc, 0x9a, 0xe3, 0x67, 0x20, 0xda, 0xf5, 0x24, 0x1b, 0x93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76, 0xab, 0xe7, 0x75, 0x65, 0xbe, - 0xa0, 0x07, 0xf5, 0xc7, 0x74, 0x70, 0xfa, 0x26, 0xcd, 0x17, 0x94, 0xcb, 0xb0, 0x3b, 0x9f, 0xdd, - 0x72, 0x0f, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x1b, 0x13, 0xbc, 0xfa, 0x75, 0x05, 0x00, 0x00, + // 565 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x54, 0x4f, 0x6f, 0xd3, 0x3e, + 0x18, 0x6e, 0xf6, 0xdb, 0x6f, 0x7f, 0x0c, 0x1b, 0xab, 0xe9, 0x50, 0x36, 0x20, 0x2b, 0x05, 0xa1, + 0x5d, 0xb0, 0x29, 0x5c, 0x00, 0x21, 0x10, 0x65, 0x03, 0x55, 0x5a, 0xa9, 0xd4, 0x9d, 0xe0, 0x12, + 0xb9, 0x89, 0x97, 0x85, 0xd6, 0x7e, 0xab, 0xd9, 0x59, 0xcb, 0x95, 0x03, 0x67, 0x3e, 0x01, 0x7c, + 0x9d, 0x1d, 0x77, 0x44, 0x1c, 0x26, 0xd4, 0x7e, 0x11, 0x94, 0xc4, 0x69, 0xd9, 0xa2, 0xa2, 0x4e, + 0xe2, 0x52, 0xd5, 0x7e, 0xdf, 0xe7, 0x79, 0x5e, 0x3f, 0x79, 0x6c, 0xf4, 0x04, 0x94, 0x00, 0x15, + 0x2a, 0xea, 0x81, 0x12, 0x7d, 0xa6, 0x44, 0x0f, 0xa0, 0x4b, 0x8f, 0xab, 0x6d, 0xae, 0x59, 0x95, + 0x0a, 0xf0, 0x79, 0x37, 0xfe, 0x8d, 0xba, 0xdc, 0x55, 0x91, 0x0f, 0xae, 0x50, 0x01, 0xe9, 0x1d, + 0x81, 0x06, 0x7c, 0xcb, 0x20, 0xc9, 0x9f, 0x48, 0x62, 0x90, 0x9b, 0xa5, 0x00, 0x02, 0x48,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9c, 0xc2, 0xe9, 0xc8, 0x29, + 0xfc, 0x18, 0x39, 0x85, 0x0f, 0x2f, 0x83, 0x50, 0x1f, 0x46, 0x6d, 0xe2, 0x81, 0xa0, 0xe6, 0x6c, + 0x0f, 0xba, 0xac, 0xad, 0xb2, 0x05, 0x3d, 0xae, 0x3e, 0xa5, 0x83, 0xf3, 0xef, 0x5d, 0xb6, 0xa0, + 0x42, 0x05, 0xed, 0x85, 0xe4, 0x2d, 0x7a, 0xfc, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x13, 0x86, 0x28, + 0x1a, 0x1b, 0x05, 0x00, 0x00, } func (m *SwapExactAmountIn) Marshal() (dAtA []byte, err error) { diff --git a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go index 096553a4684..c0961145a7c 100644 --- a/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go +++ b/x/cosmwasmpool/cosmwasm/msg/pool_query_msg.pb.go @@ -4,8 +4,8 @@ package msg import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -73,7 +73,7 @@ func (m *GetSwapFeeQueryMsg) GetGetSwapFee() EmptyStruct { type GetSwapFeeQueryMsgResponse struct { // swap_fee is the swap fee for this swap estimate. - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee"` } func (m *GetSwapFeeQueryMsgResponse) Reset() { *m = GetSwapFeeQueryMsgResponse{} } @@ -495,40 +495,40 @@ 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, 0x01, 0xc1, 0x05, 0x91, 0x16, 0x2a, 0xa4, 0x22, 0x35, 0x09, 0x97, - 0x72, 0xb1, 0x36, 0xce, 0xb2, 0xb1, 0xb0, 0x33, 0x4e, 0x66, 0xd3, 0x10, 0xde, 0x80, 0x1b, 0x8f, - 0xd5, 0x63, 0x8f, 0x88, 0x43, 0x85, 0x92, 0x17, 0x41, 0xeb, 0x38, 0x9b, 0x44, 0x29, 0x39, 0xf4, - 0x94, 0xec, 0xec, 0xfc, 0xf7, 0x37, 0xff, 0x99, 0xf5, 0xc2, 0x4b, 0xa4, 0x04, 0x29, 0x22, 0x16, - 0x22, 0x25, 0x3d, 0x4e, 0x49, 0x8a, 0x18, 0xb3, 0xf3, 0xfd, 0xba, 0x50, 0x7c, 0x9f, 0x25, 0xd8, - 0x10, 0x31, 0xd3, 0xa1, 0xa0, 0xdd, 0x15, 0x9d, 0x7e, 0x90, 0x90, 0xf4, 0xd3, 0x0e, 0x2a, 0x74, - 0x1e, 0xe6, 0x42, 0x7f, 0x5a, 0xe8, 0xe7, 0xc2, 0xad, 0x75, 0x89, 0x12, 0xb3, 0x44, 0xa6, 0xff, - 0x8d, 0x34, 0x5b, 0x6e, 0x98, 0x89, 0x58, 0x9d, 0x93, 0x30, 0x8c, 0x10, 0xa3, 0xd6, 0x68, 0xdf, - 0x93, 0xe0, 0x1c, 0x0b, 0x55, 0xeb, 0xf1, 0xf4, 0xbd,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e, 0x06, 0x00, 0x00, 0xff, 0xff, 0x5f, 0xed, 0x81, 0xec, 0x95, 0x04, 0x00, 0x00, + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0x63, 0x8a, 0x00, 0x4f, 0x4a, 0x69, 0xad, 0x82, 0xda, 0x40, 0xdd, 0x62, 0x84, 0x08, + 0x48, 0xd8, 0x4a, 0x39, 0x20, 0x38, 0x80, 0x48, 0x0b, 0xbd, 0x04, 0xa9, 0x49, 0xb8, 0x14, 0x21, + 0x59, 0x1b, 0x67, 0xd9, 0x58, 0xd8, 0x19, 0x27, 0xb3, 0x69, 0x08, 0x6f, 0xc0, 0x8d, 0xc7, 0xea, + 0xb1, 0x47, 0xc4, 0xa1, 0x42, 0xc9, 0x8b, 0xa0, 0x75, 0x9c, 0x4d, 0xa2, 0x94, 0x1c, 0x7a, 0xcb, + 0xce, 0xce, 0x3f, 0xdf, 0xfc, 0x33, 0x1b, 0xc3, 0x4b, 0xa4, 0x18, 0x29, 0x24, 0x2f, 0x40, 0x8a, + 0xfb, 0x8c, 0xe2, 0x04, 0x31, 0xf2, 0x4e, 0x4b, 0x0d, 0x2e, 0x59, 0xc9, 0x8b, 0xb1, 0xc9, 0x23, + 0x4f, 0x85, 0xfc, 0x4e, 0x8f, 0x77, 0x07, 0x7e, 0x4c, 0xc2, 0x4d, 0xba, 0x28, 0xd1, 0x7a, 0x90, + 0x09, 0xdd, 0x59, 0xa1, 0x9b, 0x09, 0x0b, 0x9b, 0x02, 0x05, 0xa6, 0x89, 0x9e, 0xfa, 0x35, 0xd6, + 0x14, 0xec, 0x20, 0x15, 0x79, 0x0d, 0x46, 0x5c, 0x33, 0x02, 0x0c, 0xdb, 0xe3, 0x7b, 0x47, 0x80, + 0x75, 0xc4, 0x65, 0xbd, 0xcf, 0x92, 0x0f, 0x9c, 0x57, 0x15, 0xf0, 0x23, 0x09, 0xab, 0x0a, 0xab, + 0x82, 0x4b, 0x9f, 0xfa, 0x2c, 0xf1, 0xbf, 0x72, 0xbe, 0x65, 0xec, 0x19, 0xc5, 0xfc, 0xfe, 0x53, + 0x77, 0x59, 0x03, 0xee, 0xfb, 0x38, 0x91, 0x83, 0xba, 0xec, 0xf6, 0x02, 0x59, 0xbe, 0x7e, 0x76, + 0xb1, 0x9b, 0xab, 0x81, 0xd0, 0xa5, 0x9d, 0x2f, 0x50, 0x58, 0x04, 0xd5, 0x38, 0x25, 0xd8, 0x26, + 0x6e, 0xbd, 0x81, 0x5b, 0x1a, 0xb6, 0xb2, 0x67, 0x14, 0xcd, 0xf2, 0x23, 0x55, 0xe1, 0xcf, 0xc5, + 0xee, 0xfd, 0xb1, 0x01, 0x6a, 0x7e, 0x73, 0x43, 0xf4, 0x62, 0x26, 0x5b, 0x6e, 0x85, 0x0b, 0x16, + 0x0c, 0x0e, 0x79, 0x50, 0xbb, 0x49, 0x59, 0x75, 0x06, 0x66, 0x3d, 0x41, 0x79, 0xdc, 0x0d, 0x03, + 0x6e, 0x3d, 0x83, 0x8d, 0x4e, 0x0f, 0x25, 0xf7, 0x19, 0x11, 0x97, 0x7e, 0x93, 0xb7, 0x31, 0x4e, + 0x2d, 0x98, 0xb5, 0x3b, 0xe9, 0xc5, 0x3b, 0x15, 0x3f, 0x54, 0x61, 0xab, 0x08, 0xeb, 0x6a, 0x34, + 0x73, 0xa9, 0xd7, 0xd2, 0xd4, 0x35, 0x15, 0x9f, 0x66, 0x3a, 0x0c, 0x36, 0x34, 0x42, 0x0f, 0xaa, + 0x02, 0x40, 0x09, 0x4a, 0x3f, 0x51, 0xd1, 0x6c, 0x4c, 0x4f, 0x96, 0x8f, 0x49, 0x17, 0xc9, 0x86, + 0x64, 0xd2, 0x24, 0xe0, 0xbc, 0x86, 0xed, 0x05, 0x84, 0x1e, 0xd1, 0xce, 0x02, 0xca, 0x9c, 0xd5, + 0xde, 0x86, 0xfc, 0x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 0x24, 0x73, 0x88, 0x87, 0x8a, 0x04, 0x00, 0x00, } func (m *GetSwapFeeQueryMsg) Marshal() (dAtA []byte, err error) { diff --git a/x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go b/x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go index 251dd09353a..ef912192c6c 100644 --- a/x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go +++ b/x/cosmwasmpool/cosmwasm/msg/transmuter/transmuter_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" incentivetypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -26,7 +27,7 @@ type TransmuterSuite struct { var ( defaultPoolId = uint64(1) - defaultAmount = sdk.NewInt(100) + defaultAmount = osmomath.NewInt(100) initalDefaultSupply = sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)) uosmo = "uosmo" @@ -80,7 +81,7 @@ func (s *TransmuterSuite) TestFunctionalTransmuter() { s.Require().NoError(err) // Create gauge - incentive := sdk.NewCoins(sdk.NewCoin(uosmo, sdk.NewInt(1_000_000))) + incentive := sdk.NewCoins(sdk.NewCoin(uosmo, osmomath.NewInt(1_000_000))) s.FundAcc(s.TestAccs[1], incentive) gaugeId, err := s.App.IncentivesKeeper.CreateGauge(s.Ctx, true, s.TestAccs[1], incentive, lockuptypes.QueryCondition{ LockQueryType: lockuptypes.ByDuration, diff --git a/x/cosmwasmpool/model/pool.go b/x/cosmwasmpool/model/pool.go index 39bce2c7238..01ab9a4e7fb 100644 --- a/x/cosmwasmpool/model/pool.go +++ b/x/cosmwasmpool/model/pool.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" + "github.com/osmosis-labs/osmosis/osmomath" cosmwasmutils "github.com/osmosis-labs/osmosis/osmoutils/cosmwasm" ) @@ -59,7 +60,7 @@ func (p Pool) String() string { } // GetSpreadFactor returns the swap fee of the pool. -func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { +func (p Pool) GetSpreadFactor(ctx sdk.Context) osmomath.Dec { request := msg.GetSwapFeeQueryMsg{} response := cosmwasmutils.MustQuery[msg.GetSwapFeeQueryMsg, msg.GetSwapFeeQueryMsgResponse](ctx, p.WasmKeeper, p.ContractAddress, request) return response.SwapFee @@ -71,7 +72,7 @@ func (p Pool) IsActive(ctx sdk.Context) bool { } // SpotPrice returns the spot price of the pool. -func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (sdk.Dec, error) { +func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (osmomath.Dec, error) { request := msg.SpotPriceQueryMsg{ SpotPrice: msg.SpotPrice{ QuoteAssetDenom: quoteAssetDenom, @@ -80,9 +81,9 @@ func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom } response, err := cosmwasmutils.Query[msg.SpotPriceQueryMsg, msg.SpotPriceQueryMsgResponse](ctx, p.WasmKeeper, p.ContractAddress, request) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } - return sdk.MustNewDecFromStr(response.SpotPrice), nil + return osmomath.MustNewDecFromStr(response.SpotPrice), nil } // GetType returns the type of the pool. diff --git a/x/cosmwasmpool/model/pool_test.go b/x/cosmwasmpool/model/pool_test.go index 30939515cbd..a9c8e0f0d1b 100644 --- a/x/cosmwasmpool/model/pool_test.go +++ b/x/cosmwasmpool/model/pool_test.go @@ -3,9 +3,9 @@ package model_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" ) @@ -29,7 +29,7 @@ func (s *CosmWasmPoolSuite) SetupTest() { // TestGetSpreadFactor validates that spread factor is set to zero. func (s *CosmWasmPoolSuite) TestGetSpreadFactor() { var ( - expectedSwapFee = sdk.ZeroDec() + expectedSwapFee = osmomath.ZeroDec() ) pool := s.PrepareCosmWasmPool() @@ -42,7 +42,7 @@ func (s *CosmWasmPoolSuite) TestGetSpreadFactor() { // TestSpotPrice validates that spot price is returned as one. func (s *CosmWasmPoolSuite) TestSpotPrice() { var ( - expectedSpotPrice = sdk.OneDec() + expectedSpotPrice = osmomath.OneDec() ) pool := s.PrepareCosmWasmPool() diff --git a/x/cosmwasmpool/model/store_model.go b/x/cosmwasmpool/model/store_model.go index 609e1ac6382..801a46d8558 100644 --- a/x/cosmwasmpool/model/store_model.go +++ b/x/cosmwasmpool/model/store_model.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -33,11 +34,11 @@ func (p CosmWasmPool) GetId() uint64 { panic("CosmWasmPool.GetId not implemented") } -func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { +func (p CosmWasmPool) GetSpreadFactor(ctx sdk.Context) osmomath.Dec { panic("CosmWasmPool.GetSpreadFactor not implemented") } -func (p CosmWasmPool) GetExitFee(ctx sdk.Context) sdk.Dec { +func (p CosmWasmPool) GetExitFee(ctx sdk.Context) osmomath.Dec { panic("CosmWasmPool.GetExitFee not implemented") } @@ -45,7 +46,7 @@ func (p CosmWasmPool) IsActive(ctx sdk.Context) bool { panic("CosmWasmPool.IsActive not implemented") } -func (p CosmWasmPool) SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error) { +func (p CosmWasmPool) SpotPrice(ctx sdk.Context, baseAssetDenom string, quoteAssetDenom string) (osmomath.Dec, error) { panic("CosmWasmPool.SpotPrice not implemented") } diff --git a/x/cosmwasmpool/pool_module.go b/x/cosmwasmpool/pool_module.go index d0a0dd37590..faa45002ef8 100644 --- a/x/cosmwasmpool/pool_module.go +++ b/x/cosmwasmpool/pool_module.go @@ -4,6 +4,7 @@ package cosmwasmpool import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/cosmwasm/msg" "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/model" @@ -167,10 +168,10 @@ func (k Keeper) CalculateSpotPrice( poolId uint64, quoteAssetDenom string, baseAssetDenom string, -) (price sdk.Dec, err error) { +) (price osmomath.Dec, err error) { cosmwasmPool, err := k.GetPoolById(ctx, poolId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return cosmwasmPool.SpotPrice(ctx, quoteAssetDenom, baseAssetDenom) @@ -188,7 +189,7 @@ func (k Keeper) CalculateSpotPrice( // - swapFee: The fee associated with the swap operation. // // Returns: -// - sdk.Int: The actual amount of the output token received after the swap. +// - osmomath.Int: The actual amount of the output token received after the swap. // - error: An error if the swap operation fails or if the pool conversion fails. func (k Keeper) SwapExactAmountIn( ctx sdk.Context, @@ -196,12 +197,12 @@ func (k Keeper) SwapExactAmountIn( pool poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - swapFee sdk.Dec, -) (sdk.Int, error) { + tokenOutMinAmount osmomath.Int, + swapFee osmomath.Dec, +) (osmomath.Int, error) { cosmwasmPool, err := k.asCosmwasmPool(pool) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Send token in from sender to the pool @@ -209,13 +210,13 @@ func (k Keeper) SwapExactAmountIn( // However, note that the contract sends the token back to the sender after the swap // As a result, we do not need to worry about sending it back here. if err := k.bankKeeper.SendCoins(ctx, sender, sdk.MustAccAddressFromBech32(cosmwasmPool.GetContractAddress()), sdk.NewCoins(tokenIn)); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } request := msg.NewSwapExactAmountInSudoMsg(sender.String(), tokenIn, tokenOutDenom, tokenOutMinAmount, swapFee) response, err := cosmwasm.Sudo[msg.SwapExactAmountInSudoMsg, msg.SwapExactAmountInSudoMsgResponse](ctx, k.contractKeeper, cosmwasmPool.GetContractAddress(), request) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return response.TokenOutAmount, nil @@ -238,7 +239,7 @@ func (k Keeper) CalcOutAmtGivenIn( poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - swapFee sdk.Dec, + swapFee osmomath.Dec, ) (tokenOut sdk.Coin, err error) { cosmwasmPool, err := k.asCosmwasmPool(poolI) if err != nil { @@ -266,20 +267,20 @@ func (k Keeper) CalcOutAmtGivenIn( // - swapFee: The fee associated with the swap operation. // // Returns: -// - sdk.Int: The actual amount of the input token used in the swap. +// - osmomath.Int: The actual amount of the input token used in the swap. // - error: An error if the swap operation fails or if the pool conversion fails. func (k Keeper) SwapExactAmountOut( ctx sdk.Context, sender sdk.AccAddress, pool poolmanagertypes.PoolI, tokenInDenom string, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, - swapFee sdk.Dec, -) (tokenInAmount sdk.Int, err error) { + swapFee osmomath.Dec, +) (tokenInAmount osmomath.Int, err error) { cosmwasmPool, err := k.asCosmwasmPool(pool) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } contractAddr := sdk.MustAccAddressFromBech32(cosmwasmPool.GetContractAddress()) @@ -288,7 +289,7 @@ func (k Keeper) SwapExactAmountOut( // We do this because sudo message does not support sending coins from the sender // And we need to send the max amount because we do not know how much the contract will use. if err := k.bankKeeper.SendCoins(ctx, sender, contractAddr, sdk.NewCoins(sdk.NewCoin(tokenInDenom, tokenInMaxAmount))); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Note that the contract sends the token out back to the sender after the swap @@ -296,7 +297,7 @@ func (k Keeper) SwapExactAmountOut( request := msg.NewSwapExactAmountOutSudoMsg(sender.String(), tokenInDenom, tokenOut, tokenInMaxAmount, swapFee) response, err := cosmwasm.Sudo[msg.SwapExactAmountOutSudoMsg, msg.SwapExactAmountOutSudoMsgResponse](ctx, k.contractKeeper, cosmwasmPool.GetContractAddress(), request) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenInExcessiveAmount := tokenInMaxAmount.Sub(response.TokenInAmount) @@ -305,7 +306,7 @@ func (k Keeper) SwapExactAmountOut( // required amount should be less than or equal to max amount if tokenInExcessiveAmount.IsNegative() { - return sdk.Int{}, types.NegativeExcessiveTokenInAmountError{ + return osmomath.Int{}, types.NegativeExcessiveTokenInAmountError{ TokenInMaxAmount: tokenInMaxAmount, TokenInRequiredAmount: response.TokenInAmount, TokenInExcessiveAmount: tokenInExcessiveAmount, @@ -315,7 +316,7 @@ func (k Keeper) SwapExactAmountOut( // Send excessibe token in from pool back to sender if tokenInExcessiveAmount.IsPositive() { if err := k.bankKeeper.SendCoins(ctx, contractAddr, sender, sdk.NewCoins(sdk.NewCoin(tokenInDenom, tokenInExcessiveAmount))); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } @@ -339,7 +340,7 @@ func (k Keeper) CalcInAmtGivenOut( poolI poolmanagertypes.PoolI, tokenOut sdk.Coin, tokenInDenom string, - swapFee sdk.Dec, + swapFee osmomath.Dec, ) (tokenIn sdk.Coin, err error) { cosmwasmPool, err := k.asCosmwasmPool(poolI) if err != nil { diff --git a/x/cosmwasmpool/pool_module_test.go b/x/cosmwasmpool/pool_module_test.go index 3ad24d2f738..014251fb2f3 100644 --- a/x/cosmwasmpool/pool_module_test.go +++ b/x/cosmwasmpool/pool_module_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/model" @@ -28,7 +29,7 @@ type PoolModuleSuite struct { } var ( - defaultAmount = sdk.NewInt(100) + defaultAmount = osmomath.NewInt(100) initalDefaultSupply = sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)) defaultDenoms = []string{denomA, denomB} @@ -168,8 +169,8 @@ func (s *PoolModuleSuite) TestCalcOutAmtGivenIn_SwapOutAmtGivenIn() { initialCoins sdk.Coins tokenIn sdk.Coin tokenOutDenom string - tokenOutMinAmount sdk.Int - swapFee sdk.Dec + tokenOutMinAmount osmomath.Int + swapFee osmomath.Dec isInvalidPool bool expectedTokenOut sdk.Coin @@ -177,34 +178,34 @@ func (s *PoolModuleSuite) TestCalcOutAmtGivenIn_SwapOutAmtGivenIn() { }{ "calc amount less than supply": { initialCoins: initalDefaultSupply, - tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenOutDenom: denomB, - expectedTokenOut: sdk.NewCoin(denomB, defaultAmount.Sub(sdk.OneInt())), - swapFee: sdk.ZeroDec(), + expectedTokenOut: sdk.NewCoin(denomB, defaultAmount.Sub(osmomath.OneInt())), + swapFee: osmomath.ZeroDec(), }, "calc amount equal to supply": { initialCoins: initalDefaultSupply, tokenIn: sdk.NewCoin(denomA, defaultAmount), tokenOutDenom: denomB, expectedTokenOut: sdk.NewCoin(denomB, defaultAmount), - swapFee: sdk.ZeroDec(), + swapFee: osmomath.ZeroDec(), }, "calc amount greater than supply": { initialCoins: initalDefaultSupply, - tokenIn: sdk.NewCoin(denomA, defaultAmount.Add(sdk.OneInt())), + tokenIn: sdk.NewCoin(denomA, defaultAmount.Add(osmomath.OneInt())), tokenOutDenom: denomB, - expectedErrorMessage: fmt.Sprintf("Insufficient pool asset: required: %s, available: %s", sdk.NewCoin(denomB, defaultAmount.Add(sdk.OneInt())), sdk.NewCoin(denomB, defaultAmount)), + expectedErrorMessage: fmt.Sprintf("Insufficient pool asset: required: %s, available: %s", sdk.NewCoin(denomB, defaultAmount.Add(osmomath.OneInt())), sdk.NewCoin(denomB, defaultAmount)), }, "non-zero swap fee": { initialCoins: initalDefaultSupply, - tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenOutDenom: denomB, - swapFee: sdk.MustNewDecFromStr(nonZeroFeeStr), - expectedErrorMessage: fmt.Sprintf("Invalid swap fee: expected: %s, actual: %s", sdk.ZeroInt(), nonZeroFeeStr), + swapFee: osmomath.MustNewDecFromStr(nonZeroFeeStr), + expectedErrorMessage: fmt.Sprintf("Invalid swap fee: expected: %s, actual: %s", osmomath.ZeroInt(), nonZeroFeeStr), }, "invalid pool given": { initialCoins: sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)), - tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenIn: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenOutDenom: denomB, isInvalidPool: true, @@ -289,8 +290,8 @@ func (s *PoolModuleSuite) TestCalcInAmtGivenOut_SwapInAmtGivenOut() { initialCoins sdk.Coins tokenOut sdk.Coin tokenInDenom string - tokenInMaxAmount sdk.Int - swapFee sdk.Dec + tokenInMaxAmount osmomath.Int + swapFee osmomath.Dec isInvalidPool bool expectedTokenIn sdk.Coin @@ -298,11 +299,11 @@ func (s *PoolModuleSuite) TestCalcInAmtGivenOut_SwapInAmtGivenOut() { }{ "calc amount less than supply": { initialCoins: initalDefaultSupply, - tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenInDenom: denomB, - expectedTokenIn: sdk.NewCoin(denomB, defaultAmount.Sub(sdk.OneInt())), + expectedTokenIn: sdk.NewCoin(denomB, defaultAmount.Sub(osmomath.OneInt())), tokenInMaxAmount: defaultAmount, - swapFee: sdk.ZeroDec(), + swapFee: osmomath.ZeroDec(), }, "calc amount equal to supply": { initialCoins: initalDefaultSupply, @@ -310,28 +311,28 @@ func (s *PoolModuleSuite) TestCalcInAmtGivenOut_SwapInAmtGivenOut() { tokenInDenom: denomB, expectedTokenIn: sdk.NewCoin(denomB, defaultAmount), tokenInMaxAmount: defaultAmount, - swapFee: sdk.ZeroDec(), + swapFee: osmomath.ZeroDec(), }, "calc amount greater than supply": { initialCoins: initalDefaultSupply, - tokenOut: sdk.NewCoin(denomA, defaultAmount.Add(sdk.OneInt())), + tokenOut: sdk.NewCoin(denomA, defaultAmount.Add(osmomath.OneInt())), tokenInDenom: denomB, - tokenInMaxAmount: defaultAmount.Sub(sdk.OneInt()), - expectedErrorMessage: fmt.Sprintf("Insufficient pool asset: required: %s, available: %s", sdk.NewCoin(denomA, defaultAmount.Add(sdk.OneInt())), sdk.NewCoin(denomA, defaultAmount)), + tokenInMaxAmount: defaultAmount.Sub(osmomath.OneInt()), + expectedErrorMessage: fmt.Sprintf("Insufficient pool asset: required: %s, available: %s", sdk.NewCoin(denomA, defaultAmount.Add(osmomath.OneInt())), sdk.NewCoin(denomA, defaultAmount)), }, "non-zero swap fee": { initialCoins: initalDefaultSupply, - tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenInDenom: denomB, - tokenInMaxAmount: defaultAmount.Sub(sdk.OneInt()), - swapFee: sdk.MustNewDecFromStr(nonZeroFeeStr), - expectedErrorMessage: fmt.Sprintf("Invalid swap fee: expected: %s, actual: %s", sdk.ZeroInt(), nonZeroFeeStr), + tokenInMaxAmount: defaultAmount.Sub(osmomath.OneInt()), + swapFee: osmomath.MustNewDecFromStr(nonZeroFeeStr), + expectedErrorMessage: fmt.Sprintf("Invalid swap fee: expected: %s, actual: %s", osmomath.ZeroInt(), nonZeroFeeStr), }, "invalid pool given": { initialCoins: sdk.NewCoins(sdk.NewCoin(denomA, defaultAmount), sdk.NewCoin(denomB, defaultAmount)), - tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(sdk.OneInt())), + tokenOut: sdk.NewCoin(denomA, defaultAmount.Sub(osmomath.OneInt())), tokenInDenom: denomB, - tokenInMaxAmount: defaultAmount.Sub(sdk.OneInt()), + tokenInMaxAmount: defaultAmount.Sub(osmomath.OneInt()), isInvalidPool: true, expectedErrorMessage: types.InvalidPoolTypeError{ diff --git a/x/cosmwasmpool/types/errors.go b/x/cosmwasmpool/types/errors.go index b1b52a053de..c2ee277de9b 100644 --- a/x/cosmwasmpool/types/errors.go +++ b/x/cosmwasmpool/types/errors.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) var ( @@ -38,9 +38,9 @@ func (e CodeIdNotWhitelistedError) Error() string { } type NegativeExcessiveTokenInAmountError struct { - TokenInMaxAmount sdk.Int - TokenInRequiredAmount sdk.Int - TokenInExcessiveAmount sdk.Int + TokenInMaxAmount osmomath.Int + TokenInRequiredAmount osmomath.Int + TokenInExcessiveAmount osmomath.Int } func (e NegativeExcessiveTokenInAmountError) Error() string { diff --git a/x/epochs/go.mod b/x/epochs/go.mod index e0499e51ee9..5ae45ecac2c 100644 --- a/x/epochs/go.mod +++ b/x/epochs/go.mod @@ -3,12 +3,12 @@ module github.com/osmosis-labs/osmosis/x/epochs go 1.20 require ( - github.com/cosmos/cosmos-sdk v0.47.4 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230807183608-16c217dedde5 + github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d github.com/spf13/cobra v1.7.0 github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.37.0-rc1 @@ -18,6 +18,7 @@ require ( ) require ( + cosmossdk.io/math v1.1.3-rc.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 @@ -27,7 +28,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd v0.22.3 // indirect - github.com/bytedance/sonic v1.10.0 // indirect + github.com/bytedance/sonic v1.10.1 // 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 @@ -86,8 +87,8 @@ require ( github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.27.6 // indirect + github.com/opencontainers/runc v1.1.5 // indirect + github.com/osmosis-labs/osmosis/osmomath v0.0.6 // 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 @@ -138,8 +139,8 @@ require ( // use cosmos-compatible protobufs replace ( - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.24 ) diff --git a/x/epochs/go.sum b/x/epochs/go.sum index fd728acd06f..8f710c6e851 100644 --- a/x/epochs/go.sum +++ b/x/epochs/go.sum @@ -39,6 +39,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 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -141,7 +143,9 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +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.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= 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= @@ -156,8 +160,12 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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= @@ -189,6 +197,7 @@ github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1 github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= +github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -342,6 +351,7 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw 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.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= @@ -554,9 +564,11 @@ github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B 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= @@ -576,6 +588,7 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -659,7 +672,6 @@ github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= @@ -689,9 +701,11 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 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/osmoutils v0.0.0-20230807183608-16c217dedde5 h1:j4ifxomFROGROHalqWwX7VPDgxOPotMB1GiAWdb03i4= +github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/osmosis/osmomath v0.0.6 h1:WNkVmeeudAqRFk5a4CChWsdxfiY/XLClT1i845L78ss= +github.com/osmosis-labs/osmosis/osmomath v0.0.6/go.mod h1:UlftwozB+QObT3o0YfkuuyL9fsVdgoWt0dm6J7MLYnU= +github.com/osmosis-labs/osmosis/osmoutils v0.0.7-0.20230907220438-2f6dd779bc6d h1:9xBej3lldho6WlM8vFdznEjPpXf3EWL6ySvZlkoof/w= +github.com/osmosis-labs/osmosis/v19 v19.0.0 h1:gqcas/XfxtEuZXsWGTO9vNMHiY78Qs09FBQw73djIVM= github.com/otiai10/copy v1.7.0 h1:hVoPiN+t+7d2nzzwMiDHPSOogsWAStewq3TwU05+clE= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -796,6 +810,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -872,6 +887,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 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= @@ -923,6 +939,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= 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= @@ -947,6 +964,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm 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.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 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= @@ -962,6 +980,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1041,6 +1060,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -1137,13 +1157,16 @@ golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 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= @@ -1154,6 +1177,7 @@ 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.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= @@ -1220,6 +1244,7 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1303,8 +1328,11 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D 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-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.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1330,6 +1358,7 @@ google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= +google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -1343,6 +1372,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.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= @@ -1390,10 +1420,12 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/x/gamm/README.md b/x/gamm/README.md index 5b041a7f40a..3235bbb13b4 100644 --- a/x/gamm/README.md +++ b/x/gamm/README.md @@ -160,8 +160,8 @@ Pools have the following parameters: | Key | Type | | --------------------------| ----------------------------| -| SpreadFactor | sdk.Dec | -| ExitFee | sdk.Dec | +| SpreadFactor | osmomath.Dec | +| ExitFee | osmomath.Dec | | FutureGovernor | \*FutureGovernor | | Weights | \*Weights | | SmoothWeightChangeParams | \*SmoothWeightChangeParams | diff --git a/x/gamm/client/cli/cli_test.go b/x/gamm/client/cli/cli_test.go index 9d20ed29366..5334448637e 100644 --- a/x/gamm/client/cli/cli_test.go +++ b/x/gamm/client/cli/cli_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/gamm/client/cli" @@ -181,7 +182,7 @@ func TestNewJoinPoolCmd(t *testing.T) { ExpectedMsg: &types.MsgJoinPool{ Sender: testAddresses[0].String(), PoolId: 1, - ShareOutAmount: sdk.NewIntFromUint64(100), + ShareOutAmount: osmomath.NewIntFromUint64(100), TokenInMaxs: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), }, }, @@ -197,7 +198,7 @@ func TestNewExitPoolCmd(t *testing.T) { ExpectedMsg: &types.MsgExitPool{ Sender: testAddresses[0].String(), PoolId: 1, - ShareInAmount: sdk.NewIntFromUint64(10), + ShareInAmount: osmomath.NewIntFromUint64(10), TokenOutMins: sdk.NewCoins(sdk.NewInt64Coin("stake", 100)), }, }, @@ -213,7 +214,7 @@ func TestNewSwapExactAmountOutCmd(t *testing.T) { ExpectedMsg: &types.MsgSwapExactAmountOut{ Sender: testAddresses[0].String(), Routes: []poolmanagertypes.SwapAmountOutRoute{{PoolId: 1, TokenInDenom: "node0token"}}, - TokenInMaxAmount: sdk.NewIntFromUint64(20), + TokenInMaxAmount: osmomath.NewIntFromUint64(20), TokenOut: sdk.NewInt64Coin("stake", 10), }, }, @@ -230,7 +231,7 @@ func TestNewSwapExactAmountInCmd(t *testing.T) { Sender: testAddresses[0].String(), Routes: []poolmanagertypes.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "node0token"}}, TokenIn: sdk.NewInt64Coin("stake", 10), - TokenOutMinAmount: sdk.NewIntFromUint64(3), + TokenOutMinAmount: osmomath.NewIntFromUint64(3), }, }, } @@ -246,7 +247,7 @@ func TestNewJoinSwapExternAmountInCmd(t *testing.T) { Sender: testAddresses[0].String(), PoolId: 1, TokenIn: sdk.NewInt64Coin("stake", 10), - ShareOutMinAmount: sdk.NewIntFromUint64(1), + ShareOutMinAmount: osmomath.NewIntFromUint64(1), }, }, } @@ -262,8 +263,8 @@ func TestNewJoinSwapShareAmountOutCmd(t *testing.T) { Sender: testAddresses[0].String(), PoolId: 1, TokenInDenom: "stake", - ShareOutAmount: sdk.NewIntFromUint64(10), - TokenInMaxAmount: sdk.NewIntFromUint64(1), + ShareOutAmount: osmomath.NewIntFromUint64(10), + TokenInMaxAmount: osmomath.NewIntFromUint64(1), }, }, } @@ -279,7 +280,7 @@ func TestNewExitSwapExternAmountOutCmd(t *testing.T) { Sender: testAddresses[0].String(), PoolId: 1, TokenOut: sdk.NewInt64Coin("stake", 10), - ShareInMaxAmount: sdk.NewIntFromUint64(1), + ShareInMaxAmount: osmomath.NewIntFromUint64(1), }, }, } @@ -295,8 +296,8 @@ func TestNewExitSwapShareAmountInCmd(t *testing.T) { Sender: testAddresses[0].String(), PoolId: 1, TokenOutDenom: "stake", - ShareInAmount: sdk.NewIntFromUint64(10), - TokenOutMinAmount: sdk.NewIntFromUint64(1), + ShareInAmount: osmomath.NewIntFromUint64(10), + TokenOutMinAmount: osmomath.NewIntFromUint64(1), }, }, } diff --git a/x/gamm/client/cli/flags.go b/x/gamm/client/cli/flags.go index 24a71f1f571..672f5bfac8d 100644 --- a/x/gamm/client/cli/flags.go +++ b/x/gamm/client/cli/flags.go @@ -22,12 +22,12 @@ const ( PoolFileTargetPoolWeights = "target-pool-weights" FlagPoolId = "pool-id" - // Will be parsed to sdk.Int. + // Will be parsed to osmomath.Int. FlagShareAmountOut = "share-amount-out" // Will be parsed to []sdk.Coin. FlagMaxAmountsIn = "max-amounts-in" - // Will be parsed to sdk.Int. + // Will be parsed to osmomath.Int. FlagShareAmountIn = "share-amount-in" // Will be parsed to []sdk.Coin. FlagMinAmountsOut = "min-amounts-out" diff --git a/x/gamm/client/cli/query_test.go b/x/gamm/client/cli/query_test.go index 7c4be65bd15..15633dc579a 100644 --- a/x/gamm/client/cli/query_test.go +++ b/x/gamm/client/cli/query_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) @@ -32,10 +33,10 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() { uosmoDenom = apptesting.DefaultPoolAssets[3].Token.Denom basicValidTokensIn = sdk.NewCoins( - sdk.NewCoin(fooDenom, sdk.OneInt()), - sdk.NewCoin(barDenom, sdk.OneInt()), - sdk.NewCoin(bazDenom, sdk.OneInt()), - sdk.NewCoin(uosmoDenom, sdk.OneInt())) + sdk.NewCoin(fooDenom, osmomath.OneInt()), + sdk.NewCoin(barDenom, osmomath.OneInt()), + sdk.NewCoin(bazDenom, osmomath.OneInt()), + sdk.NewCoin(uosmoDenom, osmomath.OneInt())) ) testCases := []struct { @@ -113,7 +114,7 @@ func (s *QueryTestSuite) TestQueriesNeverAlterState() { { "Query exit pool coins from shares", "/osmosis.gamm.v1beta1.Query/CalcExitPoolCoinsFromShares", - &types.QueryCalcExitPoolCoinsFromSharesRequest{PoolId: 1, ShareInAmount: sdk.OneInt()}, + &types.QueryCalcExitPoolCoinsFromSharesRequest{PoolId: 1, ShareInAmount: osmomath.OneInt()}, &types.QueryCalcExitPoolCoinsFromSharesResponse{}, }, } diff --git a/x/gamm/client/cli/tx.go b/x/gamm/client/cli/tx.go index 675ee162af7..6ed63f43c19 100644 --- a/x/gamm/client/cli/tx.go +++ b/x/gamm/client/cli/tx.go @@ -12,6 +12,7 @@ import ( "github.com/spf13/cobra" flag "github.com/spf13/pflag" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" @@ -462,12 +463,12 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, fs *flag.FlagSet) ( return nil, errors.New("deposit tokens and token weights should have same length") } - spreadFactor, err := sdk.NewDecFromStr(pool.SwapFee) + spreadFactor, err := osmomath.NewDecFromStr(pool.SwapFee) if err != nil { return nil, err } - exitFee, err := sdk.NewDecFromStr(pool.ExitFee) + exitFee, err := osmomath.NewDecFromStr(pool.ExitFee) if err != nil { return nil, err } @@ -557,12 +558,12 @@ func NewBuildCreateStableswapPoolMsg(clientCtx client.Context, fs *flag.FlagSet) return nil, err } - spreadFactor, err := sdk.NewDecFromStr(flags.SwapFee) + spreadFactor, err := osmomath.NewDecFromStr(flags.SwapFee) if err != nil { return nil, err } - exitFee, err := sdk.NewDecFromStr(flags.ExitFee) + exitFee, err := osmomath.NewDecFromStr(flags.ExitFee) if err != nil { return nil, err } @@ -697,7 +698,7 @@ func NewBuildSwapExactAmountOutMsg(clientCtx client.Context, args []string, fs * return nil, err } - tokenInMaxAmount, ok := sdk.NewIntFromString(tokenInMaxAmountStr) + tokenInMaxAmount, ok := osmomath.NewIntFromString(tokenInMaxAmountStr) if !ok { return nil, errors.New("invalid token in max amount") } @@ -889,13 +890,13 @@ func parsePoolRecordsWithCFMMLink(cmd *cobra.Command) ([]types.PoolRecordWithCFM } exponentAtPriceOneStr := poolRecordsWithCFMMLink[i+3] - exponentAtPriceOne, ok := sdk.NewIntFromString(exponentAtPriceOneStr) + exponentAtPriceOne, ok := osmomath.NewIntFromString(exponentAtPriceOneStr) if !ok { return nil, fmt.Errorf("invalid exponentAtPriceOne: %s", exponentAtPriceOneStr) } spreadFactorStr := poolRecordsWithCFMMLink[i+4] - spreadFactor, err := sdk.NewDecFromStr(spreadFactorStr) + spreadFactor, err := osmomath.NewDecFromStr(spreadFactorStr) if err != nil { return nil, err } diff --git a/x/gamm/client/cli/tx_test.go b/x/gamm/client/cli/tx_test.go index a408af92f9d..9e87aaf1f68 100644 --- a/x/gamm/client/cli/tx_test.go +++ b/x/gamm/client/cli/tx_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/client/cli" ) @@ -18,7 +19,7 @@ func TestParseCoinsNoSort(t *testing.T) { ) var ( - ten = sdk.NewInt(10) + ten = osmomath.NewInt(10) coinA = sdk.NewCoin(a, ten) coinB = sdk.NewCoin(b, ten) @@ -51,10 +52,10 @@ func TestParseCoinsNoSort(t *testing.T) { "mixed with different values.": { coinsStr: "100ddd,20bbb,300aaa,40ccc", expectedCoins: sdk.Coins{ - sdk.NewCoin(d, sdk.NewInt(100)), - sdk.NewCoin(b, sdk.NewInt(20)), - sdk.NewCoin(a, sdk.NewInt(300)), - sdk.NewCoin(c, sdk.NewInt(40)), + sdk.NewCoin(d, osmomath.NewInt(100)), + sdk.NewCoin(b, osmomath.NewInt(20)), + sdk.NewCoin(a, osmomath.NewInt(300)), + sdk.NewCoin(c, osmomath.NewInt(40)), }, }, } diff --git a/x/gamm/keeper/export_test.go b/x/gamm/keeper/export_test.go index f0b3231a53d..2006253615a 100644 --- a/x/gamm/keeper/export_test.go +++ b/x/gamm/keeper/export_test.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -34,7 +35,7 @@ func (k Keeper) UnmarshalPoolLegacy(bz []byte) (poolmanagertypes.PoolI, error) { return acc, k.cdc.UnmarshalInterface(bz, &acc) } -func GetMaximalNoSwapLPAmount(ctx sdk.Context, pool types.CFMMPoolI, shareOutAmount sdk.Int) (neededLpLiquidity sdk.Coins, err error) { +func GetMaximalNoSwapLPAmount(ctx sdk.Context, pool types.CFMMPoolI, shareOutAmount osmomath.Int) (neededLpLiquidity sdk.Coins, err error) { return getMaximalNoSwapLPAmount(ctx, pool, shareOutAmount) } diff --git a/x/gamm/keeper/gas_test.go b/x/gamm/keeper/gas_test.go index bcddf735df9..014a52aa492 100644 --- a/x/gamm/keeper/gas_test.go +++ b/x/gamm/keeper/gas_test.go @@ -4,6 +4,7 @@ import ( "fmt" "strconv" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -13,13 +14,13 @@ import ( var ( defaultAddr sdk.AccAddress = sdk.AccAddress([]byte("addr1---------------")) defaultCoins sdk.Coins = sdk.Coins{} - minShareOutAmount sdk.Int = types.OneShare.MulRaw(50) + minShareOutAmount osmomath.Int = types.OneShare.MulRaw(50) ) func (s *KeeperTestSuite) measureJoinPoolGas( addr sdk.AccAddress, poolID uint64, - shareOutAmountMax sdk.Int, maxCoins sdk.Coins, + shareOutAmountMax osmomath.Int, maxCoins sdk.Coins, ) uint64 { alreadySpent := s.Ctx.GasMeter().GasConsumed() _, _, err := s.App.GAMMKeeper.JoinPoolNoSwap(s.Ctx, addr, poolID, shareOutAmountMax, maxCoins) @@ -35,7 +36,7 @@ func (s *KeeperTestSuite) measureAvgAndMaxJoinPoolGas( numIterations int, addr sdk.AccAddress, poolIDFn func(int) uint64, - shareOutAmountMaxFn func(int) sdk.Int, + shareOutAmountMaxFn func(int) osmomath.Int, maxCoinsFn func(int) sdk.Coins, ) (avg uint64, maxGas uint64) { runningTotal := uint64(0) @@ -57,17 +58,17 @@ func (s *KeeperTestSuite) TestJoinPoolGas() { poolId := s.PrepareBalancerPool() poolIDFn := func(int) uint64 { return poolId } - minShareOutAmountFn := func(int) sdk.Int { return minShareOutAmount } + minShareOutAmountFn := func(int) osmomath.Int { return minShareOutAmount } maxCoinsFn := func(int) sdk.Coins { return defaultCoins } startAveragingAt := 1000 totalNumJoins := 10000 // mint some assets to the accounts s.FundAcc(defaultAddr, sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000000000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000000000000)), - sdk.NewCoin("baz", sdk.NewInt(10000000000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000000000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000000000000)), + sdk.NewCoin("baz", osmomath.NewInt(10000000000000000)), )) firstJoinGas := s.measureJoinPoolGas(defaultAddr, poolId, minShareOutAmount, defaultCoins) @@ -87,7 +88,7 @@ func (s *KeeperTestSuite) TestJoinPoolGas() { func (s *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() { // mint some usomo to account s.FundAcc(defaultAddr, sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1000000000000000000)), )) // number of distinct denom to test @@ -95,28 +96,28 @@ func (s *KeeperTestSuite) TestRepeatedJoinPoolDistinctDenom() { // create pools prior to testing JoinPool using distinct denom coins := sdk.NewCoins( - sdk.NewCoin("randToken1", sdk.NewInt(100)), + sdk.NewCoin("randToken1", osmomath.NewInt(100)), ) s.FundAcc(defaultAddr, coins) defaultPoolParams := balancer.PoolParams{ - SwapFee: sdk.NewDec(0), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDec(0), + ExitFee: osmomath.NewDec(0), } for i := 1; i <= denomNumber; i++ { randToken := "randToken" + strconv.Itoa(i+1) prevRandToken := "randToken" + strconv.Itoa(i) - coins := sdk.NewCoins(sdk.NewCoin(randToken, sdk.NewInt(100))) + coins := sdk.NewCoins(sdk.NewCoin(randToken, osmomath.NewInt(100))) s.FundAcc(defaultAddr, coins) poolAssets := []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(prevRandToken, sdk.NewInt(10)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(prevRandToken, osmomath.NewInt(10)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(randToken, sdk.NewInt(10)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(randToken, osmomath.NewInt(10)), }, } msg := balancer.NewMsgCreateBalancerPool(defaultAddr, defaultPoolParams, poolAssets, "") diff --git a/x/gamm/keeper/genesis_test.go b/x/gamm/keeper/genesis_test.go index d27cdb23cec..d67eafade5d 100644 --- a/x/gamm/keeper/genesis_test.go +++ b/x/gamm/keeper/genesis_test.go @@ -5,6 +5,7 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" gammmigration "github.com/osmosis-labs/osmosis/v19/x/gamm/types/migration" @@ -86,34 +87,34 @@ func (s *KeeperTestSuite) TestGammExportGenesis() { acc1 := s.TestAccs[0] err := simapp.FundAccount(s.App.BankKeeper, ctx, acc1, sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), sdk.NewInt64Coin("foo", 100000), sdk.NewInt64Coin("bar", 100000), )) s.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, "") _, err = s.App.PoolManagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) msg = balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(70), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(70), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, "") _, err = s.App.PoolManagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) @@ -131,21 +132,21 @@ func (s *KeeperTestSuite) TestMarshalUnmarshalGenesis() { acc1 := s.TestAccs[0] err := simapp.FundAccount(s.App.BankKeeper, ctx, acc1, sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), sdk.NewInt64Coin("foo", 100000), sdk.NewInt64Coin("bar", 100000), )) s.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, "") _, err = s.App.PoolManagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) diff --git a/x/gamm/keeper/grpc_query.go b/x/gamm/keeper/grpc_query.go index efa772ef180..035e15150f9 100644 --- a/x/gamm/keeper/grpc_query.go +++ b/x/gamm/keeper/grpc_query.go @@ -15,6 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/query" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/gamm/v2types" @@ -252,7 +253,7 @@ func (q Querier) CalcExitPoolCoinsFromShares(ctx context.Context, req *types.Que exitFee := pool.GetExitFee(sdkCtx) totalSharesAmount := pool.GetTotalShares() - if req.ShareInAmount.GTE(totalSharesAmount) || req.ShareInAmount.LTE(sdk.ZeroInt()) { + if req.ShareInAmount.GTE(totalSharesAmount) || req.ShareInAmount.LTE(osmomath.ZeroInt()) { return nil, errorsmod.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative") } diff --git a/x/gamm/keeper/grpc_query_test.go b/x/gamm/keeper/grpc_query_test.go index 929d44dcec4..9fd82d27b36 100644 --- a/x/gamm/keeper/grpc_query_test.go +++ b/x/gamm/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -19,36 +20,36 @@ func (s *KeeperTestSuite) TestCalcExitPoolCoinsFromShares() { queryClient := s.queryClient ctx := s.Ctx poolId := s.PrepareBalancerPool() - exitFee := sdk.ZeroDec() + exitFee := osmomath.ZeroDec() testCases := []struct { name string poolId uint64 - shareInAmount sdk.Int + shareInAmount osmomath.Int expectedErr error }{ { "valid test case", poolId, - sdk.NewInt(1000000000000000000), + osmomath.NewInt(1000000000000000000), nil, }, { "pool id does not exist", poolId + 1, - sdk.NewInt(1000000000000000000), + osmomath.NewInt(1000000000000000000), types.ErrPoolNotFound, }, { "zero share in amount", poolId, - sdk.ZeroInt(), + osmomath.ZeroInt(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative"), }, { "negative share in amount", poolId, - sdk.NewInt(-10000), + osmomath.NewInt(-10000), errorsmod.Wrapf(types.ErrInvalidMathApprox, "share ratio is zero or negative"), }, } @@ -95,7 +96,7 @@ func (s *KeeperTestSuite) TestCalcJoinPoolNoSwapShares() { queryClient := s.queryClient ctx := s.Ctx poolId := s.PrepareBalancerPool() - spreadFactor := sdk.ZeroDec() + spreadFactor := osmomath.ZeroDec() testCases := []struct { name string @@ -106,37 +107,37 @@ func (s *KeeperTestSuite) TestCalcJoinPoolNoSwapShares() { { "valid uneven multi asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000)), sdk.NewCoin("baz", sdk.NewInt(5000000)), sdk.NewCoin("uosmo", sdk.NewInt(5000000))), + sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000000)), sdk.NewCoin("bar", osmomath.NewInt(5000000)), sdk.NewCoin("baz", osmomath.NewInt(5000000)), sdk.NewCoin("uosmo", osmomath.NewInt(5000000))), nil, }, { "valid even multi asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500000)), sdk.NewCoin("bar", sdk.NewInt(1000000)), sdk.NewCoin("baz", sdk.NewInt(1500000)), sdk.NewCoin("uosmo", sdk.NewInt(2000000))), + sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(500000)), sdk.NewCoin("bar", osmomath.NewInt(1000000)), sdk.NewCoin("baz", osmomath.NewInt(1500000)), sdk.NewCoin("uosmo", osmomath.NewInt(2000000))), nil, }, { "invalid single asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))), errors.New("no-swap joins require LP'ing with all assets in pool"), }, { "pool id does not exist", poolId + 1, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))), types.PoolDoesNotExistError{PoolId: poolId + 1}, }, { "token in denom does not exist", poolId, - sdk.NewCoins(sdk.NewCoin("random", sdk.NewInt(10000))), + sdk.NewCoins(sdk.NewCoin("random", osmomath.NewInt(10000))), errorsmod.Wrapf(types.ErrDenomNotFoundInPool, "input denoms must already exist in the pool (%s)", "random"), }, { "join pool with incorrect amount of assets", poolId, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000)), sdk.NewCoin("bar", sdk.NewInt(10000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10000)), sdk.NewCoin("bar", osmomath.NewInt(10000))), errors.New("no-swap joins require LP'ing with all assets in pool"), }, } @@ -171,14 +172,14 @@ func (s *KeeperTestSuite) TestCalcJoinPoolNoSwapShares() { func (s *KeeperTestSuite) TestPoolsWithFilter() { var ( defaultAcctFunds sdk.Coins = sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000)), - sdk.NewCoin("baz", sdk.NewInt(10000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000)), + sdk.NewCoin("baz", osmomath.NewInt(10000000)), ) defaultPoolParams = balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), } ) @@ -199,12 +200,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { pool_type: "Balancer", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -216,12 +217,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { min_liquidity: "500000000foo, 500000000bar", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -234,12 +235,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { pool_type: "balaswap", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -252,12 +253,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { pool_type: "Balancer", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -269,12 +270,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { min_liquidity: "500whoami", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -286,12 +287,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { min_liquidity: "0foo,0bar", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -303,12 +304,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { pool_type: "Balancer", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: false, @@ -321,12 +322,12 @@ func (s *KeeperTestSuite) TestPoolsWithFilter() { pool_type: "Balancer", poolAssets: []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, expectedErr: true, @@ -359,7 +360,7 @@ func (s *KeeperTestSuite) TestCalcJoinPoolShares() { queryClient := s.queryClient ctx := s.Ctx poolId := s.PrepareBalancerPool() - spreadFactor := sdk.ZeroDec() + spreadFactor := osmomath.ZeroDec() testCases := []struct { name string @@ -370,37 +371,37 @@ func (s *KeeperTestSuite) TestCalcJoinPoolShares() { { "valid uneven multi asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000)), sdk.NewCoin("baz", sdk.NewInt(5000000)), sdk.NewCoin("uosmo", sdk.NewInt(5000000))), + sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000000)), sdk.NewCoin("bar", osmomath.NewInt(5000000)), sdk.NewCoin("baz", osmomath.NewInt(5000000)), sdk.NewCoin("uosmo", osmomath.NewInt(5000000))), nil, }, { "valid even multi asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(500000)), sdk.NewCoin("bar", sdk.NewInt(1000000)), sdk.NewCoin("baz", sdk.NewInt(1500000)), sdk.NewCoin("uosmo", sdk.NewInt(2000000))), + sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(500000)), sdk.NewCoin("bar", osmomath.NewInt(1000000)), sdk.NewCoin("baz", osmomath.NewInt(1500000)), sdk.NewCoin("uosmo", osmomath.NewInt(2000000))), nil, }, { "valid single asset join test case", poolId, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))), nil, }, { "pool id does not exist", poolId + 1, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))), types.PoolDoesNotExistError{PoolId: poolId + 1}, }, { "token in denom does not exist", poolId, - sdk.NewCoins(sdk.NewCoin("random", sdk.NewInt(10000))), + sdk.NewCoins(sdk.NewCoin("random", osmomath.NewInt(10000))), errorsmod.Wrapf(types.ErrDenomNotFoundInPool, "input denoms must already exist in the pool (%s)", "random"), }, { "join pool with incorrect amount of assets", poolId, - sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000)), sdk.NewCoin("bar", sdk.NewInt(10000))), + sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10000)), sdk.NewCoin("bar", osmomath.NewInt(10000))), errors.New("balancer pool only supports LP'ing with one asset or all assets in pool"), }, } @@ -555,7 +556,7 @@ func (s *KeeperTestSuite) TestQueryTotalPoolLiquidity() { res, err := queryClient.TotalPoolLiquidity(gocontext.Background(), &types.QueryTotalPoolLiquidityRequest{PoolId: poolId}) s.Require().NoError(err) - expectedCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000000)), sdk.NewCoin("bar", sdk.NewInt(5000000)), sdk.NewCoin("baz", sdk.NewInt(5000000)), sdk.NewCoin("uosmo", sdk.NewInt(5000000))) + expectedCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000000)), sdk.NewCoin("bar", osmomath.NewInt(5000000)), sdk.NewCoin("baz", osmomath.NewInt(5000000)), sdk.NewCoin("uosmo", osmomath.NewInt(5000000))) s.Require().Equal(res.Liquidity, expectedCoins) } @@ -617,24 +618,24 @@ func (s *KeeperTestSuite) TestQueryBalancerPoolTotalLiquidity() { // /* // { -// Weight: sdk.NewInt(200 * GuaranteedWeightPrecision), -// Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), +// Weight: osmomath.NewInt(200 * GuaranteedWeightPrecision), +// Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), // }, // { -// Weight: sdk.NewInt(300 * GuaranteedWeightPrecision), -// Token: sdk.NewCoin("baz", sdk.NewInt(5000000)), +// Weight: osmomath.NewInt(300 * GuaranteedWeightPrecision), +// Token: sdk.NewCoin("baz", osmomath.NewInt(5000000)), // }, // { -// Weight: sdk.NewInt(100 * GuaranteedWeightPrecision), -// Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), +// Weight: osmomath.NewInt(100 * GuaranteedWeightPrecision), +// Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), // }, // */ // PoolAssets := res.PoolAssets // s.Require().Equal(3, len(PoolAssets)) -// s.Require().Equal(sdk.NewInt(200*types.GuaranteedWeightPrecision), PoolAssets[0].Weight) -// s.Require().Equal(sdk.NewInt(300*types.GuaranteedWeightPrecision), PoolAssets[1].Weight) -// s.Require().Equal(sdk.NewInt(100*types.GuaranteedWeightPrecision), PoolAssets[2].Weight) +// s.Require().Equal(osmomath.NewInt(200*types.GuaranteedWeightPrecision), PoolAssets[0].Weight) +// s.Require().Equal(osmomath.NewInt(300*types.GuaranteedWeightPrecision), PoolAssets[1].Weight) +// s.Require().Equal(osmomath.NewInt(100*types.GuaranteedWeightPrecision), PoolAssets[2].Weight) // s.Require().Equal("5000000bar", PoolAssets[0].Token.String()) // s.Require().Equal("5000000baz", PoolAssets[1].Token.String()) @@ -688,7 +689,7 @@ func (s *KeeperTestSuite) TestQueryBalancerPoolSpotPrice() { BaseAssetDenom: "foo", QuoteAssetDenom: "bar", }, - result: sdk.NewDec(2).String(), + result: osmomath.NewDec(2).String(), }, { name: "valid request for bar/baz", @@ -697,7 +698,7 @@ func (s *KeeperTestSuite) TestQueryBalancerPoolSpotPrice() { BaseAssetDenom: "bar", QuoteAssetDenom: "baz", }, - result: sdk.NewDecWithPrec(15, 1).String(), + result: osmomath.NewDecWithPrec(15, 1).String(), }, { name: "valid request for baz/foo", @@ -706,7 +707,7 @@ func (s *KeeperTestSuite) TestQueryBalancerPoolSpotPrice() { BaseAssetDenom: "baz", QuoteAssetDenom: "foo", }, - result: sdk.MustNewDecFromStr("0.333333330000000000").String(), + result: osmomath.MustNewDecFromStr("0.333333330000000000").String(), }, } @@ -779,7 +780,7 @@ func (s *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { BaseAssetDenom: "tokenA", QuoteAssetDenom: "tokenB", }, - result: sdk.NewDec(2).String(), + result: osmomath.NewDec(2).String(), }, { name: "tokenB in terms of tokenA", @@ -788,7 +789,7 @@ func (s *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { BaseAssetDenom: "tokenB", QuoteAssetDenom: "tokenA", }, - result: sdk.NewDecWithPrec(5, 1).String(), + result: osmomath.NewDecWithPrec(5, 1).String(), }, { name: "tokenC in terms of tokenD (rounded decimal of 4/3)", @@ -797,7 +798,7 @@ func (s *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { BaseAssetDenom: "tokenC", QuoteAssetDenom: "tokenD", }, - result: sdk.MustNewDecFromStr("1.333333330000000000").String(), + result: osmomath.MustNewDecFromStr("1.333333330000000000").String(), }, { name: "tokenD in terms of tokenE (1)", @@ -806,7 +807,7 @@ func (s *KeeperTestSuite) TestV2QueryBalancerPoolSpotPrice() { BaseAssetDenom: "tokenD", QuoteAssetDenom: "tokenE", }, - result: sdk.OneDec().String(), + result: osmomath.OneDec().String(), }, } @@ -896,12 +897,12 @@ func (s *KeeperTestSuite) TestQueryStableswapPoolSpotPrice() { } else { s.Require().NoError(err, "unexpected error") // We allow for a small geometric error due to our spot price being an approximation - expectedSpotPrice := sdk.MustNewDecFromStr(tc.result) - actualSpotPrice := sdk.MustNewDecFromStr(result.SpotPrice) + expectedSpotPrice := osmomath.MustNewDecFromStr(tc.result) + actualSpotPrice := osmomath.MustNewDecFromStr(result.SpotPrice) diff := (expectedSpotPrice.Sub(actualSpotPrice)).Abs() - errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, actualSpotPrice)) + errTerm := diff.Quo(osmomath.MinDec(expectedSpotPrice, actualSpotPrice)) - s.Require().True(errTerm.LT(sdk.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) + s.Require().True(errTerm.LT(osmomath.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) } }) } @@ -979,12 +980,12 @@ func (s *KeeperTestSuite) TestV2QueryStableswapPoolSpotPrice() { s.Require().NoError(err, "unexpected error") // We allow for a small geometric error due to our spot price being an approximation - expectedSpotPrice := sdk.MustNewDecFromStr(tc.result) - actualSpotPrice := sdk.MustNewDecFromStr(result.SpotPrice) + expectedSpotPrice := osmomath.MustNewDecFromStr(tc.result) + actualSpotPrice := osmomath.MustNewDecFromStr(result.SpotPrice) diff := (expectedSpotPrice.Sub(actualSpotPrice)).Abs() - errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, actualSpotPrice)) + errTerm := diff.Quo(osmomath.MinDec(expectedSpotPrice, actualSpotPrice)) - s.Require().True(errTerm.LT(sdk.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) + s.Require().True(errTerm.LT(osmomath.NewDecWithPrec(1, 3)), "Expected: %d, Actual: %d", expectedSpotPrice, actualSpotPrice) } }) } diff --git a/x/gamm/keeper/keeper_test.go b/x/gamm/keeper/keeper_test.go index 734a5ad7d1a..bb2185864ab 100644 --- a/x/gamm/keeper/keeper_test.go +++ b/x/gamm/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" @@ -20,8 +21,8 @@ type KeeperTestSuite struct { } var ( - defaultSpreadFactor = sdk.MustNewDecFromStr("0.025") - defaultZeroExitFee = sdk.ZeroDec() + defaultSpreadFactor = osmomath.MustNewDecFromStr("0.025") + defaultZeroExitFee = osmomath.ZeroDec() ) func TestKeeperTestSuite(t *testing.T) { diff --git a/x/gamm/keeper/migrate.go b/x/gamm/keeper/migrate.go index 8fdc9cbbb65..d6bf6a7028b 100644 --- a/x/gamm/keeper/migrate.go +++ b/x/gamm/keeper/migrate.go @@ -4,6 +4,7 @@ import ( "fmt" "sort" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -367,7 +368,7 @@ func (k Keeper) UpdateMigrationRecords(ctx sdk.Context, records []gammmigration. // Returns error if desired denom 0 is not in associated with the CFMM pool. // Returns error if CFMM pool does not have exactly 2 denoms. // Returns error if pool creation fails. -func (k Keeper) CreateConcentratedPoolFromCFMM(ctx sdk.Context, cfmmPoolIdToLinkWith uint64, desiredDenom0 string, spreadFactor sdk.Dec, tickSpacing uint64) (poolmanagertypes.PoolI, error) { +func (k Keeper) CreateConcentratedPoolFromCFMM(ctx sdk.Context, cfmmPoolIdToLinkWith uint64, desiredDenom0 string, spreadFactor osmomath.Dec, tickSpacing uint64) (poolmanagertypes.PoolI, error) { cfmmPool, err := k.GetCFMMPool(ctx, cfmmPoolIdToLinkWith) if err != nil { return nil, err @@ -409,7 +410,7 @@ func (k Keeper) CreateConcentratedPoolFromCFMM(ctx sdk.Context, cfmmPoolIdToLink // This method calls OverwriteMigrationRecords, which creates a migration link between the CFMM/CL pool as well as migrates the // gauges and distribution records from the CFMM pool to the new CL pool. // Returns error if fails to create concentrated liquidity pool from CFMM pool. -func (k Keeper) CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx sdk.Context, cfmmPoolId uint64, desiredDenom0 string, spreadFactor sdk.Dec, tickSpacing uint64) (poolmanagertypes.PoolI, error) { +func (k Keeper) CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(ctx sdk.Context, cfmmPoolId uint64, desiredDenom0 string, spreadFactor osmomath.Dec, tickSpacing uint64) (poolmanagertypes.PoolI, error) { concentratedPool, err := k.CreateConcentratedPoolFromCFMM(ctx, cfmmPoolId, desiredDenom0, spreadFactor, tickSpacing) if err != nil { return nil, err diff --git a/x/gamm/keeper/migrate_test.go b/x/gamm/keeper/migrate_test.go index 62a1a7c5441..63af0e328ec 100644 --- a/x/gamm/keeper/migrate_test.go +++ b/x/gamm/keeper/migrate_test.go @@ -23,8 +23,8 @@ var ( DAIIBCDenom = "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7" USDCIBCDenom = "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858" - defaultDaiAmount, _ = sdk.NewIntFromString("73000000000000000000000") - defaultDenom0mount = sdk.NewInt(10000000000) + defaultDaiAmount, _ = osmomath.NewIntFromString("73000000000000000000000") + defaultDenom0mount = osmomath.NewInt(10000000000) desiredDenom0 = "uosmo" desiredDenom0Coin = sdk.NewCoin(desiredDenom0, defaultDenom0mount) daiCoin = sdk.NewCoin(DAIIBCDenom, defaultDaiAmount) @@ -33,9 +33,9 @@ var ( func (s *KeeperTestSuite) TestMigrate() { defaultAccount := apptesting.CreateRandomAccounts(1)[0] - defaultGammShares := sdk.NewCoin("gamm/pool/1", sdk.MustNewDecFromStr("100000000000000000000").RoundInt()) - invalidGammShares := sdk.NewCoin("gamm/pool/1", sdk.MustNewDecFromStr("190000000000000000001").RoundInt()) - defaultAccountFunds := sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(200000000000)), sdk.NewCoin("usdc", sdk.NewInt(200000000000))) + defaultGammShares := sdk.NewCoin("gamm/pool/1", osmomath.MustNewDecFromStr("100000000000000000000").RoundInt()) + invalidGammShares := sdk.NewCoin("gamm/pool/1", osmomath.MustNewDecFromStr("190000000000000000001").RoundInt()) + defaultAccountFunds := sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(200000000000)), sdk.NewCoin("usdc", osmomath.NewInt(200000000000))) // Explanation of additive tolerance of 100000: // @@ -56,7 +56,7 @@ func (s *KeeperTestSuite) TestMigrate() { // These leaves us with full transfer of asset 0 and a (correct) transfer of asset 1 amounting to full GAMM balance minus 100000. // We expect this tolerance to be sufficient as long as our test cases are on the same order of magnitude. defaultErrorTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.NewDec(100000), + AdditiveTolerance: osmomath.NewDec(100000), RoundingDir: osmomath.RoundDown, } defaultJoinTime := s.Ctx.BlockTime() @@ -64,16 +64,16 @@ func (s *KeeperTestSuite) TestMigrate() { type param struct { sender sdk.AccAddress sharesToMigrateDenom string - sharesToMigrateAmount sdk.Int + sharesToMigrateAmount osmomath.Int } tests := []struct { name string param param expectedErr error - sharesToCreate sdk.Int + sharesToCreate osmomath.Int tokenOutMins sdk.Coins - expectedLiquidity sdk.Dec + expectedLiquidity osmomath.Dec setupPoolMigrationLink bool errTolerance osmomath.ErrTolerance }{ @@ -85,7 +85,7 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: defaultGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: true, errTolerance: defaultErrorTolerance, }, @@ -97,7 +97,7 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: defaultGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: false, expectedErr: types.ConcentratedPoolMigrationLinkNotFoundError{PoolIdLeaving: 1}, errTolerance: defaultErrorTolerance, @@ -107,10 +107,10 @@ func (s *KeeperTestSuite) TestMigrate() { param: param{ sender: defaultAccount, sharesToMigrateDenom: defaultGammShares.Denom, - sharesToMigrateAmount: defaultGammShares.Amount.Quo(sdk.NewInt(2)), + sharesToMigrateAmount: defaultGammShares.Amount.Quo(osmomath.NewInt(2)), }, sharesToCreate: defaultGammShares.Amount, - expectedLiquidity: sdk.MustNewDecFromStr("50000000000.000000005000000000"), + expectedLiquidity: osmomath.MustNewDecFromStr("50000000000.000000005000000000"), setupPoolMigrationLink: true, errTolerance: defaultErrorTolerance, }, @@ -119,10 +119,10 @@ func (s *KeeperTestSuite) TestMigrate() { param: param{ sender: defaultAccount, sharesToMigrateDenom: defaultGammShares.Denom, - sharesToMigrateAmount: defaultGammShares.Amount.Quo(sdk.NewInt(2)), + sharesToMigrateAmount: defaultGammShares.Amount.Quo(osmomath.NewInt(2)), }, - sharesToCreate: defaultGammShares.Amount.Mul(sdk.NewInt(2)), - expectedLiquidity: sdk.MustNewDecFromStr("49999999999.000000004999999999"), + sharesToCreate: defaultGammShares.Amount.Mul(osmomath.NewInt(2)), + expectedLiquidity: osmomath.MustNewDecFromStr("49999999999.000000004999999999"), setupPoolMigrationLink: true, errTolerance: defaultErrorTolerance, }, @@ -134,7 +134,7 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: invalidGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: true, expectedErr: errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, fmt.Sprintf("%s is smaller than %s", defaultGammShares, invalidGammShares)), }, @@ -147,8 +147,8 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: defaultGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(90000000000)), sdk.NewCoin(USDC, sdk.NewInt(90000000000))), - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(90000000000)), sdk.NewCoin(USDC, osmomath.NewInt(90000000000))), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: true, errTolerance: defaultErrorTolerance, }, @@ -160,12 +160,12 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: defaultGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(110000000000)), sdk.NewCoin(USDC, sdk.NewInt(110000000000))), - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(110000000000)), sdk.NewCoin(USDC, osmomath.NewInt(110000000000))), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: true, expectedErr: errorsmod.Wrapf(types.ErrLimitMinAmount, "Exit pool returned %s , minimum tokens out specified as %s", - sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(100000000000)), sdk.NewCoin(USDC, sdk.NewInt(100000000000))), sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(110000000000)), sdk.NewCoin(USDC, sdk.NewInt(110000000000)))), + sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(100000000000)), sdk.NewCoin(USDC, osmomath.NewInt(100000000000))), sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(110000000000)), sdk.NewCoin(USDC, osmomath.NewInt(110000000000)))), errTolerance: defaultErrorTolerance, }, { @@ -176,12 +176,12 @@ func (s *KeeperTestSuite) TestMigrate() { sharesToMigrateAmount: defaultGammShares.Amount, }, sharesToCreate: defaultGammShares.Amount, - tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(110000000000)), sdk.NewCoin(USDC, sdk.NewInt(100000000000))), - expectedLiquidity: sdk.MustNewDecFromStr("100000000000.000000010000000000"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(110000000000)), sdk.NewCoin(USDC, osmomath.NewInt(100000000000))), + expectedLiquidity: osmomath.MustNewDecFromStr("100000000000.000000010000000000"), setupPoolMigrationLink: true, expectedErr: errorsmod.Wrapf(types.ErrLimitMinAmount, "Exit pool returned %s , minimum tokens out specified as %s", - sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(100000000000)), sdk.NewCoin(USDC, sdk.NewInt(100000000000))), sdk.NewCoins(sdk.NewCoin(ETH, sdk.NewInt(110000000000)), sdk.NewCoin(USDC, sdk.NewInt(100000000000)))), + sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(100000000000)), sdk.NewCoin(USDC, osmomath.NewInt(100000000000))), sdk.NewCoins(sdk.NewCoin(ETH, osmomath.NewInt(110000000000)), sdk.NewCoin(USDC, osmomath.NewInt(100000000000)))), errTolerance: defaultErrorTolerance, }, } @@ -193,7 +193,7 @@ func (s *KeeperTestSuite) TestMigrate() { // Prepare both balancer and concentrated pools s.FundAcc(test.param.sender, defaultAccountFunds) - balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("eth", sdk.NewInt(100000000000)), sdk.NewCoin("usdc", sdk.NewInt(100000000000))) + balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("eth", osmomath.NewInt(100000000000)), sdk.NewCoin("usdc", osmomath.NewInt(100000000000))) balancerPool, err := s.App.GAMMKeeper.GetPoolAndPoke(s.Ctx, balancerPoolId) s.Require().NoError(err) clPool := s.PrepareConcentratedPool() @@ -210,7 +210,7 @@ func (s *KeeperTestSuite) TestMigrate() { clPoolAddress := clPool.GetAddress() // Join balancer pool to create gamm shares directed in the test case - _, _, err = s.App.GAMMKeeper.JoinPoolNoSwap(s.Ctx, test.param.sender, balancerPoolId, test.sharesToCreate, sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(999999999999999)), sdk.NewCoin("usdc", sdk.NewInt(999999999999999)))) + _, _, err = s.App.GAMMKeeper.JoinPoolNoSwap(s.Ctx, test.param.sender, balancerPoolId, test.sharesToCreate, sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(999999999999999)), sdk.NewCoin("usdc", osmomath.NewInt(999999999999999)))) s.Require().NoError(err) // Note balancer pool balance after joining balancer pool @@ -224,7 +224,7 @@ func (s *KeeperTestSuite) TestMigrate() { balancerPool, err = s.App.GAMMKeeper.GetPoolAndPoke(s.Ctx, balancerPoolId) s.Require().NoError(err) sharesToMigrate := sdk.NewCoin(test.param.sharesToMigrateDenom, test.param.sharesToMigrateAmount) - expectedCoinsOut, err := balancerPool.CalcExitPoolCoinsFromShares(s.Ctx, sharesToMigrate.Amount, sdk.ZeroDec()) + expectedCoinsOut, err := balancerPool.CalcExitPoolCoinsFromShares(s.Ctx, sharesToMigrate.Amount, osmomath.ZeroDec()) s.Require().NoError(err) // Migrate the user's gamm shares to a full range concentrated liquidity position @@ -246,8 +246,8 @@ func (s *KeeperTestSuite) TestMigrate() { // Assure cl pool has no balance after a failed migration. clPoolEthBalanceAfterFailedMigration := s.App.BankKeeper.GetBalance(s.Ctx, clPoolAddress, ETH) clPoolUsdcBalanceAfterFailedMigration := s.App.BankKeeper.GetBalance(s.Ctx, clPoolAddress, USDC) - s.Require().Equal(sdk.NewInt(0), clPoolEthBalanceAfterFailedMigration.Amount) - s.Require().Equal(sdk.NewInt(0), clPoolUsdcBalanceAfterFailedMigration.Amount) + s.Require().Equal(osmomath.NewInt(0), clPoolEthBalanceAfterFailedMigration.Amount) + s.Require().Equal(osmomath.NewInt(0), clPoolUsdcBalanceAfterFailedMigration.Amount) // Assure the position was not created. // TODO: When we implement lock breaking, we need to change time.Time{} to the lock's end time. @@ -431,8 +431,8 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { s.SetupTest() keeper := s.App.GAMMKeeper - defaultBalancerCoin0 := sdk.NewCoin(ETH, sdk.NewInt(1000000000)) - defaultBalancerCoin1 := sdk.NewCoin(USDC, sdk.NewInt(1000000000)) + defaultBalancerCoin0 := sdk.NewCoin(ETH, osmomath.NewInt(1000000000)) + defaultBalancerCoin1 := sdk.NewCoin(USDC, osmomath.NewInt(1000000000)) if test.overwriteBalancerDenom0 != "" { defaultBalancerCoin0.Denom = test.overwriteBalancerDenom0 @@ -449,7 +449,7 @@ func (s *KeeperTestSuite) TestReplaceMigrationRecords() { s.PrepareBalancerPoolWithCoins(poolCoins...) } for i := 0; i < 2; i++ { - s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, defaultTickSpacing, sdk.ZeroDec()) + s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, defaultTickSpacing, osmomath.ZeroDec()) } // Four asset balancer pool ID if created: 5 if test.createFourAssetBalancerPool { @@ -690,8 +690,8 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { s.SetupTest() keeper := s.App.GAMMKeeper - defaultBalancerCoin0 := sdk.NewCoin(ETH, sdk.NewInt(1000000000)) - defaultBalancerCoin1 := sdk.NewCoin(USDC, sdk.NewInt(1000000000)) + defaultBalancerCoin0 := sdk.NewCoin(ETH, osmomath.NewInt(1000000000)) + defaultBalancerCoin1 := sdk.NewCoin(USDC, osmomath.NewInt(1000000000)) if test.overwriteBalancerDenom0 != "" { defaultBalancerCoin0.Denom = test.overwriteBalancerDenom0 @@ -708,7 +708,7 @@ func (s *KeeperTestSuite) TestUpdateMigrationRecords() { s.PrepareBalancerPoolWithCoins(poolCoins...) } for i := 0; i < 4; i++ { - s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, defaultTickSpacing, sdk.ZeroDec()) + s.PrepareCustomConcentratedPool(s.TestAccs[0], ETH, USDC, defaultTickSpacing, osmomath.ZeroDec()) } // Four asset balancer pool ID if created: 9 if test.createFourAssetBalancerPool { @@ -920,8 +920,8 @@ func (s *KeeperTestSuite) TestRedirectDistributionRecord() { s.Setup() var ( - defaultUsdcAmount = sdk.NewInt(7300000000) - defaultOsmoAmount = sdk.NewInt(10000000000) + defaultUsdcAmount = osmomath.NewInt(7300000000) + defaultOsmoAmount = osmomath.NewInt(10000000000) usdcCoin = sdk.NewCoin("uusdc", defaultUsdcAmount) osmoCoin = sdk.NewCoin("uosmo", defaultOsmoAmount) ) @@ -975,22 +975,22 @@ func (s *KeeperTestSuite) TestRedirectDistributionRecord() { // Distribution info prior to redirecting. originalDistrInfo := poolincentivestypes.DistrInfo{ - TotalWeight: sdk.NewInt(100), + TotalWeight: osmomath.NewInt(100), Records: []poolincentivestypes.DistrRecord{ { GaugeId: gaugeToRedirect, - Weight: sdk.NewInt(50), + Weight: osmomath.NewInt(50), }, { GaugeId: gaugeToNotRedirect, - Weight: sdk.NewInt(50), + Weight: osmomath.NewInt(50), }, }, } s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, originalDistrInfo) // Create concentrated pool. - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], tc.poolLiquidity[1].Denom, tc.poolLiquidity[0].Denom, 100, sdk.MustNewDecFromStr("0.001")) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], tc.poolLiquidity[1].Denom, tc.poolLiquidity[0].Denom, 100, osmomath.MustNewDecFromStr("0.001")) // Redirect distribution record from the primary balancer pool to the concentrated pool. err = s.App.GAMMKeeper.RedirectDistributionRecord(s.Ctx, tc.cfmmPoolId, tc.clPoolId) @@ -1055,7 +1055,7 @@ func (s *KeeperTestSuite) TestCreateConcentratedPoolFromCFMM() { balancerPool, err := s.App.PoolManagerKeeper.GetPool(s.Ctx, balancerId) s.Require().NoError(err) - clPoolReturned, err := s.App.GAMMKeeper.CreateConcentratedPoolFromCFMM(s.Ctx, tc.cfmmPoolIdToLinkWith, tc.desiredDenom0, sdk.ZeroDec(), defaultTickSpacing) + clPoolReturned, err := s.App.GAMMKeeper.CreateConcentratedPoolFromCFMM(s.Ctx, tc.cfmmPoolIdToLinkWith, tc.desiredDenom0, osmomath.ZeroDec(), defaultTickSpacing) if tc.expectError != nil { s.Require().Error(err) @@ -1165,21 +1165,21 @@ func (s *KeeperTestSuite) TestCreateCanonicalConcentratedLiquidityPoolAndMigrati gaugeToNotRedeirect, _ := s.App.PoolIncentivesKeeper.GetPoolGaugeId(s.Ctx, balancerId2, longestLockableDuration) originalDistrInfo := poolincentivestypes.DistrInfo{ - TotalWeight: sdk.NewInt(100), + TotalWeight: osmomath.NewInt(100), Records: []poolincentivestypes.DistrRecord{ { GaugeId: gaugeToRedirect, - Weight: sdk.NewInt(50), + Weight: osmomath.NewInt(50), }, { GaugeId: gaugeToNotRedeirect, - Weight: sdk.NewInt(50), + Weight: osmomath.NewInt(50), }, }, } s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, originalDistrInfo) - clPool, err := s.App.GAMMKeeper.CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(s.Ctx, tc.cfmmPoolIdToLinkWith, tc.desiredDenom0, sdk.ZeroDec(), defaultTickSpacing) + clPool, err := s.App.GAMMKeeper.CreateCanonicalConcentratedLiquidityPoolAndMigrationLink(s.Ctx, tc.cfmmPoolIdToLinkWith, tc.desiredDenom0, osmomath.ZeroDec(), defaultTickSpacing) if tc.expectError != nil { s.Require().Error(err) diff --git a/x/gamm/keeper/msg_server_test.go b/x/gamm/keeper/msg_server_test.go index c10c9c1d00e..68e33d967eb 100644 --- a/x/gamm/keeper/msg_server_test.go +++ b/x/gamm/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/keeper" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -25,15 +26,15 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { testcases := map[string]struct { routes []poolmanagertypes.SwapAmountInRoute tokenIn sdk.Coin - tokenOutMinAmount sdk.Int + tokenOutMinAmount osmomath.Int expectError bool expectedSwapEvents int expectedMessageEvents int }{ "zero hops": { routes: []poolmanagertypes.SwapAmountInRoute{}, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(tokenIn)), + tokenOutMinAmount: osmomath.NewInt(tokenInMinAmount), expectError: true, }, "one hop": { @@ -43,8 +44,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { TokenOutDenom: "bar", }, }, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(tokenIn)), + tokenOutMinAmount: osmomath.NewInt(tokenInMinAmount), expectedSwapEvents: 1, expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. }, @@ -59,8 +60,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { TokenOutDenom: "baz", }, }, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(tokenIn)), + tokenOutMinAmount: osmomath.NewInt(tokenInMinAmount), expectedSwapEvents: 2, expectedMessageEvents: 9, // 1 gamm + 8 events emitted by other keeper methods. }, @@ -75,8 +76,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountIn_Events() { TokenOutDenom: "baz", }, }, - tokenIn: sdk.NewCoin(doesNotExistDenom, sdk.NewInt(tokenIn)), - tokenOutMinAmount: sdk.NewInt(tokenInMinAmount), + tokenIn: sdk.NewCoin(doesNotExistDenom, osmomath.NewInt(tokenIn)), + tokenOutMinAmount: osmomath.NewInt(tokenInMinAmount), expectedMessageEvents: 2, // 2 event gets triggered prior to failure. expectError: true, }, @@ -125,15 +126,15 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { testcases := map[string]struct { routes []poolmanagertypes.SwapAmountOutRoute tokenOut sdk.Coin - tokenInMaxAmount sdk.Int + tokenInMaxAmount osmomath.Int expectError bool expectedSwapEvents int expectedMessageEvents int }{ "zero hops": { routes: []poolmanagertypes.SwapAmountOutRoute{}, - tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), - tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), + tokenOut: sdk.NewCoin("foo", osmomath.NewInt(tokenOut)), + tokenInMaxAmount: osmomath.NewInt(tokenInMaxAmount), expectError: true, }, "one hop": { @@ -143,8 +144,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { TokenInDenom: "bar", }, }, - tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), - tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), + tokenOut: sdk.NewCoin("foo", osmomath.NewInt(tokenOut)), + tokenInMaxAmount: osmomath.NewInt(tokenInMaxAmount), expectedSwapEvents: 1, expectedMessageEvents: 5, // 1 gamm + 4 events emitted by other keeper methods. }, @@ -159,8 +160,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { TokenInDenom: "baz", }, }, - tokenOut: sdk.NewCoin("foo", sdk.NewInt(tokenOut)), - tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), + tokenOut: sdk.NewCoin("foo", osmomath.NewInt(tokenOut)), + tokenInMaxAmount: osmomath.NewInt(tokenInMaxAmount), expectedSwapEvents: 2, expectedMessageEvents: 9, // 1 gamm + 8 events emitted by other keeper methods. }, @@ -175,8 +176,8 @@ func (s *KeeperTestSuite) TestSwapExactAmountOut_Events() { TokenInDenom: "baz", }, }, - tokenOut: sdk.NewCoin(doesNotExistDenom, sdk.NewInt(tokenOut)), - tokenInMaxAmount: sdk.NewInt(tokenInMaxAmount), + tokenOut: sdk.NewCoin(doesNotExistDenom, osmomath.NewInt(tokenOut)), + tokenInMaxAmount: osmomath.NewInt(tokenInMaxAmount), expectError: true, }, } @@ -223,7 +224,7 @@ func (s *KeeperTestSuite) TestJoinPool_Events() { testcases := map[string]struct { poolId uint64 - shareOutAmount sdk.Int + shareOutAmount osmomath.Int tokenInMaxs sdk.Coins expectError bool expectedAddLiquidityEvents int @@ -231,20 +232,20 @@ func (s *KeeperTestSuite) TestJoinPool_Events() { }{ "successful join": { poolId: 1, - shareOutAmount: sdk.NewInt(shareOut), + shareOutAmount: osmomath.NewInt(shareOut), tokenInMaxs: sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(tokenInMaxAmount)), - sdk.NewCoin("bar", sdk.NewInt(tokenInMaxAmount)), - sdk.NewCoin("baz", sdk.NewInt(tokenInMaxAmount)), - sdk.NewCoin("uosmo", sdk.NewInt(tokenInMaxAmount)), + sdk.NewCoin("foo", osmomath.NewInt(tokenInMaxAmount)), + sdk.NewCoin("bar", osmomath.NewInt(tokenInMaxAmount)), + sdk.NewCoin("baz", osmomath.NewInt(tokenInMaxAmount)), + sdk.NewCoin("uosmo", osmomath.NewInt(tokenInMaxAmount)), ), expectedAddLiquidityEvents: 1, expectedMessageEvents: 3, // 1 gamm + 2 events emitted by other keeper methods. }, "tokenInMaxs do not match all tokens in pool - invalid join": { poolId: 1, - shareOutAmount: sdk.NewInt(shareOut), - tokenInMaxs: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tokenInMaxAmount))), + shareOutAmount: osmomath.NewInt(shareOut), + tokenInMaxs: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tokenInMaxAmount))), expectError: true, }, } @@ -290,7 +291,7 @@ func (s *KeeperTestSuite) TestExitPool_Events() { testcases := map[string]struct { poolId uint64 - shareInAmount sdk.Int + shareInAmount osmomath.Int tokenOutMins sdk.Coins expectError bool expectedRemoveLiquidityEvents int @@ -298,15 +299,15 @@ func (s *KeeperTestSuite) TestExitPool_Events() { }{ "successful exit": { poolId: 1, - shareInAmount: sdk.NewInt(shareIn), + shareInAmount: osmomath.NewInt(shareIn), tokenOutMins: sdk.NewCoins(), expectedRemoveLiquidityEvents: 1, expectedMessageEvents: 3, // 1 gamm + 2 events emitted by other keeper methods. }, "invalid tokenOutMins": { poolId: 1, - shareInAmount: sdk.NewInt(shareIn), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tokenOutMinAmount))), + shareInAmount: osmomath.NewInt(shareIn), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tokenOutMinAmount))), expectError: true, }, } @@ -325,12 +326,12 @@ func (s *KeeperTestSuite) TestExitPool_Events() { joinPoolResponse, err := msgServer.JoinPool(sdk.WrapSDKContext(ctx), &types.MsgJoinPool{ Sender: sender, PoolId: tc.poolId, - ShareOutAmount: sdk.NewInt(shareIn), + ShareOutAmount: osmomath.NewInt(shareIn), TokenInMaxs: sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(int64Max)), - sdk.NewCoin("bar", sdk.NewInt(int64Max)), - sdk.NewCoin("baz", sdk.NewInt(int64Max)), - sdk.NewCoin("uosmo", sdk.NewInt(int64Max)), + sdk.NewCoin("foo", osmomath.NewInt(int64Max)), + sdk.NewCoin("bar", osmomath.NewInt(int64Max)), + sdk.NewCoin("baz", osmomath.NewInt(int64Max)), + sdk.NewCoin("uosmo", osmomath.NewInt(int64Max)), ), }) s.Require().NoError(err) diff --git a/x/gamm/keeper/pool.go b/x/gamm/keeper/pool.go index 9b70f618b2e..b309dac9eb7 100644 --- a/x/gamm/keeper/pool.go +++ b/x/gamm/keeper/pool.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" @@ -149,7 +150,7 @@ func (k Keeper) DeletePool(ctx sdk.Context, poolId uint64) error { // on remaining locks before calling this function. // func (k Keeper) CleanupBalancerPool(ctx sdk.Context, poolIds []uint64, excludedModules []string) (err error) { // pools := make(map[string]types.CFMMPoolI) -// totalShares := make(map[string]sdk.Int) +// totalShares := make(map[string]osmomath.Int) // for _, poolId := range poolIds { // pool, err := k.GetPool(ctx, poolId) // if err != nil { @@ -299,10 +300,10 @@ func (k Keeper) GetTotalPoolLiquidity(ctx sdk.Context, poolId uint64) (sdk.Coins } // GetTotalPoolShares returns the total number of pool shares for the given pool. -func (k Keeper) GetTotalPoolShares(ctx sdk.Context, poolId uint64) (sdk.Int, error) { +func (k Keeper) GetTotalPoolShares(ctx sdk.Context, poolId uint64) (osmomath.Int, error) { pool, err := k.GetCFMMPool(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return pool.GetTotalShares(), nil @@ -357,6 +358,6 @@ func asCFMMPool(pool poolmanagertypes.PoolI) (types.CFMMPoolI, error) { // 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) { +func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.Dec, error) { return k.poolManager.GetTradingPairTakerFee(ctx, denom0, denom1) } diff --git a/x/gamm/keeper/pool_service.go b/x/gamm/keeper/pool_service.go index c5164b62c85..d7cdd54aea7 100644 --- a/x/gamm/keeper/pool_service.go +++ b/x/gamm/keeper/pool_service.go @@ -26,30 +26,30 @@ func (k Keeper) CalculateSpotPrice( poolID uint64, quoteAssetDenom string, baseAssetDenom string, -) (spotPrice sdk.Dec, err error) { +) (spotPrice osmomath.Dec, err error) { pool, err := k.GetPoolAndPoke(ctx, poolID) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } // defer to catch panics, in case something internal overflows. defer func() { if r := recover(); r != nil { - spotPrice = sdk.Dec{} + spotPrice = osmomath.Dec{} err = types.ErrSpotPriceInternal } }() spotPrice, err = pool.SpotPrice(ctx, quoteAssetDenom, baseAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } // if spotPrice greater than max spot price, return an error if spotPrice.GT(types.MaxSpotPrice) { return types.MaxSpotPrice, types.ErrSpotPriceOverflow } else if !spotPrice.IsPositive() { - return sdk.Dec{}, types.ErrSpotPriceInternal + return osmomath.Dec{}, types.ErrSpotPriceInternal } // we want to round this to `SpotPriceSigFigs` of precision @@ -127,49 +127,49 @@ func (k Keeper) JoinPoolNoSwap( ctx sdk.Context, sender sdk.AccAddress, poolId uint64, - shareOutAmount sdk.Int, + shareOutAmount osmomath.Int, tokenInMaxs sdk.Coins, -) (tokenIn sdk.Coins, sharesOut sdk.Int, err error) { +) (tokenIn sdk.Coins, sharesOut osmomath.Int, err error) { // defer to catch panics, in case something internal overflows. defer func() { if r := recover(); r != nil { tokenIn = sdk.Coins{} - sharesOut = sdk.Int{} + sharesOut = osmomath.Int{} err = fmt.Errorf("function JoinPoolNoSwap failed due to internal reason: %v", r) } }() // all pools handled within this method are pointer references, `JoinPool` directly updates the pools pool, err := k.GetPoolAndPoke(ctx, poolId) if err != nil { - return nil, sdk.ZeroInt(), err + return nil, osmomath.ZeroInt(), err } // we do an abstract calculation on the lp liquidity coins needed to have // the designated amount of given shares of the pool without performing swap neededLpLiquidity, err := getMaximalNoSwapLPAmount(ctx, pool, shareOutAmount) if err != nil { - return nil, sdk.ZeroInt(), err + return nil, osmomath.ZeroInt(), err } // check that needed lp liquidity does not exceed the given `tokenInMaxs` parameter. Return error if so. // if tokenInMaxs == 0, don't do this check. if tokenInMaxs.Len() != 0 { if !(neededLpLiquidity.DenomsSubsetOf(tokenInMaxs)) { - return nil, sdk.ZeroInt(), errorsmod.Wrapf(types.ErrLimitMaxAmount, "TokenInMaxs does not include all the tokens that are part of the target pool,"+ + return nil, osmomath.ZeroInt(), errorsmod.Wrapf(types.ErrLimitMaxAmount, "TokenInMaxs does not include all the tokens that are part of the target pool,"+ " upperbound: %v, needed %v", tokenInMaxs, neededLpLiquidity) } else if !(tokenInMaxs.DenomsSubsetOf(neededLpLiquidity)) { - return nil, sdk.ZeroInt(), errorsmod.Wrapf(types.ErrDenomNotFoundInPool, "TokenInMaxs includes tokens that are not part of the target pool,"+ + return nil, osmomath.ZeroInt(), errorsmod.Wrapf(types.ErrDenomNotFoundInPool, "TokenInMaxs includes tokens that are not part of the target pool,"+ " input tokens: %v, pool tokens %v", tokenInMaxs, neededLpLiquidity) } if !(tokenInMaxs.IsAllGTE(neededLpLiquidity)) { - return nil, sdk.ZeroInt(), errorsmod.Wrapf(types.ErrLimitMaxAmount, "TokenInMaxs is less than the needed LP liquidity to this JoinPoolNoSwap,"+ + return nil, osmomath.ZeroInt(), errorsmod.Wrapf(types.ErrLimitMaxAmount, "TokenInMaxs is less than the needed LP liquidity to this JoinPoolNoSwap,"+ " upperbound: %v, needed %v", tokenInMaxs, neededLpLiquidity) } } sharesOut, err = pool.JoinPoolNoSwap(ctx, neededLpLiquidity, pool.GetSpreadFactor(ctx)) if err != nil { - return nil, sdk.ZeroInt(), err + return nil, osmomath.ZeroInt(), err } // sanity check, don't return error as not worth halting the LP. We know its not too much. if sharesOut.LT(shareOutAmount) { @@ -186,12 +186,12 @@ func (k Keeper) JoinPoolNoSwap( // 1. calculate how much percent of the pool does given share account for(# of input shares / # of current total shares) // 2. since we know how much % of the pool we want, iterate through all pool liquidity to calculate how much coins we need for // each pool asset. -func getMaximalNoSwapLPAmount(ctx sdk.Context, pool types.CFMMPoolI, shareOutAmount sdk.Int) (neededLpLiquidity sdk.Coins, err error) { +func getMaximalNoSwapLPAmount(ctx sdk.Context, pool types.CFMMPoolI, shareOutAmount osmomath.Int) (neededLpLiquidity sdk.Coins, err error) { totalSharesAmount := pool.GetTotalShares() // shareRatio is the desired number of shares, divided by the total number of // shares currently in the pool. It is intended to be used in scenarios where you want - shareRatio := shareOutAmount.ToDec().QuoInt(totalSharesAmount) - if shareRatio.LTE(sdk.ZeroDec()) { + shareRatio := shareOutAmount.ToLegacyDec().QuoInt(totalSharesAmount) + if shareRatio.LTE(osmomath.ZeroDec()) { return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Too few shares out wanted. "+ "(debug: getMaximalNoSwapLPAmount share ratio is zero or negative)") } @@ -201,8 +201,8 @@ func getMaximalNoSwapLPAmount(ctx sdk.Context, pool types.CFMMPoolI, shareOutAmo for _, coin := range poolLiquidity { // (coin.Amt * shareRatio).Ceil() - neededAmt := coin.Amount.ToDec().Mul(shareRatio).Ceil().RoundInt() - if neededAmt.LTE(sdk.ZeroInt()) { + neededAmt := coin.Amount.ToLegacyDec().Mul(shareRatio).Ceil().RoundInt() + if neededAmt.LTE(osmomath.ZeroInt()) { return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Too few shares out wanted") } neededCoin := sdk.Coin{Denom: coin.Denom, Amount: neededAmt} @@ -221,41 +221,45 @@ func (k Keeper) JoinSwapExactAmountIn( sender sdk.AccAddress, poolId uint64, tokensIn sdk.Coins, - shareOutMinAmount sdk.Int, -) (sharesOut sdk.Int, err error) { + shareOutMinAmount osmomath.Int, +) (sharesOut osmomath.Int, err error) { // defer to catch panics, in case something internal overflows. defer func() { if r := recover(); r != nil { - sharesOut = sdk.Int{} + sharesOut = osmomath.Int{} err = fmt.Errorf("function JoinSwapExactAmountIn failed due to internal reason: %v", r) } }() pool, err := k.GetCFMMPool(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } + ctx.Logger().Info("JoinSwapExactAmountIn", "poold id", poolId, "height", ctx.BlockHeight(), "pool type", pool.GetType()) + sharesOut, err = pool.JoinPool(ctx, tokensIn, pool.GetSpreadFactor(ctx)) switch { case err != nil: - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err case sharesOut.LT(shareOutMinAmount): - return sdk.ZeroInt(), errorsmod.Wrapf( + return osmomath.ZeroInt(), errorsmod.Wrapf( types.ErrLimitMinAmount, "too much slippage; needed a minimum of %s shares to pass, got %s", shareOutMinAmount, sharesOut, ) - case sharesOut.LTE(sdk.ZeroInt()): - return sdk.ZeroInt(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "share amount is zero or negative") + case sharesOut.LTE(osmomath.ZeroInt()): + return osmomath.ZeroInt(), errorsmod.Wrapf(types.ErrInvalidMathApprox, "share amount is zero or negative") } if err := k.applyJoinPoolStateChange(ctx, pool, sender, sharesOut, tokensIn); err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } + ctx.Logger().Info("JoinSwapExactAmountIn final sharesOut", "sharesOut", sharesOut) + return sharesOut, nil } @@ -264,34 +268,34 @@ func (k Keeper) JoinSwapShareAmountOut( sender sdk.AccAddress, poolId uint64, tokenInDenom string, - shareOutAmount sdk.Int, - tokenInMaxAmount sdk.Int, -) (tokenInAmount sdk.Int, err error) { + shareOutAmount osmomath.Int, + tokenInMaxAmount osmomath.Int, +) (tokenInAmount osmomath.Int, err error) { // defer to catch panics, in case something internal overflows. defer func() { if r := recover(); r != nil { - tokenInAmount = sdk.Int{} + tokenInAmount = osmomath.Int{} err = fmt.Errorf("function JoinSwapShareAmountOut failed due to internal reason: %v", r) } }() pool, err := k.GetCFMMPool(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } extendedPool, ok := pool.(types.PoolAmountOutExtension) if !ok { - return sdk.Int{}, fmt.Errorf("pool with id %d does not support this kind of join", poolId) + return osmomath.Int{}, fmt.Errorf("pool with id %d does not support this kind of join", poolId) } tokenInAmount, err = extendedPool.CalcTokenInShareAmountOut(ctx, tokenInDenom, shareOutAmount, pool.GetSpreadFactor(ctx)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } if tokenInAmount.GT(tokenInMaxAmount) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, "%s resulted tokens is larger than the max amount of %s", tokenInAmount, tokenInMaxAmount) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, "%s resulted tokens is larger than the max amount of %s", tokenInAmount, tokenInMaxAmount) } tokenIn := sdk.NewCoins(sdk.NewCoin(tokenInDenom, tokenInAmount)) @@ -300,7 +304,7 @@ func (k Keeper) JoinSwapShareAmountOut( err = k.applyJoinPoolStateChange(ctx, pool, sender, shareOutAmount, tokenIn) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } return tokenInAmount, nil } @@ -309,7 +313,7 @@ func (k Keeper) ExitPool( ctx sdk.Context, sender sdk.AccAddress, poolId uint64, - shareInAmount sdk.Int, + shareInAmount osmomath.Int, tokenOutMins sdk.Coins, ) (exitCoins sdk.Coins, err error) { pool, err := k.GetPoolAndPoke(ctx, poolId) @@ -320,7 +324,7 @@ func (k Keeper) ExitPool( totalSharesAmount := pool.GetTotalShares() if shareInAmount.GTE(totalSharesAmount) { return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit >= the number of shares contained in the pool.") - } else if shareInAmount.LTE(sdk.ZeroInt()) { + } else if shareInAmount.LTE(osmomath.ZeroInt()) { return sdk.Coins{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "Trying to exit a negative amount of shares") } exitFee := pool.GetExitFee(ctx) @@ -350,17 +354,17 @@ func (k Keeper) ExitSwapShareAmountIn( sender sdk.AccAddress, poolId uint64, tokenOutDenom string, - shareInAmount sdk.Int, - tokenOutMinAmount sdk.Int, -) (tokenOutAmount sdk.Int, err error) { + shareInAmount osmomath.Int, + tokenOutMinAmount osmomath.Int, +) (tokenOutAmount osmomath.Int, err error) { exitCoins, err := k.ExitPool(ctx, sender, poolId, shareInAmount, sdk.Coins{}) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } pool, err := k.GetPool(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } spreadFactor := pool.GetSpreadFactor(ctx) @@ -369,15 +373,15 @@ func (k Keeper) ExitSwapShareAmountIn( if coin.Denom == tokenOutDenom { continue } - swapOut, err := k.SwapExactAmountIn(ctx, sender, pool, coin, tokenOutDenom, sdk.ZeroInt(), spreadFactor) + swapOut, err := k.SwapExactAmountIn(ctx, sender, pool, coin, tokenOutDenom, osmomath.ZeroInt(), spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmount = tokenOutAmount.Add(swapOut) } if tokenOutAmount.LT(tokenOutMinAmount) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrLimitMinAmount, + return osmomath.Int{}, errorsmod.Wrapf(types.ErrLimitMinAmount, "Provided LP shares yield %s tokens out, wanted a minimum of %s for it to work", tokenOutAmount, tokenOutMinAmount) } @@ -389,25 +393,25 @@ func (k Keeper) ExitSwapExactAmountOut( sender sdk.AccAddress, poolId uint64, tokenOut sdk.Coin, - shareInMaxAmount sdk.Int, -) (shareInAmount sdk.Int, err error) { + shareInMaxAmount osmomath.Int, +) (shareInAmount osmomath.Int, err error) { pool, err := k.GetCFMMPool(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } extendedPool, ok := pool.(types.PoolAmountOutExtension) if !ok { - return sdk.Int{}, fmt.Errorf("pool with id %d does not support this kind of exit", poolId) + return osmomath.Int{}, fmt.Errorf("pool with id %d does not support this kind of exit", poolId) } shareInAmount, err = extendedPool.ExitSwapExactAmountOut(ctx, tokenOut, shareInMaxAmount) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } if err := k.applyExitPoolStateChange(ctx, pool, sender, shareInAmount, sdk.Coins{tokenOut}); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return shareInAmount, nil diff --git a/x/gamm/keeper/pool_service_test.go b/x/gamm/keeper/pool_service_test.go index f70777ebd8a..9092673343d 100644 --- a/x/gamm/keeper/pool_service_test.go +++ b/x/gamm/keeper/pool_service_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" _ "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -27,23 +28,23 @@ var ( // pool assets defaultFooAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), } defaultBarAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), } defaultPoolAssets = []balancer.PoolAsset{defaultFooAsset, defaultBarAsset} defaultStableSwapPoolAssets sdk.Coins = sdk.NewCoins( - sdk.NewCoin("foo", sdk.NewInt(10000)), - sdk.NewCoin("bar", sdk.NewInt(10000)), + sdk.NewCoin("foo", osmomath.NewInt(10000)), + sdk.NewCoin("bar", osmomath.NewInt(10000)), ) defaultAcctFunds sdk.Coins = sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000)), - sdk.NewCoin("baz", sdk.NewInt(10000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000)), + sdk.NewCoin("baz", osmomath.NewInt(10000000)), ) ETH = "eth" USDC = "usdc" @@ -80,7 +81,7 @@ func (s *KeeperTestSuite) TestCreateBalancerPool() { }, { name: "create a pool with negative spread factor", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(-1, 2), + SwapFee: osmomath.NewDecWithPrec(-1, 2), ExitFee: defaultZeroExitFee, }, defaultPoolAssets, defaultFutureGovernor), emptySender: false, @@ -88,23 +89,23 @@ func (s *KeeperTestSuite) TestCreateBalancerPool() { }, { name: "create a pool with negative exit fee", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDecWithPrec(-1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDecWithPrec(-1, 2), }, defaultPoolAssets, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create a pool with non zero exit fee", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDecWithPrec(1, 2), }, defaultPoolAssets, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create the pool with empty PoolAssets", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{}, defaultFutureGovernor), emptySender: false, @@ -112,73 +113,73 @@ func (s *KeeperTestSuite) TestCreateBalancerPool() { }, { name: "create the pool with 0 weighted PoolAsset", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(0), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(0), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create the pool with negative weighted PoolAsset", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(-1), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(-1), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create the pool with 0 balance PoolAsset", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(0)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create the pool with negative balance PoolAsset", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), Token: sdk.Coin{ Denom: "foo", - Amount: sdk.NewInt(-1), + Amount: osmomath.NewInt(-1), }, }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }}, defaultFutureGovernor), emptySender: false, expectPass: false, }, { name: "create the pool with duplicated PoolAssets", msg: balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, []balancer.PoolAsset{{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }}, defaultFutureGovernor), emptySender: false, expectPass: false, @@ -295,7 +296,7 @@ func (s *KeeperTestSuite) TestInitializePool() { defaultPoolId, balancer.PoolParams{ SwapFee: defaultSpreadFactor, - ExitFee: sdk.NewDecWithPrec(5, 1), + ExitFee: osmomath.NewDecWithPrec(5, 1), }, defaultPoolAssets, "", @@ -401,16 +402,16 @@ func (s *KeeperTestSuite) TestSpotPriceOverflow() { panics bool }{ "uniV2marginalOverflow": { - poolLiquidity: sdk.NewCoins(sdk.NewCoin(denomA, types.MaxSpotPrice.TruncateInt().Add(sdk.OneInt())), - sdk.NewCoin(denomB, sdk.OneInt())), + poolLiquidity: sdk.NewCoins(sdk.NewCoin(denomA, types.MaxSpotPrice.TruncateInt().Add(osmomath.OneInt())), + sdk.NewCoin(denomB, osmomath.OneInt())), poolWeights: []int64{1, 1}, quoteAssetDenom: denomA, baseAssetDenom: denomB, overflows: true, }, "uniV2 internal error": { - poolLiquidity: sdk.NewCoins(sdk.NewCoin(denomA, sdk.NewDec(2).Power(250).TruncateInt()), - sdk.NewCoin(denomB, sdk.OneInt())), + poolLiquidity: sdk.NewCoins(sdk.NewCoin(denomA, osmomath.NewDec(2).Power(250).TruncateInt()), + sdk.NewCoin(denomB, osmomath.OneInt())), poolWeights: []int64{1, 1 << 19}, quoteAssetDenom: denomB, baseAssetDenom: denomA, @@ -423,7 +424,7 @@ func (s *KeeperTestSuite) TestSpotPriceOverflow() { poolId := s.PrepareBalancerPoolWithCoinsAndWeights(tc.poolLiquidity, tc.poolWeights) pool, err := s.App.GAMMKeeper.GetPoolAndPoke(s.Ctx, poolId) s.Require().NoError(err) - var poolSpotPrice sdk.Dec + var poolSpotPrice osmomath.Dec var poolErr error osmoassert.ConditionalPanic(s.T(), tc.panics, func() { poolSpotPrice, poolErr = pool.SpotPrice(s.Ctx, tc.baseAssetDenom, tc.quoteAssetDenom) @@ -437,7 +438,7 @@ func (s *KeeperTestSuite) TestSpotPriceOverflow() { } else if tc.panics { s.Require().ErrorIs(keeperErr, types.ErrSpotPriceInternal) s.Require().Error(keeperErr) - s.Require().Equal(sdk.Dec{}, keeperSpotPrice) + s.Require().Equal(osmomath.Dec{}, keeperSpotPrice) } else { s.Require().NoError(poolErr) s.Require().NoError(keeperErr) @@ -449,11 +450,11 @@ func (s *KeeperTestSuite) TestSpotPriceOverflow() { // TODO: Add more edge cases around TokenInMaxs not containing every token in pool. func (s *KeeperTestSuite) TestJoinPoolNoSwap() { - fiveKFooAndBar := sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(5000)), sdk.NewCoin("foo", sdk.NewInt(5000))) + fiveKFooAndBar := sdk.NewCoins(sdk.NewCoin("bar", osmomath.NewInt(5000)), sdk.NewCoin("foo", osmomath.NewInt(5000))) tests := []struct { name string txSender sdk.AccAddress - sharesRequested sdk.Int + sharesRequested osmomath.Int tokenInMaxs sdk.Coins expectPass bool }{ @@ -467,23 +468,23 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { { name: "join no swap with zero shares requested", txSender: s.TestAccs[1], - sharesRequested: sdk.NewInt(0), + sharesRequested: osmomath.NewInt(0), tokenInMaxs: sdk.Coins{}, expectPass: false, }, { name: "join no swap with negative shares requested", txSender: s.TestAccs[1], - sharesRequested: sdk.NewInt(-1), + sharesRequested: osmomath.NewInt(-1), tokenInMaxs: sdk.Coins{}, expectPass: false, }, { name: "join no swap with insufficient funds", txSender: s.TestAccs[1], - sharesRequested: sdk.NewInt(-1), + sharesRequested: osmomath.NewInt(-1), tokenInMaxs: sdk.Coins{ - sdk.NewCoin("bar", sdk.NewInt(4999)), sdk.NewCoin("foo", sdk.NewInt(4999)), + sdk.NewCoin("bar", osmomath.NewInt(4999)), sdk.NewCoin("foo", osmomath.NewInt(4999)), }, expectPass: false, }, @@ -501,7 +502,7 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { txSender: s.TestAccs[1], sharesRequested: types.OneShare.MulRaw(50), tokenInMaxs: sdk.Coins{ - fiveKFooAndBar[0], fiveKFooAndBar[1], sdk.NewCoin("baz", sdk.NewInt(5000)), + fiveKFooAndBar[0], fiveKFooAndBar[1], sdk.NewCoin("baz", osmomath.NewInt(5000)), }, expectPass: false, }, @@ -530,7 +531,7 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { // Create the pool at first msg := balancer.NewMsgCreateBalancerPool(testAccount, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), + SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: defaultZeroExitFee, }, defaultPoolAssets, defaultFutureGovernor) poolId, err := poolmanagerKeeper.CreatePool(s.Ctx, msg) @@ -565,11 +566,11 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { } func (s *KeeperTestSuite) TestExitPool() { - fiveKFooAndBar := sdk.NewCoins(sdk.NewCoin("bar", sdk.NewInt(5000)), sdk.NewCoin("foo", sdk.NewInt(5000))) + fiveKFooAndBar := sdk.NewCoins(sdk.NewCoin("bar", osmomath.NewInt(5000)), sdk.NewCoin("foo", osmomath.NewInt(5000))) tests := []struct { name string txSender sdk.AccAddress - sharesIn sdk.Int + sharesIn osmomath.Int tokenOutMins sdk.Coins emptySender bool expectPass bool @@ -593,7 +594,7 @@ func (s *KeeperTestSuite) TestExitPool() { { name: "attempt exit pool requesting 0 share amount", txSender: s.TestAccs[0], - sharesIn: sdk.NewInt(0), + sharesIn: osmomath.NewInt(0), tokenOutMins: sdk.Coins{}, emptySender: false, expectPass: false, @@ -601,7 +602,7 @@ func (s *KeeperTestSuite) TestExitPool() { { name: "attempt exit pool requesting negative share amount", txSender: s.TestAccs[0], - sharesIn: sdk.NewInt(-1), + sharesIn: osmomath.NewInt(-1), tokenOutMins: sdk.Coins{}, emptySender: false, expectPass: false, @@ -611,7 +612,7 @@ func (s *KeeperTestSuite) TestExitPool() { txSender: s.TestAccs[0], sharesIn: types.OneShare.MulRaw(50), tokenOutMins: sdk.Coins{ - sdk.NewCoin("foo", sdk.NewInt(5001)), + sdk.NewCoin("foo", osmomath.NewInt(5001)), }, emptySender: false, expectPass: false, @@ -642,8 +643,8 @@ func (s *KeeperTestSuite) TestExitPool() { // Create the pool at first msg := balancer.NewMsgCreateBalancerPool(test.txSender, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) poolId, err := poolmanagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) @@ -685,21 +686,21 @@ func (s *KeeperTestSuite) TestJoinPoolExitPool_InverseRelationship() { testCases := []struct { name string pool balancer.MsgCreateBalancerPool - joinPoolShareAmt sdk.Int + joinPoolShareAmt osmomath.Int }{ { name: "pool with same token ratio", pool: balancer.NewMsgCreateBalancerPool(nil, balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }, []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }, }, defaultFutureGovernor), joinPoolShareAmt: types.OneShare.MulRaw(50), @@ -707,16 +708,16 @@ func (s *KeeperTestSuite) TestJoinPoolExitPool_InverseRelationship() { { name: "pool with different token ratio", pool: balancer.NewMsgCreateBalancerPool(nil, balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }, []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(7000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(7000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("bar", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("bar", osmomath.NewInt(10000)), }, }, defaultFutureGovernor), joinPoolShareAmt: types.OneShare.MulRaw(50), @@ -761,7 +762,7 @@ func (s *KeeperTestSuite) TestJoinPoolExitPool_InverseRelationship() { // due to rounding, `balanceBeforeJoin` and `balanceAfterExit` have neglectable difference // coming from rounding in exitPool.Here we test if the difference is within rounding tolerance range - roundingToleranceCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1)), sdk.NewCoin("bar", sdk.NewInt(1))) + roundingToleranceCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1)), sdk.NewCoin("bar", osmomath.NewInt(1))) s.Require().True(deltaBalance.AmountOf("foo").LTE(roundingToleranceCoins.AmountOf("foo"))) s.Require().True(deltaBalance.AmountOf("bar").LTE(roundingToleranceCoins.AmountOf("bar"))) }) @@ -790,8 +791,8 @@ func (s *KeeperTestSuite) TestActiveBalancerPool() { // Create the pool at first poolId := s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ - SwapFee: sdk.NewDec(0), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDec(0), + ExitFee: osmomath.NewDec(0), }) ctx = ctx.WithBlockTime(tc.blockTime) @@ -806,25 +807,25 @@ func (s *KeeperTestSuite) TestActiveBalancerPool() { s.AssertEventEmitted(ctx, types.TypeEvtPoolExited, 1) - foocoin := sdk.NewCoin("foo", sdk.NewInt(10)) + foocoin := sdk.NewCoin("foo", osmomath.NewInt(10)) foocoins := sdk.Coins{foocoin} if tc.expectPass { - _, err = gammKeeper.JoinSwapExactAmountIn(ctx, testAccount, poolId, foocoins, sdk.ZeroInt()) + _, err = gammKeeper.JoinSwapExactAmountIn(ctx, testAccount, poolId, foocoins, osmomath.ZeroInt()) s.Require().NoError(err) - _, err = gammKeeper.JoinSwapShareAmountOut(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), sdk.NewInt(1000000000000000000)) + _, err = gammKeeper.JoinSwapShareAmountOut(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), osmomath.NewInt(1000000000000000000)) s.Require().NoError(err) - _, err = gammKeeper.ExitSwapShareAmountIn(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), sdk.ZeroInt()) + _, err = gammKeeper.ExitSwapShareAmountIn(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), osmomath.ZeroInt()) s.Require().NoError(err) - _, err = gammKeeper.ExitSwapExactAmountOut(ctx, testAccount, poolId, foocoin, sdk.NewInt(1000000000000000000)) + _, err = gammKeeper.ExitSwapExactAmountOut(ctx, testAccount, poolId, foocoin, osmomath.NewInt(1000000000000000000)) s.Require().NoError(err) } else { s.Require().Error(err) - _, err = gammKeeper.JoinSwapShareAmountOut(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), sdk.NewInt(1000000000000000000)) + _, err = gammKeeper.JoinSwapShareAmountOut(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), osmomath.NewInt(1000000000000000000)) s.Require().Error(err) - _, err = gammKeeper.ExitSwapShareAmountIn(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), sdk.ZeroInt()) + _, err = gammKeeper.ExitSwapShareAmountIn(ctx, testAccount, poolId, "foo", types.OneShare.MulRaw(10), osmomath.ZeroInt()) s.Require().Error(err) - _, err = gammKeeper.ExitSwapExactAmountOut(ctx, testAccount, poolId, foocoin, sdk.NewInt(1000000000000000000)) + _, err = gammKeeper.ExitSwapExactAmountOut(ctx, testAccount, poolId, foocoin, osmomath.NewInt(1000000000000000000)) s.Require().Error(err) } }) @@ -834,21 +835,21 @@ func (s *KeeperTestSuite) TestActiveBalancerPool() { func (s *KeeperTestSuite) TestJoinSwapExactAmountInConsistency() { testCases := []struct { name string - poolSpreadFactor sdk.Dec - poolExitFee sdk.Dec + poolSpreadFactor osmomath.Dec + poolExitFee osmomath.Dec tokensIn sdk.Coins - shareOutMinAmount sdk.Int - expectedSharesOut sdk.Int - tokenOutMinAmount sdk.Int + shareOutMinAmount osmomath.Int + expectedSharesOut osmomath.Int + tokenOutMinAmount osmomath.Int }{ { name: "single coin with zero swap and exit fees", - poolSpreadFactor: sdk.ZeroDec(), - poolExitFee: sdk.ZeroDec(), - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000))), - shareOutMinAmount: sdk.ZeroInt(), - expectedSharesOut: sdk.NewInt(6265857020099440400), - tokenOutMinAmount: sdk.ZeroInt(), + poolSpreadFactor: osmomath.ZeroDec(), + poolExitFee: osmomath.ZeroDec(), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1000000))), + shareOutMinAmount: osmomath.ZeroInt(), + expectedSharesOut: osmomath.NewInt(6265857020099440400), + tokenOutMinAmount: osmomath.ZeroInt(), }, // TODO: Uncomment or remove this following test case once the referenced // issue is resolved. @@ -856,12 +857,12 @@ func (s *KeeperTestSuite) TestJoinSwapExactAmountInConsistency() { // Ref: https://github.com/osmosis-labs/osmosis/issues/1196 // { // name: "single coin with positive spread factor and zero exit fee", - // poolSpreadFactor: sdk.NewDecWithPrec(1, 2), - // poolExitFee: sdk.ZeroDec(), - // tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1000000))), - // shareOutMinAmount: sdk.ZeroInt(), - // expectedSharesOut: sdk.NewInt(6226484702880621000), - // tokenOutMinAmount: sdk.ZeroInt(), + // poolSpreadFactor: osmomath.NewDecWithPrec(1, 2), + // poolExitFee: osmomath.ZeroDec(), + // tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1000000))), + // shareOutMinAmount: osmomath.ZeroInt(), + // expectedSharesOut: osmomath.NewInt(6226484702880621000), + // tokenOutMinAmount: osmomath.ZeroInt(), // }, } @@ -878,12 +879,12 @@ func (s *KeeperTestSuite) TestJoinSwapExactAmountInConsistency() { defaultAcctFunds, []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(5000000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("bar", sdk.NewInt(5000000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("bar", osmomath.NewInt(5000000)), }, }, balancer.PoolParams{ @@ -907,13 +908,13 @@ func (s *KeeperTestSuite) TestJoinSwapExactAmountInConsistency() { s.Require().NoError(err) // require swapTokenOutAmt <= (tokenInAmt * (1 - tc.poolSpreadFactor)) - oneMinusSwapFee := sdk.OneDec().Sub(tc.poolSpreadFactor) + oneMinusSwapFee := osmomath.OneDec().Sub(tc.poolSpreadFactor) spreadFactorAdjustedAmount := oneMinusSwapFee.MulInt(tc.tokensIn[0].Amount).RoundInt() s.Require().True(tokenOutAmt.LTE(spreadFactorAdjustedAmount)) // require swapTokenOutAmt + 10 > input s.Require().True( - spreadFactorAdjustedAmount.Sub(tokenOutAmt).LTE(sdk.NewInt(10)), + spreadFactorAdjustedAmount.Sub(tokenOutAmt).LTE(osmomath.NewInt(10)), "expected out amount %s, actual out amount %s", spreadFactorAdjustedAmount, tokenOutAmt, ) diff --git a/x/gamm/keeper/pool_test.go b/x/gamm/keeper/pool_test.go index d3493a24d03..16fa5f8f8f2 100644 --- a/x/gamm/keeper/pool_test.go +++ b/x/gamm/keeper/pool_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/golang/mock/gomock" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/mocks" "github.com/osmosis-labs/osmosis/v19/x/gamm/keeper" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -17,8 +18,8 @@ import ( var ( defaultPoolParamsStableSwap = stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } defaultPoolId = uint64(1) ) @@ -41,10 +42,10 @@ var ( // s.Ctx, // acc, // sdk.NewCoins( -// sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), -// sdk.NewCoin("foo", sdk.NewInt(1000)), -// sdk.NewCoin("bar", sdk.NewInt(1000)), -// sdk.NewCoin("baz", sdk.NewInt(1000)), +// sdk.NewCoin("uosmo", osmomath.NewInt(1000000000)), +// sdk.NewCoin("foo", osmomath.NewInt(1000)), +// sdk.NewCoin("bar", osmomath.NewInt(1000)), +// sdk.NewCoin("baz", osmomath.NewInt(1000)), // ), // ) // if err != nil { @@ -54,25 +55,25 @@ var ( // poolId, err := s.App.GAMMKeeper.CreateBalancerPool(s.Ctx, acc1, defaultPoolParams, []types.PoolAsset{ // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("foo", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("foo", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("bar", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("bar", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("baz", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("baz", osmomath.NewInt(1000)), // }, // }, "") // s.NoError(err) // for _, acc := range []sdk.AccAddress{acc2, acc3} { // err = s.App.GAMMKeeper.JoinPool(s.Ctx, acc, poolId, types.OneShare.MulRaw(100), sdk.NewCoins( -// sdk.NewCoin("foo", sdk.NewInt(1000)), -// sdk.NewCoin("bar", sdk.NewInt(1000)), -// sdk.NewCoin("baz", sdk.NewInt(1000)), +// sdk.NewCoin("foo", osmomath.NewInt(1000)), +// sdk.NewCoin("bar", osmomath.NewInt(1000)), +// sdk.NewCoin("baz", osmomath.NewInt(1000)), // )) // s.NoError(err) // } @@ -80,7 +81,7 @@ var ( // pool, err := s.App.GAMMKeeper.GetPool(s.Ctx, poolId) // s.NoError(err) // denom := pool.GetTotalShares().Denom -// totalAmount := sdk.ZeroInt() +// totalAmount := osmomath.ZeroInt() // for _, acc := range s.TestAccs { // coin := s.App.BankKeeper.GetBalance(s.Ctx, acc, denom) // s.True(coin.Amount.Equal(types.OneShare.MulRaw(100))) @@ -93,7 +94,7 @@ var ( // for _, acc := range s.TestAccs { // for _, denom := range []string{"foo", "bar", "baz"} { // amt := s.App.BankKeeper.GetBalance(s.Ctx, acc, denom) -// s.True(amt.Amount.Equal(sdk.NewInt(1000)), +// s.True(amt.Amount.Equal(osmomath.NewInt(1000)), // "Expected equal %s: %d, %d", amt.Denom, amt.Amount.Int64(), 1000) // } // } @@ -108,7 +109,7 @@ var ( // for _, acc := range s.TestAccs { // coins := make(sdk.Coins, 3) // for i := range coins { -// amount := sdk.NewInt(rand.Int63n(1000)) +// amount := osmomath.NewInt(rand.Int63n(1000)) // // give large amount of coins to the pool creator // if i == 0 { // amount = amount.MulRaw(10000) @@ -116,7 +117,7 @@ var ( // coins[i] = sdk.Coin{denoms[i], amount} // } // coinOf[acc.String()] = coins -// coins = append(coins, sdk.NewCoin("uosmo", sdk.NewInt(1000000000))) +// coins = append(coins, sdk.NewCoin("uosmo", osmomath.NewInt(1000000000))) // s.FundAcc( // s.App.BankKeeper, @@ -147,7 +148,7 @@ var ( // for _, coin := range coinOf[acc.String()] { // amt := s.App.BankKeeper.GetBalance(s.Ctx, acc, coin.Denom) // // the refund could have rounding error -// s.True(amt.Amount.Sub(coin.Amount).Abs().LTE(sdk.NewInt(2)), +// s.True(amt.Amount.Sub(coin.Amount).Abs().LTE(osmomath.NewInt(2)), // "Expected equal %s: %d, %d", amt.Denom, amt.Amount.Int64(), coin.Amount.Int64()) // } // } @@ -160,10 +161,10 @@ var ( // s.Ctx, // acc1, // sdk.NewCoins( -// sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), -// sdk.NewCoin("foo", sdk.NewInt(1000)), -// sdk.NewCoin("bar", sdk.NewInt(1000)), -// sdk.NewCoin("baz", sdk.NewInt(1000)), +// sdk.NewCoin("uosmo", osmomath.NewInt(1000000000)), +// sdk.NewCoin("foo", osmomath.NewInt(1000)), +// sdk.NewCoin("bar", osmomath.NewInt(1000)), +// sdk.NewCoin("baz", osmomath.NewInt(1000)), // ), // ) // if err != nil { @@ -172,16 +173,16 @@ var ( // poolId, err := s.App.GAMMKeeper.CreateBalancerPool(s.Ctx, acc1, defaultPoolParams, []types.PoolAsset{ // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("foo", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("foo", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("bar", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("bar", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("baz", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("baz", osmomath.NewInt(1000)), // }, // }, "") // s.NoError(err) @@ -189,7 +190,7 @@ var ( // err = s.App.GAMMKeeper.CleanupBalancerPool(s.Ctx, []uint64{poolId}, []string{}) // s.NoError(err) -// _, _, err = s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, acc1, poolId, sdk.NewCoin("foo", sdk.NewInt(1)), "bar", sdk.NewInt(1)) +// _, _, err = s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, acc1, poolId, sdk.NewCoin("foo", osmomath.NewInt(1)), "bar", osmomath.NewInt(1)) // s.Error(err) // } @@ -200,10 +201,10 @@ var ( // s.Ctx, // acc1, // sdk.NewCoins( -// sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), -// sdk.NewCoin("foo", sdk.NewInt(1000)), -// sdk.NewCoin("bar", sdk.NewInt(1000)), -// sdk.NewCoin("baz", sdk.NewInt(1000)), +// sdk.NewCoin("uosmo", osmomath.NewInt(1000000000)), +// sdk.NewCoin("foo", osmomath.NewInt(1000)), +// sdk.NewCoin("bar", osmomath.NewInt(1000)), +// sdk.NewCoin("baz", osmomath.NewInt(1000)), // ), // ) // if err != nil { @@ -212,16 +213,16 @@ var ( // poolId, err := s.App.GAMMKeeper.CreateBalancerPool(s.Ctx, acc1, defaultPoolParams, []types.PoolAsset{ // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("foo", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("foo", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("bar", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("bar", osmomath.NewInt(1000)), // }, // { -// Weight: sdk.NewInt(100), -// Token: sdk.NewCoin("baz", sdk.NewInt(1000)), +// Weight: osmomath.NewInt(100), +// Token: sdk.NewCoin("baz", osmomath.NewInt(1000)), // }, // }, "") // s.NoError(err) @@ -239,8 +240,8 @@ var ( // for _, coin := range []string{"foo", "bar", "baz"} { // amt := s.App.BankKeeper.GetBalance(s.Ctx, acc1, coin) // // the refund could have rounding error -// s.True(amt.Amount.Equal(sdk.NewInt(1000)) || amt.Amount.Equal(sdk.NewInt(1000).SubRaw(1)), -// "Expected equal %s: %d, %d", amt.Denom, amt.Amount.Int64(), sdk.NewInt(1000).Int64()) +// s.True(amt.Amount.Equal(osmomath.NewInt(1000)) || amt.Amount.Equal(osmomath.NewInt(1000).SubRaw(1)), +// "Expected equal %s: %d, %d", amt.Denom, amt.Amount.Int64(), osmomath.NewInt(1000).Int64()) // } // } @@ -259,11 +260,11 @@ func (s *KeeperTestSuite) TestGetPoolAndPoke() { startPoolWeightAssets := []balancer.PoolAsset{ { - Weight: defaultPoolAssets[0].Weight.Quo(sdk.NewInt(2)), + Weight: defaultPoolAssets[0].Weight.Quo(osmomath.NewInt(2)), Token: defaultPoolAssets[0].Token, }, { - Weight: defaultPoolAssets[1].Weight.Mul(sdk.NewInt(3)), + Weight: defaultPoolAssets[1].Weight.Mul(osmomath.NewInt(3)), Token: defaultPoolAssets[1].Token, }, } @@ -598,7 +599,7 @@ func (s *KeeperTestSuite) TestSetStableSwapScalingFactorController() { func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { tests := map[string]struct { poolId uint64 - shareOutAmount sdk.Int + shareOutAmount osmomath.Int expectedLpLiquidity sdk.Coins err error }{ @@ -607,7 +608,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { SwapFee: defaultSpreadFactor, ExitFee: defaultZeroExitFee, }), - shareOutAmount: sdk.ZeroInt(), + shareOutAmount: osmomath.ZeroInt(), err: types.ErrInvalidMathApprox, }, @@ -616,7 +617,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { SwapFee: defaultSpreadFactor, ExitFee: defaultZeroExitFee, }), - shareOutAmount: sdk.NewInt(-1), + shareOutAmount: osmomath.NewInt(-1), err: types.ErrInvalidMathApprox, }, @@ -632,7 +633,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { // Amount of tokens in poolAssets: // - defaultPoolAssets[1].Token.Amount: 10000 // - defaultPoolAssets[0].Token.Amount: 10000 - shareOutAmount: sdk.NewInt(8_000_000_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_000_000_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultPoolAssets[1].Token.Denom, 800), sdk.NewInt64Coin(defaultPoolAssets[0].Token.Denom, 800), @@ -651,7 +652,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { // Amount of tokens in poolAssets: // - defaultPoolAssets[1].Token.Amount: 10000 // - defaultPoolAssets[0].Token.Amount: 10000 - shareOutAmount: sdk.NewInt(8_888_000_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_888_000_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultPoolAssets[1].Token.Denom, 889), sdk.NewInt64Coin(defaultPoolAssets[0].Token.Denom, 889), @@ -668,7 +669,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.ZeroInt(), + shareOutAmount: osmomath.ZeroInt(), err: types.ErrInvalidMathApprox, }, @@ -682,7 +683,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount.QuoRaw(2)), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.ZeroInt(), + shareOutAmount: osmomath.ZeroInt(), err: types.ErrInvalidMathApprox, }, @@ -696,7 +697,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.NewInt(-1), + shareOutAmount: osmomath.NewInt(-1), err: types.ErrInvalidMathApprox, }, @@ -710,7 +711,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount.QuoRaw(2)), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.NewInt(-1), + shareOutAmount: osmomath.NewInt(-1), err: types.ErrInvalidMathApprox, }, @@ -724,7 +725,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.NewInt(8_000_000_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_000_000_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultAcctFunds[1].Denom, 800000), sdk.NewInt64Coin(defaultAcctFunds[2].Denom, 800000), @@ -747,7 +748,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { // Amount of tokens in liquidity: // - defaultAcctFunds[1].Amount: 10000000 // - defaultAcctFunds[2].Amount: 10000000 - shareOutAmount: sdk.NewInt(8_888_888_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_888_888_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultAcctFunds[1].Denom, 888889), sdk.NewInt64Coin(defaultAcctFunds[2].Denom, 888889), @@ -764,7 +765,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { sdk.NewCoins(sdk.NewCoin(defaultAcctFunds[1].Denom, defaultAcctFunds[1].Amount.QuoRaw(2)), sdk.NewCoin(defaultAcctFunds[2].Denom, defaultAcctFunds[2].Amount)), []uint64{1, 1}, ), - shareOutAmount: sdk.NewInt(8_000_000_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_000_000_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultAcctFunds[1].Denom, 400000), sdk.NewInt64Coin(defaultAcctFunds[2].Denom, 800000), @@ -787,7 +788,7 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { // Amount of tokens in liquidity: // - defaultAcctFunds[1].Amount: 10000000 // - defaultAcctFunds[2].Amount: 5000000 - shareOutAmount: sdk.NewInt(8_888_888_000_000_000_000), + shareOutAmount: osmomath.NewInt(8_888_888_000_000_000_000), expectedLpLiquidity: sdk.Coins{ sdk.NewInt64Coin(defaultAcctFunds[1].Denom, 444445), sdk.NewInt64Coin(defaultAcctFunds[2].Denom, 888889), @@ -818,19 +819,19 @@ func (suite *KeeperTestSuite) TestGetMaximalNoSwapLPAmount() { func (suite *KeeperTestSuite) TestGetTotalPoolShares() { tests := map[string]struct { - sharesJoined sdk.Int + sharesJoined osmomath.Int poolNotCreated bool expectedError error }{ "happy path: default balancer pool": { - sharesJoined: sdk.ZeroInt(), + sharesJoined: osmomath.ZeroInt(), }, "Multiple LPs with shares exist": { sharesJoined: types.OneShare, }, "error: pool does not exist": { - sharesJoined: sdk.ZeroInt(), + sharesJoined: osmomath.ZeroInt(), poolNotCreated: true, expectedError: types.PoolDoesNotExistError{PoolId: uint64(0)}, }, @@ -850,8 +851,8 @@ func (suite *KeeperTestSuite) TestGetTotalPoolShares() { balancerPoolId = suite.PrepareBalancerPool() } - sharesJoined := sdk.ZeroInt() - if !tc.sharesJoined.Equal(sdk.ZeroInt()) { + sharesJoined := osmomath.ZeroInt() + if !tc.sharesJoined.Equal(osmomath.ZeroInt()) { suite.FundAcc(testAccount, defaultAcctFunds) _, sharesActualJoined, err := gammKeeper.JoinPoolNoSwap(suite.Ctx, testAccount, balancerPoolId, tc.sharesJoined, sdk.Coins{}) suite.Require().NoError(err) diff --git a/x/gamm/keeper/share.go b/x/gamm/keeper/share.go index 70f5cd21b90..59f886cf60a 100644 --- a/x/gamm/keeper/share.go +++ b/x/gamm/keeper/share.go @@ -3,12 +3,13 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/events" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) -func (k Keeper) applyJoinPoolStateChange(ctx sdk.Context, pool poolmanagertypes.PoolI, joiner sdk.AccAddress, numShares sdk.Int, joinCoins sdk.Coins) error { +func (k Keeper) applyJoinPoolStateChange(ctx sdk.Context, pool poolmanagertypes.PoolI, joiner sdk.AccAddress, numShares osmomath.Int, joinCoins sdk.Coins) error { err := k.bankKeeper.SendCoins(ctx, joiner, pool.GetAddress(), joinCoins) if err != nil { return err @@ -30,7 +31,7 @@ func (k Keeper) applyJoinPoolStateChange(ctx sdk.Context, pool poolmanagertypes. return nil } -func (k Keeper) applyExitPoolStateChange(ctx sdk.Context, pool poolmanagertypes.PoolI, exiter sdk.AccAddress, numShares sdk.Int, exitCoins sdk.Coins) error { +func (k Keeper) applyExitPoolStateChange(ctx sdk.Context, pool poolmanagertypes.PoolI, exiter sdk.AccAddress, numShares osmomath.Int, exitCoins sdk.Coins) error { err := k.bankKeeper.SendCoins(ctx, pool.GetAddress(), exiter, exitCoins) if err != nil { return err @@ -55,7 +56,7 @@ func (k Keeper) applyExitPoolStateChange(ctx sdk.Context, pool poolmanagertypes. // MintPoolShareToAccount attempts to mint shares of a GAMM denomination to the // specified address returning an error upon failure. Shares are minted using // the x/gamm module account. -func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool poolmanagertypes.PoolI, addr sdk.AccAddress, amount sdk.Int) error { +func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool poolmanagertypes.PoolI, addr sdk.AccAddress, amount osmomath.Int) error { amt := sdk.NewCoins(sdk.NewCoin(types.GetPoolShareDenom(pool.GetId()), amount)) err := k.bankKeeper.MintCoins(ctx, types.ModuleName, amt) @@ -72,7 +73,7 @@ func (k Keeper) MintPoolShareToAccount(ctx sdk.Context, pool poolmanagertypes.Po } // BurnPoolShareFromAccount burns `amount` of the given pools shares held by `addr`. -func (k Keeper) BurnPoolShareFromAccount(ctx sdk.Context, pool poolmanagertypes.PoolI, addr sdk.AccAddress, amount sdk.Int) error { +func (k Keeper) BurnPoolShareFromAccount(ctx sdk.Context, pool poolmanagertypes.PoolI, addr sdk.AccAddress, amount osmomath.Int) error { amt := sdk.Coins{ sdk.NewCoin(types.GetPoolShareDenom(pool.GetId()), amount), } diff --git a/x/gamm/keeper/swap.go b/x/gamm/keeper/swap.go index 2c0d04ffede..a945ae82195 100644 --- a/x/gamm/keeper/swap.go +++ b/x/gamm/keeper/swap.go @@ -7,6 +7,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/events" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -24,51 +25,51 @@ func (k Keeper) SwapExactAmountIn( pool poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - spreadFactor sdk.Dec, -) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int, + spreadFactor osmomath.Dec, +) (tokenOutAmount osmomath.Int, err error) { if tokenIn.Denom == tokenOutDenom { - return sdk.Int{}, errors.New("cannot trade same denomination in and out") + return osmomath.Int{}, errors.New("cannot trade same denomination in and out") } poolSpreadFactor := pool.GetSpreadFactor(ctx) if spreadFactor.LT(poolSpreadFactor.QuoInt64(2)) { - return sdk.Int{}, fmt.Errorf("given spread factor (%s) must be greater than or equal to half of the pool's spread factor (%s)", spreadFactor, poolSpreadFactor) + return osmomath.Int{}, fmt.Errorf("given spread factor (%s) must be greater than or equal to half of the pool's spread factor (%s)", spreadFactor, poolSpreadFactor) } tokensIn := sdk.Coins{tokenIn} defer func() { if r := recover(); r != nil { - tokenOutAmount = sdk.Int{} + tokenOutAmount = osmomath.Int{} err = fmt.Errorf("function swapExactAmountIn failed due to internal reason: %v", r) } }() cfmmPool, err := asCFMMPool(pool) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Executes the swap in the pool and stores the output. Updates pool assets but // does not actually transfer any tokens to or from the pool. tokenOutCoin, err := cfmmPool.SwapOutAmtGivenIn(ctx, tokensIn, tokenOutDenom, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmount = tokenOutCoin.Amount if !tokenOutAmount.IsPositive() { - return sdk.Int{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "token amount must be positive") + return osmomath.Int{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "token amount must be positive") } if tokenOutAmount.LT(tokenOutMinAmount) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrLimitMinAmount, "%s token is lesser than min amount", tokenOutDenom) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrLimitMinAmount, "%s token is lesser than min amount", tokenOutDenom) } // Settles balances between the tx sender and the pool to match the swap that was executed earlier. // Also emits swap event and updates related liquidity metrics if err := k.updatePoolForSwap(ctx, pool, sender, tokenIn, tokenOutCoin); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return tokenOutAmount, nil @@ -83,53 +84,53 @@ func (k Keeper) SwapExactAmountOut( sender sdk.AccAddress, pool poolmanagertypes.PoolI, tokenInDenom string, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, - spreadFactor sdk.Dec, -) (tokenInAmount sdk.Int, err error) { + spreadFactor osmomath.Dec, +) (tokenInAmount osmomath.Int, err error) { if tokenInDenom == tokenOut.Denom { - return sdk.Int{}, errors.New("cannot trade same denomination in and out") + return osmomath.Int{}, errors.New("cannot trade same denomination in and out") } defer func() { if r := recover(); r != nil { - tokenInAmount = sdk.Int{} + tokenInAmount = osmomath.Int{} err = fmt.Errorf("function swapExactAmountOut failed due to internal reason: %v", r) } }() liquidity, err := k.GetTotalPoolLiquidity(ctx, pool.GetId()) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } poolOutBal := liquidity.AmountOf(tokenOut.Denom) if tokenOut.Amount.GTE(poolOutBal) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrTooManyTokensOut, + return osmomath.Int{}, errorsmod.Wrapf(types.ErrTooManyTokensOut, "can't get more tokens out than there are tokens in the pool") } cfmmPool, err := asCFMMPool(pool) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenIn, err := cfmmPool.SwapInAmtGivenOut(ctx, sdk.Coins{tokenOut}, tokenInDenom, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenInAmount = tokenIn.Amount - if tokenInAmount.LTE(sdk.ZeroInt()) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "token amount is zero or negative") + if tokenInAmount.LTE(osmomath.ZeroInt()) { + return osmomath.Int{}, errorsmod.Wrapf(types.ErrInvalidMathApprox, "token amount is zero or negative") } if tokenInAmount.GT(tokenInMaxAmount) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, "Swap requires %s, which is greater than the amount %s", tokenIn, tokenInMaxAmount) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, "Swap requires %s, which is greater than the amount %s", tokenIn, tokenInMaxAmount) } err = k.updatePoolForSwap(ctx, pool, sender, tokenIn, tokenOut) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return tokenInAmount, nil } @@ -141,7 +142,7 @@ func (k Keeper) CalcOutAmtGivenIn( poolI poolmanagertypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (tokenOut sdk.Coin, err error) { cfmmPool, err := asCFMMPool(poolI) if err != nil { @@ -157,7 +158,7 @@ func (k Keeper) CalcInAmtGivenOut( poolI poolmanagertypes.PoolI, tokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (tokenIn sdk.Coin, err error) { cfmmPool, err := asCFMMPool(poolI) if err != nil { diff --git a/x/gamm/keeper/swap_test.go b/x/gamm/keeper/swap_test.go index 858a2fafa95..7428a567f31 100644 --- a/x/gamm/keeper/swap_test.go +++ b/x/gamm/keeper/swap_test.go @@ -7,6 +7,7 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/tests/mocks" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -19,8 +20,8 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() { type param struct { tokenIn sdk.Coin tokenOutDenom string - tokenOutMinAmount sdk.Int - expectedTokenOut sdk.Int + tokenOutMinAmount osmomath.Int + expectedTokenOut osmomath.Int } tests := []struct { @@ -28,90 +29,90 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() { param param // Note: by default spread factor is zero in all tests // It is only set to non-zero when this overwrite is non-nil - spreadFactorOverwrite sdk.Dec + spreadFactorOverwrite osmomath.Dec // Note: this is the value by which the original spread factor is divided // by if it is non-nil. This is done to test the case where the given // parameter spread factor is reduced by more than allowed (max factor of 0.5) - spreadFactorOverwriteQuotient sdk.Dec + spreadFactorOverwriteQuotient osmomath.Dec expectPass bool }{ { name: "Proper swap", param: param{ - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenOutDenom: "bar", - tokenOutMinAmount: sdk.NewInt(1), - expectedTokenOut: sdk.NewInt(49262), + tokenOutMinAmount: osmomath.NewInt(1), + expectedTokenOut: osmomath.NewInt(49262), }, expectPass: true, }, { name: "Proper swap2", param: param{ - tokenIn: sdk.NewCoin("bar", sdk.NewInt(2451783)), + tokenIn: sdk.NewCoin("bar", osmomath.NewInt(2451783)), tokenOutDenom: "baz", - tokenOutMinAmount: sdk.NewInt(1), - expectedTokenOut: sdk.NewInt(1167843), + tokenOutMinAmount: osmomath.NewInt(1), + expectedTokenOut: osmomath.NewInt(1167843), }, expectPass: true, }, { name: "boundary valid spread factor given (= 0.5 pool spread factor)", param: param{ - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenOutDenom: "bar", - tokenOutMinAmount: sdk.NewInt(1), - expectedTokenOut: sdk.NewInt(46833), + tokenOutMinAmount: osmomath.NewInt(1), + expectedTokenOut: osmomath.NewInt(46833), }, - spreadFactorOverwrite: sdk.MustNewDecFromStr("0.1"), - spreadFactorOverwriteQuotient: sdk.MustNewDecFromStr("2"), + spreadFactorOverwrite: osmomath.MustNewDecFromStr("0.1"), + spreadFactorOverwriteQuotient: osmomath.MustNewDecFromStr("2"), expectPass: true, }, { name: "invalid spread factor given (< 0.5 pool spread factor)", param: param{ - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenOutDenom: "bar", - tokenOutMinAmount: sdk.NewInt(1), - expectedTokenOut: sdk.NewInt(49262), + tokenOutMinAmount: osmomath.NewInt(1), + expectedTokenOut: osmomath.NewInt(49262), }, - spreadFactorOverwrite: sdk.MustNewDecFromStr("0.1"), - spreadFactorOverwriteQuotient: sdk.MustNewDecFromStr("3"), + spreadFactorOverwrite: osmomath.MustNewDecFromStr("0.1"), + spreadFactorOverwriteQuotient: osmomath.MustNewDecFromStr("3"), expectPass: false, }, { name: "out is lesser than min amount", param: param{ - tokenIn: sdk.NewCoin("bar", sdk.NewInt(2451783)), + tokenIn: sdk.NewCoin("bar", osmomath.NewInt(2451783)), tokenOutDenom: "baz", - tokenOutMinAmount: sdk.NewInt(9000000), + tokenOutMinAmount: osmomath.NewInt(9000000), }, expectPass: false, }, { name: "in and out denom are same", param: param{ - tokenIn: sdk.NewCoin("bar", sdk.NewInt(2451783)), + tokenIn: sdk.NewCoin("bar", osmomath.NewInt(2451783)), tokenOutDenom: "bar", - tokenOutMinAmount: sdk.NewInt(1), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: false, }, { name: "unknown in denom", param: param{ - tokenIn: sdk.NewCoin("bara", sdk.NewInt(2451783)), + tokenIn: sdk.NewCoin("bara", osmomath.NewInt(2451783)), tokenOutDenom: "bar", - tokenOutMinAmount: sdk.NewInt(1), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: false, }, { name: "unknown out denom", param: param{ - tokenIn: sdk.NewCoin("bar", sdk.NewInt(2451783)), + tokenIn: sdk.NewCoin("bar", osmomath.NewInt(2451783)), tokenOutDenom: "bara", - tokenOutMinAmount: sdk.NewInt(1), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: false, }, @@ -122,13 +123,13 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() { s.Run(test.name, func() { // Init suite for each test. s.SetupTest() - spreadFactor := sdk.ZeroDec() + spreadFactor := osmomath.ZeroDec() if !test.spreadFactorOverwrite.IsNil() { spreadFactor = test.spreadFactorOverwrite } poolId := s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: spreadFactor, - ExitFee: sdk.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) if !test.spreadFactorOverwriteQuotient.IsNil() { spreadFactor = spreadFactor.Quo(test.spreadFactorOverwriteQuotient) @@ -160,7 +161,7 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() { } // Ratio of the token out should be between the before spot price and after spot price. - tradeAvgPrice := test.param.tokenIn.Amount.ToDec().Quo(tokenOutAmount.ToDec()) + tradeAvgPrice := test.param.tokenIn.Amount.ToLegacyDec().Quo(tokenOutAmount.ToLegacyDec()) s.True(tradeAvgPrice.GT(spotPriceBefore) && tradeAvgPrice.LT(spotPriceAfter), "test: %v", test.name) } else { _, err := keeper.SwapExactAmountIn(ctx, s.TestAccs[0], pool, test.param.tokenIn, test.param.tokenOutDenom, test.param.tokenOutMinAmount, spreadFactor) @@ -188,7 +189,7 @@ func (s *KeeperTestSuite) TestCalcOutAmtGivenIn() { name: "balancer", param: param{ poolType: "balancer", - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenOutDenom: "bar", }, expectPass: true, @@ -197,7 +198,7 @@ func (s *KeeperTestSuite) TestCalcOutAmtGivenIn() { name: "stableswap", param: param{ poolType: "stableswap", - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenOutDenom: "bar", }, expectPass: true, @@ -253,7 +254,7 @@ func (s *KeeperTestSuite) TestCalcInAmtGivenOut() { name: "balancer", param: param{ poolType: "balancer", - tokenOut: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOut: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenInDenom: "bar", }, expectPass: true, @@ -262,7 +263,7 @@ func (s *KeeperTestSuite) TestCalcInAmtGivenOut() { name: "stableswap", param: param{ poolType: "stableswap", - tokenOut: sdk.NewCoin("foo", sdk.NewInt(100000)), + tokenOut: sdk.NewCoin("foo", osmomath.NewInt(100000)), tokenInDenom: "bar", }, expectPass: true, @@ -311,9 +312,9 @@ func (s *KeeperTestSuite) TestCalcInAmtGivenOut() { func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { type param struct { tokenInDenom string - tokenInMaxAmount sdk.Int + tokenInMaxAmount osmomath.Int tokenOut sdk.Coin - expectedTokenInAmount sdk.Int + expectedTokenInAmount osmomath.Int } tests := []struct { @@ -325,9 +326,9 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "Proper swap", param: param{ tokenInDenom: "foo", - tokenInMaxAmount: sdk.NewInt(900000000), - tokenOut: sdk.NewCoin("bar", sdk.NewInt(100000)), - expectedTokenInAmount: sdk.NewInt(206165), + tokenInMaxAmount: osmomath.NewInt(900000000), + tokenOut: sdk.NewCoin("bar", osmomath.NewInt(100000)), + expectedTokenInAmount: osmomath.NewInt(206165), }, expectPass: true, }, @@ -335,9 +336,9 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "Proper swap2", param: param{ tokenInDenom: "foo", - tokenInMaxAmount: sdk.NewInt(900000000), - tokenOut: sdk.NewCoin("baz", sdk.NewInt(316721)), - expectedTokenInAmount: sdk.NewInt(1084571), + tokenInMaxAmount: osmomath.NewInt(900000000), + tokenOut: sdk.NewCoin("baz", osmomath.NewInt(316721)), + expectedTokenInAmount: osmomath.NewInt(1084571), }, expectPass: true, }, @@ -345,8 +346,8 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "in is greater than max", param: param{ tokenInDenom: "foo", - tokenInMaxAmount: sdk.NewInt(100), - tokenOut: sdk.NewCoin("baz", sdk.NewInt(316721)), + tokenInMaxAmount: osmomath.NewInt(100), + tokenOut: sdk.NewCoin("baz", osmomath.NewInt(316721)), }, expectPass: false, }, @@ -354,8 +355,8 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "pool doesn't have enough token to out", param: param{ tokenInDenom: "foo", - tokenInMaxAmount: sdk.NewInt(900000000), - tokenOut: sdk.NewCoin("baz", sdk.NewInt(99316721)), + tokenInMaxAmount: osmomath.NewInt(900000000), + tokenOut: sdk.NewCoin("baz", osmomath.NewInt(99316721)), }, expectPass: false, }, @@ -363,8 +364,8 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "unknown in denom", param: param{ tokenInDenom: "fooz", - tokenInMaxAmount: sdk.NewInt(900000000), - tokenOut: sdk.NewCoin("bar", sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(900000000), + tokenOut: sdk.NewCoin("bar", osmomath.NewInt(100000)), }, expectPass: false, }, @@ -372,8 +373,8 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { name: "unknown out denom", param: param{ tokenInDenom: "foo", - tokenInMaxAmount: sdk.NewInt(900000000), - tokenOut: sdk.NewCoin("barz", sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(900000000), + tokenOut: sdk.NewCoin("barz", osmomath.NewInt(100000)), }, expectPass: false, }, @@ -412,7 +413,7 @@ func (s *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() { s.NoError(err, "test: %v", test.name) // Ratio of the token out should be between the before spot price and after spot price. - tradeAvgPrice := tokenInAmount.ToDec().Quo(test.param.tokenOut.Amount.ToDec()) + tradeAvgPrice := tokenInAmount.ToLegacyDec().Quo(test.param.tokenOut.Amount.ToLegacyDec()) s.True(tradeAvgPrice.GT(spotPriceBefore) && tradeAvgPrice.LT(spotPriceAfter), "test: %v", test.name) } else { _, err := keeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, test.param.tokenInDenom, test.param.tokenInMaxAmount, test.param.tokenOut, spreadFactor) @@ -441,8 +442,8 @@ func (s *KeeperTestSuite) TestActiveBalancerPoolSwap() { s.FundAcc(acc, defaultAcctFunds) poolId := s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ - SwapFee: sdk.NewDec(0), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDec(0), + ExitFee: osmomath.NewDec(0), }) s.Ctx = s.Ctx.WithBlockTime(tc.blockTime) @@ -450,17 +451,17 @@ func (s *KeeperTestSuite) TestActiveBalancerPoolSwap() { s.Require().NoError(err) spreadFactor := pool.GetSpreadFactor(s.Ctx) - foocoin := sdk.NewCoin("foo", sdk.NewInt(10)) + foocoin := sdk.NewCoin("foo", osmomath.NewInt(10)) if tc.expectPass { - _, err := s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, foocoin, "bar", sdk.ZeroInt(), spreadFactor) + _, err := s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, foocoin, "bar", osmomath.ZeroInt(), spreadFactor) s.Require().NoError(err) - _, err = s.App.GAMMKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, "bar", sdk.NewInt(1000000000000000000), foocoin, spreadFactor) + _, err = s.App.GAMMKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, "bar", osmomath.NewInt(1000000000000000000), foocoin, spreadFactor) s.Require().NoError(err) } else { - _, err := s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, foocoin, "bar", sdk.ZeroInt(), spreadFactor) + _, err := s.App.GAMMKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], pool, foocoin, "bar", osmomath.ZeroInt(), spreadFactor) s.Require().Error(err) - _, err = s.App.GAMMKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, "bar", sdk.NewInt(1000000000000000000), foocoin, spreadFactor) + _, err = s.App.GAMMKeeper.SwapExactAmountOut(s.Ctx, s.TestAccs[0], pool, "bar", osmomath.NewInt(1000000000000000000), foocoin, spreadFactor) s.Require().Error(err) } } @@ -476,7 +477,7 @@ func (s *KeeperTestSuite) TestActiveBalancerPoolSwap() { func (s *KeeperTestSuite) TestInactivePoolFreezeSwaps() { // Setup test s.SetupTest() - testCoin := sdk.NewCoin("foo", sdk.NewInt(10)) + testCoin := sdk.NewCoin("foo", osmomath.NewInt(10)) s.FundAcc(s.TestAccs[0], defaultAcctFunds) // Setup active pool @@ -520,7 +521,7 @@ func (s *KeeperTestSuite) TestInactivePoolFreezeSwaps() { }, }, testCoin, - sdk.ZeroInt(), + osmomath.ZeroInt(), ) _, swapOutErr := s.App.PoolManagerKeeper.RouteExactAmountOut( @@ -532,7 +533,7 @@ func (s *KeeperTestSuite) TestInactivePoolFreezeSwaps() { TokenInDenom: "bar", }, }, - sdk.NewInt(1000000000000000000), + osmomath.NewInt(1000000000000000000), testCoin, ) diff --git a/x/gamm/keeper/total_liquidity.go b/x/gamm/keeper/total_liquidity.go index a5a6c66cf73..c096ce4a632 100644 --- a/x/gamm/keeper/total_liquidity.go +++ b/x/gamm/keeper/total_liquidity.go @@ -4,6 +4,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) @@ -22,7 +23,7 @@ func (k Keeper) setTotalLiquidity(ctx sdk.Context, coins sdk.Coins) { } } -func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount sdk.Int) { +func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount osmomath.Int) { store := ctx.KVStore(k.storeKey) bz, err := amount.Marshal() if err != nil { @@ -31,14 +32,14 @@ func (k Keeper) setDenomLiquidity(ctx sdk.Context, denom string, amount sdk.Int) store.Set(types.GetDenomPrefix(denom), bz) } -func (k Keeper) GetDenomLiquidity(ctx sdk.Context, denom string) sdk.Int { +func (k Keeper) GetDenomLiquidity(ctx sdk.Context, denom string) osmomath.Int { store := ctx.KVStore(k.storeKey) bz := store.Get(types.GetDenomPrefix(denom)) if bz == nil { - return sdk.NewInt(0) + return osmomath.NewInt(0) } - var amount sdk.Int + var amount osmomath.Int if err := amount.Unmarshal(bz); err != nil { panic(err) } @@ -53,7 +54,7 @@ func (k Keeper) IterateDenomLiquidity(ctx sdk.Context, cb func(sdk.Coin) bool) { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var amount sdk.Int + var amount osmomath.Int if err := amount.Unmarshal(iterator.Value()); err != nil { panic(err) } diff --git a/x/gamm/pool-models/balancer/amm.go b/x/gamm/pool-models/balancer/amm.go index d7e08e2fdc5..b8267ba3cb5 100644 --- a/x/gamm/pool-models/balancer/amm.go +++ b/x/gamm/pool-models/balancer/amm.go @@ -56,7 +56,7 @@ func addPoolAssetWeights(base []PoolAsset, other []PoolAsset) []PoolAsset { } // assumes 0 < d < 1 -func poolAssetsMulDec(base []PoolAsset, d sdk.Dec) []PoolAsset { +func poolAssetsMulDec(base []PoolAsset, d osmomath.Dec) []PoolAsset { newWeights := make([]PoolAsset, len(base)) for i, asset := range base { // TODO: This can adversarially panic at the moment! (as can Pool.TotalWeight) @@ -71,7 +71,7 @@ func poolAssetsMulDec(base []PoolAsset, d sdk.Dec) []PoolAsset { // ValidateUserSpecifiedWeight ensures that a weight that is provided from user-input anywhere // for creating a pool obeys the expected guarantees. // Namely, that the weight is in the range [1, MaxUserSpecifiedWeight) -func ValidateUserSpecifiedWeight(weight sdk.Int) error { +func ValidateUserSpecifiedWeight(weight osmomath.Int) error { if !weight.IsPositive() { return errorsmod.Wrap(types.ErrNotPositiveWeight, weight.String()) } @@ -97,8 +97,8 @@ func solveConstantFunctionInvariant( tokenBalanceFixedAfter, tokenWeightFixed, tokenBalanceUnknownBefore, - tokenWeightUnknown sdk.Dec, -) sdk.Dec { + tokenWeightUnknown osmomath.Dec, +) osmomath.Dec { // weightRatio = (weightX/weightY) weightRatio := tokenWeightFixed.Quo(tokenWeightUnknown) @@ -107,7 +107,7 @@ func solveConstantFunctionInvariant( // amountY = balanceY * (1 - (y ^ weightRatio)) yToWeightRatio := osmomath.Pow(y, weightRatio) - paranthetical := sdk.OneDec().Sub(yToWeightRatio) + paranthetical := osmomath.OneDec().Sub(yToWeightRatio) amountY := tokenBalanceUnknownBefore.Mul(paranthetical) return amountY } @@ -119,8 +119,8 @@ func calcPoolSharesOutGivenSingleAssetIn( normalizedTokenWeightIn, poolShares, tokenAmountIn, - spreadFactor sdk.Dec, -) sdk.Dec { + spreadFactor osmomath.Dec, +) osmomath.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) @@ -135,12 +135,28 @@ func calcPoolSharesOutGivenSingleAssetIn( // The number of new shares we need to make is then `old_shares * ((k'/k) - 1)` // Whats very cool, is that this turns out to be the exact same `solveConstantFunctionInvariant` code // with the answer's sign reversed. + + if tokenAmountIn.Equal(osmomath.NewDec(100000)) { + fmt.Println("calcPoolSharesOutGivenSingleAssetIn") + fmt.Println("tokenBalanceIn", tokenBalanceIn) + fmt.Println("normalizedTokenWeightIn", normalizedTokenWeightIn) + fmt.Println("poolShares", poolShares) + fmt.Println("tokenAmountIn", tokenAmountIn) + fmt.Println("spreadFactor", spreadFactor) + } + poolAmountOut := solveConstantFunctionInvariant( tokenBalanceIn.Add(tokenAmountInAfterFee), tokenBalanceIn, normalizedTokenWeightIn, poolShares, - sdk.OneDec()).Neg() + osmomath.OneDec()).Neg() + + if tokenAmountIn.Equal(osmomath.NewDec(100000)) { + fmt.Println("poolAmountOutDec", poolAmountOut) + fmt.Println("poolAmountOutInt", poolAmountOut.TruncateInt()) + } + return poolAmountOut } @@ -186,8 +202,8 @@ func updateIntermediaryPoolAssetsLiquidity(liquidity sdk.Coins, poolAssetsByDeno // feeRatio returns the fee ratio that is defined as follows: // 1 - ((1 - normalizedTokenWeightOut) * spreadFactor) -func feeRatio(normalizedWeight, spreadFactor sdk.Dec) sdk.Dec { - return sdk.OneDec().Sub((sdk.OneDec().Sub(normalizedWeight)).Mul(spreadFactor)) +func feeRatio(normalizedWeight, spreadFactor osmomath.Dec) osmomath.Dec { + return osmomath.OneDec().Sub((osmomath.OneDec().Sub(normalizedWeight)).Mul(spreadFactor)) } // calcSingleAssetInGivenPoolSharesOut returns token amount in with fee included @@ -197,11 +213,11 @@ func calcSingleAssetInGivenPoolSharesOut( normalizedTokenWeightIn, totalPoolSharesSupply, sharesAmountOut, - spreadFactor sdk.Dec, -) sdk.Dec { + spreadFactor osmomath.Dec, +) osmomath.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() + tokenAmountIn := solveConstantFunctionInvariant(totalPoolSharesSupply.Add(sharesAmountOut), totalPoolSharesSupply, osmomath.OneDec(), tokenBalanceIn, normalizedTokenWeightIn).Neg() // deduct spread factor on the in asset tokenAmountInFeeIncluded := tokenAmountIn.Quo(feeRatio(normalizedTokenWeightIn, spreadFactor)) return tokenAmountInFeeIncluded @@ -216,17 +232,17 @@ func calcPoolSharesInGivenSingleAssetOut( totalPoolSharesSupply, tokenAmountOut, spreadFactor, - exitFee sdk.Dec, -) sdk.Dec { + exitFee osmomath.Dec, +) osmomath.Dec { tokenAmountOutFeeIncluded := tokenAmountOut.Quo(feeRatio(normalizedTokenWeightOut, spreadFactor)) // delta poolSupply is positive(total pool shares decreases) // pool weight is always 1 - sharesIn := solveConstantFunctionInvariant(tokenBalanceOut.Sub(tokenAmountOutFeeIncluded), tokenBalanceOut, normalizedTokenWeightOut, totalPoolSharesSupply, sdk.OneDec()) + sharesIn := solveConstantFunctionInvariant(tokenBalanceOut.Sub(tokenAmountOutFeeIncluded), tokenBalanceOut, normalizedTokenWeightOut, totalPoolSharesSupply, osmomath.OneDec()) // charge exit fee on the pool token side // pAi = pAiAfterExitFee/(1-exitFee) - sharesInFeeIncluded := sharesIn.Quo(sdk.OneDec().Sub(exitFee)) + sharesInFeeIncluded := sharesIn.Quo(osmomath.OneDec().Sub(exitFee)) return sharesInFeeIncluded } diff --git a/x/gamm/pool-models/balancer/amm_test.go b/x/gamm/pool-models/balancer/amm_test.go index 223b2a8bb9d..22313dce53d 100644 --- a/x/gamm/pool-models/balancer/amm_test.go +++ b/x/gamm/pool-models/balancer/amm_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/internal/test_helpers" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -25,24 +26,24 @@ func TestBalancerPoolParams(t *testing.T) { // errors or succeeds as intended. Furthermore, it checks that // NewPool panics in the error case. tests := []struct { - SpreadFactor sdk.Dec - ExitFee sdk.Dec + SpreadFactor osmomath.Dec + ExitFee osmomath.Dec shouldErr bool }{ // Should work {defaultSpreadFactor, defaultZeroExitFee, noErr}, // Can't set the spread factor as negative - {sdk.NewDecWithPrec(-1, 2), defaultZeroExitFee, wantErr}, + {osmomath.NewDecWithPrec(-1, 2), defaultZeroExitFee, wantErr}, // Can't set the spread factor as 1 - {sdk.NewDec(1), defaultZeroExitFee, wantErr}, + {osmomath.NewDec(1), defaultZeroExitFee, wantErr}, // Can't set the spread factor above 1 - {sdk.NewDecWithPrec(15, 1), defaultZeroExitFee, wantErr}, + {osmomath.NewDecWithPrec(15, 1), defaultZeroExitFee, wantErr}, // Can't set the exit fee as negative - {defaultSpreadFactor, sdk.NewDecWithPrec(-1, 2), wantErr}, + {defaultSpreadFactor, osmomath.NewDecWithPrec(-1, 2), wantErr}, // Can't set the exit fee as 1 - {defaultSpreadFactor, sdk.NewDec(1), wantErr}, + {defaultSpreadFactor, osmomath.NewDec(1), wantErr}, // Can't set the exit fee above 1 - {defaultSpreadFactor, sdk.NewDecWithPrec(15, 1), wantErr}, + {defaultSpreadFactor, osmomath.NewDecWithPrec(15, 1), wantErr}, } for i, params := range tests { @@ -71,19 +72,19 @@ func (s *KeeperTestSuite) TestEnsureDenomInPool() { }{ "all of tokensIn is in pool asset map": { poolAssets: []balancer.PoolAsset{defaultOsmoPoolAsset, defaultAtomPoolAsset}, - tokensIn: sdk.NewCoins(sdk.NewCoin("uatom", sdk.OneInt())), + tokensIn: sdk.NewCoins(sdk.NewCoin("uatom", osmomath.OneInt())), expectPass: true, expectedErr: nil, }, "one of tokensIn is in pool asset map": { poolAssets: []balancer.PoolAsset{defaultOsmoPoolAsset, defaultAtomPoolAsset}, - tokensIn: sdk.NewCoins(sdk.NewCoin("uatom", sdk.OneInt()), sdk.NewCoin("foo", sdk.OneInt())), + tokensIn: sdk.NewCoins(sdk.NewCoin("uatom", osmomath.OneInt()), sdk.NewCoin("foo", osmomath.OneInt())), expectPass: false, expectedErr: types.ErrDenomNotFoundInPool, }, "none of tokensIn is in pool asset map": { poolAssets: []balancer.PoolAsset{defaultOsmoPoolAsset, defaultAtomPoolAsset}, - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.OneInt())), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.OneInt())), expectPass: false, expectedErr: types.ErrDenomNotFoundInPool, }, diff --git a/x/gamm/pool-models/balancer/balancerPool.pb.go b/x/gamm/pool-models/balancer/balancerPool.pb.go index cde215b1858..b703a5c5d6a 100644 --- a/x/gamm/pool-models/balancer/balancerPool.pb.go +++ b/x/gamm/pool-models/balancer/balancerPool.pb.go @@ -9,9 +9,9 @@ package balancer import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types1 "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -135,12 +135,12 @@ func (m *SmoothWeightChangeParams) GetTargetPoolWeights() []PoolAsset { // governance. Instead they will be managed by the token holders of the pool. // The pool's token holders are specified in future_pool_governor. type PoolParams struct { - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee" yaml:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee" yaml:"swap_fee"` // N.B.: exit fee is disabled during pool creation in x/poolmanager. While old // 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"` - 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"` + ExitFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=cosmossdk.io/math.LegacyDec" 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"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -192,7 +192,7 @@ type PoolAsset struct { // the denomination must be unique amongst all PoolAssets for this pool. Token types1.Coin `protobuf:"bytes,1,opt,name=token,proto3" json:"token" yaml:"token"` // Weight that is not normalized. This weight must be less than 2^50 - Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight" yaml:"weight"` + Weight cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=cosmossdk.io/math.Int" json:"weight" yaml:"weight"` } func (m *PoolAsset) Reset() { *m = PoolAsset{} } @@ -255,7 +255,7 @@ type Pool struct { // They contain the pool asset and the information about the weight PoolAssets []PoolAsset `protobuf:"bytes,6,rep,name=pool_assets,json=poolAssets,proto3" json:"pool_assets" yaml:"pool_assets"` // sum of all non-normalized pool weights - TotalWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,7,opt,name=total_weight,json=totalWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_weight" yaml:"total_weight"` + TotalWeight cosmossdk_io_math.Int `protobuf:"bytes,7,opt,name=total_weight,json=totalWeight,proto3,customtype=cosmossdk.io/math.Int" json:"total_weight" yaml:"total_weight"` } func (m *Pool) Reset() { *m = Pool{} } @@ -302,62 +302,62 @@ 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, 0x8f, 0xdb, 0x44, - 0x14, 0x8f, 0x37, 0xd9, 0x4d, 0x77, 0x52, 0x8a, 0x76, 0x9a, 0x83, 0x93, 0x15, 0x99, 0xd5, 0x80, - 0x50, 0x55, 0x35, 0xb6, 0x52, 0xb8, 0xb0, 0x97, 0xaa, 0x6e, 0x0b, 0xea, 0xad, 0xb8, 0x48, 0xa5, - 0xa8, 0x92, 0x35, 0x49, 0x26, 0xb6, 0x55, 0xdb, 0x63, 0x79, 0x26, 0x69, 0xf7, 0x1b, 0xa0, 0x9e, - 0x7a, 0x2c, 0xb7, 0xde, 0xb9, 0x70, 0xe0, 0x43, 0xac, 0xe0, 0x52, 0x89, 0x0b, 0xe2, 0x60, 0xd0, - 0xee, 0x01, 0x89, 0x63, 0x3e, 0x01, 0x9a, 0x3f, 0xce, 0x9f, 0x25, 0x11, 0xad, 0x7a, 0x49, 0x66, - 0xde, 0xbc, 0xf7, 0x7b, 0xbf, 0xf7, 0xde, 0x6f, 0xc6, 0xe0, 0x73, 0xc6, 0x53, 0xc6, 0x63, 0xee, - 0x86, 0x24, 0x4d, 0xdd, 0x9c, 0xb1, 0xa4, 0x9f, 0xb2, 0x31, 0x4d, 0xb8, 0x3b, 0x24, 0x09, 0xc9, - 0x46, 0xb4, 0x58, 0x2c, 0x1e, 0x30, 0x96, 0x38, 0x79, 0xc1, 0x04, 0x83, 0x6d, 0x13, 0xe5, 0xc8, - 0x28, 0x67, 0x36, 0x18, 0x52, 0x41, 0x06, 0xdd, 0xce, 0x48, 0x99, 0x03, 0xe5, 0xe3, 0xea, 0x8d, - 0x0e, 0xe8, 0xb6, 0x43, 0x16, 0x32, 0x6d, 0x97, 0x2b, 0x63, 0x3d, 0x20, 0x69, 0x9c, 0x31, 0x57, - 0xfd, 0x1a, 0x53, 0x2f, 0x64, 0x2c, 0x4c, 0xa8, 0xab, 0x76, 0xc3, 0xe9, 0xc4, 0x1d, 0x4f, 0x0b, - 0x22, 0x62, 0x96, 0x99, 0x73, 0x74, 0xf1, 0x5c, 0xc4, 0x29, 0xe5, 0x82, 0xa4, 0x79, 0x05, 0xa0, - 0xf3, 0xba, 0x64, 0x2a, 0x22, 0xd7, 0x30, 0x53, 0x9b, 0x0b, 0xe7, 0x43, 0xc2, 0xe9, 0xe2, 0x7c, - 0xc4, 0x62, 0x93, 0x00, 0xff, 0x5a, 0x07, 0xf6, 0xc3, 0x94, 0x31, 0x11, 0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a, - 0xd5, 0x5e, 0xbd, 0x46, 0xb5, 0x5f, 0x7e, 0xee, 0xef, 0x4a, 0xa2, 0xf7, 0xe5, 0x4d, 0xe8, 0x6c, - 0xbd, 0x09, 0xde, 0xe3, 0xd3, 0xb3, 0x9e, 0xf5, 0xe6, 0xac, 0x67, 0xfd, 0x75, 0xd6, 0xb3, 0x5e, - 0x9e, 0xf7, 0x6a, 0x6f, 0xce, 0x7b, 0xb5, 0xdf, 0xcf, 0x7b, 0xb5, 0xef, 0x6e, 0xad, 0xd0, 0x32, - 0xf1, 0xfd, 0x84, 0x0c, 0x79, 0xb5, 0x71, 0x67, 0x83, 0x2f, 0xdc, 0xe7, 0xdb, 0xbf, 0xd3, 0xc3, - 0x3d, 0xf5, 0xa1, 0xf8, 0xec, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x9d, 0x13, 0x7c, 0x51, 0xd3, - 0x07, 0x00, 0x00, + // 870 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0x4d, 0x8f, 0xdb, 0x44, + 0x18, 0x8e, 0xb3, 0xd9, 0xdd, 0xee, 0x6c, 0x29, 0xda, 0x69, 0x90, 0x9c, 0x44, 0x64, 0x56, 0x03, + 0x87, 0xaa, 0xea, 0xda, 0x4a, 0xa9, 0x90, 0xd8, 0x0b, 0xc2, 0x2d, 0x45, 0x95, 0x38, 0x14, 0x17, + 0xa9, 0x14, 0x21, 0x59, 0x93, 0x64, 0x62, 0x8f, 0x6a, 0x7b, 0x22, 0xcf, 0x24, 0xed, 0xfe, 0x03, + 0xc4, 0xa9, 0xc7, 0xc2, 0xa9, 0x3f, 0x81, 0x03, 0xbf, 0x80, 0xd3, 0x0a, 0x2e, 0x3d, 0x22, 0x0e, + 0x06, 0xed, 0x1e, 0x90, 0x38, 0x46, 0xfc, 0x00, 0x34, 0x1f, 0xce, 0xc7, 0x36, 0x51, 0xab, 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3, 0xbc, 0x5b, 0xfb, 0xf6, 0xd3, 0x98, 0xc9, 0x64, 0xd2, 0xf7, + 0x06, 0x3c, 0xf3, 0x2d, 0xfe, 0x28, 0x25, 0x7d, 0x51, 0x2d, 0xfc, 0x69, 0xef, 0x13, 0xff, 0xe9, + 0xe6, 0xff, 0xdb, 0xfe, 0x8e, 0x7e, 0xf0, 0x3f, 0xfa, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x7c, 0xcf, + 0x58, 0x0b, 0x9b, 0x07, 0x00, 0x00, } func (m *SmoothWeightChangeParams) Marshal() (dAtA []byte, err error) { diff --git a/x/gamm/pool-models/balancer/constants.go b/x/gamm/pool-models/balancer/constants.go index f11f02e699a..731a085966c 100644 --- a/x/gamm/pool-models/balancer/constants.go +++ b/x/gamm/pool-models/balancer/constants.go @@ -1,7 +1,7 @@ package balancer import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) var ( @@ -11,7 +11,7 @@ var ( // The weight used in the balancer equation is then creator-specified-weight * GuaranteedWeightPrecision. // This is done so that LBP's / smooth weight changes can actually happen smoothly, // without complex precision loss / edge effects. - MaxUserSpecifiedWeight sdk.Int = sdk.NewIntFromUint64(1 << 20) + MaxUserSpecifiedWeight osmomath.Int = osmomath.NewIntFromUint64(1 << 20) // Scaling factor for every weight. The pool weight is: // weight_in_MsgCreateBalancerPool * GuaranteedWeightPrecision // diff --git a/x/gamm/pool-models/balancer/export_test.go b/x/gamm/pool-models/balancer/export_test.go index edff7d4b8fe..12308a4d7b7 100644 --- a/x/gamm/pool-models/balancer/export_test.go +++ b/x/gamm/pool-models/balancer/export_test.go @@ -1,6 +1,10 @@ package balancer -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" +) const ( ErrMsgFormatRepeatingPoolAssetsNotAllowed = formatRepeatingPoolAssetsNotAllowedErrFormat @@ -18,10 +22,10 @@ var ( EnsureDenomInPool = ensureDenomInPool ) -func (p *Pool) CalcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor sdk.Dec, tokenInPoolAsset PoolAsset, totalShares sdk.Int) (numShares sdk.Int, err error) { +func (p *Pool) CalcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor osmomath.Dec, tokenInPoolAsset PoolAsset, totalShares osmomath.Int) (numShares osmomath.Int, err error) { return p.calcSingleAssetJoin(tokenIn, spreadFactor, tokenInPoolAsset, totalShares) } -func (p *Pool) CalcJoinSingleAssetTokensIn(tokensIn sdk.Coins, totalSharesSoFar sdk.Int, poolAssetsByDenom map[string]PoolAsset, spreadFactor sdk.Dec) (sdk.Int, sdk.Coins, error) { +func (p *Pool) CalcJoinSingleAssetTokensIn(tokensIn sdk.Coins, totalSharesSoFar osmomath.Int, poolAssetsByDenom map[string]PoolAsset, spreadFactor osmomath.Dec) (osmomath.Int, sdk.Coins, error) { return p.calcJoinSingleAssetTokensIn(tokensIn, totalSharesSoFar, poolAssetsByDenom, spreadFactor) } diff --git a/x/gamm/pool-models/balancer/marshal.go b/x/gamm/pool-models/balancer/marshal.go index c847affedbf..58cb2563033 100644 --- a/x/gamm/pool-models/balancer/marshal.go +++ b/x/gamm/pool-models/balancer/marshal.go @@ -4,6 +4,8 @@ import ( "encoding/json" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) type balancerPoolPretty struct { @@ -11,7 +13,7 @@ type balancerPoolPretty struct { Id uint64 `json:"id" yaml:"id"` PoolParams PoolParams `json:"pool_params" yaml:"pool_params"` FuturePoolGovernor string `json:"future_pool_governor" yaml:"future_pool_governor"` - TotalWeight sdk.Dec `json:"total_weight" yaml:"total_weight"` + TotalWeight osmomath.Dec `json:"total_weight" yaml:"total_weight"` TotalShares sdk.Coin `json:"total_shares" yaml:"total_shares"` PoolAssets []PoolAsset `json:"pool_assets" yaml:"pool_assets"` } @@ -31,7 +33,7 @@ func (p Pool) MarshalJSON() ([]byte, error) { return nil, err } - decTotalWeight := sdk.NewDecFromInt(p.TotalWeight) + decTotalWeight := osmomath.NewDecFromInt(p.TotalWeight) return json.Marshal(balancerPoolPretty{ Address: accAddr, diff --git a/x/gamm/pool-models/balancer/marshal_test.go b/x/gamm/pool-models/balancer/marshal_test.go index 6ecdd496d4f..63decdefa0e 100644 --- a/x/gamm/pool-models/balancer/marshal_test.go +++ b/x/gamm/pool-models/balancer/marshal_test.go @@ -8,6 +8,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" sdk "github.com/cosmos/cosmos-sdk/types" @@ -18,12 +19,12 @@ func TestPoolJson(t *testing.T) { jsonAssetTest := []balancer.PoolAsset{ { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(10000)), }, } pacc, err := balancer.NewBalancerPool(poolId, balancer.PoolParams{ @@ -55,23 +56,23 @@ func TestPoolProtoMarshal(t *testing.T) { require.Equal(t, pool2.Id, uint64(10)) require.Equal(t, pool2.PoolParams.SwapFee, defaultSpreadFactor) - require.Equal(t, pool2.PoolParams.ExitFee, sdk.MustNewDecFromStr("0.025")) + require.Equal(t, pool2.PoolParams.ExitFee, osmomath.MustNewDecFromStr("0.025")) require.Equal(t, pool2.FuturePoolGovernor, "") - require.Equal(t, pool2.TotalShares, sdk.Coin{Denom: "gamm/pool/10", Amount: sdk.ZeroInt()}) + require.Equal(t, pool2.TotalShares, sdk.Coin{Denom: "gamm/pool/10", Amount: osmomath.ZeroInt()}) require.Equal(t, pool2.PoolAssets, []balancer.PoolAsset{ { Token: sdk.Coin{ Denom: "test1", - Amount: sdk.NewInt(10000), + Amount: osmomath.NewInt(10000), }, - Weight: sdk.NewInt(107374182400), + Weight: osmomath.NewInt(107374182400), }, { Token: sdk.Coin{ Denom: "test2", - Amount: sdk.NewInt(50000), + Amount: osmomath.NewInt(50000), }, - Weight: sdk.NewInt(214748364800), + Weight: osmomath.NewInt(214748364800), }, }) } diff --git a/x/gamm/pool-models/balancer/msgs_test.go b/x/gamm/pool-models/balancer/msgs_test.go index 9a3b1002d5d..c37638530a7 100644 --- a/x/gamm/pool-models/balancer/msgs_test.go +++ b/x/gamm/pool-models/balancer/msgs_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" appParams "github.com/osmosis-labs/osmosis/v19/app/params" balancer "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -23,18 +24,18 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { createMsg := func(after func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { testPoolAsset := []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test", sdk.NewInt(100)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test", osmomath.NewInt(100)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test2", sdk.NewInt(100)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test2", osmomath.NewInt(100)), }, } poolParams := &balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } msg := &balancer.MsgCreateBalancerPool{ @@ -108,7 +109,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { { name: "has the PoolAsset that includes 0 weight", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { - msg.PoolAssets[0].Weight = sdk.NewInt(0) + msg.PoolAssets[0].Weight = osmomath.NewInt(0) return msg }), expectPass: false, @@ -116,7 +117,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { { name: "has a PoolAsset that includes a negative weight", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { - msg.PoolAssets[0].Weight = sdk.NewInt(-10) + msg.PoolAssets[0].Weight = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -124,7 +125,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { { name: "has a PoolAsset that includes a negative weight", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { - msg.PoolAssets[0].Weight = sdk.NewInt(-10) + msg.PoolAssets[0].Weight = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -132,7 +133,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { { name: "has a PoolAsset that includes a zero coin", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { - msg.PoolAssets[0].Token = sdk.NewCoin("test1", sdk.NewInt(0)) + msg.PoolAssets[0].Token = sdk.NewCoin("test1", osmomath.NewInt(0)) return msg }), expectPass: false, @@ -142,7 +143,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { msg.PoolAssets[0].Token = sdk.Coin{ Denom: "test1", - Amount: sdk.NewInt(-10), + Amount: osmomath.NewInt(-10), } return msg }), @@ -152,8 +153,8 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { name: "negative spread factor with zero exit fee", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { msg.PoolParams = &balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(-1, 2), - ExitFee: sdk.NewDecWithPrec(0, 0), + SwapFee: osmomath.NewDecWithPrec(-1, 2), + ExitFee: osmomath.NewDecWithPrec(0, 0), } return msg }), @@ -195,8 +196,8 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { name: "zero spread factor, zero exit fee", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { msg.PoolParams = &balancer.PoolParams{ - ExitFee: sdk.NewDecWithPrec(0, 0), - SwapFee: sdk.NewDecWithPrec(0, 0), + ExitFee: osmomath.NewDecWithPrec(0, 0), + SwapFee: osmomath.NewDecWithPrec(0, 0), } return msg }), @@ -205,7 +206,7 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { { name: "too large of a weight", msg: createMsg(func(msg balancer.MsgCreateBalancerPool) balancer.MsgCreateBalancerPool { - msg.PoolAssets[0].Weight = sdk.NewInt(1 << 21) + msg.PoolAssets[0].Weight = osmomath.NewInt(1 << 21) return msg }), expectPass: false, @@ -218,12 +219,12 @@ func TestMsgCreateBalancerPool_ValidateBasic(t *testing.T) { // Duration: time.Hour, // TargetPoolWeights: []PoolAsset{ // { - // Weight: sdk.NewInt(200), - // Token: sdk.NewCoin("test", sdk.NewInt(1)), + // Weight: osmomath.NewInt(200), + // Token: sdk.NewCoin("test", osmomath.NewInt(1)), // }, // { - // Weight: sdk.NewInt(50), - // Token: sdk.NewCoin("test2", sdk.NewInt(1)), + // Weight: osmomath.NewInt(50), + // Token: sdk.NewCoin("test2", osmomath.NewInt(1)), // }, // }, // } @@ -251,7 +252,7 @@ func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { "basic success test": { msg: balancer.MsgCreateBalancerPool{ Sender: s.TestAccs[0].String(), - PoolParams: &balancer.PoolParams{SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.ZeroDec()}, + PoolParams: &balancer.PoolParams{SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: osmomath.ZeroDec()}, PoolAssets: apptesting.DefaultPoolAssets, FuturePoolGovernor: "", }, @@ -260,7 +261,7 @@ func (s *KeeperTestSuite) TestMsgCreateBalancerPool() { "error due to negative spread factor": { msg: balancer.MsgCreateBalancerPool{ Sender: s.TestAccs[0].String(), - PoolParams: &balancer.PoolParams{SwapFee: sdk.NewDecWithPrec(1, 2).Neg(), ExitFee: sdk.ZeroDec()}, + PoolParams: &balancer.PoolParams{SwapFee: osmomath.NewDecWithPrec(1, 2).Neg(), ExitFee: osmomath.ZeroDec()}, PoolAssets: apptesting.DefaultPoolAssets, FuturePoolGovernor: "", }, diff --git a/x/gamm/pool-models/balancer/pool.go b/x/gamm/pool-models/balancer/pool.go index f7b67039cc1..f30460585c0 100644 --- a/x/gamm/pool-models/balancer/pool.go +++ b/x/gamm/pool-models/balancer/pool.go @@ -10,6 +10,7 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/internal/cfmm_common" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -49,7 +50,7 @@ func NewBalancerPool(poolId uint64, balancerPoolParams PoolParams, assets []Pool Address: poolAddr.String(), Id: poolId, PoolParams: PoolParams{}, - TotalWeight: sdk.ZeroInt(), + TotalWeight: osmomath.ZeroInt(), TotalShares: sdk.NewCoin(types.GetPoolShareDenom(poolId), types.InitPoolSharesSupply), PoolAssets: nil, FuturePoolGovernor: futureGovernor, @@ -88,7 +89,7 @@ func (p Pool) GetId() uint64 { return p.Id } -func (p Pool) GetSpreadFactor(_ sdk.Context) sdk.Dec { +func (p Pool) GetSpreadFactor(_ sdk.Context) osmomath.Dec { return p.PoolParams.SwapFee } @@ -96,7 +97,7 @@ func (p Pool) GetTotalPoolLiquidity(_ sdk.Context) sdk.Coins { return poolAssetsCoins(p.PoolAssets) } -func (p Pool) GetExitFee(_ sdk.Context) sdk.Dec { +func (p Pool) GetExitFee(_ sdk.Context) osmomath.Dec { return p.PoolParams.ExitFee } @@ -104,19 +105,19 @@ func (p Pool) GetPoolParams() PoolParams { return p.PoolParams } -func (p Pool) GetTotalWeight() sdk.Int { +func (p Pool) GetTotalWeight() osmomath.Int { return p.TotalWeight } -func (p Pool) GetTotalShares() sdk.Int { +func (p Pool) GetTotalShares() osmomath.Int { return p.TotalShares.Amount } -func (p *Pool) AddTotalShares(amt sdk.Int) { +func (p *Pool) AddTotalShares(amt osmomath.Int) { p.TotalShares.Amount = p.TotalShares.Amount.Add(amt) } -func (p *Pool) SubTotalShares(amt sdk.Int) { +func (p *Pool) SubTotalShares(amt osmomath.Int) { p.TotalShares.Amount = p.TotalShares.Amount.Sub(amt) } @@ -139,7 +140,7 @@ func (p *Pool) SetInitialPoolAssets(PoolAssets []PoolAsset) error { // TODO: Refactor this into PoolAsset.validate() for _, asset := range PoolAssets { - if asset.Token.Amount.LTE(sdk.ZeroInt()) { + if asset.Token.Amount.LTE(osmomath.ZeroInt()) { return fmt.Errorf("can't add the zero or negative balance of token") } @@ -179,7 +180,7 @@ func (p *Pool) setInitialPoolParams(params PoolParams, sortedAssets []PoolAsset, for i, v := range sortedAssets { initialWeights[i] = PoolAsset{ Weight: v.Weight, - Token: sdk.Coin{Denom: v.Token.Denom, Amount: sdk.ZeroInt()}, + Token: sdk.Coin{Denom: v.Token.Denom, Amount: osmomath.ZeroInt()}, } } params.SmoothWeightChangeParams.InitialPoolWeights = initialWeights @@ -284,7 +285,7 @@ func (p Pool) parsePoolAssetsCoins(tokensA sdk.Coins, tokensB sdk.Coins) ( return Aasset, Basset, err } -func (p *Pool) IncreaseLiquidity(sharesOut sdk.Int, coinsIn sdk.Coins) { +func (p *Pool) IncreaseLiquidity(sharesOut osmomath.Int, coinsIn sdk.Coins) { err := p.addToPoolAssetBalances(coinsIn) if err != nil { panic(err) @@ -299,7 +300,7 @@ func (p *Pool) UpdatePoolAssetBalance(coin sdk.Coin) error { return err } - if coin.Amount.LTE(sdk.ZeroInt()) { + if coin.Amount.LTE(osmomath.ZeroInt()) { return fmt.Errorf("can't set the pool's balance of a token to be zero or negative") } @@ -378,7 +379,7 @@ func (p *Pool) updateAllWeights(newWeights []PoolAsset) { if len(p.PoolAssets) != len(newWeights) { panic("updateAllWeights called with invalid input, len(newWeights) != len(existingWeights)") } - totalWeight := sdk.ZeroInt() + totalWeight := osmomath.ZeroInt() for i, asset := range p.PoolAssets { if asset.Token.Denom != newWeights[i].Token.Denom { panic(fmt.Sprintf("updateAllWeights called with invalid input, "+ @@ -438,11 +439,11 @@ func (p *Pool) PokePool(blockTime time.Time) { // case 3: t > start_time + duration: w(t) = target_pool_weights shiftedBlockTime := blockTime.Sub(params.StartTime).Milliseconds() - percentDurationElapsed := sdk.NewDec(shiftedBlockTime).QuoInt64(params.Duration.Milliseconds()) + percentDurationElapsed := osmomath.NewDec(shiftedBlockTime).QuoInt64(params.Duration.Milliseconds()) // If the duration elapsed is equal to the total time, or a rounding error // makes it seem like it is, just set to target weight. - if percentDurationElapsed.GTE(sdk.OneDec()) { + if percentDurationElapsed.GTE(osmomath.OneDec()) { p.updateAllWeights(params.TargetPoolWeights) return } @@ -456,19 +457,19 @@ func (p *Pool) PokePool(blockTime time.Time) { } } -func (p Pool) GetTokenWeight(denom string) (sdk.Int, error) { +func (p Pool) GetTokenWeight(denom string) (osmomath.Int, error) { PoolAsset, err := p.GetPoolAsset(denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return PoolAsset.Weight, nil } -func (p Pool) GetTokenBalance(denom string) (sdk.Int, error) { +func (p Pool) GetTokenBalance(denom string) (osmomath.Int, error) { PoolAsset, err := p.GetPoolAsset(denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return PoolAsset.Token.Amount, nil @@ -492,15 +493,15 @@ func (p Pool) CalcOutAmtGivenIn( ctx sdk.Context, tokensIn sdk.Coins, tokenOutDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (sdk.Coin, error) { tokenIn, poolAssetIn, poolAssetOut, err := p.parsePoolAssets(tokensIn, tokenOutDenom) if err != nil { return sdk.Coin{}, err } - tokenAmountInAfterFee := tokenIn.Amount.ToDec().Mul(sdk.OneDec().Sub(spreadFactor)) - poolTokenInBalance := poolAssetIn.Token.Amount.ToDec() + tokenAmountInAfterFee := tokenIn.Amount.ToLegacyDec().Mul(osmomath.OneDec().Sub(spreadFactor)) + poolTokenInBalance := poolAssetIn.Token.Amount.ToLegacyDec() poolPostSwapInBalance := poolTokenInBalance.Add(tokenAmountInAfterFee) // deduct spread factor on the tokensIn @@ -508,9 +509,9 @@ func (p Pool) CalcOutAmtGivenIn( tokenAmountOut := solveConstantFunctionInvariant( poolTokenInBalance, poolPostSwapInBalance, - poolAssetIn.Weight.ToDec(), - poolAssetOut.Token.Amount.ToDec(), - poolAssetOut.Weight.ToDec(), + poolAssetIn.Weight.ToLegacyDec(), + poolAssetOut.Token.Amount.ToLegacyDec(), + poolAssetOut.Weight.ToLegacyDec(), ) // We ignore the decimal component, as we round down the token amount out. @@ -527,7 +528,7 @@ func (p *Pool) SwapOutAmtGivenIn( ctx sdk.Context, tokensIn sdk.Coins, tokenOutDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) ( tokenOut sdk.Coin, err error, ) { @@ -546,7 +547,7 @@ func (p *Pool) SwapOutAmtGivenIn( // CalcInAmtGivenOut calculates token to be provided, fee added, // given the swapped out amount, using solveConstantFunctionInvariant. func (p Pool) CalcInAmtGivenOut( - ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) ( + ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) ( tokenIn sdk.Coin, err error, ) { tokenOut, poolAssetOut, poolAssetIn, err := p.parsePoolAssets(tokensOut, tokenInDenom) @@ -555,18 +556,18 @@ func (p Pool) CalcInAmtGivenOut( } // delta balanceOut is positive(tokens inside the pool decreases) - poolTokenOutBalance := poolAssetOut.Token.Amount.ToDec() - poolPostSwapOutBalance := poolTokenOutBalance.Sub(tokenOut.Amount.ToDec()) + poolTokenOutBalance := poolAssetOut.Token.Amount.ToLegacyDec() + poolPostSwapOutBalance := poolTokenOutBalance.Sub(tokenOut.Amount.ToLegacyDec()) // (x_0)(y_0) = (x_0 + in)(y_0 - out) tokenAmountIn := solveConstantFunctionInvariant( - poolTokenOutBalance, poolPostSwapOutBalance, poolAssetOut.Weight.ToDec(), - poolAssetIn.Token.Amount.ToDec(), poolAssetIn.Weight.ToDec()).Neg() + poolTokenOutBalance, poolPostSwapOutBalance, poolAssetOut.Weight.ToLegacyDec(), + poolAssetIn.Token.Amount.ToLegacyDec(), poolAssetIn.Weight.ToLegacyDec()).Neg() // We deduct a spread factor on the input asset. The swap happens by following the invariant curve on the input * (1 - spread factor) // 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)) + tokenAmountInBeforeFee := tokenAmountIn.Quo(osmomath.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. @@ -580,7 +581,7 @@ func (p Pool) CalcInAmtGivenOut( // SwapInAmtGivenOut is a mutative method for CalcOutAmtGivenIn, which includes the actual swap. func (p *Pool) SwapInAmtGivenOut( - ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) ( + ctx sdk.Context, tokensOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) ( tokenIn sdk.Coin, err error, ) { tokenInCoin, err := p.CalcInAmtGivenOut(ctx, tokensOut, tokenInDenom, spreadFactor) @@ -628,42 +629,42 @@ func (p *Pool) applySwap(ctx sdk.Context, tokensIn sdk.Coins, tokensOut sdk.Coin // In other words, it costs 0.5 uosmo to get one uatom. // // panics if the pool in state is incorrect, and has any weight that is 0. -func (p Pool) SpotPrice(ctx sdk.Context, quoteAsset, baseAsset string) (spotPrice sdk.Dec, err error) { +func (p Pool) SpotPrice(ctx sdk.Context, quoteAsset, baseAsset string) (spotPrice osmomath.Dec, err error) { quote, base, err := p.parsePoolAssetsByDenoms(quoteAsset, baseAsset) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } if base.Weight.IsZero() || quote.Weight.IsZero() { - return sdk.Dec{}, errors.New("pool is misconfigured, got 0 weight") + return osmomath.Dec{}, errors.New("pool is misconfigured, got 0 weight") } // spot_price = (Quote Supply / Quote Weight) / (Base Supply / Base Weight) // = (Quote Supply / Quote Weight) * (Base Weight / Base Supply) // = (Base Weight / Quote Weight) * (Quote Supply / Base Supply) - invWeightRatio := base.Weight.ToDec().Quo(quote.Weight.ToDec()) - supplyRatio := quote.Token.Amount.ToDec().Quo(base.Token.Amount.ToDec()) + invWeightRatio := base.Weight.ToLegacyDec().Quo(quote.Weight.ToLegacyDec()) + supplyRatio := quote.Token.Amount.ToLegacyDec().Quo(base.Token.Amount.ToLegacyDec()) spotPrice = supplyRatio.Mul(invWeightRatio) return spotPrice, err } // calcPoolOutGivenSingleIn - balance pAo. -func (p *Pool) calcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor sdk.Dec, tokenInPoolAsset PoolAsset, totalShares sdk.Int) (numShares sdk.Int, err error) { +func (p *Pool) calcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor osmomath.Dec, tokenInPoolAsset PoolAsset, totalShares osmomath.Int) (numShares osmomath.Int, err error) { _, err = p.GetPoolAsset(tokenIn.Denom) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } totalWeight := p.GetTotalWeight() if totalWeight.IsZero() { - return sdk.ZeroInt(), errors.New("pool misconfigured, total weight = 0") + return osmomath.ZeroInt(), errors.New("pool misconfigured, total weight = 0") } - normalizedWeight := tokenInPoolAsset.Weight.ToDec().Quo(totalWeight.ToDec()) + normalizedWeight := tokenInPoolAsset.Weight.ToLegacyDec().Quo(totalWeight.ToLegacyDec()) return calcPoolSharesOutGivenSingleAssetIn( - tokenInPoolAsset.Token.Amount.ToDec(), + tokenInPoolAsset.Token.Amount.ToLegacyDec(), normalizedWeight, - totalShares.ToDec(), - tokenIn.Amount.ToDec(), + totalShares.ToLegacyDec(), + tokenIn.Amount.ToLegacyDec(), spreadFactor, ).TruncateInt(), nil } @@ -671,10 +672,10 @@ func (p *Pool) calcSingleAssetJoin(tokenIn sdk.Coin, spreadFactor sdk.Dec, token // JoinPool calculates the number of shares needed given tokensIn with spreadFactor applied. // It updates the liquidity if the pool is joined successfully. If not, returns error. // and updates pool accordingly. -func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) { +func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) { numShares, newLiquidity, err := p.CalcJoinPoolShares(ctx, tokensIn, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // update pool with the calculated share and liquidity needed to join pool @@ -684,10 +685,10 @@ func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.De // JoinPoolNoSwap calculates the number of shares needed for an all-asset join given tokensIn with spreadFactor applied. // It updates the liquidity if the pool is joined successfully. If not, returns error. -func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) { +func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) { numShares, tokensJoined, err := p.CalcJoinPoolNoSwapShares(ctx, tokensIn, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // update pool with the calculated share and liquidity needed to join pool @@ -702,7 +703,7 @@ func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor // // It returns the number of shares created, the amount of coins actually joined into the pool // (in case of not being able to fully join), or an error. -func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, tokensJoined sdk.Coins, err error) { +func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error) { // 1) Get pool current liquidity + and token weights // 2) If single token provided, do single asset join and exit. // 3) If multi-asset join, first do as much of a join as we can with no swaps. @@ -718,27 +719,29 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac // 1) get all 'pool assets' (aka current pool liquidity + balancer weight) poolAssetsByDenom, err := getPoolAssetsByDenom(p.GetAllPoolAssets()) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // check to make sure the input denom exists in the pool err = ensureDenomInPool(poolAssetsByDenom, tokensIn) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } + ctx.Logger().Info("CalcJoinPoolShares", "poold id", p.Id, "height", ctx.BlockHeight()) + totalShares := p.GetTotalShares() if tokensIn.Len() == 1 { // 2) Single token provided, so do single asset join and exit. numShares, err = p.calcSingleAssetJoin(tokensIn[0], spreadFactor, poolAssetsByDenom[tokensIn[0].Denom], totalShares) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // we join all the tokens. tokensJoined = tokensIn return numShares, tokensJoined, nil } else if tokensIn.Len() != p.NumAssets() { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("balancer pool only supports LP'ing with one asset or all assets in pool") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("balancer pool only supports LP'ing with one asset or all assets in pool") } // 3) JoinPoolNoSwap with as many tokens as we can. (What is in perfect ratio) @@ -747,12 +750,12 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac // if remaining coins is empty, logic is done (we joined all tokensIn) numShares, tokensJoined, err = p.CalcJoinPoolNoSwapShares(ctx, tokensIn, spreadFactor) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // safely ends the calculation if all input tokens are successfully LP'd if tokensJoined.IsAnyGT(tokensIn) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than tokens passed in") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than tokens passed in") } else if tokensJoined.IsEqual(tokensIn) { return numShares, tokensJoined, nil } @@ -763,7 +766,7 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac // * We add the joined coins to our "current pool liquidity" object (poolAssetsByDenom) // * We increment a variable for our "newTotalShares" to add in the shares that've been added. if err := updateIntermediaryPoolAssetsLiquidity(tokensJoined, poolAssetsByDenom); err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } newTotalShares := totalShares.Add(numShares) @@ -771,14 +774,14 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac remainingTokensIn := tokensIn.Sub(tokensJoined) newNumSharesFromRemaining, newLiquidityFromRemaining, err := p.calcJoinSingleAssetTokensIn(remainingTokensIn, newTotalShares, poolAssetsByDenom, spreadFactor) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // update total amount LP'd variable, and total new LP shares variable, run safety check, and return numShares = numShares.Add(newNumSharesFromRemaining) tokensJoined = tokensJoined.Add(newLiquidityFromRemaining...) if tokensJoined.IsAnyGT(tokensIn) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") } return numShares, tokensJoined, nil @@ -793,21 +796,21 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac // Since CalcJoinPoolNoSwapShares is non-mutative, the steps for updating pool shares / liquidity are // more complex / don't just alter the state. // We should simplify this logic further in the future using multi-join equations. -func (p *Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, tokensJoined sdk.Coins, err error) { +func (p *Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error) { // get all 'pool assets' (aka current pool liquidity + balancer weight) poolAssetsByDenom, err := getPoolAssetsByDenom(p.GetAllPoolAssets()) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } err = ensureDenomInPool(poolAssetsByDenom, tokensIn) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // ensure that there aren't too many or too few assets in `tokensIn` if tokensIn.Len() != p.NumAssets() { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("no-swap joins require LP'ing with all assets in pool") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("no-swap joins require LP'ing with all assets in pool") } // execute a no-swap join with as many tokens as possible given a perfect ratio: @@ -815,13 +818,13 @@ func (p *Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spr // * remainingTokensIn is how many coins we have left to join that have not already been used. numShares, remainingTokensIn, err := cfmm_common.MaximalExactRatioJoin(p, ctx, tokensIn) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // ensure that no more tokens have been joined than is possible with the given `tokensIn` tokensJoined = tokensIn.Sub(remainingTokensIn) if tokensJoined.IsAnyGT(tokensIn) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") } return numShares, tokensJoined, nil @@ -835,13 +838,13 @@ func (p *Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spr // Returns totalNewShares and totalNewLiquidity from joining all tokensIn // by mimicking individually single asset joining each. // or error if fails to calculate join for any of the tokensIn. -func (p *Pool) calcJoinSingleAssetTokensIn(tokensIn sdk.Coins, totalShares sdk.Int, poolAssetsByDenom map[string]PoolAsset, spreadFactor sdk.Dec) (sdk.Int, sdk.Coins, error) { - totalNewShares := sdk.ZeroInt() +func (p *Pool) calcJoinSingleAssetTokensIn(tokensIn sdk.Coins, totalShares osmomath.Int, poolAssetsByDenom map[string]PoolAsset, spreadFactor osmomath.Dec) (osmomath.Int, sdk.Coins, error) { + totalNewShares := osmomath.ZeroInt() totalNewLiquidity := sdk.NewCoins() for _, coin := range tokensIn { newShares, err := p.calcSingleAssetJoin(coin, spreadFactor, poolAssetsByDenom[coin.Denom], totalShares.Add(totalNewShares)) if err != nil { - return sdk.ZeroInt(), sdk.Coins{}, err + return osmomath.ZeroInt(), sdk.Coins{}, err } totalNewLiquidity = totalNewLiquidity.Add(coin) @@ -850,7 +853,7 @@ func (p *Pool) calcJoinSingleAssetTokensIn(tokensIn sdk.Coins, totalShares sdk.I return totalNewShares, totalNewLiquidity, nil } -func (p *Pool) ExitPool(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) (exitingCoins sdk.Coins, err error) { +func (p *Pool) ExitPool(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitingCoins sdk.Coins, err error) { exitingCoins, err = p.CalcExitPoolCoinsFromShares(ctx, exitingShares, exitFee) if err != nil { return sdk.Coins{}, err @@ -865,7 +868,7 @@ func (p *Pool) ExitPool(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) // exitPool exits the pool given exitingCoins and exitingShares. // updates the pool's liquidity and totalShares. -func (p *Pool) exitPool(ctx sdk.Context, exitingCoins sdk.Coins, exitingShares sdk.Int) error { +func (p *Pool) exitPool(ctx sdk.Context, exitingCoins sdk.Coins, exitingShares osmomath.Int) error { balances := p.GetTotalPoolLiquidity(ctx).Sub(exitingCoins) if err := p.UpdatePoolAssetBalances(balances); err != nil { return err @@ -877,35 +880,35 @@ func (p *Pool) exitPool(ctx sdk.Context, exitingCoins sdk.Coins, exitingShares s return nil } -func (p *Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) (exitedCoins sdk.Coins, err error) { +func (p *Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitedCoins sdk.Coins, err error) { return cfmm_common.CalcExitPool(ctx, p, exitingShares, exitFee) } func (p *Pool) CalcTokenInShareAmountOut( ctx sdk.Context, tokenInDenom string, - shareOutAmount sdk.Int, - spreadFactor sdk.Dec, -) (tokenInAmount sdk.Int, err error) { + shareOutAmount osmomath.Int, + spreadFactor osmomath.Dec, +) (tokenInAmount osmomath.Int, err error) { _, poolAssetIn, err := p.getPoolAssetAndIndex(tokenInDenom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } - normalizedWeight := poolAssetIn.Weight.ToDec().Quo(p.GetTotalWeight().ToDec()) + normalizedWeight := poolAssetIn.Weight.ToLegacyDec().Quo(p.GetTotalWeight().ToLegacyDec()) // We round up tokenInAmount, as this is whats charged for the swap, for the precise amount out. // Otherwise, the pool would under-charge by this rounding error. tokenInAmount = calcSingleAssetInGivenPoolSharesOut( - poolAssetIn.Token.Amount.ToDec(), + poolAssetIn.Token.Amount.ToLegacyDec(), normalizedWeight, - p.GetTotalShares().ToDec(), - shareOutAmount.ToDec(), + p.GetTotalShares().ToLegacyDec(), + shareOutAmount.ToLegacyDec(), spreadFactor, ).Ceil().TruncateInt() if !tokenInAmount.IsPositive() { - return sdk.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveTokenAmountErrFormat, tokenInAmount) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveTokenAmountErrFormat, tokenInAmount) } return tokenInAmount, nil @@ -914,31 +917,31 @@ func (p *Pool) CalcTokenInShareAmountOut( func (p *Pool) JoinPoolTokenInMaxShareAmountOut( ctx sdk.Context, tokenInDenom string, - shareOutAmount sdk.Int, -) (tokenInAmount sdk.Int, err error) { + shareOutAmount osmomath.Int, +) (tokenInAmount osmomath.Int, err error) { _, poolAssetIn, err := p.getPoolAssetAndIndex(tokenInDenom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } - normalizedWeight := poolAssetIn.Weight.ToDec().Quo(p.GetTotalWeight().ToDec()) + normalizedWeight := poolAssetIn.Weight.ToLegacyDec().Quo(p.GetTotalWeight().ToLegacyDec()) tokenInAmount = calcSingleAssetInGivenPoolSharesOut( - poolAssetIn.Token.Amount.ToDec(), + poolAssetIn.Token.Amount.ToLegacyDec(), normalizedWeight, - p.GetTotalShares().ToDec(), - shareOutAmount.ToDec(), + p.GetTotalShares().ToLegacyDec(), + shareOutAmount.ToLegacyDec(), p.GetSpreadFactor(ctx), ).TruncateInt() if !tokenInAmount.IsPositive() { - return sdk.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveTokenAmountErrFormat, tokenInAmount) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveTokenAmountErrFormat, tokenInAmount) } poolAssetIn.Token.Amount = poolAssetIn.Token.Amount.Add(tokenInAmount) err = p.UpdatePoolAssetBalance(poolAssetIn.Token) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return tokenInAmount, nil @@ -947,32 +950,32 @@ func (p *Pool) JoinPoolTokenInMaxShareAmountOut( func (p *Pool) ExitSwapExactAmountOut( ctx sdk.Context, tokenOut sdk.Coin, - shareInMaxAmount sdk.Int, -) (shareInAmount sdk.Int, err error) { + shareInMaxAmount osmomath.Int, +) (shareInAmount osmomath.Int, err error) { _, poolAssetOut, err := p.getPoolAssetAndIndex(tokenOut.Denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } sharesIn := calcPoolSharesInGivenSingleAssetOut( - poolAssetOut.Token.Amount.ToDec(), - poolAssetOut.Weight.ToDec().Quo(p.TotalWeight.ToDec()), - p.GetTotalShares().ToDec(), - tokenOut.Amount.ToDec(), + poolAssetOut.Token.Amount.ToLegacyDec(), + poolAssetOut.Weight.ToLegacyDec().Quo(p.TotalWeight.ToLegacyDec()), + p.GetTotalShares().ToLegacyDec(), + tokenOut.Amount.ToLegacyDec(), p.GetSpreadFactor(ctx), p.GetExitFee(ctx), ).TruncateInt() if !sharesIn.IsPositive() { - return sdk.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveSharesAmountErrFormat, sharesIn) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrNotPositiveRequireAmount, nonPostiveSharesAmountErrFormat, sharesIn) } if sharesIn.GT(shareInMaxAmount) { - return sdk.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, sharesLargerThanMaxErrFormat, sharesIn, shareInMaxAmount) + return osmomath.Int{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, sharesLargerThanMaxErrFormat, sharesIn, shareInMaxAmount) } if err := p.exitPool(ctx, sdk.NewCoins(tokenOut), sharesIn); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return sharesIn, nil diff --git a/x/gamm/pool-models/balancer/pool_asset.go b/x/gamm/pool-models/balancer/pool_asset.go index 43e2e807767..bbb502d7aeb 100644 --- a/x/gamm/pool-models/balancer/pool_asset.go +++ b/x/gamm/pool-models/balancer/pool_asset.go @@ -7,6 +7,7 @@ import ( "gopkg.in/yaml.v2" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" errorsmod "cosmossdk.io/errors" @@ -15,13 +16,13 @@ import ( ) type poolAssetPretty struct { - Token sdk.Coin `json:"token" yaml:"token"` - Weight sdk.Dec `json:"weight" yaml:"weight"` + Token sdk.Coin `json:"token" yaml:"token"` + Weight osmomath.Dec `json:"weight" yaml:"weight"` } // validates a pool asset, to check if it has a valid weight. func (pa PoolAsset) validateWeight() error { - if pa.Weight.LTE(sdk.ZeroInt()) { + if pa.Weight.LTE(osmomath.ZeroInt()) { return fmt.Errorf("a token's weight in the pool must be greater than 0") } @@ -33,7 +34,7 @@ func (pa PoolAsset) validateWeight() error { func (pa PoolAsset) prettify() poolAssetPretty { return poolAssetPretty{ - Weight: sdk.NewDecFromInt(pa.Weight).QuoInt64(GuaranteedWeightPrecision), + Weight: osmomath.NewDecFromInt(pa.Weight).QuoInt64(GuaranteedWeightPrecision), Token: pa.Token, } } diff --git a/x/gamm/pool-models/balancer/pool_params.go b/x/gamm/pool-models/balancer/pool_params.go index eec2f51ad71..9fcf6b7fa79 100644 --- a/x/gamm/pool-models/balancer/pool_params.go +++ b/x/gamm/pool-models/balancer/pool_params.go @@ -3,12 +3,11 @@ package balancer import ( "errors" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) -func NewPoolParams(spreadFactor, exitFee sdk.Dec, params *SmoothWeightChangeParams) PoolParams { +func NewPoolParams(spreadFactor, exitFee osmomath.Dec, params *SmoothWeightChangeParams) PoolParams { return PoolParams{ SwapFee: spreadFactor, ExitFee: exitFee, @@ -21,7 +20,7 @@ func (params PoolParams) Validate(poolWeights []PoolAsset) error { return types.ErrNegativeExitFee } - if params.ExitFee.GTE(sdk.OneDec()) { + if params.ExitFee.GTE(osmomath.OneDec()) { return types.ErrTooMuchExitFee } @@ -29,7 +28,7 @@ func (params PoolParams) Validate(poolWeights []PoolAsset) error { return types.ErrNegativeSpreadFactor } - if params.SwapFee.GTE(sdk.OneDec()) { + if params.SwapFee.GTE(osmomath.OneDec()) { return types.ErrTooMuchSpreadFactor } @@ -69,10 +68,10 @@ func (params PoolParams) Validate(poolWeights []PoolAsset) error { return nil } -func (params PoolParams) GetPoolSpreadFactor() sdk.Dec { +func (params PoolParams) GetPoolSpreadFactor() osmomath.Dec { return params.SwapFee } -func (params PoolParams) GetPoolExitFee() sdk.Dec { +func (params PoolParams) GetPoolExitFee() osmomath.Dec { return params.ExitFee } diff --git a/x/gamm/pool-models/balancer/pool_suite_test.go b/x/gamm/pool-models/balancer/pool_suite_test.go index a23f6488fd7..083b57cdd7b 100644 --- a/x/gamm/pool-models/balancer/pool_suite_test.go +++ b/x/gamm/pool-models/balancer/pool_suite_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/app/apptesting" v10 "github.com/osmosis-labs/osmosis/v19/app/upgrades/v10" @@ -30,14 +31,14 @@ const ( ) var ( - oneTrillion = sdk.NewInt(1e12) + oneTrillion = osmomath.NewInt(1e12) defaultOsmoPoolAsset = balancer.PoolAsset{ Token: sdk.NewCoin("uosmo", oneTrillion), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), } defaultAtomPoolAsset = balancer.PoolAsset{ Token: sdk.NewCoin("uatom", oneTrillion), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), } oneTrillionEvenPoolAssets = []balancer.PoolAsset{ defaultOsmoPoolAsset, @@ -54,10 +55,10 @@ var ( // CalcJoinPoolShares with only one tokensIn. type calcJoinSharesTestCase struct { name string - spreadFactor sdk.Dec + spreadFactor osmomath.Dec poolAssets []balancer.PoolAsset tokensIn sdk.Coins - expectShares sdk.Int + expectShares osmomath.Int expectLiq sdk.Coins expectPanic bool expErr error @@ -80,10 +81,10 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100000000000000000000*%28%281+%2B+%2850000%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2,499,999,968,750 name: "single tokensIn - equal weights with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(2_499_999_968_750), + expectShares: osmomath.NewInt(2_499_999_968_750), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -101,10 +102,10 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-0.5%29+*+0.01%29%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2_487_500_000_000 name: "single tokensIn - equal weights with 0.01 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(2_487_500_000_000), + expectShares: osmomath.NewInt(2_487_500_000_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -122,10 +123,10 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=%28100+*+10%5E18+%29*+%28%28+1+%2B+%2850%2C000+*+%281+-+%281+-+0.5%29+*+0.99%29+%2F+1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 1_262_500_000_000 name: "single tokensIn - equal weights with 0.99 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.99"), + spreadFactor: osmomath.MustNewDecFromStr("0.99"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(1_262_500_000_000), + expectShares: osmomath.NewInt(1_262_500_000_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -143,16 +144,16 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=%28100+*+10%5E18+%29*+%28%28+1+%2B+%2850%2C000+*+%281+-+%281+-+0.25%29+*+0.99%29+%2F+1000000000000%29%29%5E0.25+-+1%29 // Simplified: P_issued = 321_875_000_000 name: "single tokensIn - unequal weights with 0.99 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.99"), + spreadFactor: osmomath.MustNewDecFromStr("0.99"), poolAssets: []balancer.PoolAsset{ defaultOsmoPoolAsset, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(300), + Weight: osmomath.NewInt(300), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(321_875_000_000), + expectShares: osmomath.NewInt(321_875_000_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -169,16 +170,16 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-%28500+%2F+%28100+%2B+500%29%29%29+*+0%29%2F1000000000000%29%29%5E%28500+%2F+%28100+%2B+500%29%29+-+1%29 // Simplified: P_issued = 4_159_722_200_000 name: "single asset - token in weight is greater than the other token, with zero spread factor", - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(500), + Weight: osmomath.NewInt(500), }, defaultAtomPoolAsset, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(4_166_666_649_306), + expectShares: osmomath.NewInt(4_166_666_649_306), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -195,16 +196,16 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-%28500+%2F+%28100+%2B+500%29%29%29+*+0.01%29%2F1000000000000%29%29%5E%28500+%2F+%28100+%2B+500%29%29+-+1%29 // Simplified: P_issued = 4_159_722_200_000 name: "single asset - token in weight is greater than the other token, with non-zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(500), + Weight: osmomath.NewInt(500), }, defaultAtomPoolAsset, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(4_159_722_200_000), + expectShares: osmomath.NewInt(4_159_722_200_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -221,19 +222,19 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-%28200+%2F+%28200+%2B+1000%29%29%29+*+0%29%2F1000000000000%29%29%5E%28200+%2F+%28200+%2B+1000%29%29+-+1%29 // Simplified: P_issued = 833_333_315_972 name: "single asset - token in weight is smaller than the other token, with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(833_333_315_972), + expectShares: osmomath.NewInt(833_333_315_972), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -250,19 +251,19 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-%28200+%2F+%28200+%2B+1000%29%29%29+*+0.02%29%2F1000000000000%29%29%5E%28200+%2F+%28200+%2B+1000%29%29+-+1%29 // Simplified: P_issued = 819_444_430_000 name: "single asset - token in weight is smaller than the other token, with non-zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.02"), + spreadFactor: osmomath.MustNewDecFromStr("0.02"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(819_444_430_000), + expectShares: osmomath.NewInt(819_444_430_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -279,20 +280,20 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%28117552*%281+-+%281-%28200+%2F+%28200+%2B+1000%29%29%29+*+0%29%2F156736%29%29%5E%28200+%2F+%28200+%2B+1000%29%29+-+1%29 // Simplified: P_issued = 9_775_731_930_496_140_648 name: "single asset - tokenIn is large relative to liquidity, token in weight is smaller than the other token, with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 156_736), - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, // 156_736 * 3 / 4 = 117552 tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", (156_736*3)/4)), - expectShares: sdk.NewIntFromUint64(9_775_731_930_496_140_648), + expectShares: osmomath.NewIntFromUint64(9_775_731_930_496_140_648), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -309,20 +310,20 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-%28200+%2F+%28200+%2B+1000%29%29%29+*+0.02%29%2F1000000000000%29%29%5E%28200+%2F+%28200+%2B+1000%29%29+-+1%29 // Simplified: P_issued = 9_644_655_900_000_000_000 name: "single asset - tokenIn is large relative to liquidity, token in weight is smaller than the other token, with non-zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.02"), + spreadFactor: osmomath.MustNewDecFromStr("0.02"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 156_736), - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, // 156_736 / 4 * 3 = 117552 tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 156_736/4*3)), - expectShares: sdk.NewIntFromUint64(9_644_655_900_000_000_000), + expectShares: osmomath.NewIntFromUint64(9_644_655_900_000_000_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -339,19 +340,19 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%28499999*%281+-+%281-%28100+%2F+%28100+%2B+1000%29%29%29+*+0%29%2F500000%29%29%5E%28100+%2F+%28100+%2B+1000%29%29+-+1%29 // Simplified: P_issued = 6_504_099_261_800_144_638 name: "single asset - (almost 1 == tokenIn / liquidity ratio), token in weight is smaller than the other token, with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 500_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 499_999)), - expectShares: sdk.NewIntFromUint64(6_504_099_261_800_144_638), + expectShares: osmomath.NewIntFromUint64(6_504_099_261_800_144_638), }, { // Currently, our Pow approximation function does not work correctly when one tries @@ -360,75 +361,75 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{ // This has been deemed as acceptable since it causes code complexity to fix // & only affects UX in an edge case (user has to split up single asset joins) name: "single asset - (exactly 1 == tokenIn / liquidity ratio - failure), token in weight is smaller than the other token, with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 500_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(1000), + Weight: osmomath.NewInt(1000), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 500_000)), - expectShares: sdk.NewIntFromUint64(6_504_099_261_800_144_638), + expectShares: osmomath.NewIntFromUint64(6_504_099_261_800_144_638), expectPanic: true, }, { name: "tokenIn asset does not exist in pool", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin(doesNotExistDenom, 50_000)), - expectShares: sdk.ZeroInt(), + expectShares: osmomath.ZeroInt(), expErr: errorsmod.Wrapf(types.ErrDenomNotFoundInPool, fmt.Sprintf(balancer.ErrMsgFormatNoPoolAssetFound, doesNotExistDenom)), }, { // Pool liquidity is changed by 1e-12 / 2 // P_issued = 1e20 * 1e-12 / 2 = 1e8 / 2 = 50_000_000 name: "minimum input single asset equal liquidity", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), ), - expectShares: sdk.NewInt(50_000_000), + expectShares: osmomath.NewInt(50_000_000), }, { // P_issued should be 1/10th that of the previous test // p_issued = 50_000_000 / 10 = 5_000_000 name: "minimum input single asset imbalanced liquidity", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 10_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), ), - expectShares: sdk.NewInt(5_000_000), + expectShares: osmomath.NewInt(5_000_000), }, } var multiAssetExactInputTestCases = []calcJoinSharesTestCase{ { name: "swap equal weights with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), @@ -437,7 +438,7 @@ var multiAssetExactInputTestCases = []calcJoinSharesTestCase{ // Raises liquidity perfectly by 25_000 / 1_000_000_000_000. // Initial number of pool shares = 100 * 10**18 = 10**20 // Expected increase = liquidity_increase_ratio * initial number of pool shares = (25_000 / 1e12) * 10**20 = 2500000000000.0 = 2.5 * 10**12 - expectShares: sdk.NewInt(2.5e12), + expectShares: osmomath.NewInt(2.5e12), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 25_000), @@ -445,13 +446,13 @@ var multiAssetExactInputTestCases = []calcJoinSharesTestCase{ }, { name: "swap equal weights with 0.001 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.001"), + spreadFactor: osmomath.MustNewDecFromStr("0.001"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 25_000), ), - expectShares: sdk.NewInt(2500000000000), + expectShares: osmomath.NewInt(2500000000000), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 25_000), @@ -462,22 +463,22 @@ var multiAssetExactInputTestCases = []calcJoinSharesTestCase{ // This is set to 1e20 (or 100 * 10^18) for Osmosis, so we should expect: // P_issued = 1e20 name: "minimum input with two assets and minimum liquidity", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), sdk.NewInt64Coin("uatom", 1), ), - expectShares: sdk.NewInt(1e18).Mul(sdk.NewInt(100)), + expectShares: osmomath.NewInt(1e18).Mul(osmomath.NewInt(100)), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), sdk.NewInt64Coin("uatom", 1), @@ -487,22 +488,22 @@ var multiAssetExactInputTestCases = []calcJoinSharesTestCase{ // Pool liquidity is changed by 1e-12 // P_issued = 1e20 * 1e-12 = 1e8 name: "minimum input two assets equal liquidity", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uatom", 1_000_000_000_000), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), sdk.NewInt64Coin("uatom", 1), ), - expectShares: sdk.NewInt(100_000_000), + expectShares: osmomath.NewInt(100_000_000), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 1), sdk.NewInt64Coin("uatom", 1), @@ -530,14 +531,14 @@ var multiAssetUnevenInputTestCases = []calcJoinSharesTestCase{ // Simplified: P_issued = 2_500_000_000_000 + 1_249_999_960_937 name: "Multi-tokens In: unequal amounts, equal weights with 0 spread factor", - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(2.5e12 + 1249999992187), + expectShares: osmomath.NewInt(2.5e12 + 1249999992187), }, { // For uosmos and uatom @@ -558,13 +559,13 @@ var multiAssetUnevenInputTestCases = []calcJoinSharesTestCase{ // Simplified: P_issued = 2_500_000_000_000 + 1_243_750_000_000 name: "Multi-tokens In: unequal amounts, equal weights with 0.01 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(2.5e12 + 1243750000000), + expectShares: osmomath.NewInt(2.5e12 + 1243750000000), }, { // join pool is first done to the extent where the ratio can be preserved, which is 25,000 uosmo and 12,500 uatom. @@ -586,11 +587,11 @@ var multiAssetUnevenInputTestCases = []calcJoinSharesTestCase{ // Full solution with fees: https://www.wolframalpha.com/input?i=%28100+*10%5E18+%2B+1250000000000%29*%28%281%2B++++%2837500*%281+-+%281-1%2F6%29+*+0.03%29%2F1000000012500%29%29%5E%281%2F6%29+-+1%29 // Simplified: P_issued = 1,250,000,000,000 + 609,374,990,000 name: "Multi-tokens In: unequal amounts, with unequal weights with 0.03 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 2_000_000_000_000), - Weight: sdk.NewInt(500), + Weight: osmomath.NewInt(500), }, defaultAtomPoolAsset, }, @@ -598,7 +599,7 @@ var multiAssetUnevenInputTestCases = []calcJoinSharesTestCase{ sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(1250000000000 + 609374990000), + expectShares: osmomath.NewInt(1250000000000 + 609374990000), }, } @@ -637,49 +638,49 @@ func (s *KeeperTestSuite) TestBalancerSpotPrice() { baseDenomPoolInput sdk.Coin quoteDenomPoolInput sdk.Coin expectError bool - expectedOutput sdk.Dec + expectedOutput osmomath.Dec }{ { name: "equal value", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 100), quoteDenomPoolInput: sdk.NewInt64Coin(quoteDenom, 100), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("1"), + expectedOutput: osmomath.MustNewDecFromStr("1"), }, { name: "1:2 ratio", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 100), quoteDenomPoolInput: sdk.NewInt64Coin(quoteDenom, 200), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("0.500000000000000000"), + expectedOutput: osmomath.MustNewDecFromStr("0.500000000000000000"), }, { name: "2:1 ratio", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 200), quoteDenomPoolInput: sdk.NewInt64Coin(quoteDenom, 100), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("2.000000000000000000"), + expectedOutput: osmomath.MustNewDecFromStr("2.000000000000000000"), }, { name: "rounding after sigfig ratio", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 220), quoteDenomPoolInput: sdk.NewInt64Coin(quoteDenom, 115), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("1.913043480000000000"), // ans is 1.913043478260869565, rounded is 1.91304348 + expectedOutput: osmomath.MustNewDecFromStr("1.913043480000000000"), // ans is 1.913043478260869565, rounded is 1.91304348 }, { name: "check number of sig figs", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 100), quoteDenomPoolInput: sdk.NewInt64Coin(quoteDenom, 300), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("0.333333330000000000"), + expectedOutput: osmomath.MustNewDecFromStr("0.333333330000000000"), }, { name: "check number of sig figs high sizes", baseDenomPoolInput: sdk.NewInt64Coin(baseDenom, 343569192534), - quoteDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.MustNewDecFromStr("186633424395479094888742").TruncateInt()), + quoteDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.MustNewDecFromStr("186633424395479094888742").TruncateInt()), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("0.000000000001840877"), + expectedOutput: osmomath.MustNewDecFromStr("0.000000000001840877"), }, } @@ -721,37 +722,37 @@ func (s *KeeperTestSuite) TestBalancerSpotPriceBounds() { tests := []struct { name string quoteDenomPoolInput sdk.Coin - quoteDenomWeight sdk.Int + quoteDenomWeight osmomath.Int baseDenomPoolInput sdk.Coin - baseDenomWeight sdk.Int + baseDenomWeight osmomath.Int expectError bool - expectedOutput sdk.Dec + expectedOutput osmomath.Dec }{ { name: "spot price check at max bitlen supply", // 2^196, as >= 2^197 trips max bitlen of 256 - quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.MustNewDecFromStr("100433627766186892221372630771322662657637687111424552206336").TruncateInt()), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.MustNewDecFromStr("100433627766186892221372630771322662657637687111424552206337").TruncateInt()), - baseDenomWeight: sdk.NewInt(100), + quoteDenomPoolInput: sdk.NewCoin(baseDenom, osmomath.MustNewDecFromStr("100433627766186892221372630771322662657637687111424552206336").TruncateInt()), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.MustNewDecFromStr("100433627766186892221372630771322662657637687111424552206337").TruncateInt()), + baseDenomWeight: osmomath.NewInt(100), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("1.000000000000000000"), + expectedOutput: osmomath.MustNewDecFromStr("1.000000000000000000"), }, { name: "spot price check at min supply", - quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.OneInt()), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.OneInt()), - baseDenomWeight: sdk.NewInt(100), + quoteDenomPoolInput: sdk.NewCoin(baseDenom, osmomath.OneInt()), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.OneInt()), + baseDenomWeight: osmomath.NewInt(100), expectError: false, - expectedOutput: sdk.MustNewDecFromStr("1.000000000000000000"), + expectedOutput: osmomath.MustNewDecFromStr("1.000000000000000000"), }, { name: "max spot price with equal weights", quoteDenomPoolInput: sdk.NewCoin(baseDenom, types.MaxSpotPrice.TruncateInt()), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.OneInt()), - baseDenomWeight: sdk.NewInt(100), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.OneInt()), + baseDenomWeight: osmomath.NewInt(100), expectError: false, expectedOutput: types.MaxSpotPrice, }, @@ -759,35 +760,35 @@ func (s *KeeperTestSuite) TestBalancerSpotPriceBounds() { // test int overflows name: "max spot price with extreme weights", quoteDenomPoolInput: sdk.NewCoin(baseDenom, types.MaxSpotPrice.TruncateInt()), - quoteDenomWeight: sdk.OneInt(), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.OneInt()), - baseDenomWeight: sdk.NewInt(1 << 19), + quoteDenomWeight: osmomath.OneInt(), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.OneInt()), + baseDenomWeight: osmomath.NewInt(1 << 19), expectError: true, }, { name: "greater than max spot price with equal weights", // Max spot price capped at 2^160 - quoteDenomPoolInput: sdk.NewCoin(baseDenom, types.MaxSpotPrice.TruncateInt().Add(sdk.OneInt())), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.OneInt()), - baseDenomWeight: sdk.NewInt(100), + quoteDenomPoolInput: sdk.NewCoin(baseDenom, types.MaxSpotPrice.TruncateInt().Add(osmomath.OneInt())), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.OneInt()), + baseDenomWeight: osmomath.NewInt(100), expectError: true, }, { name: "internal error due to spot price precision being too small, resulting in 0 spot price", - quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.OneInt()), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.NewDec(10).PowerMut(19).TruncateInt().Sub(sdk.NewInt(2))), - baseDenomWeight: sdk.NewInt(100), + quoteDenomPoolInput: sdk.NewCoin(baseDenom, osmomath.OneInt()), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.NewDec(10).PowerMut(19).TruncateInt().Sub(osmomath.NewInt(2))), + baseDenomWeight: osmomath.NewInt(100), expectError: true, }, { name: "at min spot price", - quoteDenomPoolInput: sdk.NewCoin(baseDenom, sdk.OneInt()), - quoteDenomWeight: sdk.NewInt(100), - baseDenomPoolInput: sdk.NewCoin(quoteDenom, sdk.NewDec(10).PowerMut(18).TruncateInt()), - baseDenomWeight: sdk.NewInt(100), - expectedOutput: sdk.OneDec().Quo(sdk.NewDec(10).PowerMut(18)), + quoteDenomPoolInput: sdk.NewCoin(baseDenom, osmomath.OneInt()), + quoteDenomWeight: osmomath.NewInt(100), + baseDenomPoolInput: sdk.NewCoin(quoteDenom, osmomath.NewDec(10).PowerMut(18).TruncateInt()), + baseDenomWeight: osmomath.NewInt(100), + expectedOutput: osmomath.OneDec().Quo(osmomath.NewDec(10).PowerMut(18)), }, } @@ -805,7 +806,7 @@ func (s *KeeperTestSuite) TestBalancerSpotPriceBounds() { } poolAssets := []balancer.PoolAsset{defaultBaseAsset, defaultQuoteAsset} - poolId := s.PrepareCustomBalancerPool(poolAssets, balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.ZeroDec()}) + poolId := s.PrepareCustomBalancerPool(poolAssets, balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.ZeroDec()}) pool, err := s.App.GAMMKeeper.GetPoolAndPoke(s.Ctx, poolId) s.Require().NoError(err, "test: %s", tc.name) @@ -840,7 +841,7 @@ func (s *KeeperTestSuite) TestCalcJoinPoolShares() { tc := tc s.T().Run(tc.name, func(t *testing.T) { - pool := createTestPool(t, tc.spreadFactor, sdk.ZeroDec(), tc.poolAssets...) + pool := createTestPool(t, tc.spreadFactor, osmomath.ZeroDec(), tc.poolAssets...) // system under test sut := func() { @@ -848,7 +849,7 @@ func (s *KeeperTestSuite) TestCalcJoinPoolShares() { if tc.expErr != nil { require.Error(t, err) require.ErrorAs(t, tc.expErr, &err) - require.Equal(t, sdk.ZeroInt(), shares) + require.Equal(t, osmomath.ZeroInt(), shares) require.Equal(t, sdk.NewCoins(), liquidity) } else { require.NoError(t, err) @@ -877,7 +878,7 @@ func (s *KeeperTestSuite) TestJoinPool() { tc := tc s.T().Run(tc.name, func(t *testing.T) { - pool := createTestPool(t, tc.spreadFactor, sdk.ZeroDec(), tc.poolAssets...) + pool := createTestPool(t, tc.spreadFactor, osmomath.ZeroDec(), tc.poolAssets...) // system under test sut := func() { @@ -888,7 +889,7 @@ func (s *KeeperTestSuite) TestJoinPool() { if tc.expErr != nil { require.Error(t, err) require.ErrorAs(t, tc.expErr, &err) - require.Equal(t, sdk.Int{}, shares) + require.Equal(t, osmomath.Int{}, shares) require.Equal(t, preJoinAssets, postJoinAssets) } else { require.NoError(t, err) @@ -913,14 +914,14 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { { // only the exact ratio portion is successfully joined name: "Multi-tokens In: unequal amounts, equal weights with 0 spread factor", - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(2.5e12), + expectShares: osmomath.NewInt(2.5e12), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 25_000), @@ -929,14 +930,14 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { { // only the exact ratio portion is successfully joined name: "Multi-tokens In: unequal amounts, equal weights with 0.01 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(2.5e12), + expectShares: osmomath.NewInt(2.5e12), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 25_000), @@ -947,11 +948,11 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { // We expect a 2:1 ratio in the joined liquidity because there's a 2:1 ration in existing liquidity // Since only the exact ratio portion is successfully joined, we expect 25k uosmo and 12.5k uatom name: "Multi-tokens In: unequal amounts, with unequal weights with 0.03 spread factor", - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 2_000_000_000_000), - Weight: sdk.NewInt(500), + Weight: osmomath.NewInt(500), }, defaultAtomPoolAsset, }, @@ -959,7 +960,7 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 50_000), ), - expectShares: sdk.NewInt(1250000000000), + expectShares: osmomath.NewInt(1250000000000), expectLiq: sdk.NewCoins( sdk.NewInt64Coin("uosmo", 25_000), sdk.NewInt64Coin("uatom", 12_500), @@ -972,7 +973,7 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { tc := tc s.T().Run(tc.name, func(t *testing.T) { - pool := createTestPool(t, tc.spreadFactor, sdk.ZeroDec(), tc.poolAssets...) + pool := createTestPool(t, tc.spreadFactor, osmomath.ZeroDec(), tc.poolAssets...) // system under test sut := func() { @@ -983,7 +984,7 @@ func (s *KeeperTestSuite) TestJoinPoolNoSwap() { if tc.expErr != nil { require.Error(t, err) require.ErrorAs(t, tc.expErr, &err) - require.Equal(t, sdk.Int{}, shares) + require.Equal(t, osmomath.Int{}, shares) require.Equal(t, preJoinAssets, postJoinAssets) } else { require.NoError(t, err) @@ -1006,7 +1007,7 @@ func (s *KeeperTestSuite) TestRandomizedJoinPoolExitPoolInvariants() { percentRatio int64 - numShares sdk.Int + numShares osmomath.Int } const ( @@ -1030,20 +1031,20 @@ func (s *KeeperTestSuite) TestRandomizedJoinPoolExitPoolInvariants() { return tc } - spreadFactorDec := sdk.ZeroDec() - exitFeeDec := sdk.ZeroDec() + spreadFactorDec := osmomath.ZeroDec() + exitFeeDec := osmomath.ZeroDec() // create pool with randomized initial token amounts // and randomized ratio of join/exit createPool := func(tc *testCase) (pool *balancer.Pool) { poolAssetOut := balancer.PoolAsset{ Token: sdk.NewInt64Coin(denomOut, tc.initialTokensDenomOut), - Weight: sdk.NewInt(5), + Weight: osmomath.NewInt(5), } poolAssetIn := balancer.PoolAsset{ Token: sdk.NewInt64Coin(denomIn, tc.initialTokensDenomIn), - Weight: sdk.NewInt(5), + Weight: osmomath.NewInt(5), } pool = createTestPool(s.T(), spreadFactorDec, exitFeeDec, poolAssetOut, poolAssetIn) @@ -1055,8 +1056,8 @@ func (s *KeeperTestSuite) TestRandomizedJoinPoolExitPoolInvariants() { // joins with predetermined ratio joinPool := func(pool types.CFMMPoolI, tc *testCase) { tokensIn := sdk.Coins{ - sdk.NewCoin(denomIn, sdk.NewInt(tc.initialTokensDenomIn).MulRaw(tc.percentRatio).QuoRaw(100)), - sdk.NewCoin(denomOut, sdk.NewInt(tc.initialTokensDenomOut).MulRaw(tc.percentRatio).QuoRaw(100)), + sdk.NewCoin(denomIn, osmomath.NewInt(tc.initialTokensDenomIn).MulRaw(tc.percentRatio).QuoRaw(100)), + sdk.NewCoin(denomOut, osmomath.NewInt(tc.initialTokensDenomOut).MulRaw(tc.percentRatio).QuoRaw(100)), } numShares, err := pool.JoinPool(s.Ctx, tokensIn, spreadFactorDec) s.Require().NoError(err) @@ -1071,7 +1072,7 @@ func (s *KeeperTestSuite) TestRandomizedJoinPoolExitPoolInvariants() { invariantJoinExitInversePreserve := func( beforeCoins, afterCoins sdk.Coins, - beforeShares, afterShares sdk.Int, + beforeShares, afterShares osmomath.Int, ) { // test token amount has been preserved s.Require().True( diff --git a/x/gamm/pool-models/balancer/pool_test.go b/x/gamm/pool-models/balancer/pool_test.go index 3e565b922bd..b4c4a90c637 100644 --- a/x/gamm/pool-models/balancer/pool_test.go +++ b/x/gamm/pool-models/balancer/pool_test.go @@ -18,8 +18,8 @@ import ( ) var ( - defaultSpreadFactor = sdk.MustNewDecFromStr("0.025") - defaultZeroExitFee = sdk.ZeroDec() + defaultSpreadFactor = osmomath.MustNewDecFromStr("0.025") + defaultZeroExitFee = osmomath.ZeroDec() defaultPoolId = uint64(10) defaultBalancerPoolParams = balancer.PoolParams{ SwapFee: defaultSpreadFactor, @@ -60,15 +60,15 @@ func TestUpdateIntermediaryPoolAssetsLiquidity(t *testing.T) { poolAssets: map[string]balancer.PoolAsset{ "uosmo": { Token: sdk.NewInt64Coin("uosmo", uosmoValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, "atom": { Token: sdk.NewInt64Coin("atom", atomValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, "ion": { Token: sdk.NewInt64Coin("ion", ionValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, }, expectPass: true, @@ -79,15 +79,15 @@ func TestUpdateIntermediaryPoolAssetsLiquidity(t *testing.T) { poolAssets: map[string]balancer.PoolAsset{ "uosmo": { Token: sdk.NewInt64Coin("uosmo", uosmoValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, "atom": { Token: sdk.NewInt64Coin("atom", atomValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, "ion": { Token: sdk.NewInt64Coin("ion", ionValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, }, expectPass: true, @@ -99,7 +99,7 @@ func TestUpdateIntermediaryPoolAssetsLiquidity(t *testing.T) { poolAssets: map[string]balancer.PoolAsset{ "uosmo": { Token: sdk.NewInt64Coin("uosmo", uosmoValueOriginal), - Weight: sdk.NewInt(weight), + Weight: osmomath.NewInt(weight), }, }, expectPass: false, @@ -136,7 +136,7 @@ func TestCalcSingleAssetJoin(t *testing.T) { for _, tc := range calcSingleAssetJoinTestCases { tc := tc t.Run(tc.name, func(t *testing.T) { - pool := createTestPool(t, tc.spreadFactor, sdk.MustNewDecFromStr("0"), tc.poolAssets...) + pool := createTestPool(t, tc.spreadFactor, osmomath.MustNewDecFromStr("0"), tc.poolAssets...) tokenIn := tc.tokensIn[0] @@ -160,7 +160,7 @@ func TestCalcSingleAssetJoin(t *testing.T) { if tc.expErr != nil { require.Error(t, err) require.ErrorAs(t, tc.expErr, &err) - require.Equal(t, sdk.ZeroInt(), shares) + require.Equal(t, osmomath.ZeroInt(), shares) return } @@ -178,10 +178,10 @@ func TestCalcSingleAssetJoin(t *testing.T) { func TestCalcJoinSingleAssetTokensIn(t *testing.T) { testCases := []struct { name string - spreadFactor sdk.Dec + spreadFactor osmomath.Dec poolAssets []balancer.PoolAsset tokensIn sdk.Coins - expectShares sdk.Int + expectShares osmomath.Int expectLiqudity sdk.Coins expErr error }{ @@ -200,10 +200,10 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { // Full solution: https://www.wolframalpha.com/input?i=100000000000000000000*%28%281+%2B+%2850000%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2,499,999,968,750 name: "one token in - equal weights with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(2_499_999_968_750), + expectShares: osmomath.NewInt(2_499_999_968_750), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10: @@ -220,10 +220,10 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { // Full solution: https://www.wolframalpha.com/input?i=100000000000000000000*%28%281+%2B+%2850000%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2,499,999,968,750 name: "two tokens in - equal weights with zero spread factor", - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000), sdk.NewInt64Coin("uatom", 50_000)), - expectShares: sdk.NewInt(2_499_999_968_750 * 2), + expectShares: osmomath.NewInt(2_499_999_968_750 * 2), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) with on page 10 @@ -242,10 +242,10 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-0.5%29+*+0.01%29%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2_487_500_000_000 name: "one token in - equal weights with spread factor of 0.01", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000)), - expectShares: sdk.NewInt(2_487_500_000_000), + expectShares: osmomath.NewInt(2_487_500_000_000), }, { // Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) with on page 10 @@ -264,10 +264,10 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%2850000*%281+-+%281-0.5%29+*+0.01%29%2F1000000000000%29%29%5E0.5+-+1%29 // Simplified: P_issued = 2_487_500_000_000 name: "two tokens in - equal weights with spread factor of 0.01", - spreadFactor: sdk.MustNewDecFromStr("0.01"), + spreadFactor: osmomath.MustNewDecFromStr("0.01"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000), sdk.NewInt64Coin("uatom", 50_000)), - expectShares: sdk.NewInt(2_487_500_000_000 * 2), + expectShares: osmomath.NewInt(2_487_500_000_000 * 2), }, { // For uosmo: @@ -307,34 +307,34 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { // Full solution: https://www.wolframalpha.com/input?i=100+*10%5E18*%28%281+%2B+%28100000*%281+-+%281-%28100+%2F+%28500+%2B+100%29%29%29+*+0.03%29%2F1000000000000%29%29%5E%28100+%2F+%28500+%2B+100%29%29+-+1%29 // Simplified: P_issued = 1_624_999_900_000 name: "two varying tokens in, varying weights, with spread factor of 0.03", - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 2_000_000_000), - Weight: sdk.NewInt(500), + Weight: osmomath.NewInt(500), }, { Token: sdk.NewInt64Coin("uatom", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000), sdk.NewInt64Coin("uatom", 100_000)), - expectShares: sdk.NewInt(2_072_912_400_000_000 + 1_624_999_900_000), + expectShares: osmomath.NewInt(2_072_912_400_000_000 + 1_624_999_900_000), }, { name: "no tokens in", - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), poolAssets: oneTrillionEvenPoolAssets, tokensIn: sdk.NewCoins(), - expectShares: sdk.NewInt(0), + expectShares: osmomath.NewInt(0), }, { name: "one of the tokensIn asset does not exist in pool", - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), poolAssets: oneTrillionEvenPoolAssets, // Second tokenIn does not exist. tokensIn: sdk.NewCoins(sdk.NewInt64Coin("uosmo", 50_000), sdk.NewInt64Coin(doesNotExistDenom, 50_000)), - expectShares: sdk.ZeroInt(), + expectShares: osmomath.ZeroInt(), expErr: fmt.Errorf(balancer.ErrMsgFormatNoPoolAssetFound, doesNotExistDenom), }, } @@ -343,7 +343,7 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { tc := tc t.Run(tc.name, func(t *testing.T) { - pool := createTestPool(t, tc.spreadFactor, sdk.ZeroDec(), tc.poolAssets...) + pool := createTestPool(t, tc.spreadFactor, osmomath.ZeroDec(), tc.poolAssets...) poolAssetsByDenom, err := balancer.GetPoolAssetsByDenom(pool.GetAllPoolAssets()) require.NoError(t, err) @@ -360,7 +360,7 @@ func TestCalcJoinSingleAssetTokensIn(t *testing.T) { if tc.expErr != nil { require.Error(t, err) require.ErrorAs(t, tc.expErr, &err) - require.Equal(t, sdk.ZeroInt(), totalNumShares) + require.Equal(t, osmomath.ZeroInt(), totalNumShares) require.Equal(t, sdk.Coins{}, totalNewLiquidity) return } @@ -402,13 +402,13 @@ func TestGetPoolAssetsByDenom(t *testing.T) { poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, expectedPoolAssetsByDenom: map[string]balancer.PoolAsset{ "uosmo": { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, }, @@ -417,21 +417,21 @@ func TestGetPoolAssetsByDenom(t *testing.T) { poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("atom", 123), - Weight: sdk.NewInt(400), + Weight: osmomath.NewInt(400), }, }, expectedPoolAssetsByDenom: map[string]balancer.PoolAsset{ "uosmo": { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, "atom": { Token: sdk.NewInt64Coin("atom", 123), - Weight: sdk.NewInt(400), + Weight: osmomath.NewInt(400), }, }, }, @@ -440,11 +440,11 @@ func TestGetPoolAssetsByDenom(t *testing.T) { poolAssets: []balancer.PoolAsset{ { Token: sdk.NewInt64Coin("uosmo", 1e12), - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { Token: sdk.NewInt64Coin("uosmo", 123), - Weight: sdk.NewInt(400), + Weight: osmomath.NewInt(400), }, }, err: fmt.Errorf(balancer.ErrMsgFormatRepeatingPoolAssetsNotAllowed, "uosmo"), @@ -552,25 +552,25 @@ func (suite *BalancerTestSuite) TestBalancerCalculateAmountOutAndIn_InverseRelat poolAssetOut := balancer.PoolAsset{ Token: sdk.NewInt64Coin(tc.denomOut, tc.initialPoolOut), - Weight: sdk.NewInt(tc.initialWeightOut), + Weight: osmomath.NewInt(tc.initialWeightOut), } poolAssetIn := balancer.PoolAsset{ Token: sdk.NewInt64Coin(tc.denomIn, tc.initialPoolIn), - Weight: sdk.NewInt(tc.initialWeightIn), + Weight: osmomath.NewInt(tc.initialWeightIn), } - spreadFactorDec, err := sdk.NewDecFromStr(spreadFactor) + spreadFactorDec, err := osmomath.NewDecFromStr(spreadFactor) suite.Require().NoError(err) - exitFeeDec, err := sdk.NewDecFromStr("0") + exitFeeDec, err := osmomath.NewDecFromStr("0") suite.Require().NoError(err) pool := createTestPool(suite.T(), spreadFactorDec, exitFeeDec, poolAssetOut, poolAssetIn) suite.Require().NotNil(pool) errTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.OneDec(), MultiplicativeTolerance: sdk.Dec{}, + AdditiveTolerance: osmomath.OneDec(), MultiplicativeTolerance: osmomath.Dec{}, } sut := func() { test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, poolAssetIn.Token.Denom, poolAssetOut.Token.Denom, tc.initialCalcOut, spreadFactorDec, errTolerance) @@ -657,42 +657,42 @@ func TestCalcSingleAssetInAndOut_InverseRelationship(t *testing.T) { for _, tc := range testcases { for _, spreadFactor := range spreadFactorCases { t.Run(getTestCaseName(tc, spreadFactor), func(t *testing.T) { - spreadFactorDec, err := sdk.NewDecFromStr(spreadFactor) + spreadFactorDec, err := osmomath.NewDecFromStr(spreadFactor) require.NoError(t, err) - initialPoolBalanceOut := sdk.NewInt(tc.initialPoolOut) + initialPoolBalanceOut := osmomath.NewInt(tc.initialPoolOut) - initialWeightOut := sdk.NewInt(tc.initialWeightOut) - initialWeightIn := sdk.NewInt(tc.initialWeightIn) + initialWeightOut := osmomath.NewInt(tc.initialWeightOut) + initialWeightIn := osmomath.NewInt(tc.initialWeightIn) - initialTotalShares := types.InitPoolSharesSupply.ToDec() - initialCalcTokenOut := sdk.NewInt(tc.tokenOut) + initialTotalShares := types.InitPoolSharesSupply.ToLegacyDec() + initialCalcTokenOut := osmomath.NewInt(tc.tokenOut) actualSharesOut := balancer.CalcPoolSharesOutGivenSingleAssetIn( - initialPoolBalanceOut.ToDec(), - initialWeightOut.ToDec().Quo(initialWeightOut.Add(initialWeightIn).ToDec()), + initialPoolBalanceOut.ToLegacyDec(), + initialWeightOut.ToLegacyDec().Quo(initialWeightOut.Add(initialWeightIn).ToLegacyDec()), initialTotalShares, - initialCalcTokenOut.ToDec(), + initialCalcTokenOut.ToLegacyDec(), spreadFactorDec, ) inverseCalcTokenOut := balancer.CalcSingleAssetInGivenPoolSharesOut( - initialPoolBalanceOut.Add(initialCalcTokenOut).ToDec(), - initialWeightOut.ToDec().Quo(initialWeightOut.Add(initialWeightIn).ToDec()), + initialPoolBalanceOut.Add(initialCalcTokenOut).ToLegacyDec(), + initialWeightOut.ToLegacyDec().Quo(initialWeightOut.Add(initialWeightIn).ToLegacyDec()), initialTotalShares.Add(actualSharesOut), actualSharesOut, spreadFactorDec, ) - tol := sdk.NewDec(1) - osmoassert.DecApproxEq(t, initialCalcTokenOut.ToDec(), inverseCalcTokenOut, tol) + tol := osmomath.NewDec(1) + osmoassert.DecApproxEq(t, initialCalcTokenOut.ToLegacyDec(), inverseCalcTokenOut, tol) }) } } } // Expected is un-scaled -func testTotalWeight(t *testing.T, expected sdk.Int, pool balancer.Pool) { +func testTotalWeight(t *testing.T, expected osmomath.Int, pool balancer.Pool) { t.Helper() scaledExpected := expected.MulRaw(balancer.GuaranteedWeightPrecision) require.Equal(t, @@ -706,12 +706,12 @@ func TestBalancerPoolUpdatePoolAssetBalance(t *testing.T) { initialAssets := []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(50000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, } @@ -723,43 +723,43 @@ func TestBalancerPoolUpdatePoolAssetBalance(t *testing.T) { _, err = pacc.GetPoolAsset("") require.Error(t, err) - testTotalWeight(t, sdk.NewInt(300), pacc) + testTotalWeight(t, osmomath.NewInt(300), pacc) // Break abstractions and start reasoning about the underlying internal representation's APIs. // TODO: This test actually just needs to be refactored to not be doing this, and just // create a different pool each time. err = pacc.SetInitialPoolAssets([]balancer.PoolAsset{{ - Weight: sdk.NewInt(-1), - Token: sdk.NewCoin("negativeWeight", sdk.NewInt(50000)), + Weight: osmomath.NewInt(-1), + Token: sdk.NewCoin("negativeWeight", osmomath.NewInt(50000)), }}) require.Error(t, err) err = pacc.SetInitialPoolAssets([]balancer.PoolAsset{{ - Weight: sdk.NewInt(0), - Token: sdk.NewCoin("zeroWeight", sdk.NewInt(50000)), + Weight: osmomath.NewInt(0), + Token: sdk.NewCoin("zeroWeight", osmomath.NewInt(50000)), }}) require.Error(t, err) err = pacc.UpdatePoolAssetBalance( - sdk.NewCoin("test1", sdk.NewInt(0))) + sdk.NewCoin("test1", osmomath.NewInt(0))) require.Error(t, err) err = pacc.UpdatePoolAssetBalance( - sdk.Coin{Denom: "test1", Amount: sdk.NewInt(-1)}, + sdk.Coin{Denom: "test1", Amount: osmomath.NewInt(-1)}, ) require.Error(t, err) err = pacc.UpdatePoolAssetBalance( - sdk.NewCoin("test1", sdk.NewInt(1))) + sdk.NewCoin("test1", osmomath.NewInt(1))) require.NoError(t, err) - testTotalWeight(t, sdk.NewInt(300), pacc) + testTotalWeight(t, osmomath.NewInt(300), pacc) PoolAsset, err := pacc.GetPoolAsset("test1") require.NoError(t, err) - require.Equal(t, sdk.NewInt(1).String(), PoolAsset.Token.Amount.String()) + require.Equal(t, osmomath.NewInt(1).String(), PoolAsset.Token.Amount.String()) } func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { @@ -773,8 +773,8 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(0), - Token: sdk.NewCoin("test1", sdk.NewInt(50000)), + Weight: osmomath.NewInt(0), + Token: sdk.NewCoin("test1", osmomath.NewInt(50000)), }, }, wantErr, @@ -783,8 +783,8 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(-1), - Token: sdk.NewCoin("test1", sdk.NewInt(50000)), + Weight: osmomath.NewInt(-1), + Token: sdk.NewCoin("test1", osmomath.NewInt(50000)), }, }, wantErr, @@ -793,8 +793,8 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(0)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(0)), }, }, wantErr, @@ -803,10 +803,10 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), Token: sdk.Coin{ Denom: "test1", - Amount: sdk.NewInt(-1), + Amount: osmomath.NewInt(-1), }, }, }, @@ -816,12 +816,12 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(10000)), }, }, noErr, @@ -830,16 +830,16 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(300), - Token: sdk.NewCoin("test1", sdk.NewInt(10000)), + Weight: osmomath.NewInt(300), + Token: sdk.NewCoin("test1", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test2", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test2", osmomath.NewInt(10000)), }, }, wantErr, @@ -848,16 +848,16 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { { []balancer.PoolAsset{ { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(7000), - Token: sdk.NewCoin("test3", sdk.NewInt(10000)), + Weight: osmomath.NewInt(7000), + Token: sdk.NewCoin("test3", osmomath.NewInt(10000)), }, }, noErr, @@ -872,7 +872,7 @@ func TestBalancerPoolAssetsWeightAndTokenBalance(t *testing.T) { require.Error(t, err, "unexpected lack of error, tc %v", i) } else { require.NoError(t, err, "unexpected error, tc %v", i) - expectedTotalWeight := sdk.ZeroInt() + expectedTotalWeight := osmomath.ZeroInt() for i, asset := range tc.assets { expectedTotalWeight = expectedTotalWeight.Add(asset.Weight) @@ -896,20 +896,20 @@ func TestGetBalancerPoolAssets(t *testing.T) { assets := []balancer.PoolAsset{ { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test2", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test2", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test1", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test1", osmomath.NewInt(10000)), }, { - Weight: sdk.NewInt(200), - Token: sdk.NewCoin("test3", sdk.NewInt(50000)), + Weight: osmomath.NewInt(200), + Token: sdk.NewCoin("test3", osmomath.NewInt(50000)), }, { - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("test4", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("test4", osmomath.NewInt(10000)), }, } @@ -943,12 +943,12 @@ func TestLBPParamsEmptyStartTime(t *testing.T) { initialPoolAssets := []balancer.PoolAsset{ { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset1", sdk.NewInt(1000)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset1", osmomath.NewInt(1000)), }, { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset2", sdk.NewInt(1000)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset2", osmomath.NewInt(1000)), }, } @@ -956,12 +956,12 @@ func TestLBPParamsEmptyStartTime(t *testing.T) { Duration: defaultDuration, TargetPoolWeights: []balancer.PoolAsset{ { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset1", sdk.NewInt(0)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset1", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(2), - Token: sdk.NewCoin("asset2", sdk.NewInt(0)), + Weight: osmomath.NewInt(2), + Token: sdk.NewCoin("asset2", osmomath.NewInt(0)), }, }, } @@ -991,7 +991,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { // is already handled. type testCase struct { blockTime time.Time - expectedWeights []sdk.Int + expectedWeights []osmomath.Int } // Tests how the pool weights get updated via PokeTokenWeights at different block times. @@ -1011,22 +1011,22 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { Duration: defaultDuration, InitialPoolWeights: []balancer.PoolAsset{ { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset1", sdk.NewInt(0)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset1", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset2", sdk.NewInt(0)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset2", osmomath.NewInt(0)), }, }, TargetPoolWeights: []balancer.PoolAsset{ { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset1", sdk.NewInt(0)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset1", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(2), - Token: sdk.NewCoin("asset2", sdk.NewInt(0)), + Weight: osmomath.NewInt(2), + Token: sdk.NewCoin("asset2", osmomath.NewInt(0)), }, }, }, @@ -1034,19 +1034,19 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { { // Halfway through at 50 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+50, 0), - expectedWeights: []sdk.Int{ - sdk.NewInt(1 * balancer.GuaranteedWeightPrecision), + expectedWeights: []osmomath.Int{ + osmomath.NewInt(1 * balancer.GuaranteedWeightPrecision), // Halfway between 1 & 2 - sdk.NewInt(3 * balancer.GuaranteedWeightPrecision / 2), + osmomath.NewInt(3 * balancer.GuaranteedWeightPrecision / 2), }, }, { // Quarter way through at 25 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+25, 0), - expectedWeights: []sdk.Int{ - sdk.NewInt(1 * balancer.GuaranteedWeightPrecision), + expectedWeights: []osmomath.Int{ + osmomath.NewInt(1 * balancer.GuaranteedWeightPrecision), // Quarter way between 1 & 2 = 1.25 - sdk.NewInt(int64(1.25 * floatGuaranteedPrecision)), + osmomath.NewInt(int64(1.25 * floatGuaranteedPrecision)), }, }, }, @@ -1059,22 +1059,22 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { Duration: defaultDuration, InitialPoolWeights: []balancer.PoolAsset{ { - Weight: sdk.NewInt(2), - Token: sdk.NewCoin("asset1", sdk.NewInt(0)), + Weight: osmomath.NewInt(2), + Token: sdk.NewCoin("asset1", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(2), - Token: sdk.NewCoin("asset2", sdk.NewInt(0)), + Weight: osmomath.NewInt(2), + Token: sdk.NewCoin("asset2", osmomath.NewInt(0)), }, }, TargetPoolWeights: []balancer.PoolAsset{ { - Weight: sdk.NewInt(4), - Token: sdk.NewCoin("asset1", sdk.NewInt(0)), + Weight: osmomath.NewInt(4), + Token: sdk.NewCoin("asset1", osmomath.NewInt(0)), }, { - Weight: sdk.NewInt(1), - Token: sdk.NewCoin("asset2", sdk.NewInt(0)), + Weight: osmomath.NewInt(1), + Token: sdk.NewCoin("asset2", osmomath.NewInt(0)), }, }, }, @@ -1082,21 +1082,21 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { { // Halfway through at 50 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+50, 0), - expectedWeights: []sdk.Int{ + expectedWeights: []osmomath.Int{ // Halfway between 2 & 4 - sdk.NewInt(6 * balancer.GuaranteedWeightPrecision / 2), + osmomath.NewInt(6 * balancer.GuaranteedWeightPrecision / 2), // Halfway between 1 & 2 - sdk.NewInt(3 * balancer.GuaranteedWeightPrecision / 2), + osmomath.NewInt(3 * balancer.GuaranteedWeightPrecision / 2), }, }, { // Quarter way through at 25 seconds elapsed blockTime: time.Unix(defaultStartTimeUnix+25, 0), - expectedWeights: []sdk.Int{ + expectedWeights: []osmomath.Int{ // Quarter way between 2 & 4 = 2.5 - sdk.NewInt(int64(2.5 * floatGuaranteedPrecision)), + osmomath.NewInt(int64(2.5 * floatGuaranteedPrecision)), // Quarter way between 2 & 1 = 1.75 - sdk.NewInt(int64(1.75 * floatGuaranteedPrecision)), + osmomath.NewInt(int64(1.75 * floatGuaranteedPrecision)), }, }, }, @@ -1109,8 +1109,8 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { timeBeforeWeightChangeStart := time.Unix(params.StartTime.Unix()-1, 0) timeAtWeightChangeEnd := params.StartTime.Add(params.Duration) timeAfterWeightChangeEnd := time.Unix(timeAtWeightChangeEnd.Unix()+1, 0) - initialWeights := make([]sdk.Int, len(params.InitialPoolWeights)) - finalWeights := make([]sdk.Int, len(params.TargetPoolWeights)) + initialWeights := make([]osmomath.Int, len(params.InitialPoolWeights)) + finalWeights := make([]osmomath.Int, len(params.TargetPoolWeights)) for i, v := range params.InitialPoolWeights { initialWeights[i] = v.Weight.MulRaw(balancer.GuaranteedWeightPrecision) } @@ -1173,7 +1173,7 @@ func TestBalancerPoolPokeTokenWeights(t *testing.T) { for caseNum, testCase := range testCases { pacc.PokePool(testCase.blockTime) - totalWeight := sdk.ZeroInt() + totalWeight := osmomath.ZeroInt() for assetNum, asset := range pacc.GetAllPoolAssets() { require.Equal(t, testCase.expectedWeights[assetNum], asset.Weight, @@ -1217,118 +1217,118 @@ func TestIsActive(t *testing.T) { func TestCalcJoinPoolNoSwapShares(t *testing.T) { balancerPoolAssets := []balancer.PoolAsset{ - {Token: sdk.NewInt64Coin("foo", 100), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("bar", 100), Weight: sdk.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("foo", 100), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("bar", 100), Weight: osmomath.NewIntFromUint64(5)}, } balancerThreePoolAssets := []balancer.PoolAsset{ - {Token: sdk.NewInt64Coin("foo", 100), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("bar", 100), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("baz", 100), Weight: sdk.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("foo", 100), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("bar", 100), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("baz", 100), Weight: osmomath.NewIntFromUint64(5)}, } tests := map[string]struct { tokensIn sdk.Coins poolAssets []balancer.PoolAsset - expNumShare sdk.Int + expNumShare osmomath.Int expTokensJoined sdk.Coins expPoolAssets []balancer.PoolAsset expectPass bool }{ "two asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10))), poolAssets: balancerPoolAssets, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10))), expPoolAssets: balancerPoolAssets, expectPass: true, }, "two asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(11))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(11))), poolAssets: balancerPoolAssets, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10))), expPoolAssets: balancerPoolAssets, expectPass: true, }, "three asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10)), sdk.NewCoin("baz", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10)), sdk.NewCoin("baz", osmomath.NewInt(10))), poolAssets: balancerThreePoolAssets, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10)), sdk.NewCoin("baz", sdk.NewInt(10))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10)), sdk.NewCoin("baz", osmomath.NewInt(10))), expPoolAssets: balancerThreePoolAssets, expectPass: true, }, "three asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10)), sdk.NewCoin("baz", sdk.NewInt(11))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10)), sdk.NewCoin("baz", osmomath.NewInt(11))), poolAssets: balancerThreePoolAssets, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10)), sdk.NewCoin("baz", sdk.NewInt(10))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10)), sdk.NewCoin("baz", osmomath.NewInt(10))), expPoolAssets: balancerThreePoolAssets, expectPass: true, }, "two asset pool, no-swap join attempt with one asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10))), poolAssets: balancerPoolAssets, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: balancerPoolAssets, expectPass: false, }, "two asset pool, no-swap join attempt with one valid and one invalid asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("baz", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("baz", osmomath.NewInt(10))), poolAssets: balancerPoolAssets, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: balancerPoolAssets, expectPass: false, }, "two asset pool, no-swap join attempt with two invalid assets": { - tokensIn: sdk.NewCoins(sdk.NewCoin("baz", sdk.NewInt(10)), sdk.NewCoin("qux", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("baz", osmomath.NewInt(10)), sdk.NewCoin("qux", osmomath.NewInt(10))), poolAssets: balancerPoolAssets, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: balancerPoolAssets, expectPass: false, }, "three asset pool, no-swap join attempt with an invalid asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10)), sdk.NewCoin("qux", sdk.NewInt(10))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10)), sdk.NewCoin("qux", osmomath.NewInt(10))), poolAssets: balancerThreePoolAssets, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: balancerThreePoolAssets, expectPass: false, }, "single asset pool, no-swap join attempt with one asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(sdk.MaxSortableDec.TruncateInt64()))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(sdk.MaxSortableDec.TruncateInt64()))), poolAssets: []balancer.PoolAsset{ - {Token: sdk.NewCoin("foo", sdk.NewInt(1)), Weight: sdk.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(1)), Weight: osmomath.NewIntFromUint64(1)}, }, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: []balancer.PoolAsset{ - {Token: sdk.NewCoin("foo", sdk.NewInt(1)), Weight: sdk.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(1)), Weight: osmomath.NewIntFromUint64(1)}, }, expectPass: false, }, "duplicate asset pool, no-swap join attempt with duplicate assets": { - tokensIn: sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(1)), sdk.NewCoin("foo", sdk.NewInt(1))}, + tokensIn: sdk.Coins{sdk.NewCoin("foo", osmomath.NewInt(1)), sdk.NewCoin("foo", osmomath.NewInt(1))}, poolAssets: []balancer.PoolAsset{ - {Token: sdk.NewCoin("foo", sdk.NewInt(100)), Weight: sdk.NewIntFromUint64(1)}, - {Token: sdk.NewCoin("foo", sdk.NewInt(100)), Weight: sdk.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(100)), Weight: osmomath.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(100)), Weight: osmomath.NewIntFromUint64(1)}, }, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: []balancer.PoolAsset{ - {Token: sdk.NewCoin("foo", sdk.NewInt(100)), Weight: sdk.NewIntFromUint64(1)}, - {Token: sdk.NewCoin("foo", sdk.NewInt(100)), Weight: sdk.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(100)), Weight: osmomath.NewIntFromUint64(1)}, + {Token: sdk.NewCoin("foo", osmomath.NewInt(100)), Weight: osmomath.NewIntFromUint64(1)}, }, expectPass: false, }, "attempt joining pool with no assets in it": { - tokensIn: sdk.Coins{sdk.NewCoin("foo", sdk.NewInt(1)), sdk.NewCoin("foo", sdk.NewInt(1))}, + tokensIn: sdk.Coins{sdk.NewCoin("foo", osmomath.NewInt(1)), sdk.NewCoin("foo", osmomath.NewInt(1))}, poolAssets: []balancer.PoolAsset{}, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: []balancer.PoolAsset{}, expectPass: false, diff --git a/x/gamm/pool-models/balancer/util_test.go b/x/gamm/pool-models/balancer/util_test.go index 581905bb0fa..09f4d58dc99 100644 --- a/x/gamm/pool-models/balancer/util_test.go +++ b/x/gamm/pool-models/balancer/util_test.go @@ -12,7 +12,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" ) -func createTestPool(t *testing.T, spreadFactor, exitFee sdk.Dec, poolAssets ...balancer.PoolAsset) *balancer.Pool { +func createTestPool(t *testing.T, spreadFactor, exitFee osmomath.Dec, poolAssets ...balancer.PoolAsset) *balancer.Pool { t.Helper() pool, err := balancer.NewBalancerPool( 1, @@ -26,9 +26,9 @@ func createTestPool(t *testing.T, spreadFactor, exitFee sdk.Dec, poolAssets ...b return &pool } -func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares sdk.Int) { +func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares osmomath.Int) { t.Helper() - allowedErrRatioDec, err := sdk.NewDecFromStr(allowedErrRatio) + allowedErrRatioDec, err := osmomath.NewDecFromStr(allowedErrRatio) require.NoError(t, err) errTolerance := osmomath.ErrTolerance{ diff --git a/x/gamm/pool-models/internal/cfmm_common/lp.go b/x/gamm/pool-models/internal/cfmm_common/lp.go index 48f042d3a04..5755df18f3b 100644 --- a/x/gamm/pool-models/internal/cfmm_common/lp.go +++ b/x/gamm/pool-models/internal/cfmm_common/lp.go @@ -14,21 +14,21 @@ import ( const errMsgFormatSharesLargerThanMax = "cannot exit all shares in a pool. Attempted to exit %s shares, max allowed is %s" // CalcExitPool returns how many tokens should come out, when exiting k LP shares against a "standard" CFMM -func CalcExitPool(ctx sdk.Context, pool types.CFMMPoolI, exitingShares sdk.Int, exitFee sdk.Dec) (sdk.Coins, error) { +func CalcExitPool(ctx sdk.Context, pool types.CFMMPoolI, exitingShares osmomath.Int, exitFee osmomath.Dec) (sdk.Coins, error) { totalShares := pool.GetTotalShares() if exitingShares.GTE(totalShares) { - return sdk.Coins{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, errMsgFormatSharesLargerThanMax, exitingShares, totalShares.Sub(sdk.OneInt())) + return sdk.Coins{}, errorsmod.Wrapf(types.ErrLimitMaxAmount, errMsgFormatSharesLargerThanMax, exitingShares, totalShares.Sub(osmomath.OneInt())) } // refundedShares = exitingShares * (1 - exit fee) // with 0 exit fee optimization - var refundedShares sdk.Dec + var refundedShares osmomath.Dec if !exitFee.IsZero() { // exitingShares * (1 - exit fee) - oneSubExitFee := sdk.OneDec().Sub(exitFee) + oneSubExitFee := osmomath.OneDec().Sub(exitFee) refundedShares = oneSubExitFee.MulIntMut(exitingShares) } else { - refundedShares = exitingShares.ToDec() + refundedShares = exitingShares.ToLegacyDec() } shareOutRatio := refundedShares.QuoInt(totalShares) @@ -39,7 +39,7 @@ func CalcExitPool(ctx sdk.Context, pool types.CFMMPoolI, exitingShares sdk.Int, for _, asset := range poolLiquidity { // round down here, due to not wanting to over-exit exitAmt := shareOutRatio.MulInt(asset.Amount).TruncateInt() - if exitAmt.LTE(sdk.ZeroInt()) { + if exitAmt.LTE(osmomath.ZeroInt()) { continue } if exitAmt.GTE(asset.Amount) { @@ -63,10 +63,10 @@ func CalcExitPool(ctx sdk.Context, pool types.CFMMPoolI, exitingShares sdk.Int, // 1. iterate through all the tokens provided as an argument, calculate how much ratio it accounts for the asset in the pool // 2. get the minimal share ratio that would work as the benchmark for all tokens. // 3. calculate the number of shares that could be joined (total share * min share ratio), return the remaining coins -func MaximalExactRatioJoin(p types.CFMMPoolI, ctx sdk.Context, tokensIn sdk.Coins) (numShares sdk.Int, remCoins sdk.Coins, err error) { - coinShareRatios := make([]sdk.Dec, len(tokensIn)) +func MaximalExactRatioJoin(p types.CFMMPoolI, ctx sdk.Context, tokensIn sdk.Coins) (numShares osmomath.Int, remCoins sdk.Coins, err error) { + coinShareRatios := make([]osmomath.Dec, len(tokensIn)) minShareRatio := sdk.MaxSortableDec - maxShareRatio := sdk.ZeroDec() + maxShareRatio := osmomath.ZeroDec() poolLiquidity := p.GetTotalPoolLiquidity(ctx) totalShares := p.GetTotalShares() @@ -75,7 +75,7 @@ func MaximalExactRatioJoin(p types.CFMMPoolI, ctx sdk.Context, tokensIn sdk.Coin // Note: QuoInt implements floor division, unlike Quo // This is because it calls the native golang routine big.Int.Quo // https://pkg.go.dev/math/big#Int.Quo - shareRatio := coin.Amount.ToDec().QuoInt(poolLiquidity.AmountOfNoDenomValidation(coin.Denom)) + shareRatio := coin.Amount.ToLegacyDec().QuoInt(poolLiquidity.AmountOfNoDenomValidation(coin.Denom)) if shareRatio.LT(minShareRatio) { minShareRatio = shareRatio } @@ -126,42 +126,42 @@ func MaximalExactRatioJoin(p types.CFMMPoolI, ctx sdk.Context, tokensIn sdk.Coin func BinarySearchSingleAssetJoin( pool types.CFMMPoolI, tokenIn sdk.Coin, - poolWithAddedLiquidityAndShares func(newLiquidity sdk.Coin, newShares sdk.Int) types.CFMMPoolI, -) (numLPShares sdk.Int, err error) { + poolWithAddedLiquidityAndShares func(newLiquidity sdk.Coin, newShares osmomath.Int) types.CFMMPoolI, +) (numLPShares osmomath.Int, err error) { // use dummy context ctx := sdk.Context{} - // should be guaranteed to converge if above 256 since sdk.Int has 256 bits + // should be guaranteed to converge if above 256 since osmomath.Int has 256 bits maxIterations := 300 // upperbound of number of LP shares = existingShares * tokenIn.Amount / pool.totalLiquidity.AmountOf(tokenIn.Denom) existingTokenLiquidity := pool.GetTotalPoolLiquidity(ctx).AmountOf(tokenIn.Denom) existingLPShares := pool.GetTotalShares() - LPShareUpperBound := existingLPShares.Mul(tokenIn.Amount).ToDec().QuoInt(existingTokenLiquidity).Ceil().TruncateInt() - LPShareLowerBound := sdk.ZeroInt() + LPShareUpperBound := existingLPShares.Mul(tokenIn.Amount).ToLegacyDec().QuoInt(existingTokenLiquidity).Ceil().TruncateInt() + LPShareLowerBound := osmomath.ZeroInt() // Creates a pool with tokenIn liquidity added, where it created `sharesIn` number of shares. // Returns how many tokens you'd get, if you then exited all of `sharesIn` for tokenIn.Denom - estimateCoinOutGivenShares := func(sharesIn sdk.Int) (tokenOut sdk.Int, err error) { + estimateCoinOutGivenShares := func(sharesIn osmomath.Int) (tokenOut osmomath.Int, err error) { // new pool with added liquidity & LP shares, which we can mutate. poolWithUpdatedLiquidity := poolWithAddedLiquidityAndShares(tokenIn, sharesIn) swapToDenom := tokenIn.Denom // so now due to correctness of exitPool, we exitPool and swap all remaining assets to base asset - exitFee := sdk.ZeroDec() + exitFee := osmomath.ZeroDec() exitedCoins, err := poolWithUpdatedLiquidity.ExitPool(ctx, sharesIn, exitFee) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } - return SwapAllCoinsToSingleAsset(poolWithUpdatedLiquidity, ctx, exitedCoins, swapToDenom, sdk.ZeroDec()) + return SwapAllCoinsToSingleAsset(poolWithUpdatedLiquidity, ctx, exitedCoins, swapToDenom, osmomath.ZeroDec()) } // We accept an additive tolerance of 1 LP share error and round down - errTolerance := osmomath.ErrTolerance{AdditiveTolerance: sdk.OneDec(), MultiplicativeTolerance: sdk.Dec{}, RoundingDir: osmomath.RoundDown} + errTolerance := osmomath.ErrTolerance{AdditiveTolerance: osmomath.OneDec(), MultiplicativeTolerance: osmomath.Dec{}, RoundingDir: osmomath.RoundDown} numLPShares, err = osmomath.BinarySearch( estimateCoinOutGivenShares, LPShareLowerBound, LPShareUpperBound, tokenIn.Amount, errTolerance, maxIterations) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return numLPShares, nil @@ -169,8 +169,8 @@ func BinarySearchSingleAssetJoin( // SwapAllCoinsToSingleAsset iterates through each token in the input set and trades it against the same pool sequentially func SwapAllCoinsToSingleAsset(pool types.CFMMPoolI, ctx sdk.Context, inTokens sdk.Coins, swapToDenom string, - spreadFactor sdk.Dec, -) (sdk.Int, error) { + spreadFactor osmomath.Dec, +) (osmomath.Int, error) { tokenOutAmt := inTokens.AmountOfNoDenomValidation(swapToDenom) for _, coin := range inTokens { if coin.Denom == swapToDenom { @@ -178,7 +178,7 @@ func SwapAllCoinsToSingleAsset(pool types.CFMMPoolI, ctx sdk.Context, inTokens s } tokenOut, err := pool.SwapOutAmtGivenIn(ctx, sdk.NewCoins(coin), swapToDenom, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmt = tokenOutAmt.Add(tokenOut.Amount) } diff --git a/x/gamm/pool-models/internal/cfmm_common/lp_test.go b/x/gamm/pool-models/internal/cfmm_common/lp_test.go index d7411cbbaf7..b35d6c8616f 100644 --- a/x/gamm/pool-models/internal/cfmm_common/lp_test.go +++ b/x/gamm/pool-models/internal/cfmm_common/lp_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/internal/cfmm_common" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" @@ -16,7 +17,7 @@ import ( ) // a helper function used to multiply coins -func mulCoins(coins sdk.Coins, multiplier sdk.Dec) sdk.Coins { +func mulCoins(coins sdk.Coins, multiplier osmomath.Dec) sdk.Coins { outCoins := sdk.Coins{} for _, coin := range coins { outCoin := sdk.NewCoin(coin.Denom, multiplier.MulInt(coin.Amount).TruncateInt()) @@ -36,15 +37,15 @@ func TestCalcExitPool(t *testing.T) { ) threeBalancerPoolAssets := []balancer.PoolAsset{ - {Token: sdk.NewInt64Coin("foo", 2000000000), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("bar", 3000000000), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("baz", 4000000000), Weight: sdk.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("foo", 2000000000), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("bar", 3000000000), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("baz", 4000000000), Weight: osmomath.NewIntFromUint64(5)}, } // create these pools used for testing twoAssetPool, err := stableswap.NewStableswapPool( 1, - stableswap.PoolParams{ExitFee: sdk.ZeroDec()}, + stableswap.PoolParams{ExitFee: osmomath.ZeroDec()}, twoStablePoolAssets, []uint64{1, 1}, "", @@ -54,7 +55,7 @@ func TestCalcExitPool(t *testing.T) { threeAssetPool, err := balancer.NewBalancerPool( 1, - balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.ZeroDec()}, + balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.ZeroDec()}, threeBalancerPoolAssets, "", time.Now(), @@ -63,7 +64,7 @@ func TestCalcExitPool(t *testing.T) { twoAssetPoolWithExitFee, err := stableswap.NewStableswapPool( 1, - stableswap.PoolParams{ExitFee: sdk.MustNewDecFromStr("0.0001")}, + stableswap.PoolParams{ExitFee: osmomath.MustNewDecFromStr("0.0001")}, twoStablePoolAssets, []uint64{1, 1}, "", @@ -73,7 +74,7 @@ func TestCalcExitPool(t *testing.T) { threeAssetPoolWithExitFee, err := balancer.NewBalancerPool( 1, - balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.MustNewDecFromStr("0.0002")}, + balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.MustNewDecFromStr("0.0002")}, threeBalancerPoolAssets, "", time.Now(), @@ -83,7 +84,7 @@ func TestCalcExitPool(t *testing.T) { tests := []struct { name string pool gammtypes.CFMMPoolI - exitingShares sdk.Int + exitingShares osmomath.Int expError bool }{ { @@ -107,7 +108,7 @@ func TestCalcExitPool(t *testing.T) { { name: "three-asset pool, valid exiting shares", pool: &threeAssetPool, - exitingShares: sdk.NewIntFromUint64(3000000000000), + exitingShares: osmomath.NewIntFromUint64(3000000000000), expError: false, }, { @@ -119,7 +120,7 @@ func TestCalcExitPool(t *testing.T) { { name: "three-asset pool with exit fee, valid exiting shares", pool: &threeAssetPoolWithExitFee, - exitingShares: sdk.NewIntFromUint64(7000000000000), + exitingShares: osmomath.NewIntFromUint64(7000000000000), expError: false, }, } @@ -134,7 +135,7 @@ func TestCalcExitPool(t *testing.T) { require.NoError(t, err, "test: %v", test.name) // exitCoins = ( (1 - exitFee) * exitingShares / poolTotalShares ) * poolTotalLiquidity - expExitCoins := mulCoins(test.pool.GetTotalPoolLiquidity(emptyContext), (sdk.OneDec().Sub(exitFee)).MulInt(test.exitingShares).QuoInt(test.pool.GetTotalShares())) + expExitCoins := mulCoins(test.pool.GetTotalPoolLiquidity(emptyContext), (osmomath.OneDec().Sub(exitFee)).MulInt(test.exitingShares).QuoInt(test.pool.GetTotalShares())) require.Equal(t, expExitCoins.Sort().String(), exitCoins.Sort().String(), "test: %v", test.name) } } @@ -144,15 +145,15 @@ func TestMaximalExactRatioJoin(t *testing.T) { emptyContext := sdk.Context{} balancerPoolAsset := []balancer.PoolAsset{ - {Token: sdk.NewInt64Coin("foo", 100), Weight: sdk.NewIntFromUint64(5)}, - {Token: sdk.NewInt64Coin("bar", 100), Weight: sdk.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("foo", 100), Weight: osmomath.NewIntFromUint64(5)}, + {Token: sdk.NewInt64Coin("bar", 100), Weight: osmomath.NewIntFromUint64(5)}, } tests := []struct { name string pool func() poolmanagertypes.PoolI tokensIn sdk.Coins - expNumShare sdk.Int + expNumShare osmomath.Int expRemCoin sdk.Coins }{ { @@ -160,7 +161,7 @@ func TestMaximalExactRatioJoin(t *testing.T) { pool: func() poolmanagertypes.PoolI { balancerPool, err := balancer.NewBalancerPool( 1, - balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.ZeroDec()}, + balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.ZeroDec()}, balancerPoolAsset, "", time.Now(), @@ -168,8 +169,8 @@ func TestMaximalExactRatioJoin(t *testing.T) { require.NoError(t, err) return &balancerPool }, - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(10))), - expNumShare: sdk.NewIntFromUint64(10000000000000000000), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(10))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), expRemCoin: sdk.Coins{}, }, { @@ -177,7 +178,7 @@ func TestMaximalExactRatioJoin(t *testing.T) { pool: func() poolmanagertypes.PoolI { balancerPool, err := balancer.NewBalancerPool( 1, - balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.ZeroDec()}, + balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.ZeroDec()}, balancerPoolAsset, "", time.Now(), @@ -185,16 +186,16 @@ func TestMaximalExactRatioJoin(t *testing.T) { require.NoError(t, err) return &balancerPool }, - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10)), sdk.NewCoin("bar", sdk.NewInt(11))), - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expRemCoin: sdk.NewCoins(sdk.NewCoin("bar", sdk.NewIntFromUint64(1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10)), sdk.NewCoin("bar", osmomath.NewInt(11))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expRemCoin: sdk.NewCoins(sdk.NewCoin("bar", osmomath.NewIntFromUint64(1))), }, } for _, test := range tests { balancerPool, err := balancer.NewBalancerPool( 1, - balancer.PoolParams{SwapFee: sdk.ZeroDec(), ExitFee: sdk.ZeroDec()}, + balancer.PoolParams{SwapFee: osmomath.ZeroDec(), ExitFee: osmomath.ZeroDec()}, balancerPoolAsset, "", time.Now(), diff --git a/x/gamm/pool-models/internal/test_helpers/test_helpers.go b/x/gamm/pool-models/internal/test_helpers/test_helpers.go index b53a008fc1b..18dd0ff844a 100644 --- a/x/gamm/pool-models/internal/test_helpers/test_helpers.go +++ b/x/gamm/pool-models/internal/test_helpers/test_helpers.go @@ -39,7 +39,7 @@ func TestCalculateAmountOutAndIn_InverseRelationship( assetInDenom string, assetOutDenom string, initialCalcOut int64, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, errTolerance osmomath.ErrTolerance, ) { initialOut := sdk.NewInt64Coin(assetOutDenom, initialCalcOut) @@ -49,26 +49,26 @@ func TestCalculateAmountOutAndIn_InverseRelationship( require.NoError(t, err) // we expect that any output less than 1 will always be rounded up - require.True(t, actualTokenIn.Amount.GTE(sdk.OneInt())) + require.True(t, actualTokenIn.Amount.GTE(osmomath.OneInt())) inverseTokenOut, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(actualTokenIn), assetOutDenom, spreadFactor) require.NoError(t, err) require.Equal(t, initialOut.Denom, inverseTokenOut.Denom) - expected := initialOut.Amount.ToDec() - actual := inverseTokenOut.Amount.ToDec() + expected := initialOut.Amount.ToLegacyDec() + actual := inverseTokenOut.Amount.ToLegacyDec() // If the pool is extremely imbalanced (specifically in the case of stableswap), // we expect there to be drastically amplified error that will fall outside our usual bounds. // Since these cases are effectively unusable by design, we only really care about whether // they are safe i.e. round correctly. - preFeeTokenIn := actualTokenIn.Amount.ToDec().Mul((sdk.OneDec().Sub(spreadFactor))).Ceil().TruncateInt() - if preFeeTokenIn.Equal(sdk.OneInt()) { + preFeeTokenIn := actualTokenIn.Amount.ToLegacyDec().Mul((osmomath.OneDec().Sub(spreadFactor))).Ceil().TruncateInt() + if preFeeTokenIn.Equal(osmomath.OneInt()) { require.True(t, actual.GT(expected)) } else { - if expected.Sub(actual).Abs().GT(sdk.OneDec()) { - compRes := errTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(expected), osmomath.BigDecFromSDKDec(actual)) + if expected.Sub(actual).Abs().GT(osmomath.OneDec()) { + compRes := errTolerance.CompareBigDec(osmomath.BigDecFromDec(expected), osmomath.BigDecFromDec(actual)) require.True(t, compRes == 0, "expected %s, actual %s, not within error tolerance %v", expected, actual, errTolerance) } @@ -139,7 +139,7 @@ func TestSlippageRelationInGivenOut( for !isWithinBounds(ctx, curPool, swapOutAmt, swapInDenom, fee) { // increase pool liquidity by 10x for i, coin := range initLiquidity { - curLiquidity[i] = sdk.NewCoin(coin.Denom, coin.Amount.Mul(sdk.NewInt(10))) + curLiquidity[i] = sdk.NewCoin(coin.Denom, coin.Amount.Mul(osmomath.NewInt(10))) } curPool = createPoolWithLiquidity(ctx, curLiquidity) } @@ -164,7 +164,7 @@ func TestSlippageRelationInGivenOut( } // returns true if the pool can accommodate an InGivenOut swap with `tokenOut` amount out, false otherwise -func isWithinBounds(ctx sdk.Context, pool types.CFMMPoolI, tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (b bool) { +func isWithinBounds(ctx sdk.Context, pool types.CFMMPoolI, tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (b bool) { b = true defer func() { if r := recover(); r != nil { diff --git a/x/gamm/pool-models/stableswap/README.md b/x/gamm/pool-models/stableswap/README.md index d4f042b586d..735fb3d4fb1 100644 --- a/x/gamm/pool-models/stableswap/README.md +++ b/x/gamm/pool-models/stableswap/README.md @@ -68,14 +68,14 @@ We detail rounding modes and scaling details as pseudocode in the relevant secti The AMM pool interfaces requires implementing the following stateful methods: ```golang - SwapOutAmtGivenIn(tokenIn sdk.Coins, tokenOutDenom string, spreadFactor sdk.Dec) (tokenOut sdk.Coin, err error) - SwapInAmtGivenOut(tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (tokenIn sdk.Coin, err error) + SwapOutAmtGivenIn(tokenIn sdk.Coins, tokenOutDenom string, spreadFactor osmomath.Dec) (tokenOut sdk.Coin, err error) + SwapInAmtGivenOut(tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (tokenIn sdk.Coin, err error) - SpotPrice(baseAssetDenom string, quoteAssetDenom string) (sdk.Dec, error) + SpotPrice(baseAssetDenom string, quoteAssetDenom string) (osmomath.Dec, error) - JoinPool(tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) - JoinPoolNoSwap(tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) - ExitPool(numShares sdk.Int, exitFee sdk.Dec) (exitedCoins sdk.Coins, err error) + JoinPool(tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) + JoinPoolNoSwap(tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) + ExitPool(numShares osmomath.Int, exitFee osmomath.Dec) (exitedCoins sdk.Coins, err error) ``` The "constant" part of CFMM's imply that we can reason about all their necessary algorithms from just the CFMM equation. There are still multiple ways to solve each method. We detail below the ways in which we do so. This is organized by first discussing variable substitutions we do, to be in a more amenable form, and then the details of how we implement each method. diff --git a/x/gamm/pool-models/stableswap/amm.go b/x/gamm/pool-models/stableswap/amm.go index bc3133bcb80..641a7e334a2 100644 --- a/x/gamm/pool-models/stableswap/amm.go +++ b/x/gamm/pool-models/stableswap/amm.go @@ -39,7 +39,7 @@ func cfmmConstantMultiNoVY(xReserve, yReserve, wSumSquares osmomath.BigDec) osmo // xy(x^2 + y^2 + w) = (x - a)(y + b)((x - a)^2 + (y + b)^2 + w) // with w set to 0 for 2 asset pools func solveCfmm(xReserve, yReserve osmomath.BigDec, remReserves []osmomath.BigDec, yIn osmomath.BigDec) osmomath.BigDec { - wSumSquares := osmomath.ZeroDec() + wSumSquares := osmomath.ZeroBigDec() for _, assetReserve := range remReserves { wSumSquares = wSumSquares.Add(assetReserve.Mul(assetReserve)) } @@ -64,7 +64,7 @@ func targetKCalculator(x0, y0, w, yf osmomath.BigDec) osmomath.BigDec { // where x_out = x_0 - x_f func iterKCalculator(x0, w, yf osmomath.BigDec) func(osmomath.BigDec) osmomath.BigDec { // compute coefficients first - cubicCoeff := osmomath.OneDec().Neg() + cubicCoeff := osmomath.OneBigDec().Neg() quadraticCoeff := x0.MulInt64(3) linearCoeff := quadraticCoeff.Mul(x0).Add(w).Add(yf.Mul(yf)).Neg() return func(xf osmomath.BigDec) osmomath.BigDec { @@ -79,8 +79,8 @@ func iterKCalculator(x0, w, yf osmomath.BigDec) func(osmomath.BigDec) osmomath.B } var ( - zero = osmomath.ZeroDec() - one = osmomath.OneDec() + zero = osmomath.ZeroBigDec() + one = osmomath.OneBigDec() ) func deriveUpperLowerXFinalReserveBounds(xReserve, yReserve, wSumSquares, yFinal osmomath.BigDec) ( @@ -102,7 +102,7 @@ func deriveUpperLowerXFinalReserveBounds(xReserve, yReserve, wSumSquares, yFinal xFinalUpperbound = xReserve.Quo(kRatio).Ceil() } else if kRatio.GT(one) { // need to find a lowerbound. We could use a cubic relation, but for now we just set it to 0. - xFinalLowerbound = osmomath.ZeroDec() + xFinalLowerbound = osmomath.ZeroBigDec() } // else // k remains unchanged. @@ -125,7 +125,7 @@ func solveCFMMBinarySearchMulti(xReserve, yReserve, wSumSquares, yIn osmomath.Bi maxIterations := 256 // we use a geometric error tolerance that guarantees approximately 10^-12 precision on outputs - errTolerance := osmomath.ErrTolerance{AdditiveTolerance: sdk.Dec{}, MultiplicativeTolerance: sdk.NewDecWithPrec(1, 12)} + errTolerance := osmomath.ErrTolerance{AdditiveTolerance: osmomath.Dec{}, MultiplicativeTolerance: osmomath.NewDecWithPrec(1, 12)} // if yIn is positive, we want to under-estimate the amount of xOut. // This means, we want x_out to be rounded down, as x_out = x_init - x_final, for x_init > x_final. @@ -155,7 +155,7 @@ func solveCFMMBinarySearchMulti(xReserve, yReserve, wSumSquares, yIn osmomath.Bi return xOut } -func (p Pool) spotPrice(quoteDenom, baseDenom string) (spotPrice sdk.Dec, err error) { +func (p Pool) spotPrice(quoteDenom, baseDenom string) (spotPrice osmomath.Dec, err error) { // Define f_{y -> x}(a) as the function that outputs the amount of tokens X you'd get by // trading "a" units of Y against the pool, assuming 0 spread factor, at the current liquidity. // The spot price of the pool is then lim a -> 0, f_{y -> x}(a) / a @@ -169,28 +169,28 @@ func (p Pool) spotPrice(quoteDenom, baseDenom string) (spotPrice sdk.Dec, err er // We arbitrarily choose a = 1, and anticipate that this is a small value at the scale of // xReserve & yReserve. - a := sdk.OneInt() + a := osmomath.OneInt() - res, err := p.calcOutAmtGivenIn(sdk.NewCoin(baseDenom, a), quoteDenom, sdk.ZeroDec()) + res, err := p.calcOutAmtGivenIn(sdk.NewCoin(baseDenom, a), quoteDenom, osmomath.ZeroDec()) // fmt.Println("spot price res", res) return res, err } -func oneMinus(spreadFactor sdk.Dec) osmomath.BigDec { - return osmomath.BigDecFromSDKDec(sdk.OneDec().Sub(spreadFactor)) +func oneMinus(spreadFactor osmomath.Dec) osmomath.BigDec { + return osmomath.BigDecFromDec(osmomath.OneDec().Sub(spreadFactor)) } -// calcOutAmtGivenIn calculate amount of specified denom to output from a pool in sdk.Dec given the input `tokenIn` -func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, spreadFactor sdk.Dec) (sdk.Dec, error) { +// calcOutAmtGivenIn calculate amount of specified denom to output from a pool in osmomath.Dec given the input `tokenIn` +func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, spreadFactor osmomath.Dec) (osmomath.Dec, error) { // round liquidity down, and round token in down reserves, err := p.scaledSortedPoolReserves(tokenIn.Denom, tokenOutDenom, osmomath.RoundDown) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } tokenInSupply, tokenOutSupply, remReserves := reserves[0], reserves[1], reserves[2:] tokenInDec, err := p.scaleCoin(tokenIn, osmomath.RoundDown) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } // amm input = tokenIn * (1 - spread factor) @@ -204,16 +204,16 @@ func (p Pool) calcOutAmtGivenIn(tokenIn sdk.Coin, tokenOutDenom string, spreadFa } // calcInAmtGivenOut calculates exact input amount given the desired output and return as a decimal -func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, spreadFactor sdk.Dec) (sdk.Dec, error) { +func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, spreadFactor osmomath.Dec) (osmomath.Dec, error) { // round liquidity down, and round token out up reserves, err := p.scaledSortedPoolReserves(tokenInDenom, tokenOut.Denom, osmomath.RoundDown) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } tokenInSupply, tokenOutSupply, remReserves := reserves[0], reserves[1], reserves[2:] tokenOutAmount, err := p.scaleCoin(tokenOut, osmomath.RoundUp) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } // We are solving for the amount of token in, cfmm(x,y) = cfmm(x + x_in, y - y_out) @@ -230,8 +230,8 @@ func (p *Pool) calcInAmtGivenOut(tokenOut sdk.Coin, tokenInDenom string, spreadF // calcSingleAssetJoinShares calculates the number of LP shares that // should be granted given the passed in single-token input (non-mutative) -func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor sdk.Dec) (sdk.Int, error) { - poolWithAddedLiquidityAndShares := func(newLiquidity sdk.Coin, newShares sdk.Int) types.CFMMPoolI { +func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor osmomath.Dec) (osmomath.Int, error) { + poolWithAddedLiquidityAndShares := func(newLiquidity sdk.Coin, newShares osmomath.Int) types.CFMMPoolI { paCopy := p.Copy() paCopy.updatePoolForJoin(sdk.NewCoins(newLiquidity), newShares) return &paCopy @@ -244,10 +244,10 @@ func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor sdk.Dec) // 4) Multiplying token in by one minus spread factor. spreadFactorApplicableRatio, err := p.singleAssetJoinSpreadFactorRatio(tokenIn.Denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } - oneMinusSpreadFactor := sdk.OneDec().Sub(spreadFactor.Mul(spreadFactorApplicableRatio)) - tokenInAmtAfterFee := tokenIn.Amount.ToDec().Mul(oneMinusSpreadFactor).TruncateInt() + oneMinusSpreadFactor := osmomath.OneDec().Sub(spreadFactor.Mul(spreadFactorApplicableRatio)) + tokenInAmtAfterFee := tokenIn.Amount.ToLegacyDec().Mul(oneMinusSpreadFactor).TruncateInt() return cfmm_common.BinarySearchSingleAssetJoin(p, sdk.NewCoin(tokenIn.Denom, tokenInAmtAfterFee), poolWithAddedLiquidityAndShares) } @@ -258,7 +258,7 @@ func (p *Pool) calcSingleAssetJoinShares(tokenIn sdk.Coin, spreadFactor sdk.Dec) // and we input asset A, this function will return 20%. // Note that this will over-estimate spread factor for single asset joins slightly, // as in the swapping process into the pool, the A to B ratio would decrease the relative supply of B. -func (p *Pool) singleAssetJoinSpreadFactorRatio(tokenInDenom string) (sdk.Dec, error) { +func (p *Pool) singleAssetJoinSpreadFactorRatio(tokenInDenom string) (osmomath.Dec, error) { // get a second denom in pool tokenOut := p.PoolLiquidity[0] if tokenOut.Denom == tokenInDenom { @@ -267,42 +267,42 @@ func (p *Pool) singleAssetJoinSpreadFactorRatio(tokenInDenom string) (sdk.Dec, e // We round bankers scaled liquidity, since we care about the ratio of liquidity. scaledLiquidity, err := p.scaledSortedPoolReserves(tokenInDenom, tokenOut.Denom, osmomath.RoundDown) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } - totalLiquidityDenominator := osmomath.ZeroDec() + totalLiquidityDenominator := osmomath.ZeroBigDec() for _, amount := range scaledLiquidity { totalLiquidityDenominator = totalLiquidityDenominator.Add(amount) } ratioOfInputAssetLiquidityToTotalLiquidity := scaledLiquidity[0].Quo(totalLiquidityDenominator) - // SDKDec() rounds down (as it truncates), therefore 1 - term is rounded up, as desired. - nonInternalAssetRatio := sdk.OneDec().Sub(ratioOfInputAssetLiquidityToTotalLiquidity.SDKDec()) + // Dec() rounds down (as it truncates), therefore 1 - term is rounded up, as desired. + nonInternalAssetRatio := osmomath.OneDec().Sub(ratioOfInputAssetLiquidityToTotalLiquidity.Dec()) return nonInternalAssetRatio, nil } // Route a pool join attempt to either a single-asset join or all-asset join (mutates pool state) // Eventually, we intend to switch this to a COW wrapped pa for better performance -func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, tokensJoined sdk.Coins, err error) { +func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error) { if !tokensIn.DenomsSubsetOf(p.GetTotalPoolLiquidity(ctx)) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("attempted joining pool with assets that do not exist in pool") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("attempted joining pool with assets that do not exist in pool") } - if len(tokensIn) == 1 && tokensIn[0].Amount.GT(sdk.OneInt()) { + if len(tokensIn) == 1 && tokensIn[0].Amount.GT(osmomath.OneInt()) { numShares, err = p.calcSingleAssetJoinShares(tokensIn[0], spreadFactor) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } tokensJoined = tokensIn } else if len(tokensIn) != p.NumAssets() { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New( + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New( "stableswap pool only supports LP'ing with one asset, or all assets in pool") } else { // Add all exact coins we can (no swap). ctx arg doesn't matter for Stableswap var remCoins sdk.Coins numShares, remCoins, err = cfmm_common.MaximalExactRatioJoin(p, sdk.Context{}, tokensIn) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } tokensJoined = tokensIn.Sub(remCoins) @@ -311,7 +311,7 @@ func (p *Pool) joinPoolSharesInternal(ctx sdk.Context, tokensIn sdk.Coins, sprea p.updatePoolForJoin(tokensJoined, numShares) if err = validatePoolLiquidity(p.PoolLiquidity, p.ScalingFactors); err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } return numShares, tokensJoined, nil diff --git a/x/gamm/pool-models/stableswap/amm_test.go b/x/gamm/pool-models/stableswap/amm_test.go index 43b16167dfd..f9e3a25be4f 100644 --- a/x/gamm/pool-models/stableswap/amm_test.go +++ b/x/gamm/pool-models/stableswap/amm_test.go @@ -38,7 +38,7 @@ type CFMMTestCase struct { } var ( - overflowDec = osmomath.NewDecFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(1024), nil), big.NewInt(1))) + overflowDec = osmomath.NewBigDecFromBigInt(new(big.Int).Sub(new(big.Int).Exp(big.NewInt(2), big.NewInt(1024), nil), big.NewInt(1))) twoAssetCFMMTestCases = map[string]CFMMTestCase{ // sanity checks "small pool small input": { @@ -417,7 +417,7 @@ func TestStableSwapTestSuite(t *testing.T) { } func TestCFMMInvariantTwoAssets(t *testing.T) { - kErrTolerance := osmomath.OneDec() + kErrTolerance := osmomath.OneBigDec() tests := twoAssetCFMMTestCases @@ -442,7 +442,7 @@ func TestCFMMInvariantTwoAssets(t *testing.T) { } func TestCFMMInvariantTwoAssetsDirect(t *testing.T) { - kErrTolerance := osmomath.OneDec() + kErrTolerance := osmomath.OneBigDec() tests := twoAssetCFMMTestCases @@ -512,13 +512,13 @@ func solveCfmmDirect(xReserve, yReserve, yIn osmomath.BigDec) osmomath.BigDec { scaled_y4_quo_k2 := scaled_y4_quo_k.Mul(scaled_y4_quo_k) // let sqrt_term = sqrt(1 + scaled_y4_quo_k2) - sqrt_term, err := (osmomath.OneDec().Add(scaled_y4_quo_k2)).ApproxRoot(2) + sqrt_term, err := (osmomath.OneBigDec().Add(scaled_y4_quo_k2)).ApproxRoot(2) if err != nil { panic(err) } // let common_factor = [y^2 * 9k) * (sqrt_term + 1)]^(1/3) - common_factor, err := (y2.MulInt64(9).Mul(k).Mul((sqrt_term.Add(osmomath.OneDec())))).ApproxRoot(3) + common_factor, err := (y2.MulInt64(9).Mul(k).Mul((sqrt_term.Add(osmomath.OneBigDec())))).ApproxRoot(3) if err != nil { panic(err) } @@ -553,7 +553,7 @@ func cfmmConstant(xReserve, yReserve osmomath.BigDec) osmomath.BigDec { } func TestCFMMInvariantMultiAssets(t *testing.T) { - kErrTolerance := osmomath.OneDec() + kErrTolerance := osmomath.OneBigDec() tests := multiAssetCFMMTestCases @@ -588,7 +588,7 @@ func cfmmConstantMulti(xReserve, yReserve, u, v osmomath.BigDec) osmomath.BigDec } func TestCFMMInvariantMultiAssetsDirect(t *testing.T) { - kErrTolerance := osmomath.OneDec() + kErrTolerance := osmomath.OneBigDec() tests := multiAssetCFMMTestCases @@ -689,7 +689,7 @@ func solveCFMMMultiDirect(xReserve, yReserve, wSumSquares, yIn osmomath.BigDec) } func TestCFMMInvariantMultiAssetsBinarySearch(t *testing.T) { - kErrTolerance := osmomath.OneDec() + kErrTolerance := osmomath.OneBigDec() tests := multiAssetCFMMTestCases @@ -731,8 +731,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000_000)), ), scalingFactors: []uint64{1, 1}, }, @@ -742,8 +742,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(500_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(500_000)), ), scalingFactors: []uint64{1, 1}, }, @@ -753,8 +753,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000)), ), scalingFactors: []uint64{1, 1}, }, @@ -764,8 +764,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000_000)), ), scalingFactors: []uint64{1, 1}, }, @@ -775,8 +775,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000_000)), ), scalingFactors: []uint64{1, 8}, }, @@ -786,8 +786,8 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(500_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(500_000)), ), scalingFactors: []uint64{1, 9}, }, @@ -799,9 +799,9 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{1, 1, 1}, }, @@ -811,9 +811,9 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(500_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(500_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{1, 1, 1}, }, @@ -823,9 +823,9 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{1, 1, 1}, }, @@ -835,9 +835,9 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{1, 1, 1}, }, @@ -847,9 +847,9 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(1_000_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{5, 3, 9}, }, @@ -859,16 +859,16 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers initialCalcOut: 100, poolLiquidity: sdk.NewCoins( - sdk.NewCoin("ion", sdk.NewInt(1_000_000)), - sdk.NewCoin("uosmo", sdk.NewInt(500_000)), - sdk.NewCoin("foo", sdk.NewInt(1_000_000)), + sdk.NewCoin("ion", osmomath.NewInt(1_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(500_000)), + sdk.NewCoin("foo", osmomath.NewInt(1_000_000)), ), scalingFactors: []uint64{100, 76, 33}, }, } // create randomized test cases r := rand.New(rand.NewSource(12345)) - coinMax := sdk.NewInt(10).ToDec().Power(30).TruncateInt() + coinMax := osmomath.NewInt(10).ToLegacyDec().Power(30).TruncateInt() for c := 2; c < 5; c++ { for i := 0; i < 10; i++ { coins := sdk.NewCoins() @@ -904,17 +904,17 @@ func (suite *StableSwapTestSuite) Test_StableSwap_CalculateAmountOutAndIn_Invers suite.Run(getTestCaseName(name, tc, spreadFactor), func() { ctx := suite.CreateTestContext() - spreadFactorDec, err := sdk.NewDecFromStr(spreadFactor) + spreadFactorDec, err := osmomath.NewDecFromStr(spreadFactor) suite.Require().NoError(err) - exitFeeDec, err := sdk.NewDecFromStr("0") + exitFeeDec, err := osmomath.NewDecFromStr("0") suite.Require().NoError(err) // TODO: add scaling factors into inverse relationship tests pool := createTestPool(suite.T(), tc.poolLiquidity, spreadFactorDec, exitFeeDec, tc.scalingFactors) suite.Require().NotNil(pool) errTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.Dec{}, MultiplicativeTolerance: sdk.NewDecWithPrec(1, 12), + AdditiveTolerance: osmomath.Dec{}, MultiplicativeTolerance: osmomath.NewDecWithPrec(1, 12), } test_helpers.TestCalculateAmountOutAndIn_InverseRelationship(suite.T(), ctx, pool, tc.denomIn, tc.denomOut, tc.initialCalcOut, spreadFactorDec, errTolerance) }) @@ -945,7 +945,7 @@ func (suite *StableSwapTestSuite) Test_StableSwap_Slippage_LiquidityRelation() { for name, tc := range testcases { for _, spreadFactor := range spreadFactorCases { createPoolFn := func(ctx sdk.Context, liq sdk.Coins) types.CFMMPoolI { - return createTestPool(suite.T(), liq, sdk.MustNewDecFromStr(spreadFactor), sdk.ZeroDec(), tc.scalingFactors) + return createTestPool(suite.T(), liq, osmomath.MustNewDecFromStr(spreadFactor), osmomath.ZeroDec(), tc.scalingFactors) } ctx := sdk.Context{} test_helpers.TestSlippageRelationWithLiquidityIncrease(name, suite.T(), ctx, createPoolFn, tc.initialLiquidity) @@ -954,7 +954,7 @@ func (suite *StableSwapTestSuite) Test_StableSwap_Slippage_LiquidityRelation() { } func calcUReserve(remReserves []osmomath.BigDec) osmomath.BigDec { - uReserve := osmomath.OneDec() + uReserve := osmomath.OneBigDec() for _, assetReserve := range remReserves { uReserve = uReserve.Mul(assetReserve) } @@ -962,7 +962,7 @@ func calcUReserve(remReserves []osmomath.BigDec) osmomath.BigDec { } func calcWSumSquares(remReserves []osmomath.BigDec) osmomath.BigDec { - wSumSquares := osmomath.ZeroDec() + wSumSquares := osmomath.ZeroBigDec() for _, assetReserve := range remReserves { wSumSquares = wSumSquares.Add(assetReserve.Mul(assetReserve)) } @@ -974,83 +974,83 @@ func TestCalcSingleAssetJoinShares(t *testing.T) { tokenIn sdk.Coin poolAssets sdk.Coins scalingFactors []uint64 - spreadFactor sdk.Dec - expectedOut sdk.Int + spreadFactor osmomath.Dec + expectedOut osmomath.Int } tests := map[string]testcase{ // no spread factors "even two asset pool, no spread factor": { - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100)), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expectedOut: sdk.NewInt(100), + spreadFactor: osmomath.ZeroDec(), + expectedOut: osmomath.NewInt(100), }, "uneven two asset pool, no spread factor": { - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100)), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expectedOut: sdk.NewInt(100), + spreadFactor: osmomath.ZeroDec(), + expectedOut: osmomath.NewInt(100), }, "even 3-asset pool, no spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(1000)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(1000)), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expectedOut: sdk.NewInt(1000), + spreadFactor: osmomath.ZeroDec(), + expectedOut: osmomath.NewInt(1000), }, "uneven 3-asset pool, no spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(100)), poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expectedOut: sdk.NewInt(100), + spreadFactor: osmomath.ZeroDec(), + expectedOut: osmomath.NewInt(100), }, // with spread factors "even two asset pool, default spread factor": { - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100)), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, spreadFactor: defaultSpreadFactor, - expectedOut: sdk.NewInt(100 - 3), + expectedOut: osmomath.NewInt(100 - 3), }, "uneven two asset pool, default spread factor": { - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100)), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, spreadFactor: defaultSpreadFactor, - expectedOut: sdk.NewInt(100 - 3), + expectedOut: osmomath.NewInt(100 - 3), }, "even 3-asset pool, default spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(100)), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, spreadFactor: defaultSpreadFactor, - expectedOut: sdk.NewInt(100 - 3), + expectedOut: osmomath.NewInt(100 - 3), }, "uneven 3-asset pool, default spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(100)), poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, spreadFactor: defaultSpreadFactor, - expectedOut: sdk.NewInt(100 - 3), + expectedOut: osmomath.NewInt(100 - 3), }, "even 3-asset pool, 0.03 spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(100)), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.MustNewDecFromStr("0.03"), - expectedOut: sdk.NewInt(100 - 3), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), + expectedOut: osmomath.NewInt(100 - 3), }, "uneven 3-asset pool, 0.03 spread factor": { - tokenIn: sdk.NewCoin("asset/a", sdk.NewInt(100)), + tokenIn: sdk.NewCoin("asset/a", osmomath.NewInt(100)), poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.MustNewDecFromStr("0.03"), - expectedOut: sdk.NewInt(100 - 3), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), + expectedOut: osmomath.NewInt(100 - 3), }, } @@ -1063,13 +1063,13 @@ func TestCalcSingleAssetJoinShares(t *testing.T) { require.NoError(t, err, "test: %s", name) p.updatePoolForJoin(sdk.Coins{tc.tokenIn}, shares) - exitTokens, err := p.ExitPool(ctx, shares, sdk.ZeroDec()) + exitTokens, err := p.ExitPool(ctx, shares, osmomath.ZeroDec()) require.NoError(t, err, "test: %s", name) - // since each asset swap can have up to sdk.OneInt() error, our expected error bound is 1*numAssets - correctnessThreshold := sdk.OneInt().Mul(sdk.NewInt(int64(len(p.PoolLiquidity)))) + // since each asset swap can have up to osmomath.OneInt() error, our expected error bound is 1*numAssets + correctnessThreshold := osmomath.OneInt().Mul(osmomath.NewInt(int64(len(p.PoolLiquidity)))) - tokenOutAmount, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, exitTokens, tc.tokenIn.Denom, sdk.ZeroDec()) + tokenOutAmount, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, exitTokens, tc.tokenIn.Denom, osmomath.ZeroDec()) require.NoError(t, err, "test: %s", name) require.True(t, tokenOutAmount.LTE(tc.tokenIn.Amount)) require.True(t, tc.expectedOut.Sub(tokenOutAmount).Abs().LTE(correctnessThreshold)) @@ -1079,14 +1079,14 @@ func TestCalcSingleAssetJoinShares(t *testing.T) { func TestJoinPoolSharesInternal(t *testing.T) { tenPercentOfTwoPoolRaw := int64(1000000000 / 10) - tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", sdk.NewInt(int64(1000000000/10)))) + tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", osmomath.NewInt(int64(1000000000/10)))) twoAssetPlusTenPercent := twoEvenStablePoolAssets.Add(tenPercentOfTwoPoolCoins...) type testcase struct { tokensIn sdk.Coins poolAssets sdk.Coins scalingFactors []uint64 - spreadFactor sdk.Dec - expNumShare sdk.Int + spreadFactor osmomath.Dec + expNumShare osmomath.Int expTokensJoined sdk.Coins expPoolAssets sdk.Coins expectPass bool @@ -1097,19 +1097,19 @@ func TestJoinPoolSharesInternal(t *testing.T) { tokensIn: tenPercentOfTwoPoolCoins, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expNumShare: sdk.NewIntFromUint64(10000000000000000000), + spreadFactor: osmomath.ZeroDec(), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), expTokensJoined: tenPercentOfTwoPoolCoins, expPoolAssets: twoAssetPlusTenPercent, expectPass: true, }, "even two asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(10+tenPercentOfTwoPoolRaw))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", osmomath.NewInt(10+tenPercentOfTwoPoolRaw))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPoolRaw))), + spreadFactor: osmomath.ZeroDec(), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPoolRaw))), expPoolAssets: twoAssetPlusTenPercent, expectPass: true, }, @@ -1123,8 +1123,8 @@ func TestJoinPoolSharesInternal(t *testing.T) { sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expNumShare: sdk.ZeroInt(), + spreadFactor: osmomath.ZeroDec(), + expNumShare: osmomath.ZeroInt(), expTokensJoined: sdk.Coins{}, expPoolAssets: sdk.NewCoins( sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), @@ -1141,8 +1141,8 @@ func TestJoinPoolSharesInternal(t *testing.T) { sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset), ), scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), - expNumShare: sdk.ZeroInt(), + spreadFactor: osmomath.ZeroDec(), + expNumShare: osmomath.ZeroInt(), expTokensJoined: sdk.Coins{}, expPoolAssets: sdk.NewCoins( sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset), @@ -1156,11 +1156,11 @@ func TestJoinPoolSharesInternal(t *testing.T) { sdk.NewInt64Coin("bar", 1), ), poolAssets: sdk.NewCoins( - sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset.Sub(sdk.NewInt(1))), - sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset.Sub(sdk.NewInt(1))), + sdk.NewCoin("foo", types.StableswapMaxScaledAmtPerAsset.Sub(osmomath.NewInt(1))), + sdk.NewCoin("bar", types.StableswapMaxScaledAmtPerAsset.Sub(osmomath.NewInt(1))), ), scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expNumShare: types.InitPoolSharesSupply.Quo(types.StableswapMaxScaledAmtPerAsset), expTokensJoined: sdk.NewCoins( sdk.NewInt64Coin("foo", 1), @@ -1192,38 +1192,38 @@ func TestJoinPoolSharesInternal(t *testing.T) { } func TestSingleAssetJoinSpreadFactorRatio(t *testing.T) { - largeInt, ok := sdk.NewIntFromString("123456789012345678") + largeInt, ok := osmomath.NewIntFromString("123456789012345678") require.True(t, ok) type testcase struct { poolLiquidity sdk.Coins scalingFactors []uint64 tokenInDenom string - expectedRatio sdk.Dec + expectedRatio osmomath.Dec } tests := map[string]testcase{ "godoc-example": { poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), scalingFactors: []uint64{1, 1}, tokenInDenom: "tokenA", - expectedRatio: sdk.MustNewDecFromStr("0.2"), + expectedRatio: osmomath.MustNewDecFromStr("0.2"), }, "godoc-example-denom-rev": { poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), scalingFactors: []uint64{1, 1}, tokenInDenom: "tokenB", - expectedRatio: sdk.MustNewDecFromStr("0.8"), + expectedRatio: osmomath.MustNewDecFromStr("0.8"), }, "80:20 -> 1:1 scaling factor": { poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), scalingFactors: []uint64{80, 20}, tokenInDenom: "tokenA", - expectedRatio: sdk.MustNewDecFromStr("0.5"), + expectedRatio: osmomath.MustNewDecFromStr("0.5"), }, "80:20 -> 2:1 scaling factor": { poolLiquidity: sdk.NewCoins(sdk.NewInt64Coin("tokenA", 80), sdk.NewInt64Coin("tokenB", 20)), scalingFactors: []uint64{40, 20}, tokenInDenom: "tokenA", - expectedRatio: sdk.MustNewDecFromStr("0.333333333333333334"), + expectedRatio: osmomath.MustNewDecFromStr("0.333333333333333334"), }, "60:40:40, large numbers": { poolLiquidity: sdk.NewCoins( @@ -1233,7 +1233,7 @@ func TestSingleAssetJoinSpreadFactorRatio(t *testing.T) { scalingFactors: []uint64{1, 1, 1}, tokenInDenom: "tokenA", // 1 - (6 / 14) = 8/14 = 4/7 ~= 0.571428571428571429 - expectedRatio: sdk.MustNewDecFromStr("0.571428571428571429"), + expectedRatio: osmomath.MustNewDecFromStr("0.571428571428571429"), }, } for name, tc := range tests { diff --git a/x/gamm/pool-models/stableswap/msgs_test.go b/x/gamm/pool-models/stableswap/msgs_test.go index 4e8e90fe933..d6cebb91eb0 100644 --- a/x/gamm/pool-models/stableswap/msgs_test.go +++ b/x/gamm/pool-models/stableswap/msgs_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" appParams "github.com/osmosis-labs/osmosis/v19/app/params" stableswap "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -14,13 +15,13 @@ import ( func baseCreatePoolMsgGen(sender sdk.AccAddress) *stableswap.MsgCreateStableswapPool { testPoolAsset := sdk.Coins{ - sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("osmo", sdk.NewInt(100)), + sdk.NewCoin("atom", osmomath.NewInt(100)), + sdk.NewCoin("osmo", osmomath.NewInt(100)), } poolParams := &stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } msg := &stableswap.MsgCreateStableswapPool{ @@ -93,7 +94,7 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "has one coin in InitialPoolLiquidity", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100)), + sdk.NewCoin("osmo", osmomath.NewInt(100)), } return msg }), @@ -103,15 +104,15 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "have assets in excess of cap", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("akt", sdk.NewInt(100)), - sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("band", sdk.NewInt(100)), - sdk.NewCoin("evmos", sdk.NewInt(100)), - sdk.NewCoin("juno", sdk.NewInt(100)), - sdk.NewCoin("osmo", sdk.NewInt(100)), - sdk.NewCoin("regen", sdk.NewInt(100)), - sdk.NewCoin("usdt", sdk.NewInt(100)), - sdk.NewCoin("usdc", sdk.NewInt(100)), + sdk.NewCoin("akt", osmomath.NewInt(100)), + sdk.NewCoin("atom", osmomath.NewInt(100)), + sdk.NewCoin("band", osmomath.NewInt(100)), + sdk.NewCoin("evmos", osmomath.NewInt(100)), + sdk.NewCoin("juno", osmomath.NewInt(100)), + sdk.NewCoin("osmo", osmomath.NewInt(100)), + sdk.NewCoin("regen", osmomath.NewInt(100)), + sdk.NewCoin("usdt", osmomath.NewInt(100)), + sdk.NewCoin("usdc", osmomath.NewInt(100)), } return msg }), @@ -121,8 +122,8 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "negative spread factor with zero exit fee", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.PoolParams = &stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(-1, 2), - ExitFee: sdk.NewDecWithPrec(0, 0), + SwapFee: osmomath.NewDecWithPrec(-1, 2), + ExitFee: osmomath.NewDecWithPrec(0, 0), } return msg }), @@ -196,8 +197,8 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "zero spread factor, zero exit fee", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.PoolParams = &stableswap.PoolParams{ - ExitFee: sdk.NewDecWithPrec(0, 0), - SwapFee: sdk.NewDecWithPrec(0, 0), + ExitFee: osmomath.NewDecWithPrec(0, 0), + SwapFee: osmomath.NewDecWithPrec(0, 0), } return msg }), @@ -207,10 +208,10 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "multi assets pool", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("osmo", sdk.NewInt(100)), - sdk.NewCoin("usdc", sdk.NewInt(100)), - sdk.NewCoin("usdt", sdk.NewInt(100)), + sdk.NewCoin("atom", osmomath.NewInt(100)), + sdk.NewCoin("osmo", osmomath.NewInt(100)), + sdk.NewCoin("usdc", osmomath.NewInt(100)), + sdk.NewCoin("usdt", osmomath.NewInt(100)), } msg.ScalingFactors = []uint64{1, 1, 1, 1} return msg @@ -221,10 +222,10 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "post-scaled asset amount less than 1", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", sdk.NewInt(100)), - sdk.NewCoin("atom", sdk.NewInt(100)), - sdk.NewCoin("usdt", sdk.NewInt(100)), - sdk.NewCoin("usdc", sdk.NewInt(100)), + sdk.NewCoin("osmo", osmomath.NewInt(100)), + sdk.NewCoin("atom", osmomath.NewInt(100)), + sdk.NewCoin("usdt", osmomath.NewInt(100)), + sdk.NewCoin("usdc", osmomath.NewInt(100)), } msg.ScalingFactors = []uint64{1000, 1, 1, 1} return msg @@ -253,7 +254,7 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "greater than max post-scaled amount with regular scaling factors", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("osmo", types.StableswapMaxScaledAmtPerAsset.Add(sdk.OneInt())), + sdk.NewCoin("osmo", types.StableswapMaxScaledAmtPerAsset.Add(osmomath.OneInt())), sdk.NewCoin("atom", types.StableswapMaxScaledAmtPerAsset), sdk.NewCoin("usdt", types.StableswapMaxScaledAmtPerAsset), sdk.NewCoin("usdc", types.StableswapMaxScaledAmtPerAsset), @@ -271,14 +272,14 @@ func TestMsgCreateStableswapPoolValidateBasic(t *testing.T) { name: "100B token 8-asset pool using large scaling factors (6 decimal precision per asset)", msg: updateMsg(func(msg stableswap.MsgCreateStableswapPool) stableswap.MsgCreateStableswapPool { msg.InitialPoolLiquidity = sdk.Coins{ - sdk.NewCoin("akt", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("atom", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("band", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("juno", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("osmo", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("regen", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("usdc", sdk.NewInt(100_000_000_000_000_000)), - sdk.NewCoin("usdt", sdk.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("akt", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("atom", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("band", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("juno", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("osmo", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("regen", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("usdc", osmomath.NewInt(100_000_000_000_000_000)), + sdk.NewCoin("usdt", osmomath.NewInt(100_000_000_000_000_000)), } msg.ScalingFactors = []uint64{10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000, 10000000} return msg @@ -300,8 +301,8 @@ func (suite *TestSuite) TestMsgCreateStableswapPool() { suite.SetupTest() var ( - validParams = &stableswap.PoolParams{SwapFee: sdk.NewDecWithPrec(1, 2), ExitFee: sdk.ZeroDec()} - validInitialLiquidity = sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(1_000_000)), sdk.NewCoin("usdt", sdk.NewInt(2_000_000))) + validParams = &stableswap.PoolParams{SwapFee: osmomath.NewDecWithPrec(1, 2), ExitFee: osmomath.ZeroDec()} + validInitialLiquidity = sdk.NewCoins(sdk.NewCoin("usdc", osmomath.NewInt(1_000_000)), sdk.NewCoin("usdt", osmomath.NewInt(2_000_000))) validScalingFactors = []uint64{1, 1} invalidScalingFactors = []uint64{1, 1, 1} ) diff --git a/x/gamm/pool-models/stableswap/pool.go b/x/gamm/pool-models/stableswap/pool.go index c6b50c30b61..087fd2fe11a 100644 --- a/x/gamm/pool-models/stableswap/pool.go +++ b/x/gamm/pool-models/stableswap/pool.go @@ -86,11 +86,11 @@ func (p Pool) GetId() uint64 { return p.Id } -func (p Pool) GetSpreadFactor(ctx sdk.Context) sdk.Dec { +func (p Pool) GetSpreadFactor(ctx sdk.Context) osmomath.Dec { return p.PoolParams.SwapFee } -func (p Pool) GetExitFee(ctx sdk.Context) sdk.Dec { +func (p Pool) GetExitFee(ctx sdk.Context) osmomath.Dec { return p.PoolParams.ExitFee } @@ -103,7 +103,7 @@ func (p Pool) GetTotalPoolLiquidity(ctx sdk.Context) sdk.Coins { return p.PoolLiquidity } -func (p Pool) GetTotalShares() sdk.Int { +func (p Pool) GetTotalShares() osmomath.Int { return p.TotalShares.Amount } @@ -143,10 +143,10 @@ func (p Pool) scaleCoin(input sdk.Coin, roundingDirection osmomath.RoundingDirec // getDescaledPoolAmt descales the passed in amount // by the scaling factor of the passed in denom -func (p Pool) getDescaledPoolAmt(denom string, amount osmomath.BigDec) sdk.Dec { +func (p Pool) getDescaledPoolAmt(denom string, amount osmomath.BigDec) osmomath.Dec { scalingFactor := p.GetScalingFactorByDenom(denom) - return amount.MulInt64(int64(scalingFactor)).SDKDec() + return amount.MulInt64(int64(scalingFactor)).Dec() } // scaledSortedPoolReserves sorts and scales passed in pool reserves such that the denom @@ -220,7 +220,7 @@ func (p *Pool) updatePoolLiquidityForSwap(tokensIn sdk.Coins, tokensOut sdk.Coin // updatePoolLiquidityForExit updates the pool liquidity and total shares after an exit. // The function sanity checks that not all tokens of a given denom are removed, // and panics if thats the case. -func (p *Pool) updatePoolLiquidityForExit(tokensOut sdk.Coins, exitingShares sdk.Int) { +func (p *Pool) updatePoolLiquidityForExit(tokensOut sdk.Coins, exitingShares osmomath.Int) { p.updatePoolLiquidityForSwap(sdk.Coins{}, tokensOut) p.TotalShares.Amount = p.TotalShares.Amount.Sub(exitingShares) } @@ -228,7 +228,7 @@ func (p *Pool) updatePoolLiquidityForExit(tokensOut sdk.Coins, exitingShares sdk // updatePoolForJoin updates the pool liquidity and total shares after a join. // The function sanity checks that no new denoms were added to the pool // and panics if this is the case. -func (p *Pool) updatePoolForJoin(tokensIn sdk.Coins, newShares sdk.Int) { +func (p *Pool) updatePoolForJoin(tokensIn sdk.Coins, newShares osmomath.Int) { numTokens := p.NumAssets() p.PoolLiquidity = p.PoolLiquidity.Add(tokensIn...) if len(p.PoolLiquidity) != numTokens { @@ -239,7 +239,7 @@ func (p *Pool) updatePoolForJoin(tokensIn sdk.Coins, newShares sdk.Int) { // TODO: These should all get moved to amm.go // CalcOutAmtGivenIn calculates expected output amount given input token -func (p Pool) CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor sdk.Dec) (tokenOut sdk.Coin, err error) { +func (p Pool) CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor osmomath.Dec) (tokenOut sdk.Coin, err error) { if tokenIn.Len() != 1 { return sdk.Coin{}, errors.New("stableswap CalcOutAmtGivenIn: tokenIn is of wrong length") } @@ -258,7 +258,7 @@ func (p Pool) CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDeno } // SwapOutAmtGivenIn executes a swap given a desired input amount -func (p *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor sdk.Dec) (tokenOut sdk.Coin, err error) { +func (p *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor osmomath.Dec) (tokenOut sdk.Coin, err error) { if err = validatePoolLiquidity(p.PoolLiquidity.Add(tokenIn...), p.ScalingFactors); err != nil { return sdk.Coin{}, err } @@ -274,7 +274,7 @@ func (p *Pool) SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDen } // CalcInAmtGivenOut calculates input amount needed to receive given output -func (p Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (tokenIn sdk.Coin, err error) { +func (p Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (tokenIn sdk.Coin, err error) { if tokenOut.Len() != 1 { return sdk.Coin{}, errors.New("stableswap CalcInAmtGivenOut: tokenOut is of wrong length") } @@ -295,7 +295,7 @@ func (p Pool) CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDeno } // SwapInAmtGivenOut executes a swap given a desired output amount -func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (tokenIn sdk.Coin, err error) { +func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (tokenIn sdk.Coin, err error) { tokenIn, err = p.CalcInAmtGivenOut(ctx, tokenOut, tokenInDenom, spreadFactor) if err != nil { return sdk.Coin{}, err @@ -312,7 +312,7 @@ func (p *Pool) SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDen // SpotPrice calculates the approximate amount of `baseDenom` one would receive for // an input dx of `quoteDenom` (to simplify calculations, we approximate dx = 1) -func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (sdk.Dec, error) { +func (p Pool) SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (osmomath.Dec, error) { return p.spotPrice(quoteAssetDenom, baseAssetDenom) } @@ -322,7 +322,7 @@ func (p Pool) Copy() Pool { return p2 } -func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, newLiquidity sdk.Coins, err error) { +func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, newLiquidity sdk.Coins, err error) { pCopy := p.Copy() return pCopy.joinPoolSharesInternal(ctx, tokensIn, spreadFactor) } @@ -332,10 +332,10 @@ func (p *Pool) CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFac // // Returns the number of shares created, the amount of coins actually joined into the pool as not all may tokens may be joinable. // If an all-asset join is not possible, returns an error. -func (p Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, tokensJoined sdk.Coins, err error) { +func (p Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, tokensJoined sdk.Coins, err error) { // ensure that there aren't too many or too few assets in `tokensIn` if tokensIn.Len() != p.NumAssets() || !tokensIn.DenomsSubsetOf(p.GetTotalPoolLiquidity(ctx)) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("no-swap joins require LP'ing with all assets in pool") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("no-swap joins require LP'ing with all assets in pool") } // execute a no-swap join with as many tokens as possible given a perfect ratio: @@ -343,27 +343,27 @@ func (p Pool) CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spre // * remainingTokensIn is how many coins we have left to join that have not already been used. numShares, remainingTokensIn, err := cfmm_common.MaximalExactRatioJoin(&p, ctx, tokensIn) if err != nil { - return sdk.ZeroInt(), sdk.NewCoins(), err + return osmomath.ZeroInt(), sdk.NewCoins(), err } // ensure that no more tokens have been joined than is possible with the given `tokensIn` tokensJoined = tokensIn.Sub(remainingTokensIn) if tokensJoined.IsAnyGT(tokensIn) { - return sdk.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") + return osmomath.ZeroInt(), sdk.NewCoins(), errors.New("an error has occurred, more coins joined than token In") } return numShares, tokensJoined, nil } -func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (sdk.Int, error) { +func (p *Pool) JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (osmomath.Int, error) { numShares, _, err := p.joinPoolSharesInternal(ctx, tokensIn, spreadFactor) return numShares, err } -func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (sdk.Int, error) { +func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (osmomath.Int, error) { newShares, tokensJoined, err := p.CalcJoinPoolNoSwapShares(ctx, tokensIn, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // update pool with the calculated share and liquidity needed to join pool @@ -371,7 +371,7 @@ func (p *Pool) JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor return newShares, nil } -func (p *Pool) ExitPool(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) (exitingCoins sdk.Coins, err error) { +func (p *Pool) ExitPool(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitingCoins sdk.Coins, err error) { exitingCoins, err = p.CalcExitPoolCoinsFromShares(ctx, exitingShares, exitFee) if err != nil { return sdk.Coins{}, err @@ -387,7 +387,7 @@ func (p *Pool) ExitPool(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) return exitingCoins, nil } -func (p Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares sdk.Int, exitFee sdk.Dec) (exitingCoins sdk.Coins, err error) { +func (p Pool) CalcExitPoolCoinsFromShares(ctx sdk.Context, exitingShares osmomath.Int, exitFee osmomath.Dec) (exitingCoins sdk.Coins, err error) { return cfmm_common.CalcExitPool(ctx, &p, exitingShares, exitFee) } @@ -461,10 +461,10 @@ func validatePoolLiquidity(liquidity sdk.Coins, scalingFactors []uint64) error { return types.UnsortedPoolLiqError{ActualLiquidity: liquidity} } - scaledAmount := asset.Amount.Quo(sdk.NewInt(int64(scalingFactors[i]))) + scaledAmount := asset.Amount.Quo(osmomath.NewInt(int64(scalingFactors[i]))) if scaledAmount.GT(types.StableswapMaxScaledAmtPerAsset) { return types.ErrHitMaxScaledAssets - } else if scaledAmount.LT(sdk.NewInt(types.StableswapMinScaledAmtPerAsset)) { + } else if scaledAmount.LT(osmomath.NewInt(types.StableswapMinScaledAmtPerAsset)) { return types.ErrHitMinScaledAssets } } diff --git a/x/gamm/pool-models/stableswap/pool_params.go b/x/gamm/pool-models/stableswap/pool_params.go index 68c4992fe4f..23891b19148 100644 --- a/x/gamm/pool-models/stableswap/pool_params.go +++ b/x/gamm/pool-models/stableswap/pool_params.go @@ -1,8 +1,7 @@ package stableswap import ( - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) @@ -11,7 +10,7 @@ func (params PoolParams) Validate() error { return types.ErrNegativeExitFee } - if params.ExitFee.GTE(sdk.OneDec()) { + if params.ExitFee.GTE(osmomath.OneDec()) { return types.ErrTooMuchExitFee } @@ -19,7 +18,7 @@ func (params PoolParams) Validate() error { return types.ErrNegativeSpreadFactor } - if params.SwapFee.GTE(sdk.OneDec()) { + if params.SwapFee.GTE(osmomath.OneDec()) { return types.ErrTooMuchSpreadFactor } return nil diff --git a/x/gamm/pool-models/stableswap/pool_test.go b/x/gamm/pool-models/stableswap/pool_test.go index bdd86fd421c..443f364afb8 100644 --- a/x/gamm/pool-models/stableswap/pool_test.go +++ b/x/gamm/pool-models/stableswap/pool_test.go @@ -17,8 +17,8 @@ import ( ) var ( - defaultSpreadFactor = sdk.MustNewDecFromStr("0.025") - defaultExitFee = sdk.ZeroDec() + defaultSpreadFactor = osmomath.MustNewDecFromStr("0.025") + defaultExitFee = osmomath.ZeroDec() defaultPoolId = uint64(1) defaultStableswapPoolParams = PoolParams{ SwapFee: defaultSpreadFactor, @@ -184,7 +184,7 @@ func TestScaledSortedPoolReserves(t *testing.T) { denoms: [2]string{"foo", "bar"}, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{10000000000, 10000000000}, - expReserves: []osmomath.BigDec{osmomath.NewDecWithPrec(1, 1).Quo(bigDecScalingMultiplier), osmomath.NewDecWithPrec(1, 1).Quo(bigDecScalingMultiplier)}, + expReserves: []osmomath.BigDec{osmomath.NewBigDecWithPrec(1, 1).Quo(bigDecScalingMultiplier), osmomath.NewBigDecWithPrec(1, 1).Quo(bigDecScalingMultiplier)}, }, "five asset pool, scaling factors = 1": { denoms: [2]string{"asset/c", "asset/d"}, @@ -293,15 +293,15 @@ func TestGetDescaledPoolAmts(t *testing.T) { amount osmomath.BigDec poolAssets sdk.Coins scalingFactors []uint64 - expResult sdk.Dec + expResult osmomath.Dec expPanic bool }{ "pass in no denoms": { denom: "", - amount: osmomath.ZeroDec(), + amount: osmomath.ZeroBigDec(), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.ZeroDec(), + expResult: osmomath.ZeroDec(), }, // sanity checks, default scaling factors "get exact supply of one asset, even two-asset pool with default scaling factors": { @@ -309,21 +309,21 @@ func TestGetDescaledPoolAmts(t *testing.T) { amount: osmomath.NewBigDec(100000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get less than supply of one asset, even two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(500000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of one asset, even two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(100000000), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * types.ScalingFactorMultiplier), }, // uneven pools @@ -332,42 +332,42 @@ func TestGetDescaledPoolAmts(t *testing.T) { amount: osmomath.NewBigDec(200000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(200000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(200000000 * types.ScalingFactorMultiplier), }, "get less than supply of first asset, uneven two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(500000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of first asset, uneven two-asset pool with default scaling factors": { denom: "foo", amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get exact supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * types.ScalingFactorMultiplier), }, "get less than supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", amount: osmomath.NewBigDec(500000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(500000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(500000000 * types.ScalingFactorMultiplier), }, "get more than supply of second asset, uneven two-asset pool with default scaling factors": { denom: "bar", amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expResult: sdk.NewDec(100000000 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * types.ScalingFactorMultiplier), }, // uneven scaling factors (note: denoms are ordered lexicographically, not by pool asset input) @@ -376,42 +376,42 @@ func TestGetDescaledPoolAmts(t *testing.T) { amount: osmomath.NewBigDec(20000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(20000000 * 5 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(20000000 * 5 * types.ScalingFactorMultiplier), }, "get less than supply of first asset, uneven two-asset pool with uneven scaling factors": { denom: "foo", amount: osmomath.NewBigDec(50000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(50000000 * 5 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(50000000 * 5 * types.ScalingFactorMultiplier), }, "get more than supply of first asset, uneven two-asset pool with uneven scaling factors": { denom: "foo", amount: osmomath.NewBigDec(100000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(100000000 * 5 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(100000000 * 5 * types.ScalingFactorMultiplier), }, "get exact supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", amount: osmomath.NewBigDec(20000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(20000000 * 10 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(20000000 * 10 * types.ScalingFactorMultiplier), }, "get less than supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", amount: osmomath.NewBigDec(50000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(50000000 * 10 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(50000000 * 10 * types.ScalingFactorMultiplier), }, "get more than supply of second asset, uneven two-asset pool with uneven scaling factors": { denom: "bar", amount: osmomath.NewBigDec(10000000), poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, - expResult: sdk.NewDec(10000000 * 10 * types.ScalingFactorMultiplier), + expResult: osmomath.NewDec(10000000 * 10 * types.ScalingFactorMultiplier), }, } @@ -440,7 +440,7 @@ func TestScaleCoin(t *testing.T) { expError bool }{ "even two-asset pool with default scaling factors": { - input: sdk.NewCoin("bar", sdk.NewInt(100)), + input: sdk.NewCoin("bar", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, @@ -448,7 +448,7 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "uneven two-asset pool with default scaling factors": { - input: sdk.NewCoin("foo", sdk.NewInt(200)), + input: sdk.NewCoin("foo", osmomath.NewInt(200)), rounding: osmomath.RoundDown, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, @@ -456,7 +456,7 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "even two-asset pool with uneven scaling factors greater than 1": { - input: sdk.NewCoin("bar", sdk.NewInt(100)), + input: sdk.NewCoin("bar", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10, 5}, @@ -464,15 +464,15 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "even two-asset pool with even, massive scaling factors greater than 1": { - input: sdk.NewCoin("foo", sdk.NewInt(100)), + input: sdk.NewCoin("foo", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{10000000000, 10_000_000_000}, - expOutput: osmomath.NewDecWithPrec(100, 10).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), + expOutput: osmomath.NewBigDecWithPrec(100, 10).Quo(osmomath.NewBigDec(types.ScalingFactorMultiplier)), expError: false, }, "five asset pool scaling factors = 1": { - input: sdk.NewCoin("asset/c", sdk.NewInt(100)), + input: sdk.NewCoin("asset/c", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 1, 1, 1, 1}, @@ -480,7 +480,7 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "five asset pool scaling factors = 1,2,3,4,5": { - input: sdk.NewCoin("asset/d", sdk.NewInt(100)), + input: sdk.NewCoin("asset/d", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: fiveUnevenStablePoolAssets, scalingFactors: []uint64{1, 2, 3, 4, 5}, @@ -488,7 +488,7 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "max scaling factors on small token inputs": { - input: sdk.NewCoin("foo", sdk.NewInt(10)), + input: sdk.NewCoin("foo", osmomath.NewInt(10)), rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{(1 << 62) / types.ScalingFactorMultiplier, (1 << 62) / types.ScalingFactorMultiplier}, @@ -496,7 +496,7 @@ func TestScaleCoin(t *testing.T) { expError: false, }, "zero scaling factor": { - input: sdk.NewCoin("bar", sdk.NewInt(100)), + input: sdk.NewCoin("bar", osmomath.NewInt(100)), rounding: osmomath.RoundDown, poolAssets: twoEvenStablePoolAssets, scalingFactors: []uint64{0, 1}, @@ -527,144 +527,144 @@ func TestCalcJoinPoolNoSwapShares(t *testing.T) { tokensIn sdk.Coins poolAssets sdk.Coins scalingFactors []uint64 - expNumShare sdk.Int + expNumShare osmomath.Int expTokensJoined sdk.Coins expPoolAssets sdk.Coins expectPass bool }{ "even two asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), expPoolAssets: twoEvenStablePoolAssets, expectPass: true, }, "even two asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool+1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool+1))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), expPoolAssets: twoEvenStablePoolAssets, expectPass: true, }, "uneven two asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), expPoolAssets: twoUnevenStablePoolAssets, expectPass: true, }, "uneven two asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool+1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool+1))), poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", sdk.NewInt(tenPercentOfTwoPool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(2*tenPercentOfTwoPool)), sdk.NewCoin("bar", osmomath.NewInt(tenPercentOfTwoPool))), expPoolAssets: twoUnevenStablePoolAssets, expectPass: true, }, "even three asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(tenPercentOfThreePool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(tenPercentOfThreePool))), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(tenPercentOfThreePool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(tenPercentOfThreePool))), expPoolAssets: threeEvenStablePoolAssets, expectPass: true, }, "even three asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(tenPercentOfThreePool+1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(tenPercentOfThreePool+1))), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(tenPercentOfThreePool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(tenPercentOfThreePool))), expPoolAssets: threeEvenStablePoolAssets, expectPass: true, }, "uneven three asset pool, same tokenIn ratio": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool))), poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool))), expPoolAssets: threeUnevenStablePoolAssets, expectPass: true, }, "uneven three asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool+1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool+1))), poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool))), expPoolAssets: threeUnevenStablePoolAssets, expectPass: true, }, "uneven three asset pool, uneven scaling factors": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool))), poolAssets: threeUnevenStablePoolAssets, scalingFactors: []uint64{5, 9, 175}, - expNumShare: sdk.NewIntFromUint64(10000000000000000000), - expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", sdk.NewInt(3*tenPercentOfThreePool))), + expNumShare: osmomath.NewIntFromUint64(10000000000000000000), + expTokensJoined: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(2*tenPercentOfThreePool)), sdk.NewCoin("asset/c", osmomath.NewInt(3*tenPercentOfThreePool))), expPoolAssets: threeUnevenStablePoolAssets, expectPass: true, }, // error catching "even two asset pool, no-swap join attempt with one asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: twoEvenStablePoolAssets, expectPass: false, }, "even two asset pool, no-swap join attempt with one valid and one invalid asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("baz", sdk.NewInt(tenPercentOfTwoPool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("baz", osmomath.NewInt(tenPercentOfTwoPool))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: twoEvenStablePoolAssets, expectPass: false, }, "even two asset pool, no-swap join attempt with two invalid assets": { - tokensIn: sdk.NewCoins(sdk.NewCoin("baz", sdk.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("qux", sdk.NewInt(tenPercentOfTwoPool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("baz", osmomath.NewInt(tenPercentOfTwoPool)), sdk.NewCoin("qux", osmomath.NewInt(tenPercentOfTwoPool))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: twoEvenStablePoolAssets, expectPass: false, }, "even three asset pool, no-swap join attempt with an invalid asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", sdk.NewInt(tenPercentOfThreePool)), sdk.NewCoin("qux", sdk.NewInt(tenPercentOfThreePool))), + tokensIn: sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("asset/b", osmomath.NewInt(tenPercentOfThreePool)), sdk.NewCoin("qux", osmomath.NewInt(tenPercentOfThreePool))), poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: threeEvenStablePoolAssets, expectPass: false, }, "single asset pool, no-swap join attempt with one asset": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(sdk.MaxSortableDec.TruncateInt64()))), - poolAssets: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(sdk.MaxSortableDec.TruncateInt64()))), + poolAssets: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1))), scalingFactors: []uint64{1}, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, - expPoolAssets: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1))), + expPoolAssets: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1))), expectPass: false, }, "attempt joining pool with no assets in it": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(1))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(1))), poolAssets: sdk.Coins{}, scalingFactors: []uint64{}, - expNumShare: sdk.NewIntFromUint64(0), + expNumShare: osmomath.NewIntFromUint64(0), expTokensJoined: sdk.Coins{}, expPoolAssets: sdk.Coins{}, expectPass: false, @@ -699,7 +699,7 @@ func TestSwapOutAmtGivenIn(t *testing.T) { tokenIn sdk.Coins expectedTokenOut sdk.Coin expectedPoolLiquidity sdk.Coins - spreadFactor sdk.Dec + spreadFactor osmomath.Dec expError bool }{ "even pool basic trade": { @@ -708,7 +708,7 @@ func TestSwapOutAmtGivenIn(t *testing.T) { tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 100)), expectedTokenOut: sdk.NewInt64Coin("bar", 99), expectedPoolLiquidity: twoEvenStablePoolAssets.Add(sdk.NewInt64Coin("foo", 100)).Sub(sdk.NewCoins(sdk.NewInt64Coin("bar", 99))), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: false, }, "100:1 scaling factor ratio, even swap": { @@ -720,10 +720,10 @@ func TestSwapOutAmtGivenIn(t *testing.T) { tokenIn: sdk.NewCoins(sdk.NewInt64Coin("foo", 100)), expectedTokenOut: sdk.NewInt64Coin("bar", 9999), expectedPoolLiquidity: sdk.NewCoins( - sdk.NewInt64Coin("bar", 1000000000).SubAmount(sdk.NewIntFromUint64(9999)), - sdk.NewInt64Coin("foo", 10000000).AddAmount(sdk.NewIntFromUint64(100)), + sdk.NewInt64Coin("bar", 1000000000).SubAmount(osmomath.NewIntFromUint64(9999)), + sdk.NewInt64Coin("foo", 10000000).AddAmount(osmomath.NewIntFromUint64(100)), ), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: false, }, // TODO: Add test cases here, where they're off 1-1 ratio @@ -742,7 +742,7 @@ func TestSwapOutAmtGivenIn(t *testing.T) { sdk.NewInt64Coin("foo", 9_999_999_999), sdk.NewInt64Coin("bar", 9_999_999_997), ), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: true, }, "trade exceeds max pool capacity for asset": { @@ -757,7 +757,7 @@ func TestSwapOutAmtGivenIn(t *testing.T) { sdk.NewInt64Coin("foo", 10_000_000_000), sdk.NewInt64Coin("bar", 10_000_000_000), ), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: true, }, } @@ -786,7 +786,7 @@ func TestSwapInAmtGivenOut(t *testing.T) { tokenOut sdk.Coins expectedTokenIn sdk.Coin expectedPoolLiquidity sdk.Coins - spreadFactor sdk.Dec + spreadFactor osmomath.Dec expError bool }{ "even pool basic trade": { @@ -795,7 +795,7 @@ func TestSwapInAmtGivenOut(t *testing.T) { tokenOut: sdk.NewCoins(sdk.NewInt64Coin("bar", 100)), expectedTokenIn: sdk.NewInt64Coin("foo", 100), expectedPoolLiquidity: twoEvenStablePoolAssets.Add(sdk.NewInt64Coin("foo", 100)).Sub(sdk.NewCoins(sdk.NewInt64Coin("bar", 100))), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: false, }, "trade hits max pool capacity for asset": { @@ -810,7 +810,7 @@ func TestSwapInAmtGivenOut(t *testing.T) { sdk.NewInt64Coin("foo", 9_999_999_998*types.ScalingFactorMultiplier), sdk.NewInt64Coin("bar", 9_999_999_996*types.ScalingFactorMultiplier), ), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: false, }, "trade exceeds max pool capacity for asset": { @@ -825,7 +825,7 @@ func TestSwapInAmtGivenOut(t *testing.T) { sdk.NewInt64Coin("foo", 10_000_000_000*types.ScalingFactorMultiplier), sdk.NewInt64Coin("bar", 10_000_000_000*types.ScalingFactorMultiplier), ), - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), expError: true, }, } @@ -846,16 +846,16 @@ func TestSwapInAmtGivenOut(t *testing.T) { } func TestInverseJoinPoolExitPool(t *testing.T) { - hundredFoo := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) - thousandAssetA := sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(1000))) + hundredFoo := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100))) + thousandAssetA := sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(1000))) tenPercentOfTwoPoolRaw := int64(1000000000 / 10) - tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", sdk.NewInt(int64(1000000000/10)))) + tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", osmomath.NewInt(int64(1000000000/10)))) type testcase struct { tokensIn sdk.Coins poolAssets sdk.Coins unevenJoinedTokens sdk.Coins scalingFactors []uint64 - spreadFactor sdk.Dec + spreadFactor osmomath.Dec } tests := map[string]testcase{ @@ -863,25 +863,25 @@ func TestInverseJoinPoolExitPool(t *testing.T) { tokensIn: hundredFoo, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[single asset join] uneven two asset pool, no spread factor": { tokensIn: hundredFoo, poolAssets: twoUnevenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[single asset join] even 3-asset pool, no spread factor": { tokensIn: thousandAssetA, poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[single asset join] uneven 3-asset pool, no spread factor": { tokensIn: thousandAssetA, poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[single asset join] even two asset pool, default spread factor": { tokensIn: hundredFoo, @@ -911,29 +911,29 @@ func TestInverseJoinPoolExitPool(t *testing.T) { tokensIn: thousandAssetA, poolAssets: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), }, "[single asset join] uneven 3-asset pool, 0.03 spread factor": { tokensIn: thousandAssetA, poolAssets: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, - spreadFactor: sdk.MustNewDecFromStr("0.03"), + spreadFactor: osmomath.MustNewDecFromStr("0.03"), }, "[all asset join] even two asset pool, same tokenIn ratio": { tokensIn: tenPercentOfTwoPoolCoins, poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[all asset join] even two asset pool, different tokenIn ratio with pool": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(10+tenPercentOfTwoPoolRaw))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", osmomath.NewInt(10+tenPercentOfTwoPoolRaw))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, "[all asset join] even two asset pool, different tokenIn ratio with pool, nonzero spread factor": { - tokensIn: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", sdk.NewInt(10+tenPercentOfTwoPoolRaw))), + tokensIn: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(tenPercentOfTwoPoolRaw)), sdk.NewCoin("bar", osmomath.NewInt(10+tenPercentOfTwoPoolRaw))), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, spreadFactor: defaultSpreadFactor, @@ -942,7 +942,7 @@ func TestInverseJoinPoolExitPool(t *testing.T) { tokensIn: sdk.NewCoins(), poolAssets: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, - spreadFactor: sdk.ZeroDec(), + spreadFactor: osmomath.ZeroDec(), }, } @@ -952,7 +952,7 @@ func TestInverseJoinPoolExitPool(t *testing.T) { p := poolStructFromAssets(tc.poolAssets, tc.scalingFactors) // only for single asset join case - var swapRatio sdk.Dec + var swapRatio osmomath.Dec var err error if len(tc.tokensIn) == 1 { swapRatio, err = p.singleAssetJoinSpreadFactorRatio(tc.tokensIn[0].Denom) @@ -966,7 +966,7 @@ func TestInverseJoinPoolExitPool(t *testing.T) { // if single asset join, we swap output tokens to input denom to test the full inverse relationship if len(tc.tokensIn) == 1 { - tokenOutAmt, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, tokenOut, tc.tokensIn[0].Denom, sdk.ZeroDec()) + tokenOutAmt, err := cfmm_common.SwapAllCoinsToSingleAsset(&p, ctx, tokenOut, tc.tokensIn[0].Denom, osmomath.ZeroDec()) require.NoError(t, err) tokenOut = sdk.NewCoins(sdk.NewCoin(tc.tokensIn[0].Denom, tokenOutAmt)) } @@ -975,8 +975,8 @@ func TestInverseJoinPoolExitPool(t *testing.T) { // to be smaller by swap ratio * 2 var expectedTokenOut sdk.Coins if len(tc.tokensIn) == 1 { - oneMinusSingleSpreadFactor := sdk.OneDec().Sub((swapRatio.Mul(tc.spreadFactor))) - expectedAmt := (tc.tokensIn[0].Amount.ToDec().Mul(oneMinusSingleSpreadFactor)).TruncateInt() + oneMinusSingleSpreadFactor := osmomath.OneDec().Sub((swapRatio.Mul(tc.spreadFactor))) + expectedAmt := (tc.tokensIn[0].Amount.ToLegacyDec().Mul(oneMinusSingleSpreadFactor)).TruncateInt() expectedTokenOut = sdk.NewCoins(sdk.NewCoin(tc.tokensIn[0].Denom, expectedAmt)) } else { expectedTokenOut = tc.tokensIn @@ -991,11 +991,11 @@ func TestInverseJoinPoolExitPool(t *testing.T) { } func TestExitPool(t *testing.T) { - tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", sdk.NewInt(int64(1000000000/10)))) - tenPercentOfThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/b", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/c", sdk.NewInt(1000000/10))) - tenPercentOfUnevenThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", sdk.NewInt(1000000/10)), sdk.NewCoin("asset/b", sdk.NewInt(2000000/10)), sdk.NewCoin("asset/c", sdk.NewInt(3000000/10))) + tenPercentOfTwoPoolCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(int64(1000000000/10))), sdk.NewCoin("bar", osmomath.NewInt(int64(1000000000/10)))) + tenPercentOfThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(1000000/10)), sdk.NewCoin("asset/b", osmomath.NewInt(1000000/10)), sdk.NewCoin("asset/c", osmomath.NewInt(1000000/10))) + tenPercentOfUnevenThreePoolCoins := sdk.NewCoins(sdk.NewCoin("asset/a", osmomath.NewInt(1000000/10)), sdk.NewCoin("asset/b", osmomath.NewInt(2000000/10)), sdk.NewCoin("asset/c", osmomath.NewInt(3000000/10))) type testcase struct { - sharesIn sdk.Int + sharesIn osmomath.Int initialPoolLiquidity sdk.Coins scalingFactors []uint64 expectedPoolLiquidity sdk.Coins @@ -1004,7 +1004,7 @@ func TestExitPool(t *testing.T) { } tests := map[string]testcase{ "basic two-asset pool exit on even pool": { - sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + sharesIn: types.InitPoolSharesSupply.Quo(osmomath.NewInt(10)), initialPoolLiquidity: twoEvenStablePoolAssets, scalingFactors: defaultTwoAssetScalingFactors, expectedPoolLiquidity: twoEvenStablePoolAssets.Sub(tenPercentOfTwoPoolCoins), @@ -1012,7 +1012,7 @@ func TestExitPool(t *testing.T) { expectPass: true, }, "basic three-asset pool exit on even pool": { - sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + sharesIn: types.InitPoolSharesSupply.Quo(osmomath.NewInt(10)), initialPoolLiquidity: threeEvenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, expectedPoolLiquidity: threeEvenStablePoolAssets.Sub(tenPercentOfThreePoolCoins), @@ -1020,7 +1020,7 @@ func TestExitPool(t *testing.T) { expectPass: true, }, "basic three-asset pool exit on uneven pool": { - sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(10)), + sharesIn: types.InitPoolSharesSupply.Quo(osmomath.NewInt(10)), initialPoolLiquidity: threeUnevenStablePoolAssets, scalingFactors: defaultThreeAssetScalingFactors, expectedPoolLiquidity: threeUnevenStablePoolAssets.Sub(tenPercentOfUnevenThreePoolCoins), @@ -1029,7 +1029,7 @@ func TestExitPool(t *testing.T) { }, "pool exit pushes post-scaled asset below 1": { // attempt to exit one token when post-scaled amount is already 1 for each asset - sharesIn: types.InitPoolSharesSupply.Quo(sdk.NewInt(1000000)), + sharesIn: types.InitPoolSharesSupply.Quo(osmomath.NewInt(1000000)), initialPoolLiquidity: threeEvenStablePoolAssets, scalingFactors: []uint64{1000000 / types.ScalingFactorMultiplier, 100000 / types.ScalingFactorMultiplier, 100000 / types.ScalingFactorMultiplier}, expectedPoolLiquidity: threeEvenStablePoolAssets, @@ -1063,7 +1063,7 @@ func TestValidatePoolLiquidity(t *testing.T) { ) var ( - ten = sdk.NewInt(10) + ten = osmomath.NewInt(10) coinA = sdk.NewCoin(a, ten) coinB = sdk.NewCoin(b, ten) @@ -1206,7 +1206,7 @@ func TestStableswapSpotPrice(t *testing.T) { poolAssets sdk.Coins scalingFactors []uint64 expectPass bool - expectedPrice sdk.Dec + expectedPrice osmomath.Dec } tests := map[string]testcase{ "even two-asset pool": { @@ -1228,7 +1228,7 @@ func TestStableswapSpotPrice(t *testing.T) { quoteDenom: "bar", poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10000, 20000}, - expectedPrice: sdk.NewDecWithPrec(5, 1), + expectedPrice: osmomath.NewDecWithPrec(5, 1), expectPass: true, }, "even two-asset pool with different scaling factors (bar -> foo)": { @@ -1236,7 +1236,7 @@ func TestStableswapSpotPrice(t *testing.T) { quoteDenom: "foo", poolAssets: twoUnevenStablePoolAssets, scalingFactors: []uint64{10000, 20000}, - expectedPrice: sdk.NewDec(2), + expectedPrice: osmomath.NewDec(2), expectPass: true, }, "uneven two-asset pool": { @@ -1344,18 +1344,18 @@ func TestStableswapSpotPrice(t *testing.T) { if tc.expectPass { require.NoError(t, err) - var expectedSpotPrice sdk.Dec - if (tc.expectedPrice != sdk.Dec{}) { + var expectedSpotPrice osmomath.Dec + if (tc.expectedPrice != osmomath.Dec{}) { expectedSpotPrice = tc.expectedPrice } else { - expectedSpotPrice, err = p.calcOutAmtGivenIn(sdk.NewInt64Coin(tc.baseDenom, 1), tc.quoteDenom, sdk.ZeroDec()) + expectedSpotPrice, err = p.calcOutAmtGivenIn(sdk.NewInt64Coin(tc.baseDenom, 1), tc.quoteDenom, osmomath.ZeroDec()) require.NoError(t, err) } // We allow for a small geometric error due to our spot price being an approximation diff := (expectedSpotPrice.Sub(spotPrice)).Abs() - errTerm := diff.Quo(sdk.MinDec(expectedSpotPrice, spotPrice)) - require.True(t, errTerm.LT(sdk.NewDecWithPrec(1, 8)), "Expected: %d, Actual: %d", expectedSpotPrice, spotPrice) + errTerm := diff.Quo(osmomath.MinDec(expectedSpotPrice, spotPrice)) + require.True(t, errTerm.LT(osmomath.NewDecWithPrec(1, 8)), "Expected: %d, Actual: %d", expectedSpotPrice, spotPrice) // Pool liquidity should remain unchanged require.Equal(t, tc.poolAssets, p.GetTotalPoolLiquidity(ctx)) diff --git a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go index 7303599c3f7..f236a5adc7b 100644 --- a/x/gamm/pool-models/stableswap/stableswap_pool.pb.go +++ b/x/gamm/pool-models/stableswap/stableswap_pool.pb.go @@ -4,6 +4,7 @@ package stableswap import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" @@ -34,11 +35,11 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // governance. Instead they will be managed by the token holders of the pool. // The pool's token holders are specified in future_pool_governor. type PoolParams struct { - SwapFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=swap_fee,json=swapFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"swap_fee" yaml:"swap_fee"` + SwapFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=swap_fee,json=swapFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"swap_fee" yaml:"swap_fee"` // N.B.: exit fee is disabled during pool creation in x/poolmanager. While old // 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"` + ExitFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=exit_fee,json=exitFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"exit_fee" yaml:"exit_fee"` } func (m *PoolParams) Reset() { *m = PoolParams{} } @@ -140,50 +141,50 @@ func init() { } var fileDescriptor_ae0f054436f9999a = []byte{ - // 676 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0xcf, 0x4f, 0xd4, 0x4c, - 0x18, 0xde, 0xc2, 0xc2, 0xf2, 0x0d, 0xdf, 0xb7, 0xe4, 0xab, 0x24, 0x16, 0x88, 0x9d, 0xa5, 0x11, - 0xb2, 0x21, 0x6e, 0xeb, 0x6a, 0x62, 0x02, 0x37, 0x16, 0x83, 0x31, 0x31, 0x06, 0xcb, 0xc9, 0x1f, - 0xc9, 0x3a, 0x6d, 0x67, 0xcb, 0xc4, 0x76, 0xa7, 0x76, 0xa6, 0x08, 0x17, 0xcf, 0xc6, 0x93, 0x47, - 0x8f, 0x9c, 0x3d, 0x79, 0xf0, 0x8f, 0x20, 0x7a, 0xe1, 0x68, 0x3c, 0x54, 0x03, 0x07, 0xaf, 0x66, - 0xff, 0x02, 0x33, 0xd3, 0xd9, 0x5d, 0x16, 0x95, 0x90, 0x78, 0xd9, 0x9d, 0xf7, 0x7d, 0x9f, 0xf7, - 0x79, 0x7f, 0x3d, 0x29, 0x58, 0xa5, 0x2c, 0xa6, 0x8c, 0x30, 0x27, 0x44, 0x71, 0xec, 0x24, 0x94, - 0x46, 0x8d, 0x98, 0x06, 0x38, 0x62, 0x0e, 0xe3, 0xc8, 0x8b, 0x30, 0x7b, 0x81, 0x92, 0x53, 0xcf, - 0xb6, 0x40, 0xd8, 0x49, 0x4a, 0x39, 0xd5, 0x57, 0x54, 0xaa, 0x2d, 0x52, 0x6d, 0x11, 0x28, 0x32, - 0xed, 0x21, 0xdc, 0xde, 0x6d, 0x7a, 0x98, 0xa3, 0xe6, 0xfc, 0x9c, 0x2f, 0xc1, 0x6d, 0x99, 0xe9, - 0x14, 0x46, 0x41, 0x33, 0x3f, 0x1b, 0xd2, 0x90, 0x16, 0x7e, 0xf1, 0x52, 0xde, 0xff, 0x51, 0x4c, - 0xba, 0xd4, 0x91, 0xbf, 0xca, 0x65, 0x86, 0x94, 0x86, 0x11, 0x76, 0xa4, 0xe5, 0x65, 0x1d, 0x27, - 0xc8, 0x52, 0xc4, 0x09, 0xed, 0xaa, 0x38, 0x3c, 0x1b, 0xe7, 0x24, 0xc6, 0x8c, 0xa3, 0x38, 0xe9, - 0x13, 0x14, 0x75, 0x1d, 0x94, 0xf1, 0x1d, 0x47, 0x75, 0x26, 0x8d, 0x33, 0x71, 0x0f, 0x31, 0x3c, - 0x88, 0xfb, 0x94, 0xa8, 0x02, 0xd6, 0x0f, 0x0d, 0x80, 0x2d, 0x4a, 0xa3, 0x2d, 0x94, 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 0x7e, 0x68, 0x4c, 0x88, 0xd3, 0xdc, 0x15, - 0x9a, 0x5e, 0x38, 0x47, 0xd3, 0xad, 0xc7, 0x87, 0xc7, 0xa6, 0x76, 0x74, 0x6c, 0x6a, 0xdf, 0x8e, - 0x4d, 0xed, 0xcd, 0x89, 0x59, 0x3a, 0x3a, 0x31, 0x4b, 0x9f, 0x4f, 0xcc, 0xd2, 0xa3, 0xf5, 0x53, - 0x7b, 0x53, 0x0c, 0x8d, 0x08, 0x79, 0xac, 0x6f, 0x38, 0xbb, 0xcd, 0x55, 0x67, 0xef, 0xbc, 0x8f, - 0xa4, 0x37, 0x29, 0x3f, 0x12, 0x37, 0x7f, 0x06, 0x00, 0x00, 0xff, 0xff, 0x5b, 0xe4, 0x2c, 0xc5, - 0x52, 0x05, 0x00, 0x00, + // 684 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x54, 0xbf, 0x6f, 0xd3, 0x4e, + 0x14, 0x8f, 0xdb, 0xb4, 0xe9, 0xd7, 0xfd, 0x92, 0x0a, 0x53, 0x09, 0xb7, 0x11, 0x76, 0x6a, 0x51, + 0x14, 0x55, 0xc4, 0x47, 0x40, 0xaa, 0xd4, 0x6e, 0xa4, 0xa8, 0x08, 0xa9, 0x42, 0xc5, 0x9d, 0x80, + 0x21, 0x9c, 0xed, 0x8b, 0x73, 0xaa, 0x9d, 0x33, 0xbe, 0x73, 0x69, 0x16, 0x66, 0xc4, 0xc4, 0xc8, + 0xd8, 0x99, 0x89, 0x81, 0x3f, 0xa2, 0x82, 0xa5, 0x23, 0xea, 0x60, 0x50, 0x3b, 0xb0, 0xe7, 0x2f, + 0x40, 0x77, 0xbe, 0xa4, 0x49, 0x81, 0x08, 0xb1, 0x24, 0xf7, 0xde, 0xfb, 0x7c, 0x3e, 0xef, 0xc7, + 0x3d, 0x9f, 0xba, 0x41, 0x68, 0x44, 0x28, 0xa6, 0x20, 0x80, 0x51, 0x04, 0x62, 0x42, 0xc2, 0x7a, + 0x44, 0x7c, 0x14, 0x52, 0x40, 0x19, 0x74, 0x43, 0x44, 0x5f, 0xc1, 0x78, 0xe4, 0xd8, 0xe2, 0x08, + 0x3b, 0x4e, 0x08, 0x23, 0xda, 0x9a, 0xa4, 0xda, 0x9c, 0x6a, 0xf3, 0x40, 0xce, 0xb4, 0x2f, 0xe0, + 0xf6, 0x41, 0xc3, 0x45, 0x0c, 0x36, 0x96, 0x97, 0x3c, 0x01, 0x6e, 0x09, 0x26, 0xc8, 0x8d, 0x5c, + 0x66, 0x79, 0x31, 0x20, 0x01, 0xc9, 0xfd, 0xfc, 0x24, 0xbd, 0x57, 0x61, 0x84, 0xbb, 0x04, 0x88, + 0x5f, 0xe9, 0x32, 0x02, 0x42, 0x82, 0x10, 0x01, 0x61, 0xb9, 0x69, 0x1b, 0xf8, 0x69, 0x02, 0x19, + 0x26, 0x5d, 0x19, 0x37, 0x2f, 0xc7, 0x19, 0x8e, 0x10, 0x65, 0x30, 0x8a, 0x07, 0x02, 0x79, 0x5e, + 0x00, 0x53, 0xd6, 0x01, 0xb2, 0x32, 0x61, 0x5c, 0x8a, 0xbb, 0x90, 0xa2, 0x61, 0xdc, 0x23, 0x58, + 0x26, 0xb0, 0x4e, 0x15, 0x55, 0xdd, 0x25, 0x24, 0xdc, 0x85, 0x09, 0x8c, 0xa8, 0xf6, 0x44, 0x9d, + 0x13, 0x23, 0x69, 0x23, 0xa4, 0x2b, 0x55, 0xa5, 0xf6, 0x5f, 0x73, 0xfd, 0x38, 0x33, 0x0b, 0xa7, + 0x99, 0x59, 0xc9, 0x85, 0xa8, 0xbf, 0x6f, 0x63, 0x02, 0x22, 0xc8, 0x3a, 0xf6, 0x0e, 0x0a, 0xa0, + 0xd7, 0x7b, 0x80, 0xbc, 0x7e, 0x66, 0x2e, 0xf4, 0x60, 0x14, 0x6e, 0x5a, 0x03, 0xb2, 0xe5, 0x94, + 0xf8, 0x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, 0x97, 0x0e, + 0x0c, 0x70, 0xd0, 0xd8, 0x00, 0x87, 0x93, 0x9e, 0x43, 0x77, 0x56, 0x3c, 0x07, 0xf7, 0x7e, 0x06, + 0x00, 0x00, 0xff, 0xff, 0xdc, 0x02, 0xde, 0xf4, 0x3c, 0x05, 0x00, 0x00, } func (m *PoolParams) Marshal() (dAtA []byte, err error) { diff --git a/x/gamm/pool-models/stableswap/util_test.go b/x/gamm/pool-models/stableswap/util_test.go index 04542925176..f1394bb013f 100644 --- a/x/gamm/pool-models/stableswap/util_test.go +++ b/x/gamm/pool-models/stableswap/util_test.go @@ -6,10 +6,11 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" ) -func createTestPool(t *testing.T, poolLiquidity sdk.Coins, spreadFactor, exitFee sdk.Dec, scalingFactors []uint64) types.CFMMPoolI { +func createTestPool(t *testing.T, poolLiquidity sdk.Coins, spreadFactor, exitFee osmomath.Dec, scalingFactors []uint64) types.CFMMPoolI { t.Helper() scalingFactors, _ = applyScalingFactorMultiplier(scalingFactors) diff --git a/x/gamm/simulation/sim_msgs.go b/x/gamm/simulation/sim_msgs.go index c02ff440ac4..c3bdaebe292 100644 --- a/x/gamm/simulation/sim_msgs.go +++ b/x/gamm/simulation/sim_msgs.go @@ -8,6 +8,7 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" "github.com/osmosis-labs/osmosis/v19/x/gamm/keeper" @@ -104,14 +105,14 @@ func RandomCreateUniV2Msg(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context // TODO: pseudo-randomly generate swap and exit fees poolParams := &balancertypes.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), } // from the above selected account, determine the token type and respective weight needed to make the pool for i := 0; i < len(poolCoins); i++ { poolAssets = append(poolAssets, balancertypes.PoolAsset{ - Weight: sdk.OneInt(), + Weight: osmomath.OneInt(), Token: poolCoins[i], }) } @@ -156,7 +157,7 @@ func RandomSwapExactAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Cont return nil, err } - amountInAfterSubTakerFee := randomCoinSubset[0].Amount.ToDec().Mul(sdk.OneDec().Sub(takerFee)) + amountInAfterSubTakerFee := randomCoinSubset[0].Amount.ToLegacyDec().Mul(osmomath.OneDec().Sub(takerFee)) tokenInAfterSubTakerFee := sdk.NewCoin(randomCoinSubset[0].Denom, amountInAfterSubTakerFee.TruncateInt()) tokenOutMin, err := pool.CalcOutAmtGivenIn(ctx, sdk.NewCoins(tokenInAfterSubTakerFee), coinOut.Denom, pool.GetSpreadFactor(ctx)) @@ -213,7 +214,7 @@ func RandomSwapExactAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Con return nil, err } - amountInAfterAddTakerFee := tokenInMax.Amount.ToDec().Quo(sdk.OneDec().Sub(takerFee)) + amountInAfterAddTakerFee := tokenInMax.Amount.ToLegacyDec().Quo(osmomath.OneDec().Sub(takerFee)) tokenInMax = sdk.NewCoin(tokenInMax.Denom, amountInAfterAddTakerFee.TruncateInt()) return &types.MsgSwapExactAmountOut{ @@ -345,7 +346,7 @@ func RandomExitSwapExternAmountOut(k keeper.Keeper, sim *simtypes.SimCtx, ctx sd Sender: sender.Address.String(), PoolId: poolId, TokenOut: tokenOut, - ShareInMaxAmount: gammShares.Amount.Quo(sdk.NewInt(2)), + ShareInMaxAmount: gammShares.Amount.Quo(osmomath.NewInt(2)), }, nil } @@ -389,33 +390,33 @@ func RandomExitSwapShareAmountIn(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk. Sender: sender.Address.String(), PoolId: pool.GetId(), TokenOutDenom: tokenOut.Denom, - ShareInAmount: gammShares.Amount.Quo(sdk.NewInt(2)), - TokenOutMinAmount: tokenOut.Amount.Quo(sdk.NewInt(2)), + ShareInAmount: gammShares.Amount.Quo(osmomath.NewInt(2)), + TokenOutMinAmount: tokenOut.Amount.Quo(osmomath.NewInt(2)), }, nil } // TODO: Fix CalcJoinPoolShares API so we don't have to do this -func deriveRealMinShareOutAmt(ctx sdk.Context, tokenIn sdk.Coins, pool types.CFMMPoolI) (sdk.Int, error) { +func deriveRealMinShareOutAmt(ctx sdk.Context, tokenIn sdk.Coins, pool types.CFMMPoolI) (osmomath.Int, error) { minShareOutAmt, _, err := pool.CalcJoinPoolShares(ctx, tokenIn, pool.GetSpreadFactor(ctx)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalSharesAmount := pool.GetTotalShares() // shareRatio is the desired number of shares, divided by the total number of // shares currently in the pool. It is intended to be used in scenarios where you want - shareRatio := minShareOutAmt.ToDec().QuoInt(totalSharesAmount) - if shareRatio.LTE(sdk.ZeroDec()) { - return sdk.Int{}, fmt.Errorf("share ratio is zero or negative") + shareRatio := minShareOutAmt.ToLegacyDec().QuoInt(totalSharesAmount) + if shareRatio.LTE(osmomath.ZeroDec()) { + return osmomath.Int{}, fmt.Errorf("share ratio is zero or negative") } poolLiquidity := pool.GetTotalPoolLiquidity(ctx) neededLpLiquidity := sdk.Coins{} for _, coin := range poolLiquidity { - neededAmt := coin.Amount.ToDec().Mul(shareRatio).Ceil().RoundInt() - if neededAmt.LTE(sdk.ZeroInt()) { - return sdk.Int{}, fmt.Errorf("Too few shares out wanted") + neededAmt := coin.Amount.ToLegacyDec().Mul(shareRatio).Ceil().RoundInt() + if neededAmt.LTE(osmomath.ZeroInt()) { + return osmomath.Int{}, fmt.Errorf("Too few shares out wanted") } neededCoin := sdk.Coin{Denom: coin.Denom, Amount: neededAmt} neededLpLiquidity = neededLpLiquidity.Add(neededCoin) @@ -423,10 +424,10 @@ func deriveRealMinShareOutAmt(ctx sdk.Context, tokenIn sdk.Coins, pool types.CFM if tokenIn.Len() != 0 { if !(neededLpLiquidity.DenomsSubsetOf(tokenIn) && tokenIn.IsAllGTE(neededLpLiquidity)) { - return sdk.Int{}, fmt.Errorf("TokenInMaxs is less than the needed LP liquidity to this JoinPoolNoSwap,"+ + return osmomath.Int{}, fmt.Errorf("TokenInMaxs is less than the needed LP liquidity to this JoinPoolNoSwap,"+ " upperbound: %v, needed %v", tokenIn, neededLpLiquidity) } else if !(tokenIn.DenomsSubsetOf(neededLpLiquidity)) { - return sdk.Int{}, fmt.Errorf("TokenInMaxs includes tokens that are not part of the target pool,"+ + return osmomath.Int{}, fmt.Errorf("TokenInMaxs includes tokens that are not part of the target pool,"+ " input tokens: %v, pool tokens %v", tokenIn, neededLpLiquidity) } } @@ -447,12 +448,12 @@ func getRandPool(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) (types. // select a pseudo-random pool ID, max bound by the upcoming pool ID pools, err := k.GetPoolsAndPoke(ctx) if err != nil { - return nil, sdk.NewCoin("denom", sdk.ZeroInt()), sdk.NewCoin("denom", sdk.ZeroInt()), err + return nil, sdk.NewCoin("denom", osmomath.ZeroInt()), sdk.NewCoin("denom", osmomath.ZeroInt()), err } numPools := len(pools) if numPools == 0 { - return nil, sdk.NewCoin("denom", sdk.ZeroInt()), sdk.NewCoin("denom", sdk.ZeroInt()), fmt.Errorf("no pools exist") + return nil, sdk.NewCoin("denom", osmomath.ZeroInt()), sdk.NewCoin("denom", osmomath.ZeroInt()), fmt.Errorf("no pools exist") } rand := sim.GetRand() diff --git a/x/gamm/types/constants.go b/x/gamm/types/constants.go index 8cc43273661..25a66a11566 100644 --- a/x/gamm/types/constants.go +++ b/x/gamm/types/constants.go @@ -1,7 +1,7 @@ package types import ( - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -22,25 +22,25 @@ const ( var ( // OneShare represents the amount of subshares in a single pool share. - OneShare = sdk.NewIntWithDecimal(1, OneShareExponent) + OneShare = osmomath.NewIntWithDecimal(1, OneShareExponent) // InitPoolSharesSupply is the amount of new shares to initialize a pool with. InitPoolSharesSupply = OneShare.MulRaw(100) // SpotPriceSigFigs is the amount of significant figures used in return value of calculate SpotPrice - SpotPriceSigFigs = sdk.NewDec(10).Power(SigFigsExponent).TruncateInt() + SpotPriceSigFigs = osmomath.NewDec(10).Power(SigFigsExponent).TruncateInt() // MaxSpotPrice is the maximum supported spot price. Anything greater than this will error. // Internal note: Ctrl+F for MaxSpotPrice in code if ever changed. // Other tests depend on being equal to MaxSpotPrice, // but don't directly import it due to import issues. - MaxSpotPrice = sdk.NewDec(2).Power(128).Sub(sdk.OneDec()) + MaxSpotPrice = osmomath.NewDec(2).Power(128).Sub(osmomath.OneDec()) // MinSpotPrice is the minimum supported spot price. Anything less than this will error. - // It is limited by sdk.Dec's precision. - MinSpotPrice = sdk.SmallestDec() + // It is limited by osmomath.Dec's precision. + MinSpotPrice = osmomath.SmallestDec() // MultihopSpreadFactorMultiplierForOsmoPools if a spread factor multiplier for trades consists of just two OSMO pools during a single transaction. - MultihopSpreadFactorMultiplierForOsmoPools = sdk.NewDecWithPrec(5, 1) // 0.5 + MultihopSpreadFactorMultiplierForOsmoPools = osmomath.NewDecWithPrec(5, 1) // 0.5 // Maximum amount per asset after the application of scaling factors should be 10e34. - StableswapMaxScaledAmtPerAsset = sdk.NewDec(10).Power(34).TruncateInt() + StableswapMaxScaledAmtPerAsset = osmomath.NewDec(10).Power(34).TruncateInt() ) diff --git a/x/gamm/types/expected_keepers.go b/x/gamm/types/expected_keepers.go index a77f2a62324..b040b559fb0 100644 --- a/x/gamm/types/expected_keepers.go +++ b/x/gamm/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" @@ -70,25 +71,25 @@ type PoolManager interface { sender sdk.AccAddress, routes []poolmanagertypes.SwapAmountInRoute, tokenIn sdk.Coin, - tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) + tokenOutMinAmount osmomath.Int) (tokenOutAmount osmomath.Int, err error) RouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, routes []poolmanagertypes.SwapAmountOutRoute, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, - ) (tokenInAmount sdk.Int, err error) + ) (tokenInAmount osmomath.Int, err error) MultihopEstimateOutGivenExactAmountIn( ctx sdk.Context, routes []poolmanagertypes.SwapAmountInRoute, tokenIn sdk.Coin, - ) (tokenOutAmount sdk.Int, err error) + ) (tokenOutAmount osmomath.Int, err error) MultihopEstimateInGivenExactAmountOut( ctx sdk.Context, routes []poolmanagertypes.SwapAmountOutRoute, - tokenOut sdk.Coin) (tokenInAmount sdk.Int, err error) + tokenOut sdk.Coin) (tokenInAmount osmomath.Int, err error) GetPoolModule(ctx sdk.Context, poolId uint64) (poolmanagertypes.PoolModuleI, error) @@ -96,7 +97,7 @@ type PoolManager interface { CreateConcentratedPoolAsPoolManager(ctx sdk.Context, msg poolmanagertypes.CreatePoolMsg) (poolmanagertypes.PoolI, error) - GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (sdk.Dec, error) + GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.Dec, error) } type PoolIncentivesKeeper interface { diff --git a/x/gamm/types/gov.go b/x/gamm/types/gov.go index aa20caeae58..056dc4a8be7 100644 --- a/x/gamm/types/gov.go +++ b/x/gamm/types/gov.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/osmosis-labs/osmosis/osmomath" gammmigration "github.com/osmosis-labs/osmosis/v19/x/gamm/types/migration" ) @@ -192,7 +193,7 @@ func (p *CreateConcentratedLiquidityPoolsAndLinktoCFMMProposal) ValidateBasic() } spreadFactor := record.SpreadFactor - if spreadFactor.IsNegative() || spreadFactor.GTE(sdk.OneDec()) { + if spreadFactor.IsNegative() || spreadFactor.GTE(osmomath.OneDec()) { return fmt.Errorf("Invalid Spread factor") } diff --git a/x/gamm/types/gov.pb.go b/x/gamm/types/gov.pb.go index 37359ed00f4..b2167f33427 100644 --- a/x/gamm/types/gov.pb.go +++ b/x/gamm/types/gov.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -117,12 +117,12 @@ func (m *UpdateMigrationRecordsProposal) XXX_DiscardUnknown() { var xxx_messageInfo_UpdateMigrationRecordsProposal proto.InternalMessageInfo type PoolRecordWithCFMMLink struct { - 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"` - TickSpacing uint64 `protobuf:"varint,3,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` - ExponentAtPriceOne github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"exponent_at_price_one" yaml:"exponent_at_price_one"` - SpreadFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spread_factor" yaml:"spread_factor"` - BalancerPoolId uint64 `protobuf:"varint,6,opt,name=balancer_pool_id,json=balancerPoolId,proto3" json:"balancer_pool_id,omitempty" yaml:"balancer_pool_id"` + 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"` + TickSpacing uint64 `protobuf:"varint,3,opt,name=tick_spacing,json=tickSpacing,proto3" json:"tick_spacing,omitempty" yaml:"tick_spacing"` + ExponentAtPriceOne cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=exponent_at_price_one,json=exponentAtPriceOne,proto3,customtype=cosmossdk.io/math.Int" json:"exponent_at_price_one" yaml:"exponent_at_price_one"` + SpreadFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=spread_factor,json=spreadFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spread_factor" yaml:"spread_factor"` + BalancerPoolId uint64 `protobuf:"varint,6,opt,name=balancer_pool_id,json=balancerPoolId,proto3" json:"balancer_pool_id,omitempty" yaml:"balancer_pool_id"` } func (m *PoolRecordWithCFMMLink) Reset() { *m = PoolRecordWithCFMMLink{} } @@ -280,57 +280,58 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/gov.proto", fileDescriptor_f31b9a6c0dbbdfa3) } var fileDescriptor_f31b9a6c0dbbdfa3 = []byte{ - // 800 bytes of a gzipped FileDescriptorProto + // 805 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x55, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0x8e, 0x93, 0x6c, 0x56, 0x4c, 0x77, 0x11, 0x35, 0x81, 0x84, 0x2e, 0xb2, 0x83, 0x0f, 0xa5, - 0xac, 0x88, 0xbd, 0xe1, 0xc7, 0x81, 0x48, 0x1c, 0x9a, 0x40, 0xa5, 0x45, 0x5b, 0xa8, 0xdc, 0x5d, - 0x10, 0x5c, 0xac, 0xc9, 0x78, 0xea, 0x8c, 0x62, 0xcf, 0x98, 0x99, 0xd9, 0xb2, 0x3d, 0x72, 0x40, - 0x20, 0x4e, 0x1c, 0x11, 0xa7, 0xfe, 0x09, 0x1c, 0xf8, 0x23, 0x2a, 0x4e, 0x3d, 0x22, 0x0e, 0x16, - 0x6a, 0x0f, 0xf4, 0x9c, 0x23, 0x17, 0xd0, 0xcc, 0xd8, 0x25, 0x40, 0x44, 0x15, 0x7a, 0xe2, 0x92, - 0xf8, 0xbd, 0xf7, 0xf9, 0x7b, 0x7e, 0xdf, 0xbc, 0x4f, 0x03, 0x1c, 0x26, 0x32, 0x26, 0x88, 0x08, - 0x12, 0x98, 0x65, 0xc1, 0xe1, 0x60, 0x82, 0x25, 0x1c, 0x04, 0x09, 0x3b, 0xf4, 0x73, 0xce, 0x24, - 0xb3, 0xdb, 0x65, 0xdd, 0x57, 0x75, 0xbf, 0xac, 0x6f, 0xb4, 0x13, 0x96, 0x30, 0x0d, 0x08, 0xd4, - 0x93, 0xc1, 0x6e, 0x78, 0xcb, 0xb9, 0x30, 0xc5, 0x8a, 0xc0, 0x60, 0x5e, 0x5a, 0x8a, 0x11, 0x53, - 0xc8, 0x71, 0x5c, 0x42, 0x5e, 0x40, 0x1a, 0x13, 0x19, 0x7e, 0x13, 0x94, 0xa5, 0x75, 0x98, 0x11, - 0xca, 0x02, 0xfd, 0x6b, 0x52, 0xde, 0x97, 0x75, 0xe0, 0x86, 0x38, 0x4f, 0x21, 0xc2, 0xbb, 0x24, - 0xe1, 0x50, 0x12, 0x46, 0x43, 0x8c, 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0x74, 0x07, 0xdc, 0xac, 0xf6, 0x43, 0xdf, 0x4c, 0xd8, 0xca, 0xf5, 0xe8, 0xed, 0x75, + 0x60, 0xa3, 0x33, 0x99, 0x08, 0xc6, 0x31, 0xc7, 0x42, 0x98, 0x93, 0x08, 0x97, 0xff, 0xae, 0x6c, + 0x98, 0xc2, 0xe0, 0xe3, 0xab, 0x99, 0x72, 0xaf, 0x32, 0xe5, 0xf2, 0xd6, 0x86, 0xef, 0x1f, 0x9d, + 0x38, 0xd6, 0xf1, 0x89, 0x63, 0xfd, 0x7a, 0xe2, 0x58, 0xdf, 0x9c, 0x3a, 0xb5, 0xe3, 0x53, 0xa7, + 0xf6, 0xf3, 0xa9, 0x53, 0xfb, 0xe4, 0x7e, 0x42, 0xe4, 0x64, 0x6f, 0xec, 0x23, 0x96, 0x05, 0x25, + 0xe1, 0x7a, 0x0a, 0xc7, 0xa2, 0x0a, 0x82, 0xfd, 0xfe, 0xdb, 0xc1, 0x81, 0xf9, 0xce, 0xc9, 0x59, + 0x8e, 0xc5, 0xb8, 0xa5, 0xbf, 0x58, 0x6f, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x0e, 0x7d, + 0xe5, 0x74, 0x07, 0x00, 0x00, } func (this *ReplaceMigrationRecordsProposal) Equal(that interface{}) bool { diff --git a/x/gamm/types/hooks.go b/x/gamm/types/hooks.go index caf3ae4fb10..96cd3d79dce 100644 --- a/x/gamm/types/hooks.go +++ b/x/gamm/types/hooks.go @@ -1,16 +1,20 @@ package types -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" +) type GammHooks interface { // AfterCFMMPoolCreated is called after a CFMM pool is created AfterCFMMPoolCreated(ctx sdk.Context, sender sdk.AccAddress, poolId uint64) // AfterJoinPool is called after JoinPool, JoinSwapExternAmountIn, and JoinSwapShareAmountOut - AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) + AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int) // AfterExitPool is called after ExitPool, ExitSwapShareAmountIn, and ExitSwapExternAmountOut - AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) + AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins) // AfterSwap is called after SwapExactAmountIn and SwapExactAmountOut in x/gamm. AfterCFMMSwap(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, input sdk.Coins, output sdk.Coins) @@ -32,13 +36,13 @@ func (h MultiGammHooks) AfterCFMMPoolCreated(ctx sdk.Context, sender sdk.AccAddr } } -func (h MultiGammHooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { +func (h MultiGammHooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int) { for i := range h { h[i].AfterJoinPool(ctx, sender, poolId, enterCoins, shareOutAmount) } } -func (h MultiGammHooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { +func (h MultiGammHooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins) { for i := range h { h[i].AfterExitPool(ctx, sender, poolId, shareInAmount, exitCoins) } diff --git a/x/gamm/types/msgs_test.go b/x/gamm/types/msgs_test.go index 7bed4fdad71..46b3045320c 100644 --- a/x/gamm/types/msgs_test.go +++ b/x/gamm/types/msgs_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -31,8 +32,8 @@ func TestMsgSwapExactAmountIn(t *testing.T) { PoolId: 1, TokenOutDenom: "test2", }}, - TokenIn: sdk.NewCoin("test", sdk.NewInt(100)), - TokenOutMinAmount: sdk.NewInt(200), + TokenIn: sdk.NewCoin("test", osmomath.NewInt(100)), + TokenOutMinAmount: osmomath.NewInt(200), } return after(properMsg) @@ -105,7 +106,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "zero amount token", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountIn) gammtypes.MsgSwapExactAmountIn { - msg.TokenIn.Amount = sdk.NewInt(0) + msg.TokenIn.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -113,7 +114,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "negative amount token", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountIn) gammtypes.MsgSwapExactAmountIn { - msg.TokenIn.Amount = sdk.NewInt(-10) + msg.TokenIn.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -121,7 +122,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "zero amount criteria", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountIn) gammtypes.MsgSwapExactAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(0) + msg.TokenOutMinAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -129,7 +130,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "negative amount criteria", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountIn) gammtypes.MsgSwapExactAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(-10) + msg.TokenOutMinAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -161,8 +162,8 @@ func TestMsgSwapExactAmountOut(t *testing.T) { PoolId: 1, TokenInDenom: "test2", }}, - TokenOut: sdk.NewCoin("test", sdk.NewInt(100)), - TokenInMaxAmount: sdk.NewInt(200), + TokenOut: sdk.NewCoin("test", osmomath.NewInt(100)), + TokenInMaxAmount: osmomath.NewInt(200), } return after(properMsg) @@ -235,7 +236,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "zero amount token", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountOut) gammtypes.MsgSwapExactAmountOut { - msg.TokenOut.Amount = sdk.NewInt(0) + msg.TokenOut.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -243,7 +244,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "negative amount token", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountOut) gammtypes.MsgSwapExactAmountOut { - msg.TokenOut.Amount = sdk.NewInt(-10) + msg.TokenOut.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -251,7 +252,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "zero amount criteria", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountOut) gammtypes.MsgSwapExactAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(0) + msg.TokenInMaxAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -259,7 +260,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "negative amount criteria", msg: createMsg(func(msg gammtypes.MsgSwapExactAmountOut) gammtypes.MsgSwapExactAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(-10) + msg.TokenInMaxAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -285,8 +286,8 @@ func TestMsgJoinPool(t *testing.T) { properMsg := gammtypes.MsgJoinPool{ Sender: addr1, PoolId: 1, - ShareOutAmount: sdk.NewInt(10), - TokenInMaxs: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(10)), sdk.NewCoin("test2", sdk.NewInt(20))), + ShareOutAmount: osmomath.NewInt(10), + TokenInMaxs: sdk.NewCoins(sdk.NewCoin("test1", osmomath.NewInt(10)), sdk.NewCoin("test2", osmomath.NewInt(20))), } return after(properMsg) @@ -327,7 +328,7 @@ func TestMsgJoinPool(t *testing.T) { { name: "negative requirement", msg: createMsg(func(msg gammtypes.MsgJoinPool) gammtypes.MsgJoinPool { - msg.ShareOutAmount = sdk.NewInt(-10) + msg.ShareOutAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -335,7 +336,7 @@ func TestMsgJoinPool(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgJoinPool) gammtypes.MsgJoinPool { - msg.TokenInMaxs[1].Amount = sdk.NewInt(0) + msg.TokenInMaxs[1].Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -343,7 +344,7 @@ func TestMsgJoinPool(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgJoinPool) gammtypes.MsgJoinPool { - msg.TokenInMaxs[1].Amount = sdk.NewInt(-10) + msg.TokenInMaxs[1].Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -385,8 +386,8 @@ func TestMsgExitPool(t *testing.T) { properMsg := gammtypes.MsgExitPool{ Sender: addr1, PoolId: 1, - ShareInAmount: sdk.NewInt(10), - TokenOutMins: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(10)), sdk.NewCoin("test2", sdk.NewInt(20))), + ShareInAmount: osmomath.NewInt(10), + TokenOutMins: sdk.NewCoins(sdk.NewCoin("test1", osmomath.NewInt(10)), sdk.NewCoin("test2", osmomath.NewInt(20))), } return after(properMsg) } @@ -426,7 +427,7 @@ func TestMsgExitPool(t *testing.T) { { name: "negative requirement", msg: createMsg(func(msg gammtypes.MsgExitPool) gammtypes.MsgExitPool { - msg.ShareInAmount = sdk.NewInt(-10) + msg.ShareInAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -434,7 +435,7 @@ func TestMsgExitPool(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgExitPool) gammtypes.MsgExitPool { - msg.TokenOutMins[1].Amount = sdk.NewInt(0) + msg.TokenOutMins[1].Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -442,7 +443,7 @@ func TestMsgExitPool(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgExitPool) gammtypes.MsgExitPool { - msg.TokenOutMins[1].Amount = sdk.NewInt(-10) + msg.TokenOutMins[1].Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -484,8 +485,8 @@ func TestMsgJoinSwapExternAmountIn(t *testing.T) { properMsg := gammtypes.MsgJoinSwapExternAmountIn{ Sender: addr1, PoolId: 1, - TokenIn: sdk.NewCoin("test", sdk.NewInt(100)), - ShareOutMinAmount: sdk.NewInt(100), + TokenIn: sdk.NewCoin("test", osmomath.NewInt(100)), + ShareOutMinAmount: osmomath.NewInt(100), } return after(properMsg) } @@ -533,7 +534,7 @@ func TestMsgJoinSwapExternAmountIn(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgJoinSwapExternAmountIn) gammtypes.MsgJoinSwapExternAmountIn { - msg.TokenIn.Amount = sdk.NewInt(0) + msg.TokenIn.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -541,7 +542,7 @@ func TestMsgJoinSwapExternAmountIn(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgJoinSwapExternAmountIn) gammtypes.MsgJoinSwapExternAmountIn { - msg.TokenIn.Amount = sdk.NewInt(-10) + msg.TokenIn.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -549,7 +550,7 @@ func TestMsgJoinSwapExternAmountIn(t *testing.T) { { name: "zero criteria", msg: createMsg(func(msg gammtypes.MsgJoinSwapExternAmountIn) gammtypes.MsgJoinSwapExternAmountIn { - msg.ShareOutMinAmount = sdk.NewInt(0) + msg.ShareOutMinAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -557,7 +558,7 @@ func TestMsgJoinSwapExternAmountIn(t *testing.T) { { name: "negative criteria", msg: createMsg(func(msg gammtypes.MsgJoinSwapExternAmountIn) gammtypes.MsgJoinSwapExternAmountIn { - msg.ShareOutMinAmount = sdk.NewInt(-10) + msg.ShareOutMinAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -584,8 +585,8 @@ func TestMsgJoinSwapShareAmountOut(t *testing.T) { Sender: addr1, PoolId: 1, TokenInDenom: "test", - ShareOutAmount: sdk.NewInt(100), - TokenInMaxAmount: sdk.NewInt(100), + ShareOutAmount: osmomath.NewInt(100), + TokenInMaxAmount: osmomath.NewInt(100), } return after(properMsg) } @@ -633,7 +634,7 @@ func TestMsgJoinSwapShareAmountOut(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgJoinSwapShareAmountOut) gammtypes.MsgJoinSwapShareAmountOut { - msg.ShareOutAmount = sdk.NewInt(0) + msg.ShareOutAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -641,7 +642,7 @@ func TestMsgJoinSwapShareAmountOut(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgJoinSwapShareAmountOut) gammtypes.MsgJoinSwapShareAmountOut { - msg.ShareOutAmount = sdk.NewInt(-10) + msg.ShareOutAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -649,7 +650,7 @@ func TestMsgJoinSwapShareAmountOut(t *testing.T) { { name: "zero criteria", msg: createMsg(func(msg gammtypes.MsgJoinSwapShareAmountOut) gammtypes.MsgJoinSwapShareAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(0) + msg.TokenInMaxAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -657,7 +658,7 @@ func TestMsgJoinSwapShareAmountOut(t *testing.T) { { name: "negative criteria", msg: createMsg(func(msg gammtypes.MsgJoinSwapShareAmountOut) gammtypes.MsgJoinSwapShareAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(-10) + msg.TokenInMaxAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -683,8 +684,8 @@ func TestMsgExitSwapExternAmountOut(t *testing.T) { properMsg := gammtypes.MsgExitSwapExternAmountOut{ Sender: addr1, PoolId: 1, - TokenOut: sdk.NewCoin("test", sdk.NewInt(100)), - ShareInMaxAmount: sdk.NewInt(100), + TokenOut: sdk.NewCoin("test", osmomath.NewInt(100)), + ShareInMaxAmount: osmomath.NewInt(100), } return after(properMsg) } @@ -732,7 +733,7 @@ func TestMsgExitSwapExternAmountOut(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgExitSwapExternAmountOut) gammtypes.MsgExitSwapExternAmountOut { - msg.TokenOut.Amount = sdk.NewInt(0) + msg.TokenOut.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -740,7 +741,7 @@ func TestMsgExitSwapExternAmountOut(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgExitSwapExternAmountOut) gammtypes.MsgExitSwapExternAmountOut { - msg.TokenOut.Amount = sdk.NewInt(-10) + msg.TokenOut.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -748,7 +749,7 @@ func TestMsgExitSwapExternAmountOut(t *testing.T) { { name: "zero criteria", msg: createMsg(func(msg gammtypes.MsgExitSwapExternAmountOut) gammtypes.MsgExitSwapExternAmountOut { - msg.ShareInMaxAmount = sdk.NewInt(0) + msg.ShareInMaxAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -756,7 +757,7 @@ func TestMsgExitSwapExternAmountOut(t *testing.T) { { name: "negative criteria", msg: createMsg(func(msg gammtypes.MsgExitSwapExternAmountOut) gammtypes.MsgExitSwapExternAmountOut { - msg.ShareInMaxAmount = sdk.NewInt(-10) + msg.ShareInMaxAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -783,8 +784,8 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { Sender: addr1, PoolId: 1, TokenOutDenom: "test", - ShareInAmount: sdk.NewInt(100), - TokenOutMinAmount: sdk.NewInt(100), + ShareInAmount: osmomath.NewInt(100), + TokenOutMinAmount: osmomath.NewInt(100), } return after(properMsg) } @@ -832,7 +833,7 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg gammtypes.MsgExitSwapShareAmountIn) gammtypes.MsgExitSwapShareAmountIn { - msg.ShareInAmount = sdk.NewInt(0) + msg.ShareInAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -840,7 +841,7 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg gammtypes.MsgExitSwapShareAmountIn) gammtypes.MsgExitSwapShareAmountIn { - msg.ShareInAmount = sdk.NewInt(-10) + msg.ShareInAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -848,7 +849,7 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { { name: "zero criteria", msg: createMsg(func(msg gammtypes.MsgExitSwapShareAmountIn) gammtypes.MsgExitSwapShareAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(0) + msg.TokenOutMinAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -856,7 +857,7 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { { name: "negative criteria", msg: createMsg(func(msg gammtypes.MsgExitSwapShareAmountIn) gammtypes.MsgExitSwapShareAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(-10) + msg.TokenOutMinAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -876,7 +877,7 @@ func TestMsgExitSwapShareAmountIn(t *testing.T) { func TestAuthzMsg(t *testing.T) { pk1 := ed25519.GenPrivKey().PubKey() addr1 := sdk.AccAddress(pk1.Address()).String() - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)) testCases := []struct { name string @@ -888,8 +889,8 @@ func TestAuthzMsg(t *testing.T) { Sender: addr1, PoolId: 1, TokenOutDenom: "test", - ShareInAmount: sdk.NewInt(100), - TokenOutMinAmount: sdk.NewInt(100), + ShareInAmount: osmomath.NewInt(100), + TokenOutMinAmount: osmomath.NewInt(100), }, }, { @@ -898,7 +899,7 @@ func TestAuthzMsg(t *testing.T) { Sender: addr1, PoolId: 1, TokenOut: coin, - ShareInMaxAmount: sdk.NewInt(1), + ShareInMaxAmount: osmomath.NewInt(1), }, }, { @@ -906,7 +907,7 @@ func TestAuthzMsg(t *testing.T) { gammMsg: &gammtypes.MsgExitPool{ Sender: addr1, PoolId: 1, - ShareInAmount: sdk.NewInt(100), + ShareInAmount: osmomath.NewInt(100), TokenOutMins: sdk.NewCoins(coin), }, }, @@ -915,7 +916,7 @@ func TestAuthzMsg(t *testing.T) { gammMsg: &gammtypes.MsgJoinPool{ Sender: addr1, PoolId: 1, - ShareOutAmount: sdk.NewInt(1), + ShareOutAmount: osmomath.NewInt(1), TokenInMaxs: sdk.NewCoins(coin), }, }, @@ -925,7 +926,7 @@ func TestAuthzMsg(t *testing.T) { Sender: addr1, PoolId: 1, TokenIn: coin, - ShareOutMinAmount: sdk.NewInt(1), + ShareOutMinAmount: osmomath.NewInt(1), }, }, { @@ -940,7 +941,7 @@ func TestAuthzMsg(t *testing.T) { TokenOutDenom: "test2", }}, TokenIn: coin, - TokenOutMinAmount: sdk.NewInt(1), + TokenOutMinAmount: osmomath.NewInt(1), }, }, { @@ -955,7 +956,7 @@ func TestAuthzMsg(t *testing.T) { TokenInDenom: "test2", }}, TokenOut: coin, - TokenInMaxAmount: sdk.NewInt(1), + TokenInMaxAmount: osmomath.NewInt(1), }, }, { diff --git a/x/gamm/types/pool.go b/x/gamm/types/pool.go index 4b2cb3d33bc..4fc08b2a84b 100644 --- a/x/gamm/types/pool.go +++ b/x/gamm/types/pool.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -18,45 +19,45 @@ type CFMMPoolI interface { // This function is mutative and updates the pool's internal state if there is no error. // It is up to pool implementation if they support LP'ing at arbitrary ratios, or a subset of ratios. // Pools are expected to guarantee LP'ing at the exact ratio, and single sided LP'ing. - JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) + JoinPool(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) // JoinPoolNoSwap joins the pool with an all-asset join using the maximum amount possible given the tokensIn provided. // This function is mutative and updates the pool's internal state if there is no error. // Pools are expected to guarantee LP'ing at the exact ratio. - JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, err error) + JoinPoolNoSwap(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, err error) // ExitPool exits #numShares LP shares from the pool, decreases its internal liquidity & LP share totals, // and returns the number of coins that are being returned. // This mutates the pool and state. - ExitPool(ctx sdk.Context, numShares sdk.Int, exitFee sdk.Dec) (exitedCoins sdk.Coins, err error) + ExitPool(ctx sdk.Context, numShares osmomath.Int, exitFee osmomath.Dec) (exitedCoins sdk.Coins, err error) // CalcJoinPoolNoSwapShares returns how many LP shares JoinPoolNoSwap would return on these arguments. // This does not mutate the pool, or state. - CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, newLiquidity sdk.Coins, err error) + CalcJoinPoolNoSwapShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, newLiquidity sdk.Coins, err error) // CalcExitPoolCoinsFromShares returns how many coins ExitPool would return on these arguments. // This does not mutate the pool, or state. - CalcExitPoolCoinsFromShares(ctx sdk.Context, numShares sdk.Int, exitFee sdk.Dec) (exitedCoins sdk.Coins, err error) + CalcExitPoolCoinsFromShares(ctx sdk.Context, numShares osmomath.Int, exitFee osmomath.Dec) (exitedCoins sdk.Coins, err error) // CalcJoinPoolShares returns how many LP shares JoinPool would return on these arguments. // This does not mutate the pool, or state. - CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor sdk.Dec) (numShares sdk.Int, newLiquidity sdk.Coins, err error) + CalcJoinPoolShares(ctx sdk.Context, tokensIn sdk.Coins, spreadFactor osmomath.Dec) (numShares osmomath.Int, newLiquidity sdk.Coins, err error) // SwapOutAmtGivenIn swaps 'tokenIn' against the pool, for tokenOutDenom, with the provided spreadFactor charged. // Balance transfers are done in the keeper, but this method updates the internal pool state. - SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor sdk.Dec) (tokenOut sdk.Coin, err error) + SwapOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor osmomath.Dec) (tokenOut sdk.Coin, err error) // CalcOutAmtGivenIn returns how many coins SwapOutAmtGivenIn would return on these arguments. // This does not mutate the pool, or state. - CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor sdk.Dec) (tokenOut sdk.Coin, err error) + CalcOutAmtGivenIn(ctx sdk.Context, tokenIn sdk.Coins, tokenOutDenom string, spreadFactor osmomath.Dec) (tokenOut sdk.Coin, err error) // SwapInAmtGivenOut swaps exactly enough tokensIn against the pool, to get the provided tokenOut amount out of the pool. // Balance transfers are done in the keeper, but this method updates the internal pool state. - SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (tokenIn sdk.Coin, err error) + SwapInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (tokenIn sdk.Coin, err error) // CalcInAmtGivenOut returns how many coins SwapInAmtGivenOut would return on these arguments. // This does not mutate the pool, or state. - CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor sdk.Dec) (tokenIn sdk.Coin, err error) + CalcInAmtGivenOut(ctx sdk.Context, tokenOut sdk.Coins, tokenInDenom string, spreadFactor osmomath.Dec) (tokenIn sdk.Coin, err error) // GetTotalShares returns the total number of LP shares in the pool - GetTotalShares() sdk.Int + GetTotalShares() osmomath.Int // GetTotalPoolLiquidity returns the coins in the pool owned by all LPs GetTotalPoolLiquidity(ctx sdk.Context) sdk.Coins // 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 + GetExitFee(ctx sdk.Context) osmomath.Dec } // PoolAmountOutExtension is an extension of the PoolI @@ -76,28 +77,28 @@ type PoolAmountOutExtension interface { CalcTokenInShareAmountOut( ctx sdk.Context, tokenInDenom string, - shareOutAmount sdk.Int, - spreadFactor sdk.Dec, - ) (tokenInAmount sdk.Int, err error) + shareOutAmount osmomath.Int, + spreadFactor osmomath.Dec, + ) (tokenInAmount osmomath.Int, err error) // JoinPoolTokenInMaxShareAmountOut add liquidity to a specified pool with a maximum amount of tokens in (tokenInMaxAmount) // and swaps to an exact number of shares (shareOutAmount). JoinPoolTokenInMaxShareAmountOut( ctx sdk.Context, tokenInDenom string, - shareOutAmount sdk.Int, - ) (tokenInAmount sdk.Int, err error) + shareOutAmount osmomath.Int, + ) (tokenInAmount osmomath.Int, err error) // ExitSwapExactAmountOut removes liquidity from a specified pool with a maximum amount of LP shares (shareInMaxAmount) // and swaps to an exact amount of one of the token pairs (tokenOut). ExitSwapExactAmountOut( ctx sdk.Context, tokenOut sdk.Coin, - shareInMaxAmount sdk.Int, - ) (shareInAmount sdk.Int, err error) + shareInMaxAmount osmomath.Int, + ) (shareInAmount osmomath.Int, err error) // IncreaseLiquidity increases the pool's liquidity by the specified sharesOut and coinsIn. - IncreaseLiquidity(sharesOut sdk.Int, coinsIn sdk.Coins) + IncreaseLiquidity(sharesOut osmomath.Int, coinsIn sdk.Coins) } // WeightedPoolExtension is an extension of the PoolI interface @@ -110,5 +111,5 @@ type WeightedPoolExtension interface { PokePool(blockTime time.Time) // GetTokenWeight returns the weight of the specified token in the pool. - GetTokenWeight(denom string) (sdk.Int, error) + GetTokenWeight(denom string) (osmomath.Int, error) } diff --git a/x/gamm/types/query.pb.go b/x/gamm/types/query.pb.go index 70985c9f930..bcd3f590a2a 100644 --- a/x/gamm/types/query.pb.go +++ b/x/gamm/types/query.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -457,7 +458,7 @@ func (m *QueryCalcJoinPoolSharesRequest) GetTokensIn() github_com_cosmos_cosmos_ } type QueryCalcJoinPoolSharesResponse struct { - ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"share_out_amount"` + ShareOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_amount" yaml:"share_out_amount"` TokensOut github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,2,rep,name=tokens_out,json=tokensOut,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_out"` } @@ -503,8 +504,8 @@ func (m *QueryCalcJoinPoolSharesResponse) GetTokensOut() github_com_cosmos_cosmo // =============================== CalcExitPoolCoinsFromShares type QueryCalcExitPoolCoinsFromSharesRequest struct { - PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` - ShareInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_amount"` + PoolId uint64 `protobuf:"varint,1,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty"` + ShareInAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_in_amount"` } func (m *QueryCalcExitPoolCoinsFromSharesRequest) Reset() { @@ -923,7 +924,7 @@ func (m *QueryCalcJoinPoolNoSwapSharesRequest) GetTokensIn() github_com_cosmos_c type QueryCalcJoinPoolNoSwapSharesResponse struct { TokensOut github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=tokens_out,json=tokensOut,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"tokens_out" yaml:"tokens_out"` - SharesOut github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=shares_out,json=sharesOut,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"shares_out"` + SharesOut cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=shares_out,json=sharesOut,proto3,customtype=cosmossdk.io/math.Int" json:"shares_out"` } func (m *QueryCalcJoinPoolNoSwapSharesResponse) Reset() { *m = QueryCalcJoinPoolNoSwapSharesResponse{} } @@ -1267,7 +1268,7 @@ func (m *QuerySwapExactAmountInRequest) GetRoutes() []types2.SwapAmountInRoute { // Deprecated: Do not use. type QuerySwapExactAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *QuerySwapExactAmountInResponse) Reset() { *m = QuerySwapExactAmountInResponse{} } @@ -1376,7 +1377,7 @@ func (m *QuerySwapExactAmountOutRequest) GetTokenOut() string { // Deprecated: Do not use. type QuerySwapExactAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *QuerySwapExactAmountOutResponse) Reset() { *m = QuerySwapExactAmountOutResponse{} } @@ -1712,136 +1713,136 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/query.proto", fileDescriptor_d9a717df9ca609ef) } var fileDescriptor_d9a717df9ca609ef = []byte{ - // 2055 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0x4d, 0x6c, 0x1b, 0xc7, - 0x15, 0xd6, 0xc8, 0xb2, 0x22, 0x8d, 0x6d, 0xfd, 0x4c, 0xe4, 0x98, 0xa6, 0x6c, 0xd1, 0x99, 0x26, - 0x92, 0x63, 0x4b, 0x4b, 0xc9, 0x56, 0xd0, 0x46, 0x8d, 0x13, 0x4b, 0x8a, 0x64, 0x53, 0xb0, 0x2c, - 0x65, 0x1d, 0xb4, 0x68, 0x8b, 0x76, 0xb1, 0x22, 0xd7, 0xd4, 0xc6, 0xdc, 0x1d, 0x9a, 0x3b, 0x1b, - 0x4b, 0x08, 0x8c, 0x00, 0x39, 0xa5, 0xbd, 0xa4, 0x40, 0xdb, 0x14, 0x2d, 0x8a, 0xf6, 0x12, 0x14, - 0x45, 0xcf, 0x05, 0x7a, 0xea, 0xa1, 0xe8, 0xc5, 0xe8, 0xc9, 0x68, 0x7b, 0x28, 0x7a, 0x60, 0x0b, - 0xbb, 0xbd, 0xf5, 0xa4, 0x4b, 0xae, 0xc5, 0xcc, 0xbc, 0xfd, 0x21, 0xb9, 0x5c, 0xfe, 0x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x00, 0x00, 0xff, 0xff, 0x55, 0xee, 0xd8, 0xe5, 0x10, 0x1f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/gamm/types/tx.pb.go b/x/gamm/types/tx.pb.go index 651289866f7..b88ffe87ca3 100644 --- a/x/gamm/types/tx.pb.go +++ b/x/gamm/types/tx.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/gogo/protobuf/gogoproto" @@ -35,10 +35,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgJoinPool // This is really MsgJoinPoolNoSwap type MsgJoinPool struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"pool_amount_out"` - TokenInMaxs []types.Coin `protobuf:"bytes,4,rep,name=token_in_maxs,json=tokenInMaxs,proto3" json:"token_in_maxs" yaml:"token_in_max_amounts"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + ShareOutAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_amount" yaml:"pool_amount_out"` + TokenInMaxs []types.Coin `protobuf:"bytes,4,rep,name=token_in_maxs,json=tokenInMaxs,proto3" json:"token_in_maxs" yaml:"token_in_max_amounts"` } func (m *MsgJoinPool) Reset() { *m = MsgJoinPool{} } @@ -96,8 +96,8 @@ func (m *MsgJoinPool) GetTokenInMaxs() []types.Coin { } type MsgJoinPoolResponse struct { - ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"share_out_amount"` - TokenIn []types.Coin `protobuf:"bytes,2,rep,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` + ShareOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_amount" yaml:"share_out_amount"` + TokenIn []types.Coin `protobuf:"bytes,2,rep,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` } func (m *MsgJoinPoolResponse) Reset() { *m = MsgJoinPoolResponse{} } @@ -142,10 +142,10 @@ func (m *MsgJoinPoolResponse) GetTokenIn() []types.Coin { // ===================== MsgExitPool type MsgExitPool struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - ShareInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_amount" yaml:"share_in_amount"` - TokenOutMins []types.Coin `protobuf:"bytes,4,rep,name=token_out_mins,json=tokenOutMins,proto3" json:"token_out_mins" yaml:"token_out_min_amounts"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + ShareInAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_in_amount" yaml:"share_in_amount"` + TokenOutMins []types.Coin `protobuf:"bytes,4,rep,name=token_out_mins,json=tokenOutMins,proto3" json:"token_out_mins" yaml:"token_out_min_amounts"` } func (m *MsgExitPool) Reset() { *m = MsgExitPool{} } @@ -248,10 +248,10 @@ func (m *MsgExitPoolResponse) GetTokenOut() []types.Coin { // ===================== MsgSwapExactAmountIn type MsgSwapExactAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []types1.SwapAmountInRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` - TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []types1.SwapAmountInRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` + TokenOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` } func (m *MsgSwapExactAmountIn) Reset() { *m = MsgSwapExactAmountIn{} } @@ -309,7 +309,7 @@ func (m *MsgSwapExactAmountIn) GetTokenIn() types.Coin { } type MsgSwapExactAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *MsgSwapExactAmountInResponse) Reset() { *m = MsgSwapExactAmountInResponse{} } @@ -346,10 +346,10 @@ func (m *MsgSwapExactAmountInResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSwapExactAmountInResponse proto.InternalMessageInfo type MsgSwapExactAmountOut struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []types1.SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` - TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []types1.SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` + TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` } func (m *MsgSwapExactAmountOut) Reset() { *m = MsgSwapExactAmountOut{} } @@ -407,7 +407,7 @@ func (m *MsgSwapExactAmountOut) GetTokenOut() types.Coin { } type MsgSwapExactAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *MsgSwapExactAmountOutResponse) Reset() { *m = MsgSwapExactAmountOutResponse{} } @@ -446,10 +446,10 @@ var xxx_messageInfo_MsgSwapExactAmountOutResponse proto.InternalMessageInfo // ===================== MsgJoinSwapExternAmountIn // TODO: Rename to MsgJoinSwapExactAmountIn type MsgJoinSwapExternAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` - ShareOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=share_out_min_amount,json=shareOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_min_amount" yaml:"share_out_min_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` + ShareOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=share_out_min_amount,json=shareOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_min_amount" yaml:"share_out_min_amount"` } func (m *MsgJoinSwapExternAmountIn) Reset() { *m = MsgJoinSwapExternAmountIn{} } @@ -507,7 +507,7 @@ func (m *MsgJoinSwapExternAmountIn) GetTokenIn() types.Coin { } type MsgJoinSwapExternAmountInResponse struct { - ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"share_out_amount"` + ShareOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_amount" yaml:"share_out_amount"` } func (m *MsgJoinSwapExternAmountInResponse) Reset() { *m = MsgJoinSwapExternAmountInResponse{} } @@ -545,11 +545,11 @@ var xxx_messageInfo_MsgJoinSwapExternAmountInResponse proto.InternalMessageInfo // ===================== MsgJoinSwapShareAmountOut type MsgJoinSwapShareAmountOut struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - TokenInDenom string `protobuf:"bytes,3,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty" yaml:"token_in_denom"` - ShareOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_out_amount" yaml:"share_out_amount"` - TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenInDenom string `protobuf:"bytes,3,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty" yaml:"token_in_denom"` + ShareOutAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=share_out_amount,json=shareOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_out_amount" yaml:"share_out_amount"` + TokenInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` } func (m *MsgJoinSwapShareAmountOut) Reset() { *m = MsgJoinSwapShareAmountOut{} } @@ -607,7 +607,7 @@ func (m *MsgJoinSwapShareAmountOut) GetTokenInDenom() string { } type MsgJoinSwapShareAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *MsgJoinSwapShareAmountOutResponse) Reset() { *m = MsgJoinSwapShareAmountOutResponse{} } @@ -645,11 +645,11 @@ var xxx_messageInfo_MsgJoinSwapShareAmountOutResponse proto.InternalMessageInfo // ===================== MsgExitSwapShareAmountIn type MsgExitSwapShareAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - TokenOutDenom string `protobuf:"bytes,3,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty" yaml:"token_out_denom"` - ShareInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_amount" yaml:"share_in_amount"` - TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenOutDenom string `protobuf:"bytes,3,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty" yaml:"token_out_denom"` + ShareInAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_in_amount" yaml:"share_in_amount"` + TokenOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,5,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` } func (m *MsgExitSwapShareAmountIn) Reset() { *m = MsgExitSwapShareAmountIn{} } @@ -707,7 +707,7 @@ func (m *MsgExitSwapShareAmountIn) GetTokenOutDenom() string { } type MsgExitSwapShareAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *MsgExitSwapShareAmountInResponse) Reset() { *m = MsgExitSwapShareAmountInResponse{} } @@ -745,10 +745,10 @@ var xxx_messageInfo_MsgExitSwapShareAmountInResponse proto.InternalMessageInfo // ===================== MsgExitSwapExternAmountOut type MsgExitSwapExternAmountOut struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` - TokenOut types.Coin `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` - ShareInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=share_in_max_amount,json=shareInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_max_amount" yaml:"share_in_max_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + PoolId uint64 `protobuf:"varint,2,opt,name=pool_id,json=poolId,proto3" json:"pool_id,omitempty" yaml:"pool_id"` + TokenOut types.Coin `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` + ShareInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=share_in_max_amount,json=shareInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_in_max_amount" yaml:"share_in_max_amount"` } func (m *MsgExitSwapExternAmountOut) Reset() { *m = MsgExitSwapExternAmountOut{} } @@ -806,7 +806,7 @@ func (m *MsgExitSwapExternAmountOut) GetTokenOut() types.Coin { } type MsgExitSwapExternAmountOutResponse struct { - ShareInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"share_in_amount" yaml:"share_in_amount"` + ShareInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=share_in_amount,json=shareInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"share_in_amount" yaml:"share_in_amount"` } func (m *MsgExitSwapExternAmountOutResponse) Reset() { *m = MsgExitSwapExternAmountOutResponse{} } @@ -864,83 +864,83 @@ func init() { func init() { proto.RegisterFile("osmosis/gamm/v1beta1/tx.proto", fileDescriptor_cfc8fd3ac7df3247) } var fileDescriptor_cfc8fd3ac7df3247 = []byte{ - // 1214 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x58, 0xcb, 0x6e, 0xdb, 0x46, - 0x14, 0x35, 0x25, 0xc5, 0x76, 0xc6, 0xf5, 0x43, 0x8c, 0x1f, 0x32, 0x9d, 0x48, 0xf6, 0xb4, 0x70, - 0x9c, 0x38, 0x22, 0x63, 0x07, 0xe8, 0xc3, 0x9b, 0xa2, 0x6a, 0x03, 0x54, 0x41, 0x04, 0x05, 0xcc, - 0x26, 0xe8, 0x46, 0xa0, 0x2c, 0x42, 0x61, 0x63, 0xce, 0x08, 0x1a, 0xd2, 0x51, 0x50, 0xa0, 0x05, - 0x0a, 0xb4, 0x40, 0xbb, 0x6a, 0x51, 0xf4, 0xf1, 0x19, 0xdd, 0xf6, 0x0f, 0xb2, 0xcc, 0xa2, 0x05, - 0xda, 0x14, 0x10, 0x0a, 0x7b, 0xd1, 0x6d, 0xa1, 0x2f, 0x28, 0x86, 0x33, 0xa4, 0x48, 0x8a, 0xb4, - 0x44, 0x47, 0x8a, 0x37, 0x89, 0x35, 0x73, 0x5f, 0x73, 0xee, 0xe1, 0x99, 0x4b, 0x82, 0x6b, 0x98, - 0x98, 0x98, 0x18, 0x44, 0x69, 0x6a, 0xa6, 0xa9, 0x1c, 0xef, 0xd5, 0x75, 0x4b, 0xdb, 0x53, 0xac, - 0x8e, 0xdc, 0x6a, 0x63, 0x0b, 0x8b, 0xcb, 0x7c, 0x5b, 0xa6, 0xdb, 0x32,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0xbe, 0xf3, 0xdd, 0x8c, 0xf5, - 0x1f, 0xb0, 0x95, 0xf6, 0x47, 0xb7, 0xf5, 0x92, 0x1e, 0x03, 0x31, 0xe2, 0x4d, 0x62, 0x77, 0xd4, - 0x48, 0x55, 0xdb, 0x92, 0xee, 0x24, 0x30, 0xf6, 0xf2, 0x7e, 0x29, 0x80, 0xd5, 0x98, 0x11, 0x55, - 0x39, 0xb3, 0x19, 0x83, 0x0e, 0xd2, 0x3b, 0x09, 0x1d, 0x22, 0x8b, 0x08, 0x4d, 0x46, 0xc3, 0x8b, - 0x08, 0x3a, 0x8c, 0x50, 0x44, 0xcc, 0x25, 0xfd, 0x95, 0x00, 0xd6, 0xe2, 0xd4, 0xeb, 0xf6, 0x99, - 0xec, 0x89, 0xf0, 0x90, 0xde, 0x4d, 0xea, 0xe1, 0xd5, 0xf1, 0x05, 0x58, 0x89, 0xbe, 0xb6, 0xe5, - 0xa1, 0x21, 0x03, 0xf6, 0xd2, 0xdb, 0xc9, 0xec, 0xdd, 0x02, 0x4a, 0xf7, 0x9e, 0x9f, 0xe4, 0x85, - 0x17, 0x27, 0x79, 0xe1, 0x9f, 0x93, 0xbc, 0xf0, 0xdd, 0x69, 0x7e, 0xea, 0xc5, 0x69, 0x7e, 0xea, - 0xcf, 0xd3, 0xfc, 0xd4, 0x27, 0xb7, 0x7d, 0x32, 0xc1, 0x63, 0x17, 0x8f, 0xb4, 0x3a, 0x71, 0x7f, - 0x28, 0xc7, 0x7b, 0xef, 0x29, 0x1d, 0x26, 0x5b, 0x8e, 0x68, 0xd4, 0xa7, 0x9d, 0x4f, 0xa9, 0x77, - 0xfe, 0x0f, 0x00, 0x00, 0xff, 0xff, 0x78, 0x71, 0x07, 0x17, 0xf8, 0x15, 0x00, 0x00, + // 1207 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0x4d, 0x6f, 0xdb, 0x46, +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 0x2e, 0xf5, + 0x92, 0xf1, 0x57, 0x0a, 0x48, 0xbe, 0x44, 0xfc, 0x22, 0x38, 0x49, 0xed, 0x09, 0x9c, 0xed, 0xe9, + 0x31, 0x9c, 0xed, 0x4c, 0x28, 0x3c, 0x42, 0xf8, 0x84, 0x22, 0x33, 0x94, 0x50, 0x44, 0x44, 0x80, + 0xea, 0x12, 0xa7, 0x55, 0x4f, 0x28, 0x0a, 0x0c, 0xea, 0x9d, 0x18, 0xa8, 0x83, 0xe7, 0x0c, 0xcb, + 0xf2, 0x8d, 0x00, 0x60, 0x7c, 0x8f, 0xfd, 0x52, 0x11, 0x1e, 0x08, 0x61, 0x9c, 0x03, 0xb1, 0xff, + 0xf3, 0x0c, 0x48, 0x97, 0x49, 0x43, 0x7c, 0x06, 0x66, 0xbd, 0xcf, 0x03, 0xdb, 0x72, 0xd4, 0xc7, + 0x0b, 0xd9, 0xf7, 0xd6, 0x2b, 0xdd, 0x4e, 0x34, 0xf1, 0x4a, 0x78, 0x06, 0x66, 0xbd, 0x37, 0xcc, + 0xf8, 0xc8, 0xae, 0xc9, 0x05, 0x91, 0xfb, 0xde, 0xad, 0x08, 0x58, 0xee, 0x7f, 0x0b, 0xba, 0x13, + 0xeb, 0xdf, 0x67, 0x2b, 0xed, 0x0f, 0x6e, 0xeb, 0x6d, 0x7a, 0x02, 0xc4, 0x88, 0xdb, 0xf7, 0xee, + 0xa0, 0x91, 0x2a, 0x16, 0x95, 0xee, 0x0f, 0x61, 0xec, 0xed, 0xfb, 0x5a, 0x00, 0x6b, 0x31, 0x17, + 0x3f, 0xe5, 0x42, 0x30, 0xfa, 0x1d, 0xa4, 0x07, 0x43, 0x3a, 0x44, 0x26, 0x11, 0xba, 0x91, 0x24, + 0x27, 0x11, 0x74, 0x18, 0x20, 0x89, 0x98, 0xe3, 0xf3, 0x8d, 0x00, 0xd6, 0xe3, 0xb4, 0xe9, 0xde, + 0x85, 0xec, 0x89, 0xf0, 0x90, 0x1e, 0x0e, 0xeb, 0xe1, 0xe5, 0xf1, 0x25, 0x58, 0x8d, 0x3e, 0x61, + 0xe5, 0xc4, 0x90, 0x01, 0x7b, 0xe9, 0xfd, 0xe1, 0xec, 0xdd, 0x04, 0x8a, 0x8f, 0x4f, 0xcf, 0x72, + 0xc2, 0xdb, 0xb3, 0x9c, 0xf0, 0xe7, 0x59, 0x4e, 0xf8, 0xfe, 0x3c, 0x37, 0xf5, 0xf6, 0x3c, 0x37, + 0xf5, 0xdb, 0x79, 0x6e, 0xea, 0x8b, 0x7b, 0x0d, 0x83, 0x1e, 0x59, 0x35, 0xf9, 0x10, 0x9b, 0x0a, + 0x8f, 0x5d, 0x38, 0xd6, 0x6a, 0xc4, 0xfd, 0xa1, 0x9c, 0xec, 0x7d, 0xa0, 0xb4, 0x1d, 0x95, 0xa2, + 0xaf, 0x9a, 0x3a, 0xa9, 0x4d, 0xdb, 0x5f, 0x0a, 0xef, 0xff, 0x17, 0x00, 0x00, 0xff, 0xff, 0xdd, + 0xe7, 0xf0, 0x9f, 0xd7, 0x14, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/ibc-hooks/go.mod b/x/ibc-hooks/go.mod index 1297d79a3db..1884e9ebd59 100644 --- a/x/ibc-hooks/go.mod +++ b/x/ibc-hooks/go.mod @@ -6,11 +6,12 @@ require ( cosmossdk.io/errors v1.0.0 github.com/CosmWasm/wasmd v0.31.0 github.com/cosmos/cosmos-proto v1.0.0-beta.3 - github.com/cosmos/cosmos-sdk v0.47.4 + github.com/cosmos/cosmos-sdk v0.47.5 github.com/cosmos/ibc-go/v4 v4.3.1 github.com/gogo/protobuf v1.3.3 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae github.com/spf13/cobra v1.7.0 github.com/tendermint/tendermint v0.37.0-rc1 @@ -18,6 +19,7 @@ require ( ) require ( + cosmossdk.io/math v1.1.3-rc.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 @@ -28,7 +30,7 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd v0.22.3 // indirect - github.com/bytedance/sonic v1.10.0 // indirect + github.com/bytedance/sonic v1.10.1 // 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 @@ -92,7 +94,6 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect github.com/nxadm/tail v1.4.8 // indirect - github.com/onsi/gomega v1.27.6 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/pelletier/go-toml/v2 v2.0.8 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect @@ -150,8 +151,8 @@ replace ( github.com/CosmWasm/wasmvm => github.com/CosmWasm/wasmvm v1.2.3 // dragonberry github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/ed4eb883f2a65bd5343e9d2f6186060f45294cb2 - github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230703010110-ed4eb883f2a6 + // Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: v16.x. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/c92a56002bede63d4a3d5d0af94443c8bcdc1095 + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 // use cosmos-compatible protobufs github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/tendermint/tendermint => github.com/informalsystems/tendermint v0.34.24 diff --git a/x/ibc-hooks/go.sum b/x/ibc-hooks/go.sum index 85315307c78..4f6ac9fb78e 100644 --- a/x/ibc-hooks/go.sum +++ b/x/ibc-hooks/go.sum @@ -40,6 +40,8 @@ cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9 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 h1:nxF07lmlBbB8NKQhtJ+sJm6ef5uV1XkvPXG2bUntb04= +cosmossdk.io/errors v1.0.0/go.mod h1:+hJZLuhdDE0pYN8HkOrVNwrIOYvUGnn6+4fjnJs/oV0= +cosmossdk.io/math v1.1.3-rc.0 h1:lut7IbQGuqog4vEIHSB7ivtwwIr6rHrt5yoVowmtoDs= 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= @@ -144,7 +146,9 @@ github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= -github.com/bytedance/sonic v1.10.0 h1:qtNZduETEIWJVIyDl01BeNxur2rW9OwTQ/yBqFRkKEk= +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.1 h1:7a1wuFXL1cMy7a3f7/VFcEtriuXQnUBhtoVfOZiaysc= 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= @@ -159,8 +163,12 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +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= @@ -191,6 +199,7 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.3 h1:VitvZ1lPORTVxkmF2fAp3IiA61xVwArQYKXTdEcpW6o= +github.com/cosmos/cosmos-proto v1.0.0-beta.3/go.mod h1:t8IASdLaAq+bbHbjq4p960BvcTqtwuAxid3b/2rOD6I= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 h1:iKclrn3YEOwk4jQHT2ulgzuXyxmzmPczUalMwW4XH9k= github.com/cosmos/cosmos-sdk/ics23/go v0.8.0/go.mod h1:2a4dBq88TUoqoWAU5eu0lGvpFP3wWDPgdHPargtyw30= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= @@ -352,6 +361,7 @@ github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGw 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.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= @@ -565,10 +575,12 @@ github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8 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/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/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= @@ -588,6 +600,7 @@ github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgx github.com/leodido/go-urn v1.2.4 h1:XlAE/cm/ms7TE/VMVoduSpNBoyc2dOxHs5MZSwAN63Q= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= +github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -702,8 +715,9 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= 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/cosmos-sdk v0.45.0-rc1.0.20230913192254-a2075590d5a3 h1:kRNCIZn9NU8BBObAsFj0Zp05QQo/4iLDfRiXgtXF//I= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d h1:b8Bz31kbzTbcSNsBOcvc2CRVJz5C3cGOQB7JqWDzdfA= +github.com/osmosis-labs/osmosis/osmomath v0.0.7-0.20230907220438-2f6dd779bc6d/go.mod h1:Jj4zQ/IA8iPuHF+Hc/dTFJqAis5WYX3EcO7Xg70fAd8= 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/wasmd v0.31.0-osmo-v16 h1:X747cZYdnqc/+RV48iPVeGprpVb/fUWSaKGsZUWrdbg= @@ -812,6 +826,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= @@ -888,6 +903,7 @@ github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1 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 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= @@ -940,6 +956,7 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k= 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= @@ -964,6 +981,7 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm 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.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= +golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= 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= @@ -979,6 +997,7 @@ golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EH golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea h1:vLCWI/yYrdEHyN2JzIzPO3aaQJHQdp89IZBA/+azVC4= +golang.org/x/exp v0.0.0-20230510235704-dd950f8aeaea/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1058,6 +1077,7 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx 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.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= 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= @@ -1154,14 +1174,17 @@ golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/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.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.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.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= 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= @@ -1172,6 +1195,7 @@ 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.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.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= @@ -1238,6 +1262,7 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1321,8 +1346,11 @@ google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6D 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-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.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1362,6 +1390,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba 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.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= @@ -1409,10 +1438,12 @@ honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= 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= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/x/ibc-hooks/wasm_hook.go b/x/ibc-hooks/wasm_hook.go index 8c169649b31..ea348a74cc6 100644 --- a/x/ibc-hooks/wasm_hook.go +++ b/x/ibc-hooks/wasm_hook.go @@ -3,6 +3,7 @@ package ibc_hooks import ( "encoding/json" "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" @@ -10,6 +11,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/x/ibc-hooks/keeper" "github.com/osmosis-labs/osmosis/osmoutils" @@ -88,7 +90,7 @@ func (h WasmHooks) OnRecvPacketOverride(im IBCMiddleware, ctx sdk.Context, packe return ack } - amount, ok := sdk.NewIntFromString(data.GetAmount()) + amount, ok := osmomath.NewIntFromString(data.GetAmount()) if !ok { // This should never happen, as it should've been caught in the underlaying call to OnRecvPacket, // but returning here for completeness diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go index c07424653f2..de57fd7d37b 100644 --- a/x/ibc-rate-limit/ibc_middleware_test.go +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -15,6 +15,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v4/testing" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" txfeetypes "github.com/osmosis-labs/osmosis/v19/x/txfees/types" "github.com/osmosis-labs/osmosis/v19/app/apptesting" @@ -52,7 +53,7 @@ func NewTransferPath(chainA, chainB *osmosisibctesting.TestChain) *ibctesting.Pa func (suite *MiddlewareTestSuite) SetupTest() { suite.SkipIfWSL() // TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123 - txfeetypes.ConsensusMinFee = sdk.ZeroDec() + txfeetypes.ConsensusMinFee = osmomath.ZeroDec() suite.Setup() ibctesting.DefaultTestingAppInit = osmosisibctesting.SetupTestingApp suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) @@ -77,7 +78,7 @@ func (suite *MiddlewareTestSuite) TearDownSuite() { } // Helpers -func (suite *MiddlewareTestSuite) MessageFromAToB(denom string, amount sdk.Int) sdk.Msg { +func (suite *MiddlewareTestSuite) MessageFromAToB(denom string, amount osmomath.Int) sdk.Msg { coin := sdk.NewCoin(denom, amount) port := suite.path.EndpointA.ChannelConfig.PortID channel := suite.path.EndpointA.ChannelID @@ -95,7 +96,7 @@ func (suite *MiddlewareTestSuite) MessageFromAToB(denom string, amount sdk.Int) ) } -func (suite *MiddlewareTestSuite) MessageFromBToA(denom string, amount sdk.Int) sdk.Msg { +func (suite *MiddlewareTestSuite) MessageFromBToA(denom string, amount osmomath.Int) sdk.Msg { coin := sdk.NewCoin(denom, amount) port := suite.path.EndpointB.ChannelConfig.PortID channel := suite.path.EndpointB.ChannelID @@ -113,7 +114,7 @@ func (suite *MiddlewareTestSuite) MessageFromBToA(denom string, amount sdk.Int) ) } -func CalculateChannelValue(ctx sdk.Context, denom string, bankKeeper bankkeeper.Keeper) sdk.Int { +func CalculateChannelValue(ctx sdk.Context, denom string, bankKeeper bankkeeper.Keeper) osmomath.Int { return bankKeeper.GetSupplyWithOffset(ctx, denom).Amount // ToDo: The commented-out code bellow is what we want to happen, but we're temporarily @@ -127,7 +128,7 @@ func CalculateChannelValue(ctx sdk.Context, denom string, bankKeeper bankkeeper. // // For native tokens, obtain the balance held in escrow for all potential channels //channels := channelKeeper.GetAllChannels(ctx) - //balance := sdk.NewInt(0) + //balance := osmomath.NewInt(0) //for _, channel := range channels { // escrowAddress := transfertypes.GetEscrowAddress("transfer", channel.ChannelId) // balance = balance.Add(bankKeeper.GetBalance(ctx, escrowAddress, denom).Amount) @@ -141,7 +142,7 @@ func (suite *MiddlewareTestSuite) TestInvalidReceiver() { msg := transfertypes.NewMsgTransfer( suite.path.EndpointB.ChannelConfig.PortID, suite.path.EndpointB.ChannelID, - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), + sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)), suite.chainB.SenderAccount.GetAddress().String(), strings.Repeat("x", 4097), clienttypes.NewHeight(0, 100), @@ -252,19 +253,19 @@ func (suite *MiddlewareTestSuite) BuildChannelQuota(name, channel, denom string, // Test that Sending IBC messages works when the middleware isn't configured func (suite *MiddlewareTestSuite) TestSendTransferNoContract() { - one := sdk.NewInt(1) + one := osmomath.NewInt(1) _, err := suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, one)) suite.Require().NoError(err) } // Test that Receiving IBC messages works when the middleware isn't configured func (suite *MiddlewareTestSuite) TestReceiveTransferNoContract() { - one := sdk.NewInt(1) + one := osmomath.NewInt(1) _, err := suite.AssertReceive(true, suite.MessageFromBToA(sdk.DefaultBondDenom, one)) suite.Require().NoError(err) } -func (suite *MiddlewareTestSuite) initializeEscrow() (totalEscrow, expectedSed sdk.Int) { +func (suite *MiddlewareTestSuite) initializeEscrow() (totalEscrow, expectedSed osmomath.Int) { osmosisApp := suite.chainA.GetOsmosisApp() supply := osmosisApp.BankKeeper.GetSupplyWithOffset(suite.chainA.GetContext(), sdk.DefaultBondDenom) @@ -329,13 +330,13 @@ func (suite *MiddlewareTestSuite) fullSendTest(native bool) map[string]string { // Calculate remaining allowance in the quota attrs := suite.ExtractAttributes(suite.FindEvent(r.GetEvents(), "wasm")) - used, ok := sdk.NewIntFromString(attrs["weekly_used_out"]) + used, ok := osmomath.NewIntFromString(attrs["weekly_used_out"]) suite.Require().True(ok) suite.Require().Equal(used, sendAmount.MulRaw(2)) // Sending above the quota should fail. We use 2 instead of 1 here to avoid rounding issues - _, err = suite.AssertSend(false, suite.MessageFromAToB(denom, sdk.NewInt(2))) + _, err = suite.AssertSend(false, suite.MessageFromAToB(denom, osmomath.NewInt(2))) suite.Require().Error(err) return attrs } @@ -375,7 +376,7 @@ func (suite *MiddlewareTestSuite) TestSendTransferReset() { suite.coordinator.IncrementTimeBy(oneSecAfterReset.Sub(suite.coordinator.CurrentTime)) // Sending should succeed again - _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, osmomath.NewInt(1))) suite.Require().NoError(err) } @@ -421,7 +422,7 @@ func (suite *MiddlewareTestSuite) fullRecvTest(native bool) { suite.Require().NoError(err) // Sending above the quota should fail. We send 2 instead of 1 to account for rounding errors - _, err = suite.AssertReceive(false, suite.MessageFromBToA(sendDenom, sdk.NewInt(2))) + _, err = suite.AssertReceive(false, suite.MessageFromBToA(sendDenom, osmomath.NewInt(2))) suite.Require().NoError(err) } @@ -448,7 +449,7 @@ func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { // send 1 token. // If the contract doesn't have a quota for the current channel, all transfers are allowed - _, err := suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err := suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, osmomath.NewInt(1))) suite.Require().NoError(err) } @@ -519,7 +520,7 @@ func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { suite.Require().NoError(err) // We should be able to send again because the packet that exceeded the quota failed and has been reverted - _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) + _, err = suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, osmomath.NewInt(1))) suite.Require().NoError(err) } diff --git a/x/incentives/client/cli/query_test.go b/x/incentives/client/cli/query_test.go index 8ee4aa34541..3da6a4dd9fe 100644 --- a/x/incentives/client/cli/query_test.go +++ b/x/incentives/client/cli/query_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -25,7 +26,7 @@ func (s *QueryTestSuite) SetupSuite() { // create a pool s.PrepareBalancerPool() // set up lock with id = 1 - s.LockTokens(s.TestAccs[0], sdk.Coins{sdk.NewCoin("gamm/pool/1", sdk.NewInt(1000000))}, time.Hour*24) + s.LockTokens(s.TestAccs[0], sdk.Coins{sdk.NewCoin("gamm/pool/1", osmomath.NewInt(1000000))}, time.Hour*24) s.Commit() } diff --git a/x/incentives/keeper/distribute.go b/x/incentives/keeper/distribute.go index 39457b61e05..11ddd09ab6e 100644 --- a/x/incentives/keeper/distribute.go +++ b/x/incentives/keeper/distribute.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -322,13 +323,13 @@ func (k Keeper) distributeInternal( // is supposed to distribute over that epoch. for _, remainCoin := range remainCoins { // remaining coin amount per epoch. - remainAmountPerEpoch := remainCoin.Amount.Quo(sdk.NewIntFromUint64(remainEpochs)) + remainAmountPerEpoch := remainCoin.Amount.Quo(osmomath.NewIntFromUint64(remainEpochs)) remainCoinPerEpoch := sdk.NewCoin(remainCoin.Denom, remainAmountPerEpoch) // emissionRate calculates amount of tokens to emit per second // for ex: 10000uosmo to be distributed over 1day epoch will be 1000 tokens ÷ 86,400 seconds ≈ 0.01157 tokens per second (truncated) // Note: reason why we do millisecond conversion is because floats are non-deterministic. - emissionRate := sdk.NewDecFromInt(remainAmountPerEpoch).QuoTruncate(sdk.NewDec(currentEpoch.Duration.Milliseconds()).QuoInt(sdk.NewInt(1000))) + emissionRate := osmomath.NewDecFromInt(remainAmountPerEpoch).QuoTruncate(osmomath.NewDec(currentEpoch.Duration.Milliseconds()).QuoInt(osmomath.NewInt(1000))) ctx.Logger().Info("distributeInternal, CreateIncentiveRecord NoLock gauge", "module", types.ModuleName, "gaugeId", gauge.Id, "poolId", pool.GetId(), "remainCoinPerEpoch", remainCoinPerEpoch, "height", ctx.BlockHeight()) _, err := k.clk.CreateIncentive(ctx, @@ -367,7 +368,7 @@ func (k Keeper) distributeInternal( // Remove some spam gauges, is state compatible. // If they're to pool 1 they can't distr at this small of a quantity. - if remainCoins.Len() == 1 && remainCoins[0].Amount.LTE(sdk.NewInt(10)) && gauge.DistributeTo.Denom == "gamm/pool/1" && remainCoins[0].Denom != "uosmo" { + if remainCoins.Len() == 1 && remainCoins[0].Amount.LTE(osmomath.NewInt(10)) && gauge.DistributeTo.Denom == "gamm/pool/1" && remainCoins[0].Denom != "uosmo" { ctx.Logger().Debug(fmt.Sprintf("gauge debug, this gauge is perceived spam, skipping %d", gauge.Id)) err := k.updateGaugePostDistribute(ctx, gauge, totalDistrCoins) return totalDistrCoins, err @@ -403,7 +404,7 @@ func (k Keeper) distributeInternal( for _, coin := range remainCoins { // distribution amount = gauge_size * denom_lock_amount / (total_denom_lock_amount * remain_epochs) denomLockAmt := lock.Coins.AmountOfNoDenomValidation(denom) - amt := coin.Amount.Mul(denomLockAmt).Quo(lockSum.Mul(sdk.NewInt(int64(remainEpochs)))) + amt := coin.Amount.Mul(denomLockAmt).Quo(lockSum.Mul(osmomath.NewInt(int64(remainEpochs)))) if amt.IsPositive() { newlyDistributedCoin := sdk.Coin{Denom: coin.Denom, Amount: amt} distrCoins = distrCoins.Add(newlyDistributedCoin) diff --git a/x/incentives/keeper/distribute_test.go b/x/incentives/keeper/distribute_test.go index fdc4473b06e..70b8db0c4bb 100644 --- a/x/incentives/keeper/distribute_test.go +++ b/x/incentives/keeper/distribute_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" osmoutils "github.com/osmosis-labs/osmosis/osmoutils" appParams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -173,7 +174,7 @@ func (s *KeeperTestSuite) TestDistribute_InternalIncentives_NoLock() { fiveKRewardCoinsUosmo := sdk.NewInt64Coin(appParams.BaseCoinUnit, 5000) fifteenKRewardCoins := sdk.NewInt64Coin(defaultRewardDenom, 15000) - coinsToMint := sdk.NewCoins(sdk.NewCoin(defaultRewardDenom, sdk.NewInt(10000000)), sdk.NewCoin(appParams.BaseCoinUnit, sdk.NewInt(10000000))) + coinsToMint := sdk.NewCoins(sdk.NewCoin(defaultRewardDenom, osmomath.NewInt(10000000)), sdk.NewCoin(appParams.BaseCoinUnit, osmomath.NewInt(10000000))) defaultGaugeStartTime := s.Ctx.BlockTime() incentivesParams := s.App.IncentivesKeeper.GetParams(s.Ctx).DistrEpochIdentifier @@ -300,7 +301,7 @@ func (s *KeeperTestSuite) TestDistribute_InternalIncentives_NoLock() { balance := s.App.BankKeeper.GetAllBalances(s.Ctx, s.App.AccountKeeper.GetModuleAddress(types.ModuleName)) for _, coin := range balance { actualbalanceAfterDistribution := coinsToMint.AmountOf(coin.Denom).Sub(coin.Amount) - s.Require().Equal(tc.expectedDistributions.AmountOf(coin.Denom).Add(sdk.ZeroInt()), actualbalanceAfterDistribution.Add(sdk.ZeroInt())) + s.Require().Equal(tc.expectedDistributions.AmountOf(coin.Denom).Add(osmomath.ZeroInt()), actualbalanceAfterDistribution.Add(osmomath.ZeroInt())) } for i, gauge := range gauges { @@ -317,7 +318,7 @@ func (s *KeeperTestSuite) TestDistribute_InternalIncentives_NoLock() { incentiveRecord, err := s.App.ConcentratedLiquidityKeeper.GetIncentiveRecord(s.Ctx, poolId, types.DefaultConcentratedUptime, uint64(incentiveId)) s.Require().NoError(err) - expectedEmissionRate := sdk.NewDecFromInt(coin.Amount).QuoTruncate(sdk.NewDec(int64(currentEpoch.Duration.Seconds()))) + expectedEmissionRate := osmomath.NewDecFromInt(coin.Amount).QuoTruncate(osmomath.NewDec(int64(currentEpoch.Duration.Seconds()))) // Check that gauge distribution state is updated. s.ValidateDistributedGauge(gaugeId, 1, tc.gaugeCoins) @@ -388,7 +389,7 @@ func (s *KeeperTestSuite) TestDistribute_ExternalIncentives_NoLock() { expectErr: false, expectedDistributions: sdk.NewCoins(fiveKRewardCoins), - expectedRemainingAmountIncentiveRecord: []sdk.Dec{sdk.NewDec(defaultAmount)}, + expectedRemainingAmountIncentiveRecord: []osmomath.Dec{osmomath.NewDec(defaultAmount)}, } withIsPerpetual := func(tc test, isPerpetual bool) test { @@ -401,7 +402,7 @@ func (s *KeeperTestSuite) TestDistribute_ExternalIncentives_NoLock() { tc.expectedDistributions = gaugeCoins tc.expectedRemainingAmountIncentiveRecord = make([]sdk.Dec, len(gaugeCoins)) for i := range tc.expectedRemainingAmountIncentiveRecord { - tc.expectedRemainingAmountIncentiveRecord[i] = sdk.NewDec(gaugeCoins[i].Amount.Int64()) + tc.expectedRemainingAmountIncentiveRecord[i] = osmomath.NewDec(gaugeCoins[i].Amount.Int64()) } return tc } @@ -421,10 +422,10 @@ func (s *KeeperTestSuite) TestDistribute_ExternalIncentives_NoLock() { for i := range tc.expectedRemainingAmountIncentiveRecord { // update expected distributions - tempDistributions[i].Amount = tc.expectedDistributions[i].Amount.Quo(sdk.NewInt(int64(numEpochs))) + tempDistributions[i].Amount = tc.expectedDistributions[i].Amount.Quo(osmomath.NewInt(int64(numEpochs))) // update expected remaining amount in incentive record - tempRemainingAmountIncentiveRecord[i] = tc.expectedRemainingAmountIncentiveRecord[i].QuoTruncate(sdk.NewDec(int64(numEpochs))).TruncateDec() + tempRemainingAmountIncentiveRecord[i] = tc.expectedRemainingAmountIncentiveRecord[i].QuoTruncate(osmomath.NewDec(int64(numEpochs))).TruncateDec() } tc.expectedDistributions = tempDistributions @@ -506,14 +507,14 @@ func (s *KeeperTestSuite) TestDistribute_ExternalIncentives_NoLock() { s.Require().Equal(tc.expectedDistributions, totalDistributedCoins) incentivesEpochDuration := s.App.IncentivesKeeper.GetEpochInfo(s.Ctx).Duration - incentivesEpochDurationSeconds := sdk.NewDec(incentivesEpochDuration.Milliseconds()).QuoInt(sdk.NewInt(1000)) + incentivesEpochDurationSeconds := osmomath.NewDec(incentivesEpochDuration.Milliseconds()).QuoInt(osmomath.NewInt(1000)) // Check that incentive records were created for i, coin := range tc.expectedDistributions { incentiveRecords, err := s.App.ConcentratedLiquidityKeeper.GetIncentiveRecord(s.Ctx, tc.poolId, time.Nanosecond, uint64(i+1)) s.Require().NoError(err) - expectedEmissionRatePerEpoch := coin.Amount.ToDec().QuoTruncate(incentivesEpochDurationSeconds) + expectedEmissionRatePerEpoch := coin.Amount.ToLegacyDec().QuoTruncate(incentivesEpochDurationSeconds) s.Require().Equal(tc.startTime.UTC(), incentiveRecords.IncentiveRecordBody.StartTime.UTC()) s.Require().Equal(coin.Denom, incentiveRecords.IncentiveRecordBody.RemainingCoin.Denom) @@ -883,30 +884,31 @@ func (s *KeeperTestSuite) TestGetPoolFromGaugeId() { // TestFunctionalInternalExternalCLGauge is a functional test that covers more complex scenarios relating to distributing incentives through gauges // at the end of each epoch. // -// // Testing strategy: // 1. Initialize variables. // 2. Setup CL pool and gauge (gauge automatically gets created at the end of CL pool creation). // 3. Create external no-lock gauges for CL pools // 4. Create Distribution records to incentivize internal CL no-lock gauges // 5. let epoch 1 pass -// - we only distribute external incentive in epoch 1. -// - Check that incentive record has been correctly created and gauge has been correctly updated. -// - all perpetual gauges must finish distributing records -// - ClPool1 will recieve full 1Musdc, 1Meth in this epoch. -// - ClPool2 will recieve 500kusdc, 500keth in this epoch. -// - ClPool3 will recieve full 1Musdc, 1Meth in this epoch whereas +// - we only distribute external incentive in epoch 1. +// - Check that incentive record has been correctly created and gauge has been correctly updated. +// - all perpetual gauges must finish distributing records +// - ClPool1 will recieve full 1Musdc, 1Meth in this epoch. +// - ClPool2 will recieve 500kusdc, 500keth in this epoch. +// - ClPool3 will recieve full 1Musdc, 1Meth in this epoch whereas +// // 6. Remove distribution records for internal incentives using HandleReplacePoolIncentivesProposal // 7. let epoch 2 pass -// - We distribute internal incentive in epoch 2. -// - check only external non-perpetual gauges with 2 epochs distributed -// - check gauge has been correctly updated -// - ClPool1 will already have 1Musdc, 1Meth (from epoch1) as external incentive. Will recieve 750Kstake as internal incentive. -// - ClPool2 will already have 500kusdc, 500keth (from epoch1) as external incentive. Will recieve 500kusdc, 500keth (from epoch 2) as external incentive and 750Kstake as internal incentive. -// - ClPool3 will already have 1M, 1M (from epoch1) as external incentive. This pool will not recieve any internal incentive. +// - We distribute internal incentive in epoch 2. +// - check only external non-perpetual gauges with 2 epochs distributed +// - check gauge has been correctly updated +// - ClPool1 will already have 1Musdc, 1Meth (from epoch1) as external incentive. Will recieve 750Kstake as internal incentive. +// - ClPool2 will already have 500kusdc, 500keth (from epoch1) as external incentive. Will recieve 500kusdc, 500keth (from epoch 2) as external incentive and 750Kstake as internal incentive. +// - ClPool3 will already have 1M, 1M (from epoch1) as external incentive. This pool will not recieve any internal incentive. +// // 8. let epoch 3 pass -// - nothing distributes as non-perpetual gauges with 2 epochs have ended and perpetual gauges have not been reloaded -// - nothing should change in terms of incentive records +// - nothing distributes as non-perpetual gauges with 2 epochs have ended and perpetual gauges have not been reloaded +// - nothing should change in terms of incentive records func (s *KeeperTestSuite) TestFunctionalInternalExternalCLGauge() { // 1. Initialize variables s.SetupTest() @@ -1102,11 +1104,11 @@ func (s *KeeperTestSuite) CreateNoLockExternalGauges(clPoolId uint64, externalGa } func (s *KeeperTestSuite) IncentivizeInternalGauge(poolIds []uint64, epochDuration time.Duration, removeDistrRecord bool) { - var weight sdk.Int + var weight osmomath.Int if !removeDistrRecord { - weight = sdk.NewInt(100) + weight = osmomath.NewInt(100) } else { - weight = sdk.ZeroInt() + weight = osmomath.ZeroInt() } var gaugeIds []uint64 diff --git a/x/incentives/keeper/export_test.go b/x/incentives/keeper/export_test.go index 5be094c0683..1b3212b2468 100644 --- a/x/incentives/keeper/export_test.go +++ b/x/incentives/keeper/export_test.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" ) @@ -37,6 +38,6 @@ func (k Keeper) MoveActiveGaugeToFinishedGauge(ctx sdk.Context, gauge types.Gaug } // ChargeFeeIfSufficientFeeDenomBalance see chargeFeeIfSufficientFeeDenomBalance spec. -func (k Keeper) ChargeFeeIfSufficientFeeDenomBalance(ctx sdk.Context, address sdk.AccAddress, fee sdk.Int, gaugeCoins sdk.Coins) error { +func (k Keeper) ChargeFeeIfSufficientFeeDenomBalance(ctx sdk.Context, address sdk.AccAddress, fee osmomath.Int, gaugeCoins sdk.Coins) error { return k.chargeFeeIfSufficientFeeDenomBalance(ctx, address, fee, gaugeCoins) } diff --git a/x/incentives/keeper/gauge.go b/x/incentives/keeper/gauge.go index daa376d8453..6d7b2e95c39 100644 --- a/x/incentives/keeper/gauge.go +++ b/x/incentives/keeper/gauge.go @@ -16,6 +16,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -358,7 +359,7 @@ func (k Keeper) GetEpochInfo(ctx sdk.Context) epochtypes.EpochInfo { // gaugeCoins might not have a coin of tx base denom. In that case, fee is only compared to balance. // The fee is sent to the community pool. // Returns nil on success, error otherwise. -func (k Keeper) chargeFeeIfSufficientFeeDenomBalance(ctx sdk.Context, address sdk.AccAddress, fee sdk.Int, gaugeCoins sdk.Coins) (err error) { +func (k Keeper) chargeFeeIfSufficientFeeDenomBalance(ctx sdk.Context, address sdk.AccAddress, fee osmomath.Int, gaugeCoins sdk.Coins) (err error) { feeDenom, err := k.tk.GetBaseDenom(ctx) if err != nil { return err diff --git a/x/incentives/keeper/gauge_test.go b/x/incentives/keeper/gauge_test.go index 2cc12c76347..3d7a83bc26f 100644 --- a/x/incentives/keeper/gauge_test.go +++ b/x/incentives/keeper/gauge_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -248,51 +249,51 @@ func (s *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { expectError bool }{ "fee + base denom gauge coin == acount balance, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee / 2, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee/2))), }, "fee + base denom gauge coin < acount balance, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee/2 - 1, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee/2))), }, "fee + base denom gauge coin > acount balance, error": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee/2 + 1, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee/2))), expectError: true, }, "fee + base denom gauge coin < acount balance, custom values, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(11793193112)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(11793193112)), feeToCharge: 55, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(328812))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(328812))), }, "account funded with coins other than base denom, error": { - accountBalanceToFund: sdk.NewCoin("usdc", sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin("usdc", osmomath.NewInt(baseFee)), feeToCharge: baseFee, - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee/2))), expectError: true, }, "fee == account balance, no gauge coins, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee, }, "gauge coins == account balance, no fee, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), - gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee))), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), + gaugeCoins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee))), }, "fee == account balance, gauge coins in denom other than base, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee, - gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", osmomath.NewInt(baseFee*2))), }, "fee + gauge coins == account balance, multiple gauge coins, one in denom other than base, success": { - accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee)), + accountBalanceToFund: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee)), feeToCharge: baseFee / 2, - gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", sdk.NewInt(baseFee*2)), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(baseFee/2))), + gaugeCoins: sdk.NewCoins(sdk.NewCoin("usdc", osmomath.NewInt(baseFee*2)), sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(baseFee/2))), }, } @@ -312,7 +313,7 @@ func (s *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { oldBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, sdk.DefaultBondDenom).Amount // System under test. - err := incentivesKeepers.ChargeFeeIfSufficientFeeDenomBalance(ctx, testAccount, sdk.NewInt(tc.feeToCharge), tc.gaugeCoins) + err := incentivesKeepers.ChargeFeeIfSufficientFeeDenomBalance(ctx, testAccount, osmomath.NewInt(tc.feeToCharge), tc.gaugeCoins) // Assertions. newBalanceAmount := bankKeeper.GetBalance(ctx, testAccount, sdk.DefaultBondDenom).Amount @@ -325,7 +326,7 @@ func (s *KeeperTestSuite) TestChargeFeeIfSufficientFeeDenomBalance() { s.Require().NoError(err) // check account balance changed. - expectedNewBalanceAmount := oldBalanceAmount.Sub(sdk.NewInt(tc.feeToCharge)) + expectedNewBalanceAmount := oldBalanceAmount.Sub(osmomath.NewInt(tc.feeToCharge)) s.Require().Equal(expectedNewBalanceAmount.String(), newBalanceAmount.String()) } }) @@ -346,8 +347,8 @@ func (s *KeeperTestSuite) TestAddToGaugeRewards() { name: "valid case: valid gauge", owner: s.TestAccs[0], coinsToAdd: sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(100000)), - sdk.NewCoin("atom", sdk.NewInt(99999)), + sdk.NewCoin("uosmo", osmomath.NewInt(100000)), + sdk.NewCoin("atom", osmomath.NewInt(99999)), ), gaugeId: 1, minimumGasConsumed: uint64(2 * types.BaseGasFeeForAddRewardToGauge), @@ -358,14 +359,14 @@ func (s *KeeperTestSuite) TestAddToGaugeRewards() { name: "valid case: valid gauge with >4 denoms", owner: s.TestAccs[0], coinsToAdd: sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(100000)), - sdk.NewCoin("atom", sdk.NewInt(99999)), - sdk.NewCoin("mars", sdk.NewInt(88888)), - sdk.NewCoin("akash", sdk.NewInt(77777)), - sdk.NewCoin("eth", sdk.NewInt(6666)), - sdk.NewCoin("usdc", sdk.NewInt(555)), - sdk.NewCoin("dai", sdk.NewInt(4444)), - sdk.NewCoin("ust", sdk.NewInt(3333)), + sdk.NewCoin("uosmo", osmomath.NewInt(100000)), + sdk.NewCoin("atom", osmomath.NewInt(99999)), + sdk.NewCoin("mars", osmomath.NewInt(88888)), + sdk.NewCoin("akash", osmomath.NewInt(77777)), + sdk.NewCoin("eth", osmomath.NewInt(6666)), + sdk.NewCoin("usdc", osmomath.NewInt(555)), + sdk.NewCoin("dai", osmomath.NewInt(4444)), + sdk.NewCoin("ust", osmomath.NewInt(3333)), ), gaugeId: 1, minimumGasConsumed: uint64(8 * types.BaseGasFeeForAddRewardToGauge), @@ -376,8 +377,8 @@ func (s *KeeperTestSuite) TestAddToGaugeRewards() { name: "invalid case: gauge Id is not valid", owner: s.TestAccs[0], coinsToAdd: sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(100000)), - sdk.NewCoin("atom", sdk.NewInt(99999)), + sdk.NewCoin("uosmo", osmomath.NewInt(100000)), + sdk.NewCoin("atom", osmomath.NewInt(99999)), ), gaugeId: 0, minimumGasConsumed: uint64(0), @@ -453,8 +454,8 @@ func (s *KeeperTestSuite) TestCreateGauge_NoLockGauges() { var ( defaultCoins = sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(100000)), - sdk.NewCoin("atom", sdk.NewInt(99999)), + sdk.NewCoin("uosmo", osmomath.NewInt(100000)), + sdk.NewCoin("atom", osmomath.NewInt(99999)), ) defaultTime = time.Unix(0, 0) diff --git a/x/incentives/keeper/grpc_query_test.go b/x/incentives/keeper/grpc_query_test.go index 5a301127077..527ef8132f0 100644 --- a/x/incentives/keeper/grpc_query_test.go +++ b/x/incentives/keeper/grpc_query_test.go @@ -8,6 +8,7 @@ import ( query "github.com/cosmos/cosmos-sdk/types/query" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" pooltypes "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" @@ -387,7 +388,7 @@ func (s *KeeperTestSuite) TestRewardsEstWithPoolIncentives() { // take newly created gauge and modify its pool incentives distribution weight to 100 distrRecord := pooltypes.DistrRecord{ GaugeId: gaugeID, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), } err = s.App.PoolIncentivesKeeper.ReplaceDistrRecords(s.Ctx, distrRecord) s.Require().NoError(err) @@ -407,7 +408,7 @@ func (s *KeeperTestSuite) TestRewardsEstWithPoolIncentives() { s.App.EpochsKeeper.AfterEpochEnd(s.Ctx, epochIdentifier, curEpochNumber) // TODO: Figure out what this number should be // TODO: Respond to this - mintCoins := sdk.NewCoin(coins[0].Denom, sdk.NewInt(1500000)) + mintCoins := sdk.NewCoin(coins[0].Denom, osmomath.NewInt(1500000)) // query the rewards of the new address after the 10th epoch // since it is the only address the gauge is paying out to, the future rewards should equal the entirety of the gauge plus the newly minted coins diff --git a/x/incentives/keeper/keeper_test.go b/x/incentives/keeper/keeper_test.go index 31babf3f89b..d58daf83004 100644 --- a/x/incentives/keeper/keeper_test.go +++ b/x/incentives/keeper/keeper_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/incentives/keeper" @@ -48,7 +49,7 @@ func (s *KeeperTestSuite) ValidateNotDistributedGauge(gaugeID uint64) { s.ValidateDistributedGauge(gaugeID, 0, sdk.Coins(nil)) } -func (s *KeeperTestSuite) ValidateIncentiveRecord(poolId uint64, remainingCoin sdk.DecCoin, emissionRate sdk.Dec, incentiveRecord cltypes.IncentiveRecord) { +func (s *KeeperTestSuite) ValidateIncentiveRecord(poolId uint64, remainingCoin sdk.DecCoin, emissionRate osmomath.Dec, incentiveRecord cltypes.IncentiveRecord) { s.Require().Equal(poolId, incentiveRecord.PoolId) s.Require().Equal(emissionRate, incentiveRecord.GetIncentiveRecordBody().EmissionRate) s.Require().Equal(types.DefaultConcentratedUptime, incentiveRecord.MinUptime) diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index a9dbb73e02d..317ec64fa2c 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/keeper" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -18,8 +19,8 @@ import ( var _ = suite.TestingSuite(nil) var ( - seventyTokens = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000))) - tenTokens = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000))) + seventyTokens = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000))) + tenTokens = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10000000))) ) func (s *KeeperTestSuite) TestCreateGauge_Fee() { @@ -34,48 +35,48 @@ func (s *KeeperTestSuite) TestCreateGauge_Fee() { }{ { name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(60000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(60000000))), gaugeAddition: tenTokens, }, { name: "user creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000))), gaugeAddition: tenTokens, }, { name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, }, { name: "module account creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, isPerpetual: true, isModuleAccount: true, }, { name: "user with multiple denoms creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, isPerpetual: true, }, { name: "user tries to create a non-perpetual gauge but does not have enough funds to pay for the create gauge fee", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(40000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(40000000))), gaugeAddition: tenTokens, expectErr: true, }, { name: "user tries to create a non-perpetual gauge but does not have the correct fee denom", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(60000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(60000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10000000))), expectErr: true, }, { name: "one user tries to create a gauge, has enough funds to pay for the create gauge fee but not enough to fill the gauge", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(60000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(30000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(60000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(30000000))), expectErr: true, }, } @@ -151,7 +152,7 @@ func (s *KeeperTestSuite) TestAddToGauge_Fee() { }{ { name: "user creates a non-perpetual gauge and fills gauge with all remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(35000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(35000000))), gaugeAddition: tenTokens, }, { @@ -161,32 +162,32 @@ func (s *KeeperTestSuite) TestAddToGauge_Fee() { }, { name: "user with multiple denoms creates a non-perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, }, { name: "module account creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, isPerpetual: true, isModuleAccount: true, }, { name: "user with multiple denoms creates a perpetual gauge and fills gauge with some remaining tokens", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(70000000)), sdk.NewCoin("foo", sdk.NewInt(70000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(70000000)), sdk.NewCoin("foo", osmomath.NewInt(70000000))), gaugeAddition: tenTokens, isPerpetual: true, }, { name: "user tries to create a non-perpetual gauge but does not have enough funds to pay for the create gauge fee", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20000000))), gaugeAddition: tenTokens, expectErr: true, }, { name: "user tries to add to a non-perpetual gauge but does not have the correct fee denom", - accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(60000000))), - gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000000))), + accountBalanceToFund: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(60000000))), + gaugeAddition: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10000000))), expectErr: true, }, { @@ -220,7 +221,7 @@ func (s *KeeperTestSuite) TestAddToGauge_Fee() { } // System under test. - coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(500000000))) + coins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(500000000))) gaugeID, gauge, _, _ := s.SetupNewGauge(tc.isPerpetual, coins) if tc.nonexistentGauge { gaugeID = incentivesKeeper.GetLastGaugeID(s.Ctx) + 1 @@ -257,7 +258,7 @@ func (s *KeeperTestSuite) TestAddToGauge_Fee() { } func (s *KeeperTestSuite) completeGauge(gauge *types.Gauge, sendingAddress sdk.AccAddress) { - lockCoins := sdk.NewCoin(gauge.DistributeTo.Denom, sdk.NewInt(1000)) + lockCoins := sdk.NewCoin(gauge.DistributeTo.Denom, osmomath.NewInt(1000)) s.FundAcc(sendingAddress, sdk.NewCoins(lockCoins)) s.LockTokens(sendingAddress, sdk.NewCoins(lockCoins), gauge.DistributeTo.Duration) epochId := s.App.IncentivesKeeper.GetEpochInfo(s.Ctx).Identifier diff --git a/x/incentives/simulation/operations.go b/x/incentives/simulation/operations.go index e7a144517aa..4247437acad 100644 --- a/x/incentives/simulation/operations.go +++ b/x/incentives/simulation/operations.go @@ -4,6 +4,7 @@ import ( "math/rand" "time" + "github.com/osmosis-labs/osmosis/osmomath" osmosimtypes "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" "github.com/cosmos/cosmos-sdk/baseapp" @@ -63,12 +64,12 @@ func WeightedOperations( } // genRewardCoins generates a random number of coin denoms with a respective random value for each coin. -func genRewardCoins(r *rand.Rand, coins sdk.Coins, fee sdk.Int) (res sdk.Coins) { +func genRewardCoins(r *rand.Rand, coins sdk.Coins, fee osmomath.Int) (res sdk.Coins) { numCoins := 1 + r.Intn(Min(coins.Len(), 1)) denomIndices := r.Perm(numCoins) for i := 0; i < numCoins; i++ { var ( - amt sdk.Int + amt osmomath.Int err error ) denom := coins[denomIndices[i]].Denom diff --git a/x/incentives/types/expected_keepers.go b/x/incentives/types/expected_keepers.go index 35e877862b6..034230f71e7 100644 --- a/x/incentives/types/expected_keepers.go +++ b/x/incentives/types/expected_keepers.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -26,7 +27,7 @@ type BankKeeper interface { // LockupKeeper defines the expected interface needed to retrieve locks. type LockupKeeper interface { GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, duration time.Duration) []lockuptypes.PeriodLock - GetPeriodLocksAccumulation(ctx sdk.Context, query lockuptypes.QueryCondition) sdk.Int + GetPeriodLocksAccumulation(ctx sdk.Context, query lockuptypes.QueryCondition) osmomath.Int GetAccountPeriodLocks(ctx sdk.Context, addr sdk.AccAddress) []lockuptypes.PeriodLock GetLockByID(ctx sdk.Context, lockID uint64) (*lockuptypes.PeriodLock, error) } @@ -47,7 +48,7 @@ type TxFeesKeeper interface { } type ConcentratedLiquidityKeeper interface { - CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveCoin sdk.Coin, emissionRate sdk.Dec, startTime time.Time, minUptime time.Duration) (cltypes.IncentiveRecord, error) + CreateIncentive(ctx sdk.Context, poolId uint64, sender sdk.AccAddress, incentiveCoin sdk.Coin, emissionRate osmomath.Dec, startTime time.Time, minUptime time.Duration) (cltypes.IncentiveRecord, error) GetConcentratedPoolById(ctx sdk.Context, poolId uint64) (cltypes.ConcentratedPoolExtension, error) } diff --git a/x/incentives/types/gauge.go b/x/incentives/types/gauge.go index 7b774186829..62fad62acc4 100644 --- a/x/incentives/types/gauge.go +++ b/x/incentives/types/gauge.go @@ -3,6 +3,7 @@ package types import ( time "time" + "github.com/osmosis-labs/osmosis/osmomath" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,9 +11,9 @@ import ( var ( // CreateGaugeFee is the fee required to create a new gauge. - CreateGaugeFee = sdk.NewInt(50 * 1_000_000) + CreateGaugeFee = osmomath.NewInt(50 * 1_000_000) // AddToGagugeFee is the fee required to add to gauge. - AddToGaugeFee = sdk.NewInt(25 * 1_000_000) + AddToGaugeFee = osmomath.NewInt(25 * 1_000_000) ) // NewGauge creates a new gauge struct given the required gauge parameters. diff --git a/x/incentives/types/msgs_test.go b/x/incentives/types/msgs_test.go index 1387d252e89..2e1b1400729 100644 --- a/x/incentives/types/msgs_test.go +++ b/x/incentives/types/msgs_test.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/incentives/types" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -306,7 +307,7 @@ func TestAuthzMsg(t *testing.T) { appParams.SetAddressPrefixes() pk1 := ed25519.GenPrivKey().PubKey() addr1 := sdk.AccAddress(pk1.Address()).String() - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)) someDate := time.Date(1, 1, 1, 1, 1, 1, 1, time.UTC) testCases := []struct { diff --git a/x/lockup/client/cli/query.go b/x/lockup/client/cli/query.go index 96e78435f38..4582a4842a5 100644 --- a/x/lockup/client/cli/query.go +++ b/x/lockup/client/cli/query.go @@ -15,8 +15,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/version" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -314,7 +313,7 @@ $ %s query lockup output-all-locks Id int Status int // one of {doesnt_exist, } Denom string - Amount sdk.Int + Amount osmomath.Int Address string UnbondEndTime time.Time } diff --git a/x/lockup/keeper/bench_test.go b/x/lockup/keeper/bench_test.go index 749c21c8e78..5e764f21044 100644 --- a/x/lockup/keeper/bench_test.go +++ b/x/lockup/keeper/bench_test.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -67,7 +68,7 @@ func benchmarkResetLogic(b *testing.B, numLockups int) { // setup lockups for i := 0; i < numLockups; i++ { addr := addrs[r.Int()%numAccts] - simCoins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(r.Int63n(100)))) + simCoins := sdk.NewCoins(sdk.NewCoin(denom, osmomath.NewInt(r.Int63n(100)))) duration := time.Duration(r.Intn(1*60*60*24*7)) * time.Second lock := lockuptypes.NewPeriodLock(uint64(i+1), addr, addr.String(), duration, time.Time{}, simCoins) locks[i] = lock diff --git a/x/lockup/keeper/genesis_test.go b/x/lockup/keeper/genesis_test.go index d670f295bf8..1906a4727d0 100644 --- a/x/lockup/keeper/genesis_test.go +++ b/x/lockup/keeper/genesis_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" osmoapp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/x/lockup" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -71,7 +72,7 @@ func TestInitGenesis(t *testing.T) { Denom: "foo", Duration: time.Second, }) - require.Equal(t, sdk.NewInt(30000000), acc) + require.Equal(t, osmomath.NewInt(30000000), acc) } func TestExportGenesis(t *testing.T) { diff --git a/x/lockup/keeper/grpc_query_test.go b/x/lockup/keeper/grpc_query_test.go index 053b78fbe34..491eb388afa 100644 --- a/x/lockup/keeper/grpc_query_test.go +++ b/x/lockup/keeper/grpc_query_test.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -527,7 +528,7 @@ func (s *KeeperTestSuite) TestLockedDenom() { sdk.WrapSDKContext(s.Ctx), &types.LockedDenomRequest{Denom: "stake", Duration: duration}) s.Require().NoError(err) - s.Require().Equal(res.Amount, sdk.NewInt(expectedAmount)) + s.Require().Equal(res.Amount, osmomath.NewInt(expectedAmount)) } // lock coins diff --git a/x/lockup/keeper/invariants.go b/x/lockup/keeper/invariants.go index 2b13d24fc30..535ee48eccb 100644 --- a/x/lockup/keeper/invariants.go +++ b/x/lockup/keeper/invariants.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -65,7 +66,7 @@ func AccumulationStoreInvariant(keeper Keeper) sdk.Invariant { }) locks := keeper.GetLocksLongerThanDurationDenom(ctx, denom, duration) - lockupSum := sdk.ZeroInt() + lockupSum := osmomath.ZeroInt() for _, lock := range locks { lockupSum = lockupSum.Add(lock.Coins.AmountOf(denom)) } @@ -93,7 +94,7 @@ func LocksBalancesInvariant(keeper Keeper) sdk.Invariant { // loop all denoms on lockup module for _, coin := range balances { denom := coin.Denom - lockedAmount := sdk.ZeroInt() + lockedAmount := osmomath.ZeroInt() locksByDenom := keeper.GetLocksDenom(ctx, denom) for _, lock := range locksByDenom { lockedAmount = lockedAmount.Add(lock.Coins.AmountOf(denom)) diff --git a/x/lockup/keeper/lock.go b/x/lockup/keeper/lock.go index dbdec9dcc7d..0118a637071 100644 --- a/x/lockup/keeper/lock.go +++ b/x/lockup/keeper/lock.go @@ -13,6 +13,7 @@ import ( "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/sumtree" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -40,7 +41,7 @@ func (k Keeper) GetModuleLockedCoins(ctx sdk.Context) sdk.Coins { // GetPeriodLocksByDuration returns the total amount of query.Denom tokens locked for longer than // query.Duration. -func (k Keeper) GetPeriodLocksAccumulation(ctx sdk.Context, query types.QueryCondition) sdk.Int { +func (k Keeper) GetPeriodLocksAccumulation(ctx sdk.Context, query types.QueryCondition) osmomath.Int { beginKey := accumulationKey(query.Duration) return k.accumulationStore(ctx, query.Denom).SubsetAccumulation(beginKey, nil) } @@ -299,7 +300,7 @@ func (k Keeper) RebuildAccumulationStoreForDenom(ctx sdk.Context, denom string) prefix := accumulationStorePrefix(denom) k.clearKeysByPrefix(ctx, prefix) locks := k.GetLocksDenom(ctx, denom) - mapDurationToAmount := make(map[time.Duration]sdk.Int) + mapDurationToAmount := make(map[time.Duration]osmomath.Int) for _, lock := range locks { if v, ok := mapDurationToAmount[lock.Duration]; ok { mapDurationToAmount[lock.Duration] = v.Add(lock.Coins.AmountOf(denom)) @@ -318,7 +319,7 @@ func (k Keeper) RebuildSuperfluidAccumulationStoresForDenom(ctx sdk.Context, den superfluidStorePrefix = superfluidStorePrefix[0 : len(superfluidStorePrefix)-1] k.clearKeysByPrefix(ctx, superfluidStorePrefix) - accumulationStoreEntries := make(map[string]map[time.Duration]sdk.Int) + accumulationStoreEntries := make(map[string]map[time.Duration]osmomath.Int) locks := k.GetLocksDenom(ctx, denom) for _, lock := range locks { synthLock, found, err := k.GetSyntheticLockupByUnderlyingLockId(ctx, lock.ID) @@ -326,11 +327,11 @@ func (k Keeper) RebuildSuperfluidAccumulationStoresForDenom(ctx sdk.Context, den continue } - var curDurationMap map[time.Duration]sdk.Int + var curDurationMap map[time.Duration]osmomath.Int if durationMap, ok := accumulationStoreEntries[synthLock.SynthDenom]; ok { curDurationMap = durationMap } else { - curDurationMap = make(map[time.Duration]sdk.Int) + curDurationMap = make(map[time.Duration]osmomath.Int) } newAmt := lock.Coins.AmountOf(denom) if curAmt, ok := curDurationMap[synthLock.Duration]; ok { @@ -613,7 +614,7 @@ func (k Keeper) InitializeAllLocks(ctx sdk.Context, locks []types.PeriodLock) er // We accumulate the accumulation store entries separately, // to avoid hitting the myriad of slowdowns in the SDK iterator creation process. // We then save these once to the accumulation store at the end. - accumulationStoreEntries := make(map[string]map[time.Duration]sdk.Int) + accumulationStoreEntries := make(map[string]map[time.Duration]osmomath.Int) denoms := []string{} for i, lock := range locks { if i%25000 == 0 { @@ -628,7 +629,7 @@ func (k Keeper) InitializeAllLocks(ctx sdk.Context, locks []types.PeriodLock) er // Add to the accumlation store cache for _, coin := range lock.Coins { // update or create the new map from duration -> Int for this denom. - var curDurationMap map[time.Duration]sdk.Int + var curDurationMap map[time.Duration]osmomath.Int if durationMap, ok := accumulationStoreEntries[coin.Denom]; ok { curDurationMap = durationMap // update or create new amount in the duration map @@ -639,7 +640,7 @@ func (k Keeper) InitializeAllLocks(ctx sdk.Context, locks []types.PeriodLock) er curDurationMap[lock.Duration] = newAmt } else { denoms = append(denoms, coin.Denom) - curDurationMap = map[time.Duration]sdk.Int{lock.Duration: coin.Amount} + curDurationMap = map[time.Duration]osmomath.Int{lock.Duration: coin.Amount} } accumulationStoreEntries[coin.Denom] = curDurationMap } @@ -655,7 +656,7 @@ func (k Keeper) InitializeAllLocks(ctx sdk.Context, locks []types.PeriodLock) er return nil } -func (k Keeper) writeDurationValuesToAccumTree(ctx sdk.Context, denom string, durationValueMap map[time.Duration]sdk.Int) { +func (k Keeper) writeDurationValuesToAccumTree(ctx sdk.Context, denom string, durationValueMap map[time.Duration]osmomath.Int) { durations := make([]time.Duration, 0, len(durationValueMap)) for duration := range durationValueMap { durations = append(durations, duration) @@ -677,7 +678,7 @@ func (k Keeper) InitializeAllSyntheticLocks(ctx sdk.Context, syntheticLocks []ty // We accumulate the accumulation store entries separately, // to avoid hitting the myriad of slowdowns in the SDK iterator creation process. // We then save these once to the accumulation store at the end. - accumulationStoreEntries := make(map[string]map[time.Duration]sdk.Int) + accumulationStoreEntries := make(map[string]map[time.Duration]osmomath.Int) denoms := []string{} for i, synthLock := range syntheticLocks { if i%25000 == 0 { @@ -701,7 +702,7 @@ func (k Keeper) InitializeAllSyntheticLocks(ctx sdk.Context, syntheticLocks []ty return err } - var curDurationMap map[time.Duration]sdk.Int + var curDurationMap map[time.Duration]osmomath.Int if durationMap, ok := accumulationStoreEntries[synthLock.SynthDenom]; ok { curDurationMap = durationMap newAmt := coin.Amount @@ -711,7 +712,7 @@ func (k Keeper) InitializeAllSyntheticLocks(ctx sdk.Context, syntheticLocks []ty curDurationMap[synthLock.Duration] = newAmt } else { denoms = append(denoms, synthLock.SynthDenom) - curDurationMap = map[time.Duration]sdk.Int{synthLock.Duration: coin.Amount} + curDurationMap = map[time.Duration]osmomath.Int{synthLock.Duration: coin.Amount} } accumulationStoreEntries[synthLock.SynthDenom] = curDurationMap } diff --git a/x/lockup/keeper/lock_test.go b/x/lockup/keeper/lock_test.go index 4396b008fce..b91f45de2e1 100644 --- a/x/lockup/keeper/lock_test.go +++ b/x/lockup/keeper/lock_test.go @@ -7,6 +7,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -137,7 +138,7 @@ func (s *KeeperTestSuite) TestGetPeriodLocks() { func (s *KeeperTestSuite) TestUnlock() { s.SetupTest() initialLockCoins := sdk.Coins{sdk.NewInt64Coin("stake", 10)} - concentratedShareCoins := sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), sdk.NewInt(10))) + concentratedShareCoins := sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), osmomath.NewInt(10))) testCases := []struct { name string @@ -330,23 +331,23 @@ func (s *KeeperTestSuite) TestUnlockMaturedLockInternalLogic() { }{ { name: "unlock lock with gamm shares", - coinsLocked: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + coinsLocked: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), coinsBurned: sdk.NewCoins(), - expectedFinalCoinsSentBack: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + expectedFinalCoinsSentBack: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), expectedError: false, }, { name: "unlock lock with cl shares", - coinsLocked: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), sdk.NewInt(100))), - coinsBurned: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), sdk.NewInt(100))), + coinsLocked: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), osmomath.NewInt(100))), + coinsBurned: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), osmomath.NewInt(100))), expectedFinalCoinsSentBack: sdk.NewCoins(), expectedError: false, }, { name: "unlock lock with gamm and cl shares (should not be possible)", - coinsLocked: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100)), sdk.NewCoin("cl/pool/1/1", sdk.NewInt(100))), - coinsBurned: sdk.NewCoins(sdk.NewCoin("cl/pool/1/1", sdk.NewInt(100))), - expectedFinalCoinsSentBack: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + coinsLocked: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100)), sdk.NewCoin("cl/pool/1/1", osmomath.NewInt(100))), + coinsBurned: sdk.NewCoins(sdk.NewCoin("cl/pool/1/1", osmomath.NewInt(100))), + expectedFinalCoinsSentBack: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), expectedError: false, }, } @@ -415,7 +416,7 @@ func (s *KeeperTestSuite) TestUnlockMaturedLockInternalLogic() { s.Require().Equal(assetsSupplyAtLockStart.AmountOf(coin.Denom).String(), assetsSupplyAtLockEnd.AmountOf(coin.Denom).String()) } else if coin.Denom == "cl/pool/1/1" { // The supply should be zero - s.Require().Equal(sdk.ZeroInt().String(), assetsSupplyAtLockEnd.AmountOf(coin.Denom).String()) + s.Require().Equal(osmomath.ZeroInt().String(), assetsSupplyAtLockEnd.AmountOf(coin.Denom).String()) } } }) @@ -530,11 +531,11 @@ func (s *KeeperTestSuite) TestCreateLock() { // check balance balance := s.App.BankKeeper.GetBalance(s.Ctx, addr1, "stake") - s.Require().Equal(sdk.ZeroInt(), balance.Amount) + s.Require().Equal(osmomath.ZeroInt(), balance.Amount) acc := s.App.AccountKeeper.GetModuleAccount(s.Ctx, types.ModuleName) balance = s.App.BankKeeper.GetBalance(s.Ctx, acc.GetAddress(), "stake") - s.Require().Equal(sdk.NewInt(30), balance.Amount) + s.Require().Equal(osmomath.NewInt(30), balance.Amount) } func (s *KeeperTestSuite) TestSetLockRewardReceiverAddress() { @@ -666,11 +667,11 @@ func (s *KeeperTestSuite) TestCreateLockNoSend() { // check that send did not occur and balances are unchanged balance := s.App.BankKeeper.GetBalance(s.Ctx, addr1, "stake") - s.Require().Equal(sdk.NewInt(originalLockBalance).String(), balance.Amount.String()) + s.Require().Equal(osmomath.NewInt(originalLockBalance).String(), balance.Amount.String()) acc := s.App.AccountKeeper.GetModuleAccount(s.Ctx, types.ModuleName) balance = s.App.BankKeeper.GetBalance(s.Ctx, acc.GetAddress(), "stake") - s.Require().Equal(sdk.ZeroInt().String(), balance.Amount.String()) + s.Require().Equal(osmomath.ZeroInt().String(), balance.Amount.String()) } func (s *KeeperTestSuite) TestAddTokensToLock() { @@ -706,13 +707,13 @@ func (s *KeeperTestSuite) TestAddTokensToLock() { }, { name: "lock invalid tokens", - tokenToAdd: sdk.NewCoin("unknown", sdk.NewInt(10)), + tokenToAdd: sdk.NewCoin("unknown", osmomath.NewInt(10)), duration: time.Second, lockingAddress: addr1, }, { name: "token to add exceeds balance", - tokenToAdd: sdk.NewCoin("stake", sdk.NewInt(20)), + tokenToAdd: sdk.NewCoin("stake", osmomath.NewInt(20)), duration: time.Second, lockingAddress: addr1, }, @@ -883,15 +884,15 @@ func (s *KeeperTestSuite) TestLock() { // Since lock method no longer sends the underlying coins, the account balance should be unchanged balance := s.App.BankKeeper.GetBalance(s.Ctx, addr1, "stake") - s.Require().Equal(sdk.NewInt(10).String(), balance.Amount.String()) + s.Require().Equal(osmomath.NewInt(10).String(), balance.Amount.String()) acc := s.App.AccountKeeper.GetModuleAccount(s.Ctx, types.ModuleName) balance = s.App.BankKeeper.GetBalance(s.Ctx, acc.GetAddress(), "stake") - s.Require().Equal(sdk.NewInt(0).String(), balance.Amount.String()) + s.Require().Equal(osmomath.NewInt(0).String(), balance.Amount.String()) } func (s *KeeperTestSuite) TestSplitLock() { - defaultAmount := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100)), sdk.NewCoin("bar", sdk.NewInt(200))) - defaultHalfAmount := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(40)), sdk.NewCoin("bar", sdk.NewInt(110))) + defaultAmount := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100)), sdk.NewCoin("bar", osmomath.NewInt(200))) + defaultHalfAmount := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(40)), sdk.NewCoin("bar", osmomath.NewInt(110))) testCases := []struct { name string amountToSplit sdk.Coins @@ -1270,28 +1271,28 @@ func (s *KeeperTestSuite) TestSlashTokensFromLockByIDSendUnderlyingAndBurn() { testCases := []struct { name string positionCoins sdk.Coins - liquidityToSlash sdk.Dec + liquidityToSlash osmomath.Dec denomToSlash string expectError bool }{ { name: "happy path", - positionCoins: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(1000000)), sdk.NewCoin("usdc", sdk.NewInt(5000000000))), - liquidityToSlash: sdk.NewDec(10000000), + positionCoins: sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(1000000)), sdk.NewCoin("usdc", osmomath.NewInt(5000000000))), + liquidityToSlash: osmomath.NewDec(10000000), denomToSlash: cltypes.GetConcentratedLockupDenomFromPoolId(1), }, { name: "error: attempt to slash more liquidity than the lock has", - positionCoins: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(1000000)), sdk.NewCoin("usdc", sdk.NewInt(5000000000))), - liquidityToSlash: sdk.NewDec(100000000), + positionCoins: sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(1000000)), sdk.NewCoin("usdc", osmomath.NewInt(5000000000))), + liquidityToSlash: osmomath.NewDec(100000000), denomToSlash: cltypes.GetConcentratedLockupDenomFromPoolId(1), expectError: true, }, { name: "error: attempt to slash a denom that does not exist in the lock", - positionCoins: sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(1000000)), sdk.NewCoin("usdc", sdk.NewInt(5000000000))), + positionCoins: sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(1000000)), sdk.NewCoin("usdc", osmomath.NewInt(5000000000))), denomToSlash: cltypes.GetConcentratedLockupDenomFromPoolId(2), - liquidityToSlash: sdk.NewDec(10000000), + liquidityToSlash: osmomath.NewDec(10000000), expectError: true, }, } @@ -1477,7 +1478,7 @@ func (s *KeeperTestSuite) TestForceUnlock() { for _, tc := range testCases { // set up test and create default lock s.SetupTest() - coinsToLock := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10000000))) + coinsToLock := sdk.NewCoins(sdk.NewCoin("stake", osmomath.NewInt(10000000))) s.FundAcc(addr1, sdk.NewCoins(coinsToLock...)) lock, err := s.App.LockupKeeper.CreateLock(s.Ctx, addr1, coinsToLock, time.Minute) s.Require().NoError(err) @@ -1519,7 +1520,7 @@ func (s *KeeperTestSuite) TestPartialForceUnlock() { addr1 := sdk.AccAddress([]byte("addr1---------------")) defaultDenomToLock := "stake" - defaultAmountToLock := sdk.NewInt(10000000) + defaultAmountToLock := osmomath.NewInt(10000000) coinsToLock := sdk.NewCoins(sdk.NewCoin("stake", defaultAmountToLock)) testCases := []struct { @@ -1534,12 +1535,12 @@ func (s *KeeperTestSuite) TestPartialForceUnlock() { }, { name: "partial unlock", - coinsToForceUnlock: sdk.Coins{sdk.NewCoin(defaultDenomToLock, defaultAmountToLock.Quo(sdk.NewInt(2)))}, + coinsToForceUnlock: sdk.Coins{sdk.NewCoin(defaultDenomToLock, defaultAmountToLock.Quo(osmomath.NewInt(2)))}, expectedPass: true, }, { name: "unlock more than locked", - coinsToForceUnlock: sdk.Coins{sdk.NewCoin(defaultDenomToLock, defaultAmountToLock.Add(sdk.NewInt(2)))}, + coinsToForceUnlock: sdk.Coins{sdk.NewCoin(defaultDenomToLock, defaultAmountToLock.Add(osmomath.NewInt(2)))}, expectedPass: false, }, { @@ -1574,7 +1575,7 @@ func (s *KeeperTestSuite) TestPartialForceUnlock() { // check balance balanceAfterForceUnlock := s.App.BankKeeper.GetBalance(s.Ctx, addr1, "stake") - s.Require().Equal(sdk.NewInt(0), balanceAfterForceUnlock.Amount) + s.Require().Equal(osmomath.NewInt(0), balanceAfterForceUnlock.Amount) } } } diff --git a/x/lockup/keeper/msg_server_test.go b/x/lockup/keeper/msg_server_test.go index 6c237cef5f5..e320c1780e8 100644 --- a/x/lockup/keeper/msg_server_test.go +++ b/x/lockup/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( "time" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/lockup/keeper" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -343,13 +344,13 @@ func (s *KeeperTestSuite) TestMsgForceUnlock() { addr1 := sdk.AccAddress([]byte("addr1---------------")) addr2 := sdk.AccAddress([]byte("addr2---------------")) defaultPoolID, defaultLockID := uint64(1), uint64(1) - defaultLockAmount := sdk.NewInt(1000000000) + defaultLockAmount := osmomath.NewInt(1000000000) tests := []struct { name string forceUnlockAllowedAddress types.Params postLockSetup func() - forceUnlockAmount sdk.Int + forceUnlockAmount osmomath.Int expectPass bool }{ { @@ -387,7 +388,7 @@ func (s *KeeperTestSuite) TestMsgForceUnlock() { types.Params{ForceUnlockAllowedAddresses: []string{addr1.String()}}, func() {}, // try force unlocking half of locked amount - defaultLockAmount.Quo(sdk.NewInt(2)), + defaultLockAmount.Quo(osmomath.NewInt(2)), true, }, { @@ -395,7 +396,7 @@ func (s *KeeperTestSuite) TestMsgForceUnlock() { types.Params{ForceUnlockAllowedAddresses: []string{addr1.String()}}, func() {}, // try force more than the locked amount - defaultLockAmount.Add(sdk.NewInt(1)), + defaultLockAmount.Add(osmomath.NewInt(1)), false, }, { @@ -420,7 +421,7 @@ func (s *KeeperTestSuite) TestMsgForceUnlock() { s.App.LockupKeeper.SetParams(s.Ctx, test.forceUnlockAllowedAddress) // prepare pool for superfluid staking cases - poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("stake", sdk.NewInt(1000000000000)), sdk.NewCoin("foo", sdk.NewInt(5000))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("stake", osmomath.NewInt(1000000000000)), sdk.NewCoin("foo", osmomath.NewInt(5000))) // lock tokens msgServer := keeper.NewMsgServerImpl(s.App.LockupKeeper) diff --git a/x/lockup/keeper/store.go b/x/lockup/keeper/store.go index 9b374a7d155..285d8207c6c 100644 --- a/x/lockup/keeper/store.go +++ b/x/lockup/keeper/store.go @@ -7,6 +7,7 @@ import ( "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" errorsmod "cosmossdk.io/errors" @@ -219,7 +220,7 @@ func (k Keeper) GetLocksDenom(ctx sdk.Context, denom string) []types.PeriodLock } // GetLockedDenom Returns the total amount of denom that are locked. -func (k Keeper) GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) sdk.Int { +func (k Keeper) GetLockedDenom(ctx sdk.Context, denom string, duration time.Duration) osmomath.Int { totalAmtLocked := k.GetPeriodLocksAccumulation(ctx, types.QueryCondition{ LockQueryType: types.ByDuration, Denom: denom, diff --git a/x/lockup/types/lock.go b/x/lockup/types/lock.go index 0de9a5975f3..b876d92ca2c 100644 --- a/x/lockup/types/lock.go +++ b/x/lockup/types/lock.go @@ -6,6 +6,8 @@ import ( "time" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // defaultOwnerReceiverPlaceholder is used as a place holder for default owner receiver for the @@ -60,8 +62,8 @@ func (p PeriodLock) SingleCoin() (sdk.Coin, error) { return p.Coins[0], nil } -func SumLocksByDenom(locks []PeriodLock, denom string) sdk.Int { - sum := sdk.NewInt(0) +func SumLocksByDenom(locks []PeriodLock, denom string) osmomath.Int { + sum := osmomath.NewInt(0) // validate the denom once, so we can avoid the expensive validate check in the hot loop. err := sdk.ValidateDenom(denom) if err != nil { diff --git a/x/lockup/types/msgs_test.go b/x/lockup/types/msgs_test.go index e67d2a4dd33..01d7b96ce97 100644 --- a/x/lockup/types/msgs_test.go +++ b/x/lockup/types/msgs_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -30,7 +31,7 @@ func TestMsgLockTokens(t *testing.T) { msg: types.MsgLockTokens{ Owner: addr1, Duration: time.Hour, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, expectPass: true, }, @@ -39,7 +40,7 @@ func TestMsgLockTokens(t *testing.T) { msg: types.MsgLockTokens{ Owner: invalidAddr, Duration: time.Hour, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, }, { @@ -47,7 +48,7 @@ func TestMsgLockTokens(t *testing.T) { msg: types.MsgLockTokens{ Owner: addr1, Duration: -1, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, }, { @@ -55,7 +56,7 @@ func TestMsgLockTokens(t *testing.T) { msg: types.MsgLockTokens{ Owner: addr1, Duration: time.Hour, - Coins: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(100000)), sdk.NewCoin("test2", sdk.NewInt(100000))), + Coins: sdk.NewCoins(sdk.NewCoin("test1", osmomath.NewInt(100000)), sdk.NewCoin("test2", osmomath.NewInt(100000))), }, }, { @@ -63,7 +64,7 @@ func TestMsgLockTokens(t *testing.T) { msg: types.MsgLockTokens{ Owner: addr1, Duration: time.Hour, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(0))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(0))), }, }, } @@ -138,7 +139,7 @@ func TestMsgBeginUnlocking(t *testing.T) { msg: types.MsgBeginUnlocking{ Owner: addr1, ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, expectPass: true, }, @@ -147,7 +148,7 @@ func TestMsgBeginUnlocking(t *testing.T) { msg: types.MsgBeginUnlocking{ Owner: invalidAddr, ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, }, { @@ -155,7 +156,7 @@ func TestMsgBeginUnlocking(t *testing.T) { msg: types.MsgBeginUnlocking{ Owner: addr1, ID: 0, - Coins: sdk.NewCoins(sdk.NewCoin("test", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("test", osmomath.NewInt(100))), }, }, { @@ -163,7 +164,7 @@ func TestMsgBeginUnlocking(t *testing.T) { msg: types.MsgBeginUnlocking{ Owner: addr1, ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(100000)), sdk.NewCoin("test2", sdk.NewInt(100000))), + Coins: sdk.NewCoins(sdk.NewCoin("test1", osmomath.NewInt(100000)), sdk.NewCoin("test2", osmomath.NewInt(100000))), }, }, { @@ -171,7 +172,7 @@ func TestMsgBeginUnlocking(t *testing.T) { msg: types.MsgBeginUnlocking{ Owner: addr1, ID: 1, - Coins: sdk.NewCoins(sdk.NewCoin("test1", sdk.NewInt(0))), + Coins: sdk.NewCoins(sdk.NewCoin("test1", osmomath.NewInt(0))), }, expectPass: true, }, @@ -266,7 +267,7 @@ func TestMsgExtendLockup(t *testing.T) { func TestAuthzMsg(t *testing.T) { pk1 := ed25519.GenPrivKey().PubKey() addr1 := sdk.AccAddress(pk1.Address()).String() - coin := sdk.NewCoin("denom", sdk.NewInt(1)) + coin := sdk.NewCoin("denom", osmomath.NewInt(1)) testCases := []struct { name string diff --git a/x/lockup/types/query.pb.go b/x/lockup/types/query.pb.go index 7566bd41ffc..8aa78c3edcb 100644 --- a/x/lockup/types/query.pb.go +++ b/x/lockup/types/query.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -912,7 +913,7 @@ func (m *LockedDenomRequest) GetDuration() time.Duration { } type LockedDenomResponse struct { - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount" yaml:"amount"` + Amount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=amount,proto3,customtype=cosmossdk.io/math.Int" json:"amount" yaml:"amount"` } func (m *LockedDenomResponse) Reset() { *m = LockedDenomResponse{} } @@ -1912,112 +1913,113 @@ func init() { func init() { proto.RegisterFile("osmosis/lockup/query.proto", fileDescriptor_e906fda01cffd91a) } var fileDescriptor_e906fda01cffd91a = []byte{ - // 1675 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcb, 0x6f, 0x14, 0x47, - 0x1a, 0x77, 0x19, 0xec, 0x5d, 0x3e, 0xd6, 0x86, 0x2d, 0x0c, 0x6b, 0xb7, 0xcd, 0x8c, 0x29, 0xc0, - 0x78, 0x77, 0xed, 0x6e, 0x6c, 0x2c, 0xf3, 0x58, 0x9e, 0x83, 0x61, 0x65, 0xd6, 0x4b, 0x60, 0x20, - 0x41, 0x79, 0x69, 0xd4, 0x33, 0x53, 0x0c, 0x2d, 0x66, 0xba, 0x87, 0xe9, 0x1e, 0xc3, 0x04, 0x11, - 0x14, 0xc8, 0x21, 0x87, 0x1c, 0x88, 0x72, 0x89, 0x72, 0x88, 0x92, 0xdc, 0x92, 0x48, 0x51, 0x2e, - 0x39, 0xa0, 0xdc, 0x13, 0x94, 0x43, 0x84, 0x94, 0x4b, 0x94, 0x83, 0x89, 0x70, 0xfe, 0x02, 0x4e, - 0x91, 0x72, 0x89, 0xba, 0xaa, 0xba, 0x3d, 0xfd, 0x9c, 0x1e, 0x4f, 0xb0, 0x7c, 0xb2, 0xa7, 0xbf, - 0xd7, 0xef, 0xf7, 0xd5, 0xf3, 0x57, 0x20, 0x19, 0x66, 0xc5, 0x30, 0x35, 0x53, 0x29, 0x1b, 0x85, - 0xeb, 0xf5, 0xaa, 0x72, 0xa3, 0x4e, 0x6b, 0x0d, 0xb9, 0x5a, 0x33, 0x2c, 0x03, 0xf7, 0x0b, 0x9b, - 0xcc, 0x6d, 0xd2, 0x40, 0xc9, 0x28, 0x19, 0xcc, 0xa4, 0xd8, 0xff, 0x71, 0x2f, 0x29, 0x55, 0x60, - 0x6e, 0x4a, 0x5e, 0x35, 0xa9, 0xb2, 0x38, 0x95, 0xa7,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xea, 0xfa, 0x69, 0x39, - 0xd5, 0xf5, 0xca, 0x74, 0xd3, 0x63, 0xb0, 0xc8, 0x31, 0x59, 0x56, 0xf3, 0xa6, 0x9b, 0x70, 0x71, - 0xea, 0xb0, 0x72, 0xcb, 0x49, 0xcb, 0x1e, 0x87, 0xf3, 0xbd, 0x4c, 0xe2, 0x1f, 0xf8, 0x23, 0x00, - 0x00, 0xff, 0xff, 0x43, 0x55, 0x33, 0x80, 0xb5, 0x1f, 0x00, 0x00, + // 1681 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x59, 0xcd, 0x6f, 0x14, 0xe5, + 0x1f, 0xef, 0x53, 0x68, 0x7f, 0x3f, 0xbe, 0xd8, 0x82, 0x0f, 0x05, 0xdb, 0x69, 0xd9, 0x2d, 0x0f, + 0x50, 0xaa, 0xb6, 0x33, 0xb4, 0x34, 0xe5, 0x45, 0x5e, 0x97, 0x52, 0x53, 0xac, 0x08, 0x0b, 0x6a, + 0x7c, 0xcb, 0x66, 0x76, 0xf7, 0x61, 0x99, 0x74, 0x77, 0x66, 0xd9, 0x99, 0x2d, 0xac, 0x04, 0x89, + 0xe0, 0xc1, 0x83, 0x07, 0x8c, 0x17, 0xe3, 0xc1, 0xa8, 0x37, 0x35, 0x31, 0x5e, 0x3c, 0x10, 0xef, + 0x4a, 0x3c, 0x18, 0x12, 0x2f, 0xc6, 0x43, 0x31, 0xd4, 0xbf, 0x80, 0x93, 0x89, 0x17, 0x33, 0xcf, + 0xf3, 0xcc, 0x76, 0xe7, 0x75, 0x67, 0xbb, 0xd2, 0xf4, 0xd4, 0xce, 0x7c, 0xdf, 0x3e, 0x9f, 0xef, + 0xf3, 0xfa, 0x99, 0x05, 0xc9, 0x30, 0x4b, 0x86, 0xa9, 0x99, 0x4a, 0xd1, 0xc8, 0x2d, 0x54, 0xcb, + 0xca, 0xd5, 0x2a, 0xad, 0xd4, 0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e, 0x2e, 0x0d, 0xfd, 0xc7, 0xaa, 0x5f, 0x7d, 0xfa, 0x8f, 0xd5, + 0x00, 0x2d, 0x4a, 0x46, 0x18, 0xc0, 0x61, 0x9c, 0x08, 0x03, 0xc8, 0xd5, 0x67, 0x6a, 0xfe, 0xfe, + 0xa3, 0x04, 0x7a, 0xf0, 0x28, 0x81, 0xfe, 0x7c, 0x94, 0x40, 0x77, 0x97, 0x13, 0x1d, 0x0f, 0x96, + 0x13, 0x1d, 0xbf, 0x2f, 0x27, 0x3a, 0xde, 0x9c, 0x6c, 0xf8, 0x2d, 0x4c, 0xe4, 0x18, 0x2f, 0xaa, + 0x59, 0xb3, 0x9e, 0x70, 0x71, 0xe2, 0xb0, 0x72, 0xdd, 0x49, 0xcb, 0x7e, 0x1b, 0xcb, 0x76, 0x33, + 0x89, 0x7f, 0xe0, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x48, 0x2e, 0xfa, 0x9c, 0xa4, 0x1f, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/mint/README.md b/x/mint/README.md index 5c867e37dcc..f81ea6b8221 100644 --- a/x/mint/README.md +++ b/x/mint/README.md @@ -52,7 +52,7 @@ The [`Minter`](https://github.com/osmosis-labs/osmosis/blob/cbb683e8395655042b44 ```go type Minter struct { - EpochProvisions sdk.Dec // Rewards for the current epoch + EpochProvisions osmomath.Dec // Rewards for the current epoch } ``` diff --git a/x/mint/keeper/export_test.go b/x/mint/keeper/export_test.go index 77eb000fccd..d891776f48e 100644 --- a/x/mint/keeper/export_test.go +++ b/x/mint/keeper/export_test.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/types" ) @@ -22,11 +23,11 @@ func (k Keeper) CreateDeveloperVestingModuleAccount(ctx sdk.Context, amount sdk. return k.createDeveloperVestingModuleAccount(ctx, amount) } -func (k Keeper) DistributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion sdk.Dec) (sdk.Int, error) { +func (k Keeper) DistributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion osmomath.Dec) (osmomath.Int, error) { return k.distributeToModule(ctx, recipientModule, mintedCoin, proportion) } -func (k Keeper) DistributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk.Coin, developerRewardsProportion sdk.Dec, developerRewardsReceivers []types.WeightedAddress) (sdk.Int, error) { +func (k Keeper) DistributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk.Coin, developerRewardsProportion osmomath.Dec, developerRewardsReceivers []types.WeightedAddress) (osmomath.Int, error) { return k.distributeDeveloperRewards(ctx, totalMintedCoin, developerRewardsProportion, developerRewardsReceivers) } diff --git a/x/mint/keeper/genesis.go b/x/mint/keeper/genesis.go index 5b67e785d2e..896a1259e06 100644 --- a/x/mint/keeper/genesis.go +++ b/x/mint/keeper/genesis.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/types" ) @@ -25,13 +26,13 @@ func (k Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { // x/auth SDK module. Therefore, we check for existence here // to avoid overwriting pre-existing genesis account data. if !k.accountKeeper.HasAccount(ctx, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) { - totalDeveloperVestingCoins := sdk.NewCoin(data.Params.MintDenom, sdk.NewInt(developerVestingAmount)) + totalDeveloperVestingCoins := sdk.NewCoin(data.Params.MintDenom, osmomath.NewInt(developerVestingAmount)) if err := k.createDeveloperVestingModuleAccount(ctx, totalDeveloperVestingCoins); err != nil { panic(err) } - k.bankKeeper.AddSupplyOffset(ctx, data.Params.MintDenom, sdk.NewInt(developerVestingAmount).Neg()) + k.bankKeeper.AddSupplyOffset(ctx, data.Params.MintDenom, osmomath.NewInt(developerVestingAmount).Neg()) } k.setLastReductionEpochNum(ctx, data.ReductionStartedEpoch) diff --git a/x/mint/keeper/genesis_test.go b/x/mint/keeper/genesis_test.go index de2e3779a20..318f7fb40e0 100644 --- a/x/mint/keeper/genesis_test.go +++ b/x/mint/keeper/genesis_test.go @@ -4,33 +4,34 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/x/mint/keeper" "github.com/osmosis-labs/osmosis/v19/x/mint/types" ) var customGenesis = types.NewGenesisState( - types.NewMinter(sdk.ZeroDec()), + types.NewMinter(osmomath.ZeroDec()), types.NewParams( - "uosmo", // denom - sdk.NewDec(200), // epoch provisions - "year", // epoch identifier - sdk.NewDecWithPrec(5, 1), // reduction factor - 5, // reduction perion in epochs + "uosmo", // denom + osmomath.NewDec(200), // epoch provisions + "year", // epoch identifier + osmomath.NewDecWithPrec(5, 1), // reduction factor + 5, // reduction perion in epochs types.DistributionProportions{ - Staking: sdk.NewDecWithPrec(25, 2), - PoolIncentives: sdk.NewDecWithPrec(25, 2), - DeveloperRewards: sdk.NewDecWithPrec(25, 2), - CommunityPool: sdk.NewDecWithPrec(25, 2), + Staking: osmomath.NewDecWithPrec(25, 2), + PoolIncentives: osmomath.NewDecWithPrec(25, 2), + DeveloperRewards: osmomath.NewDecWithPrec(25, 2), + CommunityPool: osmomath.NewDecWithPrec(25, 2), }, []types.WeightedAddress{ { Address: "osmo14kjcwdwcqsujkdt8n5qwpd8x8ty2rys5rjrdjj", - Weight: sdk.NewDecWithPrec(6, 1), + Weight: osmomath.NewDecWithPrec(6, 1), }, { Address: "osmo1gw445ta0aqn26suz2rg3tkqfpxnq2hs224d7gq", - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, }, 2), // minting reward distribution start epoch @@ -46,12 +47,12 @@ func (s *KeeperTestSuite) TestMintInitGenesis() { isDeveloperModuleAccountCreated bool expectPanic bool - expectedEpochProvisions sdk.Dec + expectedEpochProvisions osmomath.Dec // Deltas represent by how much a certain paramets // has changed after calling InitGenesis() - expectedSupplyOffsetDelta sdk.Int - expectedSupplyWithOffsetDelta sdk.Int - expectedDeveloperVestingAmountDelta sdk.Int + expectedSupplyOffsetDelta osmomath.Int + expectedSupplyWithOffsetDelta osmomath.Int + expectedDeveloperVestingAmountDelta osmomath.Int expectedHalvenStartedEpoch int64 }{ "default genesis - developer module account is not created prior to InitGenesis() - created during the call": { @@ -59,9 +60,9 @@ func (s *KeeperTestSuite) TestMintInitGenesis() { mintDenom: sdk.DefaultBondDenom, expectedEpochProvisions: types.DefaultGenesisState().Params.GenesisEpochProvisions, - expectedSupplyOffsetDelta: sdk.NewInt(keeper.DeveloperVestingAmount).Neg(), - expectedSupplyWithOffsetDelta: sdk.ZeroInt(), - expectedDeveloperVestingAmountDelta: sdk.NewInt(keeper.DeveloperVestingAmount), + expectedSupplyOffsetDelta: osmomath.NewInt(keeper.DeveloperVestingAmount).Neg(), + expectedSupplyWithOffsetDelta: osmomath.ZeroInt(), + expectedDeveloperVestingAmountDelta: osmomath.NewInt(keeper.DeveloperVestingAmount), }, "default genesis - developer module account is created prior to InitGenesis() - not created during the call": { mintGenesis: types.DefaultGenesisState(), @@ -69,18 +70,18 @@ func (s *KeeperTestSuite) TestMintInitGenesis() { isDeveloperModuleAccountCreated: true, expectedEpochProvisions: types.DefaultGenesisState().Params.GenesisEpochProvisions, - expectedSupplyOffsetDelta: sdk.ZeroInt(), - expectedSupplyWithOffsetDelta: sdk.ZeroInt(), - expectedDeveloperVestingAmountDelta: sdk.ZeroInt(), + expectedSupplyOffsetDelta: osmomath.ZeroInt(), + expectedSupplyWithOffsetDelta: osmomath.ZeroInt(), + expectedDeveloperVestingAmountDelta: osmomath.ZeroInt(), }, "custom genesis": { mintGenesis: customGenesis, mintDenom: "uosmo", - expectedEpochProvisions: sdk.NewDec(200), - expectedSupplyOffsetDelta: sdk.NewInt(keeper.DeveloperVestingAmount).Neg(), - expectedSupplyWithOffsetDelta: sdk.ZeroInt(), - expectedDeveloperVestingAmountDelta: sdk.NewInt(keeper.DeveloperVestingAmount), + expectedEpochProvisions: osmomath.NewDec(200), + expectedSupplyOffsetDelta: osmomath.NewInt(keeper.DeveloperVestingAmount).Neg(), + expectedSupplyWithOffsetDelta: osmomath.ZeroInt(), + expectedDeveloperVestingAmountDelta: osmomath.NewInt(keeper.DeveloperVestingAmount), expectedHalvenStartedEpoch: 3, }, "nil genesis state - panic": { diff --git a/x/mint/keeper/hooks_test.go b/x/mint/keeper/hooks_test.go index 519d4de882d..fcd42526ecd 100644 --- a/x/mint/keeper/hooks_test.go +++ b/x/mint/keeper/hooks_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" osmoapp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/x/mint/keeper" @@ -27,12 +28,12 @@ const ( ) var ( - defaultReductionFactor = sdk.NewDec(2).Quo(sdk.NewDec(3)) + defaultReductionFactor = osmomath.NewDec(2).Quo(osmomath.NewDec(3)) defaultDistributionProportions = types.DistributionProportions{ - Staking: sdk.NewDecWithPrec(25, 2), - PoolIncentives: sdk.NewDecWithPrec(45, 2), - DeveloperRewards: sdk.NewDecWithPrec(25, 2), - CommunityPool: sdk.NewDecWithPrec(0o5, 2), + Staking: osmomath.NewDecWithPrec(25, 2), + PoolIncentives: osmomath.NewDecWithPrec(45, 2), + DeveloperRewards: osmomath.NewDecWithPrec(25, 2), + CommunityPool: osmomath.NewDecWithPrec(0o5, 2), } ) @@ -47,32 +48,32 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { testWeightedAddresses = []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDecWithPrec(233, 3), + Weight: osmomath.NewDecWithPrec(233, 3), }, { Address: testAddressTwo.String(), - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { Address: testAddressThree.String(), - Weight: sdk.NewDecWithPrec(50, 3), + Weight: osmomath.NewDecWithPrec(50, 3), }, { Address: testAddressFour.String(), - Weight: sdk.NewDecWithPrec(217, 3), + Weight: osmomath.NewDecWithPrec(217, 3), }, } - maxArithmeticTolerance = sdk.NewDec(5) - expectedSupplyWithOffset = sdk.NewDec(0) - expectedSupply = sdk.NewDec(keeper.DeveloperVestingAmount) + maxArithmeticTolerance = osmomath.NewDec(5) + expectedSupplyWithOffset = osmomath.NewDec(0) + expectedSupply = osmomath.NewDec(keeper.DeveloperVestingAmount) ) s.assertAddressWeightsAddUpToOne(testWeightedAddresses) - defaultGenesisEpochProvisionsDec, err := sdk.NewDecFromStr(defaultGenesisEpochProvisions) + defaultGenesisEpochProvisionsDec, err := osmomath.NewDecFromStr(defaultGenesisEpochProvisions) s.Require().NoError(err) - defaultMainnetThirdenedProvisionsDec, err := sdk.NewDecFromStr(defaultMainnetThirdenedProvisions) + defaultMainnetThirdenedProvisionsDec, err := osmomath.NewDecFromStr(defaultMainnetThirdenedProvisions) s.Require().NoError(err) testcases := map[string]struct { @@ -83,16 +84,16 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { preExistingEpochNum int64 mintDenom string epochIdentifier string - genesisEpochProvisions sdk.Dec + genesisEpochProvisions osmomath.Dec reductionPeriodInEpochs int64 - reductionFactor sdk.Dec + reductionFactor osmomath.Dec distributionProportions types.DistributionProportions weightedAddresses []types.WeightedAddress mintStartEpoch int64 // Expected results. expectedLastReductionEpochNum int64 - expectedDistribution sdk.Dec + expectedDistribution osmomath.Dec expectedError bool }{ "before start epoch - no distributions": { @@ -107,7 +108,7 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, - expectedDistribution: sdk.ZeroDec(), + expectedDistribution: osmomath.ZeroDec(), }, "at start epoch - distributes": { hookArgEpochNum: defaultMintingRewardsDistributionStartEpoch, @@ -230,7 +231,7 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultReductionPeriodInEpochs + 1, - expectedDistribution: sdk.ZeroDec(), + expectedDistribution: osmomath.ZeroDec(), }, // N.B.: This test case would not work since it would require changing default genesis denom. // Leaving it to potentially revisit in the future. @@ -247,13 +248,13 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, - expectedDistribution: sdk.ZeroDec(), + expectedDistribution: osmomath.ZeroDec(), }, "custom genesisEpochProvisions, at start epoch": { hookArgEpochNum: defaultMintingRewardsDistributionStartEpoch, mintDenom: sdk.DefaultBondDenom, - genesisEpochProvisions: sdk.NewDec(1_000_000_000), + genesisEpochProvisions: osmomath.NewDec(1_000_000_000), epochIdentifier: defaultEpochIdentifier, reductionPeriodInEpochs: defaultReductionPeriodInEpochs, reductionFactor: defaultReductionFactor, @@ -271,12 +272,12 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { genesisEpochProvisions: defaultGenesisEpochProvisionsDec, epochIdentifier: defaultEpochIdentifier, reductionPeriodInEpochs: defaultReductionPeriodInEpochs, - reductionFactor: sdk.NewDec(43).Quo(sdk.NewDec(55)), + reductionFactor: osmomath.NewDec(43).Quo(osmomath.NewDec(55)), distributionProportions: defaultDistributionProportions, weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, - expectedDistribution: defaultGenesisEpochProvisionsDec.Mul(sdk.NewDec(43)).Quo(sdk.NewDec(55)), + expectedDistribution: defaultGenesisEpochProvisionsDec.Mul(osmomath.NewDec(43)).Quo(osmomath.NewDec(55)), expectedLastReductionEpochNum: defaultMintingRewardsDistributionStartEpoch + defaultReductionPeriodInEpochs, }, "custom distribution proportions, at start epoch": { @@ -288,10 +289,10 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { reductionPeriodInEpochs: defaultReductionPeriodInEpochs, reductionFactor: defaultReductionFactor, distributionProportions: types.DistributionProportions{ - Staking: sdk.NewDecWithPrec(11, 2), - PoolIncentives: sdk.NewDecWithPrec(22, 2), - DeveloperRewards: sdk.NewDecWithPrec(33, 2), - CommunityPool: sdk.NewDecWithPrec(34, 2), + Staking: osmomath.NewDecWithPrec(11, 2), + PoolIncentives: osmomath.NewDecWithPrec(22, 2), + DeveloperRewards: osmomath.NewDecWithPrec(33, 2), + CommunityPool: osmomath.NewDecWithPrec(34, 2), }, weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, @@ -312,19 +313,19 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { weightedAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDecWithPrec(11, 2), + Weight: osmomath.NewDecWithPrec(11, 2), }, { Address: testAddressTwo.String(), - Weight: sdk.NewDecWithPrec(22, 2), + Weight: osmomath.NewDecWithPrec(22, 2), }, { Address: testAddressThree.String(), - Weight: sdk.NewDecWithPrec(33, 2), + Weight: osmomath.NewDecWithPrec(33, 2), }, { Address: testAddressFour.String(), - Weight: sdk.NewDecWithPrec(34, 2), + Weight: osmomath.NewDecWithPrec(34, 2), }, }, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, @@ -344,7 +345,7 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { weightedAddresses: testWeightedAddresses, mintStartEpoch: defaultMintingRewardsDistributionStartEpoch, - expectedDistribution: sdk.ZeroDec(), + expectedDistribution: osmomath.ZeroDec(), expectedLastReductionEpochNum: defaultMintingRewardsDistributionStartEpoch, expectedError: true, }, @@ -386,12 +387,12 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { // If panic is expected, burn developer module account balance so that it causes an error that leads to a // panic in the hook. s.Require().NoError(distrKeeper.FundCommunityPool(ctx, sdk.NewCoins(developerAccountBalanceBeforeHook), accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName))) - developerAccountBalanceBeforeHook.Amount = sdk.ZeroInt() + developerAccountBalanceBeforeHook.Amount = osmomath.ZeroInt() } // Old supply oldSupply := app.BankKeeper.GetSupply(ctx, sdk.DefaultBondDenom).Amount - s.Require().Equal(sdk.NewInt(keeper.DeveloperVestingAmount), oldSupply) + s.Require().Equal(osmomath.NewInt(keeper.DeveloperVestingAmount), oldSupply) if tc.expectedError { s.Require().Error(mintKeeper.AfterEpochEnd(ctx, defaultEpochIdentifier, tc.hookArgEpochNum)) @@ -406,20 +407,20 @@ func (s *KeeperTestSuite) TestAfterEpochEnd() { // Validate developer account balance. developerAccountBalanceAfterHook := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), sdk.DefaultBondDenom) - osmoassert.DecApproxEq(s.T(), developerAccountBalanceBeforeHook.Amount.Sub(expectedDevRewards.TruncateInt()).ToDec(), developerAccountBalanceAfterHook.Amount.ToDec(), maxArithmeticTolerance) + osmoassert.DecApproxEq(s.T(), developerAccountBalanceBeforeHook.Amount.Sub(expectedDevRewards.TruncateInt()).ToLegacyDec(), developerAccountBalanceAfterHook.Amount.ToLegacyDec(), maxArithmeticTolerance) // Validate supply. - osmoassert.DecApproxEq(s.T(), expectedSupply.Add(tc.expectedDistribution).Sub(expectedDevRewards), app.BankKeeper.GetSupply(ctx, sdk.DefaultBondDenom).Amount.ToDec(), maxArithmeticTolerance) + osmoassert.DecApproxEq(s.T(), expectedSupply.Add(tc.expectedDistribution).Sub(expectedDevRewards), app.BankKeeper.GetSupply(ctx, sdk.DefaultBondDenom).Amount.ToLegacyDec(), maxArithmeticTolerance) // Validate supply with offset. - osmoassert.DecApproxEq(s.T(), expectedSupplyWithOffset.Add(tc.expectedDistribution), app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount.ToDec(), maxArithmeticTolerance) + osmoassert.DecApproxEq(s.T(), expectedSupplyWithOffset.Add(tc.expectedDistribution), app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount.ToLegacyDec(), maxArithmeticTolerance) // Validate epoch provisions. s.Require().Equal(tc.expectedLastReductionEpochNum, mintKeeper.GetLastReductionEpochNum(ctx)) if !tc.expectedDistribution.IsZero() { // Validate distribution. - osmoassert.DecApproxEq(s.T(), tc.expectedDistribution, mintKeeper.GetMinter(ctx).EpochProvisions, sdk.NewDecWithPrec(1, 6)) + osmoassert.DecApproxEq(s.T(), tc.expectedDistribution, mintKeeper.GetMinter(ctx).EpochProvisions, osmomath.NewDecWithPrec(1, 6)) } }) } @@ -436,7 +437,7 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() mintKeeper := app.MintKeeper accountKeeper := app.AccountKeeper - genesisEpochProvisionsDec, err := sdk.NewDecFromStr(defaultGenesisEpochProvisions) + genesisEpochProvisionsDec, err := osmomath.NewDecFromStr(defaultGenesisEpochProvisions) s.Require().NoError(err) mintParams := types.Params{ @@ -446,71 +447,71 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() ReductionPeriodInEpochs: defaultReductionPeriodInEpochs, ReductionFactor: defaultReductionFactor, DistributionProportions: types.DistributionProportions{ - Staking: sdk.NewDecWithPrec(25, 2), - PoolIncentives: sdk.NewDecWithPrec(45, 2), - DeveloperRewards: sdk.NewDecWithPrec(25, 2), - CommunityPool: sdk.NewDecWithPrec(0o5, 2), + Staking: osmomath.NewDecWithPrec(25, 2), + PoolIncentives: osmomath.NewDecWithPrec(45, 2), + DeveloperRewards: osmomath.NewDecWithPrec(25, 2), + CommunityPool: osmomath.NewDecWithPrec(0o5, 2), }, WeightedDeveloperRewardsReceivers: []types.WeightedAddress{ { Address: "osmo14kjcwdwcqsujkdt8n5qwpd8x8ty2rys5rjrdjj", - Weight: sdk.NewDecWithPrec(2887, 4), + Weight: osmomath.NewDecWithPrec(2887, 4), }, { Address: "osmo1gw445ta0aqn26suz2rg3tkqfpxnq2hs224d7gq", - Weight: sdk.NewDecWithPrec(229, 3), + Weight: osmomath.NewDecWithPrec(229, 3), }, { Address: "osmo13lt0hzc6u3htsk7z5rs6vuurmgg4hh2ecgxqkf", - Weight: sdk.NewDecWithPrec(1625, 4), + Weight: osmomath.NewDecWithPrec(1625, 4), }, { Address: "osmo1kvc3he93ygc0us3ycslwlv2gdqry4ta73vk9hu", - Weight: sdk.NewDecWithPrec(109, 3), + Weight: osmomath.NewDecWithPrec(109, 3), }, { Address: "osmo19qgldlsk7hdv3ddtwwpvzff30pxqe9phq9evxf", - Weight: sdk.NewDecWithPrec(995, 3).Quo(sdk.NewDec(10)), // 0.0995 + Weight: osmomath.NewDecWithPrec(995, 3).Quo(osmomath.NewDec(10)), // 0.0995 }, { Address: "osmo19fs55cx4594een7qr8tglrjtt5h9jrxg458htd", - Weight: sdk.NewDecWithPrec(6, 1).Quo(sdk.NewDec(10)), // 0.06 + Weight: osmomath.NewDecWithPrec(6, 1).Quo(osmomath.NewDec(10)), // 0.06 }, { Address: "osmo1ssp6px3fs3kwreles3ft6c07mfvj89a544yj9k", - Weight: sdk.NewDecWithPrec(15, 2).Quo(sdk.NewDec(10)), // 0.015 + Weight: osmomath.NewDecWithPrec(15, 2).Quo(osmomath.NewDec(10)), // 0.015 }, { Address: "osmo1c5yu8498yzqte9cmfv5zcgtl07lhpjrj0skqdx", - Weight: sdk.NewDecWithPrec(1, 1).Quo(sdk.NewDec(10)), // 0.01 + Weight: osmomath.NewDecWithPrec(1, 1).Quo(osmomath.NewDec(10)), // 0.01 }, { Address: "osmo1yhj3r9t9vw7qgeg22cehfzj7enwgklw5k5v7lj", - Weight: sdk.NewDecWithPrec(75, 2).Quo(sdk.NewDec(100)), // 0.0075 + Weight: osmomath.NewDecWithPrec(75, 2).Quo(osmomath.NewDec(100)), // 0.0075 }, { Address: "osmo18nzmtyn5vy5y45dmcdnta8askldyvehx66lqgm", - Weight: sdk.NewDecWithPrec(7, 1).Quo(sdk.NewDec(100)), // 0.007 + Weight: osmomath.NewDecWithPrec(7, 1).Quo(osmomath.NewDec(100)), // 0.007 }, { Address: "osmo1z2x9z58cg96ujvhvu6ga07yv9edq2mvkxpgwmc", - Weight: sdk.NewDecWithPrec(5, 1).Quo(sdk.NewDec(100)), // 0.005 + Weight: osmomath.NewDecWithPrec(5, 1).Quo(osmomath.NewDec(100)), // 0.005 }, { Address: "osmo1tvf3373skua8e6480eyy38avv8mw3hnt8jcxg9", - Weight: sdk.NewDecWithPrec(25, 2).Quo(sdk.NewDec(100)), // 0.0025 + Weight: osmomath.NewDecWithPrec(25, 2).Quo(osmomath.NewDec(100)), // 0.0025 }, { Address: "osmo1zs0txy03pv5crj2rvty8wemd3zhrka2ne8u05n", - Weight: sdk.NewDecWithPrec(25, 2).Quo(sdk.NewDec(100)), // 0.0025 + Weight: osmomath.NewDecWithPrec(25, 2).Quo(osmomath.NewDec(100)), // 0.0025 }, { Address: "osmo1djgf9p53n7m5a55hcn6gg0cm5mue4r5g3fadee", - Weight: sdk.NewDecWithPrec(1, 1).Quo(sdk.NewDec(100)), // 0.001 + Weight: osmomath.NewDecWithPrec(1, 1).Quo(osmomath.NewDec(100)), // 0.001 }, { Address: "osmo1488zldkrn8xcjh3z40v2mexq7d088qkna8ceze", - Weight: sdk.NewDecWithPrec(8, 1).Quo(sdk.NewDec(1000)), // 0.0008 + Weight: osmomath.NewDecWithPrec(8, 1).Quo(osmomath.NewDec(1000)), // 0.0008 }, }, MintingRewardsDistributionStartEpoch: defaultMintingRewardsDistributionStartEpoch, @@ -526,8 +527,8 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() EpochProvisions: genesisEpochProvisionsDec, }) - expectedSupplyWithOffset := sdk.NewDec(0) - expectedSupply := sdk.NewDec(keeper.DeveloperVestingAmount) + expectedSupplyWithOffset := osmomath.NewDec(0) + expectedSupply := osmomath.NewDec(keeper.DeveloperVestingAmount) supplyWithOffset := app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom) s.Require().Equal(expectedSupplyWithOffset.TruncateInt64(), supplyWithOffset.Amount.Int64()) @@ -535,8 +536,8 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() supply := app.BankKeeper.GetSupply(ctx, sdk.DefaultBondDenom) s.Require().Equal(expectedSupply.TruncateInt64(), supply.Amount.Int64()) - devRewardsDelta := sdk.ZeroDec() - epochProvisionsDelta := genesisEpochProvisionsDec.Sub(genesisEpochProvisionsDec.TruncateInt().ToDec()).Mul(sdk.NewDec(defaultReductionPeriodInEpochs)) + devRewardsDelta := osmomath.ZeroDec() + epochProvisionsDelta := genesisEpochProvisionsDec.Sub(genesisEpochProvisionsDec.TruncateInt().ToLegacyDec()).Mul(osmomath.NewDec(defaultReductionPeriodInEpochs)) // Actual test for running AfterEpochEnd hook thirdeningEpoch times. for i := int64(1); i <= defaultReductionPeriodInEpochs; i++ { @@ -553,12 +554,12 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() // be off by reductionPeriodInEpochs * (genesisEpochProvisionsDec - truncatedEpochProvisions) // Therefore, we store this delta in epochProvisionsDelta to add to the actual supply to compare // to expected at the end. - truncatedEpochProvisions := genesisEpochProvisionsDec.TruncateInt().ToDec() + truncatedEpochProvisions := genesisEpochProvisionsDec.TruncateInt().ToLegacyDec() // We want supply with offset to exclude unvested developer rewards // Truncation also happens when subtracting dev rewards. // Potential source of minor rounding errors #2. - devRewards := truncatedEpochProvisions.Mul(mintParams.DistributionProportions.DeveloperRewards).TruncateInt().ToDec() + devRewards := truncatedEpochProvisions.Mul(mintParams.DistributionProportions.DeveloperRewards).TruncateInt().ToLegacyDec() // We aim to exclude developer account balance from the supply with offset calculation. developerAccountBalance := app.BankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), sdk.DefaultBondDenom) @@ -567,9 +568,9 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() // This check is now failing because of rounding errors. // To prove that this is the source of errors, we keep accumulating // the delta and add it to the expected supply validation after the loop. - if !developerAccountBalanceBeforeHook.Amount.ToDec().Sub(devRewards).Equal(developerAccountBalance.Amount.ToDec()) { - expectedDeveloperAccountBalanceAfterHook := developerAccountBalanceBeforeHook.Amount.ToDec().Sub(devRewards) - actualDeveloperAccountBalanceAfterHook := developerAccountBalance.Amount.ToDec() + if !developerAccountBalanceBeforeHook.Amount.ToLegacyDec().Sub(devRewards).Equal(developerAccountBalance.Amount.ToLegacyDec()) { + expectedDeveloperAccountBalanceAfterHook := developerAccountBalanceBeforeHook.Amount.ToLegacyDec().Sub(devRewards) + actualDeveloperAccountBalanceAfterHook := developerAccountBalance.Amount.ToLegacyDec() // This is supposed to be equal but is failing due to the rounding errors from devRewards. s.Require().NotEqual(expectedDeveloperAccountBalanceAfterHook, actualDeveloperAccountBalanceAfterHook) @@ -580,7 +581,7 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() expectedSupply = expectedSupply.Add(truncatedEpochProvisions).Sub(devRewards) s.Require().Equal(expectedSupply.RoundInt(), app.BankKeeper.GetSupply(ctx, sdk.DefaultBondDenom).Amount) - expectedSupplyWithOffset = expectedSupply.Sub(developerAccountBalance.Amount.ToDec()) + expectedSupplyWithOffset = expectedSupply.Sub(developerAccountBalance.Amount.ToLegacyDec()) s.Require().Equal(expectedSupplyWithOffset.RoundInt(), app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount) // Validate that the epoch provisions have not been reduced. @@ -594,11 +595,11 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() // Here, we add the deltas to the actual supply and compare against expected. // // expectedTotalProvisionedSupply = 365 * 821917808219.178082191780821917 = 299_999_999_999_999.999999999999999705 - expectedTotalProvisionedSupply := sdk.NewDec(defaultReductionPeriodInEpochs).Mul(genesisEpochProvisionsDec) + expectedTotalProvisionedSupply := osmomath.NewDec(defaultReductionPeriodInEpochs).Mul(genesisEpochProvisionsDec) // actualTotalProvisionedSupply = 299_999_999_997_380 (off by 2619.999999999999999705) // devRewardsDelta = 2555 (hard to estimate but the source is from truncating dev rewards ) // epochProvisionsDelta = 0.178082191780821917 * 365 = 64.999999999999999705 - actualTotalProvisionedSupply := app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount.ToDec() + actualTotalProvisionedSupply := app.BankKeeper.GetSupplyWithOffset(ctx, sdk.DefaultBondDenom).Amount.ToLegacyDec() // 299_999_999_999_999.999999999999999705 == 299_999_999_997_380 + 2555 + 64.999999999999999705 s.Require().Equal(expectedTotalProvisionedSupply, actualTotalProvisionedSupply.Add(devRewardsDelta).Add(epochProvisionsDelta)) @@ -617,10 +618,10 @@ func (s *KeeperTestSuite) TestAfterEpochEnd_FirstYearThirdening_RealParameters() } func (s *KeeperTestSuite) assertAddressWeightsAddUpToOne(receivers []types.WeightedAddress) { //nolint:govet // this is a test and we can copy locks here. - sumOfWeights := sdk.ZeroDec() + sumOfWeights := osmomath.ZeroDec() // As a sanity check, ensure developer reward receivers add up to 1. for _, w := range receivers { sumOfWeights = sumOfWeights.Add(w.Weight) } - s.Require().Equal(sdk.OneDec(), sumOfWeights) + s.Require().Equal(osmomath.OneDec(), sumOfWeights) } diff --git a/x/mint/keeper/keeper.go b/x/mint/keeper/keeper.go index d94ab55437b..df7ce8e3ca0 100644 --- a/x/mint/keeper/keeper.go +++ b/x/mint/keeper/keeper.go @@ -7,6 +7,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/mint/types" poolincentivestypes "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" @@ -29,7 +30,7 @@ type Keeper struct { } type invalidRatioError struct { - ActualRatio sdk.Dec + ActualRatio osmomath.Dec } func (e invalidRatioError) Error() string { @@ -37,8 +38,8 @@ func (e invalidRatioError) Error() string { } type insufficientDevVestingBalanceError struct { - ActualBalance sdk.Int - AttemptedDistribution sdk.Int + ActualBalance osmomath.Int + AttemptedDistribution osmomath.Int } func (e insufficientDevVestingBalanceError) Error() string { @@ -177,15 +178,15 @@ func (k Keeper) mintCoins(ctx sdk.Context, newCoins sdk.Coins) error { return k.bankKeeper.MintCoins(ctx, types.ModuleName, newCoins) } -// distributeToModule distributes mintedCoin multiplied by proportion to the recepientModule account. -func (k Keeper) distributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion sdk.Dec) (sdk.Int, error) { +// distributeToModule distributes mintedCoin multiplied by proportion to the recepientModule account.osmomath.Dec +func (k Keeper) distributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion osmomath.Dec) (osmomath.Int, error) { distributionCoin, err := getProportions(mintedCoin, proportion) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } ctx.Logger().Info("distributeToModule", "module", types.ModuleName, "recepientModule", recipientModule, "distributionCoin", distributionCoin, "height", ctx.BlockHeight()) if err := k.bankKeeper.SendCoinsFromModuleToModule(ctx, types.ModuleName, recipientModule, sdk.NewCoins(distributionCoin)); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return distributionCoin.Amount, nil } @@ -204,24 +205,24 @@ func (k Keeper) distributeToModule(ctx sdk.Context, recipientModule string, mint // - the balance of mint module is less than totalMintedCoin * developerRewardsProportion. // CONTRACT: // - weights in developerRewardsReceivers add up to 1. -// - addresses in developerRewardsReceivers are valid or empty string. -func (k Keeper) distributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk.Coin, developerRewardsProportion sdk.Dec, developerRewardsReceivers []types.WeightedAddress) (sdk.Int, error) { +// - addresses in developerRewardsReceivers are valid or empty string.osmomath.Dec +func (k Keeper) distributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk.Coin, developerRewardsProportion osmomath.Dec, developerRewardsReceivers []types.WeightedAddress) (osmomath.Int, error) { devRewardCoin, err := getProportions(totalMintedCoin, developerRewardsProportion) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } developerRewardsModuleAccountAddress := k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName) developerAccountBalance := k.bankKeeper.GetBalance(ctx, developerRewardsModuleAccountAddress, totalMintedCoin.Denom) if developerAccountBalance.Amount.LT(devRewardCoin.Amount) { - return sdk.Int{}, insufficientDevVestingBalanceError{ActualBalance: developerAccountBalance.Amount, AttemptedDistribution: devRewardCoin.Amount} + return osmomath.Int{}, insufficientDevVestingBalanceError{ActualBalance: developerAccountBalance.Amount, AttemptedDistribution: devRewardCoin.Amount} } devRewardCoins := sdk.NewCoins(devRewardCoin) // TODO: https://github.com/osmosis-labs/osmosis/issues/2025 // Avoid over-allocating from the mint module address and have to later burn it here: if err := k.bankKeeper.BurnCoins(ctx, types.ModuleName, devRewardCoins); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Take the current balance of the developer rewards pool and remove it from the supply offset @@ -233,14 +234,14 @@ func (k Keeper) distributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk. if len(developerRewardsReceivers) == 0 { err = k.communityPoolKeeper.FundCommunityPool(ctx, devRewardCoins, developerRewardsModuleAccountAddress) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } else { // allocate developer rewards to addresses by weight for _, w := range developerRewardsReceivers { devPortionCoin, err := getProportions(devRewardCoin, w.Weight) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } devRewardPortionCoins := sdk.NewCoins(devPortionCoin) // fund community pool when rewards address is empty. @@ -248,18 +249,18 @@ func (k Keeper) distributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk. err := k.communityPoolKeeper.FundCommunityPool(ctx, devRewardPortionCoins, k.accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } else { devRewardsAddr, err := sdk.AccAddressFromBech32(w.Address) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // If recipient is vesting account, pay to account according to its vesting condition err = k.bankKeeper.SendCoinsFromModuleToAccount( ctx, types.DeveloperVestingModuleAcctName, devRewardsAddr, devRewardPortionCoins) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } } @@ -275,12 +276,12 @@ func (k Keeper) distributeDeveloperRewards(ctx sdk.Context, totalMintedCoin sdk. // getProportions gets the balance of the `MintedDenom` from minted coins and returns coins according to the // allocation ratio. Returns error if ratio is greater than 1. // TODO: this currently rounds down and is the cause of rounding discrepancies. -// To be fixed in: https://github.com/osmosis-labs/osmosis/issues/1917 -func getProportions(mintedCoin sdk.Coin, ratio sdk.Dec) (sdk.Coin, error) { - if ratio.GT(sdk.OneDec()) { +// To be fixed in: https://github.com/osmosis-losmomath.Decosis/issues/1917 +func getProportions(mintedCoin sdk.Coin, ratio osmomath.Dec) (sdk.Coin, error) { + if ratio.GT(osmomath.OneDec()) { return sdk.Coin{}, invalidRatioError{ratio} } - return sdk.NewCoin(mintedCoin.Denom, mintedCoin.Amount.ToDec().Mul(ratio).TruncateInt()), nil + return sdk.NewCoin(mintedCoin.Denom, mintedCoin.Amount.ToLegacyDec().Mul(ratio).TruncateInt()), nil } // createDeveloperVestingModuleAccount creates the developer vesting module account diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index 8c01be00c9f..1c94b713c91 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -14,6 +14,7 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/mint/keeper" @@ -76,66 +77,66 @@ func (s *KeeperTestSuite) setupDeveloperVestingModuleAccountTest(blockHeight int // testing edge cases of multiple tests. developerVestingAccount := accountKeeper.GetAccount(s.Ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName)) accountKeeper.RemoveAccount(s.Ctx, developerVestingAccount) - err := bankKeeper.BurnCoins(s.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(keeper.DeveloperVestingAmount)))) + err := bankKeeper.BurnCoins(s.Ctx, types.ModuleName, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(keeper.DeveloperVestingAmount)))) s.Require().Error(err) // If developer module account is created, the s.Setup() also sets the offset, // therefore, we should reset it to 0 to set up the environment truly w/o the module account. supplyOffset := bankKeeper.GetSupplyOffset(s.Ctx, sdk.DefaultBondDenom) - bankKeeper.AddSupplyOffset(s.Ctx, sdk.DefaultBondDenom, supplyOffset.Mul(sdk.NewInt(-1))) - s.Require().Equal(sdk.ZeroInt(), bankKeeper.GetSupplyOffset(s.Ctx, sdk.DefaultBondDenom)) + bankKeeper.AddSupplyOffset(s.Ctx, sdk.DefaultBondDenom, supplyOffset.Mul(osmomath.NewInt(-1))) + s.Require().Equal(osmomath.ZeroInt(), bankKeeper.GetSupplyOffset(s.Ctx, sdk.DefaultBondDenom)) } } // TestGetProportions tests that mint allocations are computed as expected. func (s *KeeperTestSuite) TestGetProportions() { - complexRatioDec := sdk.NewDecWithPrec(131, 3).Quo(sdk.NewDecWithPrec(273, 3)) + complexRatioDec := osmomath.NewDecWithPrec(131, 3).Quo(osmomath.NewDecWithPrec(273, 3)) tests := []struct { name string - ratio sdk.Dec + ratio osmomath.Dec expectedCoin sdk.Coin expectedError error mintedCoin sdk.Coin }{ { name: "0 * 0.2 = 0", - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), - ratio: sdk.NewDecWithPrec(2, 1), - expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0)), + ratio: osmomath.NewDecWithPrec(2, 1), + expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0)), }, { name: "100000 * 0.2 = 20000", - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000)), - ratio: sdk.NewDecWithPrec(2, 1), - expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000).Quo(sdk.NewInt(5))), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100000)), + ratio: osmomath.NewDecWithPrec(2, 1), + expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100000).Quo(osmomath.NewInt(5))), }, { name: "123456 * 2/3 = 82304", - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(123456)), - ratio: sdk.NewDecWithPrec(2, 1).Quo(sdk.NewDecWithPrec(3, 1)), - expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(82304)), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(123456)), + ratio: osmomath.NewDecWithPrec(2, 1).Quo(osmomath.NewDecWithPrec(3, 1)), + expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(82304)), }, { - name: "54617981 * .131/.273 approx = 2.62", - mintedCoin: sdk.NewCoin("uosmo", sdk.NewInt(54617981)), + name: "54617981 * .131/.273osmomath.NewInt(.62", + mintedCoin: sdk.NewCoin("uosmo", osmomath.NewInt(54617981)), ratio: complexRatioDec, // .131/.273 // TODO: Should not be truncated. Remove truncation after rounding errors are addressed and resolved. - // Ref: https://github.com/osmosis-labs/osmosis/issues/1917 - expectedCoin: sdk.NewCoin("uosmo", sdk.NewInt(54617981).ToDec().Mul(complexRatioDec).TruncateInt()), + // Ref: https://github.com/osmosis-osmomath.NewInt(s/issues/1917 + expectedCoin: sdk.NewCoin("uosmo", osmomath.NewInt(54617981).ToLegacyDec().Mul(complexRatioDec).TruncateInt()), }, { name: "1 * 1 = 1", - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), - ratio: sdk.NewDec(1), - expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)), + ratio: osmomath.NewDec(1), + expectedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)), }, { name: "1 * 1.01 - error, ratio must be <= 1", - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), - ratio: sdk.NewDecWithPrec(101, 2), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0)), + ratio: osmomath.NewDecWithPrec(101, 2), - expectedError: keeper.ErrInvalidRatio{ActualRatio: sdk.NewDecWithPrec(101, 2)}, + expectedError: keeper.ErrInvalidRatio{ActualRatio: osmomath.NewDecWithPrec(101, 2)}, }, } @@ -172,29 +173,29 @@ func (s *KeeperTestSuite) TestDistributeMintedCoin() { weightedAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, - mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(mintAmount)), + mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(mintAmount)), }, { name: "multiple dev reward addresses", weightedAddresses: []types.WeightedAddress{ { Address: testAddressThree.String(), - Weight: sdk.NewDecWithPrec(6, 1), + Weight: osmomath.NewDecWithPrec(6, 1), }, { Address: testAddressFour.String(), - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, }, - mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(mintAmount)), + mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(mintAmount)), }, { name: "nil dev reward address - dev rewards go to community pool", weightedAddresses: nil, - mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(mintAmount)), + mintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(mintAmount)), }, } for _, tc := range tests { @@ -213,7 +214,7 @@ func (s *KeeperTestSuite) TestDistributeMintedCoin() { // is called once. mintKeeper.SetMintHooksUnsafe(&mintHooksMock{}) - mintAmount := tc.mintCoin.Amount.ToDec() + mintAmount := tc.mintCoin.Amount.ToLegacyDec() // set WeightedDeveloperRewardsReceivers params.WeightedDeveloperRewardsReceivers = tc.weightedAddresses @@ -222,7 +223,7 @@ func (s *KeeperTestSuite) TestDistributeMintedCoin() { expectedCommunityPoolAmount := mintAmount.Mul((params.DistributionProportions.CommunityPool)) expectedDevRewardsAmount := mintAmount.Mul(params.DistributionProportions.DeveloperRewards) expectedPoolIncentivesAmount := mintAmount.Mul(params.DistributionProportions.PoolIncentives) - expectedStakingAmount := tc.mintCoin.Amount.ToDec().Mul(params.DistributionProportions.Staking) + expectedStakingAmount := tc.mintCoin.Amount.ToLegacyDec().Mul(params.DistributionProportions.Staking) // distributions go to community pool because nil dev reward addresses. if tc.weightedAddresses == nil { @@ -242,17 +243,17 @@ func (s *KeeperTestSuite) TestDistributeMintedCoin() { s.Require().Equal(1, hooks.hookCallCount) // validate distributions to fee collector. - feeCollectorBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(authtypes.FeeCollectorName), sdk.DefaultBondDenom).Amount.ToDec() + feeCollectorBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(authtypes.FeeCollectorName), sdk.DefaultBondDenom).Amount.ToLegacyDec() s.Require().Equal( expectedStakingAmount, feeCollectorBalanceAmount) // validate pool incentives distributions. - actualPoolIncentivesBalance := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(poolincentivestypes.ModuleName), sdk.DefaultBondDenom).Amount.ToDec() + actualPoolIncentivesBalance := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(poolincentivestypes.ModuleName), sdk.DefaultBondDenom).Amount.ToLegacyDec() s.Require().Equal(expectedPoolIncentivesAmount, actualPoolIncentivesBalance) // validate distributions to community pool. - actualCommunityPoolBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(distributiontypes.ModuleName), sdk.DefaultBondDenom).Amount.ToDec() + actualCommunityPoolBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(distributiontypes.ModuleName), sdk.DefaultBondDenom).Amount.ToLegacyDec() s.Require().Equal(expectedCommunityPoolAmount, actualCommunityPoolBalanceAmount) // validate distributions to developer addresses. @@ -276,7 +277,7 @@ func (s *KeeperTestSuite) TestCreateDeveloperVestingModuleAccount() { }{ "valid call": { blockHeight: 0, - amount: sdk.NewCoin("stake", sdk.NewInt(keeper.DeveloperVestingAmount)), + amount: sdk.NewCoin("stake", osmomath.NewInt(keeper.DeveloperVestingAmount)), }, "nil amount": { blockHeight: 0, @@ -284,12 +285,12 @@ func (s *KeeperTestSuite) TestCreateDeveloperVestingModuleAccount() { }, "zero amount": { blockHeight: 0, - amount: sdk.NewCoin("stake", sdk.NewInt(0)), + amount: sdk.NewCoin("stake", osmomath.NewInt(0)), expectedError: errorsmod.Wrap(types.ErrAmountNilOrZero, "amount cannot be nil or zero"), }, "module account is already created": { blockHeight: 0, - amount: sdk.NewCoin("stake", sdk.NewInt(keeper.DeveloperVestingAmount)), + amount: sdk.NewCoin("stake", osmomath.NewInt(keeper.DeveloperVestingAmount)), isDeveloperModuleAccountCreated: true, expectedError: errorsmod.Wrapf(types.ErrModuleAccountAlreadyExist, "%s vesting module account already exist", types.DeveloperVestingModuleAcctName), }, @@ -326,58 +327,58 @@ func (s *KeeperTestSuite) TestDistributeToModule() { recepientModule string mintedCoin sdk.Coin - proportion sdk.Dec + proportion osmomath.Dec expectedError bool expectPanic bool }{ - "pre-mint == distribute - poolincentives module - full amount - success": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), + "pre-mint == distribute - poolincentives module osmomath.NewInt(nt - success": { + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), recepientModule: poolincentivestypes.ModuleName, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - proportion: sdk.NewDec(1), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), + proportion: osmomath.NewDec(1), }, - "pre-mint > distribute - developer vesting module - two thirds - success": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(101)), + "pre-mint > distribute - developer vesting modulosmomath.NewInt(rds - success": { + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(101)), recepientModule: poolincentivestypes.ModuleName, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - proportion: sdk.NewDecWithPrec(2, 1).Quo(sdk.NewDecWithPrec(3, 1)), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), + proportion: osmomath.NewDecWithPrec(2, 1).Quo(osmomath.NewDecWithPrec(3, 1)), }, "pre-mint < distribute (0) - error": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0)), recepientModule: poolincentivestypes.ModuleName, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - proportion: sdk.NewDecWithPrec(2, 1).Quo(sdk.NewDecWithPrec(3, 1)), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), + proportion: osmomath.NewDecWithPrec(2, 1).Quo(osmomath.NewDecWithPrec(3, 1)), expectedError: true, }, "denom does not exist - error": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), recepientModule: poolincentivestypes.ModuleName, - mintedCoin: sdk.NewCoin(denomDoesNotExist, sdk.NewInt(100)), - proportion: sdk.NewDec(1), + mintedCoin: sdk.NewCoin(denomDoesNotExist, osmomath.NewInt(100)), + proportion: osmomath.NewDec(1), expectedError: true, }, "invalid module account -panic": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), recepientModule: moduleAccountDoesNotExist, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - proportion: sdk.NewDec(1), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), + proportion: osmomath.NewDec(1), expectPanic: true, }, "proportion greater than 1 - error": { - preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(300)), + preMintCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(300)), recepientModule: poolincentivestypes.ModuleName, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100)), - proportion: sdk.NewDec(2), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100)), + proportion: osmomath.NewDec(2), expectedError: true, }, @@ -396,7 +397,7 @@ func (s *KeeperTestSuite) TestDistributeToModule() { // TODO: Should not be truncated. Remove truncation after rounding errors are addressed and resolved. // Ref: https://github.com/osmosis-labs/osmosis/issues/1917 - expectedDistributed := tc.mintedCoin.Amount.ToDec().Mul(tc.proportion).TruncateInt() + expectedDistributed := tc.mintedCoin.Amount.ToLegacyDec().Mul(tc.proportion).TruncateInt() oldMintModuleBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.ModuleName), tc.mintedCoin.Denom).Amount oldRecepientModuleBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(tc.recepientModule), tc.mintedCoin.Denom).Amount @@ -409,7 +410,7 @@ func (s *KeeperTestSuite) TestDistributeToModule() { if tc.expectedError { s.Require().Error(err) - s.Require().Equal(actualDistributed, sdk.Int{}) + s.Require().Equal(actualDistributed, osmomath.Int{}) // Old balances should not change. s.Require().Equal(oldMintModuleBalanceAmount.Int64(), actualMintModuleBalanceAmount.Int64()) s.Require().Equal(oldRecepientModuleBalanceAmount.Int64(), actualRecepientModuleBalanceAmount.Int64()) @@ -439,17 +440,17 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { ) var ( - validLargePreMintAmount = sdk.NewInt(keeper.DeveloperVestingAmount) - validPreMintAmountAddOne = sdk.NewInt(keeper.DeveloperVestingAmount).Add(sdk.OneInt()) + validLargePreMintAmount = osmomath.NewInt(keeper.DeveloperVestingAmount) + validPreMintAmountAddOne = osmomath.NewInt(keeper.DeveloperVestingAmount).Add(osmomath.OneInt()) validPreMintCoin = sdk.NewCoin(sdk.DefaultBondDenom, validLargePreMintAmount) - validPreMintCoinSubOne = sdk.NewCoin(sdk.DefaultBondDenom, validLargePreMintAmount.Sub(sdk.OneInt())) + validPreMintCoinSubOne = sdk.NewCoin(sdk.DefaultBondDenom, validLargePreMintAmount.Sub(osmomath.OneInt())) ) tests := map[string]struct { preMintCoin sdk.Coin mintedCoin sdk.Coin - proportion sdk.Dec + proportion osmomath.Dec recepientAddresses []types.WeightedAddress expectedError error @@ -463,31 +464,30 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(153, 3), + proportion: osmomath.NewDecWithPrec(153, 3), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, }, "valid case with 3 weighted addresses and custom large mint amount under pre mint": { preMintCoin: validPreMintCoin, - - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(939_123_546_789)), - proportion: sdk.NewDecWithPrec(31347, 5), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(939_123_546_789)), + proportion: osmomath.NewDecWithPrec(31347, 5), recepientAddresses: []types.WeightedAddress{ // .231 + .4 + .369 { Address: testAddressOne.String(), - Weight: sdk.NewDecWithPrec(231, 3), + Weight: osmomath.NewDecWithPrec(231, 3), }, { Address: testAddressTwo.String(), - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, { Address: testAddressThree.String(), - Weight: sdk.NewDecWithPrec(369, 3), + Weight: osmomath.NewDecWithPrec(369, 3), }, }, }, @@ -495,15 +495,15 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(123, 3), + proportion: osmomath.NewDecWithPrec(123, 3), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { Address: testAddressOne.String(), - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, }, // Since we have double the full amount allocated @@ -515,17 +515,17 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(153, 3), + proportion: osmomath.NewDecWithPrec(153, 3), }, "valid case with 0 amount of total minted coin": { preMintCoin: validPreMintCoin, - mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.ZeroInt()), - proportion: sdk.NewDecWithPrec(153, 3), + mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.ZeroInt()), + proportion: osmomath.NewDecWithPrec(153, 3), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, }, @@ -533,25 +533,25 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDec(2), + proportion: osmomath.NewDec(2), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, - expectedError: keeper.ErrInvalidRatio{ActualRatio: sdk.NewDec(2)}, + expectedError: keeper.ErrInvalidRatio{ActualRatio: osmomath.NewDec(2)}, }, "invalid address in developer reward receivers - error": { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(153, 3), + proportion: osmomath.NewDecWithPrec(153, 3), recepientAddresses: []types.WeightedAddress{ { Address: invalidAddress, - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, @@ -566,11 +566,11 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoinSubOne, mintedCoin: validPreMintCoin, - proportion: sdk.OneDec(), + proportion: osmomath.OneDec(), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, expectedError: errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, fmt.Sprintf("%s is smaller than %s", validPreMintCoinSubOne, validPreMintCoin)), @@ -579,11 +579,11 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: sdk.NewCoin(sdk.DefaultBondDenom, validPreMintAmountAddOne), - proportion: sdk.OneDec(), + proportion: osmomath.OneDec(), recepientAddresses: []types.WeightedAddress{ { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, expectedError: keeper.ErrInsufficientDevVestingBalance{ActualBalance: validPreMintCoin.Amount, AttemptedDistribution: validPreMintAmountAddOne}, @@ -592,11 +592,11 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(153, 3), + proportion: osmomath.NewDecWithPrec(153, 3), recepientAddresses: []types.WeightedAddress{ { Address: keeper.EmptyWeightedAddressReceiver, - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, }, @@ -604,15 +604,15 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { preMintCoin: validPreMintCoin, mintedCoin: validPreMintCoin, - proportion: sdk.NewDecWithPrec(153, 3), + proportion: osmomath.NewDecWithPrec(153, 3), recepientAddresses: []types.WeightedAddress{ { Address: keeper.EmptyWeightedAddressReceiver, - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, { Address: testAddressOne.String(), - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, }, @@ -632,12 +632,12 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { // TODO: Should not be truncated. Remove truncation after rounding errors are addressed and resolved. // Ref: https://github.com/osmosis-labs/osmosis/issues/1917 - expectedDistributed := tc.mintedCoin.Amount.ToDec().Mul(tc.proportion).TruncateInt() + expectedDistributed := tc.mintedCoin.Amount.ToLegacyDec().Mul(tc.proportion).TruncateInt() oldMintModuleBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.ModuleName), tc.mintedCoin.Denom).Amount oldDeveloperVestingModuleBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(types.DeveloperVestingModuleAcctName), tc.mintedCoin.Denom).Amount oldCommunityPoolBalanceAmount := bankKeeper.GetBalance(ctx, accountKeeper.GetModuleAddress(distributiontypes.ModuleName), tc.mintedCoin.Denom).Amount - oldDeveloperRewardsBalanceAmounts := make([]sdk.Int, len(tc.recepientAddresses)) + oldDeveloperRewardsBalanceAmounts := make([]osmomath.Int, len(tc.recepientAddresses)) for i, weightedAddress := range tc.recepientAddresses { if weightedAddress.Address == keeper.EmptyWeightedAddressReceiver { continue @@ -659,7 +659,7 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { if tc.expectedError != nil { s.Require().Error(err) s.Require().Equal(tc.expectedError.Error(), err.Error()) - s.Require().Equal(actualDistributed, sdk.Int{}) + s.Require().Equal(actualDistributed, osmomath.Int{}) // See testcases with this flag set to true for details. if tc.allowBalanceChange { @@ -690,12 +690,11 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { // TODO: these should be equal, slightly off due to known rounding issues: https://github.com/osmosis-labs/osmosis/issues/1917 // s.Require().Equal(oldDeveloperVestingModuleBalanceAmount.Sub(expectedDistributed).Int64(), actualDeveloperVestingModuleBalanceAmount.Int64()) - - expectedDistributedCommunityPool := sdk.NewInt(0) + expectedDistributedCommunityPool := osmomath.NewInt(0) for i, weightedAddress := range tc.recepientAddresses { // TODO: truncation should not occur: https://github.com/osmosis-labs/osmosis/issues/1917 - expectedAllocation := expectedDistributed.ToDec().Mul(tc.recepientAddresses[i].Weight).TruncateInt() + expectedAllocation := expectedDistributed.ToLegacyDec().Mul(tc.recepientAddresses[i].Weight).TruncateInt() if weightedAddress.Address == keeper.EmptyWeightedAddressReceiver { expectedDistributedCommunityPool = expectedDistributedCommunityPool.Add(expectedAllocation) @@ -709,7 +708,7 @@ func (s *KeeperTestSuite) TestDistributeDeveloperRewards() { // Edge case. See testcases with this flag set to true for details. if tc.expectSameAddresses { - s.Require().Equal(oldDeveloperRewardsBalanceAmounts[i].Add(expectedAllocation.Mul(sdk.NewInt(2))).Int64(), actualDeveloperRewardsBalanceAmounts.Int64()) + s.Require().Equal(oldDeveloperRewardsBalanceAmounts[i].Add(expectedAllocation.Mul(osmomath.NewInt(2))).Int64(), actualDeveloperRewardsBalanceAmounts.Int64()) return } diff --git a/x/mint/simulation/decoder_test.go b/x/mint/simulation/decoder_test.go index 0f2b822c6a4..f95c5815763 100644 --- a/x/mint/simulation/decoder_test.go +++ b/x/mint/simulation/decoder_test.go @@ -6,11 +6,11 @@ import ( "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" simapp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/x/mint/simulation" "github.com/osmosis-labs/osmosis/v19/x/mint/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" ) @@ -18,7 +18,7 @@ func TestDecodeStore(t *testing.T) { cdc, _ := simapp.MakeCodecs() dec := simulation.NewDecodeStore(cdc) - minter := types.NewMinter(sdk.NewDec(15)) + minter := types.NewMinter(osmomath.NewDec(15)) kvPairs := kv.Pairs{ Pairs: []kv.Pair{ diff --git a/x/mint/simulation/genesis.go b/x/mint/simulation/genesis.go index 92a0263bc08..3462516dbb6 100644 --- a/x/mint/simulation/genesis.go +++ b/x/mint/simulation/genesis.go @@ -5,6 +5,7 @@ package simulation import ( "math/rand" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,84 +27,84 @@ const ( var ( // Taken from: // https://github.com/osmosis-labs/networks/raw/main/osmosis-1/genesis.json distributionProportions = types.DistributionProportions{ - Staking: sdk.NewDecWithPrec(25, 2), - PoolIncentives: sdk.NewDecWithPrec(45, 2), - DeveloperRewards: sdk.NewDecWithPrec(25, 2), - CommunityPool: sdk.NewDecWithPrec(0o5, 2), + Staking: osmomath.NewDecWithPrec(25, 2), + PoolIncentives: osmomath.NewDecWithPrec(45, 2), + DeveloperRewards: osmomath.NewDecWithPrec(25, 2), + CommunityPool: osmomath.NewDecWithPrec(0o5, 2), } weightedDevRewardReceivers = []types.WeightedAddress{ { Address: "osmo14kjcwdwcqsujkdt8n5qwpd8x8ty2rys5rjrdjj", - Weight: sdk.NewDecWithPrec(2887, 4), + Weight: osmomath.NewDecWithPrec(2887, 4), }, { Address: "osmo1gw445ta0aqn26suz2rg3tkqfpxnq2hs224d7gq", - Weight: sdk.NewDecWithPrec(229, 3), + Weight: osmomath.NewDecWithPrec(229, 3), }, { Address: "osmo13lt0hzc6u3htsk7z5rs6vuurmgg4hh2ecgxqkf", - Weight: sdk.NewDecWithPrec(1625, 4), + Weight: osmomath.NewDecWithPrec(1625, 4), }, { Address: "osmo1kvc3he93ygc0us3ycslwlv2gdqry4ta73vk9hu", - Weight: sdk.NewDecWithPrec(109, 3), + Weight: osmomath.NewDecWithPrec(109, 3), }, { Address: "osmo19qgldlsk7hdv3ddtwwpvzff30pxqe9phq9evxf", - Weight: sdk.NewDecWithPrec(995, 3).Quo(sdk.NewDec(10)), // 0.0995 + Weight: osmomath.NewDecWithPrec(995, 3).Quo(osmomath.NewDec(10)), // 0.0995 }, { Address: "osmo19fs55cx4594een7qr8tglrjtt5h9jrxg458htd", - Weight: sdk.NewDecWithPrec(6, 1).Quo(sdk.NewDec(10)), // 0.06 + Weight: osmomath.NewDecWithPrec(6, 1).Quo(osmomath.NewDec(10)), // 0.06 }, { Address: "osmo1ssp6px3fs3kwreles3ft6c07mfvj89a544yj9k", - Weight: sdk.NewDecWithPrec(15, 2).Quo(sdk.NewDec(10)), // 0.015 + Weight: osmomath.NewDecWithPrec(15, 2).Quo(osmomath.NewDec(10)), // 0.015 }, { Address: "osmo1c5yu8498yzqte9cmfv5zcgtl07lhpjrj0skqdx", - Weight: sdk.NewDecWithPrec(1, 1).Quo(sdk.NewDec(10)), // 0.01 + Weight: osmomath.NewDecWithPrec(1, 1).Quo(osmomath.NewDec(10)), // 0.01 }, { Address: "osmo1yhj3r9t9vw7qgeg22cehfzj7enwgklw5k5v7lj", - Weight: sdk.NewDecWithPrec(75, 2).Quo(sdk.NewDec(100)), // 0.0075 + Weight: osmomath.NewDecWithPrec(75, 2).Quo(osmomath.NewDec(100)), // 0.0075 }, { Address: "osmo18nzmtyn5vy5y45dmcdnta8askldyvehx66lqgm", - Weight: sdk.NewDecWithPrec(7, 1).Quo(sdk.NewDec(100)), // 0.007 + Weight: osmomath.NewDecWithPrec(7, 1).Quo(osmomath.NewDec(100)), // 0.007 }, { Address: "osmo1z2x9z58cg96ujvhvu6ga07yv9edq2mvkxpgwmc", - Weight: sdk.NewDecWithPrec(5, 1).Quo(sdk.NewDec(100)), // 0.005 + Weight: osmomath.NewDecWithPrec(5, 1).Quo(osmomath.NewDec(100)), // 0.005 }, { Address: "osmo1tvf3373skua8e6480eyy38avv8mw3hnt8jcxg9", - Weight: sdk.NewDecWithPrec(25, 2).Quo(sdk.NewDec(100)), // 0.0025 + Weight: osmomath.NewDecWithPrec(25, 2).Quo(osmomath.NewDec(100)), // 0.0025 }, { Address: "osmo1zs0txy03pv5crj2rvty8wemd3zhrka2ne8u05n", - Weight: sdk.NewDecWithPrec(25, 2).Quo(sdk.NewDec(100)), // 0.0025 + Weight: osmomath.NewDecWithPrec(25, 2).Quo(osmomath.NewDec(100)), // 0.0025 }, { Address: "osmo1djgf9p53n7m5a55hcn6gg0cm5mue4r5g3fadee", - Weight: sdk.NewDecWithPrec(1, 1).Quo(sdk.NewDec(100)), // 0.001 + Weight: osmomath.NewDecWithPrec(1, 1).Quo(osmomath.NewDec(100)), // 0.001 }, { Address: "osmo1488zldkrn8xcjh3z40v2mexq7d088qkna8ceze", - Weight: sdk.NewDecWithPrec(8, 1).Quo(sdk.NewDec(1000)), // 0.0008 + Weight: osmomath.NewDecWithPrec(8, 1).Quo(osmomath.NewDec(1000)), // 0.0008 }, } ) // RandomizedGenState generates a random GenesisState for mint. func RandomizedGenState(simState *module.SimulationState) { - var epochProvisions sdk.Dec + var epochProvisions osmomath.Dec simState.AppParams.GetOrGenerate( simState.Cdc, epochProvisionsKey, &epochProvisions, simState.Rand, func(r *rand.Rand) { epochProvisions = genEpochProvisions(r) }, ) - var reductionFactor sdk.Dec + var reductionFactor osmomath.Dec simState.AppParams.GetOrGenerate( simState.Cdc, reductionFactorKey, &reductionFactor, simState.Rand, func(r *rand.Rand) { reductionFactor = genReductionFactor(r) }, @@ -141,12 +142,12 @@ func RandomizedGenState(simState *module.SimulationState) { simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(mintGenesis) } -func genEpochProvisions(r *rand.Rand) sdk.Dec { - return sdk.NewDec(int64(r.Intn(maxInt64))) +func genEpochProvisions(r *rand.Rand) osmomath.Dec { + return osmomath.NewDec(int64(r.Intn(maxInt64))) } -func genReductionFactor(r *rand.Rand) sdk.Dec { - return sdk.NewDecWithPrec(int64(r.Intn(10)), 1) +func genReductionFactor(r *rand.Rand) osmomath.Dec { + return osmomath.NewDecWithPrec(int64(r.Intn(10)), 1) } func genReductionPeriodInEpochs(r *rand.Rand) int64 { diff --git a/x/mint/simulation/genesis_test.go b/x/mint/simulation/genesis_test.go index ab00a8bf3ad..5b9c9917437 100644 --- a/x/mint/simulation/genesis_test.go +++ b/x/mint/simulation/genesis_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/simulation" "github.com/osmosis-labs/osmosis/v19/x/mint/types" @@ -56,7 +57,7 @@ func TestRandomizedGenState(t *testing.T) { ) // Epoch provisions from Minter. - epochProvisionsDec, err := sdk.NewDecFromStr(expectedEpochProvisionsStr) + epochProvisionsDec, err := osmomath.NewDecFromStr(expectedEpochProvisionsStr) require.NoError(t, err) require.Equal(t, epochProvisionsDec, mintGenesis.Minter.EpochProvisions) @@ -64,7 +65,7 @@ func TestRandomizedGenState(t *testing.T) { require.Equal(t, simulation.ExpectedEpochIdentifier, mintGenesis.Params.EpochIdentifier) // Reduction factor. - reductionFactorDec, err := sdk.NewDecFromStr(expectedReductionFactorStr) + reductionFactorDec, err := osmomath.NewDecFromStr(expectedReductionFactorStr) require.NoError(t, err) require.Equal(t, reductionFactorDec, mintGenesis.Params.ReductionFactor) diff --git a/x/mint/types/expected_keepers.go b/x/mint/types/expected_keepers.go index f8132f3db5d..573d011bd59 100644 --- a/x/mint/types/expected_keepers.go +++ b/x/mint/types/expected_keepers.go @@ -1,6 +1,7 @@ package types // noalias import ( + "github.com/osmosis-labs/osmosis/osmomath" epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -24,7 +25,7 @@ type BankKeeper interface { SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error MintCoins(ctx sdk.Context, name string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, name string, amt sdk.Coins) error - AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) + AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount osmomath.Int) } // CommunityPoolKeeper defines the contract needed to be fulfilled for distribution keeper. diff --git a/x/mint/types/mint.pb.go b/x/mint/types/mint.pb.go index 0c7997a137e..c12cdb50923 100644 --- a/x/mint/types/mint.pb.go +++ b/x/mint/types/mint.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-sdk/codec/types" - 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" @@ -29,7 +29,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Minter represents the minting state. type Minter struct { // epoch_provisions represent rewards for the current epoch. - EpochProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=epoch_provisions,json=epochProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_provisions" yaml:"epoch_provisions"` + EpochProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=epoch_provisions,json=epochProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"epoch_provisions" yaml:"epoch_provisions"` } func (m *Minter) Reset() { *m = Minter{} } @@ -69,8 +69,8 @@ var xxx_messageInfo_Minter proto.InternalMessageInfo // The weight is used to determine the proportion of the total minted // tokens to be minted to the address. type WeightedAddress struct { - Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` - Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight" yaml:"weight"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty" yaml:"address"` + Weight cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight" yaml:"weight"` } func (m *WeightedAddress) Reset() { *m = WeightedAddress{} } @@ -119,16 +119,16 @@ func (m *WeightedAddress) GetAddress() string { type DistributionProportions struct { // staking defines the proportion of the minted mint_denom that is to be // allocated as staking rewards. - Staking github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=staking,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"staking" yaml:"staking"` + Staking cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=staking,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"staking" yaml:"staking"` // pool_incentives defines the proportion of the minted mint_denom that is // to be allocated as pool incentives. - PoolIncentives github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=pool_incentives,json=poolIncentives,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"pool_incentives" yaml:"pool_incentives"` + PoolIncentives cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=pool_incentives,json=poolIncentives,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"pool_incentives" yaml:"pool_incentives"` // developer_rewards defines the proportion of the minted mint_denom that is // to be allocated to developer rewards address. - DeveloperRewards github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=developer_rewards,json=developerRewards,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"developer_rewards" yaml:"developer_rewards"` + DeveloperRewards cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=developer_rewards,json=developerRewards,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"developer_rewards" yaml:"developer_rewards"` // community_pool defines the proportion of the minted mint_denom that is // to be allocated to the community pool. - CommunityPool github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=community_pool,json=communityPool,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"community_pool" yaml:"community_pool"` + CommunityPool cosmossdk_io_math.LegacyDec `protobuf:"bytes,4,opt,name=community_pool,json=communityPool,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"community_pool" yaml:"community_pool"` } func (m *DistributionProportions) Reset() { *m = DistributionProportions{} } @@ -169,7 +169,7 @@ type Params struct { // mint_denom is the denom of the coin to mint. MintDenom string `protobuf:"bytes,1,opt,name=mint_denom,json=mintDenom,proto3" json:"mint_denom,omitempty"` // genesis_epoch_provisions epoch provisions from the first epoch. - GenesisEpochProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=genesis_epoch_provisions,json=genesisEpochProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"genesis_epoch_provisions" yaml:"genesis_epoch_provisions"` + GenesisEpochProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=genesis_epoch_provisions,json=genesisEpochProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"genesis_epoch_provisions" yaml:"genesis_epoch_provisions"` // epoch_identifier mint epoch identifier e.g. (day, week). EpochIdentifier string `protobuf:"bytes,3,opt,name=epoch_identifier,json=epochIdentifier,proto3" json:"epoch_identifier,omitempty" yaml:"epoch_identifier"` // reduction_period_in_epochs the number of epochs it takes @@ -177,7 +177,7 @@ type Params struct { ReductionPeriodInEpochs int64 `protobuf:"varint,4,opt,name=reduction_period_in_epochs,json=reductionPeriodInEpochs,proto3" json:"reduction_period_in_epochs,omitempty" yaml:"reduction_period_in_epochs"` // reduction_factor is the reduction multiplier to execute // at the end of each period set by reduction_period_in_epochs. - ReductionFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=reduction_factor,json=reductionFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"reduction_factor" yaml:"reduction_factor"` + ReductionFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=reduction_factor,json=reductionFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"reduction_factor" yaml:"reduction_factor"` // distribution_proportions defines the distribution proportions of the minted // denom. In other words, defines which stakeholders will receive the minted // denoms and how much. @@ -276,55 +276,56 @@ func init() { func init() { proto.RegisterFile("osmosis/mint/v1beta1/mint.proto", fileDescriptor_ccb38f8335e0f45b) } var fileDescriptor_ccb38f8335e0f45b = []byte{ - // 768 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0xcd, 0x6e, 0xf3, 0x44, - 0x14, 0x8d, 0x49, 0x49, 0xf9, 0xa6, 0x6a, 0x53, 0xac, 0xd2, 0x98, 0x22, 0xe2, 0xd6, 0x6a, 0x51, - 0x90, 0x68, 0x4c, 0xdb, 0x15, 0xdd, 0x00, 0x51, 0x28, 0xa4, 0x12, 0x52, 0x18, 0x16, 0x95, 0xba, - 0xb1, 0x1c, 0x7b, 0xea, 0x8e, 0x1a, 0x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6, 0xe2, 0x05, 0x1b, 0xe0, 0x0f, 0x0b, - 0xec, 0x8f, 0xcc, 0xe2, 0x0a, 0x5e, 0xf4, 0x7a, 0xc0, 0x50, 0x84, 0xf0, 0x10, 0x31, 0xee, 0xac, - 0xee, 0x96, 0x1b, 0x6b, 0xc7, 0x07, 0xaf, 0x9b, 0x17, 0x56, 0x5f, 0xeb, 0x53, 0x69, 0x3a, 0xaf, - 0xff, 0x62, 0x5d, 0x0f, 0xee, 0xe5, 0xee, 0xed, 0xc2, 0x50, 0xc1, 0xdc, 0x5a, 0xf6, 0x70, 0x43, - 0xda, 0x61, 0x92, 0xcc, 0x04, 0x9e, 0x15, 0x89, 0x8b, 0x90, 0x09, 0x7d, 0xa3, 0xce, 0x7b, 0xea, - 0xf2, 0x4f, 0xa6, 0x13, 0xd7, 0xd7, 0xe6, 0xff, 0xf7, 0x9f, 0x1e, 0xdc, 0x37, 0x54, 0x93, 0xc0, - 0xd3, 0x8a, 0xfe, 0x28, 0x79, 0xaa, 0x31, 0x4e, 0x57, 0x6e, 0x7f, 0x77, 0x4b, 0xad, 0xf3, 0xbb, - 0x87, 0xba, 0x75, 0xff, 0x50, 0xb7, 0xfe, 0x79, 0xa8, 0x5b, 0xbf, 0x3d, 0xd6, 0x4b, 0xf7, 0x8f, - 0xf5, 0xd2, 0x5f, 0x8f, 0xf5, 0xd2, 0xe5, 0xe7, 0x4f, 0xba, 0xc2, 0x14, 0xeb, 0xb0, 0x1f, 0xf6, - 0x78, 0x7e, 0xf0, 0x87, 0x47, 0x5f, 0xf8, 0x3f, 0xeb, 0x2f, 0xaa, 0xea, 0x91, 0x5e, 0x45, 0x7d, - 0xc3, 0x4e, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x6e, 0xde, 0x68, 0x0c, 0x6e, 0x07, 0x00, 0x00, + // 774 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 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 0xfc, 0x36, 0xcb, 0x16, 0xee, 0xe0, 0xe0, 0x0f, 0xf7, 0xb9, 0xfa, 0xe7, 0xe3, + 0xc3, 0x14, 0xb1, 0x76, 0x49, 0xfe, 0xd7, 0x1c, 0x7d, 0x09, 0x00, 0x00, 0xff, 0xff, 0x2c, 0x9a, + 0xec, 0x92, 0x16, 0x07, 0x00, 0x00, } func (m *Minter) Marshal() (dAtA []byte, err error) { diff --git a/x/mint/types/minter.go b/x/mint/types/minter.go index 85f3278c344..943b93e34a9 100644 --- a/x/mint/types/minter.go +++ b/x/mint/types/minter.go @@ -4,6 +4,8 @@ import ( "errors" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) var ( @@ -13,7 +15,7 @@ var ( // NewMinter returns a new Minter object with the given epoch // provisions values. -func NewMinter(epochProvisions sdk.Dec) Minter { +func NewMinter(epochProvisions osmomath.Dec) Minter { return Minter{ EpochProvisions: epochProvisions, } @@ -21,7 +23,7 @@ func NewMinter(epochProvisions sdk.Dec) Minter { // InitialMinter returns an initial Minter object. func InitialMinter() Minter { - return NewMinter(sdk.NewDec(0)) + return NewMinter(osmomath.NewDec(0)) } // DefaultInitialMinter returns a default initial Minter object for a new chain. @@ -42,7 +44,7 @@ func (m Minter) Validate() error { } // NextEpochProvisions returns the epoch provisions. -func (m Minter) NextEpochProvisions(params Params) sdk.Dec { +func (m Minter) NextEpochProvisions(params Params) osmomath.Dec { return m.EpochProvisions.Mul(params.ReductionFactor) } diff --git a/x/mint/types/minter_test.go b/x/mint/types/minter_test.go index 59ffae14e8e..8bfffcb4289 100644 --- a/x/mint/types/minter_test.go +++ b/x/mint/types/minter_test.go @@ -4,6 +4,7 @@ import ( "math/rand" "testing" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -11,8 +12,8 @@ import ( ) var ( - defaultDeveloperVestingProportion = sdk.NewDecWithPrec(3, 1) - defaultProvisionsAmount = sdk.NewDec(10) + defaultDeveloperVestingProportion = osmomath.NewDecWithPrec(3, 1) + defaultProvisionsAmount = osmomath.NewDec(10) defaultParams = types.Params{ MintDenom: sdk.DefaultBondDenom, DistributionProportions: types.DistributionProportions{ @@ -22,10 +23,10 @@ var ( ) // Benchmarking :) -// previously using sdk.Int operations: +// previously using osmomath.Int operations: // BenchmarkEpochProvision-4 5000000 220 ns/op // -// using sdk.Dec operations: (current implementation) +// using osmomath.Dec operations: (current implementation) // BenchmarkEpochProvision-4 3000000 429 ns/op func BenchmarkEpochProvision(b *testing.B) { b.ReportAllocs() @@ -34,7 +35,7 @@ func BenchmarkEpochProvision(b *testing.B) { s1 := rand.NewSource(100) r1 := rand.New(s1) - minter.EpochProvisions = sdk.NewDec(r1.Int63n(1000000)) + minter.EpochProvisions = osmomath.NewDec(r1.Int63n(1000000)) // run the EpochProvision function b.N times for n := 0; n < b.N; n++ { @@ -69,7 +70,7 @@ func TestMinterValidate(t *testing.T) { { "negative -errir", types.Minter{ - EpochProvisions: sdk.NewDec(-1), + EpochProvisions: osmomath.NewDec(-1), }, types.ErrNegativeEpochProvisions, }, @@ -100,7 +101,7 @@ func TestGetInflationProvisions(t *testing.T) { minter = types.NewMinter(defaultProvisionsAmount) expectedDenom = defaultParams.MintDenom - expectedInflationAmount = defaultProvisionsAmount.Mul(sdk.OneDec().Sub(defaultDeveloperVestingProportion)) + expectedInflationAmount = defaultProvisionsAmount.Mul(osmomath.OneDec().Sub(defaultDeveloperVestingProportion)) ) // System under test diff --git a/x/mint/types/params.go b/x/mint/types/params.go index f3a1cb192cb..b39dba61b80 100644 --- a/x/mint/types/params.go +++ b/x/mint/types/params.go @@ -7,6 +7,7 @@ import ( yaml "gopkg.in/yaml.v2" + "github.com/osmosis-labs/osmosis/osmomath" epochtypes "github.com/osmosis-labs/osmosis/x/epochs/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,8 +35,8 @@ func ParamKeyTable() paramtypes.KeyTable { // NewParams returns new mint module parameters initialized to the given values. func NewParams( - mintDenom string, genesisEpochProvisions sdk.Dec, epochIdentifier string, - ReductionFactor sdk.Dec, reductionPeriodInEpochs int64, distrProportions DistributionProportions, + mintDenom string, genesisEpochProvisions osmomath.Dec, epochIdentifier string, + ReductionFactor osmomath.Dec, reductionPeriodInEpochs int64, distrProportions DistributionProportions, weightedDevRewardsReceivers []WeightedAddress, mintingRewardsDistributionStartEpoch int64, ) Params { return Params{ @@ -54,15 +55,15 @@ func NewParams( func DefaultParams() Params { return Params{ MintDenom: sdk.DefaultBondDenom, - GenesisEpochProvisions: sdk.NewDec(5000000), - EpochIdentifier: "week", // 1 week - ReductionPeriodInEpochs: 156, // 3 years - ReductionFactor: sdk.NewDecWithPrec(5, 1), // 0.5 + GenesisEpochProvisions: osmomath.NewDec(5000000), + EpochIdentifier: "week", // 1 week + ReductionPeriodInEpochs: 156, // 3 years + ReductionFactor: osmomath.NewDecWithPrec(5, 1), // 0.5 DistributionProportions: DistributionProportions{ - Staking: sdk.NewDecWithPrec(4, 1), // 0.4 - PoolIncentives: sdk.NewDecWithPrec(3, 1), // 0.3 - DeveloperRewards: sdk.NewDecWithPrec(2, 1), // 0.2 - CommunityPool: sdk.NewDecWithPrec(1, 1), // 0.1 + Staking: osmomath.NewDecWithPrec(4, 1), // 0.4 + PoolIncentives: osmomath.NewDecWithPrec(3, 1), // 0.3 + DeveloperRewards: osmomath.NewDecWithPrec(2, 1), // 0.2 + CommunityPool: osmomath.NewDecWithPrec(1, 1), // 0.1 }, WeightedDeveloperRewardsReceivers: []WeightedAddress{}, MintingRewardsDistributionStartEpoch: 0, @@ -121,14 +122,14 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } // GetInflationProportion returns the inflation proportion of epoch -// provisions. -func (p Params) GetInflationProportion() sdk.Dec { - return sdk.OneDec().Sub(p.GetDeveloperVestingProportion()) +// provisions.osmomath.Dec +func (p Params) GetInflationProportion() osmomath.Dec { + return osmomath.OneDec().Sub(p.GetDeveloperVestingProportion()) } // GetDeveloperVestingProportion returns the developer vesting proportion of epoch -// provisions. -func (p Params) GetDeveloperVestingProportion() sdk.Dec { +// provisions.osmomath.Dec +func (p Params) GetDeveloperVestingProportion() osmomath.Dec { return p.DistributionProportions.DeveloperRewards } @@ -149,7 +150,7 @@ func validateMintDenom(i interface{}) error { } func validateGenesisEpochProvisions(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(osmomath.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } @@ -175,12 +176,12 @@ func validateReductionPeriodInEpochs(i interface{}) error { } func validateReductionFactor(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(osmomath.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if v.GT(sdk.NewDec(1)) { + if v.GT(osmomath.NewDec(1)) { return fmt.Errorf("reduction factor cannot be greater than 1") } @@ -215,7 +216,7 @@ func validateDistributionProportions(i interface{}) error { totalProportions := v.Staking.Add(v.PoolIncentives).Add(v.DeveloperRewards).Add(v.CommunityPool) - if !totalProportions.Equal(sdk.NewDec(1)) { + if !totalProportions.Equal(osmomath.NewDec(1)) { return errors.New("total distributions ratio should be 1") } @@ -233,7 +234,7 @@ func validateWeightedDeveloperRewardsReceivers(i interface{}) error { return nil } - weightSum := sdk.NewDec(0) + weightSum := osmomath.NewDec(0) for i, w := range v { // we allow address to be "" to go to community pool if w.Address != "" { @@ -245,13 +246,13 @@ func validateWeightedDeveloperRewardsReceivers(i interface{}) error { if !w.Weight.IsPositive() { return fmt.Errorf("non-positive weight at %dth", i) } - if w.Weight.GT(sdk.NewDec(1)) { + if w.Weight.GT(osmomath.NewDec(1)) { return fmt.Errorf("more than 1 weight at %dth", i) } weightSum = weightSum.Add(w.Weight) } - if !weightSum.Equal(sdk.NewDec(1)) { + if !weightSum.Equal(osmomath.NewDec(1)) { return fmt.Errorf("invalid weight sum: %s", weightSum.String()) } diff --git a/x/mint/types/params_test.go b/x/mint/types/params_test.go index c718bc134cc..af4c5782414 100644 --- a/x/mint/types/params_test.go +++ b/x/mint/types/params_test.go @@ -3,17 +3,17 @@ package types_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/mint/types" ) // TestGetInflationProportion sanity checks that inflation // proportion equals to 1 - developer vesting proportion. func TestGetInflationProportion(t *testing.T) { - developerVestingProportion := sdk.NewDecWithPrec(4, 1) - expectedInflationProportion := sdk.OneDec().Sub(developerVestingProportion) + developerVestingProportion := osmomath.NewDecWithPrec(4, 1) + expectedInflationProportion := osmomath.OneDec().Sub(developerVestingProportion) params := types.Params{ DistributionProportions: types.DistributionProportions{ @@ -29,7 +29,7 @@ func TestGetInflationProportion(t *testing.T) { // vesting proportion equals to the value set by // parameter for dev rewards. func TestGetDeveloperVestingProportion(t *testing.T) { - expectedDevVestingProportion := sdk.NewDecWithPrec(4, 1) + expectedDevVestingProportion := osmomath.NewDecWithPrec(4, 1) params := types.Params{ DistributionProportions: types.DistributionProportions{ diff --git a/x/mint/types/query.pb.go b/x/mint/types/query.pb.go index 6ce0dbb6624..75f59f9567a 100644 --- a/x/mint/types/query.pb.go +++ b/x/mint/types/query.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -155,7 +155,7 @@ var xxx_messageInfo_QueryEpochProvisionsRequest proto.InternalMessageInfo // Query/EpochProvisions RPC method. type QueryEpochProvisionsResponse struct { // epoch_provisions is the current minting per epoch provisions value. - EpochProvisions github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=epoch_provisions,json=epochProvisions,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"epoch_provisions"` + EpochProvisions cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=epoch_provisions,json=epochProvisions,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"epoch_provisions"` } func (m *QueryEpochProvisionsResponse) Reset() { *m = QueryEpochProvisionsResponse{} } @@ -201,32 +201,32 @@ func init() { func init() { proto.RegisterFile("osmosis/mint/v1beta1/query.proto", fileDescriptor_cd2f42111e753fbb) } var fileDescriptor_cd2f42111e753fbb = []byte{ - // 394 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4e, 0xea, 0x40, - 0x14, 0x86, 0x5b, 0x72, 0x2f, 0x8b, 0xb9, 0x37, 0xc1, 0x8c, 0x2c, 0x4c, 0xad, 0x85, 0x34, 0x86, - 0xe0, 0x82, 0x19, 0x8b, 0x2b, 0x5d, 0x12, 0xdd, 0xb8, 0x02, 0x76, 0xba, 0x31, 0x6d, 0x9d, 0x94, - 0x46, 0xda, 0x29, 0x9d, 0x81, 0xc8, 0x56, 0x5f, 0xc0, 0xc4, 0x97, 0xf0, 0x11, 0x7c, 0x04, 0x96, - 0x24, 0x6e, 0x8c, 0x0b, 0x62, 0xc0, 0x07, 0x31, 0x9d, 0x8e, 0x44, 0x70, 0x62, 0x74, 0xd5, 0x66, - 0xce, 0x7f, 0xfe, 0xff, 0x9b, 0x73, 0x06, 0x54, 0x29, 0x8b, 0x28, 0x0b, 0x19, 0x8e, 0xc2, 0x98, - 0xe3, 0x91, 0xe3, 0x11, 0xee, 0x3a, 0x78, 0x30, 0x24, 0xe9, 0x18, 0x25, 0x29, 0xe5, 0x14, 0x96, - 0xa5, 0x02, 0x65, 0x0a, 0x24, 0x15, 0x46, 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xc4, 0xca, - 0xb5, 0xe4, 0x93, 0x82, 0x0f, 0x3a, 0x28, 0xad, 0x8d, 0x01, 0x3a, 0xdf, 0x84, 0xa8, 0x27, 0x6a, - 0x34, 0x7f, 0xd3, 0x22, 0x01, 0x91, 0x00, 0xac, 0xc3, 0x9a, 0x1a, 0x70, 0x7d, 0x03, 0xad, 0xd3, - 0xc9, 0xdc, 0xd2, 0xa7, 0x73, 0x4b, 0x7f, 0x9d, 0x5b, 0xfa, 0xdd, 0xc2, 0xd2, 0xa6, 0x0b, 0x4b, - 0x7b, 0x5e, 0x58, 0xda, 0xf9, 0xfe, 0xa7, 0x6d, 0x48, 0xaf, 0x46, 0xdf, 0xf5, 0xd8, 0xd2, 0x78, - 0xe4, 0x1c, 0xe2, 0xeb, 0xdc, 0x5e, 0xec, 0xc6, 0x2b, 0x8a, 0x07, 0x79, 0xf0, 0x1e, 0x00, 0x00, - 0xff, 0xff, 0x40, 0xb6, 0x14, 0x7c, 0x1f, 0x03, 0x00, 0x00, + // 399 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0x4a, 0xe3, 0x40, + 0x1c, 0xc6, 0x93, 0xb2, 0xdb, 0xc3, 0xec, 0x42, 0x97, 0xd9, 0x1e, 0x96, 0x34, 0x9b, 0x96, 0xec, + 0xb2, 0x74, 0x0f, 0x3b, 0xb3, 0xa9, 0x27, 0x3d, 0x16, 0xbd, 0x88, 0x48, 0xdb, 0xa3, 0x17, 0x99, + 0xc4, 0x21, 0x0d, 0x36, 0xf9, 0xa7, 0x99, 0x69, 0xb1, 0x57, 0x7d, 0x01, 0xc1, 0x97, 0xf0, 0x11, + 0x7c, 0x84, 0x1e, 0x0b, 0x5e, 0xc4, 0x43, 0x91, 0xd6, 0x07, 0x91, 0x4c, 0xd2, 0x42, 0x6b, 0x10, + 0xbd, 0x85, 0xf9, 0x7f, 0xff, 0xef, 0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0xbb, 0x12, 0xfa, 0xac, + 0x02, 0xf1, 0x95, 0x8e, 0xca, 0x19, 0x31, 0x6e, 0x16, 0xdf, 0xe7, 0x75, 0x41, 0xc6, 0xdf, 0x77, + 0x28, 0x33, 0x72, 0xfb, 0xf7, 0xe5, 0xfd, 0xf3, 0x4d, 0xc9, 0xc2, 0x26, 0x2d, 0xfc, 0x17, 0x59, + 0x3d, 0xf8, 0x56, 0x47, 0x95, 0xad, 0xbb, 0x63, 0xe7, 0x8d, 0x90, 0xe2, 0x1a, 0x8d, 0xd6, 0x47, + 0x56, 0x72, 0x40, 0xa2, 0x00, 0x9b, 0xf8, 0x4f, 0x31, 0xe0, 0x76, 0xed, 0xed, 0xc3, 0xe9, 0xc2, + 0xd2, 0x67, 0x0b, 0x4b, 0x7f, 0x5a, 0x58, 0xfa, 0xf5, 0xd2, 0xd2, 0x66, 0x4b, 0x4b, 0x7b, 0x58, + 0x5a, 0xda, 0xc9, 0x7f, 0x3f, 0x90, 0xfd, 0x91, 0x4b, 0x3c, 0x08, 0x57, 0x5e, 0xff, 0x06, 0xcc, + 0x15, 0x6b, 0xe3, 0xb1, 0xb3, 0x4b, 0x2f, 0x32, 0x7b, 0x39, 0x89, 0xb9, 0x70, 0xcb, 0xea, 0x15, + 0xee, 0xbc, 0x04, 0x00, 0x00, 0xff, 0xff, 0x37, 0x2f, 0x70, 0xd5, 0x14, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/pool-incentives/keeper/distr.go b/x/pool-incentives/keeper/distr.go index 674b6dd00f7..cbd43fd352f 100644 --- a/x/pool-incentives/keeper/distr.go +++ b/x/pool-incentives/keeper/distr.go @@ -6,6 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" @@ -42,10 +43,10 @@ func (k Keeper) AllocateAsset(ctx sdk.Context) error { ctx.Logger().Info("AllocateAsset minted amount", "module", types.ModuleName, "totalMintedAmount", asset.Amount, "height", ctx.BlockHeight()) - assetAmountDec := asset.Amount.ToDec() - totalWeightDec := distrInfo.TotalWeight.ToDec() + assetAmountDec := asset.Amount.ToLegacyDec() + totalWeightDec := distrInfo.TotalWeight.ToLegacyDec() for _, record := range distrInfo.Records { - allocatingAmount := assetAmountDec.Mul(record.Weight.ToDec().Quo(totalWeightDec)).TruncateInt() + allocatingAmount := assetAmountDec.Mul(record.Weight.ToLegacyDec().Quo(totalWeightDec)).TruncateInt() // when weight is too small and no amount is allocated, just skip this to avoid zero coin send issues if !allocatingAmount.IsPositive() { @@ -137,7 +138,7 @@ func (k Keeper) ReplaceDistrRecords(ctx sdk.Context, records ...types.DistrRecor return err } - totalWeight := sdk.NewInt(0) + totalWeight := osmomath.NewInt(0) for _, record := range records { totalWeight = totalWeight.Add(record.Weight) @@ -153,7 +154,7 @@ func (k Keeper) ReplaceDistrRecords(ctx sdk.Context, records ...types.DistrRecor // UpdateDistrRecords is checked for no err when a proposal is made, and executed when a proposal passes. func (k Keeper) UpdateDistrRecords(ctx sdk.Context, records ...types.DistrRecord) error { recordsMap := make(map[uint64]types.DistrRecord) - totalWeight := sdk.NewInt(0) + totalWeight := osmomath.NewInt(0) for _, existingRecord := range k.GetDistrInfo(ctx).Records { recordsMap[existingRecord.GaugeId] = existingRecord @@ -179,7 +180,7 @@ func (k Keeper) UpdateDistrRecords(ctx sdk.Context, records ...types.DistrRecord newRecords := []types.DistrRecord{} for _, val := range recordsMap { - if !val.Weight.Equal(sdk.ZeroInt()) { + if !val.Weight.Equal(osmomath.ZeroInt()) { newRecords = append(newRecords, val) } } diff --git a/x/pool-incentives/keeper/distr_test.go b/x/pool-incentives/keeper/distr_test.go index 46256cbec89..ad686e94084 100644 --- a/x/pool-incentives/keeper/distr_test.go +++ b/x/pool-incentives/keeper/distr_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -25,24 +26,24 @@ func (s *KeeperTestSuite) TestAllocateAsset() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 2, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { GaugeId: 3, - Weight: sdk.NewInt(300), + Weight: osmomath.NewInt(300), }, }, - mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(15000)), + mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(15000)), expectedGaugesBalances: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(2500))), - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(4999))), - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(7500))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(2500))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(4999))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(7500))), }, - expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.NewInt(0)), + expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, osmomath.NewInt(0)), }, // With minting 30000 stake to module, after AllocateAsset we get: @@ -55,33 +56,33 @@ func (s *KeeperTestSuite) TestAllocateAsset() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(700), + Weight: osmomath.NewInt(700), }, { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 2, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, }, - mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(30000)), + mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(30000)), expectedGaugesBalances: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0))), - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(3000))), - sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(6000))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(3000))), + sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(6000))), }, - expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.NewInt(21000)), + expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, osmomath.NewInt(21000)), }, // With minting 30000 stake to module, after AllocateAsset we get: // expectedCommunityPool = 30000 (Cause there are no gauges, all rewards are transferred to the community pool) { name: "community pool distribution when no distribution records are set", testingDistrRecord: []types.DistrRecord{}, - mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(30000)), + mintedCoins: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(30000)), expectedGaugesBalances: []sdk.Coins{}, - expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, sdk.NewInt(30000)), + expectedCommunityPool: sdk.NewDecCoin(sdk.DefaultBondDenom, osmomath.NewInt(30000)), }, } @@ -130,13 +131,13 @@ func (s *KeeperTestSuite) TestReplaceDistrRecords() { testingDistrRecord []types.DistrRecord isPoolPrepared bool expectErr bool - expectTotalWeight sdk.Int + expectTotalWeight osmomath.Int }{ { name: "Not existent gauge.", testingDistrRecord: []types.DistrRecord{{ GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }}, isPoolPrepared: false, expectErr: true, @@ -146,11 +147,11 @@ func (s *KeeperTestSuite) TestReplaceDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, }, isPoolPrepared: true, @@ -161,11 +162,11 @@ func (s *KeeperTestSuite) TestReplaceDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 2, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, { GaugeId: 1, - Weight: sdk.NewInt(250), + Weight: osmomath.NewInt(250), }, }, isPoolPrepared: true, @@ -176,32 +177,32 @@ func (s *KeeperTestSuite) TestReplaceDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, isPoolPrepared: true, expectErr: false, - expectTotalWeight: sdk.NewInt(200), + expectTotalWeight: osmomath.NewInt(200), }, { name: "With different weights", testingDistrRecord: []types.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, }, isPoolPrepared: true, expectErr: false, - expectTotalWeight: sdk.NewInt(300), + expectTotalWeight: osmomath.NewInt(300), }, } @@ -237,13 +238,13 @@ func (s *KeeperTestSuite) TestUpdateDistrRecords() { testingDistrRecord []types.DistrRecord isPoolPrepared bool expectErr bool - expectTotalWeight sdk.Int + expectTotalWeight osmomath.Int }{ { name: "Not existent gauge.", testingDistrRecord: []types.DistrRecord{{ GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }}, isPoolPrepared: false, expectErr: true, @@ -253,11 +254,11 @@ func (s *KeeperTestSuite) TestUpdateDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, isPoolPrepared: true, @@ -268,11 +269,11 @@ func (s *KeeperTestSuite) TestUpdateDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 2, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, }, isPoolPrepared: true, @@ -283,32 +284,32 @@ func (s *KeeperTestSuite) TestUpdateDistrRecords() { testingDistrRecord: []types.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, }, isPoolPrepared: true, expectErr: false, - expectTotalWeight: sdk.NewInt(200), + expectTotalWeight: osmomath.NewInt(200), }, { name: "With different weights", testingDistrRecord: []types.DistrRecord{ { GaugeId: 0, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, { GaugeId: 1, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, }, isPoolPrepared: true, expectErr: false, - expectTotalWeight: sdk.NewInt(300), + expectTotalWeight: osmomath.NewInt(300), }, } diff --git a/x/pool-incentives/keeper/genesis.go b/x/pool-incentives/keeper/genesis.go index 1c062ab9621..4afc3dc7502 100644 --- a/x/pool-incentives/keeper/genesis.go +++ b/x/pool-incentives/keeper/genesis.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -12,7 +13,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { k.SetLockableDurations(ctx, genState.LockableDurations) if genState.DistrInfo == nil { k.SetDistrInfo(ctx, types.DistrInfo{ - TotalWeight: sdk.NewInt(0), + TotalWeight: osmomath.NewInt(0), Records: nil, }) } else { diff --git a/x/pool-incentives/keeper/genesis_test.go b/x/pool-incentives/keeper/genesis_test.go index 1349618312b..895bf6d0abc 100644 --- a/x/pool-incentives/keeper/genesis_test.go +++ b/x/pool-incentives/keeper/genesis_test.go @@ -4,11 +4,11 @@ import ( "testing" "time" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" pool_incentives "github.com/osmosis-labs/osmosis/v19/x/pool-incentives" simapp "github.com/osmosis-labs/osmosis/v19/app" @@ -28,11 +28,11 @@ var ( time.Hour, }, DistrInfo: &types.DistrInfo{ - TotalWeight: sdk.NewInt(1), + TotalWeight: osmomath.NewInt(1), Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, diff --git a/x/pool-incentives/keeper/grpc_query.go b/x/pool-incentives/keeper/grpc_query.go index 4f9f4af08c7..e7b684ca8f4 100644 --- a/x/pool-incentives/keeper/grpc_query.go +++ b/x/pool-incentives/keeper/grpc_query.go @@ -10,6 +10,7 @@ import ( "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" incentivetypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -37,9 +38,9 @@ func (q Querier) GaugeIds(ctx context.Context, req *types.QueryGaugeIdsRequest) sdkCtx := sdk.UnwrapSDKContext(ctx) distrInfo := q.Keeper.GetDistrInfo(sdkCtx) - totalWeightDec := distrInfo.TotalWeight.ToDec() - incentivePercentage := sdk.NewDec(0) - percentMultiplier := sdk.NewInt(100) + totalWeightDec := distrInfo.TotalWeight.ToLegacyDec() + incentivePercentage := osmomath.NewDec(0) + percentMultiplier := osmomath.NewInt(100) pool, err := q.Keeper.poolmanagerKeeper.GetPool(sdkCtx, req.PoolId) if err != nil { @@ -57,7 +58,7 @@ func (q Querier) GaugeIds(ctx context.Context, req *types.QueryGaugeIdsRequest) for _, record := range distrInfo.Records { if record.GaugeId == gaugeId { // Pool incentive % = (gauge_id_weight / sum_of_all_pool_gauge_weight) * 100 - incentivePercentage = record.Weight.ToDec().Quo(totalWeightDec).MulInt(percentMultiplier) + incentivePercentage = record.Weight.ToLegacyDec().Quo(totalWeightDec).MulInt(percentMultiplier) } } @@ -84,7 +85,7 @@ func (q Querier) GaugeIds(ctx context.Context, req *types.QueryGaugeIdsRequest) for _, record := range distrInfo.Records { if record.GaugeId == gaugeId { // Pool incentive % = (gauge_id_weight / sum_of_all_pool_gauge_weight) * 100 - incentivePercentage = record.Weight.ToDec().Quo(totalWeightDec).MulInt(percentMultiplier) + incentivePercentage = record.Weight.ToLegacyDec().Quo(totalWeightDec).MulInt(percentMultiplier) } } diff --git a/x/pool-incentives/keeper/grpc_query_test.go b/x/pool-incentives/keeper/grpc_query_test.go index c94c5f2a6d0..e0b3d2723d0 100644 --- a/x/pool-incentives/keeper/grpc_query_test.go +++ b/x/pool-incentives/keeper/grpc_query_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" gammmigration "github.com/osmosis-labs/osmosis/v19/x/gamm/types/migration" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -73,22 +74,22 @@ func (s *KeeperTestSuite) TestDistrInfo() { for _, tc := range []struct { desc string poolCreated bool - weights []sdk.Int - expectedTotalWeight sdk.Int + weights []osmomath.Int + expectedTotalWeight osmomath.Int expectedRecordLength int }{ { desc: "No pool exists", poolCreated: false, - weights: []sdk.Int{}, - expectedTotalWeight: sdk.NewInt(0), + weights: []osmomath.Int{}, + expectedTotalWeight: osmomath.NewInt(0), expectedRecordLength: 0, }, { desc: "Happy case", poolCreated: true, - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, - expectedTotalWeight: sdk.NewInt(600), + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, + expectedTotalWeight: osmomath.NewInt(600), expectedRecordLength: 3, }, } { @@ -160,9 +161,9 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { for _, tc := range []struct { desc string poolCreated bool - weights []sdk.Int + weights []osmomath.Int clPoolWithGauge bool - clGaugeWeight sdk.Int + clGaugeWeight osmomath.Int perpetual bool nonPerpetual bool setupPoolMigrationLink bool @@ -171,26 +172,26 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { { desc: "No pool exist", poolCreated: false, - weights: []sdk.Int{}, + weights: []osmomath.Int{}, expectedRecordLength: 0, }, { desc: "Normal case", poolCreated: true, - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, expectedRecordLength: 3, }, { desc: "Perpetual", poolCreated: true, - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, perpetual: true, expectedRecordLength: 3, }, { desc: "Non Perpetual", poolCreated: true, - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, nonPerpetual: true, expectedRecordLength: 0, }, @@ -198,16 +199,16 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { desc: "Concentrated case, no pool migration link", poolCreated: true, clPoolWithGauge: true, - clGaugeWeight: sdk.NewInt(400), - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + clGaugeWeight: osmomath.NewInt(400), + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, expectedRecordLength: 3, // Note we expect 3 instead of 4 here, since the pool migration link is not setup. }, { desc: "Concentrated case, setup pool migration link", poolCreated: true, clPoolWithGauge: true, - clGaugeWeight: sdk.NewInt(400), - weights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + clGaugeWeight: osmomath.NewInt(400), + weights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, setupPoolMigrationLink: true, expectedRecordLength: 4, }, @@ -231,7 +232,7 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { s.Require().Equal(3, len(lockableDurations)) if tc.poolCreated { - balancerPoolId = s.PrepareBalancerPoolWithCoins(sdk.NewCoin("eth", sdk.NewInt(100000000000)), sdk.NewCoin("usdc", sdk.NewInt(100000000000))) + balancerPoolId = s.PrepareBalancerPoolWithCoins(sdk.NewCoin("eth", osmomath.NewInt(100000000000)), sdk.NewCoin("usdc", osmomath.NewInt(100000000000))) var distRecords []types.DistrRecord @@ -249,7 +250,7 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { Duration: time.Hour, }, time.Now(), 1, 0) s.Require().NoError(err) - distRecords = append(distRecords, types.DistrRecord{GaugeId: gaugePerpetualId, Weight: sdk.NewInt(300)}) + distRecords = append(distRecords, types.DistrRecord{GaugeId: gaugePerpetualId, Weight: osmomath.NewInt(300)}) } if tc.nonPerpetual { gaugeNonPerpetualId, err := s.App.IncentivesKeeper.CreateGauge( @@ -259,7 +260,7 @@ func (s *KeeperTestSuite) TestIncentivizedPools() { Duration: time.Hour, }, time.Now(), 1, 0) s.Require().NoError(err) - distRecords = append(distRecords, types.DistrRecord{GaugeId: gaugeNonPerpetualId, Weight: sdk.NewInt(100)}) + distRecords = append(distRecords, types.DistrRecord{GaugeId: gaugeNonPerpetualId, Weight: osmomath.NewInt(100)}) } // Sort in ascending order of gaugeId @@ -299,29 +300,29 @@ func (s *KeeperTestSuite) TestExternalIncentiveGauges() { tests := map[string]struct { poolCreated bool - internalGaugeWeights []sdk.Int + internalGaugeWeights []osmomath.Int externalGauges []externalGauge clPoolWithGauge bool - clGaugeWeight sdk.Int + clGaugeWeight osmomath.Int expectedNumExternalGauges int expectedGaugeIDs []uint64 }{ "No pool exist": { poolCreated: false, - internalGaugeWeights: []sdk.Int{}, + internalGaugeWeights: []osmomath.Int{}, expectedNumExternalGauges: 0, }, "All gauges are internal (no external gauges)": { poolCreated: true, - internalGaugeWeights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + internalGaugeWeights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, expectedNumExternalGauges: 0, }, "Mixed internal and external gauges": { poolCreated: true, - internalGaugeWeights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + internalGaugeWeights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, externalGauges: []externalGauge{{isPerpetual: true}, {isPerpetual: false}}, // Since there is no concentrated pool, there are only 3 internal gauges, one for each lockup duration @@ -330,7 +331,7 @@ func (s *KeeperTestSuite) TestExternalIncentiveGauges() { }, "More external gauges than internal gauges": { poolCreated: true, - internalGaugeWeights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + internalGaugeWeights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, externalGauges: []externalGauge{{isPerpetual: true}, {isPerpetual: false}, {isPerpetual: true}, {isPerpetual: true}, {isPerpetual: false}}, // Since there is no concentrated pool, there are only 3 internal gauges, one for each lockup duration @@ -339,7 +340,7 @@ func (s *KeeperTestSuite) TestExternalIncentiveGauges() { }, "Same number of external gauges as internal gauges": { poolCreated: true, - internalGaugeWeights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + internalGaugeWeights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, externalGauges: []externalGauge{{isPerpetual: true}, {isPerpetual: false}, {isPerpetual: true}}, // Since there is no concentrated pool, there are only 3 internal gauges, one for each lockup duration @@ -349,8 +350,8 @@ func (s *KeeperTestSuite) TestExternalIncentiveGauges() { "Internal gauge for concentrated pool exists": { poolCreated: true, clPoolWithGauge: true, - clGaugeWeight: sdk.NewInt(100), - internalGaugeWeights: []sdk.Int{sdk.NewInt(100), sdk.NewInt(200), sdk.NewInt(300)}, + clGaugeWeight: osmomath.NewInt(100), + internalGaugeWeights: []osmomath.Int{osmomath.NewInt(100), osmomath.NewInt(200), osmomath.NewInt(300)}, externalGauges: []externalGauge{{isPerpetual: true}, {isPerpetual: false}, {isPerpetual: true}, {isPerpetual: true}, {isPerpetual: false}}, // Since there is a concentrated pool, there are 4 internal gauges, one for each lockup duration and one for the epoch duration @@ -473,7 +474,7 @@ func (s *KeeperTestSuite) TestExternalIncentiveGauges_NoLock() { ) var ( - defaultCoins = sdk.NewCoins(sdk.NewCoin(defaultDenom, sdk.NewInt(10000000000))) + defaultCoins = sdk.NewCoins(sdk.NewCoin(defaultDenom, osmomath.NewInt(10000000000))) defaultLockableDuration = s.App.IncentivesKeeper.GetLockableDurations(s.Ctx)[0] @@ -592,13 +593,13 @@ func (s *KeeperTestSuite) TestGaugeIncentivePercentage() { // Create 3 records err = keeper.UpdateDistrRecords(s.Ctx, types.DistrRecord{ GaugeId: gauge1Id, - Weight: sdk.NewInt(100), + Weight: osmomath.NewInt(100), }, types.DistrRecord{ GaugeId: gauge2Id, - Weight: sdk.NewInt(200), + Weight: osmomath.NewInt(200), }, types.DistrRecord{ GaugeId: gauge3Id, - Weight: sdk.NewInt(300), + Weight: osmomath.NewInt(300), }) s.Require().NoError(err) diff --git a/x/pool-incentives/keeper/hooks.go b/x/pool-incentives/keeper/hooks.go index 657f3460c86..3a813bb31db 100644 --- a/x/pool-incentives/keeper/hooks.go +++ b/x/pool-incentives/keeper/hooks.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" minttypes "github.com/osmosis-labs/osmosis/v19/x/mint/types" ) @@ -28,11 +29,11 @@ func (h Hooks) AfterCFMMPoolCreated(ctx sdk.Context, sender sdk.AccAddress, pool } // AfterJoinPool hook is a noop. -func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { +func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int) { } // AfterExitPool hook is a noop. -func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { +func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins) { } // AfterCFMMSwap hook is a noop. diff --git a/x/pool-incentives/keeper/keeper_test.go b/x/pool-incentives/keeper/keeper_test.go index 3892971e674..08626a36dc4 100644 --- a/x/pool-incentives/keeper/keeper_test.go +++ b/x/pool-incentives/keeper/keeper_test.go @@ -4,9 +4,9 @@ import ( "testing" "time" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -366,11 +366,11 @@ func (s *KeeperTestSuite) TestIsPoolIncentivized() { s.PrepareConcentratedPool() s.App.PoolIncentivesKeeper.SetDistrInfo(s.Ctx, poolincentivestypes.DistrInfo{ - TotalWeight: sdk.NewInt(100), + TotalWeight: osmomath.NewInt(100), Records: []poolincentivestypes.DistrRecord{ { GaugeId: tc.poolId, - Weight: sdk.NewInt(50), + Weight: osmomath.NewInt(50), }, }, }) diff --git a/x/pool-incentives/types/genesis.go b/x/pool-incentives/types/genesis.go index 05f6259fe90..25b5ea97d86 100644 --- a/x/pool-incentives/types/genesis.go +++ b/x/pool-incentives/types/genesis.go @@ -7,7 +7,8 @@ import ( time "time" "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) func NewGenesisState(params Params, lockableDurations []time.Duration, distrInfo *DistrInfo) *GenesisState { @@ -28,7 +29,7 @@ func DefaultGenesisState() *GenesisState { time.Hour * 7, }, DistrInfo: &DistrInfo{ - TotalWeight: sdk.ZeroInt(), + TotalWeight: osmomath.ZeroInt(), Records: nil, }, } @@ -53,7 +54,7 @@ func ValidateGenesis(data *GenesisState) error { return err } - if data.DistrInfo.TotalWeight.LT(sdk.NewInt(0)) { + if data.DistrInfo.TotalWeight.LT(osmomath.NewInt(0)) { return errors.New("distrinfo weight should not be negative") } diff --git a/x/pool-incentives/types/genesis_test.go b/x/pool-incentives/types/genesis_test.go index ad9a2d0a78a..50c396bc536 100644 --- a/x/pool-incentives/types/genesis_test.go +++ b/x/pool-incentives/types/genesis_test.go @@ -5,10 +5,10 @@ import ( "time" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" ) func TestGenesisStateMarshalUnmarshal(t *testing.T) { @@ -23,7 +23,7 @@ func TestGenesisStateMarshalUnmarshal(t *testing.T) { Params: types.DefaultParams(), LockableDurations: []time.Duration(nil), DistrInfo: &types.DistrInfo{ - TotalWeight: sdk.ZeroInt(), + TotalWeight: osmomath.ZeroInt(), Records: nil, }, }, @@ -33,7 +33,7 @@ func TestGenesisStateMarshalUnmarshal(t *testing.T) { Params: types.DefaultParams(), LockableDurations: []time.Duration(nil), DistrInfo: &types.DistrInfo{ - TotalWeight: sdk.ZeroInt(), + TotalWeight: osmomath.ZeroInt(), Records: nil, }, }, @@ -43,11 +43,11 @@ func TestGenesisStateMarshalUnmarshal(t *testing.T) { Params: types.DefaultParams(), LockableDurations: []time.Duration(nil), DistrInfo: &types.DistrInfo{ - TotalWeight: sdk.NewInt(1), + TotalWeight: osmomath.NewInt(1), Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, @@ -58,7 +58,7 @@ func TestGenesisStateMarshalUnmarshal(t *testing.T) { Params: types.Params{}, LockableDurations: []time.Duration(nil), DistrInfo: &types.DistrInfo{ - TotalWeight: sdk.ZeroInt(), + TotalWeight: osmomath.ZeroInt(), Records: nil, }, }, diff --git a/x/pool-incentives/types/gov_test.go b/x/pool-incentives/types/gov_test.go index 0d7df0ad6ab..7d79cfebd3f 100644 --- a/x/pool-incentives/types/gov_test.go +++ b/x/pool-incentives/types/gov_test.go @@ -4,10 +4,10 @@ import ( "testing" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" ) func TestUpdatePoolIncentivesProposalMarshalUnmarshal(t *testing.T) { @@ -42,7 +42,7 @@ func TestUpdatePoolIncentivesProposalMarshalUnmarshal(t *testing.T) { Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, @@ -54,7 +54,7 @@ func TestUpdatePoolIncentivesProposalMarshalUnmarshal(t *testing.T) { Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(0), + Weight: osmomath.NewInt(0), }, }, }, @@ -66,11 +66,11 @@ func TestUpdatePoolIncentivesProposalMarshalUnmarshal(t *testing.T) { Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, { GaugeId: 2, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, diff --git a/x/pool-incentives/types/incentives.pb.go b/x/pool-incentives/types/incentives.pb.go index 53774f211e4..0d63eff3de2 100644 --- a/x/pool-incentives/types/incentives.pb.go +++ b/x/pool-incentives/types/incentives.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - 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" @@ -120,8 +120,8 @@ func (m *LockableDurationsInfo) GetLockableDurations() []time.Duration { } type DistrInfo struct { - TotalWeight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_weight,json=totalWeight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_weight" yaml:"total_weight"` - Records []DistrRecord `protobuf:"bytes,2,rep,name=records,proto3" json:"records"` + TotalWeight cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total_weight,json=totalWeight,proto3,customtype=cosmossdk.io/math.Int" json:"total_weight" yaml:"total_weight"` + Records []DistrRecord `protobuf:"bytes,2,rep,name=records,proto3" json:"records"` } func (m *DistrInfo) Reset() { *m = DistrInfo{} } @@ -165,8 +165,8 @@ func (m *DistrInfo) GetRecords() []DistrRecord { } type DistrRecord struct { - GaugeId uint64 `protobuf:"varint,1,opt,name=gauge_id,json=gaugeId,proto3" json:"gauge_id,omitempty" yaml:"gauge_id"` - Weight github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"weight"` + GaugeId uint64 `protobuf:"varint,1,opt,name=gauge_id,json=gaugeId,proto3" json:"gauge_id,omitempty" yaml:"gauge_id"` + Weight cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=weight,proto3,customtype=cosmossdk.io/math.Int" json:"weight"` } func (m *DistrRecord) Reset() { *m = DistrRecord{} } @@ -327,43 +327,43 @@ func init() { } var fileDescriptor_a8153bad03e553d1 = []byte{ - // 565 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x73, 0x6d, 0x94, 0xb4, 0xe7, 0xf0, 0xcb, 0x05, 0x91, 0x16, 0xc9, 0x8e, 0x4e, 0x02, - 0x55, 0x8a, 0x62, 0x13, 0x98, 0x08, 0x5b, 0x14, 0x40, 0x01, 0x86, 0xca, 0xa2, 0x42, 0x62, 0x89, - 0xec, 0xf8, 0xea, 0x58, 0xb5, 0xfd, 0x22, 0xdf, 0x25, 0xd0, 0xff, 0x00, 0x89, 0x85, 0xb1, 0x63, - 0xff, 0x0f, 0x36, 0xa6, 0x8e, 0x1d, 0x11, 0x83, 0x41, 0xc9, 0xc2, 0x9c, 0xbf, 0x00, 0xf9, 0x7c, - 0x26, 0x27, 0x2a, 0x55, 0x30, 0xe5, 0x9e, 0xd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0x99, 0x0d, 0x05, 0x5d, 0xe1, 0x76, 0xf0, 0x56, 0xb9, 0xe1, 0xe6, 0x66, 0x0b, - 0x5d, 0xfd, 0x46, 0xee, 0xc9, 0x37, 0x22, 0xc7, 0x50, 0x0a, 0x8b, 0x97, 0xf1, 0xa7, 0x0e, 0xa1, - 0xb8, 0xa1, 0xc0, 0x33, 0xfd, 0x10, 0x5f, 0x13, 0x90, 0x1c, 0x46, 0xa2, 0xed, 0xbf, 0xae, 0x4b, - 0x29, 0x22, 0xd7, 0xa5, 0x4d, 0x95, 0x4f, 0x87, 0xe7, 0x0b, 0x03, 0x5d, 0x2c, 0x0c, 0xf4, 0x73, - 0x61, 0xa0, 0xcf, 0x4b, 0xa3, 0x72, 0xb1, 0x34, 0x2a, 0xdf, 0x96, 0x46, 0xe5, 0xdd, 0x53, 0x65, - 0xe8, 0xb2, 0x47, 0x27, 0x72, 0x3d, 0x56, 0x06, 0xf6, 0xbc, 0xfb, 0xc4, 0xfe, 0x70, 0xe9, 0xef, - 0x40, 0x6c, 0xc3, 0xab, 0x09, 0xdf, 0x8f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xef, 0x98, 0xb1, - 0x8c, 0x36, 0x04, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xcd, 0x6e, 0xd3, 0x4c, + 0x14, 0xcd, 0xb4, 0x51, 0xd2, 0x8e, 0xf3, 0x7d, 0x80, 0x4b, 0x45, 0x5a, 0x84, 0x1d, 0x8d, 0x84, + 0x54, 0x29, 0xea, 0x98, 0xf0, 0xb3, 0x20, 0xec, 0xa2, 0x48, 0x28, 0xc0, 0xa2, 0xb2, 0xa8, 0x2a, + 0xb1, 0x89, 0xec, 0x78, 0xea, 0x58, 0xb5, 0x7d, 0x23, 0xcf, 0x24, 0x50, 0x9e, 0x80, 0x25, 0xcb, + 0x2e, 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e9, + 0xed, 0x92, 0xd3, 0x0d, 0xd9, 0x7d, 0x7b, 0x99, 0x9a, 0x8d, 0x92, 0xd3, 0x92, 0x4d, 0x1b, 0x6f, + 0x15, 0xeb, 0x6b, 0x6e, 0xb6, 0xd0, 0xfa, 0x07, 0x70, 0x5f, 0x3d, 0x00, 0x95, 0xba, 0x20, 0xe6, + 0x6b, 0xff, 0x33, 0x87, 0x30, 0xdc, 0x28, 0x99, 0xe7, 0xfa, 0x31, 0xfe, 0x4f, 0x9a, 0x14, 0x30, + 0x94, 0xb2, 0xff, 0xba, 0x9c, 0xd2, 0x10, 0xb5, 0x1c, 0x6d, 0x52, 0xba, 0x3a, 0xbe, 0x9a, 0x1b, + 0xe8, 0x7a, 0x6e, 0xa0, 0x9f, 0x73, 0x03, 0x7d, 0x5e, 0x18, 0x95, 0xeb, 0x85, 0x51, 0xf9, 0xb6, + 0x30, 0x2a, 0xef, 0x5e, 0xf8, 0x81, 0x18, 0x4f, 0x5d, 0x3a, 0x82, 0xc8, 0x52, 0x1a, 0x87, 0xa1, + 0xe3, 0xf2, 0xa2, 0xb0, 0x66, 0x9d, 0xe7, 0xd6, 0x87, 0x1b, 0xff, 0xba, 0x38, 0x9f, 0x30, 0xee, + 0xd6, 0x64, 0xee, 0x27, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3d, 0xc7, 0x20, 0x7a, 0x13, 0x04, + 0x00, 0x00, } func (this *DistrRecord) Equal(that interface{}) bool { diff --git a/x/pool-incentives/types/incentives_test.go b/x/pool-incentives/types/incentives_test.go index 00284e24966..2b4a560d930 100644 --- a/x/pool-incentives/types/incentives_test.go +++ b/x/pool-incentives/types/incentives_test.go @@ -5,10 +5,10 @@ import ( "time" proto "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" + "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" ) func TestParamsMarshalUnmarshal(t *testing.T) { @@ -72,32 +72,32 @@ func TestDistrInfoMarshalUnmarshal(t *testing.T) { }{ { // empty records info: &types.DistrInfo{ - TotalWeight: sdk.NewInt(0), + TotalWeight: osmomath.NewInt(0), Records: []types.DistrRecord(nil), }, }, { // one record info: &types.DistrInfo{ - TotalWeight: sdk.NewInt(1), + TotalWeight: osmomath.NewInt(1), Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, }, { // two records info: &types.DistrInfo{ - TotalWeight: sdk.NewInt(2), + TotalWeight: osmomath.NewInt(2), Records: []types.DistrRecord{ { GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, { GaugeId: 2, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, }, @@ -124,7 +124,7 @@ func TestDistrRecordMarshalUnmarshal(t *testing.T) { { // filled struct info: &types.DistrRecord{ GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, } diff --git a/x/pool-incentives/types/record_test.go b/x/pool-incentives/types/record_test.go index c35ee4c45ba..e6eacbcb554 100644 --- a/x/pool-incentives/types/record_test.go +++ b/x/pool-incentives/types/record_test.go @@ -5,8 +5,7 @@ import ( "github.com/stretchr/testify/require" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/pool-incentives/types" ) @@ -14,21 +13,21 @@ import ( func TestDistrRecord(t *testing.T) { zeroWeight := types.DistrRecord{ GaugeId: 1, - Weight: sdk.NewInt(0), + Weight: osmomath.NewInt(0), } require.NoError(t, zeroWeight.ValidateBasic()) negativeWeight := types.DistrRecord{ GaugeId: 1, - Weight: sdk.NewInt(-1), + Weight: osmomath.NewInt(-1), } require.Error(t, negativeWeight.ValidateBasic()) positiveWeight := types.DistrRecord{ GaugeId: 1, - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), } require.NoError(t, positiveWeight.ValidateBasic()) diff --git a/x/poolmanager/README.md b/x/poolmanager/README.md index 656087e5a3c..cb9007dd1a4 100644 --- a/x/poolmanager/README.md +++ b/x/poolmanager/README.md @@ -208,7 +208,7 @@ func (k Keeper) RouteExactAmountIn( sender sdk.AccAddress, routes []types.SwapAmountInRoute, tokenIn sdk.Coin, - tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int) (tokenOutAmount osmomath.Int, err error) { } ``` @@ -246,9 +246,9 @@ type SwapI interface { poolId gammtypes.PoolI, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - spreadFactor sdk.Dec, - ) (sdk.Int, error) + tokenOutMinAmount osmomath.Int, + spreadFactor osmomath.Dec, + ) (osmomath.Int, error) } ``` diff --git a/x/poolmanager/client/cli/cli_test.go b/x/poolmanager/client/cli/cli_test.go index c304c557f48..794afc25666 100644 --- a/x/poolmanager/client/cli/cli_test.go +++ b/x/poolmanager/client/cli/cli_test.go @@ -7,6 +7,7 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/app" @@ -77,7 +78,7 @@ func TestNewSwapExactAmountOutCmd(t *testing.T) { ExpectedMsg: &types.MsgSwapExactAmountOut{ Sender: testAddresses[0].String(), Routes: []types.SwapAmountOutRoute{{PoolId: 1, TokenInDenom: "node0token"}}, - TokenInMaxAmount: sdk.NewIntFromUint64(20), + TokenInMaxAmount: osmomath.NewIntFromUint64(20), TokenOut: sdk.NewInt64Coin("stake", 10), }, }, @@ -176,7 +177,7 @@ func TestNewSwapExactAmountInCmd(t *testing.T) { Sender: testAddresses[0].String(), Routes: []types.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "node0token"}}, TokenIn: sdk.NewInt64Coin("stake", 10), - TokenOutMinAmount: sdk.NewIntFromUint64(3), + TokenOutMinAmount: osmomath.NewIntFromUint64(3), }, }, } diff --git a/x/poolmanager/client/cli/tx.go b/x/poolmanager/client/cli/tx.go index 98174561a08..c55583e2012 100644 --- a/x/poolmanager/client/cli/tx.go +++ b/x/poolmanager/client/cli/tx.go @@ -21,6 +21,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" @@ -179,7 +180,7 @@ func NewMsgNewSplitRouteSwapExactAmountOut(fs *flag.FlagSet) ([]types.SwapAmount var splitRouteProto []types.SwapAmountOutSplitRoute for _, route := range splitRouteJSONdata.Route { protoRoute := types.SwapAmountOutSplitRoute{ - TokenOutAmount: sdk.NewInt(route.TokenOutAmount), + TokenOutAmount: osmomath.NewInt(route.TokenOutAmount), } protoRoute.Pools = append(protoRoute.Pools, route.Pools...) splitRouteProto = append(splitRouteProto, protoRoute) @@ -208,7 +209,7 @@ func NewMsgNewSplitRouteSwapExactAmountIn(fs *flag.FlagSet) ([]types.SwapAmountI var splitRouteProto []types.SwapAmountInSplitRoute for _, route := range splitRouteJSONdata.Route { protoRoute := types.SwapAmountInSplitRoute{ - TokenInAmount: sdk.NewInt(route.TokenInAmount), + TokenInAmount: osmomath.NewInt(route.TokenInAmount), } protoRoute.Pools = append(protoRoute.Pools, route.Pools...) splitRouteProto = append(splitRouteProto, protoRoute) @@ -229,7 +230,7 @@ func NewBuildSwapExactAmountOutMsg(clientCtx client.Context, args []string, fs * return nil, err } - tokenInMaxAmount, ok := sdk.NewIntFromString(tokenInMaxAmountStr) + tokenInMaxAmount, ok := osmomath.NewIntFromString(tokenInMaxAmountStr) if !ok { return nil, errors.New("invalid token in max amount") } @@ -301,12 +302,12 @@ func NewBuildCreateBalancerPoolMsg(clientCtx client.Context, txf tx.Factory, fs return txf, nil, errors.New("deposit tokens and token weights should have same length") } - spreadFactor, err := sdk.NewDecFromStr(pool.SwapFee) + spreadFactor, err := osmomath.NewDecFromStr(pool.SwapFee) if err != nil { return txf, nil, err } - exitFee, err := sdk.NewDecFromStr(pool.ExitFee) + exitFee, err := osmomath.NewDecFromStr(pool.ExitFee) if err != nil { return txf, nil, err } @@ -392,12 +393,12 @@ func NewBuildCreateStableswapPoolMsg(clientCtx client.Context, txf tx.Factory, f return txf, nil, err } - spreadFactor, err := sdk.NewDecFromStr(flags.SwapFee) + spreadFactor, err := osmomath.NewDecFromStr(flags.SwapFee) if err != nil { return txf, nil, err } - exitFee, err := sdk.NewDecFromStr(flags.ExitFee) + exitFee, err := osmomath.NewDecFromStr(flags.ExitFee) if err != nil { return txf, nil, err } @@ -603,7 +604,7 @@ func ParseDenomPairTakerFee(arg string) ([]types.DenomPairTakerFee, error) { denom1 := denomPairTakerFeeRecords[i+1] takerFeeStr := denomPairTakerFeeRecords[i+2] - takerFee, err := sdk.NewDecFromStr(takerFeeStr) + takerFee, err := osmomath.NewDecFromStr(takerFeeStr) if err != nil { return nil, err } diff --git a/x/poolmanager/client/cli/tx_test.go b/x/poolmanager/client/cli/tx_test.go index 493cb28dbef..fa4db648324 100644 --- a/x/poolmanager/client/cli/tx_test.go +++ b/x/poolmanager/client/cli/tx_test.go @@ -1,14 +1,13 @@ package cli_test import ( - "fmt" "testing" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/cli" - "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) func TestParseCoinsNoSort(t *testing.T) { @@ -20,7 +19,7 @@ func TestParseCoinsNoSort(t *testing.T) { ) var ( - ten = sdk.NewInt(10) + ten = osmomath.NewInt(10) coinA = sdk.NewCoin(a, ten) coinB = sdk.NewCoin(b, ten) @@ -53,10 +52,10 @@ func TestParseCoinsNoSort(t *testing.T) { "mixed with different values.": { coinsStr: "100ddd,20bbb,300aaa,40ccc", expectedCoins: sdk.Coins{ - sdk.NewCoin(d, sdk.NewInt(100)), - sdk.NewCoin(b, sdk.NewInt(20)), - sdk.NewCoin(a, sdk.NewInt(300)), - sdk.NewCoin(c, sdk.NewInt(40)), + sdk.NewCoin(d, osmomath.NewInt(100)), + sdk.NewCoin(b, osmomath.NewInt(20)), + sdk.NewCoin(a, osmomath.NewInt(300)), + sdk.NewCoin(c, osmomath.NewInt(40)), }, }, } @@ -70,52 +69,3 @@ 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) - }) - } -} diff --git a/x/poolmanager/client/queryproto/query.pb.go b/x/poolmanager/client/queryproto/query.pb.go index b887e949959..4d1b7a0b78c 100644 --- a/x/poolmanager/client/queryproto/query.pb.go +++ b/x/poolmanager/client/queryproto/query.pb.go @@ -5,6 +5,7 @@ package queryproto import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" types1 "github.com/cosmos/cosmos-sdk/codec/types" @@ -315,7 +316,7 @@ func (m *EstimateSinglePoolSwapExactAmountInRequest) GetTokenOutDenom() string { } type EstimateSwapExactAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *EstimateSwapExactAmountInResponse) Reset() { *m = EstimateSwapExactAmountInResponse{} } @@ -549,7 +550,7 @@ func (m *EstimateSinglePoolSwapExactAmountOutRequest) GetTokenOut() string { } type EstimateSwapExactAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *EstimateSwapExactAmountOutResponse) Reset() { *m = EstimateSwapExactAmountOutResponse{} } @@ -1145,106 +1146,106 @@ func init() { } var fileDescriptor_6256a4106f701b7d = []byte{ - // 1569 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0x4f, 0x6f, 0x1b, 0xc5, - 0x1b, 0xce, 0xda, 0x6e, 0x1a, 0x4f, 0x9b, 0xc4, 0x99, 0x36, 0x69, 0xe2, 0xf6, 0xe7, 0x75, 0xa7, - 0xfd, 0x15, 0xb7, 0x49, 0x76, 0x95, 0xa4, 0x80, 0xa8, 0x04, 0x55, 0x9c, 0x86, 0xc6, 0xa8, 0xd0, - 0xb0, 0x29, 0x14, 0x0a, 0xc5, 0xda, 0x24, 0x8b, 0xbb, 0xaa, 0xbd, 0xb3, 0xf1, 0xce, 0xb6, 0x8d, - 0x50, 0x2f, 0x9c, 0x38, 0xa1, 0x22, 0x24, 0x8a, 0xc4, 0x01, 0x71, 0xe0, 0x52, 0xae, 0xf0, 0x1d, - 0x2a, 0x24, 0x50, 0x10, 0x17, 0xc4, 0xc1, 0xa0, 0x96, 0x03, 0x87, 0x5e, 0xf0, 0x27, 0x40, 0xf3, - 0x67, 0xd7, 0xf6, 0xc6, 0x5e, 0xaf, 0x9d, 0x1c, 0x38, 0x65, 0x3d, 0xf3, 0xce, 0xfb, 0xbe, 0xcf, - 0xb3, 0xef, 0xb3, 0xfb, 0x6c, 0xc0, 0x73, 0xd8, 0xa9, 0x60, 0xc7, 0x74, 0x54, 0x1b, 0xe3, 0x72, - 0x45, 0xb7, 0xf4, 0x92, 0x51, 0x55, 0xef, 0xcc, 0xad, 0x1b, 0x44, 0x9f, 0x53, 0xb7, 0x5c, 0xa3, - 0xba, 0xad, 0xd8, 0x55, 0x4c, 0x30, 0x3c, 0x2e, 0x02, 0x95, 0xa6, 0x40, 0x45, 0x04, 0xa6, 0x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 0x90, 0xc5, 0x0a, 0x76, 0x2d, 0x52, 0xb0, 0x44, 0x65, - 0x38, 0x0d, 0x0e, 0xd2, 0x84, 0x45, 0x73, 0x73, 0x32, 0x96, 0x95, 0x72, 0x89, 0x3c, 0xac, 0xd7, - 0xe4, 0x91, 0x6d, 0xbd, 0x52, 0xbe, 0x80, 0xc4, 0x06, 0xd2, 0x06, 0xe9, 0x55, 0x61, 0x13, 0x2a, - 0x60, 0x88, 0xe0, 0xdb, 0x86, 0x55, 0x34, 0xad, 0xc9, 0x78, 0x56, 0xca, 0x25, 0xf3, 0x47, 0xea, - 0x35, 0x79, 0x94, 0x47, 0x7b, 0x3b, 0x48, 0x3b, 0xc8, 0x2e, 0x0b, 0x16, 0xbc, 0x09, 0x06, 0xd9, - 0x7d, 0x73, 0x26, 0x13, 0xd9, 0x78, 0xee, 0xd0, 0xbc, 0x12, 0x0a, 0x82, 0xf6, 0xe8, 0xb7, 0x47, - 0x8f, 0xe5, 0xc7, 0x29, 0x9e, 0x7a, 0x4d, 0x1e, 0xe6, 0x15, 0x78, 0x2e, 0xa4, 0x89, 0xa4, 0xaf, - 0x25, 0x86, 0xa4, 0x54, 0x4c, 0x1b, 0x74, 0x0c, 0x6b, 0xd3, 0xa8, 0xa2, 0x47, 0x31, 0x30, 0xdf, - 0x11, 0xee, 0x75, 0x93, 0xdc, 0x5a, 0xad, 0x9a, 0x15, 0x93, 0x98, 0x77, 0x8c, 0x6b, 0xdb, 0xb6, - 0xe1, 0xb4, 0x21, 0x40, 0xea, 0x89, 0x80, 0x58, 0x04, 0x02, 0x2e, 0x82, 0x11, 0xde, 0x6b, 0xd1, - 0xab, 0x11, 0xcf, 0xc6, 0x73, 0x89, 0xfc, 0x54, 0xbd, 0x26, 0x8f, 0x37, 0x83, 0x2a, 0xfa, 0xa5, - 0x0e, 0xf3, 0x85, 0x55, 0x5e, 0xf0, 0x6d, 0x30, 0x21, 0x02, 0x78, 0x76, 0xec, 0x92, 0xe2, 0xa6, - 0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 0xae, 0x38, 0xfd, 0x62, 0xcf, 0xe7, 0x44, 0xf3, 0x05, 0xd6, 0xfc, 0x12, 0x5c, 0xec, 0xe5, - 0xce, 0xab, 0x84, 0x26, 0xe4, 0x42, 0xf2, 0xbd, 0x21, 0xfc, 0x41, 0x02, 0x23, 0xad, 0xae, 0x15, - 0xce, 0x77, 0x6f, 0x6b, 0x17, 0x94, 0x85, 0x9e, 0xce, 0x08, 0x18, 0x17, 0x18, 0x8c, 0xf3, 0x70, - 0x3e, 0x02, 0x0c, 0xde, 0xbc, 0xdf, 0x77, 0xfe, 0xe6, 0xe3, 0x27, 0x19, 0x69, 0xe7, 0x49, 0x46, - 0xfa, 0xf3, 0x49, 0x46, 0x7a, 0xf0, 0x34, 0x33, 0xb0, 0xf3, 0x34, 0x33, 0xf0, 0xdb, 0xd3, 0xcc, - 0xc0, 0x8d, 0xa5, 0x26, 0x8b, 0x2c, 0xf2, 0xce, 0x96, 0xf5, 0x75, 0xc7, 0x2f, 0x72, 0x67, 0xee, - 0x25, 0xf5, 0x5e, 0x4b, 0xa9, 0x8d, 0xb2, 0x69, 0x58, 0x84, 0xff, 0x9b, 0x9c, 0x7f, 0x04, 0x0e, - 0xb2, 0x3f, 0x0b, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xe0, 0x6d, 0x19, 0xe3, 0x42, 0x18, 0x00, - 0x00, + // 1577 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x58, 0xcf, 0x6f, 0xdb, 0x64, + 0x18, 0xae, 0x93, 0xac, 0x6b, 0xbe, 0xad, 0x6d, 0xfa, 0x6d, 0xe9, 0xda, 0x6c, 0xc4, 0xd9, 0xb7, + 0x01, 0xd9, 0xda, 0xda, 0x6a, 0x3b, 0x18, 0x4c, 0x82, 0xa9, 0xe9, 0xca, 0x16, 0x34, 0x58, 0x71, + 0x07, 0x83, 0xc1, 0x88, 0x9c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, 0xe9, + 0x7d, 0xb3, 0xa7, 0x62, 0x99, 0x68, 0xf6, 0xd0, 0x82, 0x14, 0x48, 0x82, 0x60, 0xf4, 0xe0, 0x91, + 0x63, 0xb9, 0x24, 0xe1, 0xd3, 0xa8, 0x8b, 0xa3, 0xac, 0x02, 0xcb, 0x85, 0x14, 0x9e, 0xf4, 0xf5, + 0xd8, 0x88, 0x90, 0x88, 0x28, 0xc3, 0xb6, 0x66, 0x96, 0xb4, 0x1a, 0x7a, 0x14, 0x01, 0x0b, 0x5d, + 0xe9, 0xde, 0xd0, 0xf1, 0xc6, 0x6a, 0x4d, 0x37, 0x74, 0xac, 0xdf, 0xd1, 0xae, 0x6f, 0x55, 0x35, + 0xbb, 0x83, 0x00, 0x42, 0x5f, 0x02, 0x44, 0x42, 0x08, 0x70, 0x11, 0x8c, 0x31, 0xac, 0x05, 0xb7, + 0x46, 0x34, 0x13, 0xcd, 0xc6, 0x72, 0xd3, 0x8d, 0xba, 0x98, 0x6c, 0x25, 0x55, 0xf0, 0x4a, 0x1d, + 0x66, 0x0b, 0xab, 0xac, 0xe0, 0x3b, 0x60, 0x92, 0x07, 0xb0, 0xec, 0x96, 0x83, 0x0b, 0x25, 0xcd, + 0xb4, 0x0c, 0xaa, 0x68, 0x3c, 0x77, 0xb2, 0x51, 0x17, 0x9f, 0x69, 0x4b, 0xe4, 0x8b, 0x43, 0xca, + 0x11, 0xb6, 0x71, 0x9d, 0xac, 0x5f, 0x73, 0xf0, 0x25, 0xba, 0xfa, 0xb3, 0x00, 0xce, 0x7a, 0x62, + 0xe9, 0x66, 0xb9, 0xa2, 0x91, 0x82, 0x61, 0xba, 0x64, 0xff, 0x45, 0xca, 0x81, 0x71, 0x3f, 0x39, + 0xd6, 0x5c, 0xa9, 0x46, 0x5d, 0x9c, 0x6c, 0x3d, 0xd6, 0xc2, 0x6a, 0x14, 0xb7, 0xf1, 0xf9, 0x4c, + 0x00, 0x27, 0x03, 0x7a, 0x9d, 0x0f, 0x55, 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f, 0x70, + 0x77, 0xf6, 0x46, 0x39, 0x72, 0x3e, 0x7a, 0x13, 0x60, 0xfc, 0x4d, 0xc7, 0x20, 0x62, 0x7a, 0x2f, + 0xd6, 0x15, 0x90, 0x68, 0x2e, 0x71, 0x1c, 0xf3, 0x20, 0x6e, 0x3a, 0x06, 0xed, 0x12, 0x9b, 0x2b, + 0xda, 0xc2, 0xd0, 0xdb, 0x42, 0xca, 0x88, 0xc9, 0x8f, 0xa2, 0x0b, 0xe0, 0x10, 0xb9, 0x18, 0xe4, + 0x8e, 0xa0, 0x65, 0x70, 0x98, 0x9d, 0xe5, 0xe5, 0x17, 0x41, 0x8c, 0xec, 0xf0, 0xf7, 0xfa, 0x51, + 0x89, 0x99, 0x05, 0xc9, 0x35, 0x0b, 0xd2, 0x92, 0xb9, 0x95, 0x8b, 0xff, 0xf4, 0xc3, 0xdc, 0x01, + 0xda, 0xb6, 0x0a, 0x0d, 0x26, 0xd4, 0x96, 0x2a, 0x95, 0x36, 0x6a, 0x79, 0x90, 0x68, 0x2e, 0xf1, + 0xdc, 0x2f, 0x80, 0x03, 0x2e, 0xad, 0x68, 0x98, 0xe4, 0x2c, 0x1a, 0x6d, 0x0b, 0x20, 0xb1, 0x56, + 0xb5, 0xf0, 0x6a, 0x4d, 0x5f, 0xd7, 0x06, 0x6a, 0xbb, 0x15, 0x90, 0x20, 0x6e, 0xab, 0xa0, 0xda, + 0xb6, 0x86, 0xdb, 0x1a, 0xef, 0x78, 0xf3, 0xe1, 0xe9, 0x8f, 0x40, 0xca, 0x18, 0x59, 0x5a, 0x22, + 0x2b, 0xac, 0xf9, 0xae, 0x80, 0x89, 0x4d, 0xc7, 0xc2, 0xed, 0x79, 0x58, 0x13, 0x9e, 0x68, 0xd4, + 0xc5, 0x29, 0x96, 0x67, 0x57, 0x08, 0x52, 0xc6, 0xe9, 0x5a, 0x33, 0x13, 0xca, 0x83, 0x89, 0x16, + 0x46, 0x5c, 0x9e, 0x73, 0x00, 0xd8, 0x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, 0xe1, 0xc1, 0x4e, 0x7a, + 0x68, 0x7b, 0x27, 0x3d, 0xf4, 0xfb, 0x4e, 0x7a, 0xe8, 0xe6, 0x72, 0x8b, 0x45, 0xe6, 0x79, 0xe7, + 0x2a, 0x6a, 0xd1, 0xf6, 0x8a, 0xdc, 0x99, 0x7f, 0x59, 0xbe, 0xd7, 0x56, 0x6a, 0xbd, 0xa2, 0x6b, + 0x26, 0x66, 0xff, 0x04, 0x67, 0x1f, 0x81, 0xc3, 0xf4, 0xcf, 0xe2, 0x7f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x99, 0xd0, 0xeb, 0xa1, 0x20, 0x18, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/poolmanager/client/testutil/test_helpers.go b/x/poolmanager/client/testutil/test_helpers.go index c1a6ff71c1d..53aaaadaa0f 100644 --- a/x/poolmanager/client/testutil/test_helpers.go +++ b/x/poolmanager/client/testutil/test_helpers.go @@ -5,6 +5,7 @@ import ( "fmt" "testing" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app" poolmanagercli "github.com/osmosis-labs/osmosis/v19/x/poolmanager/client/cli" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -21,7 +22,7 @@ import ( var commonArgs = []string{ fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), - fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10))).String()), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10))).String()), } // MsgCreatePool broadcast a pool creation message. diff --git a/x/poolmanager/create_pool_test.go b/x/poolmanager/create_pool_test.go index 504fbc01a62..a7458106873 100644 --- a/x/poolmanager/create_pool_test.go +++ b/x/poolmanager/create_pool_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" clmodel "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" cwmodel "github.com/osmosis-labs/osmosis/v19/x/cosmwasmpool/model" @@ -34,24 +35,24 @@ func (s *KeeperTestSuite) TestPoolCreationFee() { name: "no pool creation fee for default asset pool", poolCreationFee: sdk.Coins{}, msg: balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, apptesting.DefaultPoolAssets, ""), expectPass: true, }, { name: "nil pool creation fee on basic pool", poolCreationFee: nil, msg: balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, apptesting.DefaultPoolAssets, ""), expectPass: true, }, { name: "attempt pool creation without sufficient funds for fees", - poolCreationFee: sdk.Coins{sdk.NewCoin("atom", sdk.NewInt(10000))}, + poolCreationFee: sdk.Coins{sdk.NewCoin("atom", osmomath.NewInt(10000))}, msg: balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, apptesting.DefaultPoolAssets, ""), expectPass: false, }, @@ -119,25 +120,25 @@ func (s *KeeperTestSuite) TestPoolCreationFee() { // TestCreatePool tests that all possible pools are created correctly. func (s *KeeperTestSuite) TestCreatePool() { var ( - validBalancerPoolMsg = balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), []balancer.PoolAsset{ + validBalancerPoolMsg = balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.NewPoolParams(osmomath.ZeroDec(), osmomath.ZeroDec(), nil), []balancer.PoolAsset{ { Token: sdk.NewCoin(foo, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, { Token: sdk.NewCoin(bar, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, "") - invalidBalancerPoolMsg = balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.NewPoolParams(sdk.ZeroDec(), sdk.NewDecWithPrec(1, 2), nil), []balancer.PoolAsset{ + invalidBalancerPoolMsg = balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.NewPoolParams(osmomath.ZeroDec(), osmomath.NewDecWithPrec(1, 2), nil), []balancer.PoolAsset{ { Token: sdk.NewCoin(foo, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, { Token: sdk.NewCoin(bar, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, "") @@ -146,16 +147,16 @@ func (s *KeeperTestSuite) TestCreatePool() { sdk.NewCoin(bar, defaultInitPoolAmount), ) - validStableswapPoolMsg = stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], stableswap.PoolParams{SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDec(0)}, DefaultStableswapLiquidity, []uint64{}, "") + validStableswapPoolMsg = stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], stableswap.PoolParams{SwapFee: osmomath.NewDec(0), ExitFee: osmomath.NewDec(0)}, DefaultStableswapLiquidity, []uint64{}, "") - invalidStableswapPoolMsg = stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], stableswap.PoolParams{SwapFee: sdk.NewDec(0), ExitFee: sdk.NewDecWithPrec(1, 2)}, DefaultStableswapLiquidity, []uint64{}, "") + invalidStableswapPoolMsg = stableswap.NewMsgCreateStableswapPool(s.TestAccs[0], stableswap.PoolParams{SwapFee: osmomath.NewDec(0), ExitFee: osmomath.NewDecWithPrec(1, 2)}, DefaultStableswapLiquidity, []uint64{}, "") validConcentratedPoolMsg = clmodel.NewMsgCreateConcentratedPool(s.TestAccs[0], foo, bar, 1, defaultPoolSpreadFactor) validTransmuterCodeId = uint64(1) validCWPoolMsg = cwmodel.NewMsgCreateCosmWasmPool(validTransmuterCodeId, s.TestAccs[0], s.GetDefaultTransmuterInstantiateMsgBytes()) - defaultFundAmount = sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount.Mul(sdk.NewInt(2))), sdk.NewCoin(bar, defaultInitPoolAmount.Mul(sdk.NewInt(2)))) + defaultFundAmount = sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount.Mul(osmomath.NewInt(2))), sdk.NewCoin(bar, defaultInitPoolAmount.Mul(osmomath.NewInt(2)))) ) tests := []struct { @@ -268,14 +269,14 @@ func (s *KeeperTestSuite) TestCreatePoolZeroLiquidityNoCreationFee() { return msg } - balancerPoolMsg := balancer.NewMsgCreateBalancerPool(poolManagerModuleAcc.GetAddress(), balancer.NewPoolParams(sdk.ZeroDec(), sdk.ZeroDec(), nil), []balancer.PoolAsset{ + balancerPoolMsg := balancer.NewMsgCreateBalancerPool(poolManagerModuleAcc.GetAddress(), balancer.NewPoolParams(osmomath.ZeroDec(), osmomath.ZeroDec(), nil), []balancer.PoolAsset{ { Token: sdk.NewCoin(foo, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, { Token: sdk.NewCoin(bar, defaultInitPoolAmount), - Weight: sdk.NewInt(1), + Weight: osmomath.NewInt(1), }, }, "") @@ -311,7 +312,7 @@ func (s *KeeperTestSuite) TestCreatePoolZeroLiquidityNoCreationFee() { // Note: this is necessary for gauge creation in the after pool created hook. // There is a check requiring positive supply existing on-chain. - s.MintCoins(sdk.NewCoins(sdk.NewCoin("uosmo", sdk.OneInt()))) + s.MintCoins(sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.OneInt()))) pool, err := poolmanagerKeeper.CreateConcentratedPoolAsPoolManager(ctx, tc.msg) diff --git a/x/poolmanager/events/emit_test.go b/x/poolmanager/events/emit_test.go index 7970ba3a8c7..906163477f6 100644 --- a/x/poolmanager/events/emit_test.go +++ b/x/poolmanager/events/emit_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/events" @@ -40,15 +41,15 @@ func (suite *PoolManagerEventsTestSuite) TestEmitSwapEvent() { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 1, - tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), - tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomB, sdk.NewInt(5678))), + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(1234))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomB, osmomath.NewInt(5678))), }, "valid with multiple tokens in and out": { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 200, - tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), - tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomC, sdk.NewInt(88)), sdk.NewCoin(testDenomD, sdk.NewInt(34))), + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(12)), sdk.NewCoin(testDenomB, osmomath.NewInt(99))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomC, osmomath.NewInt(88)), sdk.NewCoin(testDenomD, osmomath.NewInt(34))), }, } @@ -94,13 +95,13 @@ func (suite *PoolManagerEventsTestSuite) TestEmitAddLiquidityEvent() { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 1, - tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(1234))), }, "valid with multiple tokens in": { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 200, - tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), + tokensIn: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(12)), sdk.NewCoin(testDenomB, osmomath.NewInt(99))), }, } @@ -145,13 +146,13 @@ func (suite *PoolManagerEventsTestSuite) TestEmitRemoveLiquidityEvent() { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 1, - tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(1234))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(1234))), }, "valid with multiple tokens out": { ctx: suite.CreateTestContext(), testAccountAddr: sdk.AccAddress([]byte(addressString)), poolId: 200, - tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(12)), sdk.NewCoin(testDenomB, sdk.NewInt(99))), + tokensOut: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(12)), sdk.NewCoin(testDenomB, osmomath.NewInt(99))), }, } diff --git a/x/poolmanager/export_test.go b/x/poolmanager/export_test.go index 68a6502e6cb..a8520c3c584 100644 --- a/x/poolmanager/export_test.go +++ b/x/poolmanager/export_test.go @@ -3,6 +3,7 @@ package poolmanager import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -13,7 +14,7 @@ func (k Keeper) GetNextPoolIdAndIncrement(ctx sdk.Context) uint64 { } func (k Keeper) GetOsmoRoutedMultihopTotalSpreadFactor(ctx sdk.Context, route types.MultihopRoute) ( - totalPathSpreadFactor sdk.Dec, sumOfSpreadFactors sdk.Dec, err error, + totalPathSpreadFactor osmomath.Dec, sumOfSpreadFactors osmomath.Dec, err error, ) { return k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, route) } @@ -50,7 +51,7 @@ func (k Keeper) CreateMultihopExpectedSwapOuts( ctx sdk.Context, route []types.SwapAmountOutRoute, tokenOut sdk.Coin, -) ([]sdk.Int, error) { +) ([]osmomath.Int, error) { return k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } @@ -58,15 +59,15 @@ func (k Keeper) CreateOsmoMultihopExpectedSwapOuts( ctx sdk.Context, route []types.SwapAmountOutRoute, tokenOut sdk.Coin, - cumulativeRouteSwapFee, sumOfSwapFees sdk.Dec, -) ([]sdk.Int, error) { + cumulativeRouteSwapFee, sumOfSwapFees osmomath.Dec, +) ([]osmomath.Int, error) { return k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, cumulativeRouteSwapFee, sumOfSwapFees) } -func (k Keeper) CalcTakerFeeExactIn(tokenIn sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { +func (k Keeper) CalcTakerFeeExactIn(tokenIn sdk.Coin, takerFee osmomath.Dec) (sdk.Coin, sdk.Coin) { return k.calcTakerFeeExactIn(tokenIn, takerFee) } -func (k Keeper) CalcTakerFeeExactOut(tokenOut sdk.Coin, takerFee sdk.Dec) (sdk.Coin, sdk.Coin) { +func (k Keeper) CalcTakerFeeExactOut(tokenOut sdk.Coin, takerFee osmomath.Dec) (sdk.Coin, sdk.Coin) { return k.calcTakerFeeExactOut(tokenOut, takerFee) } diff --git a/x/poolmanager/keeper_test.go b/x/poolmanager/keeper_test.go index 5368c8f0d60..5a36a562f5e 100644 --- a/x/poolmanager/keeper_test.go +++ b/x/poolmanager/keeper_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -19,14 +20,14 @@ const testExpectedPoolId = 3 var ( testPoolCreationFee = sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 1000_000_000)} - testDefaultTakerFee = sdk.MustNewDecFromStr("0.0015") + testDefaultTakerFee = osmomath.MustNewDecFromStr("0.0015") testOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("0.3"), - CommunityPool: sdk.MustNewDecFromStr("0.7"), + StakingRewards: osmomath.MustNewDecFromStr("0.3"), + CommunityPool: osmomath.MustNewDecFromStr("0.7"), } testNonOsmoTakerFeeDistribution = types.TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("0.2"), - CommunityPool: sdk.MustNewDecFromStr("0.8"), + StakingRewards: osmomath.MustNewDecFromStr("0.2"), + CommunityPool: osmomath.MustNewDecFromStr("0.8"), } testAdminAddresses = []string{"osmo106x8q2nv7xsg7qrec2zgdf3vvq0t3gn49zvaha", "osmo105l5r3rjtynn7lg362r2m9hkpfvmgmjtkglsn9"} testCommunityPoolDenomToSwapNonWhitelistedAssetsTo = "uusdc" @@ -64,12 +65,12 @@ func (s *KeeperTestSuite) SetupTest() { // createBalancerPoolsFromCoinsWithSpreadFactor creates balancer pools from given sets of coins and respective spread factors. // Where element 1 of the input corresponds to the first pool created, // element 2 to the second pool created, up until the last element. -func (s *KeeperTestSuite) createBalancerPoolsFromCoinsWithSpreadFactor(poolCoins []sdk.Coins, spreadFactor []sdk.Dec) { +func (s *KeeperTestSuite) createBalancerPoolsFromCoinsWithSpreadFactor(poolCoins []sdk.Coins, spreadFactor []osmomath.Dec) { for i, curPoolCoins := range poolCoins { s.FundAcc(s.TestAccs[0], curPoolCoins) s.PrepareCustomBalancerPoolFromCoins(curPoolCoins, balancer.PoolParams{ SwapFee: spreadFactor[i], - ExitFee: sdk.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) } } @@ -81,8 +82,8 @@ func (s *KeeperTestSuite) createBalancerPoolsFromCoins(poolCoins []sdk.Coins) { for _, curPoolCoins := range poolCoins { s.FundAcc(s.TestAccs[0], curPoolCoins) s.PrepareCustomBalancerPoolFromCoins(curPoolCoins, balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) } } diff --git a/x/poolmanager/msg_server_test.go b/x/poolmanager/msg_server_test.go index 334b8865df8..4d765bde928 100644 --- a/x/poolmanager/msg_server_test.go +++ b/x/poolmanager/msg_server_test.go @@ -3,14 +3,15 @@ package poolmanager_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagerKeeper "github.com/osmosis-labs/osmosis/v19/x/poolmanager" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) var ( - amount = sdk.NewInt(100) - min_amount = sdk.ZeroInt() - max_amount = sdk.NewInt(10000000) + amount = osmomath.NewInt(100) + min_amount = osmomath.ZeroInt() + max_amount = osmomath.NewInt(10000000) pool1_in = types.SwapAmountInRoute{PoolId: 1, TokenOutDenom: "bar"} pool2_in = types.SwapAmountInRoute{PoolId: 2, TokenOutDenom: "baz"} @@ -27,7 +28,7 @@ func (s *KeeperTestSuite) TestSplitRouteSwapExactAmountIn() { testcases := map[string]struct { routes []types.SwapAmountInSplitRoute tokenInDenom string - tokenoutMinAmount sdk.Int + tokenoutMinAmount osmomath.Int expectedSplitRouteSwapEvent int expectedMessageEvents int @@ -113,7 +114,7 @@ func (s *KeeperTestSuite) TestSplitRouteSwapExactAmountOut() { testcases := map[string]struct { routes []types.SwapAmountOutSplitRoute tokenOutDenom string - tokenoutMaxAmount sdk.Int + tokenoutMaxAmount osmomath.Int expectedSplitRouteSwapEvent int expectedMessageEvents int @@ -214,12 +215,12 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { { Denom0: "denom0", Denom1: "denom1", - TakerFee: sdk.MustNewDecFromStr("0.0013"), + TakerFee: osmomath.MustNewDecFromStr("0.0013"), }, { Denom0: "denom0", Denom1: "denom2", - TakerFee: sdk.MustNewDecFromStr("0.0016"), + TakerFee: osmomath.MustNewDecFromStr("0.0016"), }, }, }, @@ -233,7 +234,7 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { { Denom0: "denom0", Denom1: "denom1", - TakerFee: sdk.MustNewDecFromStr("0.0013"), + TakerFee: osmomath.MustNewDecFromStr("0.0013"), }, }, }, @@ -247,7 +248,7 @@ func (s *KeeperTestSuite) TestSetDenomPairTakerFee() { { Denom0: "denom0", Denom1: "denom1", - TakerFee: sdk.MustNewDecFromStr("0.0013"), + TakerFee: osmomath.MustNewDecFromStr("0.0013"), }, }, }, diff --git a/x/poolmanager/router.go b/x/poolmanager/router.go index a1495e854d2..ce4dc461ad1 100644 --- a/x/poolmanager/router.go +++ b/x/poolmanager/router.go @@ -9,12 +9,13 @@ import ( appparams "github.com/osmosis-labs/osmosis/v19/app/params" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) -// 1 << 256 - 1 where 256 is the max bit length defined for sdk.Int -var intMaxValue = sdk.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))) +// 1 << 256 - 1 where 256 is the max bit length defined for osmomath.Int +var intMaxValue = osmomath.NewIntFromBigInt(new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1))) // RouteExactAmountIn processes a swap along the given route using the swap function // corresponding to poolID's pool type. It takes in the input denom and amount for @@ -27,18 +28,18 @@ func (k Keeper) RouteExactAmountIn( sender sdk.AccAddress, route []types.SwapAmountInRoute, tokenIn sdk.Coin, - tokenOutMinAmount sdk.Int, -) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int, +) (tokenOutAmount osmomath.Int, err error) { var ( isMultiHopRouted bool - routeSpreadFactor sdk.Dec - sumOfSpreadFactors sdk.Dec + routeSpreadFactor osmomath.Dec + sumOfSpreadFactors osmomath.Dec ) // Ensure that provided route is not empty and has valid denom format. routeStep := types.SwapAmountInRoutes(route) if err := routeStep.Validate(); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // In this loop (isOsmoRoutedMultihop), we check if: @@ -55,7 +56,7 @@ func (k Keeper) RouteExactAmountIn( isMultiHopRouted = true routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } @@ -63,7 +64,7 @@ func (k Keeper) RouteExactAmountIn( for i, routeStep := range route { // To prevent the multihop swap from being interrupted prematurely, we keep // the minimum expected output at a very low number until the last pool - _outMinAmount := sdk.NewInt(1) + _outMinAmount := osmomath.NewInt(1) if len(route)-1 == i { _outMinAmount = tokenOutMinAmount } @@ -71,18 +72,18 @@ func (k Keeper) RouteExactAmountIn( // Get underlying pool type corresponding to the pool ID at the current routeStep. swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Execute the expected swap on the current routed pool pool, poolErr := swapModule.GetPool(ctx, routeStep.PoolId) if poolErr != nil { - return sdk.Int{}, poolErr + return osmomath.Int{}, poolErr } // Check if pool has swaps enabled. if !pool.IsActive(ctx) { - return sdk.Int{}, types.InactivePoolError{PoolId: pool.GetId()} + return osmomath.Int{}, types.InactivePoolError{PoolId: pool.GetId()} } spreadFactor := pool.GetSpreadFactor(ctx) @@ -95,12 +96,12 @@ func (k Keeper) RouteExactAmountIn( tokenInAfterSubTakerFee, err := k.chargeTakerFee(ctx, tokenIn, routeStep.TokenOutDenom, sender, true) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, routeStep.TokenOutDenom, _outMinAmount, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Chain output of current pool as the input for the next routed pool @@ -129,18 +130,18 @@ func (k Keeper) SplitRouteExactAmountIn( sender sdk.AccAddress, routes []types.SwapAmountInSplitRoute, tokenInDenom string, - tokenOutMinAmount sdk.Int, -) (sdk.Int, error) { + tokenOutMinAmount osmomath.Int, +) (osmomath.Int, error) { if err := types.ValidateSwapAmountInSplitRoute(routes); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } var ( // We start the multihop min amount as zero because we want // to perform a price impact protection check on the combination of tokens out // from all multihop paths. - multihopStartTokenOutMinAmount = sdk.ZeroInt() - totalOutAmount = sdk.ZeroInt() + multihopStartTokenOutMinAmount = osmomath.ZeroInt() + totalOutAmount = osmomath.ZeroInt() ) for _, multihopRoute := range routes { @@ -151,18 +152,18 @@ func (k Keeper) SplitRouteExactAmountIn( sdk.NewCoin(tokenInDenom, multihopRoute.TokenInAmount), multihopStartTokenOutMinAmount) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalOutAmount = totalOutAmount.Add(tokenOutAmount) } if !totalOutAmount.IsPositive() { - return sdk.Int{}, types.FinalAmountIsNotPositiveError{IsAmountOut: true, Amount: totalOutAmount} + return osmomath.Int{}, types.FinalAmountIsNotPositiveError{IsAmountOut: true, Amount: totalOutAmount} } if totalOutAmount.LT(tokenOutMinAmount) { - return sdk.Int{}, types.PriceImpactProtectionExactInError{Actual: totalOutAmount, MinAmount: tokenOutMinAmount} + return osmomath.Int{}, types.PriceImpactProtectionExactInError{Actual: totalOutAmount, MinAmount: tokenOutMinAmount} } ctx.EventManager().EmitEvents(sdk.Events{ @@ -188,36 +189,36 @@ func (k Keeper) SwapExactAmountIn( poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, -) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int, +) (tokenOutAmount osmomath.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 + return osmomath.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 + return osmomath.Int{}, poolErr } // Check if pool has swaps enabled. if !pool.IsActive(ctx) { - return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) + return osmomath.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } tokenInAfterSubTakerFee, err := k.chargeTakerFee(ctx, tokenIn, tokenOutDenom, sender, true) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // routeStep to the pool-specific SwapExactAmountIn implementation. tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenInAfterSubTakerFee, tokenOutDenom, tokenOutMinAmount, pool.GetSpreadFactor(ctx)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return tokenOutAmount, nil @@ -234,31 +235,31 @@ func (k Keeper) SwapExactAmountInNoTakerFee( poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, -) (tokenOutAmount sdk.Int, err error) { + tokenOutMinAmount osmomath.Int, +) (tokenOutAmount osmomath.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 + return osmomath.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 + return osmomath.Int{}, poolErr } // Check if pool has swaps enabled. if !pool.IsActive(ctx) { - return sdk.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) + return osmomath.Int{}, fmt.Errorf("pool %d is not active", pool.GetId()) } // routeStep to the pool-specific SwapExactAmountIn implementation. tokenOutAmount, err = swapModule.SwapExactAmountIn(ctx, sender, pool, tokenIn, tokenOutDenom, tokenOutMinAmount, pool.GetSpreadFactor(ctx)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return tokenOutAmount, nil @@ -268,44 +269,44 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( ctx sdk.Context, route []types.SwapAmountInRoute, tokenIn sdk.Coin, -) (tokenOutAmount sdk.Int, err error) { +) (tokenOutAmount osmomath.Int, err error) { var ( isMultiHopRouted bool - routeSpreadFactor sdk.Dec - sumOfSpreadFactors sdk.Dec + routeSpreadFactor osmomath.Dec + sumOfSpreadFactors osmomath.Dec ) // recover from panic defer func() { if r := recover(); r != nil { - tokenOutAmount = sdk.Int{} + tokenOutAmount = osmomath.Int{} err = fmt.Errorf("function MultihopEstimateOutGivenExactAmountIn failed due to internal reason: %v", r) } }() routeStep := types.SwapAmountInRoutes(route) if err := routeStep.Validate(); err != nil { - return sdk.Int{}, err + return osmomath.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 + return osmomath.Int{}, err } } for _, routeStep := range route { swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Execute the expected swap on the current routed pool poolI, poolErr := swapModule.GetPool(ctx, routeStep.PoolId) if poolErr != nil { - return sdk.Int{}, poolErr + return osmomath.Int{}, poolErr } spreadFactor := poolI.GetSpreadFactor(ctx) @@ -318,19 +319,19 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( takerFee, err := k.GetTradingPairTakerFee(ctx, routeStep.TokenOutDenom, tokenIn.Denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenInAfterSubTakerFee, _ := k.calcTakerFeeExactIn(tokenIn, takerFee) tokenOut, err := swapModule.CalcOutAmtGivenIn(ctx, poolI, tokenInAfterSubTakerFee, routeStep.TokenOutDenom, spreadFactor) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } tokenOutAmount = tokenOut.Amount if !tokenOutAmount.IsPositive() { - return sdk.Int{}, errors.New("token amount must be positive") + return osmomath.Int{}, errors.New("token amount must be positive") } // Chain output of current pool as the input for the next routed pool @@ -348,19 +349,19 @@ func (k Keeper) MultihopEstimateOutGivenExactAmountIn( func (k Keeper) RouteExactAmountOut(ctx sdk.Context, sender sdk.AccAddress, route []types.SwapAmountOutRoute, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, -) (tokenInAmount sdk.Int, err error) { - isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} +) (tokenInAmount osmomath.Int, err error) { + isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, osmomath.Dec{}, osmomath.Dec{} // 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 + return osmomath.Int{}, err } defer func() { if r := recover(); r != nil { - tokenInAmount = sdk.Int{} + tokenInAmount = osmomath.Int{} err = fmt.Errorf("function RouteExactAmountOut failed due to internal reason: %v", r) } }() @@ -374,7 +375,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // 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 + var insExpected []osmomath.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 @@ -383,7 +384,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, if isMultiHopRouted { routeSpreadFactor, sumOfSpreadFactors, err = k.getOsmoRoutedMultihopTotalSpreadFactor(ctx, routeStep) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } insExpected, err = k.createOsmoMultihopExpectedSwapOuts(ctx, route, tokenOut, routeSpreadFactor, sumOfSpreadFactors) } else { @@ -391,10 +392,10 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, } if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } if len(insExpected) == 0 { - return sdk.Int{}, nil + return osmomath.Int{}, nil } insExpected[0] = tokenInMaxAmount @@ -405,7 +406,7 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // Get underlying pool type corresponding to the pool ID at the current routeStep. swapModule, err := k.GetPoolModule(ctx, routeStep.PoolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } _tokenOut := tokenOut @@ -419,12 +420,12 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, // Execute the expected swap on the current routed pool pool, poolErr := swapModule.GetPool(ctx, routeStep.PoolId) if poolErr != nil { - return sdk.Int{}, poolErr + return osmomath.Int{}, poolErr } // check if pool is active, if not error if !pool.IsActive(ctx) { - return sdk.Int{}, types.InactivePoolError{PoolId: pool.GetId()} + return osmomath.Int{}, types.InactivePoolError{PoolId: pool.GetId()} } spreadFactor := pool.GetSpreadFactor(ctx) @@ -436,13 +437,13 @@ func (k Keeper) RouteExactAmountOut(ctx sdk.Context, _tokenInAmount, swapErr := swapModule.SwapExactAmountOut(ctx, sender, pool, routeStep.TokenInDenom, insExpected[i], _tokenOut, spreadFactor) if swapErr != nil { - return sdk.Int{}, swapErr + return osmomath.Int{}, swapErr } tokenIn := sdk.NewCoin(routeStep.TokenInDenom, _tokenInAmount) tokenInAfterAddTakerFee, err := k.chargeTakerFee(ctx, tokenIn, _tokenOut.Denom, sender, false) if err != nil { - return sdk.Int{}, err + return osmomath.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 @@ -476,19 +477,19 @@ func (k Keeper) SplitRouteExactAmountOut( sender sdk.AccAddress, route []types.SwapAmountOutSplitRoute, tokenOutDenom string, - tokenInMaxAmount sdk.Int, -) (sdk.Int, error) { + tokenInMaxAmount osmomath.Int, +) (osmomath.Int, error) { if err := types.ValidateSwapAmountOutSplitRoute(route); err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } var ( // We start the multihop min amount as int max value - // that is defined as one under the max bit length of sdk.Int + // that is defined as one under the max bit length of osmomath.Int // which is 256. This is to ensure that we utilize price impact protection // on the total of in amount from all multihop paths. multihopStartTokenInMaxAmount = intMaxValue - totalInAmount = sdk.ZeroInt() + totalInAmount = osmomath.ZeroInt() ) for _, multihopRoute := range route { @@ -499,18 +500,18 @@ func (k Keeper) SplitRouteExactAmountOut( multihopStartTokenInMaxAmount, sdk.NewCoin(tokenOutDenom, multihopRoute.TokenOutAmount)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalInAmount = totalInAmount.Add(tokenOutAmount) } if !totalInAmount.IsPositive() { - return sdk.Int{}, types.FinalAmountIsNotPositiveError{IsAmountOut: false, Amount: totalInAmount} + return osmomath.Int{}, types.FinalAmountIsNotPositiveError{IsAmountOut: false, Amount: totalInAmount} } if totalInAmount.GT(tokenInMaxAmount) { - return sdk.Int{}, types.PriceImpactProtectionExactOutError{Actual: totalInAmount, MaxAmount: tokenInMaxAmount} + return osmomath.Int{}, types.PriceImpactProtectionExactOutError{Actual: totalInAmount, MaxAmount: tokenInMaxAmount} } ctx.EventManager().EmitEvents(sdk.Events{ @@ -547,15 +548,15 @@ func (k Keeper) RouteCalculateSpotPrice( poolId uint64, quoteAssetDenom string, baseAssetDenom string, -) (price sdk.Dec, err error) { +) (price osmomath.Dec, err error) { swapModule, err := k.GetPoolModule(ctx, poolId) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } price, err = swapModule.CalculateSpotPrice(ctx, poolId, quoteAssetDenom, baseAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return price, nil @@ -565,28 +566,28 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( ctx sdk.Context, route []types.SwapAmountOutRoute, tokenOut sdk.Coin, -) (tokenInAmount sdk.Int, err error) { - isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, sdk.Dec{}, sdk.Dec{} - var insExpected []sdk.Int +) (tokenInAmount osmomath.Int, err error) { + isMultiHopRouted, routeSpreadFactor, sumOfSpreadFactors := false, osmomath.Dec{}, osmomath.Dec{} + var insExpected []osmomath.Int // recover from panic defer func() { if r := recover(); r != nil { - insExpected = []sdk.Int{} + insExpected = []osmomath.Int{} err = fmt.Errorf("function MultihopEstimateInGivenExactAmountOut failed due to internal reason: %v", r) } }() routeStep := types.SwapAmountOutRoutes(route) if err := routeStep.Validate(); err != nil { - return sdk.Int{}, err + return osmomath.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 + return osmomath.Int{}, err } } @@ -599,10 +600,10 @@ func (k Keeper) MultihopEstimateInGivenExactAmountOut( insExpected, err = k.createMultihopExpectedSwapOuts(ctx, route, tokenOut) } if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } if len(insExpected) == 0 { - return sdk.Int{}, nil + return osmomath.Int{}, nil } return insExpected[0], nil @@ -672,20 +673,20 @@ func (k Keeper) isOsmoRoutedMultihop(ctx sdk.Context, route types.MultihopRoute, // 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, + totalPathSpreadFactor osmomath.Dec, sumOfSpreadFactors osmomath.Dec, err error, ) { - additiveSpreadFactor := sdk.ZeroDec() - maxSpreadFactor := sdk.ZeroDec() + additiveSpreadFactor := osmomath.ZeroDec() + maxSpreadFactor := osmomath.ZeroDec() for _, poolId := range route.PoolIds() { swapModule, err := k.GetPoolModule(ctx, poolId) if err != nil { - return sdk.Dec{}, sdk.Dec{}, err + return osmomath.Dec{}, osmomath.Dec{}, err } pool, poolErr := swapModule.GetPool(ctx, poolId) if poolErr != nil { - return sdk.Dec{}, sdk.Dec{}, poolErr + return osmomath.Dec{}, osmomath.Dec{}, poolErr } spreadFactor := pool.GetSpreadFactor(ctx) additiveSpreadFactor = additiveSpreadFactor.Add(spreadFactor) @@ -711,8 +712,8 @@ func (k Keeper) createMultihopExpectedSwapOuts( ctx sdk.Context, route []types.SwapAmountOutRoute, tokenOut sdk.Coin, -) ([]sdk.Int, error) { - insExpected := make([]sdk.Int, len(route)) +) ([]osmomath.Int, error) { + insExpected := make([]osmomath.Int, len(route)) for i := len(route) - 1; i >= 0; i-- { routeStep := route[i] @@ -752,9 +753,9 @@ 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)) + cumulativeRouteSpreadFactor, sumOfSpreadFactors osmomath.Dec, +) ([]osmomath.Int, error) { + insExpected := make([]osmomath.Int, len(route)) for i := len(route) - 1; i >= 0; i-- { routeStep := route[i] diff --git a/x/poolmanager/router_test.go b/x/poolmanager/router_test.go index 3998195bd07..7849089ce77 100644 --- a/x/poolmanager/router_test.go +++ b/x/poolmanager/router_test.go @@ -26,7 +26,7 @@ import ( type poolSetup struct { poolType types.PoolType initialLiquidity sdk.Coins - takerFee sdk.Dec + takerFee osmomath.Dec } type expectedTakerFees struct { @@ -47,13 +47,13 @@ const ( ) var ( - defaultInitPoolAmount = sdk.NewInt(1000000000000) + defaultInitPoolAmount = osmomath.NewInt(1000000000000) defaultPoolSpreadFactor = sdk.NewDecWithPrec(1, 3) // 0.1% pool spread factor default - pointOneFivePercent = sdk.MustNewDecFromStr("0.0015") - pointThreePercent = sdk.MustNewDecFromStr("0.003") - pointThreeFivePercent = sdk.MustNewDecFromStr("0.0035") - defaultTakerFee = sdk.ZeroDec() - defaultSwapAmount = sdk.NewInt(1000000) + pointOneFivePercent = osmomath.MustNewDecFromStr("0.0015") + pointThreePercent = osmomath.MustNewDecFromStr("0.003") + pointThreeFivePercent = osmomath.MustNewDecFromStr("0.0035") + defaultTakerFee = osmomath.ZeroDec() + defaultSwapAmount = osmomath.NewInt(1000000) gammKeeperType = reflect.TypeOf(&gamm.Keeper{}) concentratedKeeperType = reflect.TypeOf(&cl.Keeper{}) cosmwasmKeeperType = reflect.TypeOf(&cwpool.Keeper{}) @@ -66,8 +66,8 @@ var ( stakingAddrName = txfeestypes.FeeCollectorForStakingRewardsName nonQuoteCommAddrName = txfeestypes.FeeCollectorForCommunityPoolName - defaultPoolInitAmount = sdk.NewInt(10_000_000_000) - twentyFiveBaseUnitsAmount = sdk.NewInt(25_000_000) + defaultPoolInitAmount = osmomath.NewInt(10_000_000_000) + twentyFiveBaseUnitsAmount = osmomath.NewInt(25_000_000) fooCoin = sdk.NewCoin(foo, defaultPoolInitAmount) barCoin = sdk.NewCoin(bar, defaultPoolInitAmount) @@ -147,7 +147,7 @@ var ( ) // withTakerFees overrides the taker fees for the given pool setup info at the given indices and returns the full set of updated pool setup info. -func (s *KeeperTestSuite) withTakerFees(pools []poolSetup, indicesToUpdate []uint64, updatedFees []sdk.Dec) []poolSetup { +func (s *KeeperTestSuite) withTakerFees(pools []poolSetup, indicesToUpdate []uint64, updatedFees []osmomath.Dec) []poolSetup { s.Require().Equal(len(indicesToUpdate), len(updatedFees)) // Deep copy pools @@ -320,7 +320,7 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { setPositionForCLPool bool routesOverwrite map[types.PoolType]types.PoolModuleI - expectedSpotPrice sdk.Dec + expectedSpotPrice osmomath.Dec expectError error }{ @@ -329,14 +329,14 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { poolId: 1, quoteAssetDenom: "bar", baseAssetDenom: "baz", - expectedSpotPrice: sdk.MustNewDecFromStr("1.5"), + expectedSpotPrice: osmomath.MustNewDecFromStr("1.5"), }, "valid stableswap pool": { preCreatePoolType: types.Stableswap, poolId: 1, quoteAssetDenom: "bar", baseAssetDenom: "baz", - expectedSpotPrice: sdk.MustNewDecFromStr("0.99999998"), + expectedSpotPrice: osmomath.MustNewDecFromStr("0.99999998"), }, "valid concentrated liquidity pool with position": { preCreatePoolType: types.Concentrated, @@ -347,7 +347,7 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { // We generate this value using the scripts in x/concentrated-liquidity/python // Exact output: 5000.000000000000000129480272834995458481 // SDK Bankers rounded output: 5000.000000000000000129 - expectedSpotPrice: sdk.MustNewDecFromStr("5000.000000000000000129"), + expectedSpotPrice: osmomath.MustNewDecFromStr("5000.000000000000000129"), }, "valid concentrated liquidity pool without position": { preCreatePoolType: types.Concentrated, @@ -365,7 +365,7 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { quoteAssetDenom: apptesting.DefaultTransmuterDenomA, baseAssetDenom: apptesting.DefaultTransmuterDenomB, // For transmuter, the spot price is always 1. (hard-coded even if no liquidity) - expectedSpotPrice: sdk.OneDec(), + expectedSpotPrice: osmomath.OneDec(), }, "non-existent pool": { preCreatePoolType: types.Balancer, @@ -394,7 +394,7 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { // we manually set position for CL to set spot price to correct value if tc.setPositionForCLPool { - coins := sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(1000000)), sdk.NewCoin("usdc", sdk.NewInt(5000000000))) + coins := sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(1000000)), sdk.NewCoin("usdc", osmomath.NewInt(5000000000))) s.FundAcc(s.TestAccs[0], coins) clMsgServer := cl.NewMsgServerImpl(s.App.ConcentratedLiquidityKeeper) @@ -404,8 +404,8 @@ func (s *KeeperTestSuite) TestRouteCalculateSpotPrice() { LowerTick: int64(30545000), UpperTick: int64(31500000), TokensProvided: coins, - TokenMinAmount0: sdk.ZeroInt(), - TokenMinAmount1: sdk.ZeroInt(), + TokenMinAmount0: osmomath.ZeroInt(), + TokenMinAmount1: osmomath.ZeroInt(), }) s.Require().NoError(err) } @@ -435,20 +435,20 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { tests := []struct { name string poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec + poolSpreadFactor []osmomath.Dec poolType []types.PoolType routes []types.SwapAmountInRoute incentivizedGauges []uint64 tokenIn sdk.Coin - tokenOutMinAmount sdk.Int - spreadFactor sdk.Dec + tokenOutMinAmount osmomath.Int + spreadFactor osmomath.Dec expectError bool expectReducedFeeApplied bool }{ { name: "One route: Swap - [foo -> bar], 1 percent fee", poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount))}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor}, poolType: []types.PoolType{types.Balancer}, routes: []types.SwapAmountInRoute{ { @@ -456,8 +456,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: bar, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, { name: "Two routes: Swap - [foo -> bar](pool 1) - [bar -> baz](pool 2), both pools 1 percent fee", @@ -466,7 +466,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), // pool 2. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -478,8 +478,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, { name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", @@ -488,7 +488,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -500,8 +500,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin("foo", sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin("foo", osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: true, }, { @@ -511,7 +511,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { 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)}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -523,8 +523,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: true, }, { @@ -535,7 +535,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -551,8 +551,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: false, }, { @@ -564,7 +564,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -576,8 +576,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: false, }, { @@ -589,7 +589,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -601,8 +601,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: true, }, { @@ -616,7 +616,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 3. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -632,8 +632,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), expectReducedFeeApplied: false, }, { @@ -642,15 +642,15 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(foo, apptesting.DefaultCoinAmount), sdk.NewCoin(bar, apptesting.DefaultCoinAmount)), }, poolType: []types.PoolType{types.Concentrated}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, TokenOutDenom: bar, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, { name: "[Concentrated[ Three routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) - [baz -> bar](pool 3), all pools 1 percent fee", @@ -660,7 +660,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(bar, apptesting.DefaultCoinAmount), sdk.NewCoin(baz, apptesting.DefaultCoinAmount)), }, poolType: []types.PoolType{types.Concentrated, types.Concentrated, types.Concentrated}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -676,8 +676,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, { name: "[Cosmwasm] One route: Swap - [foo -> bar], 1 percent fee", @@ -685,15 +685,15 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(foo, apptesting.DefaultCoinAmount), sdk.NewCoin(bar, apptesting.DefaultCoinAmount)), }, poolType: []types.PoolType{types.CosmWasm}, - poolSpreadFactor: []sdk.Dec{sdk.OneDec()}, + poolSpreadFactor: []osmomath.Dec{osmomath.OneDec()}, routes: []types.SwapAmountInRoute{ { PoolId: 1, TokenOutDenom: bar, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, { name: "[Cosmwasm -> Concentrated] One route: Swap - [foo -> bar] -> [bar -> baz], 1 percent fee", @@ -702,7 +702,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), }, poolType: []types.PoolType{types.CosmWasm, types.Concentrated}, - poolSpreadFactor: []sdk.Dec{sdk.OneDec(), defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{osmomath.OneDec(), defaultPoolSpreadFactor}, routes: []types.SwapAmountInRoute{ { PoolId: 1, @@ -713,8 +713,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, //TODO: //change values in and out to be different with each swap module type @@ -767,13 +767,13 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { tests := []struct { name string poolCoins []sdk.Coins - poolSpreadFactor []sdk.Dec + poolSpreadFactor []osmomath.Dec poolType []types.PoolType routes []types.SwapAmountOutRoute incentivizedGauges []uint64 tokenOut sdk.Coin - tokenInMaxAmount sdk.Int - spreadFactor sdk.Dec + tokenInMaxAmount osmomath.Int + spreadFactor osmomath.Dec expectError bool expectReducedFeeApplied bool }{ @@ -781,14 +781,14 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { name: "One route: Swap - [foo -> bar], 1 percent fee", poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount))}, poolType: []types.PoolType{types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, TokenInDenom: bar, }, }, - tokenInMaxAmount: sdk.NewInt(90000000), + tokenInMaxAmount: osmomath.NewInt(90000000), tokenOut: sdk.NewCoin(foo, defaultSwapAmount), }, { @@ -798,7 +798,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), // pool 2. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -811,8 +811,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, incentivizedGauges: []uint64{}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), }, { name: "Two routes: Swap - [foo -> uosmo](pool 1) - [uosmo -> baz](pool 2) with a half fee applied, both pools 1 percent fee", @@ -821,7 +821,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoins(sdk.NewCoin(baz, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -833,8 +833,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), expectReducedFeeApplied: true, }, { @@ -844,7 +844,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { 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)}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, sdk.NewDecWithPrec(1, 1)}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -856,8 +856,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), expectReducedFeeApplied: true, }, { @@ -868,7 +868,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -884,8 +884,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(bar, osmomath.NewInt(100000)), expectReducedFeeApplied: false, }, { @@ -897,7 +897,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -909,8 +909,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), expectReducedFeeApplied: false, }, { @@ -922,7 +922,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 2. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -934,8 +934,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6}, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), expectReducedFeeApplied: true, }, { @@ -949,7 +949,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(uosmo, defaultInitPoolAmount)), // pool 3. // pool 3. }, poolType: []types.PoolType{types.Balancer, types.Balancer, types.Balancer}, - poolSpreadFactor: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor, defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -965,8 +965,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { }, }, incentivizedGauges: []uint64{1, 2, 3, 4, 5, 6, 7, 8, 9}, - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(bar, osmomath.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), expectReducedFeeApplied: false, }, { @@ -975,15 +975,15 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoins(sdk.NewCoin(foo, apptesting.DefaultCoinAmount), sdk.NewCoin(bar, apptesting.DefaultCoinAmount)), }, poolType: []types.PoolType{types.CosmWasm}, - poolSpreadFactor: []sdk.Dec{sdk.OneDec()}, + poolSpreadFactor: []osmomath.Dec{osmomath.OneDec()}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, TokenInDenom: foo, }, }, - tokenOut: sdk.NewCoin(bar, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(bar, osmomath.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), }, { name: "[Cosmwasm -> Concentrated] One route: Swap - [foo -> bar] -> [bar -> baz], 1 percent fee", @@ -992,7 +992,7 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { sdk.NewCoins(sdk.NewCoin(bar, defaultInitPoolAmount), sdk.NewCoin(baz, defaultInitPoolAmount)), }, poolType: []types.PoolType{types.CosmWasm, types.Concentrated}, - poolSpreadFactor: []sdk.Dec{sdk.OneDec(), defaultPoolSpreadFactor}, + poolSpreadFactor: []osmomath.Dec{osmomath.OneDec(), defaultPoolSpreadFactor}, routes: []types.SwapAmountOutRoute{ { PoolId: 1, @@ -1003,8 +1003,8 @@ func (s *KeeperTestSuite) TestMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenInMaxAmount: sdk.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), }, // TODO: // tests for concentrated liquidity @@ -1056,7 +1056,7 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { routes []types.SwapAmountInRoute estimateRoutes []types.SwapAmountInRoute tokenIn sdk.Coin - tokenOutMinAmount sdk.Int + tokenOutMinAmount osmomath.Int } tests := []struct { @@ -1089,8 +1089,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: true, }, @@ -1117,8 +1117,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, reducedFeeApplied: true, expectPass: true, @@ -1146,8 +1146,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: true, poolType: types.Stableswap, @@ -1175,8 +1175,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountIn() { TokenOutDenom: baz, }, }, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(9000000000000000000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(9000000000000000000)), + tokenOutMinAmount: osmomath.NewInt(1), }, expectPass: false, poolType: types.Stableswap, @@ -1237,7 +1237,7 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { type param struct { routes []types.SwapAmountOutRoute estimateRoutes []types.SwapAmountOutRoute - tokenInMaxAmount sdk.Int + tokenInMaxAmount osmomath.Int tokenOut sdk.Coin } @@ -1271,8 +1271,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), }, expectPass: true, }, @@ -1299,8 +1299,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { TokenInDenom: uosmo, }, }, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), }, expectPass: true, reducedFeeApplied: true, @@ -1328,8 +1328,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(100000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(100000)), }, expectPass: true, poolType: types.Stableswap, @@ -1357,8 +1357,8 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { TokenInDenom: bar, }, }, - tokenInMaxAmount: sdk.NewInt(90000000), - tokenOut: sdk.NewCoin(baz, sdk.NewInt(9000000000000000000)), + tokenInMaxAmount: osmomath.NewInt(90000000), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(9000000000000000000)), }, expectPass: false, poolType: types.Stableswap, @@ -1414,9 +1414,9 @@ func (s *KeeperTestSuite) TestEstimateMultihopSwapExactAmountOut() { func (s *KeeperTestSuite) makeGaugesIncentivized(incentivizedGauges []uint64) { var records []poolincentivestypes.DistrRecord - totalWeight := sdk.NewInt(int64(len(incentivizedGauges))) + totalWeight := osmomath.NewInt(int64(len(incentivizedGauges))) for _, gauge := range incentivizedGauges { - records = append(records, poolincentivestypes.DistrRecord{GaugeId: gauge, Weight: sdk.OneInt()}) + records = append(records, poolincentivestypes.DistrRecord{GaugeId: gauge, Weight: osmomath.OneInt()}) } distInfo := poolincentivestypes.DistrInfo{ TotalWeight: totalWeight, @@ -1452,7 +1452,7 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo s.Require().NoError(err) // we then do individual swaps until we reach the end of the swap route - tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, spreadFactor) + tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, osmomath.NewInt(100000000), nextTokenOut, spreadFactor) s.Require().NoError(err) tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) @@ -1475,7 +1475,7 @@ func (s *KeeperTestSuite) calcInGivenOutAmountAsSeparateSwaps(osmoFeeReduced boo swapModule, err := s.App.PoolManagerKeeper.GetPoolModule(cacheCtx, hop.PoolId) s.Require().NoError(err) - tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, sdk.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) + tokenInAmt, err := swapModule.SwapExactAmountOut(cacheCtx, s.TestAccs[0], hopPool, hop.TokenInDenom, osmomath.NewInt(100000000), nextTokenOut, updatedPoolSpreadFactor) s.Require().NoError(err) tokenInCoin := sdk.NewCoin(hop.TokenInDenom, tokenInAmt) @@ -1518,7 +1518,7 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced 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, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, osmomath.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1542,7 +1542,7 @@ func (s *KeeperTestSuite) calcOutGivenInAmountAsSeparatePoolSwaps(osmoFeeReduced 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, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, sdk.OneInt(), spreadFactor) + tokenOut, err := swapModule.SwapExactAmountIn(cacheCtx, s.TestAccs[0], pool, nextTokenInAfterSubTakerFee, hop.TokenOutDenom, osmomath.OneInt(), spreadFactor) s.Require().NoError(err) nextTokenIn = sdk.NewCoin(hop.TokenOutDenom, tokenOut) @@ -1558,12 +1558,12 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { name string poolId uint64 poolCoins sdk.Coins - poolFee sdk.Dec - takerFee sdk.Dec + poolFee osmomath.Dec + takerFee osmomath.Dec tokenIn sdk.Coin tokenOutDenom string - tokenOutMinAmount sdk.Int - expectedTokenOutAmount sdk.Int + tokenOutMinAmount osmomath.Int + expectedTokenOutAmount osmomath.Int swapWithNoTakerFee bool expectError bool }{ @@ -1580,11 +1580,11 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { poolId: 1, poolCoins: sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), poolFee: defaultPoolSpreadFactor, - takerFee: sdk.MustNewDecFromStr("0.0025"), // 0.25% - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + takerFee: osmomath.MustNewDecFromStr("0.0025"), // 0.25% + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, - expectedTokenOutAmount: sdk.NewInt(99650), // 10000 - 0.35% + expectedTokenOutAmount: osmomath.NewInt(99650), // 10000 - 0.35% }, // Swap with taker fee: // - foo: 1000000000000 @@ -1598,50 +1598,50 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { poolId: 1, poolCoins: sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), poolFee: defaultPoolSpreadFactor, - takerFee: sdk.MustNewDecFromStr("0.0025"), // 0.25% - tokenIn: sdk.NewCoin(bar, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + takerFee: osmomath.MustNewDecFromStr("0.0025"), // 0.25% + tokenIn: sdk.NewCoin(bar, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: foo, - expectedTokenOutAmount: sdk.NewInt(99650), // 100000 - 0.35% + expectedTokenOutAmount: osmomath.NewInt(99650), // 100000 - 0.35% }, { name: "Swap - [foo -> bar], 0.1 percent swap fee, 0.33 percent taker fee", poolId: 1, - poolCoins: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(2000000000000)), sdk.NewCoin(bar, sdk.NewInt(1000000000000))), + poolCoins: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(2000000000000)), sdk.NewCoin(bar, osmomath.NewInt(1000000000000))), poolFee: defaultPoolSpreadFactor, - takerFee: sdk.MustNewDecFromStr("0.0033"), // 0.33% + takerFee: osmomath.MustNewDecFromStr("0.0033"), // 0.33% // We capture the expected fees in the input token to simplify the process for calculating output. // 100000 / (1 - 0.0043) = 100432 - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100432)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100432)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, // Since spot price is 2 and the input after fees is 100000, the output should be 50000 // minus one due to truncation on rounding error. - expectedTokenOutAmount: sdk.NewInt(50000 - 1), + expectedTokenOutAmount: osmomath.NewInt(50000 - 1), }, { name: "Swap - [foo -> bar], 0 percent swap fee, 0 percent taker fee", poolId: 1, - poolCoins: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(1000000000000)), sdk.NewCoin(bar, sdk.NewInt(1000000000000))), - poolFee: sdk.ZeroDec(), - takerFee: sdk.ZeroDec(), - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + poolCoins: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(1000000000000)), sdk.NewCoin(bar, osmomath.NewInt(1000000000000))), + poolFee: osmomath.ZeroDec(), + takerFee: osmomath.ZeroDec(), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, - expectedTokenOutAmount: sdk.NewInt(100000 - 1), + expectedTokenOutAmount: osmomath.NewInt(100000 - 1), }, // 99% taker fee 99% swap fee { name: "Swap - [foo -> bar], 99 percent swap fee, 99 percent taker fee", poolId: 1, - poolCoins: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(1000000000000)), sdk.NewCoin(bar, sdk.NewInt(1000000000000))), - poolFee: sdk.MustNewDecFromStr("0.99"), - takerFee: sdk.MustNewDecFromStr("0.99"), - tokenIn: sdk.NewCoin(foo, sdk.NewInt(10000)), - tokenOutMinAmount: sdk.NewInt(1), + poolCoins: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(1000000000000)), sdk.NewCoin(bar, osmomath.NewInt(1000000000000))), + poolFee: osmomath.MustNewDecFromStr("0.99"), + takerFee: osmomath.MustNewDecFromStr("0.99"), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(10000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, // 10000 * 0.01 * 0.01 = 1 swapped at a spot price of 1 - expectedTokenOutAmount: sdk.NewInt(1), + expectedTokenOutAmount: osmomath.NewInt(1), }, // Swap with no taker fee: // - foo: 1000000000000 @@ -1655,19 +1655,19 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { 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), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, swapWithNoTakerFee: true, - expectedTokenOutAmount: sdk.NewInt(99899), + expectedTokenOutAmount: osmomath.NewInt(99899), }, { name: "Wrong pool id", poolId: 2, poolCoins: sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), poolFee: defaultPoolSpreadFactor, - tokenIn: sdk.NewCoin(foo, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, expectError: true, }, @@ -1676,8 +1676,8 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { poolId: 1, poolCoins: sdk.NewCoins(sdk.NewCoin(foo, defaultInitPoolAmount), sdk.NewCoin(bar, defaultInitPoolAmount)), poolFee: defaultPoolSpreadFactor, - tokenIn: sdk.NewCoin(baz, sdk.NewInt(100000)), - tokenOutMinAmount: sdk.NewInt(1), + tokenIn: sdk.NewCoin(baz, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: bar, expectError: true, }, @@ -1686,8 +1686,8 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { 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), + tokenIn: sdk.NewCoin(foo, osmomath.NewInt(100000)), + tokenOutMinAmount: osmomath.NewInt(1), tokenOutDenom: baz, expectError: true, }, @@ -1701,15 +1701,15 @@ func (s *KeeperTestSuite) TestSingleSwapExactAmountIn() { s.FundAcc(s.TestAccs[0], tc.poolCoins) s.PrepareCustomBalancerPoolFromCoins(tc.poolCoins, balancer.PoolParams{ SwapFee: tc.poolFee, - ExitFee: sdk.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) // execute the swap - var multihopTokenOutAmount sdk.Int + var multihopTokenOutAmount osmomath.Int var err error // TODO: move the denom pair set out and only run SwapExactAmountIn. // SwapExactAmountInNoTakerFee should be in a different test. - if (tc.takerFee != sdk.Dec{}) { + if (tc.takerFee != osmomath.Dec{}) { // If applicable, set taker fee. Note that denoms are reordered lexicographically before being stored. poolmanagerKeeper.SetDenomPairTakerFee(s.Ctx, tc.poolCoins[0].Denom, tc.poolCoins[1].Denom, tc.takerFee) @@ -1943,7 +1943,7 @@ func (s *KeeperTestSuite) TestAllPools_RealPools() { } // sets *KeeperTestSuiteof desired type and returns their IDs -func (s *KeeperTestSuite) setupPools(poolType types.PoolType, poolDefaultSpreadFactor sdk.Dec) (firstEstimatePoolId, secondEstimatePoolId uint64) { +func (s *KeeperTestSuite) setupPools(poolType types.PoolType, poolDefaultSpreadFactor osmomath.Dec) (firstEstimatePoolId, secondEstimatePoolId uint64) { switch poolType { case types.Stableswap: // Prepare 4 pools, @@ -1962,34 +1962,34 @@ func (s *KeeperTestSuite) setupPools(poolType types.PoolType, poolDefaultSpreadF // and two pools for calculating `EstimateMultihopSwapExactAmountOut` s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSpreadFactor, // 1% - ExitFee: sdk.NewDec(0), + ExitFee: osmomath.NewDec(0), }) s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSpreadFactor, - ExitFee: sdk.NewDec(0), + ExitFee: osmomath.NewDec(0), }) firstEstimatePoolId = s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSpreadFactor, // 1% - ExitFee: sdk.NewDec(0), + ExitFee: osmomath.NewDec(0), }) secondEstimatePoolId = s.PrepareBalancerPoolWithPoolParams(balancer.PoolParams{ SwapFee: poolDefaultSpreadFactor, - ExitFee: sdk.NewDec(0), + ExitFee: osmomath.NewDec(0), }) return } } // withInput takes in a types.SwapAmountInSplitRoute and returns it with the given input amount as TokenInAmount -func withInputSwapIn(route types.SwapAmountInSplitRoute, input sdk.Int) types.SwapAmountInSplitRoute { +func withInputSwapIn(route types.SwapAmountInSplitRoute, input osmomath.Int) types.SwapAmountInSplitRoute { route.TokenInAmount = input return route } // withInput takes in a types.SwapAmountOutSplitRoute and returns it with the given input amount as TokenInAmount -func withInputSwapOut(route types.SwapAmountOutSplitRoute, input sdk.Int) types.SwapAmountOutSplitRoute { +func withInputSwapOut(route types.SwapAmountOutSplitRoute, input osmomath.Int) types.SwapAmountOutSplitRoute { route.TokenOutAmount = input return route } @@ -2056,10 +2056,10 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { TokenOutDenom: baz, }, }, - TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), + TokenInAmount: osmomath.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(97866545) + priceImpactThreshold = osmomath.NewInt(97866545) ) tests := map[string]struct { @@ -2067,7 +2067,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { setupPools []poolSetup routes []types.SwapAmountInSplitRoute tokenInDenom string - tokenOutMinAmount sdk.Int + tokenOutMinAmount osmomath.Int // This value was taken from the actual result // and not manually calculated. This is acceptable @@ -2076,7 +2076,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { // The math should be tested per-module. // We keep this assertion to make sure that the // actual result is within a reasonable range. - expectedTokenOutEstimate sdk.Int + expectedTokenOutEstimate osmomath.Int expectedTakerFees expectedTakerFees checkExactOutput bool @@ -2085,23 +2085,23 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { "valid solo route one hop": { routes: defaultSingleRouteOneHop, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectedTokenOutEstimate: twentyFiveBaseUnitsAmount, expectedTakerFees: zeroTakerFeeDistr, }, "valid solo route one hop (exact output check)": { // Set the pool we swap through to have a 0.3% taker fee - setupPools: s.withTakerFees(defaultValidPools, []uint64{0}, []sdk.Dec{pointThreePercent}), + setupPools: s.withTakerFees(defaultValidPools, []uint64{0}, []osmomath.Dec{pointThreePercent}), routes: []types.SwapAmountInSplitRoute{ - withInputSwapIn(defaultSingleRouteOneHop[0], sdk.NewInt(1000)), + withInputSwapIn(defaultSingleRouteOneHop[0], osmomath.NewInt(1000)), }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), // We expect the output to truncate - expectedTokenOutEstimate: sdk.NewInt(996), + expectedTokenOutEstimate: osmomath.NewInt(996), checkExactOutput: true, // We expect total taker fees to be 3foo (0.3% of 1000foo) @@ -2115,13 +2115,13 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { // staking rewards. communityPoolQuoteAssets: sdk.NewCoins(), communityPoolNonQuoteAssets: sdk.NewCoins(), - stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(3))), + stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(3))), }, }, "valid solo route multi hop": { routes: []types.SwapAmountInSplitRoute{defaultSingleRouteTwoHops}, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectedTokenOutEstimate: twentyFiveBaseUnitsAmount, expectedTakerFees: zeroTakerFeeDistr, @@ -2132,7 +2132,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { defaultSingleRouteThreeHops, }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), // 1x from single route two hops and 3x from single route three hops expectedTokenOutEstimate: twentyFiveBaseUnitsAmount.MulRaw(4), @@ -2143,21 +2143,21 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { setupPools: s.withTakerFees( defaultValidPools, []uint64{0, 3, 6, 7}, - []sdk.Dec{pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent}, + []osmomath.Dec{pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent}, ), routes: []types.SwapAmountInSplitRoute{ - withInputSwapIn(defaultSingleRouteTwoHops, sdk.NewInt(1000)), - withInputSwapIn(fooAbcBazTwoHops, sdk.NewInt(1000)), + withInputSwapIn(defaultSingleRouteTwoHops, osmomath.NewInt(1000)), + withInputSwapIn(fooAbcBazTwoHops, osmomath.NewInt(1000)), }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), // We charge taker fee on each hop and expect the output to truncate // The output of first hop: (1 - 0.0035) * 1000 = 996.5, truncated to 996 (4foo taker fee) // which has an additional truncation after the swap executes, leaving 995. // The second hop is similar: (1 - 0.0035) * 995 = 991.5, truncated to 991 (4bar taker fee) // which has an additional truncation after the swap executes, leaving 990. - expectedTokenOutEstimate: sdk.NewInt(990 + 990), + expectedTokenOutEstimate: osmomath.NewInt(990 + 990), checkExactOutput: true, // Expected taker fees from calculation above are: @@ -2168,13 +2168,13 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { expectedTakerFees: expectedTakerFees{ // 1foo & 1bar from first route, 1foo from second route // Total: 2foo, 1bar - communityPoolQuoteAssets: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(2)), sdk.NewCoin(bar, sdk.NewInt(1))), + communityPoolQuoteAssets: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(2)), sdk.NewCoin(bar, osmomath.NewInt(1))), // 1abc from second route // Total: 1abc - communityPoolNonQuoteAssets: sdk.NewCoins(sdk.NewCoin(abc, sdk.NewInt(1))), + communityPoolNonQuoteAssets: sdk.NewCoins(sdk.NewCoin(abc, osmomath.NewInt(1))), // 3foo & 3bar from first route, 3foo & 3abc from second route // Total: 6foo, 3bar, 3abc - stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(6)), sdk.NewCoin(bar, sdk.NewInt(3)), sdk.NewCoin(abc, sdk.NewInt(3))), + stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(6)), sdk.NewCoin(bar, osmomath.NewInt(3)), sdk.NewCoin(abc, osmomath.NewInt(3))), }, }, "split route multi hop with different taker fees (exact output check)": { @@ -2182,14 +2182,14 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { setupPools: s.withTakerFees( defaultValidPools, []uint64{0, 3, 6, 7}, - []sdk.Dec{pointThreeFivePercent, sdk.ZeroDec(), pointOneFivePercent, pointThreePercent}, + []osmomath.Dec{pointThreeFivePercent, osmomath.ZeroDec(), pointOneFivePercent, pointThreePercent}, ), routes: []types.SwapAmountInSplitRoute{ - withInputSwapIn(defaultSingleRouteTwoHops, sdk.NewInt(1000)), - withInputSwapIn(fooAbcBazTwoHops, sdk.NewInt(1000)), + withInputSwapIn(defaultSingleRouteTwoHops, osmomath.NewInt(1000)), + withInputSwapIn(fooAbcBazTwoHops, osmomath.NewInt(1000)), }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), // Route 1: // Hop 1: (1 - 0.0035) * 1000 = 996.5, truncated to 996. Post swap truncated to 995. @@ -2203,7 +2203,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { // Hop 2: (1 - 0.003) * 997 = 994.009, truncated to 994. Post swap truncated to 993. // * 3abc taker fee // Route 2 output: 993 (Taker fees: 2foo, 3abc) - expectedTokenOutEstimate: sdk.NewInt(994 + 993), + expectedTokenOutEstimate: osmomath.NewInt(994 + 993), checkExactOutput: true, // Expected taker fees from calculation above are: @@ -2214,11 +2214,11 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { // Recall that foo and bar are quote assets, while abc is not. expectedTakerFees: expectedTakerFees{ // 1foo from first route, everything from second route is truncated - communityPoolQuoteAssets: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(1))), + communityPoolQuoteAssets: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(1))), communityPoolNonQuoteAssets: sdk.NewCoins(), // 3foo from first route, 2foo & 3abc from second route // Total: 5foo, 3abc - stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(5)), sdk.NewCoin(abc, sdk.NewInt(3))), + stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(5)), sdk.NewCoin(abc, osmomath.NewInt(3))), }, }, "valid split route multi hop with price impact protection that would fail individual route if given per multihop": { @@ -2242,9 +2242,9 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { }, tokenInDenom: foo, // one greater than expected amount - tokenOutMinAmount: priceImpactThreshold.Add(sdk.OneInt()), + tokenOutMinAmount: priceImpactThreshold.Add(osmomath.OneInt()), - expectError: types.PriceImpactProtectionExactInError{Actual: priceImpactThreshold, MinAmount: priceImpactThreshold.Add(sdk.OneInt())}, + expectError: types.PriceImpactProtectionExactInError{Actual: priceImpactThreshold, MinAmount: priceImpactThreshold.Add(osmomath.OneInt())}, }, "error: duplicate split routes": { routes: []types.SwapAmountInSplitRoute{ @@ -2257,7 +2257,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { }, }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectError: types.ErrDuplicateRoutesNotAllowed, }, @@ -2275,7 +2275,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { }, }, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectError: types.FailedToFindRouteError{PoolId: uint64(len(defaultValidPools) + 1)}, }, @@ -2330,7 +2330,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountIn() { // As a result, we roughly expect the amount out to be the same // as the amount in given in another token. However, the actual // amount must be stricly less than the given due to price impact. - multiplicativeTolerance := sdk.OneDec() + multiplicativeTolerance := osmomath.OneDec() if tc.checkExactOutput { // We set to a small value instead of zero since zero is a special case // where multiplicative tolerance is skipped/not considered @@ -2420,10 +2420,10 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { TokenInDenom: uosmo, }, }, - TokenOutAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), + TokenOutAmount: osmomath.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } - priceImpactThreshold = sdk.NewInt(102239504) + priceImpactThreshold = osmomath.NewInt(102239504) ) tests := map[string]struct { @@ -2431,7 +2431,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { isInvalidSender bool routes []types.SwapAmountOutSplitRoute tokenOutDenom string - tokenInMaxAmount sdk.Int + tokenInMaxAmount osmomath.Int // This value was taken from the actual result // and not manually calculated. This is acceptable @@ -2440,7 +2440,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { // The math should be tested per-module. // We keep this assertion to make sure that the // actual result is within a reasonable range. - expectedTokenInEstimate sdk.Int + expectedTokenInEstimate osmomath.Int checkExactOutput bool expectError error @@ -2454,16 +2454,16 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { }, "valid solo route one hop (exact output check)": { // Set the pool we swap through to have a 0.3% taker fee - setupPools: s.withTakerFees(defaultValidPools, []uint64{0}, []sdk.Dec{pointThreePercent}), + setupPools: s.withTakerFees(defaultValidPools, []uint64{0}, []osmomath.Dec{pointThreePercent}), routes: []types.SwapAmountOutSplitRoute{ - withInputSwapOut(defaultSingleRouteOneHop[0], sdk.NewInt(1000)), + withInputSwapOut(defaultSingleRouteOneHop[0], osmomath.NewInt(1000)), }, tokenOutDenom: bar, tokenInMaxAmount: poolmanager.IntMaxValue, // (1000 / (1 - 0.003)) = 1003.009, rounded up = 1004. Post swap rounded up to 1005. - expectedTokenInEstimate: sdk.NewInt(1005), + expectedTokenInEstimate: osmomath.NewInt(1005), checkExactOutput: true, }, "valid solo route multi hop": { @@ -2489,11 +2489,11 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { setupPools: s.withTakerFees( defaultValidPools, []uint64{0, 2, 3, 5}, - []sdk.Dec{pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent}, + []osmomath.Dec{pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent, pointThreeFivePercent}, ), routes: []types.SwapAmountOutSplitRoute{ - withInputSwapOut(defaultSingleRouteTwoHops, sdk.NewInt(1000)), - withInputSwapOut(fooUosmoBazTwoHops, sdk.NewInt(1000)), + withInputSwapOut(defaultSingleRouteTwoHops, osmomath.NewInt(1000)), + withInputSwapOut(fooUosmoBazTwoHops, osmomath.NewInt(1000)), }, tokenOutDenom: baz, tokenInMaxAmount: poolmanager.IntMaxValue, @@ -2503,7 +2503,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { // which has an additional rounding up after the swap executes, leaving 1005. // The second hop is similar: (1005 / (1 - 0.0035)) = 1008.52, rounded up = 1009 // which has an additional rounding up after the swap executes, leaving 1010. - expectedTokenInEstimate: sdk.NewInt(1010 + 1010), + expectedTokenInEstimate: osmomath.NewInt(1010 + 1010), checkExactOutput: true, }, "split route multi hop with different taker fees (exact output check)": { @@ -2513,11 +2513,11 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { setupPools: s.withTakerFees( defaultValidPools, []uint64{0, 2, 3, 5}, - []sdk.Dec{pointThreeFivePercent, sdk.ZeroDec(), pointOneFivePercent, pointThreePercent}, + []osmomath.Dec{pointThreeFivePercent, osmomath.ZeroDec(), pointOneFivePercent, pointThreePercent}, ), routes: []types.SwapAmountOutSplitRoute{ - withInputSwapOut(defaultSingleRouteTwoHops, sdk.NewInt(1000)), - withInputSwapOut(fooUosmoBazTwoHops, sdk.NewInt(1000)), + withInputSwapOut(defaultSingleRouteTwoHops, osmomath.NewInt(1000)), + withInputSwapOut(fooUosmoBazTwoHops, osmomath.NewInt(1000)), }, tokenOutDenom: baz, tokenInMaxAmount: poolmanager.IntMaxValue, @@ -2530,7 +2530,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { // Hop 1: 1000 / (1 - 0.0015) = 1001.5, rounded up to 1002. Post swap rounded up to 1003. // Hop 2: 1003 / (1 - 0.003) = 1006.01, rounded up to 1007. Post swap rounded up to 1008. // Route 2 expected input: 1008 - expectedTokenInEstimate: sdk.NewInt(1006 + 1008), + expectedTokenInEstimate: osmomath.NewInt(1006 + 1008), checkExactOutput: true, }, @@ -2555,9 +2555,9 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { tokenOutDenom: baz, // one less than expected amount // every route individually would fail, but the split route should succeed - tokenInMaxAmount: priceImpactThreshold.Sub(sdk.OneInt()), + tokenInMaxAmount: priceImpactThreshold.Sub(osmomath.OneInt()), - expectError: types.PriceImpactProtectionExactOutError{Actual: priceImpactThreshold, MaxAmount: priceImpactThreshold.Sub(sdk.OneInt())}, + expectError: types.PriceImpactProtectionExactOutError{Actual: priceImpactThreshold, MaxAmount: priceImpactThreshold.Sub(osmomath.OneInt())}, }, "error: duplicate split routes": { @@ -2639,7 +2639,7 @@ func (s *KeeperTestSuite) TestSplitRouteExactAmountOut() { // As a result, we roughly expect the amount in to be the same // as the amount out given of another token. However, the actual // amount must be stricly greater than the given due to price impact. - multiplicativeTolerance := sdk.OneDec() + multiplicativeTolerance := osmomath.OneDec() if tc.checkExactOutput { // We set to a small value instead of zero since zero is a special case // where multiplicative tolerance is skipped/not considered @@ -2660,9 +2660,9 @@ func (s *KeeperTestSuite) TestGetTotalPoolLiquidity() { cosmWasmPoolId = uint64(3) ) var ( - defaultPoolCoinOne = sdk.NewCoin("usdc", sdk.OneInt()) - defaultPoolCoinTwo = sdk.NewCoin("eth", sdk.NewInt(2)) - nonPoolCool = sdk.NewCoin("uosmo", sdk.NewInt(3)) + defaultPoolCoinOne = sdk.NewCoin("usdc", osmomath.OneInt()) + defaultPoolCoinTwo = sdk.NewCoin("eth", osmomath.NewInt(2)) + nonPoolCool = sdk.NewCoin("uosmo", osmomath.NewInt(3)) defaultCoins = sdk.NewCoins(defaultPoolCoinOne, defaultPoolCoinTwo) ) @@ -2732,7 +2732,7 @@ func (s *KeeperTestSuite) TestGetTotalPoolLiquidity() { s.PrepareBalancerPool() if tc.poolLiquidity.Len() == 2 { s.FundAcc(s.TestAccs[0], tc.poolLiquidity) - s.CreatePoolFromTypeWithCoinsAndSpreadFactor(types.CosmWasm, tc.poolLiquidity, sdk.ZeroDec()) + s.CreatePoolFromTypeWithCoinsAndSpreadFactor(types.CosmWasm, tc.poolLiquidity, osmomath.ZeroDec()) } // Get pool defined in test case @@ -2912,10 +2912,10 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { route types.MultihopRoute balancerPoolCoins []sdk.Coins concentratedPoolDenoms [][]string - poolFees []sdk.Dec + poolFees []osmomath.Dec - expectedRouteFee sdk.Dec - expectedTotalFee sdk.Dec + expectedRouteFee osmomath.Dec + expectedTotalFee osmomath.Dec expectedError error }{ "happy path: balancer route": { @@ -2929,7 +2929,7 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { TokenOutDenom: bar, }, }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolFees: []osmomath.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. @@ -2949,7 +2949,7 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { TokenOutDenom: bar, }, }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolFees: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, concentratedPoolDenoms: [][]string{ {foo, uosmo}, // pool 1. {uosmo, baz}, // pool 2. @@ -2969,7 +2969,7 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { TokenOutDenom: bar, }, }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolFees: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, concentratedPoolDenoms: [][]string{ {foo, uosmo}, // pool 1. }, @@ -2992,14 +2992,14 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { }, }), // Note that pool 2 has 5x the swap fee of pool 1 - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor.Mul(sdk.NewDec(5))}, + poolFees: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor.Mul(osmomath.NewDec(5))}, concentratedPoolDenoms: [][]string{ {foo, uosmo}, // pool 1. {uosmo, baz}, // pool 2. }, - expectedRouteFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(5)), - expectedTotalFee: defaultPoolSpreadFactor.Mul(sdk.NewDec(6)), + expectedRouteFee: defaultPoolSpreadFactor.Mul(osmomath.NewDec(5)), + expectedTotalFee: defaultPoolSpreadFactor.Mul(osmomath.NewDec(6)), }, "error: pool does not exist": { route: types.SwapAmountInRoutes([]types.SwapAmountInRoute{ @@ -3012,7 +3012,7 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { TokenOutDenom: bar, }, }), - poolFees: []sdk.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, + poolFees: []osmomath.Dec{defaultPoolSpreadFactor, defaultPoolSpreadFactor}, expectedError: types.FailedToFindRouteError{PoolId: 1}, }, @@ -3039,8 +3039,8 @@ func (s *KeeperTestSuite) TestGetOsmoRoutedMultihopTotalSpreadFactor() { 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) + s.Require().Equal(osmomath.Dec{}, routeFee) + s.Require().Equal(osmomath.Dec{}, totalFee) return } @@ -3058,10 +3058,10 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { balancerPoolCoins []sdk.Coins concentratedPoolDenoms [][]string poolCoins []sdk.Coins - cumulativeRouteSpreadFactor sdk.Dec - sumOfSpreadFactors sdk.Dec + cumulativeRouteSpreadFactor osmomath.Dec + sumOfSpreadFactors osmomath.Dec - expectedSwapIns []sdk.Int + expectedSwapIns []osmomath.Int expectedError bool }{ "happy path: one route": { @@ -3071,12 +3071,12 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { TokenInDenom: bar, }, }, - poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100)))}, + poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100)))}, - tokenOut: sdk.NewCoin(foo, sdk.NewInt(10)), + tokenOut: sdk.NewCoin(foo, osmomath.NewInt(10)), // expectedSwapIns = (tokenOut * (poolTokenOutBalance / poolPostSwapOutBalance)).ceil() // foo token = 10 * (100 / 90) ~ 12 - expectedSwapIns: []sdk.Int{sdk.NewInt(12)}, + expectedSwapIns: []osmomath.Int{osmomath.NewInt(12)}, }, "happy path: two route": { route: []types.SwapAmountOutRoute{ @@ -3091,14 +3091,14 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { }, poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100))), // pool 1. - sdk.NewCoins(sdk.NewCoin(bar, sdk.NewInt(100)), sdk.NewCoin(baz, sdk.NewInt(100))), // pool 2. + sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100))), // pool 1. + sdk.NewCoins(sdk.NewCoin(bar, osmomath.NewInt(100)), sdk.NewCoin(baz, osmomath.NewInt(100))), // pool 2. }, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(10)), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(10)), // expectedSwapIns = (tokenOut * (poolTokenOutBalance / poolPostSwapOutBalance)).ceil() // foo token = 10 * (100 / 90) ~ 12 // bar token = 12 * (100 / 88) ~ 14 - expectedSwapIns: []sdk.Int{sdk.NewInt(14), sdk.NewInt(12)}, + expectedSwapIns: []osmomath.Int{osmomath.NewInt(14), osmomath.NewInt(12)}, }, "happy path: one route with swap Fee": { route: []types.SwapAmountOutRoute{ @@ -3107,12 +3107,12 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { TokenInDenom: bar, }, }, - poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(uosmo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100)))}, - cumulativeRouteSpreadFactor: sdk.NewDec(100), - sumOfSpreadFactors: sdk.NewDec(500), + poolCoins: []sdk.Coins{sdk.NewCoins(sdk.NewCoin(uosmo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100)))}, + cumulativeRouteSpreadFactor: osmomath.NewDec(100), + sumOfSpreadFactors: osmomath.NewDec(500), - tokenOut: sdk.NewCoin(uosmo, sdk.NewInt(10)), - expectedSwapIns: []sdk.Int{sdk.NewInt(12)}, + tokenOut: sdk.NewCoin(uosmo, osmomath.NewInt(10)), + expectedSwapIns: []osmomath.Int{osmomath.NewInt(12)}, }, "happy path: two route with swap Fee": { route: []types.SwapAmountOutRoute{ @@ -3127,14 +3127,14 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { }, poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100))), // pool 1. - sdk.NewCoins(sdk.NewCoin(bar, sdk.NewInt(100)), sdk.NewCoin(uosmo, sdk.NewInt(100))), // pool 2. + sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100))), // pool 1. + sdk.NewCoins(sdk.NewCoin(bar, osmomath.NewInt(100)), sdk.NewCoin(uosmo, osmomath.NewInt(100))), // pool 2. }, - cumulativeRouteSpreadFactor: sdk.NewDec(100), - sumOfSpreadFactors: sdk.NewDec(500), + cumulativeRouteSpreadFactor: osmomath.NewDec(100), + sumOfSpreadFactors: osmomath.NewDec(500), - tokenOut: sdk.NewCoin(uosmo, sdk.NewInt(10)), - expectedSwapIns: []sdk.Int{sdk.NewInt(14), sdk.NewInt(12)}, + tokenOut: sdk.NewCoin(uosmo, osmomath.NewInt(10)), + expectedSwapIns: []osmomath.Int{osmomath.NewInt(14), osmomath.NewInt(12)}, }, "error: Invalid Pool": { route: []types.SwapAmountOutRoute{ @@ -3144,9 +3144,9 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { }, }, poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100))), // pool 1. + sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100))), // pool 1. }, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(10)), + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(10)), expectedError: true, }, "error: calculating in given out": { @@ -3158,10 +3158,10 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { }, poolCoins: []sdk.Coins{ - sdk.NewCoins(sdk.NewCoin(foo, sdk.NewInt(100)), sdk.NewCoin(bar, sdk.NewInt(100))), // pool 1. + sdk.NewCoins(sdk.NewCoin(foo, osmomath.NewInt(100)), sdk.NewCoin(bar, osmomath.NewInt(100))), // pool 1. }, - tokenOut: sdk.NewCoin(baz, sdk.NewInt(10)), - expectedSwapIns: []sdk.Int{}, + tokenOut: sdk.NewCoin(baz, osmomath.NewInt(10)), + expectedSwapIns: []osmomath.Int{}, expectedError: true, }, @@ -3173,7 +3173,7 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { suite.createBalancerPoolsFromCoins(tc.poolCoins) - var actualSwapOuts []sdk.Int + var actualSwapOuts []osmomath.Int var err error if !tc.sumOfSpreadFactors.IsNil() && !tc.cumulativeRouteSpreadFactor.IsNil() { @@ -3195,7 +3195,7 @@ func (suite *KeeperTestSuite) TestCreateMultihopExpectedSwapOuts() { // ensuring the resulting values are swapped as intended and sent to the correct destinations. func (s *KeeperTestSuite) TestTakerFee() { var ( - nonZeroTakerFee = sdk.MustNewDecFromStr("0.0015") + nonZeroTakerFee = osmomath.MustNewDecFromStr("0.0015") // Note: all pools have the default amount of 10_000_000_000 in each asset, // meaning in their initial state they have a spot price of 1. quoteNativeDenomRoute = []types.SwapAmountInSplitRoute{ @@ -3231,7 +3231,7 @@ func (s *KeeperTestSuite) TestTakerFee() { TokenInAmount: twentyFiveBaseUnitsAmount, }, } - totalExpectedTakerFee = sdk.NewDecFromInt(twentyFiveBaseUnitsAmount).Mul(nonZeroTakerFee) + totalExpectedTakerFee = osmomath.NewDecFromInt(twentyFiveBaseUnitsAmount).Mul(nonZeroTakerFee) osmoTakerFeeDistr = s.App.PoolManagerKeeper.GetParams(s.Ctx).TakerFeeParams.OsmoTakerFeeDistribution nonOsmoTakerFeeDistr = s.App.PoolManagerKeeper.GetParams(s.Ctx).TakerFeeParams.NonOsmoTakerFeeDistribution ) @@ -3239,9 +3239,9 @@ func (s *KeeperTestSuite) TestTakerFee() { tests := map[string]struct { routes []types.SwapAmountInSplitRoute tokenInDenom string - tokenOutMinAmount sdk.Int + tokenOutMinAmount osmomath.Int - expectedTokenOutEstimate sdk.Int + expectedTokenOutEstimate osmomath.Int expectedTakerFees expectedTakerFees expectedCommunityPoolBalancesDelta sdk.Coins // actual community pool expectedCommunityPoolFeeCollectorBalanceDelta sdk.Coins // where non whitelisted fees are staged prior to being swapped and sent to community pool @@ -3253,7 +3253,7 @@ func (s *KeeperTestSuite) TestTakerFee() { "native denom taker fee": { routes: quoteNativeDenomRoute, tokenInDenom: uosmo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectedTokenOutEstimate: twentyFiveBaseUnitsAmount, expectedTakerFees: expectedTakerFees{ @@ -3267,7 +3267,7 @@ func (s *KeeperTestSuite) TestTakerFee() { "quote denom taker fee": { routes: quoteQuoteDenomRoute, tokenInDenom: foo, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectedTokenOutEstimate: twentyFiveBaseUnitsAmount, expectedTakerFees: expectedTakerFees{ @@ -3278,12 +3278,12 @@ func (s *KeeperTestSuite) TestTakerFee() { // since foo is whitelisted token, it is sent directly to community pool expectedCommunityPoolBalancesDelta: sdk.NewCoins(sdk.NewCoin(foo, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.CommunityPool).TruncateInt())), // foo swapped for uosmo, uosmo sent to main fee collector, 1 uosmo diff due to slippage from swap - expectedStakingRewardFeeCollectorMainBalanceDelta: sdk.NewCoins(sdk.NewCoin(uosmo, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.StakingRewards).Sub(sdk.OneDec()).TruncateInt())), + expectedStakingRewardFeeCollectorMainBalanceDelta: sdk.NewCoins(sdk.NewCoin(uosmo, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.StakingRewards).Sub(osmomath.OneDec()).TruncateInt())), }, "non quote denom taker fee": { routes: quoteNonquoteDenomRoute, tokenInDenom: abc, - tokenOutMinAmount: sdk.OneInt(), + tokenOutMinAmount: osmomath.OneInt(), expectedTokenOutEstimate: twentyFiveBaseUnitsAmount, expectedTakerFees: expectedTakerFees{ @@ -3292,9 +3292,9 @@ func (s *KeeperTestSuite) TestTakerFee() { stakingRewardAssets: sdk.NewCoins(sdk.NewCoin(abc, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.StakingRewards).TruncateInt())), }, // since abc is not whitelisted token, it gets swapped for `CommunityPoolDenomToSwapNonWhitelistedAssetsTo`, which is set to baz, 1 baz diff due to slippage from swap - expectedCommunityPoolBalancesDelta: sdk.NewCoins(sdk.NewCoin(baz, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.CommunityPool).Sub(sdk.OneDec()).TruncateInt())), + expectedCommunityPoolBalancesDelta: sdk.NewCoins(sdk.NewCoin(baz, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.CommunityPool).Sub(osmomath.OneDec()).TruncateInt())), // abc swapped for uosmo, uosmo sent to main fee collector, 1 uosmo diff due to slippage from swap - expectedStakingRewardFeeCollectorMainBalanceDelta: sdk.NewCoins(sdk.NewCoin(uosmo, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.StakingRewards).Sub(sdk.OneDec()).TruncateInt())), + expectedStakingRewardFeeCollectorMainBalanceDelta: sdk.NewCoins(sdk.NewCoin(uosmo, totalExpectedTakerFee.Mul(nonOsmoTakerFeeDistr.StakingRewards).Sub(osmomath.OneDec()).TruncateInt())), }, } @@ -3346,7 +3346,7 @@ func (s *KeeperTestSuite) TestTakerFee() { // As a result, we roughly expect the amount out to be the same // as the amount in given in another token. However, the actual // amount must be stricly less than the given due to price impact. - multiplicativeTolerance := sdk.OneDec() + multiplicativeTolerance := osmomath.OneDec() errTolerance := osmomath.ErrTolerance{ RoundingDir: osmomath.RoundDown, MultiplicativeTolerance: multiplicativeTolerance, diff --git a/x/poolmanager/taker_fee.go b/x/poolmanager/taker_fee.go index 68d3d1d2097..350fad2d48f 100644 --- a/x/poolmanager/taker_fee.go +++ b/x/poolmanager/taker_fee.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/osmoutils" @@ -15,7 +16,7 @@ import ( // 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) { +func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, takerFee osmomath.Dec) { store := ctx.KVStore(k.storeKey) // if given taker fee is equal to the default taker fee, // delete whatever we have in current state to use default taker fee. @@ -29,7 +30,7 @@ func (k Keeper) SetDenomPairTakerFee(ctx sdk.Context, denom0, denom1 string, tak // 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 { +func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, denom0, denom1 string, takerFee osmomath.Dec) error { adminAddresses := k.GetParams(ctx).TakerFeeParams.AdminAddresses isAdmin := false for _, admin := range adminAddresses { @@ -60,14 +61,14 @@ func (k Keeper) SenderValidationSetDenomPairTakerFee(ctx sdk.Context, sender, de // 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) { +func (k Keeper) GetTradingPairTakerFee(ctx sdk.Context, denom0, denom1 string) (osmomath.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 + return osmomath.Dec{}, err } if !found { return k.GetParams(ctx).TakerFeeParams.DefaultTakerFee, nil @@ -105,9 +106,9 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom takerFeeAmtRemaining := takerFeeCoin.Amount if takerFeeCoin.Denom == defaultTakerFeeDenom { // Community Pool: - if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool.GT(osmomath.ZeroDec()) { // Osmo community pool funds is a direct send - osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) + osmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.CommunityPool) osmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(defaultTakerFeeDenom, osmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, osmoTakerFeeToCommunityPoolCoins, sender) if err != nil { @@ -116,7 +117,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom takerFeeAmtRemaining = takerFeeAmtRemaining.Sub(osmoTakerFeeToCommunityPoolCoins.AmountOf(defaultTakerFeeDenom)) } // Staking Rewards: - if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.OsmoTakerFeeDistribution.StakingRewards.GT(osmomath.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(defaultTakerFeeDenom, takerFeeAmtRemaining)) @@ -129,11 +130,11 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // If the denom is not the base denom: } else { // Community Pool: - if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool.GT(osmomath.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) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.communityPoolKeeper.FundCommunityPool(ctx, nonOsmoTakerFeeToCommunityPoolCoins, sender) if err != nil { @@ -143,7 +144,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom } 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) + nonOsmoTakerFeeToCommunityPoolDec := takerFeeAmtRemaining.ToLegacyDec().Mul(poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.CommunityPool) nonOsmoTakerFeeToCommunityPoolCoins := sdk.NewCoins(sdk.NewCoin(tokenIn.Denom, nonOsmoTakerFeeToCommunityPoolDec.TruncateInt())) err := k.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, feeCollectorForCommunityPoolName, nonOsmoTakerFeeToCommunityPoolCoins) if err != nil { @@ -153,7 +154,7 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom } } // Staking Rewards: - if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(sdk.ZeroDec()) { + if poolManagerParams.TakerFeeParams.NonOsmoTakerFeeDistribution.StakingRewards.GT(osmomath.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, feeCollectorForStakingRewardsName, nonOsmoTakerFeeToStakingRewardsCoins) @@ -168,16 +169,16 @@ func (k Keeper) chargeTakerFee(ctx sdk.Context, tokenIn sdk.Coin, tokenOutDenom // 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)) +func (k Keeper) calcTakerFeeExactIn(tokenIn sdk.Coin, takerFee osmomath.Dec) (sdk.Coin, sdk.Coin) { + amountInAfterSubTakerFee := tokenIn.Amount.ToLegacyDec().MulTruncate(osmomath.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)) +func (k Keeper) calcTakerFeeExactOut(tokenIn sdk.Coin, takerFee osmomath.Dec) (sdk.Coin, sdk.Coin) { + amountInAfterAddTakerFee := tokenIn.Amount.ToLegacyDec().Quo(osmomath.OneDec().Sub(takerFee)) tokenInAfterAddTakerFee := sdk.NewCoin(tokenIn.Denom, amountInAfterAddTakerFee.Ceil().TruncateInt()) takerFeeCoin := sdk.NewCoin(tokenIn.Denom, tokenInAfterAddTakerFee.Amount.Sub(tokenIn.Amount)) diff --git a/x/poolmanager/types/errors.go b/x/poolmanager/types/errors.go index 3505923958e..41fd1254483 100644 --- a/x/poolmanager/types/errors.go +++ b/x/poolmanager/types/errors.go @@ -4,7 +4,7 @@ import ( "errors" "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -46,7 +46,7 @@ func (e UndefinedRouteError) Error() string { type FinalAmountIsNotPositiveError struct { IsAmountOut bool - Amount sdk.Int + Amount osmomath.Int } func (e FinalAmountIsNotPositiveError) Error() string { @@ -58,8 +58,8 @@ func (e FinalAmountIsNotPositiveError) Error() string { } type PriceImpactProtectionExactInError struct { - Actual sdk.Int - MinAmount sdk.Int + Actual osmomath.Int + MinAmount osmomath.Int } func (e PriceImpactProtectionExactInError) Error() string { @@ -67,8 +67,8 @@ func (e PriceImpactProtectionExactInError) Error() string { } type PriceImpactProtectionExactOutError struct { - Actual sdk.Int - MaxAmount sdk.Int + Actual osmomath.Int + MaxAmount osmomath.Int } func (e PriceImpactProtectionExactOutError) Error() string { diff --git a/x/poolmanager/types/expected_keepers.go b/x/poolmanager/types/expected_keepers.go index 431191e3260..d182992888b 100644 --- a/x/poolmanager/types/expected_keepers.go +++ b/x/poolmanager/types/expected_keepers.go @@ -3,6 +3,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) @@ -46,7 +48,7 @@ type PoolModuleI interface { poolId uint64, quoteAssetDenom string, baseAssetDenom string, - ) (price sdk.Dec, err error) + ) (price osmomath.Dec, err error) SwapExactAmountIn( ctx sdk.Context, @@ -54,9 +56,9 @@ type PoolModuleI interface { pool PoolI, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - spreadFactor sdk.Dec, - ) (sdk.Int, error) + tokenOutMinAmount osmomath.Int, + spreadFactor osmomath.Dec, + ) (osmomath.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( @@ -64,7 +66,7 @@ type PoolModuleI interface { poolI PoolI, tokenIn sdk.Coin, tokenOutDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (tokenOut sdk.Coin, err error) SwapExactAmountOut( @@ -72,10 +74,10 @@ type PoolModuleI interface { sender sdk.AccAddress, pool PoolI, tokenInDenom string, - tokenInMaxAmount sdk.Int, + tokenInMaxAmount osmomath.Int, tokenOut sdk.Coin, - spreadFactor sdk.Dec, - ) (tokenInAmount sdk.Int, err error) + spreadFactor osmomath.Dec, + ) (tokenInAmount osmomath.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( @@ -83,7 +85,7 @@ type PoolModuleI interface { poolI PoolI, tokenOut sdk.Coin, tokenInDenom string, - spreadFactor sdk.Dec, + spreadFactor osmomath.Dec, ) (tokenIn sdk.Coin, err error) // GetTotalPoolLiquidity returns the coins in the pool owned by all LPs diff --git a/x/poolmanager/types/genesis.pb.go b/x/poolmanager/types/genesis.pb.go index 5e80d223dbf..ee7f9a88117 100644 --- a/x/poolmanager/types/genesis.pb.go +++ b/x/poolmanager/types/genesis.pb.go @@ -4,6 +4,7 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" @@ -166,7 +167,7 @@ func (m *GenesisState) GetPoolRoutes() []ModuleRoute { 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"` + DefaultTakerFee cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=default_taker_fee,json=defaultTakerFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"default_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 @@ -259,8 +260,8 @@ func (m *TakerFeeParams) GetCommunityPoolDenomToSwapNonWhitelistedAssetsTo() str // 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"` + StakingRewards cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=staking_rewards,json=stakingRewards,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"staking_rewards" yaml:"staking_rewards"` + CommunityPool cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=community_pool,json=communityPool,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"community_pool" yaml:"community_pool"` } func (m *TakerFeeDistributionPercentage) Reset() { *m = TakerFeeDistributionPercentage{} } @@ -308,58 +309,59 @@ func init() { } var fileDescriptor_aa099d9fbdf68b35 = []byte{ - // 810 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4f, 0x6f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2, 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, + // 823 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x55, 0x4d, 0x6f, 0xdb, 0x46, + 0x10, 0x35, 0x63, 0xc7, 0x80, 0xd7, 0xa9, 0xd4, 0x10, 0x4d, 0xc3, 0xd8, 0x00, 0x29, 0x30, 0x17, + 0x15, 0x45, 0x48, 0xd8, 0x05, 0x52, 0xf4, 0x23, 0x07, 0xcb, 0x46, 0x8a, 0x02, 0x69, 0xe2, 0x30, + 0x06, 0x0a, 0xe4, 0xb2, 0x58, 0x91, 0x63, 0x9a, 0xb0, 0xb8, 0xa3, 0x72, 0x97, 0x76, 0xd4, 0x5f, + 0x51, 0xa0, 0xd7, 0x9e, 0x7b, 0xe8, 0xad, 0x87, 0xfe, 0x83, 0x1e, 0x72, 0xcc, 0xb1, 0xe8, 0x41, + 0x2d, 0xe4, 0x73, 0x2f, 0xfa, 0x05, 0xc5, 0x7e, 0xc8, 0x36, 0xdd, 0x48, 0x30, 0x9a, 0x93, 0xc4, + 0x99, 0x79, 0x6f, 0xe6, 0xcd, 0xbe, 0x25, 0xc9, 0x47, 0x28, 0x4a, 0x14, 0x85, 0x88, 0x87, 0x88, + 0x83, 0x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80, 0x7b, 0x42, 0xde, 0x97, 0xec, 0x18, + 0x2a, 0x45, 0x45, 0x87, 0x7a, 0x52, 0xef, 0x46, 0xc7, 0xe9, 0xae, 0x6f, 0x7f, 0x1c, 0x2d, 0x38, + 0x94, 0xe8, 0x40, 0x81, 0x1e, 0x03, 0x18, 0x71, 0xbd, 0xc0, 0x4e, 0x79, 0xd7, 0x4c, 0x79, 0x95, + 0x32, 0x4c, 0x5a, 0xb2, 0x01, 0x70, 0x5f, 0x92, 0xbb, 0xac, 0x96, 0x47, 0x58, 0x15, 0xdf, 0x43, + 0x46, 0xbf, 0xab, 0x51, 0x02, 0xcd, 0x80, 0x63, 0x29, 0xbc, 0xe5, 0xce, 0x72, 0x77, 0xad, 0x17, + 0x4e, 0xc7, 0x81, 0x6f, 0xd8, 0xe6, 0x14, 0x86, 0xc9, 0x9d, 0x8b, 0xcc, 0x73, 0x95, 0xd8, 0x33, + 0xf1, 0xdf, 0x1d, 0x72, 0xeb, 0x2b, 0xe3, 0xaf, 0x17, 0x92, 0x49, 0x70, 0x3b, 0xe4, 0x16, 0x87, + 0x57, 0x92, 0xea, 0xe5, 0x15, 0x99, 0xe7, 0x74, 0x9c, 0xee, 0x4a, 0x42, 0x54, 0x6c, 0x1f, 0x71, + 0xf0, 0x75, 0xe6, 0xee, 0x90, 0xd5, 0x86, 0xf8, 0xfb, 0x0b, 0xc5, 0x5b, 0xd1, 0x2b, 0x4a, 0x74, + 0x62, 0x81, 0xee, 0x33, 0xb2, 0xae, 0xf9, 0xf5, 0xf1, 0x1b, 0x15, 0xeb, 0xdb, 0xdd, 0x85, 0x3c, + 0xdf, 0x68, 0xc3, 0x24, 0x0a, 0x60, 0xc9, 0x88, 0x2a, 0xd3, 0x01, 0x11, 0xfe, 0x76, 0x93, 0xb4, + 0x9a, 0x6b, 0x76, 0xfb, 0xe4, 0x76, 0x06, 0x87, 0xac, 0x1e, 0x48, 0x7a, 0xbe, 0x62, 0xad, 0x66, + 0xad, 0xf7, 0x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x74, 0x1c, 0x3c, 0x32, 0xcd, 0xfe, 0x1f, + 0x4f, 0x98, 0x44, 0xe7, 0x40, 0x75, 0x59, 0xf4, 0x1d, 0x3b, 0xc0, 0x17, 0xa7, 0x6c, 0xf8, 0x14, + 0xf9, 0xb7, 0x17, 0x90, 0x1d, 0x8d, 0x38, 0xc0, 0xf0, 0x1f, 0x87, 0xf8, 0x8b, 0xb7, 0xeb, 0x1e, + 0x92, 0xb6, 0x90, 0xec, 0xb8, 0xe0, 0x39, 0xad, 0xe0, 0x94, 0x55, 0x99, 0xb0, 0x2e, 0x7e, 0x74, + 0x0d, 0x17, 0x5f, 0xac, 0xef, 0x0a, 0x47, 0x98, 0xb4, 0x6c, 0x24, 0x31, 0x01, 0x37, 0x25, 0xad, + 0xa6, 0x6a, 0xed, 0xde, 0xb5, 0xde, 0x97, 0xd7, 0x6b, 0x73, 0xe7, 0x6d, 0x8b, 0x0b, 0x93, 0xf7, + 0x1a, 0x0b, 0xe9, 0x3d, 0x7f, 0x3d, 0xf1, 0x9d, 0x37, 0x13, 0xdf, 0xf9, 0x7b, 0xe2, 0x3b, 0x3f, + 0x9c, 0xf9, 0x4b, 0x6f, 0xce, 0xfc, 0xa5, 0x3f, 0xce, 0xfc, 0xa5, 0x97, 0x9f, 0x5e, 0x7a, 0x2f, + 0x5b, 0x2f, 0x3e, 0x18, 0xb0, 0xbe, 0x98, 0x3d, 0xc4, 0x27, 0x5b, 0x9f, 0xc5, 0xaf, 0x1a, 0xdf, + 0x12, 0xfd, 0xb2, 0xee, 0xaf, 0xea, 0xaf, 0xc7, 0x27, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0xa7, + 0x24, 0x16, 0xe1, 0x43, 0x07, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/poolmanager/types/gov_test.go b/x/poolmanager/types/gov_test.go index 87dedc2ece7..2afca32a583 100644 --- a/x/poolmanager/types/gov_test.go +++ b/x/poolmanager/types/gov_test.go @@ -3,10 +3,10 @@ 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/osmomath" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) @@ -15,17 +15,17 @@ func TestDenomPairTakerFeeProposalMarshalUnmarshal(t *testing.T) { { Denom0: "uion", Denom1: "uosmo", - TakerFee: sdk.MustNewDecFromStr("0.0013"), + TakerFee: osmomath.MustNewDecFromStr("0.0013"), }, { Denom0: "stake", Denom1: "uosmo", - TakerFee: sdk.MustNewDecFromStr("0.0016"), + TakerFee: osmomath.MustNewDecFromStr("0.0016"), }, { Denom0: "ibc/27394FB092D2ECCD56123C74F36E4C1F926001CEADA9CA97EA622B25F41E5EB2", Denom1: "uosmo", - TakerFee: sdk.MustNewDecFromStr("0.0017"), + TakerFee: osmomath.MustNewDecFromStr("0.0017"), }, } @@ -67,7 +67,7 @@ func TestDenomPairTakerFeeProposal_ValidateBasic(t *testing.T) { baseRecord := types.DenomPairTakerFee{ Denom0: "uion", Denom1: "uosmo", - TakerFee: sdk.MustNewDecFromStr("0.0013"), + TakerFee: osmomath.MustNewDecFromStr("0.0013"), } withSameDenom := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { @@ -86,7 +86,7 @@ func TestDenomPairTakerFeeProposal_ValidateBasic(t *testing.T) { } withInvalidTakerFee := func(record types.DenomPairTakerFee) types.DenomPairTakerFee { - record.TakerFee = sdk.MustNewDecFromStr("1.01") + record.TakerFee = osmomath.MustNewDecFromStr("1.01") return record } diff --git a/x/poolmanager/types/msgs_test.go b/x/poolmanager/types/msgs_test.go index da5b8f9335c..238224d7dca 100644 --- a/x/poolmanager/types/msgs_test.go +++ b/x/poolmanager/types/msgs_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" appParams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -52,8 +53,8 @@ func TestMsgSwapExactAmountIn(t *testing.T) { properMsg := types.MsgSwapExactAmountIn{ Sender: addr1, Routes: validSwapExactAmountInRoutes, - TokenIn: sdk.NewCoin("test", sdk.NewInt(100)), - TokenOutMinAmount: sdk.NewInt(200), + TokenIn: sdk.NewCoin("test", osmomath.NewInt(100)), + TokenOutMinAmount: osmomath.NewInt(200), } msg := createMsg(properMsg, func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { @@ -127,7 +128,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "zero amount token", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { - msg.TokenIn.Amount = sdk.NewInt(0) + msg.TokenIn.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -135,7 +136,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "negative amount token", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { - msg.TokenIn.Amount = sdk.NewInt(-10) + msg.TokenIn.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -143,7 +144,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "zero amount criteria", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(0) + msg.TokenOutMinAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -151,7 +152,7 @@ func TestMsgSwapExactAmountIn(t *testing.T) { { name: "negative amount criteria", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountIn) types.MsgSwapExactAmountIn { - msg.TokenOutMinAmount = sdk.NewInt(-10) + msg.TokenOutMinAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -179,8 +180,8 @@ func TestMsgSwapExactAmountOut(t *testing.T) { PoolId: 1, TokenInDenom: "test2", }}, - TokenOut: sdk.NewCoin("test", sdk.NewInt(100)), - TokenInMaxAmount: sdk.NewInt(200), + TokenOut: sdk.NewCoin("test", osmomath.NewInt(100)), + TokenInMaxAmount: osmomath.NewInt(200), } msg := createMsg(properMsg, func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { @@ -254,7 +255,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "zero amount token", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { - msg.TokenOut.Amount = sdk.NewInt(0) + msg.TokenOut.Amount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -262,7 +263,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "negative amount token", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { - msg.TokenOut.Amount = sdk.NewInt(-10) + msg.TokenOut.Amount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -270,7 +271,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "zero amount criteria", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(0) + msg.TokenInMaxAmount = osmomath.NewInt(0) return msg }), expectPass: false, @@ -278,7 +279,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { { name: "negative amount criteria", msg: createMsg(properMsg, func(msg types.MsgSwapExactAmountOut) types.MsgSwapExactAmountOut { - msg.TokenInMaxAmount = sdk.NewInt(-10) + msg.TokenInMaxAmount = osmomath.NewInt(-10) return msg }), expectPass: false, @@ -296,7 +297,7 @@ func TestMsgSwapExactAmountOut(t *testing.T) { // Test authz serialize and de-serializes for poolmanager msg. func TestAuthzMsg(t *testing.T) { - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)) testCases := []struct { name string @@ -314,7 +315,7 @@ func TestAuthzMsg(t *testing.T) { TokenOutDenom: "test2", }}, TokenIn: coin, - TokenOutMinAmount: sdk.NewInt(1), + TokenOutMinAmount: osmomath.NewInt(1), }, }, { @@ -329,7 +330,7 @@ func TestAuthzMsg(t *testing.T) { TokenInDenom: "test2", }}, TokenOut: coin, - TokenInMaxAmount: sdk.NewInt(1), + TokenInMaxAmount: osmomath.NewInt(1), }, }, } @@ -344,13 +345,13 @@ func TestMsgSplitRouteSwapExactAmountIn(t *testing.T) { var ( validMultihopRouteOne = types.SwapAmountInSplitRoute{ Pools: validSwapExactAmountInRoutes, - TokenInAmount: sdk.OneInt(), + TokenInAmount: osmomath.OneInt(), } validMultihopRouteTwo = types.SwapAmountInSplitRoute{ Pools: []types.SwapAmountInRoute{ validSwapRoutePoolThreeAmountIn, }, - TokenInAmount: sdk.OneInt(), + TokenInAmount: osmomath.OneInt(), } defaultValidMsg = types.MsgSplitRouteSwapExactAmountIn{ @@ -360,7 +361,7 @@ func TestMsgSplitRouteSwapExactAmountIn(t *testing.T) { validMultihopRouteTwo, }, TokenInDenom: "udai", - TokenOutMinAmount: sdk.OneInt(), + TokenOutMinAmount: osmomath.OneInt(), } ) msg := createMsg(defaultValidMsg, func(msg types.MsgSplitRouteSwapExactAmountIn) types.MsgSplitRouteSwapExactAmountIn { @@ -426,7 +427,7 @@ func TestMsgSplitRouteSwapExactAmountIn(t *testing.T) { }, "invalid token out min amount": { msg: createMsg(defaultValidMsg, func(msg types.MsgSplitRouteSwapExactAmountIn) types.MsgSplitRouteSwapExactAmountIn { - msg.TokenOutMinAmount = sdk.ZeroInt() + msg.TokenOutMinAmount = osmomath.ZeroInt() return msg }), expectError: true, @@ -458,13 +459,13 @@ func TestMsgSplitRouteSwapExactAmountOut(t *testing.T) { var ( validMultihopRouteOne = types.SwapAmountOutSplitRoute{ Pools: validSwapExactAmountOutRoutes, - TokenOutAmount: sdk.OneInt(), + TokenOutAmount: osmomath.OneInt(), } validMultihopRouteTwo = types.SwapAmountOutSplitRoute{ Pools: []types.SwapAmountOutRoute{ validSwapRoutePoolThreeAmountOut, }, - TokenOutAmount: sdk.OneInt(), + TokenOutAmount: osmomath.OneInt(), } defaultValidMsg = types.MsgSplitRouteSwapExactAmountOut{ @@ -474,7 +475,7 @@ func TestMsgSplitRouteSwapExactAmountOut(t *testing.T) { validMultihopRouteTwo, }, TokenOutDenom: "udai", - TokenInMaxAmount: sdk.OneInt(), + TokenInMaxAmount: osmomath.OneInt(), } ) msg := createMsg(defaultValidMsg, func(msg types.MsgSplitRouteSwapExactAmountOut) types.MsgSplitRouteSwapExactAmountOut { @@ -540,7 +541,7 @@ func TestMsgSplitRouteSwapExactAmountOut(t *testing.T) { }, "invalid token in max amount": { msg: createMsg(defaultValidMsg, func(msg types.MsgSplitRouteSwapExactAmountOut) types.MsgSplitRouteSwapExactAmountOut { - msg.TokenInMaxAmount = sdk.ZeroInt() + msg.TokenInMaxAmount = osmomath.ZeroInt() return msg }), expectError: true, @@ -576,12 +577,12 @@ func TestMsgSetDenomPairTakerFee(t *testing.T) { { Denom0: "uosmo", Denom1: "uatom", - TakerFee: sdk.MustNewDecFromStr("0.003"), + TakerFee: osmomath.MustNewDecFromStr("0.003"), }, { Denom0: "uosmo", Denom1: "uion", - TakerFee: sdk.MustNewDecFromStr("0.006"), + TakerFee: osmomath.MustNewDecFromStr("0.006"), }, }, } diff --git a/x/poolmanager/types/params.go b/x/poolmanager/types/params.go index 0e667a5e638..1ca486a1f33 100644 --- a/x/poolmanager/types/params.go +++ b/x/poolmanager/types/params.go @@ -3,6 +3,7 @@ package types import ( "fmt" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" sdk "github.com/cosmos/cosmos-sdk/types" @@ -26,7 +27,7 @@ func ParamKeyTable() paramtypes.KeyTable { } func NewParams(poolCreationFee sdk.Coins, - defaultTakerFee sdk.Dec, + defaultTakerFee osmomath.Dec, osmoTakerFeeDistribution, nonOsmoTakerFeeDistribution TakerFeeDistributionPercentage, adminAddresses, authorizedQuoteDenoms []string, communityPoolDenomToSwapNonWhitelistedAssetsTo string) Params { @@ -48,14 +49,14 @@ func DefaultParams() Params { return Params{ PoolCreationFee: sdk.Coins{sdk.NewInt64Coin(appparams.BaseCoinUnit, 1000_000_000)}, // 1000 OSMO TakerFeeParams: TakerFeeParams{ - DefaultTakerFee: sdk.ZeroDec(), // 0% + DefaultTakerFee: osmomath.ZeroDec(), // 0% OsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("1"), // 100% - CommunityPool: sdk.MustNewDecFromStr("0"), // 0% + StakingRewards: osmomath.MustNewDecFromStr("1"), // 100% + CommunityPool: osmomath.MustNewDecFromStr("0"), // 0% }, NonOsmoTakerFeeDistribution: TakerFeeDistributionPercentage{ - StakingRewards: sdk.MustNewDecFromStr("0.67"), // 67% - CommunityPool: sdk.MustNewDecFromStr("0.33"), // 33% + StakingRewards: osmomath.MustNewDecFromStr("0.67"), // 67% + CommunityPool: osmomath.MustNewDecFromStr("0.33"), // 33% }, AdminAddresses: []string{}, CommunityPoolDenomToSwapNonWhitelistedAssetsTo: "ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", // USDC @@ -123,15 +124,15 @@ func validatePoolCreationFee(i interface{}) error { } func validateDefaultTakerFee(i interface{}) error { - // Convert the given parameter to sdk.Dec. - defaultTakerFee, ok := i.(sdk.Dec) + // Convert the given parameter to osmomath.Dec. + defaultTakerFee, ok := i.(osmomath.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()) { + if defaultTakerFee.IsNegative() || defaultTakerFee.GT(osmomath.OneDec()) { return fmt.Errorf("invalid default taker fee: %s", defaultTakerFee) } @@ -139,17 +140,17 @@ func validateDefaultTakerFee(i interface{}) error { } func validateTakerFeeDistribution(i interface{}) error { - // Convert the given parameter to sdk.Dec. + // Convert the given parameter to osmomath.Dec. takerFeeDistribution, ok := i.(TakerFeeDistributionPercentage) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if takerFeeDistribution.StakingRewards.IsNegative() || takerFeeDistribution.StakingRewards.GT(sdk.OneDec()) { + if takerFeeDistribution.StakingRewards.IsNegative() || takerFeeDistribution.StakingRewards.GT(osmomath.OneDec()) { return fmt.Errorf("invalid staking rewards distribution: %s", takerFeeDistribution.StakingRewards) } - if takerFeeDistribution.CommunityPool.IsNegative() || takerFeeDistribution.CommunityPool.GT(sdk.OneDec()) { + if takerFeeDistribution.CommunityPool.IsNegative() || takerFeeDistribution.CommunityPool.GT(osmomath.OneDec()) { return fmt.Errorf("invalid community pool distribution: %s", takerFeeDistribution.CommunityPool) } @@ -235,7 +236,7 @@ func validateDenomPairTakerFees(pairs []DenomPairTakerFee) error { } takerFee := record.TakerFee - if takerFee.IsNegative() || takerFee.GTE(sdk.OneDec()) { + if takerFee.IsNegative() || takerFee.GTE(osmomath.OneDec()) { return fmt.Errorf("taker fee must be between 0 and 1: %s", takerFee.String()) } } diff --git a/x/poolmanager/types/pool.go b/x/poolmanager/types/pool.go index 5ce2f1b5d4d..4dd9e3e2d57 100644 --- a/x/poolmanager/types/pool.go +++ b/x/poolmanager/types/pool.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" proto "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) @@ -18,7 +19,7 @@ type PoolI interface { // Pools may choose to make their spread factors dependent upon state // (prior TWAPs, network downtime, other pool states, etc.) // hence Context is provided as an argument. - GetSpreadFactor(ctx sdk.Context) sdk.Dec + GetSpreadFactor(ctx sdk.Context) osmomath.Dec // Returns whether the pool has swaps enabled at the moment IsActive(ctx sdk.Context) bool @@ -26,7 +27,7 @@ type PoolI interface { // errors if either baseAssetDenom, or quoteAssetDenom does not exist. // For example, if this was a UniV2 50-50 pool, with 2 ETH, and 8000 UST // pool.SpotPrice(ctx, "eth", "ust") = 4000.00 - SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (sdk.Dec, error) + SpotPrice(ctx sdk.Context, quoteAssetDenom string, baseAssetDenom string) (osmomath.Dec, error) // GetType returns the type of the pool (Balancer, Stableswap, Concentrated, etc.) GetType() PoolType // AsSerializablePool returns the pool in a serializable form (useful when a model wraps the proto) diff --git a/x/poolmanager/types/routes_test.go b/x/poolmanager/types/routes_test.go index c1dece9f26a..3236a0a7a20 100644 --- a/x/poolmanager/types/routes_test.go +++ b/x/poolmanager/types/routes_test.go @@ -3,8 +3,9 @@ package types import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -15,7 +16,7 @@ const ( ) var ( - twentyFiveBaseUnitsAmount = sdk.NewInt(25_000_000) + twentyFiveBaseUnitsAmount = osmomath.NewInt(25_000_000) // Note: These are iniialized in such a way as it makes // it easier to reason about the test cases. @@ -71,7 +72,7 @@ var ( TokenOutDenom: baz, }, }, - TokenInAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), + TokenInAmount: osmomath.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } // Amount out default routes @@ -119,7 +120,7 @@ var ( TokenInDenom: uosmo, }, }, - TokenOutAmount: sdk.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), + TokenOutAmount: osmomath.NewInt(twentyFiveBaseUnitsAmount.Int64() * 3), } ) @@ -151,7 +152,7 @@ func TestValidateSwapAmountInSplitRoute(t *testing.T) { routes: []SwapAmountInSplitRoute{ { Pools: []SwapAmountInRoute{}, - TokenInAmount: sdk.OneInt(), + TokenInAmount: osmomath.OneInt(), }, }, expectErr: ErrEmptyRoutes, @@ -167,7 +168,7 @@ func TestValidateSwapAmountInSplitRoute(t *testing.T) { TokenOutDenom: bar, }, }, - TokenInAmount: sdk.OneInt(), + TokenInAmount: osmomath.OneInt(), }, { Pools: []SwapAmountInRoute{ @@ -176,7 +177,7 @@ func TestValidateSwapAmountInSplitRoute(t *testing.T) { TokenOutDenom: baz, }, }, - TokenInAmount: sdk.OneInt(), + TokenInAmount: osmomath.OneInt(), }, }, expectErr: InvalidFinalTokenOutError{TokenOutGivenA: bar, TokenOutGivenB: baz}, @@ -233,7 +234,7 @@ func TestValidateSwapAmountOutSplitRoute(t *testing.T) { routes: []SwapAmountOutSplitRoute{ { Pools: []SwapAmountOutRoute{}, - TokenOutAmount: sdk.OneInt(), + TokenOutAmount: osmomath.OneInt(), }, }, expectErr: ErrEmptyRoutes, @@ -249,7 +250,7 @@ func TestValidateSwapAmountOutSplitRoute(t *testing.T) { TokenInDenom: bar, }, }, - TokenOutAmount: sdk.OneInt(), + TokenOutAmount: osmomath.OneInt(), }, { Pools: []SwapAmountOutRoute{ @@ -258,7 +259,7 @@ func TestValidateSwapAmountOutSplitRoute(t *testing.T) { TokenInDenom: baz, }, }, - TokenOutAmount: sdk.OneInt(), + TokenOutAmount: osmomath.OneInt(), }, }, expectErr: InvalidFinalTokenOutError{TokenOutGivenA: bar, TokenOutGivenB: baz}, diff --git a/x/poolmanager/types/swap_route.pb.go b/x/poolmanager/types/swap_route.pb.go index dc56c732ada..06934a402b7 100644 --- a/x/poolmanager/types/swap_route.pb.go +++ b/x/poolmanager/types/swap_route.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -129,8 +129,8 @@ func (m *SwapAmountOutRoute) GetTokenInDenom() string { } type SwapAmountInSplitRoute struct { - Pools []SwapAmountInRoute `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools" yaml:"pools"` - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + Pools []SwapAmountInRoute `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools" yaml:"pools"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *SwapAmountInSplitRoute) Reset() { *m = SwapAmountInSplitRoute{} } @@ -174,8 +174,8 @@ func (m *SwapAmountInSplitRoute) GetPools() []SwapAmountInRoute { } type SwapAmountOutSplitRoute struct { - Pools []SwapAmountOutRoute `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools" yaml:"pools"` - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + Pools []SwapAmountOutRoute `protobuf:"bytes,1,rep,name=pools,proto3" json:"pools" yaml:"pools"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *SwapAmountOutSplitRoute) Reset() { *m = SwapAmountOutSplitRoute{} } @@ -230,35 +230,35 @@ func init() { } var fileDescriptor_cddd97a9a05492a8 = []byte{ - // 446 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x4d, 0x8f, 0x93, 0x40, - 0x18, 0xc7, 0x19, 0x5f, 0xd6, 0x38, 0xae, 0x55, 0xc9, 0xba, 0x5b, 0xd7, 0x04, 0x1a, 0x0e, 0xa6, - 0x89, 0x76, 0x26, 0xd5, 0x83, 0xd1, 0x8b, 0x91, 0x78, 0x90, 0x53, 0x23, 0xbd, 0xd5, 0x03, 0x19, - 0x0a, 0x41, 0x52, 0x98, 0x21, 0x9d, 0xa1, 0xb5, 0x57, 0xe3, 0x07, 0xf0, 0x63, 0xf5, 0xd8, 0xa3, - 0xf1, 0x40, 0x4c, 0x9b, 0x78, 0xf1, 0xc6, 0x27, 0x30, 0x0c, 0x60, 0xa1, 0x26, 0x8d, 0x7a, 0x62, - 0x5e, 0x9e, 0x97, 0xdf, 0xff, 0xcf, 0x33, 0xf0, 0x09, 0xe3, 0x31, 0xe3, 0x21, 0xc7, 0x09, 0x63, - 0x51, 0x4c, 0x28, 0x09, 0xfc, 0x39, 0x5e, 0x0c, 0x5d, 0x5f, 0x90, 0x21, 0xe6, 0x4b, 0x92, 0x38, - 0x73, 0x96, 0x0a, 0x1f, 0x25, 0x73, 0x26, 0x98, 0xfa, 0xb0, 0x8a, 0x46, 0x8d, 0x68, 0x54, 0x45, - 0x5f, 0x9e, 0x05, 0x2c, 0x60, 0x32, 0x0e, 0x17, 0xab, 0x32, 0xc5, 0xf8, 0x0c, 0xe0, 0xbd, 0xf1, - 0x92, 0x24, 0xaf, 0x63, 0x96, 0x52, 0x61, 0x51, 0xbb, 0x28, 0xa7, 0x3e, 0x86, 0x37, 0x8a, 0x12, - 0x4e, 0xe8, 0x75, 0x41, 0x0f, 0xf4, 0xaf, 0x99, 0x6a, 0x9e, 0xe9, 0x9d, 0x15, 0x89, 0xa3, 0x97, - 0x46, 0x75, 0x61, 0xd8, 0x27, 0xc5, 0xca, 0xf2, 0x54, 0x13, 0xde, 0x11, 0x6c, 0xe6, 0x53, 0x87, - 0xa5, 0xc2, 0xf1, 0x7c, 0xca, 0xe2, 0xee, 0x95, 0x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3b, 0xf5, 0x68, 0x95, - 0x64, 0xe6, 0xbb, 0xf5, 0x56, 0x03, 0x9b, 0xad, 0x06, 0xbe, 0x6f, 0x35, 0xf0, 0x65, 0xa7, 0x29, - 0x9b, 0x9d, 0xa6, 0x7c, 0xdd, 0x69, 0xca, 0xe4, 0x79, 0xa3, 0x59, 0x25, 0x73, 0x10, 0x11, 0x97, - 0xd7, 0x1b, 0xbc, 0x18, 0xbe, 0xc0, 0x1f, 0x5b, 0x6f, 0x4f, 0x12, 0xb8, 0x27, 0xf2, 0xf1, 0x3c, - 0xfb, 0x15, 0x00, 0x00, 0xff, 0xff, 0x76, 0x59, 0xb3, 0xd3, 0x9f, 0x03, 0x00, 0x00, + // 443 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0xbb, 0xae, 0xd3, 0x30, + 0x1c, 0xc6, 0x63, 0x2e, 0x07, 0x61, 0x0e, 0x05, 0xa2, 0x73, 0x29, 0x45, 0x4a, 0xaa, 0x4c, 0x95, + 0x00, 0x5b, 0x85, 0xa1, 0xc0, 0x82, 0x88, 0x58, 0x32, 0x55, 0xa4, 0x5b, 0x19, 0x22, 0xa7, 0x89, + 0xd2, 0xa8, 0x89, 0x1d, 0xd5, 0x4e, 0x4b, 0x57, 0xc4, 0x03, 0xf0, 0x58, 0x1d, 0xbb, 0x20, 0xa1, + 0x0e, 0x11, 0x6a, 0xdf, 0x20, 0x4f, 0x80, 0x72, 0xa3, 0x49, 0x91, 0x0a, 0x3a, 0x9b, 0x2f, 0xff, + 0xcf, 0xff, 0xdf, 0xf7, 0xd9, 0x86, 0x2f, 0x18, 0x0f, 0x19, 0xf7, 0x39, 0x8e, 0x18, 0x0b, 0x42, + 0x42, 0x89, 0xe7, 0xce, 0xf1, 0xa2, 0x6f, 0xbb, 0x82, 0xf4, 0x31, 0x5f, 0x92, 0xc8, 0x9a, 0xb3, + 0x58, 0xb8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5b, 0x55, 0x7e, 0x3e, 0xb5, 0x48, 0x2e, 0x2b, + 0xc1, 0x07, 0x99, 0x6a, 0x9b, 0xa8, 0x97, 0x93, 0xbc, 0x1b, 0x77, 0x66, 0xc8, 0x67, 0x38, 0x24, + 0x62, 0x8a, 0x0c, 0x2a, 0x8e, 0xc3, 0xfd, 0xa3, 0xae, 0xc2, 0x35, 0x68, 0x01, 0xa1, 0x6d, 0x01, + 0xbc, 0x6e, 0x84, 0x5b, 0x33, 0xf6, 0xb9, 0x69, 0x0c, 0xff, 0xa7, 0xb1, 0xea, 0x86, 0x4e, 0x3b, + 0xb3, 0xe1, 0xe3, 0xc3, 0xc5, 0x37, 0xac, 0xbd, 0xf9, 0x97, 0xb5, 0xeb, 0xe3, 0x77, 0x53, 0x79, + 0x6b, 0x55, 0x0f, 0xa7, 0x00, 0xd1, 0x3f, 0xad, 0x77, 0x0a, 0xd8, 0xec, 0x14, 0xf0, 0x6b, 0xa7, + 0x80, 0xef, 0x7b, 0x45, 0xda, 0xec, 0x15, 0xe9, 0xe7, 0x5e, 0x91, 0xc6, 0x03, 0xcf, 0x17, 0xd3, + 0xd8, 0x46, 0x13, 0x16, 0xe2, 0xd2, 0xd5, 0xcb, 0x80, 0xd8, 0xbc, 0x9a, 0xe0, 0x45, 0xff, 0x2d, + 0xfe, 0xd2, 0xf8, 0x59, 0x62, 0x15, 0xb9, 0xdc, 0x3e, 0xcb, 0xbf, 0xc6, 0xeb, 0xdf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x84, 0x58, 0x0e, 0xcc, 0x7d, 0x03, 0x00, 0x00, } func (m *SwapAmountInRoute) Marshal() (dAtA []byte, err error) { diff --git a/x/poolmanager/types/tx.pb.go b/x/poolmanager/types/tx.pb.go index 1d9e03c3197..00d7324f5fc 100644 --- a/x/poolmanager/types/tx.pb.go +++ b/x/poolmanager/types/tx.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/gogo/protobuf/gogoproto" @@ -33,10 +33,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // ===================== MsgSwapExactAmountIn type MsgSwapExactAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []SwapAmountInRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` - TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountInRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenIn types.Coin `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in" yaml:"token_in"` + TokenOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` } func (m *MsgSwapExactAmountIn) Reset() { *m = MsgSwapExactAmountIn{} } @@ -94,7 +94,7 @@ func (m *MsgSwapExactAmountIn) GetTokenIn() types.Coin { } type MsgSwapExactAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *MsgSwapExactAmountInResponse) Reset() { *m = MsgSwapExactAmountInResponse{} } @@ -132,10 +132,10 @@ var xxx_messageInfo_MsgSwapExactAmountInResponse proto.InternalMessageInfo // ===================== MsgSplitRouteSwapExactAmountIn type MsgSplitRouteSwapExactAmountIn struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []SwapAmountInSplitRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenInDenom string `protobuf:"bytes,3,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty" yaml:"token_in_denom"` - TokenOutMinAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountInSplitRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenInDenom string `protobuf:"bytes,3,opt,name=token_in_denom,json=tokenInDenom,proto3" json:"token_in_denom,omitempty" yaml:"token_in_denom"` + TokenOutMinAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_out_min_amount,json=tokenOutMinAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_min_amount" yaml:"token_out_min_amount"` } func (m *MsgSplitRouteSwapExactAmountIn) Reset() { *m = MsgSplitRouteSwapExactAmountIn{} } @@ -193,7 +193,7 @@ func (m *MsgSplitRouteSwapExactAmountIn) GetTokenInDenom() string { } type MsgSplitRouteSwapExactAmountInResponse struct { - TokenOutAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_amount" yaml:"token_out_amount"` + TokenOutAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_out_amount,json=tokenOutAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_out_amount" yaml:"token_out_amount"` } func (m *MsgSplitRouteSwapExactAmountInResponse) Reset() { @@ -233,10 +233,10 @@ var xxx_messageInfo_MsgSplitRouteSwapExactAmountInResponse proto.InternalMessage // ===================== MsgSwapExactAmountOut type MsgSwapExactAmountOut struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` - TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountOutRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` + TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out" yaml:"token_out"` } func (m *MsgSwapExactAmountOut) Reset() { *m = MsgSwapExactAmountOut{} } @@ -294,7 +294,7 @@ func (m *MsgSwapExactAmountOut) GetTokenOut() types.Coin { } type MsgSwapExactAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *MsgSwapExactAmountOutResponse) Reset() { *m = MsgSwapExactAmountOutResponse{} } @@ -332,10 +332,10 @@ var xxx_messageInfo_MsgSwapExactAmountOutResponse proto.InternalMessageInfo // ===================== MsgSplitRouteSwapExactAmountOut type MsgSplitRouteSwapExactAmountOut struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` - Routes []SwapAmountOutSplitRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` - TokenOutDenom string `protobuf:"bytes,3,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty" yaml:"token_out_denom"` - TokenInMaxAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty" yaml:"sender"` + Routes []SwapAmountOutSplitRoute `protobuf:"bytes,2,rep,name=routes,proto3" json:"routes"` + TokenOutDenom string `protobuf:"bytes,3,opt,name=token_out_denom,json=tokenOutDenom,proto3" json:"token_out_denom,omitempty" yaml:"token_out_denom"` + TokenInMaxAmount cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=token_in_max_amount,json=tokenInMaxAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_max_amount" yaml:"token_in_max_amount"` } func (m *MsgSplitRouteSwapExactAmountOut) Reset() { *m = MsgSplitRouteSwapExactAmountOut{} } @@ -393,7 +393,7 @@ func (m *MsgSplitRouteSwapExactAmountOut) GetTokenOutDenom() string { } type MsgSplitRouteSwapExactAmountOutResponse struct { - TokenInAmount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_in_amount" yaml:"token_in_amount"` + TokenInAmount cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=token_in_amount,json=tokenInAmount,proto3,customtype=cosmossdk.io/math.Int" json:"token_in_amount" yaml:"token_in_amount"` } func (m *MsgSplitRouteSwapExactAmountOutResponse) Reset() { @@ -531,9 +531,9 @@ 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"` + 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 cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=taker_fee,json=takerFee,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"taker_fee" yaml:"taker_fee"` } func (m *DenomPairTakerFee) Reset() { *m = DenomPairTakerFee{} } @@ -602,69 +602,69 @@ func init() { } var fileDescriptor_acd130b4825d67dc = []byte{ - // 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, 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, - 0x6e, 0x25, 0x7a, 0xd3, 0xc6, 0xce, 0xf3, 0xfa, 0x7f, 0x7e, 0xe7, 0xd1, 0x09, 0xbc, 0x41, 0xa8, - 0x4f, 0xa8, 0x47, 0xad, 0x80, 0x90, 0x5d, 0xdf, 0xc5, 0x6e, 0x1f, 0x0d, 0xac, 0xc7, 0x8d, 0x2e, - 0x62, 0x6e, 0xc3, 0x62, 0x43, 0x33, 0x18, 0x10, 0x46, 0xb4, 0x55, 0x65, 0x65, 0x4e, 0x58, 0x99, - 0xca, 0xaa, 0x52, 0xea, 0x93, 0x3e, 0x11, 0x76, 0x16, 0xff, 0x24, 0x5d, 0x2a, 0x45, 0xd7, 0xf7, - 0x30, 0xb1, 0xc4, 0x5f, 0xf5, 0xaa, 0xda, 0x13, 0x61, 0xac, 0xae, 0x4b, 0x51, 0x9c, 0xa3, 0x47, - 0x3c, 0xac, 0xbe, 0x7f, 0x37, 0xab, 0x16, 0xfa, 0xc4, 0x0d, 0x9c, 0x01, 0x09, 0x19, 0x92, 0xd6, - 0xfa, 0xf7, 0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0xb9, 0x57, 0x05, - 0xaf, 0xf6, 0xaa, 0xe0, 0xaf, 0xbd, 0x2a, 0x78, 0xb1, 0x5f, 0x9d, 0x7b, 0xb5, 0x5f, 0x9d, 0xfb, - 0x63, 0xbf, 0x3a, 0xf7, 0xf9, 0xfb, 0x13, 0xc7, 0x48, 0x65, 0x30, 0x76, 0xdd, 0x2e, 0x8d, 0x1e, - 0xac, 0xc7, 0x8d, 0x3b, 0xd6, 0xf0, 0xd0, 0x5a, 0x11, 0x67, 0xab, 0xbb, 0x20, 0x7e, 0xf1, 0xdd, - 0xfa, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x8b, 0xab, 0x1c, 0xe7, 0xad, 0x0e, 0x00, 0x00, + // 991 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x97, 0x4d, 0x6f, 0x1b, 0x45, + 0x18, 0xc7, 0x33, 0x4e, 0x48, 0x93, 0x29, 0x6d, 0xe3, 0xc5, 0x21, 0xae, 0x53, 0xec, 0x68, 0x5b, + 0x81, 0x83, 0xd8, 0x5d, 0x9c, 0x56, 0x2a, 0x75, 0x22, 0x21, 0xdc, 0x80, 0x14, 0xa9, 0x96, 0xdb, + 0xa5, 0x27, 0x2e, 0xab, 0xb1, 0x33, 0xb8, 0x4b, 0xb2, 0x3b, 0x96, 0x67, 0xb6, 0x75, 0x6e, 0x80, + 0x7a, 0x8a, 0x38, 0xf0, 0x0d, 0x90, 0xf8, 0x04, 0x7c, 0x03, 0xae, 0x3d, 0xf6, 0x88, 0x38, 0x58, + 0x28, 0x41, 0xe2, 0xee, 0x13, 0x12, 0x08, 0xd0, 0xbc, 0xec, 0xda, 0x5e, 0x6f, 0xfc, 0x92, 0x88, + 0x5c, 0x22, 0xef, 0xec, 0xf3, 0xfa, 0x7f, 0x7e, 0xfb, 0x68, 0x02, 0xef, 0x10, 0xea, 0x11, 0xea, + 0x52, 0xab, 0x45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, 0xc7, 0xcb, + 0x86, 0xa0, 0xc8, 0x21, 0xb8, 0x9d, 0x08, 0x01, 0x6f, 0x71, 0x60, 0xfe, 0xdf, 0x01, 0xf8, 0xee, + 0x78, 0xe9, 0x2f, 0x95, 0x84, 0x7f, 0x53, 0x70, 0x75, 0x14, 0xc7, 0x5a, 0xc0, 0x66, 0x01, 0xa0, + 0x1a, 0x03, 0xc0, 0x9a, 0x12, 0x80, 0x5a, 0x90, 0x38, 0xfc, 0xaf, 0xe0, 0x5b, 0xd1, 0x70, 0x3d, + 0xd4, 0x09, 0x5b, 0x97, 0x04, 0x6c, 0x4f, 0x6a, 0x3d, 0x17, 0xc3, 0xa3, 0x1f, 0x41, 0xb7, 0x57, + 0x14, 0x23, 0x55, 0xd4, 0x91, 0x15, 0x68, 0x8f, 0xe1, 0x72, 0x24, 0x92, 0x80, 0x63, 0xec, 0xf2, + 0xc9, 0xaa, 0xe5, 0xb3, 0x12, 0x93, 0x57, 0xb7, 0x97, 0x42, 0x5d, 0xcb, 0x26, 0x47, 0x61, 0x73, + 0xba, 0x7d, 0xc0, 0x5d, 0xbf, 0x06, 0xf0, 0x9d, 0xc4, 0x09, 0x44, 0x1c, 0x38, 0xf0, 0x46, 0xd4, + 0xcd, 0x10, 0x06, 0xf7, 0x27, 0x69, 0xf1, 0x76, 0x4c, 0x8b, 0x50, 0x87, 0x6b, 0x4a, 0x07, 0x05, + 0xc1, 0x5f, 0x29, 0x58, 0x18, 0xc7, 0xe4, 0x8c, 0x38, 0xd8, 0x31, 0x1c, 0xee, 0x4d, 0x8f, 0xc3, + 0x99, 0x0b, 0xa1, 0x12, 0x6a, 0xc0, 0x61, 0x1e, 0xdc, 0x08, 0xb9, 0x78, 0x9b, 0x91, 0x41, 0xd8, + 0x66, 0x2d, 0x60, 0x72, 0x27, 0x9c, 0xc1, 0xd5, 0xc2, 0xff, 0xc0, 0x55, 0x79, 0x93, 0x53, 0x70, + 0x67, 0xe2, 0x42, 0xe0, 0x00, 0x1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, 0xe9, 0xfc, 0x12, 0x40, + 0x2d, 0x61, 0x13, 0x6d, 0xcd, 0x18, 0xb1, 0x16, 0xb0, 0x5c, 0x79, 0x76, 0x9f, 0xa8, 0x8c, 0x1f, + 0x00, 0x5c, 0x1f, 0x77, 0x53, 0xda, 0x9e, 0x18, 0xfb, 0x6c, 0xe7, 0xdc, 0xc3, 0x0b, 0x38, 0x47, + 0x15, 0xfe, 0x08, 0xe0, 0xad, 0xb1, 0xcb, 0x7b, 0xe7, 0xdc, 0x59, 0xb8, 0x78, 0xbb, 0x17, 0xf1, + 0x8e, 0x8a, 0x3c, 0x06, 0x30, 0x93, 0xb8, 0x56, 0xee, 0x4d, 0x0c, 0x9f, 0xe0, 0x95, 0xdb, 0x39, + 0x8f, 0x57, 0x58, 0x4c, 0xe5, 0xc9, 0xab, 0x93, 0x3c, 0x78, 0x7d, 0x92, 0x07, 0xbf, 0x9d, 0xe4, + 0xc1, 0xf7, 0xa7, 0xf9, 0xb9, 0xd7, 0xa7, 0xf9, 0xb9, 0x5f, 0x4e, 0xf3, 0x73, 0x5f, 0xdc, 0x6f, + 0xba, 0xec, 0x59, 0x50, 0x37, 0x1b, 0xc4, 0xb3, 0x54, 0x06, 0xe3, 0x10, 0xd5, 0x69, 0xf8, 0x60, + 0x3d, 0x2f, 0x3d, 0xb0, 0x3a, 0x43, 0xbb, 0x84, 0x1d, 0xb5, 0x30, 0xad, 0x2f, 0x8a, 0x7f, 0xaf, + 0xee, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x40, 0x9e, 0x43, 0x97, 0x1a, 0x0e, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/protorev/client/cli/utils.go b/x/protorev/client/cli/utils.go index e1b0078be3d..8ec786929db 100644 --- a/x/protorev/client/cli/utils.go +++ b/x/protorev/client/cli/utils.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" flag "github.com/spf13/pflag" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -75,7 +76,7 @@ func (release *createArbRoutesInput) extractTokenPairArbRoutes() []types.TokenPa for _, arbRoute := range hotRoute.ArbRoutes { currentArbRoute := types.Route{} - currentArbRoute.StepSize = sdk.NewIntFromUint64(arbRoute.StepSize) + currentArbRoute.StepSize = osmomath.NewIntFromUint64(arbRoute.StepSize) for _, trade := range arbRoute.Trades { currentTrade := types.Trade{} @@ -270,7 +271,7 @@ func BuildSetBaseDenomsMsg(clientCtx client.Context, args []string, fs *flag.Fla for _, baseDenom := range *input { baseDenoms = append(baseDenoms, types.BaseDenom{ Denom: baseDenom.Denom, - StepSize: sdk.NewIntFromUint64(baseDenom.StepSize), + StepSize: osmomath.NewIntFromUint64(baseDenom.StepSize), }) } diff --git a/x/protorev/keeper/developer_fees.go b/x/protorev/keeper/developer_fees.go index 1035ff3f20d..fb9beaef22f 100644 --- a/x/protorev/keeper/developer_fees.go +++ b/x/protorev/keeper/developer_fees.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -35,7 +36,7 @@ func (k Keeper) SendDeveloperFeesToDeveloperAccount(ctx sdk.Context) error { // Deprecated: Can be removed in v16 // UpdateDeveloperFees updates the fees that developers can withdraw from the module account -func (k Keeper) UpdateDeveloperFees(ctx sdk.Context, denom string, profit sdk.Int) error { +func (k Keeper) UpdateDeveloperFees(ctx sdk.Context, denom string, profit osmomath.Int) error { daysSinceGenesis, err := k.GetDaysSinceModuleGenesis(ctx) if err != nil { return err @@ -53,7 +54,7 @@ func (k Keeper) UpdateDeveloperFees(ctx sdk.Context, denom string, profit sdk.In // Get the developer fees for the denom, if not there then set it to 0 and initialize it currentDeveloperFee, err := k.GetDeveloperFees(ctx, denom) if err != nil { - currentDeveloperFee = sdk.NewCoin(denom, sdk.ZeroInt()) + currentDeveloperFee = sdk.NewCoin(denom, osmomath.ZeroInt()) } currentDeveloperFee.Amount = currentDeveloperFee.Amount.Add(profit) @@ -80,7 +81,7 @@ func (k Keeper) SendDeveloperFee(ctx sdk.Context, arbProfit sdk.Coin) error { } // Initialize the developer profit to 0 - devProfit := sdk.NewCoin(arbProfit.Denom, sdk.ZeroInt()) + devProfit := sdk.NewCoin(arbProfit.Denom, osmomath.ZeroInt()) // Calculate the developer fee if daysSinceGenesis < types.Phase1Length { diff --git a/x/protorev/keeper/developer_fees_test.go b/x/protorev/keeper/developer_fees_test.go index de9e2a79996..ba12dd190ed 100644 --- a/x/protorev/keeper/developer_fees_test.go +++ b/x/protorev/keeper/developer_fees_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -27,11 +28,11 @@ func (suite *KeeperTestSuite) TestSendDeveloperFee() { account := apptesting.CreateRandomAccounts(1)[0] suite.App.ProtoRevKeeper.SetDeveloperAccount(suite.Ctx, account) - err := suite.pseudoExecuteTrade(types.OsmosisDenomination, sdk.NewInt(1000), 100) + err := suite.pseudoExecuteTrade(types.OsmosisDenomination, osmomath.NewInt(1000), 100) suite.Require().NoError(err) }, expectedErr: false, - expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(20)), + expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(20)), }, { description: "Send with set developer account in second phase", @@ -39,11 +40,11 @@ func (suite *KeeperTestSuite) TestSendDeveloperFee() { account := apptesting.CreateRandomAccounts(1)[0] suite.App.ProtoRevKeeper.SetDeveloperAccount(suite.Ctx, account) - err := suite.pseudoExecuteTrade(types.OsmosisDenomination, sdk.NewInt(1000), 500) + err := suite.pseudoExecuteTrade(types.OsmosisDenomination, osmomath.NewInt(1000), 500) suite.Require().NoError(err) }, expectedErr: false, - expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10)), + expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(10)), }, { description: "Send with set developer account in third (final) phase", @@ -51,11 +52,11 @@ func (suite *KeeperTestSuite) TestSendDeveloperFee() { account := apptesting.CreateRandomAccounts(1)[0] suite.App.ProtoRevKeeper.SetDeveloperAccount(suite.Ctx, account) - err := suite.pseudoExecuteTrade(types.OsmosisDenomination, sdk.NewInt(1000), 1000) + err := suite.pseudoExecuteTrade(types.OsmosisDenomination, osmomath.NewInt(1000), 1000) suite.Require().NoError(err) }, expectedErr: false, - expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(5)), + expectedDevProfit: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(5)), }, } @@ -64,7 +65,7 @@ func (suite *KeeperTestSuite) TestSendDeveloperFee() { suite.SetupTest() tc.alterState() - err := suite.App.ProtoRevKeeper.SendDeveloperFee(suite.Ctx, sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(100))) + err := suite.App.ProtoRevKeeper.SendDeveloperFee(suite.Ctx, sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(100))) if tc.expectedErr { suite.Require().Error(err) } else { @@ -83,7 +84,7 @@ func (suite *KeeperTestSuite) TestSendDeveloperFee() { } // pseudoExecuteTrade is a helper function to execute a trade given denom of profit, profit, and days since genesis -func (suite *KeeperTestSuite) pseudoExecuteTrade(denom string, profit sdk.Int, daysSinceGenesis uint64) error { +func (suite *KeeperTestSuite) pseudoExecuteTrade(denom string, profit osmomath.Int, daysSinceGenesis uint64) error { // Initialize the number of days since genesis suite.App.ProtoRevKeeper.SetDaysSinceModuleGenesis(suite.Ctx, daysSinceGenesis) // Mint the profit to the module account (which will be sent to the developer account later) diff --git a/x/protorev/keeper/emit.go b/x/protorev/keeper/emit.go index 77112ae7e75..895c9983dda 100644 --- a/x/protorev/keeper/emit.go +++ b/x/protorev/keeper/emit.go @@ -9,11 +9,12 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) // EmitBackrunEvent updates and emits a backrunEvent -func EmitBackrunEvent(ctx sdk.Context, pool SwapToBackrun, inputCoin sdk.Coin, profit, tokenOutAmount sdk.Int, remainingTxPoolPoints, remainingBlockPoolPoints uint64) { +func EmitBackrunEvent(ctx sdk.Context, pool SwapToBackrun, inputCoin sdk.Coin, profit, tokenOutAmount osmomath.Int, remainingTxPoolPoints, remainingBlockPoolPoints uint64) { // Get tx hash txHash := strings.ToUpper(hex.EncodeToString(tmhash.Sum(ctx.TxBytes()))) // Update the backrun event and add it to the context diff --git a/x/protorev/keeper/emit_test.go b/x/protorev/keeper/emit_test.go index d8a1d333923..74a33543d09 100644 --- a/x/protorev/keeper/emit_test.go +++ b/x/protorev/keeper/emit_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/tmhash" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/keeper" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -17,8 +18,8 @@ func (s *KeeperTestSuite) TestBackRunEvent() { pool keeper.SwapToBackrun remainingTxPoolPoints uint64 remainingBlockPoolPoints uint64 - profit sdk.Int - tokenOutAmount sdk.Int + profit osmomath.Int + tokenOutAmount osmomath.Int inputCoin sdk.Coin }{ "basic valid": { @@ -29,9 +30,9 @@ func (s *KeeperTestSuite) TestBackRunEvent() { }, remainingTxPoolPoints: 100, remainingBlockPoolPoints: 100, - profit: sdk.NewInt(100), - tokenOutAmount: sdk.NewInt(100), - inputCoin: sdk.NewCoin("uosmo", sdk.NewInt(100)), + profit: osmomath.NewInt(100), + tokenOutAmount: osmomath.NewInt(100), + inputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(100)), }, } diff --git a/x/protorev/keeper/epoch_hook.go b/x/protorev/keeper/epoch_hook.go index 2889f74d071..af11d6ed772 100644 --- a/x/protorev/keeper/epoch_hook.go +++ b/x/protorev/keeper/epoch_hook.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" ) @@ -12,7 +13,7 @@ type EpochHooks struct { // Struct used to track the pool with the highest liquidity type LiquidityPoolStruct struct { - Liquidity sdk.Int + Liquidity osmomath.Int PoolId uint64 } diff --git a/x/protorev/keeper/epoch_hook_test.go b/x/protorev/keeper/epoch_hook_test.go index 74babb231d3..d48fbf6a3c8 100644 --- a/x/protorev/keeper/epoch_hook_test.go +++ b/x/protorev/keeper/epoch_hook_test.go @@ -5,8 +5,7 @@ import ( "strings" "testing" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/keeper" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -144,7 +143,7 @@ func (s *KeeperTestSuite) TestUpdateHighestLiquidityPools() { }, expectedBaseDenomPools: map[string]map[string]keeper.LiquidityPoolStruct{ "epochOne": { - "uosmo": {Liquidity: sdk.NewInt(2000000), PoolId: 47}, + "uosmo": {Liquidity: osmomath.NewInt(2000000), PoolId: 47}, }, }, }, @@ -162,7 +161,7 @@ func (s *KeeperTestSuite) TestUpdateHighestLiquidityPools() { }, expectedBaseDenomPools: map[string]map[string]keeper.LiquidityPoolStruct{ "epochTwo": { - "uosmo": {Liquidity: sdk.Int(sdk.NewUintFromString("999999000000000001000000000000000000")), PoolId: 50}, + "uosmo": {Liquidity: osmomath.Int(osmomath.NewUintFromString("999999000000000001000000000000000000")), PoolId: 50}, }, }, }, diff --git a/x/protorev/keeper/grpc_query_test.go b/x/protorev/keeper/grpc_query_test.go index 0bf4e404f37..3a6061ed817 100644 --- a/x/protorev/keeper/grpc_query_test.go +++ b/x/protorev/keeper/grpc_query_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -26,27 +27,27 @@ func (s *KeeperTestSuite) TestGetProtoRevNumberOfTrades() { s.Require().Error(err) // Pseudo execute a trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) // Check the updated result res, err := s.queryClient.GetProtoRevNumberOfTrades(sdk.WrapSDKContext(s.Ctx), &types.QueryGetProtoRevNumberOfTradesRequest{}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), res.NumberOfTrades) + s.Require().Equal(osmomath.NewInt(1), res.NumberOfTrades) // Pseudo execute 3 more trades - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) res, err = s.queryClient.GetProtoRevNumberOfTrades(sdk.WrapSDKContext(s.Ctx), &types.QueryGetProtoRevNumberOfTradesRequest{}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(4).Uint64(), res.NumberOfTrades.Uint64()) + s.Require().Equal(osmomath.NewInt(4).Uint64(), res.NumberOfTrades.Uint64()) } // TestGetProtoRevProfitsByDenom tests the query for profits by denom @@ -58,17 +59,17 @@ func (s *KeeperTestSuite) TestGetProtoRevProfitsByDenom() { s.Require().Error(err) // Pseudo execute a trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) s.Commit() res, err := s.queryClient.GetProtoRevProfitsByDenom(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(10000), res.Profit.Amount) + s.Require().Equal(osmomath.NewInt(10000), res.Profit.Amount) // Pseudo execute a trade in a different denom - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", osmomath.NewInt(10000)) s.Require().NoError(err) s.Commit() @@ -80,7 +81,7 @@ func (s *KeeperTestSuite) TestGetProtoRevProfitsByDenom() { } res, err = s.queryClient.GetProtoRevProfitsByDenom(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(10000), res.Profit.Amount) + s.Require().Equal(osmomath.NewInt(10000), res.Profit.Amount) s.Require().Equal("Atom", res.Profit.Denom) } @@ -92,28 +93,28 @@ func (s *KeeperTestSuite) TestGetProtoRevAllProfits() { s.Require().Equal(0, len(res.Profits)) // Pseudo execute a trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(9000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(9000)) s.Require().NoError(err) - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", sdk.NewInt(3000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", osmomath.NewInt(3000)) s.Require().NoError(err) res, err = s.queryClient.GetProtoRevAllProfits(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) - atom := sdk.NewCoin("Atom", sdk.NewInt(3000)) - osmo := sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(9000)) + atom := sdk.NewCoin("Atom", osmomath.NewInt(3000)) + osmo := sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(9000)) s.Require().Contains(res.Profits, atom) s.Require().Contains(res.Profits, osmo) // Pseudo execute more trades - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{}, "Atom", osmomath.NewInt(10000)) s.Require().NoError(err) res, err = s.queryClient.GetProtoRevAllProfits(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) - atom = sdk.NewCoin("Atom", sdk.NewInt(13000)) - osmo = sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(19000)) + atom = sdk.NewCoin("Atom", osmomath.NewInt(13000)) + osmo = sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(19000)) s.Require().Contains(res.Profits, atom) s.Require().Contains(res.Profits, osmo) } @@ -130,40 +131,40 @@ func (s *KeeperTestSuite) TestGetProtoRevStatisticsByRoute() { s.Require().Nil(res) // Pseudo execute a trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, "Atom", sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, "Atom", osmomath.NewInt(10000)) s.Require().NoError(err) // Verify statistics res, err = s.queryClient.GetProtoRevStatisticsByRoute(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics.Route) - s.Require().Equal(sdk.OneInt(), res.Statistics.NumberOfTrades) - coin := sdk.NewCoin("Atom", sdk.NewInt(10000)) + s.Require().Equal(osmomath.OneInt(), res.Statistics.NumberOfTrades) + coin := sdk.NewCoin("Atom", osmomath.NewInt(10000)) s.Require().Contains(res.Statistics.Profits, coin) // Pseudo execute another trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, "Atom", sdk.NewInt(80000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, "Atom", osmomath.NewInt(80000)) s.Require().NoError(err) // Verify statistics res, err = s.queryClient.GetProtoRevStatisticsByRoute(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics.Route) - s.Require().Equal(sdk.NewInt(2), res.Statistics.NumberOfTrades) - coin = sdk.NewCoin("Atom", sdk.NewInt(90000)) + s.Require().Equal(osmomath.NewInt(2), res.Statistics.NumberOfTrades) + coin = sdk.NewCoin("Atom", osmomath.NewInt(90000)) s.Require().Contains(res.Statistics.Profits, coin) // Pseudo execute another trade in a different denom (might happen in multidenom pools > 2 denoms) - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, sdk.NewInt(80000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, osmomath.NewInt(80000)) s.Require().NoError(err) // Verify statistics res, err = s.queryClient.GetProtoRevStatisticsByRoute(sdk.WrapSDKContext(s.Ctx), req) s.Require().NoError(err) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics.Route) - s.Require().Equal(sdk.NewInt(3), res.Statistics.NumberOfTrades) - atomCoin := sdk.NewCoin("Atom", sdk.NewInt(90000)) - osmoCoin := sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(80000)) + s.Require().Equal(osmomath.NewInt(3), res.Statistics.NumberOfTrades) + atomCoin := sdk.NewCoin("Atom", osmomath.NewInt(90000)) + osmoCoin := sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(80000)) s.Require().Contains(res.Statistics.Profits, atomCoin) s.Require().Contains(res.Statistics.Profits, osmoCoin) } @@ -177,7 +178,7 @@ func (s *KeeperTestSuite) TestGetProtoRevAllRouteStatistics() { s.Require().Nil(res) // Pseudo execute a trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, sdk.NewInt(10000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().NoError(err) // Verify statistics @@ -185,12 +186,12 @@ func (s *KeeperTestSuite) TestGetProtoRevAllRouteStatistics() { s.Require().NoError(err) s.Require().Equal(1, len(res.Statistics)) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics[0].Route) - s.Require().Equal(sdk.OneInt(), res.Statistics[0].NumberOfTrades) - osmoCoin := sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10000)) + s.Require().Equal(osmomath.OneInt(), res.Statistics[0].NumberOfTrades) + osmoCoin := sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(10000)) s.Require().Contains(res.Statistics[0].Profits, osmoCoin) // Pseudo execute another trade - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, sdk.NewInt(80000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, types.OsmosisDenomination, osmomath.NewInt(80000)) s.Require().NoError(err) // Verify statistics @@ -198,12 +199,12 @@ func (s *KeeperTestSuite) TestGetProtoRevAllRouteStatistics() { s.Require().NoError(err) s.Require().Equal(1, len(res.Statistics)) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics[0].Route) - s.Require().Equal(sdk.NewInt(2), res.Statistics[0].NumberOfTrades) - osmoCoin = sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(90000)) + s.Require().Equal(osmomath.NewInt(2), res.Statistics[0].NumberOfTrades) + osmoCoin = sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(90000)) s.Require().Contains(res.Statistics[0].Profits, osmoCoin) // Pseudo execute another trade on a different route - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 4}}, types.OsmosisDenomination, sdk.NewInt(70000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 4}}, types.OsmosisDenomination, osmomath.NewInt(70000)) s.Require().NoError(err) // Verify statistics @@ -211,16 +212,16 @@ func (s *KeeperTestSuite) TestGetProtoRevAllRouteStatistics() { s.Require().NoError(err) s.Require().Equal(2, len(res.Statistics)) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics[0].Route) - s.Require().Equal(sdk.NewInt(2), res.Statistics[0].NumberOfTrades) + s.Require().Equal(osmomath.NewInt(2), res.Statistics[0].NumberOfTrades) s.Require().Contains(res.Statistics[0].Profits, osmoCoin) s.Require().Equal([]uint64{1, 2, 4}, res.Statistics[1].Route) - s.Require().Equal(sdk.OneInt(), res.Statistics[1].NumberOfTrades) - osmoCoin = sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(70000)) + s.Require().Equal(osmomath.OneInt(), res.Statistics[1].NumberOfTrades) + osmoCoin = sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(70000)) s.Require().Contains(res.Statistics[1].Profits, osmoCoin) // Pseudo execute another trade on a different route and denom - err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 5}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 4}}, "Atom", sdk.NewInt(80000)) + err = s.App.AppKeepers.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 5}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 4}}, "Atom", osmomath.NewInt(80000)) s.Require().NoError(err) // Verify statistics @@ -228,18 +229,18 @@ func (s *KeeperTestSuite) TestGetProtoRevAllRouteStatistics() { s.Require().NoError(err) s.Require().Equal(3, len(res.Statistics)) s.Require().Equal([]uint64{1, 2, 3}, res.Statistics[0].Route) - s.Require().Equal(sdk.NewInt(2), res.Statistics[0].NumberOfTrades) - osmoCoin = sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(90000)) + s.Require().Equal(osmomath.NewInt(2), res.Statistics[0].NumberOfTrades) + osmoCoin = sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(90000)) s.Require().Contains(res.Statistics[0].Profits, osmoCoin) s.Require().Equal([]uint64{1, 2, 4}, res.Statistics[1].Route) - s.Require().Equal(sdk.OneInt(), res.Statistics[1].NumberOfTrades) - osmoCoin = sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(70000)) + s.Require().Equal(osmomath.OneInt(), res.Statistics[1].NumberOfTrades) + osmoCoin = sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(70000)) s.Require().Contains(res.Statistics[1].Profits, osmoCoin) s.Require().Equal([]uint64{5, 2, 4}, res.Statistics[2].Route) - s.Require().Equal(sdk.OneInt(), res.Statistics[2].NumberOfTrades) - atomCoin := sdk.NewCoin("Atom", sdk.NewInt(80000)) + s.Require().Equal(osmomath.OneInt(), res.Statistics[2].NumberOfTrades) + atomCoin := sdk.NewCoin("Atom", osmomath.NewInt(80000)) s.Require().Contains(res.Statistics[2].Profits, atomCoin) } diff --git a/x/protorev/keeper/hooks.go b/x/protorev/keeper/hooks.go index 311d0e280d1..c9305be5f5c 100644 --- a/x/protorev/keeper/hooks.go +++ b/x/protorev/keeper/hooks.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -30,7 +31,7 @@ func (h Hooks) AfterCFMMPoolCreated(ctx sdk.Context, sender sdk.AccAddress, pool } // AfterJoinPool stores swaps to be checked by protorev given the coins entered into the pool. -func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { +func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int) { // Checked to avoid future unintended behavior based on how the hook is called if len(enterCoins) != 1 { return @@ -40,7 +41,7 @@ func (h Hooks) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint } // AfterExitPool stores swaps to be checked by protorev given the coins exited from the pool. -func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { +func (h Hooks) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins) { // Added due to ExitSwapShareAmountIn both calling // ExitPoolHook with all denoms of the pool and then also // Swapping which triggers the after swap hook. @@ -107,16 +108,16 @@ func (k Keeper) StoreSwap(ctx sdk.Context, poolId uint64, tokenIn, tokenOut stri } // GetComparablePoolLiquidity gets the comparable liquidity of a pool by multiplying the amounts of the pool coins. -func (k Keeper) GetComparablePoolLiquidity(ctx sdk.Context, poolId uint64) (comparableLiquidity sdk.Int, err error) { +func (k Keeper) GetComparablePoolLiquidity(ctx sdk.Context, poolId uint64) (comparableLiquidity osmomath.Int, err error) { coins, err := k.poolmanagerKeeper.GetTotalPoolLiquidity(ctx, poolId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Recover from overflow panic defer func() { if r := recover(); r != nil { - comparableLiquidity = sdk.Int{} + comparableLiquidity = osmomath.Int{} err = errors.New("Int overflow in GetComparablePoolLiquidity") } }() diff --git a/x/protorev/keeper/hooks_test.go b/x/protorev/keeper/hooks_test.go index 215b25a1cb9..32e8088ce7d 100644 --- a/x/protorev/keeper/hooks_test.go +++ b/x/protorev/keeper/hooks_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -32,7 +33,7 @@ func (s *KeeperTestSuite) TestSwapping() { }, }, executeSwap: func() { - _, err := s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], 1, sdk.NewCoin("akash", sdk.NewInt(100)), "Atom", sdk.NewInt(1)) + _, err := s.App.PoolManagerKeeper.SwapExactAmountIn(s.Ctx, s.TestAccs[0], 1, sdk.NewCoin("akash", osmomath.NewInt(100)), "Atom", osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -52,7 +53,7 @@ func (s *KeeperTestSuite) TestSwapping() { route := []poolmanagertypes.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "Atom"}} - _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("akash", sdk.NewInt(100)), sdk.NewInt(1)) + _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("akash", osmomath.NewInt(100)), osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -72,7 +73,7 @@ func (s *KeeperTestSuite) TestSwapping() { route := []poolmanagertypes.SwapAmountOutRoute{{PoolId: 1, TokenInDenom: "akash"}} - _, err := s.App.PoolManagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], route, sdk.NewInt(10000), sdk.NewCoin("Atom", sdk.NewInt(100))) + _, err := s.App.PoolManagerKeeper.RouteExactAmountOut(s.Ctx, s.TestAccs[0], route, osmomath.NewInt(10000), sdk.NewCoin("Atom", osmomath.NewInt(100))) s.Require().NoError(err) }, }, @@ -97,7 +98,7 @@ func (s *KeeperTestSuite) TestSwapping() { route := []poolmanagertypes.SwapAmountInRoute{{PoolId: 1, TokenOutDenom: "Atom"}, {PoolId: 1, TokenOutDenom: "akash"}} - _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("akash", sdk.NewInt(100)), sdk.NewInt(1)) + _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("akash", osmomath.NewInt(100)), osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -117,7 +118,7 @@ func (s *KeeperTestSuite) TestSwapping() { route := []poolmanagertypes.SwapAmountInRoute{{PoolId: 50, TokenOutDenom: "epochTwo"}} - _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewInt(1)) + _, err := s.App.PoolManagerKeeper.RouteExactAmountIn(s.Ctx, s.TestAccs[0], route, sdk.NewCoin("uosmo", osmomath.NewInt(10)), osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -160,7 +161,7 @@ func (s *KeeperTestSuite) TestLiquidityChanging() { }, }, executeLiquidityProviding: func() { - _, err := s.App.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, s.TestAccs[0], 1, sdk.NewCoins(sdk.NewCoin("akash", sdk.NewInt(100))), sdk.NewInt(1)) + _, err := s.App.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, s.TestAccs[0], 1, sdk.NewCoins(sdk.NewCoin("akash", osmomath.NewInt(100))), osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -177,7 +178,7 @@ func (s *KeeperTestSuite) TestLiquidityChanging() { }, }, executeLiquidityProviding: func() { - _, err := s.App.GAMMKeeper.JoinSwapShareAmountOut(s.Ctx, s.TestAccs[0], 1, "akash", sdk.NewInt(1000), sdk.NewInt(10000)) + _, err := s.App.GAMMKeeper.JoinSwapShareAmountOut(s.Ctx, s.TestAccs[0], 1, "akash", osmomath.NewInt(1000), osmomath.NewInt(10000)) s.Require().NoError(err) }, }, @@ -194,7 +195,7 @@ func (s *KeeperTestSuite) TestLiquidityChanging() { }, }, executeLiquidityProviding: func() { - _, err := s.App.GAMMKeeper.ExitSwapExactAmountOut(s.Ctx, s.TestAccs[0], 1, sdk.NewCoin("Atom", sdk.NewInt(1)), sdk.NewInt(1002141106353159235)) + _, err := s.App.GAMMKeeper.ExitSwapExactAmountOut(s.Ctx, s.TestAccs[0], 1, sdk.NewCoin("Atom", osmomath.NewInt(1)), osmomath.NewInt(1002141106353159235)) s.Require().NoError(err) }, }, @@ -211,7 +212,7 @@ func (s *KeeperTestSuite) TestLiquidityChanging() { }, }, executeLiquidityProviding: func() { - _, err := s.App.GAMMKeeper.ExitSwapShareAmountIn(s.Ctx, s.TestAccs[0], 1, "Atom", sdk.NewInt(1000000000000000000), sdk.NewInt(1)) + _, err := s.App.GAMMKeeper.ExitSwapShareAmountIn(s.Ctx, s.TestAccs[0], 1, "Atom", osmomath.NewInt(1000000000000000000), osmomath.NewInt(1)) s.Require().NoError(err) }, }, @@ -222,7 +223,7 @@ func (s *KeeperTestSuite) TestLiquidityChanging() { param: param{ expectedTrades: []types.Trade(nil), executeLiquidityProviding: func() { - _, err := s.App.GAMMKeeper.ExitSwapShareAmountIn(s.Ctx, s.TestAccs[0], 1, "Atom", sdk.NewInt(1000), sdk.NewInt(0)) + _, err := s.App.GAMMKeeper.ExitSwapShareAmountIn(s.Ctx, s.TestAccs[0], 1, "Atom", osmomath.NewInt(1000), osmomath.NewInt(0)) s.Require().NoError(err) }, }, @@ -263,16 +264,16 @@ func (s *KeeperTestSuite) TestPoolCreation() { executePoolCreation: func() uint64 { poolId := s.createGAMMPool([]balancer.PoolAsset{ { - Token: sdk.NewCoin("hookGamm", sdk.NewInt(1000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("hookGamm", osmomath.NewInt(1000000000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000000000)), + Weight: osmomath.NewInt(1), }, }, - sdk.NewDecWithPrec(2, 3), - sdk.NewDecWithPrec(0, 2)) + osmomath.NewDecWithPrec(2, 3), + osmomath.NewDecWithPrec(0, 2)) return poolId }, @@ -309,16 +310,16 @@ func (s *KeeperTestSuite) TestPoolCreation() { // Create balancer pool first with a new denom pair balancerPoolId := s.createGAMMPool([]balancer.PoolAsset{ { - Token: sdk.NewCoin("hook", sdk.NewInt(1)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("hook", osmomath.NewInt(1)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("uosmo", sdk.NewInt(1)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("uosmo", osmomath.NewInt(1)), + Weight: osmomath.NewInt(1), }, }, - sdk.NewDecWithPrec(1, 1), - sdk.NewDecWithPrec(0, 2), + osmomath.NewDecWithPrec(1, 1), + osmomath.NewDecWithPrec(0, 2), ) // Ensure that the balancer pool is stored since no other pool exists for the denom pair @@ -354,16 +355,16 @@ func (s *KeeperTestSuite) TestPoolCreation() { // Create balancer pool with the same denom pair and more liquidity balancerPoolId := s.createGAMMPool([]balancer.PoolAsset{ { - Token: sdk.NewCoin(clPoolLiquidity[0].Denom, clPoolLiquidity[0].Amount.Add(sdk.NewInt(1))), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(clPoolLiquidity[0].Denom, clPoolLiquidity[0].Amount.Add(osmomath.NewInt(1))), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(clPoolLiquidity[1].Denom, clPoolLiquidity[1].Amount.Add(sdk.NewInt(1))), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(clPoolLiquidity[1].Denom, clPoolLiquidity[1].Amount.Add(osmomath.NewInt(1))), + Weight: osmomath.NewInt(1), }, }, - sdk.NewDecWithPrec(1, 1), - sdk.NewDecWithPrec(0, 2), + osmomath.NewDecWithPrec(1, 1), + osmomath.NewDecWithPrec(0, 2), ) // The returned pool id should be what is finally stored in the protorev keeper since it has more liquidity @@ -438,7 +439,7 @@ func (s *KeeperTestSuite) TestStoreSwap() { TokenOut: "akash", }, }, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }) }, expectedSwapsStoredLen: 2, @@ -471,7 +472,7 @@ func (s *KeeperTestSuite) TestStoreSwap() { func (s *KeeperTestSuite) TestGetComparablePoolLiquidity() { type param struct { executePoolCreation func() uint64 - expectedComparableLiquidity sdk.Int + expectedComparableLiquidity osmomath.Int } tests := []struct { @@ -483,9 +484,9 @@ func (s *KeeperTestSuite) TestGetComparablePoolLiquidity() { name: "Get Balancer Pool Comparable Liquidity", param: param{ executePoolCreation: func() uint64 { - return s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewCoin("juno", sdk.NewInt(10))) + return s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10)), sdk.NewCoin("juno", osmomath.NewInt(10))) }, - expectedComparableLiquidity: sdk.NewInt(100), + expectedComparableLiquidity: osmomath.NewInt(100), }, expectPass: true, }, @@ -495,17 +496,17 @@ func (s *KeeperTestSuite) TestGetComparablePoolLiquidity() { executePoolCreation: func() uint64 { return s.createStableswapPool( sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10)), - sdk.NewCoin("juno", sdk.NewInt(10)), + sdk.NewCoin("uosmo", osmomath.NewInt(10)), + sdk.NewCoin("juno", osmomath.NewInt(10)), ), stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, []uint64{1, 1}, ) }, - expectedComparableLiquidity: sdk.NewInt(100), + expectedComparableLiquidity: osmomath.NewInt(100), }, expectPass: true, }, @@ -518,11 +519,11 @@ func (s *KeeperTestSuite) TestGetComparablePoolLiquidity() { s.Ctx, s.TestAccs[0], pool.GetAddress(), - sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(10)), sdk.NewCoin("usdc", sdk.NewInt(10)))) + sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(10)), sdk.NewCoin("usdc", osmomath.NewInt(10)))) s.Require().NoError(err) return pool.GetId() }, - expectedComparableLiquidity: sdk.NewInt(100), + expectedComparableLiquidity: osmomath.NewInt(100), }, expectPass: true, }, @@ -531,10 +532,10 @@ func (s *KeeperTestSuite) TestGetComparablePoolLiquidity() { param: param{ executePoolCreation: func() uint64 { return s.PrepareBalancerPoolWithCoins( - sdk.NewCoin("uosmo", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999"))), - sdk.NewCoin("juno", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999")))) + sdk.NewCoin("uosmo", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999"))), + sdk.NewCoin("juno", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999")))) }, - expectedComparableLiquidity: sdk.Int{}, + expectedComparableLiquidity: osmomath.Int{}, }, expectPass: false, }, @@ -657,7 +658,7 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { matchDenom: "juno", prepareStateAndGetPoolIdToCompare: func() (uint64, uint64) { // Prepare a balancer pool with coins - poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewCoin("juno", sdk.NewInt(10))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10)), sdk.NewCoin("juno", osmomath.NewInt(10))) // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") @@ -696,7 +697,7 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") - preparedPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewCoin("stake", sdk.NewInt(10))) + preparedPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10)), sdk.NewCoin("stake", osmomath.NewInt(10))) storedPoolId, err := s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "uosmo", "stake") s.Require().NoError(err) s.Require().Equal(preparedPoolId, storedPoolId) @@ -720,7 +721,7 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") // Prepare a balancer pool with more liquidity - balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(2000000000000000000)), sdk.NewCoin("stake", sdk.NewInt(1000000000000000000))) + balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(2000000000000000000)), sdk.NewCoin("stake", osmomath.NewInt(1000000000000000000))) storedPoolId, err := s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "uosmo", "stake") s.Require().NoError(err) s.Require().Equal(balancerPoolId, storedPoolId) @@ -738,7 +739,7 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { matchDenom: "stake", prepareStateAndGetPoolIdToCompare: func() (uint64, uint64) { // Prepare a balancer pool with more liquidity - balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(2000000000000000000)), sdk.NewCoin("stake", sdk.NewInt(1000000000000000000))) + balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(2000000000000000000)), sdk.NewCoin("stake", osmomath.NewInt(1000000000000000000))) // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") @@ -762,7 +763,7 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { matchDenom: "stake", prepareStateAndGetPoolIdToCompare: func() (uint64, uint64) { // Prepare a balancer pool with less liquidity - balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(500000000000000000)), sdk.NewCoin("stake", sdk.NewInt(1000000000000000000))) + balancerPoolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(500000000000000000)), sdk.NewCoin("stake", osmomath.NewInt(1000000000000000000))) // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") @@ -787,14 +788,14 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { prepareStateAndGetPoolIdToCompare: func() (uint64, uint64) { // Prepare a balancer pool with liquidity levels that will overflow when multiplied overflowPoolId := s.PrepareBalancerPoolWithCoins( - sdk.NewCoin("uosmo", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999"))), - sdk.NewCoin("stake", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999")))) + sdk.NewCoin("uosmo", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999"))), + sdk.NewCoin("stake", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999")))) // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") // Prepare a balancer pool with normal liquidity - poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewCoin("stake", sdk.NewInt(10))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10)), sdk.NewCoin("stake", osmomath.NewInt(10))) // The normal liquidity pool should be stored since the function will return early when catching the overflow error return poolId, overflowPoolId @@ -809,15 +810,15 @@ func (s *KeeperTestSuite) TestCompareAndStorePool() { matchDenom: "stake", prepareStateAndGetPoolIdToCompare: func() (uint64, uint64) { // Prepare a balancer pool with normal liquidity - poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", sdk.NewInt(10)), sdk.NewCoin("stake", sdk.NewInt(10))) + poolId := s.PrepareBalancerPoolWithCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10)), sdk.NewCoin("stake", osmomath.NewInt(10))) // Delete all pools for the base denom uosmo so that all tests start with a clean slate s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "uosmo") // Prepare a balancer pool with liquidity levels that will overflow when multiplied overflowPoolId := s.PrepareBalancerPoolWithCoins( - sdk.NewCoin("uosmo", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999"))), - sdk.NewCoin("stake", sdk.Int(sdk.NewUintFromString("999999999999999999999999999999999999999")))) + sdk.NewCoin("uosmo", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999"))), + sdk.NewCoin("stake", osmomath.Int(osmomath.NewUintFromString("999999999999999999999999999999999999999")))) // The overflow pool should be stored since the function will return early when catching the overflow error return overflowPoolId, poolId diff --git a/x/protorev/keeper/keeper_test.go b/x/protorev/keeper/keeper_test.go index 1a564a0d89d..239be5b32b2 100644 --- a/x/protorev/keeper/keeper_test.go +++ b/x/protorev/keeper/keeper_test.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/protorev" protorevkeeper "github.com/osmosis-labs/osmosis/v19/x/protorev/keeper" @@ -37,10 +38,10 @@ type Pool struct { PoolAssets []balancer.PoolAsset Asset1 string Asset2 string - Amount1 sdk.Int - Amount2 sdk.Int - SpreadFactor sdk.Dec - ExitFee sdk.Dec + Amount1 osmomath.Int + Amount2 osmomath.Int + SpreadFactor osmomath.Dec + ExitFee osmomath.Dec PoolId uint64 } @@ -57,10 +58,6 @@ func TestKeeperTestSuite(t *testing.T) { func (s *KeeperTestSuite) SetupTest() { s.Setup() - poolManagerParams := s.App.PoolManagerKeeper.GetParams(s.Ctx) - poolManagerParams.TakerFeeParams.DefaultTakerFee = 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()) @@ -86,15 +83,15 @@ func (s *KeeperTestSuite) SetupTest() { baseDenomPriorities := []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, { Denom: "Atom", - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, { Denom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, } err := s.App.ProtoRevKeeper.SetBaseDenoms(s.Ctx, baseDenomPriorities) @@ -170,8 +167,8 @@ func (s *KeeperTestSuite) SetupTest() { // canto <-> types.OsmosisDenomination // and so on.... func (s *KeeperTestSuite) setUpPools() { - // Create any necessary sdk.Ints that require string conversion - pool28Amount1, ok := sdk.NewIntFromString("6170367464346955818920") + // Create any necessary osmomath.Ints that require string conversion + pool28Amount1, ok := osmomath.NewIntFromString("6170367464346955818920") s.Require().True(ok) // Init pools @@ -179,602 +176,602 @@ func (s *KeeperTestSuite) setUpPools() { { // Pool 1 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 1, }, { // Pool 2 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 2, }, { // Pool 3 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 3, }, { // Pool 4 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 4, }, { // Pool 5 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 5, }, { // Pool 6 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 6, }, { // Pool 7 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 7, }, { // Pool 8 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 8, }, { // Pool 9 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 9, }, { // Pool 10 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 10, }, { // Pool 11 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 11, }, { // Pool 12 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 12, }, { // Pool 13 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 13, }, { // Pool 14 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 14, }, { // Pool 15 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("akash", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("akash", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 15, }, { // Pool 16 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 16, }, { // Pool 17 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 17, }, { // Pool 18 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("juno", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("juno", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 18, }, { // Pool 19 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 19, }, { // Pool 20 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ethereum", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ethereum", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 20, }, { // Pool 21 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("bitcoin", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("bitcoin", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("canto", sdk.NewInt(1000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("canto", osmomath.NewInt(1000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 21, }, { // Pool 22 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(18986995439401)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(18986995439401)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(191801648570)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(191801648570)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 22, }, { // Pool 23 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(72765460013038)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", osmomath.NewInt(72765460013038)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(596032233122)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(596032233122)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(535, 5), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(535, 5), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 23, }, { // Pool 24 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(165624820984787)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", osmomath.NewInt(165624820984787)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(13901565323)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(13901565323)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 24, }, { // Pool 25 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("Atom", sdk.NewInt(165624820984787)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(165624820984787)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(139015653231902)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(139015653231902)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 25, }, { // Pool 26 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(13305396712237)), - Weight: sdk.NewInt(50), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(13305396712237)), + Weight: osmomath.NewInt(50), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(171274446980)), - Weight: sdk.NewInt(50), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(171274446980)), + Weight: osmomath.NewInt(50), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 26, }, { // Pool 27 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(15766179414665)), - Weight: sdk.NewInt(50), + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", osmomath.NewInt(15766179414665)), + Weight: osmomath.NewInt(50), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(13466662920841)), - Weight: sdk.NewInt(50), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(13466662920841)), + Weight: osmomath.NewInt(50), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 27, }, { // Pool 28 PoolAssets: []balancer.PoolAsset{ { Token: sdk.NewCoin("ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE", pool28Amount1), - Weight: sdk.NewInt(25), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", sdk.NewInt(6073813312)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", osmomath.NewInt(6073813312)), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(403568175601)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(403568175601)), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", sdk.NewInt(6120465766)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("ibc/D189335C6E4A68B513C10AB227BF1C1D38C746766278BA3EEB4FB14124F1D858", osmomath.NewInt(6120465766)), + Weight: osmomath.NewInt(25), }, }, - SpreadFactor: sdk.NewDecWithPrec(4, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(4, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 28, }, { // Pool 29 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("uosmo", osmomath.NewInt(1000000000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("usdc", sdk.NewInt(2000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("usdc", osmomath.NewInt(2000000000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 29, }, { // Pool 30 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("uosmo", sdk.NewInt(1000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("uosmo", osmomath.NewInt(1000000000)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("busd", sdk.NewInt(1000000000)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("busd", osmomath.NewInt(1000000000)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 30, }, { // Pool 31 PoolAssets: []balancer.PoolAsset{ { Token: sdk.NewCoin("ibc/0E43EDE2E2A3AFA36D0CD38BDDC0B49FECA64FA426A82E102F304E430ECF46EE", pool28Amount1), // Amount didn't change on mainnet - Weight: sdk.NewInt(25), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", sdk.NewInt(6073813312)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("ibc/8242AD24008032E457D2E12D46588FD39FB54FB29680C6C7663D296B383C37C4", osmomath.NewInt(6073813312)), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(403523315860)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(403523315860)), + Weight: osmomath.NewInt(25), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(6121181710)), - Weight: sdk.NewInt(25), + Token: sdk.NewCoin("Atom", osmomath.NewInt(6121181710)), + Weight: osmomath.NewInt(25), }, }, - SpreadFactor: sdk.NewDecWithPrec(4, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(4, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 31, }, { // Pool 32 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", sdk.NewInt(23583984695)), - Weight: sdk.NewInt(70), + Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", osmomath.NewInt(23583984695)), + Weight: osmomath.NewInt(70), }, { - Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", sdk.NewInt(381295003769)), - Weight: sdk.NewInt(30), + Token: sdk.NewCoin("ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", osmomath.NewInt(381295003769)), + Weight: osmomath.NewInt(30), }, }, - SpreadFactor: sdk.NewDecWithPrec(3, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(3, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 32, }, { // Pool 33 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", sdk.NewInt(41552173575)), - Weight: sdk.NewInt(70), + Token: sdk.NewCoin("ibc/A0CC0CF735BFB30E730C70019D4218A1244FF383503FF7579C9201AB93CA9293", osmomath.NewInt(41552173575)), + Weight: osmomath.NewInt(70), }, { - Token: sdk.NewCoin("Atom", sdk.NewInt(10285796639)), - Weight: sdk.NewInt(30), + Token: sdk.NewCoin("Atom", osmomath.NewInt(10285796639)), + Weight: osmomath.NewInt(30), }, }, - SpreadFactor: sdk.NewDecWithPrec(3, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(3, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 33, }, { // Pool 34 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("Atom", sdk.NewInt(364647340206)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(364647340206)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("test/1", sdk.NewInt(1569764554938)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("test/1", osmomath.NewInt(1569764554938)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(3, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(3, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 34, }, { // Pool 35 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("test/1", sdk.NewInt(1026391517901)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("test/1", osmomath.NewInt(1026391517901)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1694086377216)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1694086377216)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 35, }, { // Pool 36 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(2774812791932)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(2774812791932)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("test/2", sdk.NewInt(1094837653970)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("test/2", osmomath.NewInt(1094837653970)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(3, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(3, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 36, }, { // Pool 37 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("Atom", sdk.NewInt(406165719545)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("Atom", osmomath.NewInt(406165719545)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("test/2", sdk.NewInt(1095887931673)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("test/2", osmomath.NewInt(1095887931673)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(3, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(3, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 37, }, { // Pool 38 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(6111815027)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(6111815027)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(4478366578)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(4478366578)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 38, }, { // Pool 39 PoolAssets: []balancer.PoolAsset{ { - Token: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(18631000485558)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(18631000485558)), + Weight: osmomath.NewInt(1), }, { - Token: sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(17000185817963)), - Weight: sdk.NewInt(1), + Token: sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(17000185817963)), + Weight: osmomath.NewInt(1), }, }, - SpreadFactor: sdk.NewDecWithPrec(2, 3), - ExitFee: sdk.NewDecWithPrec(0, 2), + SpreadFactor: osmomath.NewDecWithPrec(2, 3), + ExitFee: osmomath.NewDecWithPrec(0, 2), PoolId: 39, }, } @@ -786,113 +783,113 @@ func (s *KeeperTestSuite) setUpPools() { s.stableSwapPools = []StableSwapPool{ { // Pool 40 initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdc", sdk.NewInt(1000000000000000)), - sdk.NewCoin("usdt", sdk.NewInt(1000000000000000)), - sdk.NewCoin("busd", sdk.NewInt(1000000000000000)), + sdk.NewCoin("usdc", osmomath.NewInt(1000000000000000)), + sdk.NewCoin("usdt", osmomath.NewInt(1000000000000000)), + sdk.NewCoin("busd", osmomath.NewInt(1000000000000000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1, 1}, }, { // Pool 41 - Used for doomsday testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdc", sdk.NewInt(1000000000000000)), - sdk.NewCoin("usdt", sdk.NewInt(1000000000000000)), - sdk.NewCoin("busd", sdk.NewInt(2000000000000000)), + sdk.NewCoin("usdc", osmomath.NewInt(1000000000000000)), + sdk.NewCoin("usdt", osmomath.NewInt(1000000000000000)), + sdk.NewCoin("busd", osmomath.NewInt(2000000000000000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1, 1}, }, { // Pool 42 - Used for extended range testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdx", sdk.NewInt(1000000000000000)), - sdk.NewCoin("usdy", sdk.NewInt(2000000000000000)), + sdk.NewCoin("usdx", osmomath.NewInt(1000000000000000)), + sdk.NewCoin("usdy", osmomath.NewInt(2000000000000000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 43 - Used for extended range testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdx", sdk.NewInt(2000000000000000)), - sdk.NewCoin("usdy", sdk.NewInt(1000000000000000)), + sdk.NewCoin("usdx", osmomath.NewInt(2000000000000000)), + sdk.NewCoin("usdy", osmomath.NewInt(1000000000000000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 44 - Used for panic catching testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdx", sdk.NewInt(1000)), - sdk.NewCoin("usdy", sdk.NewInt(2000)), + sdk.NewCoin("usdx", osmomath.NewInt(1000)), + sdk.NewCoin("usdy", osmomath.NewInt(2000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 45 - Used for panic catching testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("usdx", sdk.NewInt(2000)), - sdk.NewCoin("usdy", sdk.NewInt(1000)), + sdk.NewCoin("usdx", osmomath.NewInt(2000)), + sdk.NewCoin("usdy", osmomath.NewInt(1000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 46 - Used for epoch_hook UpdateHighestLiquidityPool testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("epochOne", sdk.NewInt(1000)), - sdk.NewCoin("uosmo", sdk.NewInt(1000)), + sdk.NewCoin("epochOne", osmomath.NewInt(1000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 47 - Used for epoch_hook UpdateHighestLiquidityPool testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("epochOne", sdk.NewInt(1000)), - sdk.NewCoin("uosmo", sdk.NewInt(2000)), + sdk.NewCoin("epochOne", osmomath.NewInt(1000)), + sdk.NewCoin("uosmo", osmomath.NewInt(2000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 48 - Used for epoch_hook UpdateHighestLiquidityPool testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("epochTwo", sdk.NewInt(1000)), - sdk.NewCoin("uosmo", sdk.NewInt(1000)), + sdk.NewCoin("epochTwo", osmomath.NewInt(1000)), + sdk.NewCoin("uosmo", osmomath.NewInt(1000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 4), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(1, 4), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, { // Pool 49 - Used for CL testing initialLiquidity: sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(10_000_000_000_000)), - sdk.NewCoin("epochTwo", sdk.NewInt(8_000_000_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10_000_000_000_000)), + sdk.NewCoin("epochTwo", osmomath.NewInt(8_000_000_000_000)), ), poolParams: stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, scalingFactors: []uint64{1, 1}, }, @@ -923,16 +920,16 @@ func (s *KeeperTestSuite) setUpPools() { // Create a concentrated liquidity pool for range testing // Pool 52 // Create the CL pool - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "epochTwo", "uosmo", apptesting.DefaultTickSpacing, sdk.ZeroDec()) - fundCoins := sdk.NewCoins(sdk.NewCoin("epochTwo", sdk.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", sdk.NewInt(10_000_000_000_000))) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "epochTwo", "uosmo", apptesting.DefaultTickSpacing, osmomath.ZeroDec()) + fundCoins := sdk.NewCoins(sdk.NewCoin("epochTwo", osmomath.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", osmomath.NewInt(10_000_000_000_000))) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool, fundCoins) // Create a concentrated liquidity pool for range testing // Pool 53 // Create the CL pool - clPool = s.PrepareCustomConcentratedPool(s.TestAccs[0], "epochTwo", "uosmo", apptesting.DefaultTickSpacing, sdk.ZeroDec()) - fundCoins = sdk.NewCoins(sdk.NewCoin("epochTwo", sdk.NewInt(2_000_000_000)), sdk.NewCoin("uosmo", sdk.NewInt(1_000_000_000))) + clPool = s.PrepareCustomConcentratedPool(s.TestAccs[0], "epochTwo", "uosmo", apptesting.DefaultTickSpacing, osmomath.ZeroDec()) + fundCoins = sdk.NewCoins(sdk.NewCoin("epochTwo", osmomath.NewInt(2_000_000_000)), sdk.NewCoin("uosmo", osmomath.NewInt(1_000_000_000))) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool, fundCoins) @@ -943,14 +940,14 @@ func (s *KeeperTestSuite) setUpPools() { func (s *KeeperTestSuite) CreateCLPoolAndArbRouteWith_28000_Ticks() { // Create the CL pool - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[2], "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", "uosmo", 100, sdk.NewDecWithPrec(2, 3)) - fundCoins := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000000000000000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(1000000000000000000))) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[2], "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", "uosmo", 100, osmomath.NewDecWithPrec(2, 3)) + fundCoins := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000000000000000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(1000000000000000000))) s.FundAcc(s.TestAccs[2], fundCoins) // Create 28000 ticks in the CL pool, 14000 on each side - tokensProvided := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(100000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(100000))) - amount0Min := sdk.NewInt(0) - amount1Min := sdk.NewInt(0) + tokensProvided := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(100000)), sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(100000))) + amount0Min := osmomath.NewInt(0) + amount1Min := osmomath.NewInt(0) lowerTick := int64(0) upperTick := int64(100) @@ -979,7 +976,7 @@ func (s *KeeperTestSuite) CreateCLPoolAndArbRouteWith_28000_Ticks() { TokenOut: "uosmo", }, }, - StepSize: sdk.NewInt(100000), + StepSize: osmomath.NewInt(100000), }, }, "uosmo", @@ -998,7 +995,7 @@ func (s *KeeperTestSuite) createStableswapPool(initialLiquidity sdk.Coins, poolP } // createGAMMPool creates a balancer pool with the given pool assets and params -func (s *KeeperTestSuite) createGAMMPool(poolAssets []balancer.PoolAsset, spreadFactor, exitFee sdk.Dec) uint64 { +func (s *KeeperTestSuite) createGAMMPool(poolAssets []balancer.PoolAsset, spreadFactor, exitFee osmomath.Dec) uint64 { poolParams := balancer.PoolParams{ SwapFee: spreadFactor, ExitFee: exitFee, @@ -1060,7 +1057,7 @@ func (s *KeeperTestSuite) setUpTokenPairRoutes() { doomsdayStable1 := types.NewTrade(0, "usdc", "busd") doomsdayStable2 := types.NewTrade(30, "busd", types.OsmosisDenomination) - standardStepSize := sdk.NewInt(1_000_000) + standardStepSize := osmomath.NewInt(1_000_000) s.tokenPairArbRoutes = []types.TokenPairArbRoutes{ { diff --git a/x/protorev/keeper/msg_server_test.go b/x/protorev/keeper/msg_server_test.go index 23de70b4c4d..cb4cb77b719 100644 --- a/x/protorev/keeper/msg_server_test.go +++ b/x/protorev/keeper/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/protorev/keeper" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" @@ -10,8 +11,8 @@ import ( // TestMsgSetHotRoutes tests the MsgSetHotRoutes message. func (s *KeeperTestSuite) TestMsgSetHotRoutes() { - validStepSize := sdk.NewInt(1_000_000) - invalidStepSize := sdk.NewInt(0) + validStepSize := osmomath.NewInt(1_000_000) + invalidStepSize := osmomath.NewInt(0) testCases := []struct { description string @@ -579,7 +580,7 @@ func (s *KeeperTestSuite) TestMsgSetBaseDenoms() { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, }, false, @@ -591,7 +592,7 @@ func (s *KeeperTestSuite) TestMsgSetBaseDenoms() { []types.BaseDenom{ { Denom: "Atom", - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, }, false, @@ -603,7 +604,7 @@ func (s *KeeperTestSuite) TestMsgSetBaseDenoms() { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(0), + StepSize: osmomath.NewInt(0), }, }, false, @@ -615,7 +616,7 @@ func (s *KeeperTestSuite) TestMsgSetBaseDenoms() { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, }, true, @@ -627,7 +628,7 @@ func (s *KeeperTestSuite) TestMsgSetBaseDenoms() { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, }, true, diff --git a/x/protorev/keeper/posthandler.go b/x/protorev/keeper/posthandler.go index 83d5bbc0567..9f14f1d996f 100644 --- a/x/protorev/keeper/posthandler.go +++ b/x/protorev/keeper/posthandler.go @@ -4,6 +4,8 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) type SwapToBackrun struct { @@ -131,7 +133,7 @@ func (k Keeper) ProtoRevTrade(ctx sdk.Context, swappedPools []SwapToBackrun) (er maxProfitInputCoin, maxProfitAmount, optimalRoute := k.IterateRoutes(ctx, routes, &remainingTxPoolPoints, &remainingBlockPoolPoints) // The error that returns here is particularly focused on the minting/burning of coins, and the execution of the MultiHopSwapExactAmountIn. - if maxProfitAmount.GT(sdk.ZeroInt()) { + if maxProfitAmount.GT(osmomath.ZeroInt()) { if err := k.ExecuteTrade(ctx, optimalRoute, maxProfitInputCoin, pool, remainingTxPoolPoints, remainingBlockPoolPoints); err != nil { return err } diff --git a/x/protorev/keeper/posthandler_test.go b/x/protorev/keeper/posthandler_test.go index bfbdaa93f19..f10915dddd0 100644 --- a/x/protorev/keeper/posthandler_test.go +++ b/x/protorev/keeper/posthandler_test.go @@ -12,6 +12,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/keeper" @@ -29,8 +30,8 @@ func BenchmarkBalancerSwapHighestLiquidityArb(b *testing.B) { TokenOutDenom: "ibc/BE1BB42D4BE3C30D50B68D7C41DB4DFCE9678E8EF8C539F6E6A9345048894FCC", }, }, - TokenIn: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", sdk.NewInt(10000)), - TokenOutMinAmount: sdk.NewInt(10000), + TokenIn: sdk.NewCoin("ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", osmomath.NewInt(10000)), + TokenOutMinAmount: osmomath.NewInt(10000), }, } benchmarkWrapper(b, msgs, 1) @@ -47,8 +48,8 @@ func BenchmarkStableSwapHotRouteArb(b *testing.B) { TokenOutDenom: types.OsmosisDenomination, }, }, - TokenIn: sdk.NewCoin("usdc", sdk.NewInt(10000)), - TokenOutMinAmount: sdk.NewInt(100), + TokenIn: sdk.NewCoin("usdc", osmomath.NewInt(10000)), + TokenOutMinAmount: osmomath.NewInt(100), }, } benchmarkWrapper(b, msgs, 1) @@ -65,8 +66,8 @@ func BenchmarkFourHopHotRouteArb(b *testing.B) { TokenOutDenom: "test/2", }, }, - TokenIn: sdk.NewCoin("Atom", sdk.NewInt(10000)), - TokenOutMinAmount: sdk.NewInt(100), + TokenIn: sdk.NewCoin("Atom", osmomath.NewInt(10000)), + TokenOutMinAmount: osmomath.NewInt(100), }, } benchmarkWrapper(b, msgs, 1) @@ -75,7 +76,7 @@ func BenchmarkFourHopHotRouteArb(b *testing.B) { func (s *KeeperTestSuite) TestAnteHandle() { type param struct { trades []types.Trade - expectedNumOfTrades sdk.Int + expectedNumOfTrades osmomath.Int expectedProfits []sdk.Coin expectedPoolPoints uint64 } @@ -101,7 +102,7 @@ func (s *KeeperTestSuite) TestAnteHandle() { name: "Random Msg - Expect Nothing to Happen", params: param{ trades: []types.Trade{}, - expectedNumOfTrades: sdk.ZeroInt(), + expectedNumOfTrades: osmomath.ZeroInt(), expectedProfits: []sdk.Coin{}, expectedPoolPoints: 0, }, @@ -117,7 +118,7 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "juno", }, }, - expectedNumOfTrades: sdk.ZeroInt(), + expectedNumOfTrades: osmomath.ZeroInt(), expectedProfits: []sdk.Coin{}, expectedPoolPoints: 0, }, @@ -133,11 +134,11 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "ibc/0EF15DF2F02480ADE0BB6E85D9EBB5DAEA2836D3860E9F97F9AADE4F57A31AA0", }, }, - expectedNumOfTrades: sdk.OneInt(), + expectedNumOfTrades: osmomath.OneInt(), expectedProfits: []sdk.Coin{ { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(24848), + Amount: osmomath.NewInt(24848), }, }, expectedPoolPoints: 6, @@ -154,15 +155,15 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "Atom", }, }, - expectedNumOfTrades: sdk.NewInt(2), + expectedNumOfTrades: osmomath.NewInt(2), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(5826), + Amount: osmomath.NewInt(5826), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(24848), + Amount: osmomath.NewInt(24848), }, }, expectedPoolPoints: 12, @@ -179,15 +180,15 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "usdc", }, }, - expectedNumOfTrades: sdk.NewInt(3), + expectedNumOfTrades: osmomath.NewInt(3), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(5826), + Amount: osmomath.NewInt(5826), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56609900), + Amount: osmomath.NewInt(56609900), }, }, expectedPoolPoints: 21, @@ -204,15 +205,15 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "Atom", }, }, - expectedNumOfTrades: sdk.NewInt(4), + expectedNumOfTrades: osmomath.NewInt(4), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(15_767_231), + Amount: osmomath.NewInt(15_767_231), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56_609_900), + Amount: osmomath.NewInt(56_609_900), }, }, expectedPoolPoints: 29, @@ -229,19 +230,19 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: types.OsmosisDenomination, }, }, - expectedNumOfTrades: sdk.NewInt(5), + expectedNumOfTrades: osmomath.NewInt(5), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(15_767_231), + Amount: osmomath.NewInt(15_767_231), }, { Denom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", - Amount: sdk.NewInt(218_149_058), + Amount: osmomath.NewInt(218_149_058), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56_609_900), + Amount: osmomath.NewInt(56_609_900), }, }, expectedPoolPoints: 33, @@ -258,19 +259,19 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "busd", }, }, - expectedNumOfTrades: sdk.NewInt(5), + expectedNumOfTrades: osmomath.NewInt(5), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(15_767_231), + Amount: osmomath.NewInt(15_767_231), }, { Denom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", - Amount: sdk.NewInt(218_149_058), + Amount: osmomath.NewInt(218_149_058), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56_609_900), + Amount: osmomath.NewInt(56_609_900), }, }, expectedPoolPoints: 33, @@ -287,19 +288,19 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "busd", }, }, - expectedNumOfTrades: sdk.NewInt(5), + expectedNumOfTrades: osmomath.NewInt(5), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(15_767_231), + Amount: osmomath.NewInt(15_767_231), }, { Denom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", - Amount: sdk.NewInt(218_149_058), + Amount: osmomath.NewInt(218_149_058), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56_609_900), + Amount: osmomath.NewInt(56_609_900), }, }, expectedPoolPoints: 33, @@ -316,19 +317,19 @@ func (s *KeeperTestSuite) TestAnteHandle() { TokenIn: "busd", }, }, - expectedNumOfTrades: sdk.NewInt(5), + expectedNumOfTrades: osmomath.NewInt(5), expectedProfits: []sdk.Coin{ { Denom: "Atom", - Amount: sdk.NewInt(15_767_231), + Amount: osmomath.NewInt(15_767_231), }, { Denom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", - Amount: sdk.NewInt(218_149_058), + Amount: osmomath.NewInt(218_149_058), }, { Denom: types.OsmosisDenomination, - Amount: sdk.NewInt(56_609_900), + Amount: osmomath.NewInt(56_609_900), }, }, expectedPoolPoints: 33, @@ -350,7 +351,7 @@ func (s *KeeperTestSuite) TestAnteHandle() { s.Ctx = s.Ctx.WithMinGasPrices(sdk.NewDecCoins()) gasLimit := uint64(500000) - txFee := sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(10000))) + txFee := sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(10000))) privs, accNums, accSeqs := []cryptotypes.PrivKey{priv0}, []uint64{0}, []uint64{0} signerData := authsigning.SignerData{ @@ -438,7 +439,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.String(), numOfTrades.String()) + s.Require().Equal(tc.params.expectedNumOfTrades, numOfTrades) // Check that the profits are correct profits := s.App.ProtoRevKeeper.GetAllProfits(s.Ctx) @@ -684,7 +685,7 @@ func benchmarkWrapper(b *testing.B, msgs []sdk.Msg, expectedTrades int) { b.Fatal("error getting number of trades") } } - if !numberTrades.Equal(sdk.NewInt(int64(expectedTrades))) { + if !numberTrades.Equal(osmomath.NewInt(int64(expectedTrades))) { b.Fatalf("expected %d trades, got %d", expectedTrades, numberTrades) } } @@ -707,7 +708,7 @@ func setUpBenchmarkSuite(msgs []sdk.Msg) (*KeeperTestSuite, authsigning.Tx, sdk. priv0, _, addr0 := testdata.KeyTestPubAddr() acc1 := s.App.AccountKeeper.NewAccountWithAddress(s.Ctx, addr0) s.App.AccountKeeper.SetAccount(s.Ctx, acc1) - err = simapp.FundAccount(s.App.BankKeeper, s.Ctx, addr0, sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10000)))) + err = simapp.FundAccount(s.App.BankKeeper, s.Ctx, addr0, sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(10000)))) s.Require().NoError(err) // Build the tx @@ -726,7 +727,7 @@ func setUpBenchmarkSuite(msgs []sdk.Msg) (*KeeperTestSuite, authsigning.Tx, sdk. s.clientCtx.TxConfig, accSeqs[0], ) - tx := s.BuildTx(txBuilder, msgs, sigV2, "", sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(10000))), 500000) + tx := s.BuildTx(txBuilder, msgs, sigV2, "", sdk.NewCoins(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(10000))), 500000) // Set up the post handler protoRevDecorator := keeper.NewProtoRevDecorator(*s.App.ProtoRevKeeper) diff --git a/x/protorev/keeper/protorev_test.go b/x/protorev/keeper/protorev_test.go index 918b01a8a94..ead9261d2ee 100644 --- a/x/protorev/keeper/protorev_test.go +++ b/x/protorev/keeper/protorev_test.go @@ -3,14 +3,10 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) -const ( - atomDenom = "Atom" - wethDenom = "weth" -) - // TestGetTokenPairArbRoutes tests the GetTokenPairArbRoutes function. func (s *KeeperTestSuite) TestGetTokenPairArbRoutes() { // Tests that we can properly retrieve all of the routes that were set up @@ -67,7 +63,7 @@ func (s *KeeperTestSuite) TestGetAllBaseDenoms() { s.Require().NoError(err) s.Require().Equal(3, len(baseDenoms)) s.Require().Equal(baseDenoms[0].Denom, types.OsmosisDenomination) - s.Require().Equal(baseDenoms[1].Denom, atomDenom) + s.Require().Equal(baseDenoms[1].Denom, "Atom") s.Require().Equal(baseDenoms[2].Denom, "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7") // Should be able to delete all base denoms @@ -77,80 +73,48 @@ func (s *KeeperTestSuite) TestGetAllBaseDenoms() { s.Require().Equal(0, len(baseDenoms)) // Should be able to set the base denoms - err = s.App.ProtoRevKeeper.SetBaseDenoms(s.Ctx, []types.BaseDenom{{Denom: "osmo"}, {Denom: atomDenom}, {Denom: wethDenom}}) + err = s.App.ProtoRevKeeper.SetBaseDenoms(s.Ctx, []types.BaseDenom{{Denom: "osmo"}, {Denom: "atom"}, {Denom: "weth"}}) s.Require().NoError(err) baseDenoms, err = s.App.ProtoRevKeeper.GetAllBaseDenoms(s.Ctx) s.Require().NoError(err) s.Require().Equal(3, len(baseDenoms)) s.Require().Equal(baseDenoms[0].Denom, "osmo") - s.Require().Equal(baseDenoms[1].Denom, atomDenom) - s.Require().Equal(baseDenoms[2].Denom, wethDenom) + s.Require().Equal(baseDenoms[1].Denom, "atom") + s.Require().Equal(baseDenoms[2].Denom, "weth") } -// runGetPoolForDenomPairTest runs the basic suite of tests shared between GetPoolForDenomPair and GetPoolForDenomPairNoOrder -func (s *KeeperTestSuite) runGetPoolForDenomPairTest(systemUnderTest func(ctx sdk.Context, baseDenom, denomToMatch string) (uint64, error), isNoOrder bool) { +// TestGetPoolForDenomPair tests the GetPoolForDenomPair, SetPoolForDenomPair, and DeleteAllPoolsForBaseDenom functions. +func (s *KeeperTestSuite) TestGetPoolForDenomPair() { // Should be able to set a pool for a denom pair - s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, atomDenom, types.OsmosisDenomination, 1000) - pool, err := systemUnderTest(s.Ctx, atomDenom, types.OsmosisDenomination) + s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, "Atom", types.OsmosisDenomination, 1000) + pool, err := s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "Atom", types.OsmosisDenomination) s.Require().NoError(err) s.Require().Equal(uint64(1000), pool) // Should be able to add another pool for a denom pair - s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, atomDenom, wethDenom, 2000) - pool, err = systemUnderTest(s.Ctx, atomDenom, wethDenom) + s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, "Atom", "weth", 2000) + pool, err = s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "Atom", "weth") s.Require().NoError(err) s.Require().Equal(uint64(2000), pool) - s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, types.OsmosisDenomination, atomDenom, 3000) - pool, err = systemUnderTest(s.Ctx, types.OsmosisDenomination, atomDenom) + s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, types.OsmosisDenomination, "Atom", 3000) + pool, err = s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, types.OsmosisDenomination, "Atom") s.Require().NoError(err) s.Require().Equal(uint64(3000), pool) // Should be able to delete all pools for a base denom - s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, atomDenom) - _, err = systemUnderTest(s.Ctx, atomDenom, types.OsmosisDenomination) - // Note that if this is a no order variant, then there is still a reversed index present so no error is expected. - s.Require().True(isNoOrder && err == nil || !isNoOrder && err != nil) - - _, err = systemUnderTest(s.Ctx, atomDenom, wethDenom) + s.App.ProtoRevKeeper.DeleteAllPoolsForBaseDenom(s.Ctx, "Atom") + _, err = s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "Atom", types.OsmosisDenomination) + s.Require().Error(err) + _, err = s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, "Atom", "weth") s.Require().Error(err) // Other denoms should still exist - pool, err = systemUnderTest(s.Ctx, types.OsmosisDenomination, atomDenom) + pool, err = s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, types.OsmosisDenomination, "Atom") s.Require().NoError(err) s.Require().Equal(uint64(3000), pool) } -// TestGetPoolForDenomPair tests the GetPoolForDenomPair, SetPoolForDenomPair, and DeleteAllPoolsForBaseDenom functions. -// It tests that this method is denom order dependent. That is if set A-B but try to get B-A, an error is returned. -func (s *KeeperTestSuite) TestGetPoolForDenomPair() { - s.runGetPoolForDenomPairTest(s.App.ProtoRevKeeper.GetPoolForDenomPair, false) - - s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, atomDenom, wethDenom, 1000) - - // Different order from what set should return an error - poolId, err := s.App.ProtoRevKeeper.GetPoolForDenomPair(s.Ctx, wethDenom, atomDenom) - s.Require().Error(err) - s.Require().Equal(uint64(0), poolId) - - s.Require().ErrorIs(err, types.NoPoolForDenomPairError{BaseDenom: wethDenom, MatchDenom: atomDenom}) -} - -// tests that the GetPoolForDenomPairNoOrder returns the pool id as long as it exists in any order -// of denoms (not base-quote order dependent). That is if set A-B but try to get B-A, the pool id is returned correctly. -func (s *KeeperTestSuite) TestGetPoolForDenomPairNoOrder() { - s.runGetPoolForDenomPairTest(s.App.ProtoRevKeeper.GetPoolForDenomPairNoOrder, true) - - expectedPoolId := uint64(1000) - - s.App.ProtoRevKeeper.SetPoolForDenomPair(s.Ctx, atomDenom, wethDenom, expectedPoolId) - - // Different order from what set should NOT return an error - poolId, err := s.App.ProtoRevKeeper.GetPoolForDenomPairNoOrder(s.Ctx, wethDenom, atomDenom) - s.Require().NoError(err) - s.Require().Equal(expectedPoolId, poolId) -} - // TestGetDaysSinceModuleGenesis tests the GetDaysSinceModuleGenesis and SetDaysSinceModuleGenesis functions. func (s *KeeperTestSuite) TestGetDaysSinceModuleGenesis() { // Should be initialized to 0 on genesis @@ -178,28 +142,28 @@ func (s *KeeperTestSuite) TestGetDeveloperFees() { s.Require().Equal(sdk.Coin{}, osmoFees) // Should be no atom fees on genesis - atomFees, err := s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, atomDenom) + atomFees, err := s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, "Atom") s.Require().Error(err) s.Require().Equal(sdk.Coin{}, atomFees) // Should be able to set the fees - err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(100))) + err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(100))) s.Require().NoError(err) - err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(atomDenom, sdk.NewInt(100))) + err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin("Atom", osmomath.NewInt(100))) s.Require().NoError(err) - err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(wethDenom, sdk.NewInt(100))) + err = s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin("weth", osmomath.NewInt(100))) s.Require().NoError(err) // Should be able to get the fees osmoFees, err = s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(100)), osmoFees) - atomFees, err = s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, atomDenom) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(100)), osmoFees) + atomFees, err = s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, "Atom") s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(atomDenom, sdk.NewInt(100)), atomFees) - wethFees, err := s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, wethDenom) + s.Require().Equal(sdk.NewCoin("Atom", osmomath.NewInt(100)), atomFees) + wethFees, err := s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, "weth") s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(wethDenom, sdk.NewInt(100)), wethFees) + s.Require().Equal(sdk.NewCoin("weth", osmomath.NewInt(100)), wethFees) fees, err = s.App.ProtoRevKeeper.GetAllDeveloperFees(s.Ctx) s.Require().NoError(err) @@ -210,13 +174,13 @@ func (s *KeeperTestSuite) TestGetDeveloperFees() { // TestDeleteDeveloperFees tests the DeleteDeveloperFees function. func (s *KeeperTestSuite) TestDeleteDeveloperFees() { - err := s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(100))) + err := s.App.ProtoRevKeeper.SetDeveloperFees(s.Ctx, sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(100))) s.Require().NoError(err) // Should be able to get the fees osmoFees, err := s.App.ProtoRevKeeper.GetDeveloperFees(s.Ctx, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(100)), osmoFees) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(100)), osmoFees) // Should be able to delete the fees s.App.ProtoRevKeeper.DeleteDeveloperFees(s.Ctx, types.OsmosisDenomination) diff --git a/x/protorev/keeper/rebalance.go b/x/protorev/keeper/rebalance.go index c597189b8e7..c86801d89bb 100644 --- a/x/protorev/keeper/rebalance.go +++ b/x/protorev/keeper/rebalance.go @@ -3,16 +3,17 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) // IterateRoutes checks the profitability of every single route that is passed in // and returns the optimal route if there is one -func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, sdk.Int, poolmanagertypes.SwapAmountInRoutes) { +func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, osmomath.Int, poolmanagertypes.SwapAmountInRoutes) { var optimalRoute poolmanagertypes.SwapAmountInRoutes var maxProfitInputCoin sdk.Coin - maxProfit := sdk.ZeroInt() + maxProfit := osmomath.ZeroInt() // Iterate through the routes and find the optimal route for the given swap for index := 0; index < len(routes) && *remainingTxPoolPoints > 0; index++ { @@ -29,7 +30,7 @@ func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remaining } // If the profit is greater than zero, then we convert the profits to uosmo and compare profits in terms of uosmo - if profit.GT(sdk.ZeroInt()) { + if profit.GT(osmomath.ZeroInt()) { profit, err := k.ConvertProfits(ctx, inputCoin, profit) if err != nil { k.Logger(ctx).Error("Error converting profits: " + err.Error()) @@ -51,7 +52,7 @@ func (k Keeper) IterateRoutes(ctx sdk.Context, routes []RouteMetaData, remaining // ConvertProfits converts the profit denom to uosmo to allow for a fair comparison of profits // // NOTE: This does not check the underlying pool before swapping so this may go over the MaxTicksCrossed. -func (k Keeper) ConvertProfits(ctx sdk.Context, inputCoin sdk.Coin, profit sdk.Int) (sdk.Int, error) { +func (k Keeper) ConvertProfits(ctx sdk.Context, inputCoin sdk.Coin, profit osmomath.Int) (osmomath.Int, error) { if inputCoin.Denom == types.OsmosisDenomination { return profit, nil } @@ -93,24 +94,24 @@ func (k Keeper) ConvertProfits(ctx sdk.Context, inputCoin sdk.Coin, profit sdk.I // EstimateMultihopProfit estimates the profit for a given route // by estimating the amount out given the amount in for the first pool in the route // and then subtracting the amount in from the amount out to get the profit -func (k Keeper) EstimateMultihopProfit(ctx sdk.Context, inputDenom string, amount sdk.Int, route poolmanagertypes.SwapAmountInRoutes) (sdk.Coin, sdk.Int, error) { +func (k Keeper) EstimateMultihopProfit(ctx sdk.Context, inputDenom string, amount osmomath.Int, route poolmanagertypes.SwapAmountInRoutes) (sdk.Coin, osmomath.Int, error) { tokenIn := sdk.NewCoin(inputDenom, amount) amtOut, err := k.poolmanagerKeeper.MultihopEstimateOutGivenExactAmountIn(ctx, route, tokenIn) if err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err + return sdk.Coin{}, osmomath.ZeroInt(), err } profit := amtOut.Sub(tokenIn.Amount) return tokenIn, profit, nil } // FindMaxProfitRoute runs a binary search to find the max profit for a given route -func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, sdk.Int, error) { +func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, remainingTxPoolPoints, remainingBlockPoolPoints *uint64) (sdk.Coin, osmomath.Int, error) { // Track the tokenIn amount/denom and the profit tokenIn := sdk.Coin{} - profit := sdk.ZeroInt() + profit := osmomath.ZeroInt() // Track the left and right bounds of the binary search - curLeft := sdk.OneInt() + curLeft := osmomath.OneInt() curRight := types.MaxInputAmount // Input denom used for cyclic arbitrage @@ -121,9 +122,9 @@ func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, rema // If there is no profit, then we can return early and not run the binary search. _, minInProfit, err := k.EstimateMultihopProfit(ctx, inputDenom, curLeft.Mul(route.StepSize), route.Route) if err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err - } else if minInProfit.LTE(sdk.ZeroInt()) { - return sdk.Coin{}, sdk.ZeroInt(), nil + return sdk.Coin{}, osmomath.ZeroInt(), err + } else if minInProfit.LTE(osmomath.ZeroInt()) { + return sdk.Coin{}, osmomath.ZeroInt(), nil } // Decrement the number of pool points remaining since we know this route will be profitable @@ -132,30 +133,30 @@ func (k Keeper) FindMaxProfitForRoute(ctx sdk.Context, route RouteMetaData, rema // Increment the number of pool points consumed since we know this route will be profitable if err := k.IncrementPointCountForBlock(ctx, route.PoolPoints); err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err + return sdk.Coin{}, osmomath.ZeroInt(), err } // Update the search range if the max input amount is too small/large curLeft, curRight, err = k.UpdateSearchRangeIfNeeded(ctx, route, inputDenom, curLeft, curRight) if err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err + return sdk.Coin{}, osmomath.ZeroInt(), err } // Binary search to find the max profit for iteration := 0; curLeft.LT(curRight) && iteration < types.MaxIterations; iteration++ { - curMid := (curLeft.Add(curRight)).Quo(sdk.NewInt(2)) - curMidPlusOne := curMid.Add(sdk.OneInt()) + curMid := (curLeft.Add(curRight)).Quo(osmomath.NewInt(2)) + curMidPlusOne := curMid.Add(osmomath.OneInt()) // Short circuit profit searching if there is an error in the GAMM module tokenInMid, profitMid, err := k.EstimateMultihopProfit(ctx, inputDenom, curMid.Mul(route.StepSize), route.Route) if err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err + return sdk.Coin{}, osmomath.ZeroInt(), err } // Short circuit profit searching if there is an error in the GAMM module tokenInMidPlusOne, profitMidPlusOne, err := k.EstimateMultihopProfit(ctx, inputDenom, curMidPlusOne.Mul(route.StepSize), route.Route) if err != nil { - return sdk.Coin{}, sdk.ZeroInt(), err + return sdk.Coin{}, osmomath.ZeroInt(), err } // Reduce subspace to search for max profit @@ -181,12 +182,12 @@ func (k Keeper) UpdateSearchRangeIfNeeded( ctx sdk.Context, route RouteMetaData, inputDenom string, - curLeft, curRight sdk.Int, -) (sdk.Int, sdk.Int, error) { + curLeft, curRight osmomath.Int, +) (osmomath.Int, osmomath.Int, error) { // If there are concentrated liquidity pools in the route, then we may need to reduce the upper bound of the binary search. updatedMax, err := k.CalculateUpperBoundForSearch(ctx, route, inputDenom) if err != nil { - return sdk.ZeroInt(), sdk.ZeroInt(), err + return osmomath.ZeroInt(), osmomath.ZeroInt(), err } // In the case where the updated upper bound is less than the current upper bound, we know we will not extend @@ -204,7 +205,7 @@ func (k Keeper) CalculateUpperBoundForSearch( ctx sdk.Context, route RouteMetaData, inputDenom string, -) (sdk.Int, error) { +) (osmomath.Int, error) { var intermidiateCoin sdk.Coin poolInfo := k.GetInfoByPoolType(ctx) @@ -215,7 +216,7 @@ func (k Keeper) CalculateUpperBoundForSearch( hop := route.Route[index] pool, err := k.poolmanagerKeeper.GetPool(ctx, hop.PoolId) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } tokenInDenom := inputDenom @@ -235,7 +236,7 @@ func (k Keeper) CalculateUpperBoundForSearch( poolInfo.Concentrated.MaxTicksCrossed, ) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } // if there have been no other CL pools in the route, then we can set the intermediate coin to the max input amount. @@ -251,14 +252,14 @@ func (k Keeper) CalculateUpperBoundForSearch( // the smaller amount to ensure we do not overstep the max ticks moved. intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } case !intermidiateCoin.IsNil(): // If we have already seen a CL pool in the route, then simply propagate the intermediate coin up // the route. intermidiateCoin, err = k.executeSafeSwap(ctx, pool.GetId(), intermidiateCoin, tokenInDenom) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } } } @@ -287,11 +288,11 @@ func (k Keeper) executeSafeSwap( ) (sdk.Coin, error) { liquidity, err := k.poolmanagerKeeper.GetTotalPoolLiquidity(ctx, poolID) if err != nil { - return sdk.NewCoin(tokenInDenom, sdk.ZeroInt()), err + return sdk.NewCoin(tokenInDenom, osmomath.ZeroInt()), err } // At most we can swap half of the liquidity in the pool - liquidTokenAmt := liquidity.AmountOf(outputCoin.Denom).Quo(sdk.NewInt(4)) + liquidTokenAmt := liquidity.AmountOf(outputCoin.Denom).Quo(osmomath.NewInt(4)) if liquidTokenAmt.LT(outputCoin.Amount) { outputCoin.Amount = liquidTokenAmt } @@ -307,7 +308,7 @@ func (k Keeper) executeSafeSwap( outputCoin, ) if err != nil { - return sdk.NewCoin(tokenInDenom, sdk.ZeroInt()), err + return sdk.NewCoin(tokenInDenom, osmomath.ZeroInt()), err } return sdk.NewCoin(tokenInDenom, amt), nil @@ -318,20 +319,20 @@ func (k Keeper) ExtendSearchRangeIfNeeded( ctx sdk.Context, route RouteMetaData, inputDenom string, - curLeft, curRight, updatedMax sdk.Int, -) (sdk.Int, sdk.Int, error) { + curLeft, curRight, updatedMax osmomath.Int, +) (osmomath.Int, osmomath.Int, error) { // Get the profit for the maximum amount in _, maxInProfit, err := k.EstimateMultihopProfit(ctx, inputDenom, curRight.Mul(route.StepSize), route.Route) if err != nil { - return sdk.ZeroInt(), sdk.ZeroInt(), err + return osmomath.ZeroInt(), osmomath.ZeroInt(), err } // If the profit for the maximum amount in is still increasing, then we can increase the range of the binary search - if maxInProfit.GTE(sdk.ZeroInt()) { + if maxInProfit.GTE(osmomath.ZeroInt()) { // Get the profit for the maximum amount in + 1 - _, maxInProfitPlusOne, err := k.EstimateMultihopProfit(ctx, inputDenom, curRight.Add(sdk.OneInt()).Mul(route.StepSize), route.Route) + _, maxInProfitPlusOne, err := k.EstimateMultihopProfit(ctx, inputDenom, curRight.Add(osmomath.OneInt()).Mul(route.StepSize), route.Route) if err != nil { - return sdk.ZeroInt(), sdk.ZeroInt(), err + return osmomath.ZeroInt(), osmomath.ZeroInt(), err } // Change the range of the binary search if the profit is still increasing diff --git a/x/protorev/keeper/rebalance_test.go b/x/protorev/keeper/rebalance_test.go index 6a7328c13ef..692e7445078 100644 --- a/x/protorev/keeper/rebalance_test.go +++ b/x/protorev/keeper/rebalance_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/stableswap" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" @@ -12,8 +13,8 @@ import ( ) // Mainnet Arb Route - 2 Asset, Same Weights (Block: 5905150) -// expectedAmtIn: sdk.NewInt(10100000), -// expectedProfit: sdk.NewInt(24852) +// expectedAmtIn: osmomath.NewInt(10100000), +// expectedProfit: osmomath.NewInt(24852) var routeTwoAssetSameWeight = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 22, @@ -30,8 +31,8 @@ var routeTwoAssetSameWeight = poolmanagertypes.SwapAmountInRoutes{ } // Mainnet Arb Route - Multi Asset, Same Weights (Block: 6906570) -// expectedAmtIn: sdk.NewInt(4800000), -// expectedProfit: sdk.NewInt(4547) +// expectedAmtIn: osmomath.NewInt(4800000), +// expectedProfit: osmomath.NewInt(4547) var routeMultiAssetSameWeight = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 26, @@ -48,8 +49,8 @@ var routeMultiAssetSameWeight = poolmanagertypes.SwapAmountInRoutes{ } // Arb Route - Multi Asset, Same Weights - Pool 22 instead of 26 (Block: 6906570) -// expectedAmtIn: sdk.NewInt(519700000), -// expectedProfit: sdk.NewInt(67511701) +// expectedAmtIn: osmomath.NewInt(519700000), +// expectedProfit: osmomath.NewInt(67511701) var routeMostProfitable = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 22, @@ -66,8 +67,8 @@ var routeMostProfitable = poolmanagertypes.SwapAmountInRoutes{ } // Mainnet Arb Route - Multi Asset, Different Weights (Block: 6908256) -// expectedAmtIn: sdk.NewInt(4100000), -// expectedProfit: sdk.NewInt(5826) +// expectedAmtIn: osmomath.NewInt(4100000), +// expectedProfit: osmomath.NewInt(5826) var routeDiffDenom = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 31, @@ -84,8 +85,8 @@ var routeDiffDenom = poolmanagertypes.SwapAmountInRoutes{ } // No Arbitrage Opportunity -// expectedAmtIn: sdk.NewInt(0), -// expectedProfit: sdk.NewInt(0) +// expectedAmtIn: osmomath.NewInt(0), +// expectedProfit: osmomath.NewInt(0) var routeNoArb = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 7, @@ -102,8 +103,8 @@ var routeNoArb = poolmanagertypes.SwapAmountInRoutes{ } // StableSwap Test Route -// expectedAmtIn: sdk.NewInt(137600000), -// expectedProfit: sdk.NewInt(56585438) +// expectedAmtIn: osmomath.NewInt(137600000), +// expectedProfit: osmomath.NewInt(56585438) var routeStableSwap = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 29, @@ -120,8 +121,8 @@ var routeStableSwap = poolmanagertypes.SwapAmountInRoutes{ } // Four Pool Test Route (Mainnet Block: 1855422) -// expectedAmtIn: sdk.NewInt(1_147_000_000) -// expectedProfit: sdk.NewInt(15_761_405) +// expectedAmtIn: osmomath.NewInt(1_147_000_000) +// expectedProfit: osmomath.NewInt(15_761_405) var fourPoolRoute = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 34, @@ -142,8 +143,8 @@ var fourPoolRoute = poolmanagertypes.SwapAmountInRoutes{ } // Two Pool Test Route (Mainnet Block: 6_300_675) -// expectedAmtIn: sdk.NewInt(989_000_000) -// expectedProfit: sdk.NewInt(218_149_058) +// expectedAmtIn: osmomath.NewInt(989_000_000) +// expectedProfit: osmomath.NewInt(218_149_058) var twoPoolRoute = poolmanagertypes.SwapAmountInRoutes{ poolmanagertypes.SwapAmountInRoute{ PoolId: 38, @@ -218,8 +219,8 @@ var panicRoute = poolmanagertypes.SwapAmountInRoutes{ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { type param struct { route poolmanagertypes.SwapAmountInRoutes - expectedAmtIn sdk.Int - expectedProfit sdk.Int + expectedAmtIn osmomath.Int + expectedProfit osmomath.Int routePoolPoints uint64 } @@ -232,8 +233,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Mainnet Arb Route - 2 Asset, Same Weights (Block: 5905150)", param: param{ route: routeTwoAssetSameWeight, - expectedAmtIn: sdk.NewInt(10000000), - expectedProfit: sdk.NewInt(24848), + expectedAmtIn: osmomath.NewInt(10000000), + expectedProfit: osmomath.NewInt(24848), routePoolPoints: 6, }, expectPass: true, @@ -242,8 +243,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Mainnet Arb Route - Multi Asset, Same Weights (Block: 6906570)", param: param{ route: routeMultiAssetSameWeight, - expectedAmtIn: sdk.NewInt(5000000), - expectedProfit: sdk.NewInt(4538), + expectedAmtIn: osmomath.NewInt(5000000), + expectedProfit: osmomath.NewInt(4538), routePoolPoints: 6, }, expectPass: true, @@ -252,8 +253,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Arb Route - Multi Asset, Same Weights - Pool 22 instead of 26 (Block: 6906570)", param: param{ route: routeMostProfitable, - expectedAmtIn: sdk.NewInt(520000000), - expectedProfit: sdk.NewInt(67511675), + expectedAmtIn: osmomath.NewInt(520000000), + expectedProfit: osmomath.NewInt(67511675), routePoolPoints: 6, }, expectPass: true, @@ -262,8 +263,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Mainnet Arb Route - Multi Asset, Different Weights (Block: 6908256)", param: param{ route: routeDiffDenom, - expectedAmtIn: sdk.NewInt(4000000), - expectedProfit: sdk.NewInt(5826), + expectedAmtIn: osmomath.NewInt(4000000), + expectedProfit: osmomath.NewInt(5826), routePoolPoints: 6, }, expectPass: true, @@ -272,8 +273,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "StableSwap Test Route", param: param{ route: routeStableSwap, - expectedAmtIn: sdk.NewInt(138000000), - expectedProfit: sdk.NewInt(56585052), + expectedAmtIn: osmomath.NewInt(138000000), + expectedProfit: osmomath.NewInt(56585052), routePoolPoints: 9, }, expectPass: true, @@ -282,8 +283,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "No Arbitrage Opportunity", param: param{ route: routeNoArb, - expectedAmtIn: sdk.Int{}, - expectedProfit: sdk.NewInt(0), + expectedAmtIn: osmomath.Int{}, + expectedProfit: osmomath.NewInt(0), routePoolPoints: 0, }, expectPass: true, @@ -292,8 +293,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Four Pool Test Route", param: param{ route: fourPoolRoute, - expectedAmtIn: sdk.NewInt(1_147_000_000), - expectedProfit: sdk.NewInt(15_761_405), + expectedAmtIn: osmomath.NewInt(1_147_000_000), + expectedProfit: osmomath.NewInt(15_761_405), routePoolPoints: 8, }, expectPass: true, @@ -302,8 +303,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Two Pool Test Route", param: param{ route: twoPoolRoute, - expectedAmtIn: sdk.NewInt(989_000_000), - expectedProfit: sdk.NewInt(218_149_058), + expectedAmtIn: osmomath.NewInt(989_000_000), + expectedProfit: osmomath.NewInt(218_149_058), routePoolPoints: 4, }, expectPass: true, @@ -312,8 +313,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Extended Range Test Route", param: param{ route: extendedRangeRoute, - expectedAmtIn: sdk.NewInt(131_072_000_000), - expectedProfit: sdk.NewInt(20_900_656_975), + expectedAmtIn: osmomath.NewInt(131_072_000_000), + expectedProfit: osmomath.NewInt(20_900_656_975), routePoolPoints: 10, }, expectPass: true, @@ -322,8 +323,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "Panic Route", param: param{ route: panicRoute, - expectedAmtIn: sdk.NewInt(0), - expectedProfit: sdk.NewInt(0), + expectedAmtIn: osmomath.NewInt(0), + expectedProfit: osmomath.NewInt(0), routePoolPoints: 0, }, expectPass: false, @@ -332,8 +333,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "CL Route (extended range)", // This will search up to 131072 * stepsize param: param{ route: clPoolRouteExtended, - expectedAmtIn: sdk.NewInt(131_072_000_000), - expectedProfit: sdk.NewInt(295_125_808), + expectedAmtIn: osmomath.NewInt(131_072_000_000), + expectedProfit: osmomath.NewInt(295_125_808), routePoolPoints: 7, }, expectPass: true, @@ -342,8 +343,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "CL Route", // This will search up to 131072 * stepsize param: param{ route: clPoolRoute, - expectedAmtIn: sdk.NewInt(13_159_000_000), - expectedProfit: sdk.NewInt(18_055_586), + expectedAmtIn: osmomath.NewInt(13_159_000_000), + expectedProfit: osmomath.NewInt(18_055_586), routePoolPoints: 7, }, expectPass: true, @@ -352,8 +353,8 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { name: "CL Route Multi", // This will search up to 131072 * stepsize param: param{ route: clPoolRouteMulti, - expectedAmtIn: sdk.NewInt(414_000_000), - expectedProfit: sdk.NewInt(171_555_698), + expectedAmtIn: osmomath.NewInt(414_000_000), + expectedProfit: osmomath.NewInt(171_555_698), routePoolPoints: 12, }, expectPass: true, @@ -368,7 +369,7 @@ func (s *KeeperTestSuite) TestFindMaxProfitRoute() { route := protorevtypes.RouteMetaData{ Route: test.param.route, PoolPoints: test.param.routePoolPoints, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } amtIn, profit, err := s.App.ProtoRevKeeper.FindMaxProfitForRoute( @@ -396,7 +397,7 @@ func (s *KeeperTestSuite) TestExecuteTrade() { type param struct { route poolmanagertypes.SwapAmountInRoutes inputCoin sdk.Coin - expectedProfit sdk.Int + expectedProfit osmomath.Int } // Set protorev developer account @@ -408,25 +409,25 @@ func (s *KeeperTestSuite) TestExecuteTrade() { param param arbDenom string expectPass bool - expectedNumOfTrades sdk.Int + expectedNumOfTrades osmomath.Int }{ { name: "Mainnet Arb Route", param: param{ route: routeTwoAssetSameWeight, - inputCoin: sdk.NewCoin("uosmo", sdk.NewInt(10100000)), - expectedProfit: sdk.NewInt(24852), + inputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(10100000)), + expectedProfit: osmomath.NewInt(24852), }, arbDenom: types.OsmosisDenomination, expectPass: true, - expectedNumOfTrades: sdk.NewInt(1), + expectedNumOfTrades: osmomath.NewInt(1), }, { name: "No arbitrage opportunity - expect error at multihopswap due to profitability invariant", param: param{ route: routeNoArb, - inputCoin: sdk.NewCoin("uosmo", sdk.NewInt(1000000)), - expectedProfit: sdk.NewInt(0), + inputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(1000000)), + expectedProfit: osmomath.NewInt(0), }, arbDenom: types.OsmosisDenomination, expectPass: false, @@ -435,8 +436,8 @@ func (s *KeeperTestSuite) TestExecuteTrade() { name: "0 input amount - expect error at multihopswap due to amount needing to be positive", param: param{ route: routeNoArb, - inputCoin: sdk.NewCoin("uosmo", sdk.NewInt(0)), - expectedProfit: sdk.NewInt(0), + inputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(0)), + expectedProfit: osmomath.NewInt(0), }, arbDenom: types.OsmosisDenomination, expectPass: false, @@ -445,23 +446,23 @@ func (s *KeeperTestSuite) TestExecuteTrade() { name: "4-Pool Route Arb", param: param{ route: fourPoolRoute, - inputCoin: sdk.NewCoin("Atom", sdk.NewInt(1_147_000_000)), - expectedProfit: sdk.NewInt(15_761_405), + inputCoin: sdk.NewCoin("Atom", osmomath.NewInt(1_147_000_000)), + expectedProfit: osmomath.NewInt(15_761_405), }, arbDenom: "Atom", expectPass: true, - expectedNumOfTrades: sdk.NewInt(2), + expectedNumOfTrades: osmomath.NewInt(2), }, { name: "2-Pool Route Arb", param: param{ route: twoPoolRoute, - inputCoin: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(989_000_000)), - expectedProfit: sdk.NewInt(218_149_058), + inputCoin: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(989_000_000)), + expectedProfit: osmomath.NewInt(218_149_058), }, arbDenom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", expectPass: true, - expectedNumOfTrades: sdk.NewInt(3), + expectedNumOfTrades: osmomath.NewInt(3), }, } @@ -486,7 +487,7 @@ func (s *KeeperTestSuite) TestExecuteTrade() { // Check the protorev statistics numberOfTrades, err := s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, test.param.route.PoolIds()) s.Require().NoError(err) - s.Require().Equal(sdk.OneInt(), numberOfTrades) + s.Require().Equal(osmomath.OneInt(), numberOfTrades) routeProfit, err := s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, test.param.route.PoolIds(), test.arbDenom) s.Require().NoError(err) @@ -513,7 +514,7 @@ func (s *KeeperTestSuite) TestExecuteTrade() { func (s *KeeperTestSuite) TestIterateRoutes() { type paramm struct { routes []poolmanagertypes.SwapAmountInRoutes - expectedMaxProfitAmount sdk.Int + expectedMaxProfitAmount osmomath.Int expectedMaxProfitInputCoin sdk.Coin expectedOptimalRoute poolmanagertypes.SwapAmountInRoutes @@ -529,8 +530,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Single Route Test", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{routeTwoAssetSameWeight}, - expectedMaxProfitAmount: sdk.NewInt(24848), - expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", sdk.NewInt(10000000)), + expectedMaxProfitAmount: osmomath.NewInt(24848), + expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(10000000)), expectedOptimalRoute: routeTwoAssetSameWeight, arbDenom: types.OsmosisDenomination, }, @@ -540,8 +541,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Two routes with same arb denom test - more profitable route second", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{routeMultiAssetSameWeight, routeTwoAssetSameWeight}, - expectedMaxProfitAmount: sdk.NewInt(24848), - expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", sdk.NewInt(10000000)), + expectedMaxProfitAmount: osmomath.NewInt(24848), + expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(10000000)), expectedOptimalRoute: routeTwoAssetSameWeight, arbDenom: types.OsmosisDenomination, }, @@ -551,8 +552,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Three routes with same arb denom test - most profitable route first", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{routeMostProfitable, routeMultiAssetSameWeight, routeTwoAssetSameWeight}, - expectedMaxProfitAmount: sdk.NewInt(67511675), - expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", sdk.NewInt(520000000)), + expectedMaxProfitAmount: osmomath.NewInt(67511675), + expectedMaxProfitInputCoin: sdk.NewCoin("uosmo", osmomath.NewInt(520000000)), expectedOptimalRoute: routeMostProfitable, arbDenom: types.OsmosisDenomination, }, @@ -562,8 +563,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Two routes, different arb denoms test - more profitable route second", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{routeNoArb, routeDiffDenom}, - expectedMaxProfitAmount: sdk.NewInt(4880), - expectedMaxProfitInputCoin: sdk.NewCoin("Atom", sdk.NewInt(4000000)), + expectedMaxProfitAmount: osmomath.NewInt(4880), + expectedMaxProfitInputCoin: sdk.NewCoin("Atom", osmomath.NewInt(4000000)), expectedOptimalRoute: routeDiffDenom, arbDenom: "Atom", }, @@ -573,8 +574,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Four-pool route test", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{fourPoolRoute}, - expectedMaxProfitAmount: sdk.NewInt(13_202_729), - expectedMaxProfitInputCoin: sdk.NewCoin("Atom", sdk.NewInt(1_147_000_000)), + expectedMaxProfitAmount: osmomath.NewInt(13_202_729), + expectedMaxProfitInputCoin: sdk.NewCoin("Atom", osmomath.NewInt(1_147_000_000)), expectedOptimalRoute: fourPoolRoute, arbDenom: "Atom", }, @@ -584,8 +585,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { name: "Two-pool route test", params: paramm{ routes: []poolmanagertypes.SwapAmountInRoutes{twoPoolRoute}, - expectedMaxProfitAmount: sdk.NewInt(198_653_535), - expectedMaxProfitInputCoin: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", sdk.NewInt(989_000_000)), + expectedMaxProfitAmount: osmomath.NewInt(198_653_535), + expectedMaxProfitInputCoin: sdk.NewCoin("ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", osmomath.NewInt(989_000_000)), expectedOptimalRoute: twoPoolRoute, arbDenom: "ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7", }, @@ -600,7 +601,7 @@ func (s *KeeperTestSuite) TestIterateRoutes() { routes[i] = protorevtypes.RouteMetaData{ Route: route, PoolPoints: 0, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } } // Set a high default pool points so that all routes are considered @@ -609,8 +610,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.String(), maxProfitAmount.String()) - s.Require().Equal(test.params.expectedMaxProfitInputCoin.String(), maxProfitInputCoin.String()) + s.Require().Equal(test.params.expectedMaxProfitAmount, maxProfitAmount) + s.Require().Equal(test.params.expectedMaxProfitInputCoin, maxProfitInputCoin) s.Require().Equal(test.params.expectedOptimalRoute, optimalRoute) } }) @@ -621,8 +622,8 @@ func (s *KeeperTestSuite) TestIterateRoutes() { func (s *KeeperTestSuite) TestConvertProfits() { type param struct { inputCoin sdk.Coin - profit sdk.Int - expectedUosmoProfit sdk.Int + profit osmomath.Int + expectedUosmoProfit osmomath.Int } tests := []struct { @@ -633,27 +634,27 @@ func (s *KeeperTestSuite) TestConvertProfits() { { name: "Convert atom to uosmo", param: param{ - inputCoin: sdk.NewCoin("Atom", sdk.NewInt(100)), - profit: sdk.NewInt(10), - expectedUosmoProfit: sdk.NewInt(8), + inputCoin: sdk.NewCoin("Atom", osmomath.NewInt(100)), + profit: osmomath.NewInt(10), + expectedUosmoProfit: osmomath.NewInt(8), }, expectPass: true, }, { name: "Convert juno to uosmo (random denom)", param: param{ - inputCoin: sdk.NewCoin("juno", sdk.NewInt(100)), - profit: sdk.NewInt(10), - expectedUosmoProfit: sdk.NewInt(9), + inputCoin: sdk.NewCoin("juno", osmomath.NewInt(100)), + profit: osmomath.NewInt(10), + expectedUosmoProfit: osmomath.NewInt(9), }, expectPass: true, }, { name: "Convert denom without pool to uosmo", param: param{ - inputCoin: sdk.NewCoin("random", sdk.NewInt(100)), - profit: sdk.NewInt(10), - expectedUosmoProfit: sdk.NewInt(10), + inputCoin: sdk.NewCoin("random", osmomath.NewInt(100)), + profit: osmomath.NewInt(10), + expectedUosmoProfit: osmomath.NewInt(10), }, expectPass: false, }, @@ -737,18 +738,17 @@ func (s *KeeperTestSuite) TestRemainingPoolPointsForTx() { } func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { - s.SetupTest() s.Run("Extended search on stable pools", func() { route := keeper.RouteMetaData{ Route: extendedRangeRoute, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } curLeft, curRight, err := s.App.ProtoRevKeeper.UpdateSearchRangeIfNeeded( s.Ctx, route, "usdx", - sdk.OneInt(), + osmomath.OneInt(), types.MaxInputAmount, ) s.Require().NoError(err) @@ -758,13 +758,13 @@ func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { s.Run("Extended search on CL pools", func() { // Create two massive CL pools with a massive arb - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "atom", "uosmo", apptesting.DefaultTickSpacing, sdk.ZeroDec()) - fundCoins := sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", sdk.NewInt(10_000_000_000_000))) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "atom", "uosmo", apptesting.DefaultTickSpacing, osmomath.ZeroDec()) + fundCoins := sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", osmomath.NewInt(10_000_000_000_000))) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool, fundCoins) - clPool2 := s.PrepareCustomConcentratedPool(s.TestAccs[0], "atom", "uosmo", apptesting.DefaultTickSpacing, sdk.ZeroDec()) - fundCoins = sdk.NewCoins(sdk.NewCoin("atom", sdk.NewInt(20_000_000_000_000)), sdk.NewCoin("uosmo", sdk.NewInt(10_000_000_000_000))) + clPool2 := s.PrepareCustomConcentratedPool(s.TestAccs[0], "atom", "uosmo", apptesting.DefaultTickSpacing, osmomath.ZeroDec()) + fundCoins = sdk.NewCoins(sdk.NewCoin("atom", osmomath.NewInt(20_000_000_000_000)), sdk.NewCoin("uosmo", osmomath.NewInt(10_000_000_000_000))) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool2, fundCoins) @@ -779,14 +779,14 @@ func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { TokenOutDenom: "atom", }, }, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } curLeft, curRight, err := s.App.ProtoRevKeeper.UpdateSearchRangeIfNeeded( s.Ctx, route, "atom", - sdk.OneInt(), + osmomath.OneInt(), types.MaxInputAmount, ) s.Require().NoError(err) @@ -797,19 +797,19 @@ func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { s.Run("Reduced search on CL pools", func() { stablePool := s.createStableswapPool( sdk.NewCoins( - sdk.NewCoin("uosmo", sdk.NewInt(25_000_000_000)), - sdk.NewCoin("eth", sdk.NewInt(20_000_000_000)), + sdk.NewCoin("uosmo", osmomath.NewInt(25_000_000_000)), + sdk.NewCoin("eth", osmomath.NewInt(20_000_000_000)), ), stableswap.PoolParams{ - SwapFee: sdk.NewDecWithPrec(0, 2), - ExitFee: sdk.NewDecWithPrec(0, 2), + SwapFee: osmomath.NewDecWithPrec(0, 2), + ExitFee: osmomath.NewDecWithPrec(0, 2), }, []uint64{1, 1}, ) // Create two massive CL pools with a massive arb - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "eth", "uosmo", apptesting.DefaultTickSpacing, sdk.ZeroDec()) - fundCoins := sdk.NewCoins(sdk.NewCoin("eth", sdk.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", sdk.NewInt(10_000_000_000_000))) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], "eth", "uosmo", apptesting.DefaultTickSpacing, osmomath.ZeroDec()) + fundCoins := sdk.NewCoins(sdk.NewCoin("eth", osmomath.NewInt(10_000_000_000_000)), sdk.NewCoin("uosmo", osmomath.NewInt(10_000_000_000_000))) s.FundAcc(s.TestAccs[0], fundCoins) s.CreateFullRangePosition(clPool, fundCoins) @@ -824,18 +824,18 @@ func (s *KeeperTestSuite) TestUpdateSearchRangeIfNeeded() { TokenOutDenom: "uosmo", }, }, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } curLeft, curRight, err := s.App.ProtoRevKeeper.UpdateSearchRangeIfNeeded( s.Ctx, route, "uosmo", - sdk.OneInt(), + osmomath.OneInt(), types.MaxInputAmount, ) s.Require().NoError(err) - s.Require().Equal(sdk.OneInt(), curLeft) - s.Require().Equal(sdk.NewInt(5141), curRight) + s.Require().Equal(osmomath.OneInt(), curLeft) + s.Require().Equal(osmomath.NewInt(5141), curRight) }) } diff --git a/x/protorev/keeper/routes.go b/x/protorev/keeper/routes.go index 3e0043df127..3ba91a65e4c 100644 --- a/x/protorev/keeper/routes.go +++ b/x/protorev/keeper/routes.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -15,7 +16,7 @@ type RouteMetaData struct { // The number of pool points that were consumed to build the route PoolPoints uint64 // The step size that should be used in the binary search for the optimal swap amount - StepSize sdk.Int + StepSize osmomath.Int } // BuildRoutes builds all of the possible arbitrage routes given the tokenIn, tokenOut and poolId that were used in the swap. diff --git a/x/protorev/keeper/routes_test.go b/x/protorev/keeper/routes_test.go index cdeb04d6a6f..593973d6f10 100644 --- a/x/protorev/keeper/routes_test.go +++ b/x/protorev/keeper/routes_test.go @@ -1,8 +1,7 @@ package keeper_test import ( - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -203,7 +202,7 @@ func (s *KeeperTestSuite) TestBuildHighestLiquidityRoute() { baseDenom := types.BaseDenom{ Denom: tc.swapDenom, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), } routeMetaData, err := s.App.ProtoRevKeeper.BuildHighestLiquidityRoute(s.Ctx, baseDenom, tc.swapIn, tc.swapOut, tc.poolId) @@ -229,7 +228,7 @@ func (s *KeeperTestSuite) TestBuildHotRoutes() { swapOut string poolId uint64 expectedRoutes [][]TestRoute - expectedStepSize []sdk.Int + expectedStepSize []osmomath.Int expectedRoutePoolPoints []uint64 hasRoutes bool }{ @@ -245,7 +244,7 @@ func (s *KeeperTestSuite) TestBuildHotRoutes() { {4, "bitcoin", "Atom"}, }, }, - expectedStepSize: []sdk.Int{sdk.NewInt(1_000_000)}, + expectedStepSize: []osmomath.Int{osmomath.NewInt(1_000_000)}, expectedRoutePoolPoints: []uint64{6}, hasRoutes: true, }, @@ -262,7 +261,7 @@ func (s *KeeperTestSuite) TestBuildHotRoutes() { {10, "test/2", "Atom"}, }, }, - expectedStepSize: []sdk.Int{sdk.NewInt(1_000_000)}, + expectedStepSize: []osmomath.Int{osmomath.NewInt(1_000_000)}, expectedRoutePoolPoints: []uint64{8}, hasRoutes: true, }, diff --git a/x/protorev/keeper/statistics.go b/x/protorev/keeper/statistics.go index 3b0b92f4721..574b916feda 100644 --- a/x/protorev/keeper/statistics.go +++ b/x/protorev/keeper/statistics.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -14,17 +15,17 @@ import ( // ----------------------- Statistics Stores ----------------------- // // GetNumberOfTrades returns the number of trades executed by the ProtoRev module -func (k Keeper) GetNumberOfTrades(ctx sdk.Context) (sdk.Int, error) { +func (k Keeper) GetNumberOfTrades(ctx sdk.Context) (osmomath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixNumberOfTrades) bz := store.Get(types.KeyPrefixNumberOfTrades) if len(bz) == 0 { - return sdk.ZeroInt(), fmt.Errorf("no trades have been executed by the protorev module") + return osmomath.ZeroInt(), fmt.Errorf("no trades have been executed by the protorev module") } - trades := sdk.Int{} + trades := osmomath.Int{} if err := trades.Unmarshal(bz); err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } return trades, nil @@ -35,7 +36,7 @@ func (k Keeper) IncrementNumberOfTrades(ctx sdk.Context) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixNumberOfTrades) numberOfTrades, _ := k.GetNumberOfTrades(ctx) - numberOfTrades = numberOfTrades.Add(sdk.OneInt()) + numberOfTrades = numberOfTrades.Add(osmomath.OneInt()) bz, err := numberOfTrades.Marshal() if err != nil { @@ -52,12 +53,12 @@ func (k Keeper) GetProfitsByDenom(ctx sdk.Context, denom string) (sdk.Coin, erro bz := store.Get(key) if len(bz) == 0 { - return sdk.NewCoin(denom, sdk.ZeroInt()), fmt.Errorf("no profits for denom %s", denom) + return sdk.NewCoin(denom, osmomath.ZeroInt()), fmt.Errorf("no profits for denom %s", denom) } profits := sdk.Coin{} if err := profits.Unmarshal(bz); err != nil { - return sdk.NewCoin(denom, sdk.ZeroInt()), err + return sdk.NewCoin(denom, osmomath.ZeroInt()), err } return profits, nil @@ -83,7 +84,7 @@ func (k Keeper) GetAllProfits(ctx sdk.Context) []sdk.Coin { } // UpdateProfitsByDenom updates the profits made by the ProtoRev module for the given denom -func (k Keeper) UpdateProfitsByDenom(ctx sdk.Context, denom string, tradeProfit sdk.Int) error { +func (k Keeper) UpdateProfitsByDenom(ctx sdk.Context, denom string, tradeProfit osmomath.Int) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixProfitByDenom) key := types.GetKeyPrefixProfitByDenom(denom) @@ -123,18 +124,18 @@ func (k Keeper) GetAllRoutes(ctx sdk.Context) ([][]uint64, error) { } // GetTradesByRoute returns the number of trades executed by the ProtoRev module for the given route -func (k Keeper) GetTradesByRoute(ctx sdk.Context, route []uint64) (sdk.Int, error) { +func (k Keeper) GetTradesByRoute(ctx sdk.Context, route []uint64) (osmomath.Int, error) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixTradesByRoute) key := types.GetKeyPrefixTradesByRoute(route) bz := store.Get(key) if len(bz) == 0 { - return sdk.ZeroInt(), fmt.Errorf("no trades for route %d", route) + return osmomath.ZeroInt(), fmt.Errorf("no trades for route %d", route) } - trades := sdk.Int{} + trades := osmomath.Int{} if err := trades.Unmarshal(bz); err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } return trades, nil } @@ -145,7 +146,7 @@ func (k Keeper) IncrementTradesByRoute(ctx sdk.Context, route []uint64) error { key := types.GetKeyPrefixTradesByRoute(route) trades, _ := k.GetTradesByRoute(ctx, route) - trades = trades.Add(sdk.OneInt()) + trades = trades.Add(osmomath.OneInt()) bz, err := trades.Marshal() if err != nil { return err @@ -162,12 +163,12 @@ func (k Keeper) GetProfitsByRoute(ctx sdk.Context, route []uint64, denom string) bz := store.Get(key) if len(bz) == 0 { - return sdk.NewCoin(denom, sdk.ZeroInt()), fmt.Errorf("no profits for route %d", route) + return sdk.NewCoin(denom, osmomath.ZeroInt()), fmt.Errorf("no profits for route %d", route) } profits := sdk.Coin{} if err := profits.Unmarshal(bz); err != nil { - return sdk.NewCoin(denom, sdk.ZeroInt()), err + return sdk.NewCoin(denom, osmomath.ZeroInt()), err } return profits, nil @@ -194,7 +195,7 @@ func (k Keeper) GetAllProfitsByRoute(ctx sdk.Context, route []uint64) []sdk.Coin } // UpdateProfitsByRoute updates the profits made by the ProtoRev module for the given route and denom -func (k Keeper) UpdateProfitsByRoute(ctx sdk.Context, route []uint64, denom string, profit sdk.Int) error { +func (k Keeper) UpdateProfitsByRoute(ctx sdk.Context, route []uint64, denom string, profit osmomath.Int) error { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefixProfitsByRoute) key := types.GetKeyPrefixProfitsByRoute(route, denom) @@ -210,7 +211,7 @@ func (k Keeper) UpdateProfitsByRoute(ctx sdk.Context, route []uint64, denom stri } // UpdateStatistics updates the module statistics after each trade is executed -func (k Keeper) UpdateStatistics(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, denom string, profit sdk.Int) error { +func (k Keeper) UpdateStatistics(ctx sdk.Context, route poolmanagertypes.SwapAmountInRoutes, denom string, profit osmomath.Int) error { // Increment the number of trades executed by the ProtoRev module if err := k.IncrementNumberOfTrades(ctx); err != nil { return err diff --git a/x/protorev/keeper/statistics_test.go b/x/protorev/keeper/statistics_test.go index 642774153f6..fe7980ddc45 100644 --- a/x/protorev/keeper/statistics_test.go +++ b/x/protorev/keeper/statistics_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) @@ -12,7 +13,7 @@ func (s *KeeperTestSuite) TestGetNumberOfTrades() { // Should be zero by default numberOfTrades, err := s.App.ProtoRevKeeper.GetNumberOfTrades(s.Ctx) s.Require().Error(err) - s.Require().Equal(sdk.NewInt(0), numberOfTrades) + s.Require().Equal(osmomath.NewInt(0), numberOfTrades) // Pseudo execute a trade err = s.App.ProtoRevKeeper.IncrementNumberOfTrades(s.Ctx) @@ -21,7 +22,7 @@ func (s *KeeperTestSuite) TestGetNumberOfTrades() { // Check the updated result numberOfTrades, err = s.App.ProtoRevKeeper.GetNumberOfTrades(s.Ctx) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), numberOfTrades) + s.Require().Equal(osmomath.NewInt(1), numberOfTrades) } // TestGetProfitsByDenom tests GetProfitsByDenom, UpdateProfitsByDenom, and GetAllProfits @@ -29,37 +30,37 @@ func (s *KeeperTestSuite) TestGetProfitsByDenom() { // Should be zero by default profits, err := s.App.ProtoRevKeeper.GetProfitsByDenom(s.Ctx, types.OsmosisDenomination) s.Require().Error(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.ZeroInt()), profits) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.ZeroInt()), profits) // Pseudo execute a trade - err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, types.OsmosisDenomination, sdk.NewInt(9000)) + err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, types.OsmosisDenomination, osmomath.NewInt(9000)) s.Require().NoError(err) // Check the updated result profits, err = s.App.ProtoRevKeeper.GetProfitsByDenom(s.Ctx, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(9000)), profits) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(9000)), profits) // Pseudo execute a second trade - err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, types.OsmosisDenomination, sdk.NewInt(5000)) + err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, types.OsmosisDenomination, osmomath.NewInt(5000)) s.Require().NoError(err) // Check the updated result after the second trade profits, err = s.App.ProtoRevKeeper.GetProfitsByDenom(s.Ctx, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(14000)), profits) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(14000)), profits) // Check the result of GetAllProfits allProfits := s.App.ProtoRevKeeper.GetAllProfits(s.Ctx) - s.Require().Equal([]sdk.Coin{{Denom: types.OsmosisDenomination, Amount: sdk.NewInt(14000)}}, allProfits) + s.Require().Equal([]sdk.Coin{{Denom: types.OsmosisDenomination, Amount: osmomath.NewInt(14000)}}, allProfits) // Pseudo execute a third trade in a different denom - err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, "Atom", sdk.NewInt(1000)) + err = s.App.ProtoRevKeeper.UpdateProfitsByDenom(s.Ctx, "Atom", osmomath.NewInt(1000)) s.Require().NoError(err) // Check the result of GetAllProfits allProfits = s.App.ProtoRevKeeper.GetAllProfits(s.Ctx) - s.Require().Equal([]sdk.Coin{{Denom: "Atom", Amount: sdk.NewInt(1000)}, {Denom: types.OsmosisDenomination, Amount: sdk.NewInt(14000)}}, allProfits) + s.Require().Equal([]sdk.Coin{{Denom: "Atom", Amount: osmomath.NewInt(1000)}, {Denom: types.OsmosisDenomination, Amount: osmomath.NewInt(14000)}}, allProfits) } // TestGetTradesByRoute tests GetTradesByRoute, IncrementTradesByRoute, and GetAllRoutes @@ -72,7 +73,7 @@ func (s *KeeperTestSuite) TestGetTradesByRoute() { // Check the number of trades for a route that has not been executed trades, err := s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, []uint64{1, 2, 3}) s.Require().Error(err) - s.Require().Equal(sdk.NewInt(0), trades) + s.Require().Equal(osmomath.NewInt(0), trades) // Pseudo execute a trade err = s.App.ProtoRevKeeper.IncrementTradesByRoute(s.Ctx, []uint64{1, 2, 3}) @@ -81,7 +82,7 @@ func (s *KeeperTestSuite) TestGetTradesByRoute() { // Check the updated result trades, err = s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, []uint64{1, 2, 3}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), trades) + s.Require().Equal(osmomath.NewInt(1), trades) // Check the result of GetAllRoutes routes, err = s.App.ProtoRevKeeper.GetAllRoutes(s.Ctx) @@ -96,7 +97,7 @@ func (s *KeeperTestSuite) TestGetTradesByRoute() { // Check the updated result after the second trade trades, err = s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, []uint64{2, 3, 4}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), trades) + s.Require().Equal(osmomath.NewInt(1), trades) // Check the result of GetAllRoutes routes, err = s.App.ProtoRevKeeper.GetAllRoutes(s.Ctx) @@ -115,34 +116,34 @@ func (s *KeeperTestSuite) TestGetProfitsByRoute() { // Check the profits for a route that has not been executed profit, err := s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, types.OsmosisDenomination) s.Require().Error(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.ZeroInt()), profit) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.ZeroInt()), profit) // Pseudo execute a trade - err = s.App.ProtoRevKeeper.UpdateProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, types.OsmosisDenomination, sdk.NewInt(1000)) + err = s.App.ProtoRevKeeper.UpdateProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, types.OsmosisDenomination, osmomath.NewInt(1000)) s.Require().NoError(err) // Check the updated result profit, err = s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), profit) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), profit) // Check the result of GetAllProfitsByRoute profits = s.App.ProtoRevKeeper.GetAllProfitsByRoute(s.Ctx, []uint64{1, 2, 3}) - s.Require().Equal([]sdk.Coin{{Denom: types.OsmosisDenomination, Amount: sdk.NewInt(1000)}}, profits) + s.Require().Equal([]sdk.Coin{{Denom: types.OsmosisDenomination, Amount: osmomath.NewInt(1000)}}, profits) // Pseudo execute a second trade - err = s.App.ProtoRevKeeper.UpdateProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, "Atom", sdk.NewInt(2000)) + err = s.App.ProtoRevKeeper.UpdateProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, "Atom", osmomath.NewInt(2000)) s.Require().NoError(err) // Check the updated result after the second trade profit, err = s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, "Atom") s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin("Atom", sdk.NewInt(2000)), profit) + s.Require().Equal(sdk.NewCoin("Atom", osmomath.NewInt(2000)), profit) // Check the result of GetAllProfitsByRoute profits = s.App.ProtoRevKeeper.GetAllProfitsByRoute(s.Ctx, []uint64{1, 2, 3}) - s.Require().Contains(profits, sdk.Coin{Denom: types.OsmosisDenomination, Amount: sdk.NewInt(1000)}) - s.Require().Contains(profits, sdk.Coin{Denom: "Atom", Amount: sdk.NewInt(2000)}) + s.Require().Contains(profits, sdk.Coin{Denom: types.OsmosisDenomination, Amount: osmomath.NewInt(1000)}) + s.Require().Contains(profits, sdk.Coin{Denom: "Atom", Amount: osmomath.NewInt(2000)}) } // TestUpdateStatistics tests UpdateStatistics which is a wrapper for much of the statistics keeper @@ -151,19 +152,19 @@ func (s *KeeperTestSuite) TestUpdateStatistics() { // Pseudo execute a trade err := s.App.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 1}, {TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}}, - types.OsmosisDenomination, sdk.NewInt(1000), + types.OsmosisDenomination, osmomath.NewInt(1000), ) s.Require().NoError(err) // Check the result of GetTradesByRoute trades, err := s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, []uint64{1, 2, 3}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), trades) + s.Require().Equal(osmomath.NewInt(1), trades) // Check the result of GetProfitsByRoute profit, err := s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, []uint64{1, 2, 3}, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1000)), profit) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1000)), profit) // Check the result of GetAllRoutes routes, err := s.App.ProtoRevKeeper.GetAllRoutes(s.Ctx) @@ -173,19 +174,19 @@ func (s *KeeperTestSuite) TestUpdateStatistics() { // Pseudo execute a second trade err = s.App.ProtoRevKeeper.UpdateStatistics(s.Ctx, poolmanagertypes.SwapAmountInRoutes{{TokenOutDenom: "", PoolId: 2}, {TokenOutDenom: "", PoolId: 3}, {TokenOutDenom: "", PoolId: 4}}, - types.OsmosisDenomination, sdk.NewInt(1100), + types.OsmosisDenomination, osmomath.NewInt(1100), ) s.Require().NoError(err) // Check the result of GetTradesByRoute trades, err = s.App.ProtoRevKeeper.GetTradesByRoute(s.Ctx, []uint64{2, 3, 4}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1), trades) + s.Require().Equal(osmomath.NewInt(1), trades) // Check the result of GetProfitsByRoute profit, err = s.App.ProtoRevKeeper.GetProfitsByRoute(s.Ctx, []uint64{2, 3, 4}, types.OsmosisDenomination) s.Require().NoError(err) - s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, sdk.NewInt(1100)), profit) + s.Require().Equal(sdk.NewCoin(types.OsmosisDenomination, osmomath.NewInt(1100)), profit) // Check the result of GetAllRoutes routes, err = s.App.ProtoRevKeeper.GetAllRoutes(s.Ctx) diff --git a/x/protorev/protorev.md b/x/protorev/protorev.md index f1b023b6c79..ea256b02444 100644 --- a/x/protorev/protorev.md +++ b/x/protorev/protorev.md @@ -116,7 +116,7 @@ message Route { // The step size that will be used to find the optimal swap amount in the // binary search string step_size = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.customtype) = "cosmossdk.io/math.Int", (gogoproto.nullable) = true ]; } diff --git a/x/protorev/types/constants.go b/x/protorev/types/constants.go index 23c0cbc7772..149fc5b5163 100644 --- a/x/protorev/types/constants.go +++ b/x/protorev/types/constants.go @@ -1,8 +1,6 @@ package types -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) +import "github.com/osmosis-labs/osmosis/osmomath" // OsmosisDenomination stores the native denom name for Osmosis on chain used for route building var OsmosisDenomination string = "uosmo" @@ -10,11 +8,11 @@ var OsmosisDenomination string = "uosmo" // ----------------- Module Execution Time Constants ----------------- // // MaxInputAmount is the upper bound index for finding the optimal in amount when determining route profitability (2 ^ 14) = 16,384 -var MaxInputAmount = sdk.NewInt(16_384) +var MaxInputAmount = osmomath.NewInt(16_384) // ExtendedMaxInputAmount is the upper bound index for finding the optimal in amount // when determining route profitability for an arb that's above the default range (2 ^ 17) = 131,072 -var ExtendedMaxInputAmount = sdk.NewInt(131_072) +var ExtendedMaxInputAmount = osmomath.NewInt(131_072) // Max iterations for binary search (log2(131_072) = 17) const MaxIterations int = 17 diff --git a/x/protorev/types/expected_keepers.go b/x/protorev/types/expected_keepers.go index 383761f8118..ba0336514c6 100644 --- a/x/protorev/types/expected_keepers.go +++ b/x/protorev/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" epochtypes "github.com/osmosis-labs/osmosis/x/epochs/types" @@ -36,18 +37,18 @@ type PoolManagerKeeper interface { sender sdk.AccAddress, routes []poolmanagertypes.SwapAmountInRoute, tokenIn sdk.Coin, - tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) + tokenOutMinAmount osmomath.Int) (tokenOutAmount osmomath.Int, err error) MultihopEstimateOutGivenExactAmountIn( ctx sdk.Context, routes []poolmanagertypes.SwapAmountInRoute, tokenIn sdk.Coin, - ) (tokenOutAmount sdk.Int, err error) + ) (tokenOutAmount osmomath.Int, err error) MultihopEstimateInGivenExactAmountOut( ctx sdk.Context, routes []poolmanagertypes.SwapAmountOutRoute, - tokenOut sdk.Coin) (tokenInAmount sdk.Int, err error) + tokenOut sdk.Coin) (tokenInAmount osmomath.Int, err error) AllPools( ctx sdk.Context, diff --git a/x/protorev/types/genesis.go b/x/protorev/types/genesis.go index aa6672a2fe5..f1a81b654cb 100644 --- a/x/protorev/types/genesis.go +++ b/x/protorev/types/genesis.go @@ -2,6 +2,8 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) var ( @@ -13,7 +15,7 @@ var ( DefaultBaseDenoms = []BaseDenom{ { Denom: OsmosisDenomination, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, } DefaultPoolTypeInfo = InfoByPoolType{ diff --git a/x/protorev/types/msg_test.go b/x/protorev/types/msg_test.go index 9c2d79134bc..b3488deb480 100644 --- a/x/protorev/types/msg_test.go +++ b/x/protorev/types/msg_test.go @@ -7,12 +7,13 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/protorev/types" ) func TestMsgSetHotRoutes(t *testing.T) { - validStepSize := sdk.NewInt(1_000_000) - invalidStepSize := sdk.NewInt(0) + validStepSize := osmomath.NewInt(1_000_000) + invalidStepSize := osmomath.NewInt(0) cases := []struct { description string admin string @@ -628,7 +629,7 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: "Atom", - StepSize: sdk.NewInt(10), + StepSize: osmomath.NewInt(10), }, }, false, @@ -639,7 +640,7 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(0), + StepSize: osmomath.NewInt(0), }, }, false, @@ -650,11 +651,11 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, }, false, @@ -665,7 +666,7 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, }, true, @@ -676,15 +677,15 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, { Denom: "Atom", - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, { Denom: "testDenom", - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, }, true, @@ -695,11 +696,11 @@ func TestMsgSetBaseDenoms(t *testing.T) { []types.BaseDenom{ { Denom: types.OsmosisDenomination, - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, { Denom: "Atom", - StepSize: sdk.NewInt(1), + StepSize: osmomath.NewInt(1), }, { Denom: "testDenom", diff --git a/x/protorev/types/protorev.pb.go b/x/protorev/types/protorev.pb.go index 62cf571f0a9..141364d65d4 100644 --- a/x/protorev/types/protorev.pb.go +++ b/x/protorev/types/protorev.pb.go @@ -4,9 +4,9 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -97,7 +97,7 @@ type Route struct { Trades []Trade `protobuf:"bytes,1,rep,name=trades,proto3" json:"trades" yaml:"trades"` // The step size that will be used to find the optimal swap amount in the // binary search - StepSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=step_size,json=stepSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"step_size" yaml:"step_size"` + StepSize cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=step_size,json=stepSize,proto3,customtype=cosmossdk.io/math.Int" json:"step_size" yaml:"step_size"` } func (m *Route) Reset() { *m = Route{} } @@ -211,7 +211,7 @@ type RouteStatistics struct { Profits []types.Coin `protobuf:"bytes,1,rep,name=profits,proto3" json:"profits" yaml:"profits"` // number_of_trades is the number of trades the module has executed using this // route - NumberOfTrades github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"number_of_trades" yaml:"number_of_trades"` + NumberOfTrades cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=cosmossdk.io/math.Int" json:"number_of_trades" yaml:"number_of_trades"` // route is the route that was used (pool ids along the arbitrage route) Route []uint64 `protobuf:"varint,3,rep,packed,name=route,proto3" json:"route,omitempty" yaml:"route"` } @@ -677,7 +677,7 @@ type BaseDenom struct { Denom string `protobuf:"bytes,1,opt,name=denom,proto3" json:"denom,omitempty" yaml:"denom"` // The step size of the binary search that is used to find the optimal swap // amount - StepSize github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=step_size,json=stepSize,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"step_size" yaml:"step_size"` + StepSize cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=step_size,json=stepSize,proto3,customtype=cosmossdk.io/math.Int" json:"step_size" yaml:"step_size"` } func (m *BaseDenom) Reset() { *m = BaseDenom{} } @@ -741,66 +741,66 @@ func init() { var fileDescriptor_1e9f2391fd9fec01 = []byte{ // 949 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 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06, 0xd1, 0x22, 0x07, 0x60, 0x33, - 0x60, 0x71, 0x40, 0x63, 0x91, 0x10, 0x41, 0x07, 0x46, 0xa8, 0x24, 0x85, 0xda, 0x59, 0x6a, 0xb7, - 0x94, 0xd0, 0x0d, 0x24, 0x84, 0xe1, 0x34, 0x3a, 0x39, 0x55, 0xee, 0xe7, 0x19, 0xe1, 0x91, 0x11, - 0x2b, 0xcf, 0x9e, 0x6a, 0x86, 0x80, 0x70, 0xcd, 0x20, 0x4a, 0x04, 0xfd, 0x52, 0x02, 0xb5, 0xfd, - 0xf8, 0x88, 0xb9, 0x17, 0xb9, 0x5f, 0xfd, 0x8b, 0x11, 0x85, 0xcf, 0xc1, 0xaa, 0xea, 0x5e, 0xba, - 0x54, 0xdd, 0xeb, 0xcc, 0xff, 0x12, 0x0f, 0x25, 0x2f, 0xcf, 0x94, 0x1a, 0x33, 0x9f, 0xa4, 0x52, - 0x41, 0x58, 0xcb, 0x41, 0x0f, 0xac, 0x19, 0x4f, 0xa4, 0x7f, 0xd5, 0xbd, 0x8f, 0xe6, 0x4b, 0xbb, - 0x9a, 0x59, 0x88, 0xdf, 0xd5, 0xe2, 0xf5, 0xeb, 0x7e, 0x23, 0x5c, 0x88, 0x42, 0x06, 0xd6, 0xa7, - 0x7d, 0x92, 0xde, 0x56, 0xf7, 0x9c, 0xf9, 0x45, 0x7a, 0x53, 0xec, 0xa2, 0xd0, 0x3d, 0x5d, 0x68, - 0xf3, 0xed, 0x79, 0x20, 0x7c, 0xad, 0x40, 0xde, 0x91, 0xf1, 0x53, 0x7a, 0xff, 0xaf, 0x1d, 0xf5, - 0x34, 0x73, 0x5e, 0x47, 0x46, 0x09, 0xe1, 0x42, 0x14, 0x7d, 0x06, 0x6a, 0xd7, 0x3d, 0x86, 0x1f, - 0x82, 0xd5, 0x6b, 0x77, 0x78, 0x63, 0xe2, 0xb7, 0x99, 0xb1, 0x26, 0xa0, 0xc7, 0xa0, 0x31, 0xeb, - 0xe2, 0x22, 0x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, 0x9a, 0x9a, 0x2b, 0x3d, 0xec, 0x83, 0xba, 0x4f, 0x46, 0x24, + 0x0e, 0x68, 0x62, 0x0c, 0x6e, 0x49, 0x83, 0x56, 0x96, 0xda, 0xf7, 0x94, 0xc1, 0x1c, 0x01, 0xe1, + 0x9a, 0x41, 0xb4, 0xc9, 0x3e, 0xd8, 0x08, 0x58, 0x1c, 0xd0, 0x58, 0x24, 0x44, 0xd0, 0xa1, 0x31, + 0x2a, 0x49, 0xa3, 0x76, 0x96, 0xda, 0x2d, 0x65, 0xf4, 0x06, 0x12, 0xc2, 0x70, 0x16, 0x9d, 0xee, + 0x2a, 0x0f, 0xf4, 0x8c, 0xf0, 0xc8, 0x98, 0x95, 0xe7, 0x77, 0x35, 0x47, 0x40, 0xb8, 0x66, 0x10, + 0x65, 0x82, 0x7e, 0x2a, 0x81, 0xda, 0x6e, 0x7c, 0xc8, 0xdc, 0x8b, 0x3c, 0xaf, 0xc1, 0xc5, 0x98, + 0xc2, 0x67, 0x60, 0x45, 0x75, 0x2f, 0x53, 0xaa, 0xee, 0x74, 0x16, 0x7f, 0x67, 0x07, 0x92, 0x97, + 0x2b, 0xa5, 0xc7, 0xdc, 0x07, 0xa7, 0x5c, 0x10, 0xd6, 0x76, 0xd0, 0x03, 0xab, 0x26, 0x13, 0x99, + 0x5f, 0x75, 0xe7, 0xbd, 0xc5, 0xd6, 0xae, 0x66, 0x16, 0xe6, 0xf7, 0xb5, 0x79, 0xfd, 0x7a, 0xde, + 0x08, 0x17, 0xa6, 0x90, 0x81, 0xb5, 0xd9, 0x9c, 0x64, 0xb6, 0xd5, 0x1d, 0x67, 0x71, 0x91, 0xfe, + 0x0c, 0xbb, 0x28, 0xf4, 0x40, 0x17, 0xda, 0x78, 0xfd, 0x3c, 0x10, 0xbe, 0x56, 0x20, 0xef, 0xc8, + 0xe4, 0x29, 0xb3, 0xff, 0xdb, 0x8e, 0xfa, 0x9a, 0xb9, 0xa8, 0x23, 0xe3, 0x84, 0x70,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xad, 0xdf, 0x2f, 0xdb, 0xd6, 0x0f, 0x57, 0xed, 0xa5, 0x97, 0x57, 0xed, 0xa5, 0x57, + 0x57, 0xed, 0xa5, 0xaf, 0x3f, 0x3c, 0x0a, 0xc5, 0xf1, 0xc4, 0x77, 0x02, 0x16, 0x75, 0x75, 0xec, + 0xef, 0x8f, 0x88, 0xcf, 0xcd, 0xa4, 0x7b, 0xda, 0xfb, 0xb8, 0x7b, 0x3e, 0xfd, 0xab, 0x24, 0x2e, + 0xc6, 0x94, 0xfb, 0x2b, 0x72, 0xfe, 0xc1, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x95, 0x48, 0x2f, + 0xfa, 0x4b, 0x09, 0x00, 0x00, } func (this *TokenPairArbRoutes) Equal(that interface{}) bool { diff --git a/x/protorev/types/query.pb.go b/x/protorev/types/query.pb.go index 8367a7b1710..d672d14d502 100644 --- a/x/protorev/types/query.pb.go +++ b/x/protorev/types/query.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" @@ -157,7 +157,7 @@ var xxx_messageInfo_QueryGetProtoRevNumberOfTradesRequest proto.InternalMessageI // Query/GetProtoRevNumberOfTrades RPC method. type QueryGetProtoRevNumberOfTradesResponse struct { // number_of_trades is the number of trades the module has executed - NumberOfTrades github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"number_of_trades" yaml:"number_of_trades"` + NumberOfTrades cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=number_of_trades,json=numberOfTrades,proto3,customtype=cosmossdk.io/math.Int" json:"number_of_trades" yaml:"number_of_trades"` } func (m *QueryGetProtoRevNumberOfTradesResponse) Reset() { @@ -1427,103 +1427,103 @@ func init() { } var fileDescriptor_f5e7ac9973cce389 = []byte{ - // 1533 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x58, 0xdb, 0x6f, 0x1b, 0xc5, - 0x17, 0xce, 0xf6, 0x92, 0xfc, 0x3a, 0xbd, 0xfc, 0x9a, 0xa1, 0x49, 0x93, 0x6d, 0x6a, 0x3b, 0x93, - 0x7b, 0xd2, 0xd8, 0xf4, 0xc2, 0xa5, 0x40, 0x81, 0x6c, 0x03, 0x55, 0x54, 0xd1, 0x98, 0x25, 0xbc, - 0x80, 0x84, 0x59, 0xdb, 0x93, 0x74, 0xd5, 0xf5, 0x8e, 0xbb, 0xbb, 0x8e, 0xe2, 0x57, 0x90, 0x40, - 0x48, 0x48, 0xdc, 0x9e, 0x11, 0xfc, 0x01, 0xfc, 0x03, 0x7d, 0xe4, 0xad, 0x82, 0x97, 0x22, 0x24, - 0x84, 0x0a, 0xb2, 0x50, 0xcb, 0x03, 0xcf, 0xfe, 0x0b, 0xd0, 0xce, 0x9c, 0xb5, 0xd7, 0x3b, 0xbb, - 0x8e, 0x37, 0x91, 0x78, 0x8a, 0xbd, 0xe7, 0x9c, 0xef, 0x7c, 0xdf, 0x9c, 0x9d, 0x99, 0xcf, 0x41, - 0xb3, 0xcc, 0xad, 0x31, 0xd7, 0x74, 0x0b, 0x75, 0x87, 0x79, 0xcc, 0xa1, 0xbb, 0x85, 0xdd, 0xcb, - 0x65, 0xea, 0x19, 0x97, 0x0b, 0xf7, 0x1b, 0xd4, 0x69, 0xe6, 0xf9, 0x63, 0x3c, 0x01, 0x59, 0xf9, - 0x20, 0x2b, 0x0f, 0x59, 0xea, 0xb9, 0x1d, 0xb6, 0xc3, 0xf8, 0xd3, 0x82, 0xff, 0x49, 0x24, 0xa8, - 0x53, 0x3b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 0x10, - 0xd6, 0x78, 0x29, 0xf9, 0xc5, 0xe7, 0xc5, 0x21, 0xb4, 0x49, 0x50, 0x38, 0x2a, 0x98, 0x74, 0xa1, - 0x88, 0x1e, 0xc2, 0x25, 0x2b, 0x32, 0xa5, 0x35, 0xcb, 0x8a, 0x80, 0x05, 0x73, 0xf8, 0x5a, 0x41, - 0xcb, 0x83, 0x64, 0x27, 0x28, 0x38, 0xfa, 0x5f, 0x29, 0xd8, 0x62, 0xf7, 0xa8, 0x5d, 0x34, 0x4c, - 0x67, 0xcd, 0x29, 0x73, 0xd4, 0x8e, 0x82, 0xcf, 0x62, 0x14, 0xc4, 0x65, 0x83, 0x82, 0xf7, 0xd1, - 0x30, 0x1f, 0x5d, 0xc0, 0xfe, 0x52, 0x32, 0x7b, 0x19, 0x25, 0x7a, 0x08, 0x09, 0x24, 0xa2, 0x03, - 0x24, 0x99, 0x43, 0x33, 0xd2, 0x62, 0x56, 0x6b, 0xa6, 0xbd, 0x56, 0xa9, 0xb0, 0x86, 0xed, 0x05, - 0x94, 0x29, 0x9a, 0xed, 0x9f, 0x06, 0x5c, 0x6f, 0xa0, 0xd3, 0x86, 0xff, 0xbc, 0x64, 0x88, 0x00, - 0xec, 0xf4, 0x89, 0x76, 0x2b, 0x7b, 0x4e, 0x10, 0xe8, 0x09, 0x13, 0xfd, 0x94, 0x11, 0x82, 0x21, - 0x4b, 0x68, 0x21, 0xda, 0x66, 0x9d, 0xee, 0x52, 0x8b, 0xd5, 0xa9, 0x13, 0x61, 0xd4, 0x90, 0xf7, - 0x86, 0x9c, 0x0a, 0xac, 0x36, 0xd0, 0x68, 0x35, 0x88, 0x45, 0x98, 0x4d, 0xb5, 0x5b, 0xd9, 0x89, - 0xe0, 0x0c, 0x8a, 0xa4, 0x10, 0xfd, 0x6c, 0x35, 0x02, 0x19, 0x77, 0x68, 0x6f, 0xd8, 0xdb, 0x4c, - 0x6b, 0x16, 0x19, 0xb3, 0xb6, 0x9a, 0xf5, 0x60, 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0x59, - 0xb0, 0x10, 0x10, 0x42, 0x21, 0x3a, 0x2a, 0x77, 0x3a, 0x91, 0x1c, 0xca, 0x44, 0x79, 0xbc, 0x61, - 0x1b, 0x65, 0x8b, 0x56, 0x03, 0xaa, 0x9b, 0x28, 0x9b, 0x98, 0x01, 0x34, 0x2f, 0xa1, 0x11, 0x2a, - 0x1e, 0xf1, 0xa5, 0xfb, 0x9f, 0x86, 0xbb, 0x77, 0x1e, 0x04, 0x88, 0x1e, 0xa4, 0x90, 0xcf, 0x15, - 0x74, 0x41, 0xba, 0xfc, 0x19, 0xb3, 0x82, 0x7b, 0xee, 0x1a, 0x42, 0x5d, 0xba, 0xb0, 0x89, 0xc7, - 0xba, 0x07, 0x74, 0x37, 0x46, 0xf4, 0x13, 0x1d, 0x25, 0xf8, 0x05, 0x74, 0x92, 0x79, 0x77, 0xa9, - 0x03, 0x65, 0x47, 0x78, 0xd9, 0x78, 0x77, 0x05, 0x42, 0x41, 0xa2, 0x23, 0xfe, 0x8d, 0x17, 0x92, - 0xdb, 0x68, 0x2a, 0x9e, 0x0d, 0x88, 0x5b, 0x41, 0x23, 0x7c, 0xf4, 0x66, 0x15, 0xde, 0x8b, 0x90, - 0x38, 0x08, 0xf8, 0x3e, 0x83, 0x31, 0x6b, 0xa3, 0x7a, 0xe5, 0xc1, 0x79, 0x74, 0x9c, 0xa3, 0xe1, - 0x4f, 0x15, 0x34, 0x2c, 0x5c, 0x22, 0xee, 0x73, 0x9c, 0xcb, 0xe6, 0x54, 0x5d, 0x1d, 0x30, 0x5b, - 0xd0, 0x23, 0xb9, 0x8f, 0x7e, 0xfd, 0xfb, 0x9b, 0x23, 0x2a, 0x9e, 0x28, 0x48, 0x9e, 0x59, 0xb8, - 0x50, 0xfc, 0x93, 0x82, 0x26, 0x13, 0x7d, 0x25, 0x7e, 0x6d, 0x9f, 0x76, 0xfb, 0x79, 0x57, 0xf5, - 0xf5, 0x83, 0x03, 0x80, 0x84, 0x65, 0x2e, 0x61, 0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 0xad, 0xee, 0xef, 0x03, 0xf5, 0xf9, 0xb4, 0x65, 0xc0, 0x32, 0xc3, 0x59, - 0x4e, 0xe0, 0xf1, 0x18, 0x67, 0xc6, 0x98, 0xa5, 0xdd, 0x79, 0xf8, 0x24, 0xa3, 0x3c, 0x7a, 0x92, - 0x51, 0xfe, 0x7a, 0x92, 0x51, 0xbe, 0x7c, 0x9a, 0x19, 0x7a, 0xf4, 0x34, 0x33, 0xf4, 0xfb, 0xd3, - 0xcc, 0xd0, 0x7b, 0xd7, 0x42, 0xff, 0x51, 0x85, 0xda, 0x55, 0xcb, 0x28, 0xbb, 0x1d, 0xa0, 0xdd, - 0xcb, 0xd7, 0x0b, 0x7b, 0xa1, 0xdb, 0xa9, 0x59, 0xa7, 0x6e, 0x79, 0x98, 0x7f, 0xbf, 0xfa, 0x6f, - 0x00, 0x00, 0x00, 0xff, 0xff, 0xfd, 0x88, 0xc0, 0x8b, 0x94, 0x17, 0x00, 0x00, + // 1527 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x5d, 0x6f, 0x1b, 0x45, + 0x17, 0xce, 0xf6, 0x23, 0x79, 0x3b, 0xfd, 0x78, 0x9b, 0xa1, 0x49, 0x93, 0x6d, 0x6a, 0x3b, 0x93, + 0xa4, 0xf9, 0x6a, 0x6c, 0xfa, 0x01, 0xb4, 0x40, 0x81, 0x6c, 0x03, 0x55, 0x54, 0xd1, 0x98, 0x25, + 0xdc, 0x80, 0x84, 0x59, 0xdb, 0x93, 0x74, 0xd5, 0xf5, 0x8e, 0xbb, 0xbb, 0x8e, 0xe2, 0x5b, 0x90, + 0x40, 0x48, 0x48, 0x7c, 0xfd, 0x00, 0xf8, 0x01, 0xfc, 0x81, 0x5e, 0x72, 0x57, 0xc1, 0x4d, 0x11, + 0x12, 0x42, 0x05, 0x59, 0xa8, 0xe1, 0x82, 0x6b, 0xff, 0x02, 0xb4, 0x33, 0x67, 0xed, 0xf5, 0xce, + 0xae, 0xe3, 0x4d, 0x24, 0xee, 0xbc, 0x7b, 0xce, 0x79, 0xce, 0xf3, 0x9c, 0xd9, 0x99, 0x79, 0x8c, + 0x66, 0x99, 0x5b, 0x63, 0xae, 0xe9, 0x16, 0xea, 0x0e, 0xf3, 0x98, 0x43, 0x77, 0x0a, 0x3b, 0x57, + 0xca, 0xd4, 0x33, 0xae, 0x14, 0x1e, 0x36, 0xa8, 0xd3, 0xcc, 0xf3, 0xd7, 0x78, 0x02, 0xb2, 0xf2, + 0x41, 0x56, 0x1e, 0xb2, 0xd4, 0x73, 0xdb, 0x6c, 0x9b, 0xf1, 0xb7, 0x05, 0xff, 0x97, 0x48, 0x50, + 0xa7, 0xb6, 0x19, 0xdb, 0xb6, 0x68, 0xc1, 0xa8, 0x9b, 0x05, 0xc3, 0xb6, 0x99, 0x67, 0x78, 0x26, + 0xb3, 0xa1, 0x5c, 0x5d, 0xaa, 0x70, 0xb8, 0x42, 0xd9, 0x70, 0xa9, 0x68, 0xd3, 0x69, 0x5a, 0x37, + 0xb6, 0x4d, 0x9b, 0x27, 0x43, 0xee, 0x5c, 0x22, 0xbf, 0xba, 0xe1, 0x18, 0xb5, 0x00, 0x72, 0x3e, + 0x39, 0x2d, 0x60, 0x2c, 0x12, 0x33, 0xe1, 0xde, 0x41, 0x4e, 0x85, 0x99, 0xd0, 0x8f, 0x9c, 0x43, + 0xf8, 0x1d, 0x9f, 0x51, 0x91, 0xa3, 0xeb, 0xf4, 0x61, 0x83, 0xba, 0x1e, 0xd9, 0x42, 0xcf, 0xf5, + 0xbc, 0x75, 0xeb, 0xcc, 0x76, 0x29, 0xde, 0x40, 0xc3, 0x82, 0xc5, 0x84, 0x92, 0x53, 0x16, 0x4e, + 0x5e, 0xcd, 0xe5, 0x93, 0xe6, 0x94, 0x17, 0x95, 0xda, 0xd8, 0xe3, 0x56, 0x76, 0xa8, 0xdd, 0xca, + 0x9e, 0x6e, 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x97, 0x07, 0xd3, 0xc9, 0xff, 0x75, 0x44, 0xef, 0xdf, + 0xae, 0x01, 0x4f, 0x73, 0xff, 0x4a, 0xe6, 0x3e, 0xcd, 0xfd, 0x2b, 0x7b, 0xfe, 0x7e, 0xf7, 0x6f, + 0xc8, 0xc5, 0xe3, 0x1f, 0x14, 0x84, 0x65, 0x4b, 0x8e, 0x6f, 0x0c, 0xde, 0xbb, 0xd7, 0xe7, 0xab, + 0x37, 0x0f, 0x50, 0x09, 0x94, 0xa7, 0x39, 0xe5, 0x0b, 0x78, 0x52, 0xa6, 0x0c, 0xa6, 0x1f, 0x7f, + 0xaf, 0xa0, 0xff, 0x47, 0x1c, 0x36, 0x7e, 0x21, 0x85, 0xd9, 0xea, 0xfe, 0x3f, 0x50, 0x5f, 0x4c, + 0x5b, 0x06, 0x2c, 0x33, 0x9c, 0xe5, 0x04, 0x1e, 0x8f, 0x71, 0x66, 0x8c, 0x59, 0xda, 0xbd, 0xc7, + 0xcf, 0x32, 0xca, 0x93, 0x67, 0x19, 0xe5, 0xaf, 0x67, 0x19, 0xe5, 0xab, 0xbd, 0xcc, 0xd0, 0x93, + 0xbd, 0xcc, 0xd0, 0xef, 0x7b, 0x99, 0xa1, 0xf7, 0xaf, 0x6f, 0x9b, 0xde, 0xfd, 0x46, 0x39, 0x5f, + 0x61, 0xb5, 0xa0, 0x76, 0xc5, 0x32, 0xca, 0x6e, 0x07, 0x68, 0xe7, 0xca, 0xcd, 0xc2, 0x6e, 0xe8, + 0x76, 0x6a, 0xd6, 0xa9, 0x5b, 0x1e, 0xe6, 0xcf, 0xd7, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0x7a, + 0x3a, 0xed, 0xfa, 0x83, 0x17, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/protorev/types/token_pair_arb_routes.go b/x/protorev/types/token_pair_arb_routes.go index d3e86e4501f..843b572d21c 100644 --- a/x/protorev/types/token_pair_arb_routes.go +++ b/x/protorev/types/token_pair_arb_routes.go @@ -3,7 +3,7 @@ package types import ( "fmt" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) // Creates a new TokenPairArbRoutes object @@ -53,7 +53,7 @@ func (tp *TokenPairArbRoutes) Validate() error { // Iterate through all of the possible routes for this pool for _, route := range tp.ArbRoutes { - if route.StepSize.IsNil() || route.StepSize.LT(sdk.OneInt()) { + if route.StepSize.IsNil() || route.StepSize.LT(osmomath.OneInt()) { return fmt.Errorf("step size must be greater than 0") } diff --git a/x/protorev/types/validate.go b/x/protorev/types/validate.go index 8bc2627b855..838a29b3acc 100644 --- a/x/protorev/types/validate.go +++ b/x/protorev/types/validate.go @@ -4,6 +4,8 @@ import ( fmt "fmt" sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // ---------------------- BaseDenom Validation ---------------------- // @@ -13,7 +15,7 @@ func (base *BaseDenom) Validate() error { return fmt.Errorf("base denom cannot be empty") } - if base.StepSize.IsNil() || base.StepSize.LT(sdk.OneInt()) { + if base.StepSize.IsNil() || base.StepSize.LT(osmomath.OneInt()) { return fmt.Errorf("step size must be greater than 0") } diff --git a/x/superfluid/README.md b/x/superfluid/README.md index 2dda8315604..88f62b67ca9 100644 --- a/x/superfluid/README.md +++ b/x/superfluid/README.md @@ -658,14 +658,14 @@ message ParamsResponse { } message Params { - sdk.Dec minimum_risk_factor = 1; // serialized as string + osmomath.Dec minimum_risk_factor = 1; // serialized as string } ``` The params query returns the params for the superfluid module. This currently contains: -- `MinimumRiskFactor` which is an sdk.Dec that represents the discount +- `MinimumRiskFactor` which is an osmomath.Dec that represents the discount to apply to all superfluid staked modules when calcultating their staking power. For example, if a specific denom has an OSMO equivalent value of 100 OSMO, but the the `MinimumRiskFactor` param @@ -886,8 +886,8 @@ This query returns the total amount of delegated coins for a validator / superfluid denom pair. This query does NOT involve iteration, so should be used instead of the above `SuperfluidDelegationsByValidatorDenom` whenever possible. It is called an "Estimate" because it can have some -slight rounding errors, due to conversions between sdk.Dec and -sdk.Int\", but for the most part it should be very close to the sum of +slight rounding errors, due to conversions between osmomath.Dec and +osmomath.Int\", but for the most part it should be very close to the sum of the results of the previous query. ## Parameters diff --git a/x/superfluid/client/cli/query_test.go b/x/superfluid/client/cli/query_test.go index 782bb21c240..333600543fb 100644 --- a/x/superfluid/client/cli/query_test.go +++ b/x/superfluid/client/cli/query_test.go @@ -11,6 +11,7 @@ import ( stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" ) @@ -34,9 +35,9 @@ func (s *QueryTestSuite) SetupSuite() { time.Hour * 24 * 21, }) // set up pool - s.SetupGammPoolsWithBondDenomMultiplier([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + s.SetupGammPoolsWithBondDenomMultiplier([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // set up lock with id = 1 - s.LockTokens(s.TestAccs[0], sdk.Coins{sdk.NewCoin("gamm/pool/1", sdk.NewInt(1000000))}, time.Hour*24*21) + s.LockTokens(s.TestAccs[0], sdk.Coins{sdk.NewCoin("gamm/pool/1", osmomath.NewInt(1000000))}, time.Hour*24*21) // set up validator s.val = s.SetupValidator(stakingtypes.Bonded) // set up sfs asset diff --git a/x/superfluid/client/cli/tx.go b/x/superfluid/client/cli/tx.go index 590deb0b78c..134d8f1cb35 100644 --- a/x/superfluid/client/cli/tx.go +++ b/x/superfluid/client/cli/tx.go @@ -8,6 +8,7 @@ import ( "github.com/spf13/cobra" flag "github.com/spf13/pflag" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/osmoutils/osmocli" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -447,13 +448,13 @@ func NewUnbondConvertAndStake() *cobra.Command { valAddr := args[1] - var minAmtToStake sdk.Int + var minAmtToStake osmomath.Int // if user provided args for min amount to stake, use it. If not, use empty coin struct var sharesToConvert sdk.Coin if len(args) >= 3 { - convertedInt, ok := sdk.NewIntFromString(args[2]) + convertedInt, ok := osmomath.NewIntFromString(args[2]) if !ok { - return fmt.Errorf("Conversion for sdk.Int failed") + return fmt.Errorf("Conversion for osmomath.Int failed") } minAmtToStake = convertedInt if len(args) == 4 { @@ -464,7 +465,7 @@ func NewUnbondConvertAndStake() *cobra.Command { sharesToConvert = coins } } else { - minAmtToStake = sdk.ZeroInt() + minAmtToStake = osmomath.ZeroInt() sharesToConvert = sdk.Coin{} } diff --git a/x/superfluid/keeper/concentrated_liquidity.go b/x/superfluid/keeper/concentrated_liquidity.go index b2a28759b4c..649b0661a2f 100644 --- a/x/superfluid/keeper/concentrated_liquidity.go +++ b/x/superfluid/keeper/concentrated_liquidity.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" ) @@ -29,7 +30,7 @@ import ( // - The position is not superfluid staked. // - The position is the last position in the pool. // - The lock duration does not match the unbonding duration. -func (k Keeper) addToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, sender sdk.AccAddress, positionId uint64, amount0ToAdd, amount1ToAdd sdk.Int) (cltypes.CreateFullRangePositionData, uint64, error) { +func (k Keeper) addToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, sender sdk.AccAddress, positionId uint64, amount0ToAdd, amount1ToAdd osmomath.Int) (cltypes.CreateFullRangePositionData, uint64, error) { position, err := k.clk.GetPosition(ctx, positionId) if err != nil { return cltypes.CreateFullRangePositionData{}, 0, err diff --git a/x/superfluid/keeper/concentrated_liquidity_test.go b/x/superfluid/keeper/concentrated_liquidity_test.go index d3a4e1b1daf..b7360d7506c 100644 --- a/x/superfluid/keeper/concentrated_liquidity_test.go +++ b/x/superfluid/keeper/concentrated_liquidity_test.go @@ -22,8 +22,8 @@ func (s *KeeperTestSuite) TestAddToConcentratedLiquiditySuperfluidPosition() { superfluidUndelegating bool unlocking bool overwritePositionId bool - amount0Added sdk.Int - amount1Added sdk.Int + amount0Added osmomath.Int + amount1Added osmomath.Int doNotFundAcc bool isLastPositionInPool bool overwriteExecutionAcc bool @@ -32,74 +32,74 @@ func (s *KeeperTestSuite) TestAddToConcentratedLiquiditySuperfluidPosition() { testCases := map[string]sendTest{ "add to position that is superfluid delegated, not unlocking": { superfluidDelegated: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), }, "error: negative amount 0": { superfluidDelegated: true, doNotFundAcc: true, - amount0Added: sdk.NewInt(-100000000), - amount1Added: sdk.NewInt(100000000), - expectedError: cltypes.NegativeAmountAddedError{PositionId: 1, Asset0Amount: sdk.NewInt(-100000000), Asset1Amount: sdk.NewInt(100000000)}, + amount0Added: osmomath.NewInt(-100000000), + amount1Added: osmomath.NewInt(100000000), + expectedError: cltypes.NegativeAmountAddedError{PositionId: 1, Asset0Amount: osmomath.NewInt(-100000000), Asset1Amount: osmomath.NewInt(100000000)}, }, "error: negative amount 1": { superfluidDelegated: true, doNotFundAcc: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(-100000000), - expectedError: cltypes.NegativeAmountAddedError{PositionId: 1, Asset0Amount: sdk.NewInt(100000000), Asset1Amount: sdk.NewInt(-100000000)}, + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(-100000000), + expectedError: cltypes.NegativeAmountAddedError{PositionId: 1, Asset0Amount: osmomath.NewInt(100000000), Asset1Amount: osmomath.NewInt(-100000000)}, }, "error: not underlying lock owner of the position": { superfluidDelegated: true, overwriteExecutionAcc: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: types.LockOwnerMismatchError{LockId: 1, LockOwner: owner.String(), ProvidedOwner: nonOwner.String()}, }, "error: not enough funds to add": { doNotFundAcc: true, superfluidDelegated: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: fmt.Errorf("insufficient funds"), }, "error: last position in pool": { superfluidDelegated: true, isLastPositionInPool: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: cltypes.AddToLastPositionInPoolError{PoolId: 1, PositionId: 1}, }, "error: lock that is not superfluid delegated, not unlocking": { - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: types.ErrNotSuperfluidUsedLockup, }, "error: lock that is not superfluid delegated, unlocking": { unlocking: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: types.LockImproperStateError{LockId: 1, UnbondingDuration: s.App.StakingKeeper.UnbondingTime(s.Ctx).String()}, }, "error: lock that is superfluid undelegating, not unlocking": { superfluidDelegated: true, superfluidUndelegating: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: types.ErrNotSuperfluidUsedLockup, }, "error: lock that is superfluid undelegating, unlocking": { superfluidDelegated: true, superfluidUndelegating: true, unlocking: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: types.LockImproperStateError{LockId: 1, UnbondingDuration: s.App.StakingKeeper.UnbondingTime(s.Ctx).String()}, }, "error: non-existent position ID": { overwritePositionId: true, - amount0Added: sdk.NewInt(100000000), - amount1Added: sdk.NewInt(100000000), + amount0Added: osmomath.NewInt(100000000), + amount1Added: osmomath.NewInt(100000000), expectedError: cltypes.PositionIdNotFoundError{PositionId: 5}, }, } @@ -133,7 +133,7 @@ func (s *KeeperTestSuite) TestAddToConcentratedLiquiditySuperfluidPosition() { } if !tc.isLastPositionInPool { - fundCoins := sdk.NewCoins(sdk.NewCoin(clPool.GetToken0(), sdk.NewInt(100000000)), sdk.NewCoin(clPool.GetToken1(), sdk.NewInt(100000000))) + fundCoins := sdk.NewCoins(sdk.NewCoin(clPool.GetToken0(), osmomath.NewInt(100000000)), sdk.NewCoin(clPool.GetToken1(), osmomath.NewInt(100000000))) s.FundAcc(nonOwner, fundCoins) _, err := concentratedLiquidityKeeper.CreateFullRangePosition(ctx, clPool.GetId(), nonOwner, fundCoins) s.Require().NoError(err) @@ -164,7 +164,7 @@ func (s *KeeperTestSuite) TestAddToConcentratedLiquiditySuperfluidPosition() { // // Note that the expected difference valid additive difference of 101 on asset 1. var errTolerance osmomath.ErrTolerance - errTolerance.AdditiveTolerance = sdk.NewDec(101) + errTolerance.AdditiveTolerance = osmomath.NewDec(101) errTolerance.RoundingDir = osmomath.RoundDown postAddToPositionStakeSupply := bankKeeper.GetSupply(ctx, bondDenom) @@ -232,7 +232,7 @@ func (s *KeeperTestSuite) TestAddToConcentratedLiquiditySuperfluidPosition() { } } -func (s *KeeperTestSuite) SetupSuperfluidConcentratedPosition(ctx sdk.Context, superfluidDelegated, superfluidUndelegating, unlocking bool, owner sdk.AccAddress) (positionId, lockId uint64, amount0, amount1 sdk.Int, valAddr sdk.ValAddress, poolJoinAcc sdk.AccAddress) { +func (s *KeeperTestSuite) SetupSuperfluidConcentratedPosition(ctx sdk.Context, superfluidDelegated, superfluidUndelegating, unlocking bool, owner sdk.AccAddress) (positionId, lockId uint64, amount0, amount1 osmomath.Int, valAddr sdk.ValAddress, poolJoinAcc sdk.AccAddress) { bankKeeper := s.App.BankKeeper superfluidKeeper := s.App.SuperfluidKeeper lockupKeeper := s.App.LockupKeeper @@ -256,7 +256,7 @@ func (s *KeeperTestSuite) SetupSuperfluidConcentratedPosition(ctx sdk.Context, s valAddr = s.SetupValidator(stakingtypes.Bonded) // Create a cl pool. - clPool := s.PrepareCustomConcentratedPool(poolCreateAcc, defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, sdk.ZeroDec()) + clPool := s.PrepareCustomConcentratedPool(poolCreateAcc, defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, osmomath.ZeroDec()) clPoolId := clPool.GetId() // The lock duration is the same as the staking module's unbonding duration. diff --git a/x/superfluid/keeper/edge_case_test.go b/x/superfluid/keeper/edge_case_test.go index d747124fa04..efdbff9df5a 100644 --- a/x/superfluid/keeper/edge_case_test.go +++ b/x/superfluid/keeper/edge_case_test.go @@ -7,6 +7,7 @@ import ( evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -41,7 +42,7 @@ func (s *KeeperTestSuite) TestSuperfluidDelegatedValidatorJailed() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) locks := []lockuptypes.PeriodLock{} slashFactor := s.App.SlashingKeeper.SlashFractionDoubleSign(s.Ctx) @@ -84,7 +85,7 @@ func (s *KeeperTestSuite) TestSuperfluidDelegatedValidatorJailed() { s.Require().NoError(err) s.Require().Equal( gotLock.Coins.AmountOf(denoms[0]).String(), - sdk.NewDec(1000000).Mul(sdk.OneDec().Sub(slashFactor)).TruncateInt().String(), + osmomath.NewDec(1000000).Mul(osmomath.OneDec().Sub(slashFactor)).TruncateInt().String(), ) } }) @@ -97,28 +98,28 @@ func (s *KeeperTestSuite) TestTryUnbondingSuperfluidLockupDirectly() { validatorStats []stakingtypes.BondStatus delegatorNumber int superDelegations []superfluidDelegation - expInterDelegation []sdk.Dec + expInterDelegation []osmomath.Dec }{ { "with single validator and single superfluid delegation", []stakingtypes.BondStatus{stakingtypes.Bonded}, 1, []superfluidDelegation{{0, 0, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, { "with single validator and additional superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded}, 1, []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(20000000)}, // 50% x 20 x 1000000 x 2 + []osmomath.Dec{osmomath.NewDec(20000000)}, // 50% x 20 x 1000000 x 2 }, { "with multiple validators and multiple superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}, 2, []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000), sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000), osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, } @@ -129,8 +130,7 @@ func (s *KeeperTestSuite) TestTryUnbondingSuperfluidLockupDirectly() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, _, locks := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) diff --git a/x/superfluid/keeper/epoch.go b/x/superfluid/keeper/epoch.go index 73864f7bf61..b13472ee5d8 100644 --- a/x/superfluid/keeper/epoch.go +++ b/x/superfluid/keeper/epoch.go @@ -196,7 +196,7 @@ func (k Keeper) updateConcentratedOsmoEquivalentMultiplier(ctx sdk.Context, asse } // calculate multiplier and set it - multiplier := osmoPoolAsset.ToDec().Quo(fullRangeLiquidity) + multiplier := osmoPoolAsset.ToLegacyDec().Quo(fullRangeLiquidity) k.SetOsmoEquivalentMultiplier(ctx, newEpochNumber, asset.Denom, multiplier) return nil diff --git a/x/superfluid/keeper/epoch_test.go b/x/superfluid/keeper/epoch_test.go index 782db11c4f7..fe57a71e6d1 100644 --- a/x/superfluid/keeper/epoch_test.go +++ b/x/superfluid/keeper/epoch_test.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" incentivestypes "github.com/osmosis-labs/osmosis/v19/x/incentives/types" @@ -28,7 +29,7 @@ func (s *KeeperTestSuite) TestUpdateOsmoEquivalentMultipliers() { { name: "update LP token Osmo equivalent successfully", asset: types.SuperfluidAsset{Denom: DefaultGammAsset, AssetType: types.SuperfluidAssetTypeLPShare}, - expectedMultiplier: sdk.MustNewDecFromStr("0.01"), + expectedMultiplier: osmomath.MustNewDecFromStr("0.01"), }, { name: "update LP token Osmo equivalent with pool unexpectedly deleted", @@ -45,7 +46,7 @@ func (s *KeeperTestSuite) TestUpdateOsmoEquivalentMultipliers() { { name: "update concentrated share Osmo equivalent successfully", asset: types.SuperfluidAsset{Denom: cltypes.GetConcentratedLockupDenomFromPoolId(1), AssetType: types.SuperfluidAssetTypeConcentratedShare}, - expectedMultiplier: sdk.MustNewDecFromStr("1"), + expectedMultiplier: osmomath.MustNewDecFromStr("1"), }, { name: "update concentrated share Osmo equivalent with pool unexpectedly deleted", @@ -75,11 +76,11 @@ func (s *KeeperTestSuite) TestUpdateOsmoEquivalentMultipliers() { if tc.removeStakingAsset { stakeDenom = "bar" } - poolCoins := sdk.NewCoins(sdk.NewCoin(stakeDenom, sdk.NewInt(1000000000000000000)), sdk.NewCoin("foo", sdk.NewInt(1000000000000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin(stakeDenom, osmomath.NewInt(1000000000000000000)), sdk.NewCoin("foo", osmomath.NewInt(1000000000000000000))) // Ensure that the multiplier is zero before the test multiplier := superfluidKeeper.GetOsmoEquivalentMultiplier(ctx, tc.asset.Denom) - s.Require().Equal(multiplier, sdk.ZeroDec()) + s.Require().Equal(multiplier, osmomath.ZeroDec()) // Create the respective pool if the test case requires it if !tc.poolDoesNotExist { @@ -100,7 +101,7 @@ func (s *KeeperTestSuite) TestUpdateOsmoEquivalentMultipliers() { // Ensure unwind superfluid asset is called // Check that multiplier was not set multiplier := superfluidKeeper.GetOsmoEquivalentMultiplier(ctx, tc.asset.Denom) - s.Require().Equal(multiplier, sdk.ZeroDec()) + s.Require().Equal(multiplier, osmomath.ZeroDec()) // Check that the asset was deleted _, err := superfluidKeeper.GetSuperfluidAsset(ctx, tc.asset.Denom) s.Require().Error(err) @@ -111,10 +112,10 @@ func (s *KeeperTestSuite) TestUpdateOsmoEquivalentMultipliers() { multiplier := superfluidKeeper.GetOsmoEquivalentMultiplier(ctx, tc.asset.Denom) if !tc.expectedZeroMultipler { - s.Require().NotEqual(multiplier, sdk.ZeroDec()) + s.Require().NotEqual(multiplier, osmomath.ZeroDec()) } else { // Zero on success is expected on CL errors since those are surrounded with `ApplyFuncIfNoError` - s.Require().Equal(multiplier, sdk.ZeroDec()) + s.Require().Equal(multiplier, osmomath.ZeroDec()) } } }) @@ -199,7 +200,7 @@ func (s *KeeperTestSuite) TestMoveSuperfluidDelegationRewardToGauges() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, _ := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -207,7 +208,7 @@ func (s *KeeperTestSuite) TestMoveSuperfluidDelegationRewardToGauges() { // allocate rewards to designated validators for _, valIndex := range tc.rewardedVals { - s.AllocateRewardsToValidator(valAddrs[valIndex], sdk.NewInt(20000)) + s.AllocateRewardsToValidator(valAddrs[valIndex], osmomath.NewInt(20000)) } // move intermediary account delegation rewards to gauges @@ -260,7 +261,7 @@ func (s *KeeperTestSuite) TestDistributeSuperfluidGauges() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations delAddresses, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -284,7 +285,7 @@ func (s *KeeperTestSuite) TestDistributeSuperfluidGauges() { // allocate rewards to designated validators for _, valIndex := range tc.rewardedVals { - s.AllocateRewardsToValidator(valAddrs[valIndex], sdk.NewInt(20000)) + s.AllocateRewardsToValidator(valAddrs[valIndex], osmomath.NewInt(20000)) } // move intermediary account delegation rewards to gauges @@ -364,7 +365,7 @@ func (s *KeeperTestSuite) TestDistributeSuperfluidGauges() { rewardReceiver = lock.Owner } delegatorBalance := s.App.BankKeeper.GetBalance(s.Ctx, sdk.MustAccAddressFromBech32(rewardReceiver), bondDenom) - s.Require().Equal(sdk.ZeroInt(), delegatorBalance.Amount) + s.Require().Equal(osmomath.ZeroInt(), delegatorBalance.Amount) } } } diff --git a/x/superfluid/keeper/export_test.go b/x/superfluid/keeper/export_test.go index b7fb78b024d..f84db99e6b6 100644 --- a/x/superfluid/keeper/export_test.go +++ b/x/superfluid/keeper/export_test.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" types "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -19,7 +20,7 @@ func (k Keeper) ValidateLockForSFDelegate(ctx sdk.Context, lock *lockuptypes.Per return k.validateLockForSFDelegate(ctx, lock, sender) } -func (k Keeper) PrepareConcentratedLockForSlash(ctx sdk.Context, lock *lockuptypes.PeriodLock, slashAmt sdk.Dec) (sdk.AccAddress, sdk.Coins, error) { +func (k Keeper) PrepareConcentratedLockForSlash(ctx sdk.Context, lock *lockuptypes.PeriodLock, slashAmt osmomath.Dec) (sdk.AccAddress, sdk.Coins, error) { return k.prepareConcentratedLockForSlash(ctx, lock, slashAmt) } @@ -47,7 +48,7 @@ func (k Keeper) ValidateMigration(ctx sdk.Context, sender sdk.AccAddress, lockId return k.validateMigration(ctx, sender, lockId, sharesToMigrate) } -func (k Keeper) AddToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added sdk.Int) (cltypes.CreateFullRangePositionData, uint64, error) { +func (k Keeper) AddToConcentratedLiquiditySuperfluidPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, amount0Added, amount1Added osmomath.Int) (cltypes.CreateFullRangePositionData, uint64, error) { return k.addToConcentratedLiquiditySuperfluidPosition(ctx, owner, positionId, amount0Added, amount1Added) } @@ -64,23 +65,23 @@ func (k Keeper) DistributeSuperfluidGauges(ctx sdk.Context) { } func (k Keeper) ConvertLockToStake(ctx sdk.Context, sender sdk.AccAddress, valAddr string, lockId uint64, - minAmtToStake sdk.Int) (totalAmtConverted sdk.Int, err error) { + minAmtToStake osmomath.Int) (totalAmtConverted osmomath.Int, err error) { return k.convertLockToStake(ctx, sender, valAddr, lockId, minAmtToStake) } func (k Keeper) ConvertGammSharesToOsmoAndStake( ctx sdk.Context, sender sdk.AccAddress, valAddr string, - poolIdLeaving uint64, exitCoins sdk.Coins, minAmtToStake sdk.Int, originalSuperfluidValAddr string, -) (totalAmtCoverted sdk.Int, err error) { + poolIdLeaving uint64, exitCoins sdk.Coins, minAmtToStake osmomath.Int, originalSuperfluidValAddr string, +) (totalAmtCoverted osmomath.Int, err error) { return k.convertGammSharesToOsmoAndStake(ctx, sender, valAddr, poolIdLeaving, exitCoins, minAmtToStake, originalSuperfluidValAddr) } func (k Keeper) ConvertUnlockedToStake(ctx sdk.Context, sender sdk.AccAddress, valAddr string, sharesToStake sdk.Coin, - minAmtToStake sdk.Int) (totalAmtConverted sdk.Int, err error) { + minAmtToStake osmomath.Int) (totalAmtConverted osmomath.Int, err error) { return k.convertUnlockedToStake(ctx, sender, valAddr, sharesToStake, minAmtToStake) } -func (k Keeper) DelegateBaseOnValsetPref(ctx sdk.Context, sender sdk.AccAddress, valAddr, originalSuperfluidValAddr string, totalAmtToStake sdk.Int) error { +func (k Keeper) DelegateBaseOnValsetPref(ctx sdk.Context, sender sdk.AccAddress, valAddr, originalSuperfluidValAddr string, totalAmtToStake osmomath.Int) error { return k.delegateBaseOnValsetPref(ctx, sender, valAddr, originalSuperfluidValAddr, totalAmtToStake) } diff --git a/x/superfluid/keeper/genesis_test.go b/x/superfluid/keeper/genesis_test.go index abb778b2698..692329dc84c 100644 --- a/x/superfluid/keeper/genesis_test.go +++ b/x/superfluid/keeper/genesis_test.go @@ -8,18 +8,17 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/osmosis-labs/osmosis/osmomath" simapp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/x/superfluid" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) var now = time.Now().UTC() var testGenesis = types.GenesisState{ Params: types.Params{ - MinimumRiskFactor: sdk.NewDecWithPrec(5, 1), // 50% + MinimumRiskFactor: osmomath.NewDecWithPrec(5, 1), // 50% }, SuperfluidAssets: []types.SuperfluidAsset{ { @@ -31,7 +30,7 @@ var testGenesis = types.GenesisState{ { EpochNumber: 1, Denom: DefaultGammAsset, - Multiplier: sdk.NewDec(1000), + Multiplier: osmomath.NewDec(1000), }, }, IntermediaryAccounts: []types.SuperfluidIntermediaryAccount{ diff --git a/x/superfluid/keeper/gov/gov_test.go b/x/superfluid/keeper/gov/gov_test.go index 28af24df288..7a073ec1525 100644 --- a/x/superfluid/keeper/gov/gov_test.go +++ b/x/superfluid/keeper/gov/gov_test.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -18,8 +19,8 @@ func (s *KeeperTestSuite) createGammPool(denoms []string) uint64 { for _, denom := range denoms { coins = coins.Add(sdk.NewInt64Coin(denom, 1000000000000000000)) poolAssets = append(poolAssets, balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denom, sdk.NewInt(1000000000000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denom, osmomath.NewInt(1000000000000000000)), }) } @@ -30,8 +31,8 @@ func (s *KeeperTestSuite) createGammPool(denoms []string) uint64 { s.Require().NoError(err) msg := balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, poolAssets, "") poolId, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, msg) s.Require().NoError(err) diff --git a/x/superfluid/keeper/grpc_query.go b/x/superfluid/keeper/grpc_query.go index c215638e872..5cc3bd0d4ff 100644 --- a/x/superfluid/keeper/grpc_query.go +++ b/x/superfluid/keeper/grpc_query.go @@ -15,6 +15,7 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "github.com/osmosis-labs/osmosis/osmomath" appparams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/cosmos/cosmos-sdk/store/prefix" @@ -233,7 +234,7 @@ func (q Querier) SuperfluidDelegationsByDelegator(goCtx context.Context, req *ty res := types.SuperfluidDelegationsByDelegatorResponse{ SuperfluidDelegationRecords: []types.SuperfluidDelegationRecord{}, TotalDelegatedCoins: sdk.NewCoins(), - TotalEquivalentStakedAmount: sdk.NewCoin(appparams.BaseCoinUnit, sdk.ZeroInt()), + TotalEquivalentStakedAmount: sdk.NewCoin(appparams.BaseCoinUnit, osmomath.ZeroInt()), } syntheticLocks := q.Keeper.lk.GetAllSyntheticLockupsByAddr(ctx, delAddr) @@ -509,7 +510,7 @@ func (q Querier) TotalDelegationByValidatorForDenom(goCtx context.Context, req * delegation, _ := q.SuperfluidDelegationsByValidatorDenom(goCtx, &types.SuperfluidDelegationsByValidatorDenomRequest{ValidatorAddress: valAddr.String(), Denom: req.Denom}) - amount := sdk.ZeroInt() + amount := osmomath.ZeroInt() for _, record := range delegation.SuperfluidDelegationRecords { amount = amount.Add(record.DelegationAmount.Amount) } @@ -537,7 +538,7 @@ func (q Querier) TotalDelegationByValidatorForDenom(goCtx context.Context, req * func (q Querier) TotalSuperfluidDelegations(goCtx context.Context, _ *types.TotalSuperfluidDelegationsRequest) (*types.TotalSuperfluidDelegationsResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) - totalSuperfluidDelegated := sdk.NewInt(0) + totalSuperfluidDelegated := osmomath.NewInt(0) intermediaryAccounts := q.Keeper.GetAllIntermediaryAccounts(ctx) for _, intermediaryAccount := range intermediaryAccounts { diff --git a/x/superfluid/keeper/grpc_query_test.go b/x/superfluid/keeper/grpc_query_test.go index 73990e3965b..9287ac4b507 100644 --- a/x/superfluid/keeper/grpc_query_test.go +++ b/x/superfluid/keeper/grpc_query_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -48,7 +49,7 @@ func (s *KeeperTestSuite) TestTotalDelegationByValidatorForAsset() { delegation_amount := int64(1000000) valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) superfluidDelegations := []superfluidDelegation{ {0, 0, 0, delegation_amount}, @@ -68,14 +69,14 @@ func (s *KeeperTestSuite) TestTotalDelegationByValidatorForAsset() { for _, result := range res.Assets { // check osmo equivalent is correct actual_response_osmo := result.OsmoEquivalent - needed_response_osmo, err := s.App.SuperfluidKeeper.GetSuperfluidOSMOTokens(ctx, denom, sdk.NewInt(delegation_amount)) + needed_response_osmo, err := s.App.SuperfluidKeeper.GetSuperfluidOSMOTokens(ctx, denom, osmomath.NewInt(delegation_amount)) s.Require().NoError(err) s.Require().Equal(actual_response_osmo, needed_response_osmo) // check sfs'd asset amount correct actual_response_asset := result.AmountSfsd - needed_response_asset := sdk.NewInt(delegation_amount) + needed_response_asset := osmomath.NewInt(delegation_amount) s.Require().Equal(actual_response_asset, needed_response_asset) // check validator addresses correct @@ -122,7 +123,7 @@ func (s *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() { // setup 2 validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // create a delegation of 1000000 for every combination of 2 delegations, 2 validators, and 2 superfluid denoms superfluidDelegations := []superfluidDelegation{ @@ -157,8 +158,8 @@ func (s *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() { multiplier1 := s.querier.Keeper.GetOsmoEquivalentMultiplier(s.Ctx, denoms[1]) minRiskFactor := s.querier.Keeper.GetParams(s.Ctx).MinimumRiskFactor - expectAmount0 := multiplier0.Mul(sdk.NewDec(1000000)).Sub(multiplier0.Mul(sdk.NewDec(1000000)).Mul(minRiskFactor)) - expectAmount1 := multiplier1.Mul(sdk.NewDec(1000000)).Sub(multiplier1.Mul(sdk.NewDec(1000000)).Mul(minRiskFactor)) + expectAmount0 := multiplier0.Mul(osmomath.NewDec(1000000)).Sub(multiplier0.Mul(osmomath.NewDec(1000000)).Mul(minRiskFactor)) + expectAmount1 := multiplier1.Mul(osmomath.NewDec(1000000)).Sub(multiplier1.Mul(osmomath.NewDec(1000000)).Mul(minRiskFactor)) s.Require().NoError(err) s.Require().Len(res.SuperfluidDelegationRecords, 2) @@ -192,7 +193,7 @@ func (s *KeeperTestSuite) TestGRPCQuerySuperfluidDelegations() { totalSuperfluidDelegationsRes, err := s.queryClient.TotalSuperfluidDelegations(sdk.WrapSDKContext(s.Ctx), &types.TotalSuperfluidDelegationsRequest{}) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(40000000), totalSuperfluidDelegationsRes.TotalDelegations) + s.Require().Equal(osmomath.NewInt(40000000), totalSuperfluidDelegationsRes.TotalDelegations) for _, lockID := range locks { connectedIntermediaryAccountRes, err := s.queryClient.ConnectedIntermediaryAccount(sdk.WrapSDKContext(s.Ctx), &types.ConnectedIntermediaryAccountRequest{LockId: lockID.ID}) @@ -213,7 +214,7 @@ func (s *KeeperTestSuite) TestGRPCQuerySuperfluidDelegationsDontIncludeUnbonding // setup 2 validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // create a delegation of 1000000 for every combination of 2 delegations, 2 validators, and 2 superfluid denoms superfluidDelegations := []superfluidDelegation{ @@ -268,7 +269,7 @@ func (s *KeeperTestSuite) TestGRPCQuerySuperfluidDelegationsDontIncludeUnbonding totalSuperfluidDelegationsRes, err := s.queryClient.TotalSuperfluidDelegations(sdk.WrapSDKContext(s.Ctx), &types.TotalSuperfluidDelegationsRequest{}) s.Require().NoError(err) - s.Require().Equal(totalSuperfluidDelegationsRes.TotalDelegations, sdk.NewInt(30000000)) + s.Require().Equal(totalSuperfluidDelegationsRes.TotalDelegations, osmomath.NewInt(30000000)) } func (s *KeeperTestSuite) TestUserConcentratedSuperfluidPositionsBondedAndUnbonding() { @@ -282,7 +283,7 @@ func (s *KeeperTestSuite) TestUserConcentratedSuperfluidPositionsBondedAndUnbond stakingParams.BondDenom = "uosmo" s.App.StakingKeeper.SetParams(s.Ctx, stakingParams) - coins := sdk.NewCoins(sdk.NewCoin("token0", sdk.NewInt(1000000000000)), sdk.NewCoin(s.App.StakingKeeper.BondDenom(s.Ctx), sdk.NewInt(1000000000000))) + coins := sdk.NewCoins(sdk.NewCoin("token0", osmomath.NewInt(1000000000000)), sdk.NewCoin(s.App.StakingKeeper.BondDenom(s.Ctx), osmomath.NewInt(1000000000000))) // Prepare 2 concentrated pools. clPool := s.PrepareConcentratedPoolWithCoinsAndFullRangePosition(coins[0].Denom, coins[1].Denom) @@ -415,7 +416,7 @@ func (s *KeeperTestSuite) TestGRPCQueryTotalDelegationByDelegator() { // setup 2 validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // create a delegation of 1000000 for every combination of 2 delegations, 2 validators, and 2 superfluid denoms superfluidDelegations := []superfluidDelegation{ @@ -429,10 +430,10 @@ func (s *KeeperTestSuite) TestGRPCQueryTotalDelegationByDelegator() { delegatorAddresses, _, _ := s.setupSuperfluidDelegations(valAddrs, superfluidDelegations, denoms) // setup normal delegations - bond0to0 := stakingtypes.NewDelegation(delegatorAddresses[0], valAddrs[0], sdk.NewDec(9000000)) - bond0to1 := stakingtypes.NewDelegation(delegatorAddresses[0], valAddrs[1], sdk.NewDec(9000000)) - bond1to0 := stakingtypes.NewDelegation(delegatorAddresses[1], valAddrs[0], sdk.NewDec(9000000)) - bond1to1 := stakingtypes.NewDelegation(delegatorAddresses[1], valAddrs[1], sdk.NewDec(9000000)) + bond0to0 := stakingtypes.NewDelegation(delegatorAddresses[0], valAddrs[0], osmomath.NewDec(9000000)) + bond0to1 := stakingtypes.NewDelegation(delegatorAddresses[0], valAddrs[1], osmomath.NewDec(9000000)) + bond1to0 := stakingtypes.NewDelegation(delegatorAddresses[1], valAddrs[0], osmomath.NewDec(9000000)) + bond1to1 := stakingtypes.NewDelegation(delegatorAddresses[1], valAddrs[1], osmomath.NewDec(9000000)) s.App.StakingKeeper.SetDelegation(s.Ctx, bond0to0) s.App.StakingKeeper.SetDelegation(s.Ctx, bond0to1) @@ -443,8 +444,8 @@ func (s *KeeperTestSuite) TestGRPCQueryTotalDelegationByDelegator() { multiplier1 := s.querier.Keeper.GetOsmoEquivalentMultiplier(s.Ctx, denoms[1]) minRiskFactor := s.querier.Keeper.GetParams(s.Ctx).MinimumRiskFactor - expectAmount0 := multiplier0.Mul(sdk.NewDec(1000000)).Sub(multiplier0.Mul(sdk.NewDec(1000000)).Mul(minRiskFactor)) - expectAmount1 := multiplier1.Mul(sdk.NewDec(1000000)).Sub(multiplier1.Mul(sdk.NewDec(1000000)).Mul(minRiskFactor)) + expectAmount0 := multiplier0.Mul(osmomath.NewDec(1000000)).Sub(multiplier0.Mul(osmomath.NewDec(1000000)).Mul(minRiskFactor)) + expectAmount1 := multiplier1.Mul(osmomath.NewDec(1000000)).Sub(multiplier1.Mul(osmomath.NewDec(1000000)).Mul(minRiskFactor)) // for each delegator, query all their superfluid delegations and normal delegations. Making sure they have 4 delegations // Making sure TotalEquivalentStakedAmount is equal to converted amount + normal delegations @@ -464,7 +465,7 @@ func (s *KeeperTestSuite) TestGRPCQueryTotalDelegationByDelegator() { sdk.NewInt64Coin("uosmo", 18000000), ))) - total_osmo_equivalent := sdk.NewCoin("uosmo", expectAmount0.RoundInt().Add(expectAmount1.RoundInt()).Add(sdk.NewInt(18000000))) + total_osmo_equivalent := sdk.NewCoin("uosmo", expectAmount0.RoundInt().Add(expectAmount1.RoundInt()).Add(osmomath.NewInt(18000000))) s.Require().True(res.TotalEquivalentStakedAmount.IsEqual(total_osmo_equivalent)) } diff --git a/x/superfluid/keeper/hooks.go b/x/superfluid/keeper/hooks.go index 3d97d163637..23e45fa6a16 100644 --- a/x/superfluid/keeper/hooks.go +++ b/x/superfluid/keeper/hooks.go @@ -3,6 +3,7 @@ package keeper import ( "time" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/superfluid/keeper/internal/events" epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" @@ -87,14 +88,14 @@ func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) { } -func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) { +func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec, effectiveSlashFactor osmomath.Dec) { if slashFactor.IsZero() { return } h.k.SlashLockupsForValidatorSlash(ctx, valAddr, infractionHeight, slashFactor) } -func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec, effectiveSlashFactor sdk.Dec) { +func (h Hooks) AfterValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec, effectiveSlashFactor osmomath.Dec) { if slashFactor.IsZero() { return } diff --git a/x/superfluid/keeper/hooks_test.go b/x/superfluid/keeper/hooks_test.go index d8902eaf77e..7234456ff8a 100644 --- a/x/superfluid/keeper/hooks_test.go +++ b/x/superfluid/keeper/hooks_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" lockupkeeper "github.com/osmosis-labs/osmosis/v19/x/lockup/keeper" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -30,7 +31,7 @@ func (s *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { // delegation rewards are calculated using the equation (current period cumulative reward ratio - last period cumulative reward ratio) * asset amount // in this test case, the calculation for expected reward would be the following (0.99999 - 0) * 10_000_000 // thus we expect 999_990 stake as rewards - []sdk.Coins{{sdk.NewCoin("stake", sdk.NewInt(999990))}}, + []sdk.Coins{{sdk.NewCoin("stake", osmomath.NewInt(999990))}}, }, { "happy path with two validator and delegator each", @@ -43,7 +44,7 @@ func (s *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { // This would be the first block propsed by the second validator, current period cumulative reward ratio being 999_86.66684, // last period cumulative reward ratio being 0 // Thus as rewards, we expect 999986stake, calculted using the following equation: (999_86.66684 - 0) * 7_500_000 - []sdk.Coins{{sdk.NewCoin("stake", sdk.NewInt(999990))}, {sdk.NewCoin("stake", sdk.NewInt(999986))}}, + []sdk.Coins{{sdk.NewCoin("stake", osmomath.NewInt(999990))}, {sdk.NewCoin("stake", osmomath.NewInt(999986))}}, }, } @@ -52,7 +53,7 @@ func (s *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { s.SetupTest() valAddrs := s.SetupValidators(tc.validatorStats) - denoms, poolIds := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20)}) + denoms, poolIds := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20)}) // Generate delegator addresses delAddrs, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -72,7 +73,7 @@ func (s *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { // check lptoken twap value set newEpochMultiplier := s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, denoms[0]) - s.Require().Equal(newEpochMultiplier, sdk.NewDec(15)) + s.Require().Equal(newEpochMultiplier, osmomath.NewDec(15)) for index, lock := range locks { // check gauge creation in new block @@ -92,7 +93,7 @@ func (s *KeeperTestSuite) TestSuperfluidAfterEpochEnd() { s.Require().NoError(err) delegation, found := s.App.StakingKeeper.GetDelegation(s.Ctx, acc.GetAccAddress(), valAddr) s.Require().True(found) - s.Require().Equal(sdk.NewDec(7500000), delegation.Shares) + s.Require().Equal(osmomath.NewDec(7500000), delegation.Shares) } for index, delAddr := range delAddrs { @@ -280,12 +281,12 @@ func (s *KeeperTestSuite) TestBeforeSlashingUnbondingDelegationHook() { s.Run(tc.name, func() { s.SetupTest() - slashFactor := sdk.NewDecWithPrec(5, 2) + slashFactor := osmomath.NewDecWithPrec(5, 2) // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, _ := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -324,14 +325,14 @@ func (s *KeeperTestSuite) TestBeforeSlashingUnbondingDelegationHook() { for _, lockId := range tc.expSlashedLockIds { gotLock, err := s.App.LockupKeeper.GetLockByID(s.Ctx, lockId) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(950000).String(), gotLock.Coins.AmountOf(denoms[0]).String()) + s.Require().Equal(osmomath.NewInt(950000).String(), gotLock.Coins.AmountOf(denoms[0]).String()) } // check unslashed lockups for _, lockId := range tc.expUnslashedLockIds { gotLock, err := s.App.LockupKeeper.GetLockByID(s.Ctx, lockId) s.Require().NoError(err) - s.Require().Equal(sdk.NewInt(1000000).String(), gotLock.Coins.AmountOf(denoms[0]).String()) + s.Require().Equal(osmomath.NewInt(1000000).String(), gotLock.Coins.AmountOf(denoms[0]).String()) } }) } @@ -344,7 +345,7 @@ func (s *KeeperTestSuite) TestAfterAddTokensToLock_Event() { valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, []superfluidDelegation{{0, 0, 0, 1000000}}, denoms) @@ -353,7 +354,7 @@ func (s *KeeperTestSuite) TestAfterAddTokensToLock_Event() { for index, lock := range locks { lockupMsgServer := lockupkeeper.NewMsgServerImpl(s.App.LockupKeeper) c := sdk.WrapSDKContext(s.Ctx) - coinsToLock := sdk.NewCoins(sdk.NewCoin(denoms[index], sdk.NewInt(100))) + coinsToLock := sdk.NewCoins(sdk.NewCoin(denoms[index], osmomath.NewInt(100))) sender, _ := sdk.AccAddressFromBech32(lock.Owner) s.FundAcc(sender, coinsToLock) diff --git a/x/superfluid/keeper/intermediary_account_test.go b/x/superfluid/keeper/intermediary_account_test.go index df9e959e4fb..37a0c79062e 100644 --- a/x/superfluid/keeper/intermediary_account_test.go +++ b/x/superfluid/keeper/intermediary_account_test.go @@ -4,6 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" ) @@ -48,7 +49,7 @@ func (s *KeeperTestSuite) TestIntermediaryAccountCreation() { delAddrs := CreateRandomAccounts(int(tc.delegatorNumber)) // we create two additional pools: total three pools, 10 gauges - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) var interAccs []types.SuperfluidIntermediaryAccount diff --git a/x/superfluid/keeper/internal/events/emit_test.go b/x/superfluid/keeper/internal/events/emit_test.go index 291ad4ca9fe..3065acedff5 100644 --- a/x/superfluid/keeper/internal/events/emit_test.go +++ b/x/superfluid/keeper/internal/events/emit_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/superfluid/keeper/internal/events" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -212,7 +213,7 @@ func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidIncreaseDelegationEven "basic valid": { ctx: suite.CreateTestContext(), lockID: 1, - amount: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(100))), + amount: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(100))), }, "context with no event manager": { ctx: sdk.Context{}, @@ -220,7 +221,7 @@ func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidIncreaseDelegationEven "valid with multiple tokens in and out": { ctx: suite.CreateTestContext(), lockID: 1, - amount: sdk.NewCoins(sdk.NewCoin(testDenomA, sdk.NewInt(100)), sdk.NewCoin(testDenomB, sdk.NewInt(10))), + amount: sdk.NewCoins(sdk.NewCoin(testDenomA, osmomath.NewInt(100)), sdk.NewCoin(testDenomB, osmomath.NewInt(10))), }, } diff --git a/x/superfluid/keeper/invariants.go b/x/superfluid/keeper/invariants.go index 6f8666c4e35..9ac81483ca0 100644 --- a/x/superfluid/keeper/invariants.go +++ b/x/superfluid/keeper/invariants.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" ) @@ -26,7 +27,7 @@ func AllInvariants(keeper Keeper) sdk.Invariant { func TotalSuperfluidDelegationInvariant(keeper Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { accs := keeper.GetAllIntermediaryAccounts(ctx) - totalSuperfluidDelegationTokens := sdk.ZeroDec() + totalSuperfluidDelegationTokens := osmomath.ZeroDec() // Compute the total amount delegated from all intermediary accounts for _, acc := range accs { @@ -49,7 +50,7 @@ func TotalSuperfluidDelegationInvariant(keeper Keeper) sdk.Invariant { // Compute the total delegation amount expected // from every lockID intermediary account connections - totalExpectedSuperfluidAmount := sdk.ZeroInt() + totalExpectedSuperfluidAmount := osmomath.ZeroInt() connections := keeper.GetAllLockIdIntermediaryAccountConnections(ctx) for _, connection := range connections { lockId := connection.LockId diff --git a/x/superfluid/keeper/keeper_test.go b/x/superfluid/keeper/keeper_test.go index 609d25059fc..c7b59c42265 100644 --- a/x/superfluid/keeper/keeper_test.go +++ b/x/superfluid/keeper/keeper_test.go @@ -10,6 +10,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -64,18 +65,18 @@ func (s *KeeperTestSuite) SetupTest() { mintParams := s.App.MintKeeper.GetParams(s.Ctx) mintParams.EpochIdentifier = superfluidEpochIdentifer mintParams.DistributionProportions = minttypes.DistributionProportions{ - Staking: sdk.OneDec(), - PoolIncentives: sdk.ZeroDec(), - DeveloperRewards: sdk.ZeroDec(), - CommunityPool: sdk.ZeroDec(), + Staking: osmomath.OneDec(), + PoolIncentives: osmomath.ZeroDec(), + DeveloperRewards: osmomath.ZeroDec(), + CommunityPool: osmomath.ZeroDec(), } s.App.MintKeeper.SetParams(s.Ctx, mintParams) - s.App.MintKeeper.SetMinter(s.Ctx, minttypes.NewMinter(sdk.NewDec(1_000_000))) + s.App.MintKeeper.SetMinter(s.Ctx, minttypes.NewMinter(osmomath.NewDec(1_000_000))) distributionParams := s.App.DistrKeeper.GetParams(s.Ctx) - distributionParams.BaseProposerReward = sdk.ZeroDec() - distributionParams.BonusProposerReward = sdk.ZeroDec() - distributionParams.CommunityTax = sdk.ZeroDec() + distributionParams.BaseProposerReward = osmomath.ZeroDec() + distributionParams.BonusProposerReward = osmomath.ZeroDec() + distributionParams.CommunityTax = osmomath.ZeroDec() s.App.DistrKeeper.SetParams(s.Ctx, distributionParams) } @@ -102,8 +103,8 @@ func (s *KeeperTestSuite) createGammPool(denoms []string) uint64 { for _, denom := range denoms { coins = coins.Add(sdk.NewInt64Coin(denom, 1000000000000000000)) poolAssets = append(poolAssets, balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(denom, sdk.NewInt(1000000000000000000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(denom, osmomath.NewInt(1000000000000000000)), }) } @@ -111,8 +112,8 @@ func (s *KeeperTestSuite) createGammPool(denoms []string) uint64 { s.FundAcc(acc1, coins) msg := balancer.NewMsgCreateBalancerPool(acc1, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.ZeroDec(), }, poolAssets, "") poolId, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, msg) s.Require().NoError(err) @@ -129,7 +130,7 @@ func (s *KeeperTestSuite) SetupValidators(bondStatuses []stakingtypes.BondStatus return valAddrs } -func (s *KeeperTestSuite) SetupGammPoolsAndSuperfluidAssets(multipliers []sdk.Dec) ([]string, []uint64) { +func (s *KeeperTestSuite) SetupGammPoolsAndSuperfluidAssets(multipliers []osmomath.Dec) ([]string, []uint64) { pools := s.SetupGammPoolsWithBondDenomMultiplier(multipliers) denoms := []string{} @@ -203,13 +204,13 @@ func (s *KeeperTestSuite) checkIntermediaryAccountDelegations(intermediaryAccs [ // check delegation from intermediary account to validator delegation, found := s.App.StakingKeeper.GetDelegation(s.Ctx, acc.GetAccAddress(), valAddr) s.Require().True(found) - s.Require().True(delegation.Shares.GTE(sdk.NewDec(10000000))) + s.Require().True(delegation.Shares.GTE(osmomath.NewDec(10000000))) // check delegated tokens validator, found := s.App.StakingKeeper.GetValidator(s.Ctx, valAddr) s.Require().True(found) delegatedTokens := validator.TokensFromShares(delegation.Shares).TruncateInt() - s.Require().True(delegatedTokens.GTE(sdk.NewInt(10000000))) + s.Require().True(delegatedTokens.GTE(osmomath.NewInt(10000000))) } } diff --git a/x/superfluid/keeper/migrate_test.go b/x/superfluid/keeper/migrate_test.go index e98c13ca62f..230dc412460 100644 --- a/x/superfluid/keeper/migrate_test.go +++ b/x/superfluid/keeper/migrate_test.go @@ -25,10 +25,10 @@ import ( var ( STAKE = "stake" - DefaultAmt0 = sdk.NewInt(1000000) + DefaultAmt0 = osmomath.NewInt(1000000) DefaultCoin0 = sdk.NewCoin(STAKE, DefaultAmt0) USDC = "usdc" - DefaultAmt1 = sdk.NewInt(5000000000) + DefaultAmt1 = osmomath.NewInt(5000000000) DefaultCoin1 = sdk.NewCoin(USDC, DefaultAmt1) DefaultCoins = sdk.NewCoins(DefaultCoin0, DefaultCoin1) DefaultLowerTick = int64(30545000) @@ -49,81 +49,81 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { unlocking bool noLock bool overwriteLockId bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec minExitCoins sdk.Coins expectedError error } testCases := map[string]sendTest{ "lock that is not superfluid delegated, not unlocking": { // migrateNonSuperfluidLockBalancerToConcentrated - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.9"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.9"), expectedError: types.MigratePartialSharesError{SharesToMigrate: "45000000000000000000", SharesInLock: "50000000000000000000"}, }, "lock that is not superfluid delegated, unlocking": { // migrateNonSuperfluidLockBalancerToConcentrated unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.6"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.6"), expectedError: types.MigratePartialSharesError{SharesToMigrate: "30000000000000000000", SharesInLock: "50000000000000000000"}, }, "lock that is superfluid delegated, not unlocking (full shares)": { // migrateSuperfluidBondedBalancerToConcentrated superfluidDelegated: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "lock that is superfluid undelegating, not unlocking (full shares)": { // migrateSuperfluidUnbondingBalancerToConcentrated superfluidDelegated: true, superfluidUndelegating: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "lock that is superfluid undelegating, unlocking (full shares)": { // migrateSuperfluidUnbondingBalancerToConcentrated superfluidDelegated: true, superfluidUndelegating: true, unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "no lock (partial shares)": { // MigrateUnlockedPositionFromBalancerToConcentrated noLock: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.3"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.3"), }, "no lock (full shares)": { // MigrateUnlockedPositionFromBalancerToConcentrated noLock: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "error: non-existent lock": { overwriteLockId: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: errorsmod.Wrap(lockuptypes.ErrLockupNotFound, fmt.Sprintf("lock with ID %d does not exist", 5)), }, "error: lock that is not superfluid delegated, not unlocking, min exit coins more than being exitted": { // migrateNonSuperfluidLockBalancerToConcentrated - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000)), sdk.NewCoin("stake", sdk.NewInt(5000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000)), sdk.NewCoin("stake", osmomath.NewInt(5000))), expectedError: gammtypes.ErrLimitMinAmount, }, "error: lock that is not superfluid delegated, unlocking, min exit coins more than being exitted": { // migrateNonSuperfluidLockBalancerToConcentrated unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(5000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(5000))), expectedError: gammtypes.ErrLimitMinAmount, }, "error: lock that is superfluid delegated, not unlocking (full shares), min exit coins more than being exitted": { // migrateSuperfluidBondedBalancerToConcentrated superfluidDelegated: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10000))), expectedError: gammtypes.ErrLimitMinAmount, }, "error: lock that is superfluid undelegating, not unlocking, min exit coins more than being exitted": { // migrateSuperfluidUnbondingBalancerToConcentrated superfluidDelegated: true, superfluidUndelegating: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(40000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(40000))), expectedError: gammtypes.ErrLimitMinAmount, }, "lock that is superfluid undelegating, unlocking, min exit coins more than being exitted": { @@ -131,8 +131,8 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { superfluidDelegated: true, superfluidUndelegating: true, unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(40000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + minExitCoins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(40000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -151,7 +151,7 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // Modify migration inputs if necessary if tc.overwriteLockId { @@ -181,7 +181,7 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { // If the lock was superfluid delegated: if tc.superfluidDelegated && !tc.superfluidUndelegating { - if tc.percentOfSharesToMigrate.Equal(sdk.OneDec()) { + if tc.percentOfSharesToMigrate.Equal(osmomath.OneDec()) { // If we migrated all the shares: // The intermediary account connection to the old gamm lock should be deleted. @@ -199,7 +199,7 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { // Check that the original gamm lockup is deleted. _, err := s.App.LockupKeeper.GetLockByID(s.Ctx, originalGammLockId) s.Require().Error(err) - } else if tc.percentOfSharesToMigrate.LT(sdk.OneDec()) { + } else if tc.percentOfSharesToMigrate.LT(osmomath.OneDec()) { // If we migrated part of the shares: // The intermediary account connection to the old gamm lock should still be present. addr := superfluidKeeper.GetLockIdIntermediaryAccountConnection(s.Ctx, originalGammLockId) @@ -223,7 +223,7 @@ func (s *KeeperTestSuite) TestRouteLockedBalancerToConcentratedMigration() { clIntermediaryAcc := superfluidKeeper.GetLockIdIntermediaryAccountConnection(s.Ctx, concentratedLockId) delegation, found := stakingKeeper.GetDelegation(s.Ctx, clIntermediaryAcc, valAddr) s.Require().True(found, "expected delegation, found delegation no delegation") - s.Require().Equal(balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().Sub(sdk.OneInt()).String(), delegation.Shares.RoundInt().String(), "expected %d shares, found %d shares", balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().String(), delegation.Shares.String()) + s.Require().Equal(balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().Sub(osmomath.OneInt()).String(), delegation.Shares.RoundInt().String(), "expected %d shares, found %d shares", balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().String(), delegation.Shares.String()) } // If the lock was superfluid undelegating: @@ -257,31 +257,31 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated() { type sendTest struct { overwriteValidatorAddress bool overwriteLockId bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "lock that is superfluid delegated, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "error: migrate more shares than lock has": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1.1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1.1"), expectedError: types.MigrateMoreSharesThanLockHasError{SharesToMigrate: "55000000000000000000", SharesInLock: "50000000000000000000"}, }, "error: invalid validator address": { overwriteValidatorAddress: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: fmt.Errorf("decoding bech32 failed: invalid checksum"), }, "error: non-existent lock ID": { overwriteLockId: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: lockuptypes.ErrLockupNotFound, }, "error: lock that is superfluid delegated, not unlocking (full shares), token out mins is more than exit coins": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -300,7 +300,7 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated() { // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // GetMigrationType is called via the migration message router and is always run prior to the migration itself. // We use it here just to retrieve the synthetic lock before the migration. @@ -342,7 +342,7 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated() { positionData.Amount0, positionData.Amount1, ) - if tc.percentOfSharesToMigrate.Equal(sdk.OneDec()) { + if tc.percentOfSharesToMigrate.Equal(osmomath.OneDec()) { // If we migrated all the shares: // The intermediary account connection to the old gamm lock should be deleted. @@ -360,7 +360,7 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated() { // Check that the original gamm lockup is deleted. _, err := s.App.LockupKeeper.GetLockByID(s.Ctx, originalGammLockId) s.Require().Error(err) - } else if tc.percentOfSharesToMigrate.LT(sdk.OneDec()) { + } else if tc.percentOfSharesToMigrate.LT(osmomath.OneDec()) { // If we migrated part of the shares: // The intermediary account connection to the old gamm lock should still be present. addr := superfluidKeeper.GetLockIdIntermediaryAccountConnection(s.Ctx, originalGammLockId) @@ -385,7 +385,7 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidBondedBalancerToConcentrated() { clIntermediaryAcc := superfluidKeeper.GetLockIdIntermediaryAccountConnection(s.Ctx, concentratedLockId) delegation, found := stakingKeeper.GetDelegation(s.Ctx, clIntermediaryAcc, valAddr) s.Require().True(found, "expected delegation, found delegation no delegation") - s.Require().Equal(balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().Sub(sdk.OneInt()).String(), delegation.Shares.RoundInt().String(), "expected %d shares, found %d shares", balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().String(), delegation.Shares.String()) + s.Require().Equal(balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().Sub(osmomath.OneInt()).String(), delegation.Shares.RoundInt().String(), "expected %d shares, found %d shares", balancerDelegationPre.Shares.Mul(tc.percentOfSharesToMigrate).RoundInt().String(), delegation.Shares.String()) // Check if the new intermediary account connection was created. newConcentratedIntermediaryAccount := superfluidKeeper.GetLockIdIntermediaryAccountConnection(s.Ctx, concentratedLockId) @@ -416,26 +416,26 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidUnbondingBalancerToConcentrated() type sendTest struct { unlocking bool overwriteValidatorAddress bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "lock that is superfluid undelegating, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "lock that is superfluid undelegating, unlocking (full shares)": { unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "error: invalid validator address": { overwriteValidatorAddress: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: fmt.Errorf("decoding bech32 failed: invalid checksum"), }, "error: lock that is superfluid undelegating, not unlocking (full shares), token out mins is more than exit coins": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -456,7 +456,7 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidUnbondingBalancerToConcentrated() // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // GetMigrationType is called via the migration message router and is always run prior to the migration itself synthLockBeforeMigration, migrationType, err := superfluidKeeper.GetMigrationType(s.Ctx, int64(originalGammLockId)) @@ -490,13 +490,13 @@ func (s *KeeperTestSuite) TestMigrateSuperfluidUnbondingBalancerToConcentrated() positionData.Amount0, positionData.Amount1, ) - if tc.percentOfSharesToMigrate.Equal(sdk.OneDec()) { + if tc.percentOfSharesToMigrate.Equal(osmomath.OneDec()) { // If we migrated all the shares: // The synthetic lockup should be deleted. _, err = lockupKeeper.GetSyntheticLockup(s.Ctx, originalGammLockId, keeper.UnstakingSyntheticDenom(balancerLock.Coins[0].Denom, valAddr.String())) s.Require().Error(err) - } else if tc.percentOfSharesToMigrate.LT(sdk.OneDec()) { + } else if tc.percentOfSharesToMigrate.LT(osmomath.OneDec()) { // If we migrated part of the shares: // The synthetic lockup should not be deleted. @@ -539,21 +539,21 @@ func (s *KeeperTestSuite) TestMigrateNonSuperfluidLockBalancerToConcentrated() { defaultJoinTime := s.Ctx.BlockTime() type sendTest struct { unlocking bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "lock that is not superfluid delegated, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "lock that is not superfluid delegated, unlocking (full shares)": { unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "error: lock that is not superfluid delegated, not unlocking (full shares), token out mins is more than exit coins": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -571,7 +571,7 @@ func (s *KeeperTestSuite) TestMigrateNonSuperfluidLockBalancerToConcentrated() { // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // GetMigrationType is called via the migration message router and is always run prior to the migration itself synthLockBeforeMigration, migrationType, err := superfluidKeeper.GetMigrationType(s.Ctx, int64(originalGammLockId)) @@ -615,28 +615,28 @@ func (s *KeeperTestSuite) TestMigrateUnlockedPositionFromBalancerToConcentrated( defaultJoinTime := s.Ctx.BlockTime() type sendTest struct { unlocking bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "no lock (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "no lock (partial shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.9"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.9"), }, "no lock (more shares than own)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1.1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1.1"), expectedError: fmt.Errorf("insufficient funds"), }, "no lock (no shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0"), expectedError: errorsmod.Wrapf(gammtypes.ErrInvalidMathApprox, "Trying to exit a negative amount of shares"), }, "error: no lock (full shares), token out mins is more than exit coins": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(10000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(10000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -654,7 +654,7 @@ func (s *KeeperTestSuite) TestMigrateUnlockedPositionFromBalancerToConcentrated( // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // GetMigrationType is called via the migration message router and is always run prior to the migration itself synthLockBeforeMigration, migrationType, err := superfluidKeeper.GetMigrationType(s.Ctx, 0) @@ -693,60 +693,60 @@ func (s *KeeperTestSuite) TestValidateMigration() { overwriteSender bool overwriteSharesDenomValue string overwriteLockId bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "lock that is not superfluid delegated, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), isSuperfluidDelegated: false, isSuperfluidUndelegating: false, }, "lock that is not superfluid delegated, not unlocking (partial shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.9"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.9"), isSuperfluidDelegated: false, isSuperfluidUndelegating: false, }, "lock that is not superfluid delegated, unlocking (full shares)": { unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), isSuperfluidDelegated: false, isSuperfluidUndelegating: false, }, "lock that is superfluid undelegating, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), isSuperfluidDelegated: true, isSuperfluidUndelegating: true, }, "lock that is superfluid undelegating, unlocking (full shares)": { unlocking: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), isSuperfluidDelegated: true, isSuperfluidUndelegating: true, }, "lock that is superfluid delegated, not unlocking (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), isSuperfluidDelegated: true, }, "error: denom prefix error": { overwriteSharesDenomValue: "cl/pool/2", - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: types.SharesToMigrateDenomPrefixError{Denom: "cl/pool/2", ExpectedDenomPrefix: gammtypes.GAMMTokenPrefix}, }, "error: no canonical link": { overwriteSharesDenomValue: "gamm/pool/2", - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: gammtypes.ConcentratedPoolMigrationLinkNotFoundError{PoolIdLeaving: 2}, }, "error: wrong sender": { overwriteSender: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: lockuptypes.ErrNotLockOwner, }, "error: wrong lock ID": { overwriteLockId: true, - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), expectedError: lockuptypes.ErrLockupNotFound, }, } @@ -764,7 +764,7 @@ func (s *KeeperTestSuite) TestValidateMigration() { // Depending on the test case, we attempt to migrate a subset of the balancer LP tokens we originally created. coinsToMigrate := balancerPoolShareOut - coinsToMigrate.Amount = coinsToMigrate.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt() + coinsToMigrate.Amount = coinsToMigrate.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt() // Modify migration inputs if necessary if tc.overwriteSender { @@ -805,47 +805,47 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { overwritePool bool overwritePoolId bool exitCoinsLengthIsTwo bool - percentOfSharesToMigrate sdk.Dec + percentOfSharesToMigrate osmomath.Dec tokenOutMins sdk.Coins expectedError error } testCases := map[string]sendTest{ "happy path (full shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), }, "happy path (partial shares)": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("0.4"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("0.4"), expectedError: types.MigratePartialSharesError{SharesToMigrate: "20000000000000000000", SharesInLock: "50000000000000000000"}, }, "attempt to leave a pool that has more than two denoms": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), overwritePool: true, exitCoinsLengthIsTwo: false, }, "error: lock does not exist": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), overwritePreMigrationLock: true, expectedError: lockuptypes.ErrLockupNotFound, }, "error: attempt to migrate more than lock has": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), overwriteShares: true, expectedError: types.MigrateMoreSharesThanLockHasError{SharesToMigrate: "50000000000000000001", SharesInLock: "50000000000000000000"}, }, "error: attempt to leave a pool that does not exist": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), overwritePoolId: true, expectedError: fmt.Errorf("pool with ID %d does not exist", 2), }, "error: attempt to leave a pool that has more than two denoms with exitCoinsLengthIsTwo true": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), overwritePool: true, exitCoinsLengthIsTwo: true, expectedError: types.TwoTokenBalancerPoolError{NumberOfTokens: 4}, }, "error: happy path (full shares), token out mins is more than exit coins": { - percentOfSharesToMigrate: sdk.MustNewDecFromStr("1"), - tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100000))), + percentOfSharesToMigrate: osmomath.MustNewDecFromStr("1"), + tokenOutMins: sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100000))), expectedError: gammtypes.ErrLimitMinAmount, }, } @@ -875,8 +875,8 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { // Create a balancer pool of "stake" and "foo". msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) balancerPooId, err := poolmanagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) @@ -891,7 +891,7 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { // Note how much of the balancer pool's LP token the account that joined the pool has. balancerPoolShareOut := bankKeeper.GetBalance(ctx, poolJoinAcc, balancerPoolDenom) - sharesToMigrate := balancerPoolShareOut.Amount.ToDec().Mul(tc.percentOfSharesToMigrate).TruncateInt() + sharesToMigrate := balancerPoolShareOut.Amount.ToLegacyDec().Mul(tc.percentOfSharesToMigrate).TruncateInt() coinsToMigrate := sdk.NewCoin(balancerPoolDenom, sharesToMigrate) // The unbonding duration is the same as the staking module's unbonding duration. @@ -908,13 +908,13 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { } if tc.overwriteShares { - coinsToMigrate.Amount = lock.Coins[0].Amount.Add(sdk.NewInt(1)) + coinsToMigrate.Amount = lock.Coins[0].Amount.Add(osmomath.NewInt(1)) } if tc.overwritePool { multiCoinBalancerPoolId := s.PrepareBalancerPool() balancerPooId = multiCoinBalancerPoolId - shareAmt := sdk.MustNewDecFromStr("50000000000000000000").TruncateInt() + shareAmt := osmomath.MustNewDecFromStr("50000000000000000000").TruncateInt() newShares := sdk.NewCoin(fmt.Sprintf("gamm/pool/%d", multiCoinBalancerPoolId), shareAmt) s.FundAcc(poolJoinAcc, sdk.NewCoins(newShares)) } @@ -933,11 +933,11 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { s.Require().NoError(err) defaultErrorTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.NewDec(1), + AdditiveTolerance: osmomath.NewDec(1), RoundingDir: osmomath.RoundDown, } - if tc.percentOfSharesToMigrate.Equal(sdk.OneDec()) { + if tc.percentOfSharesToMigrate.Equal(osmomath.OneDec()) { // If all of the shares were migrated, the original lock should be deleted _, err := lockupKeeper.GetLockByID(ctx, originalGammLockId) s.Require().Error(err) @@ -952,14 +952,14 @@ func (s *KeeperTestSuite) TestForceUnlockAndExitBalancerPool() { if tc.exitCoinsLengthIsTwo { for _, coin := range exitCoins { // Check that the exit coin is the same amount that we joined with (with one unit rounding down) - s.Require().Equal(0, defaultErrorTolerance.Compare(tokensIn.AmountOf(coin.Denom).ToDec().Mul(tc.percentOfSharesToMigrate).RoundInt(), coin.Amount)) + s.Require().Equal(0, defaultErrorTolerance.Compare(tokensIn.AmountOf(coin.Denom).ToLegacyDec().Mul(tc.percentOfSharesToMigrate).RoundInt(), coin.Amount)) } } }) } } -func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegated, superfluidUndelegating, unlocking, noLock bool, percentOfSharesToMigrate sdk.Dec) (joinPoolAmt sdk.Coins, balancerIntermediaryAcc types.SuperfluidIntermediaryAccount, balancerLock *lockuptypes.PeriodLock, poolCreateAcc, poolJoinAcc sdk.AccAddress, balancerPooId, clPoolId uint64, balancerPoolShareOut sdk.Coin, valAddr sdk.ValAddress) { +func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegated, superfluidUndelegating, unlocking, noLock bool, percentOfSharesToMigrate osmomath.Dec) (joinPoolAmt sdk.Coins, balancerIntermediaryAcc types.SuperfluidIntermediaryAccount, balancerLock *lockuptypes.PeriodLock, poolCreateAcc, poolJoinAcc sdk.AccAddress, balancerPooId, clPoolId uint64, balancerPoolShareOut sdk.Coin, valAddr sdk.ValAddress) { bankKeeper := s.App.BankKeeper gammKeeper := s.App.GAMMKeeper superfluidKeeper := s.App.SuperfluidKeeper @@ -985,8 +985,8 @@ func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegate // Create a balancer pool of "stake" and "foo". msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) balancerPooId, err := poolmanagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) @@ -1015,7 +1015,7 @@ func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegate balancerPoolShareOut = bankKeeper.GetBalance(ctx, poolJoinAcc, balancerPoolDenom) // Create a cl pool with the same underlying assets as the balancer pool. - clPool := s.PrepareCustomConcentratedPool(poolCreateAcc, defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, sdk.ZeroDec()) + clPool := s.PrepareCustomConcentratedPool(poolCreateAcc, defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, osmomath.ZeroDec()) clPoolId = clPool.GetId() // Add a gov sanctioned link between the balancer and concentrated liquidity pool. @@ -1084,19 +1084,19 @@ func (s *KeeperTestSuite) SetupMigrationTest(ctx sdk.Context, superfluidDelegate return joinPoolAmt, balancerIntermediaryAcc, balancerLock, poolCreateAcc, poolJoinAcc, balancerPooId, clPoolId, balancerPoolShareOut, valAddr } -func (s *KeeperTestSuite) SlashAndValidateResult(ctx sdk.Context, gammLockId, concentratedLockId, poolIdEntering uint64, percentOfSharesToMigrate sdk.Dec, valAddr sdk.ValAddress, balancerLock lockuptypes.PeriodLock, expectSlash bool) { +func (s *KeeperTestSuite) SlashAndValidateResult(ctx sdk.Context, gammLockId, concentratedLockId, poolIdEntering uint64, percentOfSharesToMigrate osmomath.Dec, valAddr sdk.ValAddress, balancerLock lockuptypes.PeriodLock, expectSlash bool) { // Retrieve the concentrated lock and gamm lock prior to slashing. concentratedLockPreSlash, err := s.App.LockupKeeper.GetLockByID(ctx, concentratedLockId) s.Require().NoError(err) gammLockPreSlash, err := s.App.LockupKeeper.GetLockByID(ctx, gammLockId) - if percentOfSharesToMigrate.LT(sdk.OneDec()) { + if percentOfSharesToMigrate.LT(osmomath.OneDec()) { s.Require().NoError(err) } else { s.Require().Error(err) } // Slash the validator. - slashFactor := sdk.NewDecWithPrec(5, 2) + slashFactor := osmomath.NewDecWithPrec(5, 2) s.App.SuperfluidKeeper.SlashLockupsForValidatorSlash( ctx, valAddr, @@ -1107,7 +1107,7 @@ func (s *KeeperTestSuite) SlashAndValidateResult(ctx sdk.Context, gammLockId, co concentratedLockPostSlash, err := s.App.LockupKeeper.GetLockByID(ctx, concentratedLockId) s.Require().NoError(err) gammLockPostSlash, err := s.App.LockupKeeper.GetLockByID(ctx, gammLockId) - if percentOfSharesToMigrate.LT(sdk.OneDec()) { + if percentOfSharesToMigrate.LT(osmomath.OneDec()) { s.Require().NoError(err) } else { s.Require().Error(err) @@ -1115,20 +1115,20 @@ func (s *KeeperTestSuite) SlashAndValidateResult(ctx sdk.Context, gammLockId, co // Check if the concentrated lock was slashed. clDenom := cltypes.GetConcentratedLockupDenomFromPoolId(poolIdEntering) - slashAmtCL := concentratedLockPreSlash.Coins.AmountOf(clDenom).ToDec().Mul(slashFactor).TruncateInt() + slashAmtCL := concentratedLockPreSlash.Coins.AmountOf(clDenom).ToLegacyDec().Mul(slashFactor).TruncateInt() if !expectSlash { - slashAmtCL = sdk.ZeroInt() + slashAmtCL = osmomath.ZeroInt() } s.Require().Equal(concentratedLockPreSlash.Coins.AmountOf(clDenom).Sub(slashAmtCL).String(), concentratedLockPostSlash.Coins.AmountOf(clDenom).String()) // Check if the gamm lock was slashed. // We only check if the gamm lock was slashed if the lock was not migrated entirely. // Otherwise, there would be no newly created gamm lock to check. - if percentOfSharesToMigrate.LT(sdk.OneDec()) { + if percentOfSharesToMigrate.LT(osmomath.OneDec()) { gammDenom := balancerLock.Coins[0].Denom - slashAmtGamm := gammLockPreSlash.Coins.AmountOf(gammDenom).ToDec().Mul(slashFactor).TruncateInt() + slashAmtGamm := gammLockPreSlash.Coins.AmountOf(gammDenom).ToLegacyDec().Mul(slashFactor).TruncateInt() if !expectSlash { - slashAmtGamm = sdk.ZeroInt() + slashAmtGamm = osmomath.ZeroInt() } s.Require().Equal(gammLockPreSlash.Coins.AmountOf(gammDenom).Sub(slashAmtGamm).String(), gammLockPostSlash.Coins.AmountOf(gammDenom).String()) } @@ -1138,11 +1138,11 @@ func (s *KeeperTestSuite) SlashAndValidateResult(ctx sdk.Context, gammLockId, co func (s *KeeperTestSuite) ValidateMigrateResult( positionId, balancerPooId, poolIdLeaving, clPoolId, poolIdEntering uint64, - percentOfSharesToMigrate, liquidityMigrated sdk.Dec, + percentOfSharesToMigrate, liquidityMigrated osmomath.Dec, balancerLock lockuptypes.PeriodLock, joinPoolAmt sdk.Coins, balancerPoolShareOut, coinsToMigrate sdk.Coin, - amount0, amount1 sdk.Int, + amount0, amount1 osmomath.Int, ) { // Check that the concentrated liquidity and join time match what we expect position, err := s.App.ConcentratedLiquidityKeeper.GetPosition(s.Ctx, positionId) @@ -1158,11 +1158,11 @@ func (s *KeeperTestSuite) ValidateMigrateResult( // exitPool has rounding difference. // We test if correct amt has been exited and frozen by comparing with rounding tolerance. defaultErrorTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.NewDec(2), + AdditiveTolerance: osmomath.NewDec(2), RoundingDir: osmomath.RoundDown, } - s.Require().Equal(0, defaultErrorTolerance.Compare(joinPoolAmt.AmountOf(defaultPoolAssets[0].Token.Denom).ToDec().Mul(percentOfSharesToMigrate).RoundInt(), amount0)) - s.Require().Equal(0, defaultErrorTolerance.Compare(joinPoolAmt.AmountOf(defaultPoolAssets[1].Token.Denom).ToDec().Mul(percentOfSharesToMigrate).RoundInt(), amount1)) + s.Require().Equal(0, defaultErrorTolerance.Compare(joinPoolAmt.AmountOf(defaultPoolAssets[0].Token.Denom).ToLegacyDec().Mul(percentOfSharesToMigrate).RoundInt(), amount0)) + s.Require().Equal(0, defaultErrorTolerance.Compare(joinPoolAmt.AmountOf(defaultPoolAssets[1].Token.Denom).ToLegacyDec().Mul(percentOfSharesToMigrate).RoundInt(), amount1)) } type Positions struct { @@ -1178,7 +1178,7 @@ type Positions struct { type positionInfo struct { joinPoolCoins sdk.Coins coin sdk.Coin - shares sdk.Int + shares osmomath.Int lockId uint64 } @@ -1314,7 +1314,7 @@ func (s *KeeperTestSuite) TestFunctional_VaryingPositions_Migrations() { s.Require().NoError(err) balancerSpotPrice, err := balancerPool.SpotPrice(s.Ctx, DefaultCoin1.Denom, DefaultCoin0.Denom) s.Require().NoError(err) - s.CreateFullRangePosition(clPool, sdk.NewCoins(sdk.NewCoin(DefaultCoin0.Denom, sdk.NewInt(100000000)), sdk.NewCoin(DefaultCoin1.Denom, sdk.NewDec(100000000).Mul(balancerSpotPrice).TruncateInt()))) + s.CreateFullRangePosition(clPool, sdk.NewCoins(sdk.NewCoin(DefaultCoin0.Denom, osmomath.NewInt(100000000)), sdk.NewCoin(DefaultCoin1.Denom, osmomath.NewDec(100000000).Mul(balancerSpotPrice).TruncateInt()))) // Add a gov sanctioned link between the balancer and concentrated liquidity pool. migrationRecord := gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ @@ -1331,14 +1331,14 @@ func (s *KeeperTestSuite) TestFunctional_VaryingPositions_Migrations() { s.Require().NoError(err) // All the following values will be tracked as we migrate each position. We will check them against the invariants at the end. - totalAmount0Migrated := sdk.ZeroInt() - totalAmount1Migrated := sdk.ZeroInt() - totalSentBackToOwnersAmount0 := sdk.ZeroInt() - totalSentBackToOwnersAmount1 := sdk.ZeroInt() - totalBalancerPoolFundsLeftBehindAmount0 := sdk.ZeroInt() - totalBalancerPoolFundsLeftBehindAmount1 := sdk.ZeroInt() - amount0AccountFor := sdk.ZeroInt() - amount1AccountFor := sdk.ZeroInt() + totalAmount0Migrated := osmomath.ZeroInt() + totalAmount1Migrated := osmomath.ZeroInt() + totalSentBackToOwnersAmount0 := osmomath.ZeroInt() + totalSentBackToOwnersAmount1 := osmomath.ZeroInt() + totalBalancerPoolFundsLeftBehindAmount0 := osmomath.ZeroInt() + totalBalancerPoolFundsLeftBehindAmount1 := osmomath.ZeroInt() + amount0AccountFor := osmomath.ZeroInt() + amount1AccountFor := osmomath.ZeroInt() // Migrate all the positions. // We will check certain invariants after each individual migration. @@ -1404,7 +1404,7 @@ func (s *KeeperTestSuite) TestFunctional_VaryingPositions_Migrations() { // // The function returns a `positionInfo` struct with the created position's information. func (s *KeeperTestSuite) createBalancerPosition(acc sdk.AccAddress, balancerPoolId uint64, unbondingDuration time.Duration, balancerPoolShareDenom string, coins sdk.Coins, i int, superfluidDelegate bool) positionInfo { - sharesOut, err := s.App.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, acc, balancerPoolId, coins, sdk.OneInt()) + sharesOut, err := s.App.GAMMKeeper.JoinSwapExactAmountIn(s.Ctx, acc, balancerPoolId, coins, osmomath.OneInt()) s.Require().NoError(err) shareCoins := sdk.NewCoins(sdk.NewCoin(balancerPoolShareDenom, sharesOut)) diff --git a/x/superfluid/keeper/msg_server_test.go b/x/superfluid/keeper/msg_server_test.go index 045c887f3b1..60c21c6bef0 100644 --- a/x/superfluid/keeper/msg_server_test.go +++ b/x/superfluid/keeper/msg_server_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" v8constants "github.com/osmosis-labs/osmosis/v19/app/upgrades/v8/constants" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" @@ -17,7 +18,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" ) -var defaultFunds = sdk.NewCoins(defaultPoolAssets[0].Token, sdk.NewCoin("stake", sdk.NewInt(5000000000))) +var defaultFunds = sdk.NewCoins(defaultPoolAssets[0].Token, sdk.NewCoin("stake", osmomath.NewInt(5000000000))) func (s *KeeperTestSuite) TestMsgSuperfluidDelegate() { type param struct { @@ -64,11 +65,11 @@ func (s *KeeperTestSuite) TestMsgSuperfluidDelegate() { lockupMsgServer := lockupkeeper.NewMsgServerImpl(s.App.LockupKeeper) c := sdk.WrapSDKContext(s.Ctx) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // If there is no coinsToLock in the param, use pool denom if test.param.coinsToLock.Empty() { - test.param.coinsToLock = sdk.NewCoins(sdk.NewCoin(denoms[0], sdk.NewInt(20))) + test.param.coinsToLock = sdk.NewCoins(sdk.NewCoin(denoms[0], osmomath.NewInt(20))) } s.FundAcc(test.param.lockOwner, test.param.coinsToLock) resp, err := lockupMsgServer.LockTokens(c, lockuptypes.NewMsgLockTokens(test.param.lockOwner, test.param.duration, test.param.coinsToLock)) @@ -386,7 +387,7 @@ func (s *KeeperTestSuite) TestMsgSuperfluidUndelegate_Event() { // setup validators valAddrs := s.SetupValidators(test.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20)}) // setup superfluid delegations s.setupSuperfluidDelegations(valAddrs, test.superDelegations, denoms) @@ -419,7 +420,7 @@ func (s *KeeperTestSuite) TestMsgSuperfluidUnbondLock_Event() { // setup validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, _, locks := s.setupSuperfluidDelegations(valAddrs, []superfluidDelegation{{0, 0, 0, 1000000}}, denoms) @@ -454,7 +455,7 @@ func (s *KeeperTestSuite) TestMsgUnPoolWhitelistedPool_Event() { // setup validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) - denoms, poolIds := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20)}) + denoms, poolIds := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20)}) // whitelist designated pools s.App.SuperfluidKeeper.SetUnpoolAllowedPools(s.Ctx, poolIds) @@ -483,8 +484,8 @@ func (s *KeeperTestSuite) TestUnlockAndMigrateSharesToFullRangeConcentratedPosit // Set balancer pool (foo and stake) and make its respective gamm share an authorized superfluid asset msg := balancer.NewMsgCreateBalancerPool(s.TestAccs[0], balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) balancerPooId, err := s.App.PoolManagerKeeper.CreatePool(s.Ctx, msg) s.Require().NoError(err) @@ -498,7 +499,7 @@ func (s *KeeperTestSuite) TestUnlockAndMigrateSharesToFullRangeConcentratedPosit s.Require().NoError(err) // Set concentrated pool with the same denoms as the balancer pool (foo and stake) - clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, sdk.ZeroDec()) + clPool := s.PrepareCustomConcentratedPool(s.TestAccs[0], defaultPoolAssets[0].Token.Denom, defaultPoolAssets[1].Token.Denom, 1, osmomath.ZeroDec()) // Set migration link between the balancer and concentrated pool migrationRecord := gammmigration.MigrationRecords{BalancerToConcentratedPoolLinks: []gammmigration.BalancerToConcentratedPoolLink{ diff --git a/x/superfluid/keeper/slash.go b/x/superfluid/keeper/slash.go index db58fd34359..c338b7bbbe8 100644 --- a/x/superfluid/keeper/slash.go +++ b/x/superfluid/keeper/slash.go @@ -5,6 +5,7 @@ import ( "strings" "time" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" cl "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" @@ -19,7 +20,7 @@ import ( // Furthermore, if the infraction height is sufficiently old, slashes unbondings // Note: Based on sdk.staking.Slash function review, slashed tokens are burnt not sent to community pool // we ignore that, and send the underliyng tokens to the community pool anyway. -func (k Keeper) SlashLockupsForValidatorSlash(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor sdk.Dec) { +func (k Keeper) SlashLockupsForValidatorSlash(ctx sdk.Context, valAddr sdk.ValAddress, infractionHeight int64, slashFactor osmomath.Dec) { // Important note: The SDK slashing for historical heights is wrong. // It defines a "slash amount" off of the live staked amount. // Then it charges all the unbondings & redelegations at the slash factor. @@ -60,10 +61,10 @@ func (k Keeper) SlashLockupsForValidatorSlash(ctx sdk.Context, valAddr sdk.ValAd } } -func (k Keeper) slashSynthLock(ctx sdk.Context, synthLock *lockuptypes.SyntheticLock, slashFactor sdk.Dec) { +func (k Keeper) slashSynthLock(ctx sdk.Context, synthLock *lockuptypes.SyntheticLock, slashFactor osmomath.Dec) { // Only single token lock is allowed here lock, _ := k.lk.GetLockByID(ctx, synthLock.UnderlyingLockId) - slashAmt := lock.Coins[0].Amount.ToDec().Mul(slashFactor) + slashAmt := lock.Coins[0].Amount.ToLegacyDec().Mul(slashFactor) lockSharesToSlash := sdk.NewCoins(sdk.NewCoin(lock.Coins[0].Denom, slashAmt.TruncateInt())) // If the slashCoins contains a cl denom, we need to update the underlying cl position to reflect the slash. @@ -92,7 +93,7 @@ func (k Keeper) slashSynthLock(ctx sdk.Context, synthLock *lockuptypes.Synthetic // 1. Figures out the underlying assets from the liquidity being slashed and creates a coin object this represents // 2. Sets the cl position's liquidity state entry to reflect the slash // 3. Returns the pool address that will send the underlying coins as well as the underlying coins to slash -func (k Keeper) prepareConcentratedLockForSlash(ctx sdk.Context, lock *lockuptypes.PeriodLock, slashAmt sdk.Dec) (sdk.AccAddress, sdk.Coins, error) { +func (k Keeper) prepareConcentratedLockForSlash(ctx sdk.Context, lock *lockuptypes.PeriodLock, slashAmt osmomath.Dec) (sdk.AccAddress, sdk.Coins, error) { // Ensure lock is a single coin lock if len(lock.Coins) != 1 { return sdk.AccAddress{}, sdk.Coins{}, fmt.Errorf("lock must be a single coin lock, got %s", lock.Coins) diff --git a/x/superfluid/keeper/slash_test.go b/x/superfluid/keeper/slash_test.go index b0a3a8fffc8..67e9497003e 100644 --- a/x/superfluid/keeper/slash_test.go +++ b/x/superfluid/keeper/slash_test.go @@ -60,10 +60,10 @@ func (s *KeeperTestSuite) TestBeforeValidatorSlashed() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) locks := []lockuptypes.PeriodLock{} - slashFactor := sdk.NewDecWithPrec(5, 2) + slashFactor := osmomath.NewDecWithPrec(5, 2) // setup superfluid delegations for _, del := range tc.superDelegations { @@ -105,7 +105,7 @@ func (s *KeeperTestSuite) TestBeforeValidatorSlashed() { s.Require().NoError(err) s.Require().Equal( gotLock.Coins.AmountOf(denoms[0]).String(), - sdk.NewDec(1000000).Mul(sdk.OneDec().Sub(slashFactor)).TruncateInt().String(), + osmomath.NewDec(1000000).Mul(osmomath.OneDec().Sub(slashFactor)).TruncateInt().String(), ) } }) @@ -166,7 +166,7 @@ func (s *KeeperTestSuite) TestSlashLockupsForUnbondingDelegationSlash() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, _ := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -181,7 +181,7 @@ func (s *KeeperTestSuite) TestSlashLockupsForUnbondingDelegationSlash() { } // slash unbonding lockups for all intermediary accounts - slashFactor := sdk.NewDecWithPrec(5, 2) + slashFactor := osmomath.NewDecWithPrec(5, 2) for i := 0; i < len(valAddrs); i++ { s.App.SuperfluidKeeper.SlashLockupsForValidatorSlash( s.Ctx, @@ -198,7 +198,7 @@ func (s *KeeperTestSuite) TestSlashLockupsForUnbondingDelegationSlash() { for _, lockId := range tc.superUnbondingLockIds { gotLock, err := s.App.LockupKeeper.GetLockByID(s.Ctx, lockId) s.Require().NoError(err) - s.Require().Equal(gotLock.Coins[0].Amount.String(), sdk.NewInt(950000).String()) + s.Require().Equal(gotLock.Coins[0].Amount.String(), osmomath.NewInt(950000).String()) } }) } @@ -207,29 +207,29 @@ func (s *KeeperTestSuite) TestSlashLockupsForUnbondingDelegationSlash() { func (s *KeeperTestSuite) TestPrepareConcentratedLockForSlash() { type prepareConcentratedLockTestCase struct { name string - slashPercent sdk.Dec + slashPercent osmomath.Dec expectedErr bool } testCases := []prepareConcentratedLockTestCase{ { name: "SmallSlash", - slashPercent: sdk.MustNewDecFromStr("0.001"), + slashPercent: osmomath.MustNewDecFromStr("0.001"), expectedErr: false, }, { name: "FullSlash", - slashPercent: sdk.MustNewDecFromStr("1"), + slashPercent: osmomath.MustNewDecFromStr("1"), expectedErr: false, }, { name: "HalfSlash", - slashPercent: sdk.MustNewDecFromStr("0.5"), + slashPercent: osmomath.MustNewDecFromStr("0.5"), expectedErr: false, }, { name: "OverSlash", - slashPercent: sdk.MustNewDecFromStr("1.001"), + slashPercent: osmomath.MustNewDecFromStr("1.001"), expectedErr: true, }, } @@ -272,7 +272,7 @@ func (s *KeeperTestSuite) TestPrepareConcentratedLockForSlash() { uptimeAccums, err := s.App.ConcentratedLiquidityKeeper.GetUptimeAccumulators(s.Ctx, clPoolId) uptimePositionKey := string(cltypes.KeyPositionId(positionId)) s.Require().NoError(err) - numShares := make([]sdk.Dec, len(uptimeAccums)) + numShares := make([]osmomath.Dec, len(uptimeAccums)) for i, uptimeAccum := range uptimeAccums { position, err := accum.GetPosition(uptimeAccum, uptimePositionKey) s.Require().NoError(err) @@ -328,7 +328,7 @@ func (s *KeeperTestSuite) TestPrepareConcentratedLockForSlash() { s.Require().NoError(err) errTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.NewDec(1), + AdditiveTolerance: osmomath.NewDec(1), // Actual should be greater than expected, so we round up RoundingDir: osmomath.RoundUp, } diff --git a/x/superfluid/keeper/stake.go b/x/superfluid/keeper/stake.go index 8fc7b24622c..66b23336c2e 100644 --- a/x/superfluid/keeper/stake.go +++ b/x/superfluid/keeper/stake.go @@ -6,6 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -17,7 +18,7 @@ import ( ) // GetTotalSyntheticAssetsLocked returns the total amount of the given denom locked. -func (k Keeper) GetTotalSyntheticAssetsLocked(ctx sdk.Context, denom string) sdk.Int { +func (k Keeper) GetTotalSyntheticAssetsLocked(ctx sdk.Context, denom string) osmomath.Int { return k.lk.GetPeriodLocksAccumulation(ctx, lockuptypes.QueryCondition{ LockQueryType: lockuptypes.ByDuration, Denom: denom, @@ -29,14 +30,14 @@ func (k Keeper) GetTotalSyntheticAssetsLocked(ctx sdk.Context, denom string) sdk // has delegated using the most recent osmo equivalent multiplier. // This is labeled as expected because the way it calculates the amount can // lead rounding errors from the true delegated amount. -func (k Keeper) GetExpectedDelegationAmount(ctx sdk.Context, acc types.SuperfluidIntermediaryAccount) (sdk.Int, error) { +func (k Keeper) GetExpectedDelegationAmount(ctx sdk.Context, acc types.SuperfluidIntermediaryAccount) (osmomath.Int, error) { // (1) Find how many tokens total T are locked for (denom, validator) pair totalSuperfluidDelegation := k.GetTotalSyntheticAssetsLocked(ctx, stakingSyntheticDenom(acc.Denom, acc.ValAddr)) // (2) Multiply the T tokens, by the number of superfluid osmo per token, to get the total amount // of osmo we expect. refreshedAmount, err := k.GetSuperfluidOSMOTokens(ctx, acc.Denom, totalSuperfluidDelegation) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return refreshedAmount, nil } @@ -61,7 +62,7 @@ func (k Keeper) RefreshIntermediaryDelegationAmounts(ctx sdk.Context) { continue } - currentAmount := sdk.NewInt(0) + currentAmount := osmomath.NewInt(0) delegation, found := k.sk.GetDelegation(ctx, mAddr, valAddress) if !found { // continue if current delegation is 0, in case its really a dust delegation @@ -324,7 +325,7 @@ func (k Keeper) SuperfluidUnbondLock(ctx sdk.Context, underlyingLockId uint64, s // This method returns the lock id, same lock id if unlock amount is equal to the // underlying lock amount. Otherwise it returns the newly created lock id. // Note that we can either partially or fully undelegate and unbond lock using this method. -func (k Keeper) SuperfluidUndelegateAndUnbondLock(ctx sdk.Context, lockID uint64, sender string, amount sdk.Int) (uint64, error) { +func (k Keeper) SuperfluidUndelegateAndUnbondLock(ctx sdk.Context, lockID uint64, sender string, amount osmomath.Int) (uint64, error) { lock, err := k.lk.GetLockByID(ctx, lockID) if err != nil { return 0, err @@ -446,7 +447,7 @@ func (k Keeper) alreadySuperfluidStaking(ctx sdk.Context, lockID uint64) bool { } // mintOsmoTokensAndDelegate mints osmoAmount of OSMO tokens, and immediately delegate them to validator on behalf of intermediary account. -func (k Keeper) mintOsmoTokensAndDelegate(ctx sdk.Context, osmoAmount sdk.Int, intermediaryAccount types.SuperfluidIntermediaryAccount) error { +func (k Keeper) mintOsmoTokensAndDelegate(ctx sdk.Context, osmoAmount osmomath.Int, intermediaryAccount types.SuperfluidIntermediaryAccount) error { validator, err := k.validateValAddrForDelegate(ctx, intermediaryAccount.ValAddr) if err != nil { return err @@ -480,7 +481,7 @@ func (k Keeper) mintOsmoTokensAndDelegate(ctx sdk.Context, osmoAmount sdk.Int, i // from delegations between intermediary account and valAddr. // We take the returned tokens, and then immediately burn them. func (k Keeper) forceUndelegateAndBurnOsmoTokens(ctx sdk.Context, - osmoAmount sdk.Int, intermediaryAcc types.SuperfluidIntermediaryAccount, + osmoAmount osmomath.Int, intermediaryAcc types.SuperfluidIntermediaryAccount, ) error { valAddr, err := sdk.ValAddressFromBech32(intermediaryAcc.ValAddr) if err != nil { @@ -533,7 +534,7 @@ func (k Keeper) IterateBondedValidatorsByPower(ctx sdk.Context, fn func(int64, s } // TotalBondedTokens implements govtypes.StakingKeeper -func (k Keeper) TotalBondedTokens(ctx sdk.Context) sdk.Int { +func (k Keeper) TotalBondedTokens(ctx sdk.Context) osmomath.Int { return k.sk.TotalBondedTokens(ctx) } @@ -614,23 +615,23 @@ func (k Keeper) IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn // - If valAddr not provided and valset delegation is not possible, refer back to original lock's superfluid validator if it was a superfluid lock // - Else: error func (k Keeper) UnbondConvertAndStake(ctx sdk.Context, lockID uint64, sender, valAddr string, - minAmtToStake sdk.Int, sharesToConvert sdk.Coin) (totalAmtConverted sdk.Int, err error) { + minAmtToStake osmomath.Int, sharesToConvert sdk.Coin) (totalAmtConverted osmomath.Int, err error) { senderAddr, err := sdk.AccAddressFromBech32(sender) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // use getMigrationType method to check status of lock (either superfluid staked, superfluid unbonding, vanilla locked, unlocked) _, migrationType, err := k.getMigrationType(ctx, int64(lockID)) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // if superfluid bonded, first change it into superfluid undelegate to burn minted osmo and instantly undelegate. if migrationType == SuperfluidBonded { _, err = k.undelegateCommon(ctx, sender, lockID) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } } @@ -639,11 +640,11 @@ func (k Keeper) UnbondConvertAndStake(ctx sdk.Context, lockID uint64, sender, va } else if migrationType == Unlocked { // liquid gamm shares without locks totalAmtConverted, err = k.convertUnlockedToStake(ctx, senderAddr, valAddr, sharesToConvert, minAmtToStake) } else { // any other types of migration should fail - return sdk.Int{}, fmt.Errorf("unsupported staking conversion type") + return osmomath.Int{}, fmt.Errorf("unsupported staking conversion type") } if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return totalAmtConverted, nil @@ -652,15 +653,15 @@ func (k Keeper) UnbondConvertAndStake(ctx sdk.Context, lockID uint64, sender, va // convertLockToStake handles locks that are superfluid bonded, superfluid unbonding, vanilla locked(unlocking) locks. // Deletes all associated state, converts the lock itself to staking delegation by going through exit pool and swap. func (k Keeper) convertLockToStake(ctx sdk.Context, sender sdk.AccAddress, valAddr string, lockId uint64, - minAmtToStake sdk.Int) (totalAmtConverted sdk.Int, err error) { + minAmtToStake osmomath.Int) (totalAmtConverted osmomath.Int, err error) { lock, err := k.lk.GetLockByID(ctx, lockId) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // check lock owner is sender if lock.Owner != sender.String() { - return sdk.ZeroInt(), types.LockOwnerMismatchError{ + return osmomath.ZeroInt(), types.LockOwnerMismatchError{ LockId: lock.ID, LockOwner: lock.Owner, ProvidedOwner: sender.String(), @@ -671,12 +672,12 @@ func (k Keeper) convertLockToStake(ctx sdk.Context, sender sdk.AccAddress, valAd // Ensuring the sharesToMigrate contains gamm pool share prefix. if !strings.HasPrefix(lockCoin.Denom, gammtypes.GAMMTokenPrefix) { - return sdk.Int{}, types.SharesToMigrateDenomPrefixError{Denom: lockCoin.Denom, ExpectedDenomPrefix: gammtypes.GAMMTokenPrefix} + return osmomath.Int{}, types.SharesToMigrateDenomPrefixError{Denom: lockCoin.Denom, ExpectedDenomPrefix: gammtypes.GAMMTokenPrefix} } poolIdLeaving, err := gammtypes.GetPoolIdFromShareDenom(lockCoin.Denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } var superfluidValAddr string @@ -689,12 +690,12 @@ func (k Keeper) convertLockToStake(ctx sdk.Context, sender sdk.AccAddress, valAd // we exit with min token out amount zero since we are checking min amount designated to stake later on anyways. exitCoins, err := k.forceUnlockAndExitBalancerPool(ctx, sender, poolIdLeaving, lock, lockCoin, sdk.NewCoins(), false) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalAmtConverted, err = k.convertGammSharesToOsmoAndStake(ctx, sender, valAddr, poolIdLeaving, exitCoins, minAmtToStake, superfluidValAddr) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return totalAmtConverted, nil @@ -703,27 +704,27 @@ func (k Keeper) convertLockToStake(ctx sdk.Context, sender sdk.AccAddress, valAd // convertUnlockedToStake converts liquid gamm shares to staking delegation. // minAmtToStake works as slippage bound for the conversion process. func (k Keeper) convertUnlockedToStake(ctx sdk.Context, sender sdk.AccAddress, valAddr string, sharesToStake sdk.Coin, - minAmtToStake sdk.Int) (totalAmtConverted sdk.Int, err error) { + minAmtToStake osmomath.Int) (totalAmtConverted osmomath.Int, err error) { if !strings.HasPrefix(sharesToStake.Denom, gammtypes.GAMMTokenPrefix) { - return sdk.Int{}, types.SharesToMigrateDenomPrefixError{Denom: sharesToStake.Denom, ExpectedDenomPrefix: gammtypes.GAMMTokenPrefix} + return osmomath.Int{}, types.SharesToMigrateDenomPrefixError{Denom: sharesToStake.Denom, ExpectedDenomPrefix: gammtypes.GAMMTokenPrefix} } // Get the balancer poolId by parsing the gamm share denom. poolIdLeaving, err := gammtypes.GetPoolIdFromShareDenom(sharesToStake.Denom) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } // Exit the balancer pool position. // we exit with min token out amount zero since we are checking min amount designated to stake later on anyways. exitCoins, err := k.gk.ExitPool(ctx, sender, poolIdLeaving, sharesToStake.Amount, sdk.NewCoins()) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalAmtConverted, err = k.convertGammSharesToOsmoAndStake(ctx, sender, valAddr, poolIdLeaving, exitCoins, minAmtToStake, "") if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return totalAmtConverted, nil @@ -737,8 +738,8 @@ func (k Keeper) convertUnlockedToStake(ctx sdk.Context, sender sdk.AccAddress, v func (k Keeper) convertGammSharesToOsmoAndStake( ctx sdk.Context, sender sdk.AccAddress, valAddr string, - poolIdLeaving uint64, exitCoins sdk.Coins, minAmtToStake sdk.Int, originalSuperfluidValAddr string, -) (totalAmtCoverted sdk.Int, err error) { + poolIdLeaving uint64, exitCoins sdk.Coins, minAmtToStake osmomath.Int, originalSuperfluidValAddr string, +) (totalAmtCoverted osmomath.Int, err error) { var nonOsmoCoins sdk.Coins bondDenom := k.sk.BondDenom(ctx) @@ -752,13 +753,13 @@ func (k Keeper) convertGammSharesToOsmoAndStake( originalBondDenomAmt := exitCoins.AmountOf(bondDenom) // track how much non-uosmo tokens we have converted to uosmo - totalAmtCoverted = sdk.ZeroInt() + totalAmtCoverted = osmomath.ZeroInt() // iterate over non-bond denom coins and swap them into bond denom for _, coinToConvert := range nonOsmoCoins { - tokenOutAmt, err := k.pmk.SwapExactAmountIn(ctx, sender, poolIdLeaving, coinToConvert, bondDenom, sdk.ZeroInt()) + tokenOutAmt, err := k.pmk.SwapExactAmountIn(ctx, sender, poolIdLeaving, coinToConvert, bondDenom, osmomath.ZeroInt()) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } totalAmtCoverted = totalAmtCoverted.Add(tokenOutAmt) @@ -769,7 +770,7 @@ func (k Keeper) convertGammSharesToOsmoAndStake( // check if the total amount to stake after all conversion is greater than provided min amount to stake if totalAmtToStake.LT(minAmtToStake) { - return sdk.Int{}, types.TokenConvertedLessThenDesiredStakeError{ + return osmomath.Int{}, types.TokenConvertedLessThenDesiredStakeError{ ActualTotalAmtToStake: totalAmtToStake, ExpectedTotalAmtToStake: minAmtToStake, } @@ -777,7 +778,7 @@ func (k Keeper) convertGammSharesToOsmoAndStake( err = k.delegateBaseOnValsetPref(ctx, sender, valAddr, originalSuperfluidValAddr, totalAmtToStake) if err != nil { - return sdk.Int{}, err + return osmomath.Int{}, err } return totalAmtToStake, nil @@ -790,7 +791,7 @@ func (k Keeper) convertGammSharesToOsmoAndStake( // - If valAddr not provided and valset exists, valsetpref.Delegate // - If valAddr not provided and valset delegation is not possible, refer back to original lock's superfluid validator if it was a superfluid lock // - Else: error -func (k Keeper) delegateBaseOnValsetPref(ctx sdk.Context, sender sdk.AccAddress, valAddr, originalSuperfluidValAddr string, totalAmtToStake sdk.Int) error { +func (k Keeper) delegateBaseOnValsetPref(ctx sdk.Context, sender sdk.AccAddress, valAddr, originalSuperfluidValAddr string, totalAmtToStake osmomath.Int) error { bondDenom := k.sk.BondDenom(ctx) // if given valAddr is empty, we use delegation preference given from valset-pref module or reference from superfluid staking diff --git a/x/superfluid/keeper/stake_test.go b/x/superfluid/keeper/stake_test.go index 02a2ce0f377..3b2a69dbd0a 100644 --- a/x/superfluid/keeper/stake_test.go +++ b/x/superfluid/keeper/stake_test.go @@ -5,6 +5,7 @@ import ( abci "github.com/tendermint/tendermint/abci/types" + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -30,37 +31,37 @@ func (s *KeeperTestSuite) TestSuperfluidDelegate() { name string validatorStats []stakingtypes.BondStatus superDelegations []superfluidDelegation - expInterDelegation []sdk.Dec + expInterDelegation []osmomath.Dec }{ { "with single validator and single superfluid delegation", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, { "with single validator and additional superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(20000000)}, // 50% x 20 x 1000000 x 2 + []osmomath.Dec{osmomath.NewDec(20000000)}, // 50% x 20 x 1000000 x 2 }, { "with multiple validators and multiple superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000), sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000), osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, { "add unbonding validator", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Unbonding}, []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000), sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000), osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, { "add unbonded validator", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Unbonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, - []sdk.Dec{sdk.NewDec(10000000), sdk.NewDec(10000000)}, // 50% x 20 x 1000000 + []osmomath.Dec{osmomath.NewDec(10000000), osmomath.NewDec(10000000)}, // 50% x 20 x 1000000 }, } @@ -73,7 +74,7 @@ func (s *KeeperTestSuite) TestSuperfluidDelegate() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // get pre-superfluid delgations osmo supply and supplyWithOffset presupply := s.App.BankKeeper.GetSupply(s.Ctx, bondDenom) @@ -169,7 +170,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "valid gamm lock", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, osmomath.NewInt(100))), Duration: time.Hour * 24 * 21, ID: 1, }, @@ -180,7 +181,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "valid cl lock", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin(cltypes.GetConcentratedLockupDenomFromPoolId(1), osmomath.NewInt(100))), Duration: time.Hour * 24 * 21, ID: 1, }, @@ -191,7 +192,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "invalid lock - not superfluid asset", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(100))), Duration: time.Hour * 24 * 21, ID: 1, }, @@ -202,7 +203,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "invalid lock - unbonding lockup not supported", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, osmomath.NewInt(100))), Duration: time.Hour * 24 * 21, ID: 1, EndTime: time.Now().Add(time.Hour * 24), @@ -214,7 +215,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "invalid lock - not enough lockup duration", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, osmomath.NewInt(100))), Duration: time.Hour * 24, ID: 1, }, @@ -227,7 +228,7 @@ func (s *KeeperTestSuite) TestValidateLockForSFDelegate() { name: "invalid lock - already used superfluid lockup", lock: &lockuptypes.PeriodLock{ Owner: lockOwner.String(), - Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, sdk.NewInt(100))), + Coins: sdk.NewCoins(sdk.NewCoin(DefaultGammAsset, osmomath.NewInt(100))), Duration: time.Hour * 24 * 21, ID: 1, }, @@ -267,7 +268,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { superUnbondingLockIds []uint64 expSuperUnbondingErr []bool // expected amount of delegation to intermediary account - expInterDelegation []sdk.Dec + expInterDelegation []osmomath.Dec }{ { "with single validator and single superfluid delegation and single undelegation", @@ -275,7 +276,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{1}, []bool{false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, // { // "with single validator, single superfluid delegation, add more tokens to the lock, and single undelegation", @@ -284,7 +285,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { // []uint64{1}, // []uint64{1}, // []bool{false}, - // []sdk.Dec{sdk.ZeroDec()}, + // []osmomath.Dec{osmomath.ZeroDec()}, // }, { "with single validator and additional superfluid delegations and single undelegation", @@ -292,7 +293,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 0, 1000000}}, []uint64{1}, []bool{false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "with multiple validators and multiple superfluid delegations and multiple undelegations", @@ -300,7 +301,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "add unbonding validator", @@ -308,7 +309,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "add unbonded validator", @@ -316,7 +317,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "undelegating not available lock id", @@ -324,7 +325,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{2}, []bool{true}, - []sdk.Dec{}, + []osmomath.Dec{}, }, { "try undelegating twice for same lock id", @@ -332,7 +333,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{1, 1}, []bool{false, true}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, } @@ -346,7 +347,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegate() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, _ := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -440,7 +441,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { superUnbondingLockIds []uint64 expSuperUnbondingErr []bool // expected amount of delegation to intermediary account - expInterDelegation []sdk.Dec + expInterDelegation []osmomath.Dec }{ { "with single validator and single superfluid delegation and single undelegation", @@ -448,7 +449,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{1}, []bool{false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "with single validator and additional superfluid delegations and single undelegation", @@ -456,7 +457,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 0, 1000000}}, []uint64{1}, []bool{false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "with multiple validators and multiple superfluid delegations and multiple undelegations", @@ -464,7 +465,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "add unbonding validator", @@ -472,7 +473,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "add unbonded validator", @@ -480,7 +481,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, []uint64{1, 2}, []bool{false, false}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, { "undelegating not available lock id", @@ -488,7 +489,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{2}, []bool{true}, - []sdk.Dec{}, + []osmomath.Dec{}, }, { "try undelegating twice for same lock id", @@ -496,7 +497,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { []superfluidDelegation{{0, 0, 0, 1000000}}, []uint64{1, 1}, []bool{false, true}, - []sdk.Dec{sdk.ZeroDec()}, + []osmomath.Dec{osmomath.ZeroDec()}, }, } @@ -510,7 +511,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateToConcentratedPosition() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, _ := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -605,7 +606,7 @@ func (s *KeeperTestSuite) TestSuperfluidUnbondLock() { // setup validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, []superfluidDelegation{{0, 0, 0, 1000000}}, denoms) @@ -673,7 +674,7 @@ func (s *KeeperTestSuite) TestSuperfluidUnbondLock() { balances = s.App.BankKeeper.GetAllBalances(s.Ctx, lock.OwnerAddress()) s.Require().Equal(1, balances.Len()) s.Require().Equal(denoms[0], balances[0].Denom) - s.Require().Equal(sdk.NewInt(1000000), balances[0].Amount) + s.Require().Equal(osmomath.NewInt(1000000), balances[0].Amount) // check invariant is fine reason, broken := keeper.AllInvariants(*s.App.SuperfluidKeeper)(s.Ctx) @@ -686,7 +687,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { testCases := []struct { name string testInvalidLock bool - unlockAmount sdk.Int + unlockAmount osmomath.Int expectErr bool splitLockId bool undelegating bool @@ -695,7 +696,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "lock doesn't exist", testInvalidLock: true, - unlockAmount: sdk.NewInt(0), + unlockAmount: osmomath.NewInt(0), expectErr: true, splitLockId: false, undelegating: false, @@ -704,7 +705,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "unlock amount = 0", testInvalidLock: false, - unlockAmount: sdk.NewInt(0), + unlockAmount: osmomath.NewInt(0), expectErr: true, splitLockId: false, undelegating: false, @@ -713,7 +714,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "unlock amount > locked amount", testInvalidLock: false, - unlockAmount: sdk.NewInt(lockAmount + 1), + unlockAmount: osmomath.NewInt(lockAmount + 1), expectErr: true, splitLockId: false, undelegating: false, @@ -722,7 +723,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "lock is not split if unlock amount = locked amount", testInvalidLock: false, - unlockAmount: sdk.NewInt(lockAmount), + unlockAmount: osmomath.NewInt(lockAmount), expectErr: false, splitLockId: false, undelegating: false, @@ -731,7 +732,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "lock is split if unlock amount < locked amount", testInvalidLock: false, - unlockAmount: sdk.NewInt(lockAmount / 2), + unlockAmount: osmomath.NewInt(lockAmount / 2), expectErr: false, splitLockId: true, undelegating: false, @@ -740,7 +741,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "undelegate and unbond an undelegating lock", testInvalidLock: false, - unlockAmount: sdk.NewInt(1), + unlockAmount: osmomath.NewInt(1), expectErr: true, splitLockId: false, undelegating: true, @@ -749,7 +750,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { { name: "undelegate and unbond an unlocking lock", testInvalidLock: false, - unlockAmount: sdk.NewInt(1), + unlockAmount: osmomath.NewInt(1), expectErr: true, splitLockId: false, undelegating: true, @@ -764,7 +765,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { // setup validators valAddrs := s.SetupValidators([]stakingtypes.BondStatus{stakingtypes.Bonded}) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, []superfluidDelegation{{0, 0, 0, lockAmount}}, denoms) @@ -774,7 +775,7 @@ func (s *KeeperTestSuite) TestSuperfluidUndelegateAndUnbondLock() { // test invalid lock if tc.testInvalidLock { lock := lockuptypes.PeriodLock{} - _, err := s.App.SuperfluidKeeper.SuperfluidUndelegateAndUnbondLock(s.Ctx, lock.ID, lock.GetOwner(), sdk.NewInt(1)) + _, err := s.App.SuperfluidKeeper.SuperfluidUndelegateAndUnbondLock(s.Ctx, lock.ID, lock.GetOwner(), osmomath.NewInt(1)) s.Require().Error(err) return } @@ -897,49 +898,49 @@ func (s *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { validatorStats []stakingtypes.BondStatus superDelegations []superfluidDelegation // denom of the superfluid asset is the key, multiplier is the value - multipliersByDenom map[string]sdk.Dec + multipliersByDenom map[string]osmomath.Dec }{ { "with single validator and single delegation", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(10)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(10)}, }, { "with single validator and additional delegations", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 0, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(10)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(10)}, }, { "with multiple validator and multiple superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {1, 1, 0, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(10)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(10)}, }, { "with single validator and multiple denom superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {0, 0, 1, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(10), "gamm/pool/2": sdk.NewDec(10)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(10), "gamm/pool/2": osmomath.NewDec(10)}, }, { "with multiple validators and multiple denom superfluid delegations", []stakingtypes.BondStatus{stakingtypes.Bonded, stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}, {0, 1, 1, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(10), "gamm/pool/2": sdk.NewDec(10)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(10), "gamm/pool/2": osmomath.NewDec(10)}, }, { "zero price multiplier check", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDec(0)}, + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDec(0)}, }, { "dust price multiplier check", []stakingtypes.BondStatus{stakingtypes.Bonded}, []superfluidDelegation{{0, 0, 0, 1000000}}, - map[string]sdk.Dec{DefaultGammAsset: sdk.NewDecWithPrec(1, 10)}, // 10^-10 + map[string]osmomath.Dec{DefaultGammAsset: osmomath.NewDecWithPrec(1, 10)}, // 10^-10 }, } @@ -951,7 +952,7 @@ func (s *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { // setup validators valAddrs := s.SetupValidators(tc.validatorStats) - denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]sdk.Dec{sdk.NewDec(20), sdk.NewDec(20)}) + denoms, _ := s.SetupGammPoolsAndSuperfluidAssets([]osmomath.Dec{osmomath.NewDec(20), osmomath.NewDec(20)}) // setup superfluid delegations _, intermediaryAccs, locks := s.setupSuperfluidDelegations(valAddrs, tc.superDelegations, denoms) @@ -959,7 +960,7 @@ func (s *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { // we make a map of intermediary account to delegation shares to store delegation share // before refreshing intermediary account delegations on epoch - interAccIndexToDenomShare := make(map[int]sdk.Dec) + interAccIndexToDenomShare := make(map[int]osmomath.Dec) for accIndex, intermediaryAcc := range intermediaryAccs { valAddr, err := sdk.ValAddressFromBech32(intermediaryAcc.ValAddr) s.Require().NoError(err) @@ -975,13 +976,13 @@ func (s *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { s.App.SuperfluidKeeper.RefreshIntermediaryDelegationAmounts(s.Ctx) - originalMultiplier := sdk.NewDec(20) + originalMultiplier := osmomath.NewDec(20) for interAccIndex, intermediaryAcc := range intermediaryAccs { multiplier := tc.multipliersByDenom[intermediaryAcc.Denom] oldDelegation := interAccIndexToDenomShare[interAccIndex] expDelegation := oldDelegation.Mul(multiplier).Quo(originalMultiplier) - lpTokenAmount := sdk.NewInt(1000000) - decAmt := multiplier.Mul(lpTokenAmount.ToDec()) + lpTokenAmount := osmomath.NewInt(1000000) + decAmt := multiplier.Mul(lpTokenAmount.ToLegacyDec()) denom := intermediaryAcc.Denom _, err := s.App.SuperfluidKeeper.GetSuperfluidAsset(s.Ctx, denom) s.Require().NoError(err) @@ -1080,7 +1081,7 @@ func (s *KeeperTestSuite) TestUnbondConvertAndStake() { ) // we use migration setup for testing with cl lock if tc.testCLLock { - _, _, lock, _, joinPoolAcc, _, _, balancerShareOut, originalValAddr = s.SetupMigrationTest(s.Ctx, !tc.notSuperfluidDelegated, tc.superfluidUndelegating, tc.unlocking, tc.unlocked, sdk.MustNewDecFromStr("1")) + _, _, lock, _, joinPoolAcc, _, _, balancerShareOut, originalValAddr = s.SetupMigrationTest(s.Ctx, !tc.notSuperfluidDelegated, tc.superfluidUndelegating, tc.unlocking, tc.unlocked, osmomath.MustNewDecFromStr("1")) synthLockBeforeMigration, _, err := s.App.SuperfluidKeeper.GetMigrationType(s.Ctx, int64(lock.ID)) s.Require().NoError(err) _, lockId, _, err = s.App.SuperfluidKeeper.MigrateSuperfluidBondedBalancerToConcentrated(s.Ctx, joinPoolAcc, lock.ID, lock.Coins[0], synthLockBeforeMigration.SynthDenom, sdk.NewCoins()) @@ -1093,7 +1094,7 @@ func (s *KeeperTestSuite) TestUnbondConvertAndStake() { sender := sdk.MustAccAddressFromBech32(joinPoolAcc.String()) valAddr := s.SetupValidator(stakingtypes.Bonded) - minAmountToStake := sdk.ZeroInt() + minAmountToStake := osmomath.ZeroInt() sharesToConvert := sdk.NewInt64Coin("foo", 0) if tc.unlocked { sharesToConvert = balancerShareOut @@ -1160,8 +1161,8 @@ func (s *KeeperTestSuite) TestConvertLockToStake() { "error: min amount to stake greater than actual amount": { useMinAmountToStake: true, expectedError: types.TokenConvertedLessThenDesiredStakeError{ - ActualTotalAmtToStake: sdk.NewInt(8309), - ExpectedTotalAmtToStake: sdk.NewInt(999999999), + ActualTotalAmtToStake: osmomath.NewInt(8309), + ExpectedTotalAmtToStake: osmomath.NewInt(999999999), }, }, "error: use non balancer lock": { @@ -1195,7 +1196,7 @@ func (s *KeeperTestSuite) TestConvertLockToStake() { } if tc.useNonBalancerLock { - nonBalancerShareDenomCoins := sdk.NewCoins(sdk.NewCoin("foo", sdk.NewInt(100))) + nonBalancerShareDenomCoins := sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100))) s.FundAcc(sender, nonBalancerShareDenomCoins) newLock, err := s.App.LockupKeeper.CreateLock(s.Ctx, sender, nonBalancerShareDenomCoins, time.Second) s.Require().NoError(err) @@ -1203,9 +1204,9 @@ func (s *KeeperTestSuite) TestConvertLockToStake() { } valAddr := s.SetupValidator(stakingtypes.Bonded) - minAmountToStake := sdk.ZeroInt() + minAmountToStake := osmomath.ZeroInt() if tc.useMinAmountToStake { - minAmountToStake = sdk.NewInt(999999999) + minAmountToStake = osmomath.NewInt(999999999) } balanceBeforeConvertLockToStake := s.App.BankKeeper.GetAllBalances(s.Ctx, sender) @@ -1218,7 +1219,7 @@ func (s *KeeperTestSuite) TestConvertLockToStake() { // err check for LockOwnerMismatchError needs further refactoring for all these test cases // since lock owner is not know-able at the time of test creation if !tc.senderIsNotOwnerOfLock { - s.Require().Equal(tc.expectedError.Error(), err.Error()) + s.Require().Equal(err.Error(), tc.expectedError.Error()) } return } @@ -1253,15 +1254,15 @@ func (s *KeeperTestSuite) TestConvertUnlockedToStake() { "min amount to stake exceeds exit pool amount": { useMinAmountToStake: true, expectedError: types.TokenConvertedLessThenDesiredStakeError{ - ActualTotalAmtToStake: sdk.NewInt(8309), - ExpectedTotalAmtToStake: sdk.NewInt(999999999), + ActualTotalAmtToStake: osmomath.NewInt(8309), + ExpectedTotalAmtToStake: osmomath.NewInt(999999999), }, }, "error: use non gamm prefix": { useNonGammPrefix: true, expectedError: types.TokenConvertedLessThenDesiredStakeError{ - ActualTotalAmtToStake: sdk.NewInt(8309), - ExpectedTotalAmtToStake: sdk.NewInt(999999999), + ActualTotalAmtToStake: osmomath.NewInt(8309), + ExpectedTotalAmtToStake: osmomath.NewInt(999999999), }, }, } @@ -1276,13 +1277,13 @@ func (s *KeeperTestSuite) TestConvertUnlockedToStake() { // testing params valAddr := s.SetupValidator(stakingtypes.Bonded) - minAmtToStake := sdk.ZeroInt() + minAmtToStake := osmomath.ZeroInt() if tc.useMinAmountToStake { - minAmtToStake = sdk.NewInt(9999999999) + minAmtToStake = osmomath.NewInt(9999999999) } sharesToStake := shareOut if tc.usePartialShares { - sharesToStake.Amount = sharesToStake.Amount.Quo(sdk.NewInt(2)) + sharesToStake.Amount = sharesToStake.Amount.Quo(osmomath.NewInt(2)) } if tc.useNonGammPrefix { sharesToStake = sdk.NewInt64Coin("foo", 10) @@ -1296,7 +1297,7 @@ func (s *KeeperTestSuite) TestConvertUnlockedToStake() { s.Require().NoError(err) bondDenomPoolAmtBeforeConvert := totalPoolLiquidityBeforeConvert.AmountOf(bondDenom) - var expectedBondDenomAmt sdk.Int + var expectedBondDenomAmt osmomath.Int // check expected bond denom pool liquidity amount after conversion(only for non error cases) if tc.expectedError == nil { expectedBondDenomAmt = s.getExpectedBondDenomPoolAmtAfterConvert(sender, poolId, sharesToStake) @@ -1410,9 +1411,9 @@ func (s *KeeperTestSuite) TestConvertGammSharesToOsmoAndStake() { s.Require().NoError(err) } - minAmtToStake := sdk.ZeroInt() + minAmtToStake := osmomath.ZeroInt() if tc.useMinAmtToStake { - minAmtToStake = sdk.NewInt(999999999) + minAmtToStake = osmomath.NewInt(999999999) } // mark expected shares before swap @@ -1420,7 +1421,7 @@ func (s *KeeperTestSuite) TestConvertGammSharesToOsmoAndStake() { stakeDenomCoin := exitCoins.AmountOf(bondDenom) // use cache context to get expected amount after swap without changing test state cc, _ := s.Ctx.CacheContext() - tokenOutAmt, err := s.App.PoolManagerKeeper.SwapExactAmountIn(cc, sender, poolId, nonStakeDenomCoin, bondDenom, sdk.ZeroInt()) + tokenOutAmt, err := s.App.PoolManagerKeeper.SwapExactAmountIn(cc, sender, poolId, nonStakeDenomCoin, bondDenom, osmomath.ZeroInt()) s.Require().NoError(err) expectedTotalAmtStaked := tokenOutAmt.Add(stakeDenomCoin) @@ -1456,7 +1457,7 @@ func (s *KeeperTestSuite) TestConvertGammSharesToOsmoAndStake() { // in practice, the share amount between two validators should be equal, // but due to how we handle truncation and rounding in valset pref, we expect the diff to be under one dec. - s.Require().True(shareDiff.LTE(sdk.OneDec())) + s.Require().True(shareDiff.LTE(osmomath.OneDec())) } else { _, found := s.App.StakingKeeper.GetDelegation(s.Ctx, sender, valAddr) s.Require().True(found) @@ -1509,7 +1510,7 @@ func (s *KeeperTestSuite) TestDelegateBaseOnValsetPref() { s.Run(name, func() { s.Setup() bondDenom := s.App.StakingKeeper.BondDenom(s.Ctx) - stakeAmount := sdk.NewInt(100) + stakeAmount := osmomath.NewInt(100) sender := s.TestAccs[0] s.FundAcc(sender, sdk.NewCoins(sdk.NewCoin(bondDenom, stakeAmount))) @@ -1573,7 +1574,7 @@ func (s *KeeperTestSuite) TestDelegateBaseOnValsetPref() { del, found := s.App.StakingKeeper.GetDelegation(s.Ctx, sender, superfluidStakedValAddr) s.Require().True(found) // should be 200(original delegated amount + newly staked amount) - s.Require().True(del.Shares.RoundInt().Equal(stakeAmount.Mul(sdk.NewInt(2)))) + s.Require().True(del.Shares.RoundInt().Equal(stakeAmount.Mul(osmomath.NewInt(2)))) return } }) @@ -1604,8 +1605,8 @@ func (s *KeeperTestSuite) SetupUnbondConvertAndStakeTest(ctx sdk.Context, superf // Create a balancer pool of "stake" and "foo". msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) balancerPooId, err := poolmanagerKeeper.CreatePool(ctx, msg) s.Require().NoError(err) @@ -1687,7 +1688,7 @@ func (s *KeeperTestSuite) SetupUnbondConvertAndStakeTest(ctx sdk.Context, superf // We check the following in this method: // - if superfluid staked previously, check if the original validator's delegation has been deleted. // - Cehck if the delegation of the new validator matches what's expected. -func (s *KeeperTestSuite) delegationCheck(ctx sdk.Context, sender sdk.AccAddress, originalValAddr, newValAddr sdk.ValAddress, totalAmtConverted sdk.Int) { +func (s *KeeperTestSuite) delegationCheck(ctx sdk.Context, sender sdk.AccAddress, originalValAddr, newValAddr sdk.ValAddress, totalAmtConverted osmomath.Int) { if !originalValAddr.Empty() { // check if original superfluid staked lock's delgation is successfully deleted _, found := s.App.StakingKeeper.GetDelegation(s.Ctx, sender, originalValAddr) @@ -1696,8 +1697,8 @@ func (s *KeeperTestSuite) delegationCheck(ctx sdk.Context, sender sdk.AccAddress // check if delegation amount matches delegation, found := s.App.StakingKeeper.GetDelegation(s.Ctx, sender, newValAddr) s.Require().True(found) - s.Require().True(totalAmtConverted.ToDec().Equal(delegation.Shares)) - s.Require().True(delegation.Shares.Equal(totalAmtConverted.ToDec())) + s.Require().True(totalAmtConverted.ToLegacyDec().Equal(delegation.Shares)) + s.Require().True(delegation.Shares.Equal(totalAmtConverted.ToLegacyDec())) } // lockCheck checks lock related invariants of the test. @@ -1718,7 +1719,7 @@ func (s *KeeperTestSuite) lockCheck(ctx sdk.Context, lock lockuptypes.PeriodLock s.Require().Error(err) } -func (s *KeeperTestSuite) getExpectedBondDenomPoolAmtAfterConvert(sender sdk.AccAddress, poolId uint64, sharesToStake sdk.Coin) sdk.Int { +func (s *KeeperTestSuite) getExpectedBondDenomPoolAmtAfterConvert(sender sdk.AccAddress, poolId uint64, sharesToStake sdk.Coin) osmomath.Int { bondDenom := s.App.StakingKeeper.BondDenom(s.Ctx) cc, _ := s.Ctx.CacheContext() exitCoins, err := s.App.GAMMKeeper.ExitPool(cc, sender, poolId, sharesToStake.Amount, sdk.NewCoins()) @@ -1731,7 +1732,7 @@ func (s *KeeperTestSuite) getExpectedBondDenomPoolAmtAfterConvert(sender sdk.Acc nonOsmoCoin = exitCoin } } - _, err = s.App.PoolManagerKeeper.SwapExactAmountIn(cc, sender, poolId, nonOsmoCoin, bondDenom, sdk.ZeroInt()) + _, err = s.App.PoolManagerKeeper.SwapExactAmountIn(cc, sender, poolId, nonOsmoCoin, bondDenom, osmomath.ZeroInt()) s.Require().NoError(err) expectedLiquidity, err := s.App.GAMMKeeper.GetTotalPoolLiquidity(cc, poolId) s.Require().NoError(err) diff --git a/x/superfluid/keeper/superfluid_asset.go b/x/superfluid/keeper/superfluid_asset.go index 08ad96701a3..f72fca7d0af 100644 --- a/x/superfluid/keeper/superfluid_asset.go +++ b/x/superfluid/keeper/superfluid_asset.go @@ -1,6 +1,7 @@ package keeper import ( + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -17,25 +18,25 @@ import ( // See https://github.com/osmosis-labs/osmosis/issues/864 func (k Keeper) BeginUnwindSuperfluidAsset(ctx sdk.Context, epochNum int64, asset types.SuperfluidAsset) { // Right now set the TWAP to 0, and delete the asset. - k.SetOsmoEquivalentMultiplier(ctx, epochNum, asset.Denom, sdk.ZeroDec()) + k.SetOsmoEquivalentMultiplier(ctx, epochNum, asset.Denom, osmomath.ZeroDec()) k.DeleteSuperfluidAsset(ctx, asset.Denom) } // Returns amount * (1 - k.RiskFactor(asset)) // Fow now, the risk factor is a global constant. // It will move towards per pool functions. -func (k Keeper) GetRiskAdjustedOsmoValue(ctx sdk.Context, amount sdk.Int) sdk.Int { +func (k Keeper) GetRiskAdjustedOsmoValue(ctx sdk.Context, amount osmomath.Int) osmomath.Int { minRiskFactor := k.GetParams(ctx).MinimumRiskFactor - return amount.Sub(amount.ToDec().Mul(minRiskFactor).RoundInt()) + return amount.Sub(amount.ToLegacyDec().Mul(minRiskFactor).RoundInt()) } // y = x - (x * minRisk) // y = x (1 - minRisk) // y / (1 - minRisk) = x -func (k Keeper) UnriskAdjustOsmoValue(ctx sdk.Context, amount sdk.Dec) sdk.Dec { +func (k Keeper) UnriskAdjustOsmoValue(ctx sdk.Context, amount osmomath.Dec) osmomath.Dec { minRiskFactor := k.GetParams(ctx).MinimumRiskFactor - return amount.Quo(sdk.OneDec().Sub(minRiskFactor)) + return amount.Quo(osmomath.OneDec().Sub(minRiskFactor)) } func (k Keeper) AddNewSuperfluidAsset(ctx sdk.Context, asset types.SuperfluidAsset) error { diff --git a/x/superfluid/keeper/superfluid_asset_test.go b/x/superfluid/keeper/superfluid_asset_test.go index 304d68e02ed..a1334943ef4 100644 --- a/x/superfluid/keeper/superfluid_asset_test.go +++ b/x/superfluid/keeper/superfluid_asset_test.go @@ -1,9 +1,8 @@ package keeper_test import ( + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" - - sdk "github.com/cosmos/cosmos-sdk/types" ) func (s *KeeperTestSuite) TestSuperfluidAssetSetGetDeleteFlow() { @@ -48,7 +47,7 @@ func (s *KeeperTestSuite) TestGetRiskAdjustedOsmoValue() { adjustedValue := s.App.SuperfluidKeeper.GetRiskAdjustedOsmoValue( s.Ctx, - sdk.NewInt(100), + osmomath.NewInt(100), ) - s.Require().Equal(sdk.NewInt(50), adjustedValue) + s.Require().Equal(osmomath.NewInt(50), adjustedValue) } diff --git a/x/superfluid/keeper/twap_price.go b/x/superfluid/keeper/twap_price.go index bd32dae54f6..d216366b893 100644 --- a/x/superfluid/keeper/twap_price.go +++ b/x/superfluid/keeper/twap_price.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -13,12 +14,12 @@ import ( // This function calculates the osmo equivalent worth of an LP share. // It is intended to eventually use the TWAP of the worth of an LP share // once that is exposed from the gamm module. -func (k Keeper) calculateOsmoBackingPerShare(pool gammtypes.CFMMPoolI, osmoInPool sdk.Int) sdk.Dec { - twap := osmoInPool.ToDec().Quo(pool.GetTotalShares().ToDec()) +func (k Keeper) calculateOsmoBackingPerShare(pool gammtypes.CFMMPoolI, osmoInPool osmomath.Int) osmomath.Dec { + twap := osmoInPool.ToLegacyDec().Quo(pool.GetTotalShares().ToLegacyDec()) return twap } -func (k Keeper) SetOsmoEquivalentMultiplier(ctx sdk.Context, epoch int64, denom string, multiplier sdk.Dec) { +func (k Keeper) SetOsmoEquivalentMultiplier(ctx sdk.Context, epoch int64, denom string, multiplier osmomath.Dec) { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, types.KeyPrefixTokenMultiplier) priceRecord := types.OsmoEquivalentMultiplierRecord{ @@ -33,16 +34,16 @@ func (k Keeper) SetOsmoEquivalentMultiplier(ctx sdk.Context, epoch int64, denom prefixStore.Set([]byte(denom), bz) } -func (k Keeper) GetSuperfluidOSMOTokens(ctx sdk.Context, denom string, amount sdk.Int) (sdk.Int, error) { +func (k Keeper) GetSuperfluidOSMOTokens(ctx sdk.Context, denom string, amount osmomath.Int) (osmomath.Int, error) { multiplier := k.GetOsmoEquivalentMultiplier(ctx, denom) if multiplier.IsZero() { - return sdk.ZeroInt(), nil + return osmomath.ZeroInt(), nil } - decAmt := multiplier.Mul(amount.ToDec()) + decAmt := multiplier.Mul(amount.ToLegacyDec()) _, err := k.GetSuperfluidAsset(ctx, denom) if err != nil { - return sdk.ZeroInt(), err + return osmomath.ZeroInt(), err } return k.GetRiskAdjustedOsmoValue(ctx, decAmt.RoundInt()), nil } @@ -53,12 +54,12 @@ func (k Keeper) DeleteOsmoEquivalentMultiplier(ctx sdk.Context, denom string) { prefixStore.Delete([]byte(denom)) } -func (k Keeper) GetOsmoEquivalentMultiplier(ctx sdk.Context, denom string) sdk.Dec { +func (k Keeper) GetOsmoEquivalentMultiplier(ctx sdk.Context, denom string) osmomath.Dec { store := ctx.KVStore(k.storeKey) prefixStore := prefix.NewStore(store, types.KeyPrefixTokenMultiplier) bz := prefixStore.Get([]byte(denom)) if bz == nil { - return sdk.ZeroDec() + return osmomath.ZeroDec() } priceRecord := types.OsmoEquivalentMultiplierRecord{} err := proto.Unmarshal(bz, &priceRecord) diff --git a/x/superfluid/keeper/twap_price_test.go b/x/superfluid/keeper/twap_price_test.go index b192ebd380d..7414a9c70b7 100644 --- a/x/superfluid/keeper/twap_price_test.go +++ b/x/superfluid/keeper/twap_price_test.go @@ -1,6 +1,7 @@ package keeper_test import ( + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" @@ -15,18 +16,18 @@ func (s *KeeperTestSuite) TestOsmoEquivalentMultiplierSetGetDeleteFlow() { s.Require().Len(multipliers, 0) // set multiplier - s.App.SuperfluidKeeper.SetOsmoEquivalentMultiplier(s.Ctx, 1, DefaultGammAsset, sdk.NewDec(2)) + s.App.SuperfluidKeeper.SetOsmoEquivalentMultiplier(s.Ctx, 1, DefaultGammAsset, osmomath.NewDec(2)) // get multiplier multiplier := s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, DefaultGammAsset) - s.Require().Equal(multiplier, sdk.NewDec(2)) + s.Require().Equal(multiplier, osmomath.NewDec(2)) // check multipliers expectedMultipliers := []types.OsmoEquivalentMultiplierRecord{ { EpochNumber: 1, Denom: DefaultGammAsset, - Multiplier: sdk.NewDec(2), + Multiplier: osmomath.NewDec(2), }, } multipliers = s.App.SuperfluidKeeper.GetAllOsmoEquivalentMultipliers(s.Ctx) @@ -34,14 +35,14 @@ func (s *KeeperTestSuite) TestOsmoEquivalentMultiplierSetGetDeleteFlow() { // test last epoch price multiplier = s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, DefaultGammAsset) - s.Require().Equal(multiplier, sdk.NewDec(2)) + s.Require().Equal(multiplier, osmomath.NewDec(2)) // delete multiplier s.App.SuperfluidKeeper.DeleteOsmoEquivalentMultiplier(s.Ctx, DefaultGammAsset) // get multiplier multiplier = s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, DefaultGammAsset) - s.Require().Equal(multiplier, sdk.NewDec(0)) + s.Require().Equal(multiplier, osmomath.NewDec(0)) // check multipliers multipliers = s.App.SuperfluidKeeper.GetAllOsmoEquivalentMultipliers(s.Ctx) @@ -49,21 +50,21 @@ func (s *KeeperTestSuite) TestOsmoEquivalentMultiplierSetGetDeleteFlow() { // test last epoch price multiplier = s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, DefaultGammAsset) - s.Require().Equal(multiplier, sdk.NewDec(0)) + s.Require().Equal(multiplier, osmomath.NewDec(0)) } func (s *KeeperTestSuite) TestGetSuperfluidOSMOTokens() { s.SetupTest() minRiskFactor := s.App.SuperfluidKeeper.GetParams(s.Ctx).MinimumRiskFactor - poolCoins := sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(1000000000000000000)), sdk.NewCoin("foo", sdk.NewInt(1000000000000000000))) + poolCoins := sdk.NewCoins(sdk.NewCoin("stake", osmomath.NewInt(1000000000000000000)), sdk.NewCoin("foo", osmomath.NewInt(1000000000000000000))) s.PrepareBalancerPoolWithCoins(poolCoins...) s.PrepareConcentratedPoolWithCoinsAndFullRangePosition("stake", "foo") gammShareDenom := DefaultGammAsset clShareDenom := cltypes.GetConcentratedLockupDenomFromPoolId(2) - multiplier := sdk.NewDec(2) - testAmount := sdk.NewInt(100) + multiplier := osmomath.NewDec(2) + testAmount := osmomath.NewInt(100) epoch := int64(1) // Set multiplier @@ -71,13 +72,13 @@ func (s *KeeperTestSuite) TestGetSuperfluidOSMOTokens() { // Get multiplier multiplier = s.App.SuperfluidKeeper.GetOsmoEquivalentMultiplier(s.Ctx, gammShareDenom) - s.Require().Equal(multiplier, sdk.NewDec(2)) + s.Require().Equal(multiplier, osmomath.NewDec(2)) // Should get error since asset is not superfluid enabled osmoTokens, err := s.App.SuperfluidKeeper.GetSuperfluidOSMOTokens(s.Ctx, gammShareDenom, testAmount) s.Require().Error(err) s.Require().ErrorIs(err, types.ErrNonSuperfluidAsset) - s.Require().Equal(osmoTokens, sdk.NewInt(0)) + s.Require().Equal(osmoTokens, osmomath.NewInt(0)) // Set gamm share as superfluid superfluidGammAsset := types.SuperfluidAsset{ @@ -98,7 +99,7 @@ func (s *KeeperTestSuite) TestGetSuperfluidOSMOTokens() { osmoTokensRiskAdjusted := s.App.SuperfluidKeeper.GetRiskAdjustedOsmoValue(s.Ctx, osmoTokens) // Check result - s.Require().Equal(testAmount.ToDec().Mul(minRiskFactor).TruncateInt().String(), osmoTokensRiskAdjusted.String()) + s.Require().Equal(testAmount.ToLegacyDec().Mul(minRiskFactor).TruncateInt().String(), osmoTokensRiskAdjusted.String()) // Set cl share as superfluid superfluidClAsset := types.SuperfluidAsset{ @@ -119,5 +120,5 @@ func (s *KeeperTestSuite) TestGetSuperfluidOSMOTokens() { osmoTokensRiskAdjusted = s.App.SuperfluidKeeper.GetRiskAdjustedOsmoValue(s.Ctx, osmoTokens) // Check result - s.Require().Equal(testAmount.ToDec().Mul(minRiskFactor).TruncateInt().String(), osmoTokensRiskAdjusted.String()) + s.Require().Equal(testAmount.ToLegacyDec().Mul(minRiskFactor).TruncateInt().String(), osmoTokensRiskAdjusted.String()) } diff --git a/x/superfluid/keeper/unpool_test.go b/x/superfluid/keeper/unpool_test.go index a771724fb9b..07d325f938d 100644 --- a/x/superfluid/keeper/unpool_test.go +++ b/x/superfluid/keeper/unpool_test.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/gamm/pool-models/balancer" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -21,20 +22,20 @@ var ( // pool assets defaultFooAsset balancer.PoolAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin("foo", sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin("foo", osmomath.NewInt(10000)), } defaultBondDenomAsset balancer.PoolAsset = balancer.PoolAsset{ - Weight: sdk.NewInt(100), - Token: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000)), + Weight: osmomath.NewInt(100), + Token: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10000)), } defaultPoolAssets []balancer.PoolAsset = []balancer.PoolAsset{defaultFooAsset, defaultBondDenomAsset} defaultAcctFunds sdk.Coins = sdk.NewCoins( - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000000)), - sdk.NewCoin("uosmo", sdk.NewInt(10000000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000)), - sdk.NewCoin("baz", sdk.NewInt(10000000)), + sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(10000000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000)), + sdk.NewCoin("baz", osmomath.NewInt(10000000)), ) ) @@ -109,8 +110,8 @@ func (s *KeeperTestSuite) TestUnpool() { // create pool of "stake" and "foo" msg := balancer.NewMsgCreateBalancerPool(poolCreateAcc, balancer.PoolParams{ - SwapFee: sdk.NewDecWithPrec(1, 2), - ExitFee: sdk.NewDec(0), + SwapFee: osmomath.NewDecWithPrec(1, 2), + ExitFee: osmomath.NewDec(0), }, defaultPoolAssets, defaultFutureGovernor) poolId, err := poolmanagerKeeper.CreatePool(ctx, msg) @@ -212,7 +213,7 @@ func (s *KeeperTestSuite) TestUnpool() { // exitPool has rounding difference, // we test if correct amt has been exited and locked via comparing with rounding tolerance - roundingToleranceCoins := sdk.NewCoins(sdk.NewCoin(defaultFooAsset.Token.Denom, sdk.NewInt(5)), sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(5))) + roundingToleranceCoins := sdk.NewCoins(sdk.NewCoin(defaultFooAsset.Token.Denom, osmomath.NewInt(5)), sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(5))) roundDownTolerance, _ := joinPoolAmt.SafeSub(roundingToleranceCoins) roundUpTolerance := joinPoolAmt.Add(roundingToleranceCoins...) s.Require().True(cumulativeNewLockCoins.AmountOf("foo").GTE(roundDownTolerance.AmountOf("foo"))) @@ -296,42 +297,42 @@ func (s *KeeperTestSuite) TestValidateGammLockForSuperfluid() { } testCases := map[string]sendTest{ "happy path": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), accountToValidate: lockCreator, poolIdToValidate: 1, lockIdToValidate: 1, }, "error: non-existent lock ID": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), accountToValidate: lockCreator, poolIdToValidate: 1, lockIdToValidate: 2, expectedError: errorsmod.Wrap(lockuptypes.ErrLockupNotFound, fmt.Sprintf("lock with ID %d does not exist", 2)), }, "error: mismatched owner": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), accountToValidate: nonLockCreator, poolIdToValidate: 1, lockIdToValidate: 1, expectedError: lockuptypes.ErrNotLockOwner, }, "error: more than one coin in lock": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100)), - sdk.NewCoin("gamm/pool/2", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100)), + sdk.NewCoin("gamm/pool/2", osmomath.NewInt(100))), accountToValidate: lockCreator, poolIdToValidate: 1, lockIdToValidate: 1, expectedError: types.ErrMultipleCoinsLockupNotSupported, }, "error: wrong pool ID provided when compared to lock denom": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("gamm/pool/1", osmomath.NewInt(100))), accountToValidate: lockCreator, poolIdToValidate: 2, lockIdToValidate: 1, expectedError: types.UnexpectedDenomError{ExpectedDenom: gammtypes.GetPoolShareDenom(2), ProvidedDenom: "gamm/pool/1"}, }, "error: right pool ID provided but not gamm/pool/ prefix": { - fundsToLock: sdk.NewCoins(sdk.NewCoin("cl/pool/1", sdk.NewInt(100))), + fundsToLock: sdk.NewCoins(sdk.NewCoin("cl/pool/1", osmomath.NewInt(100))), accountToValidate: lockCreator, poolIdToValidate: 1, lockIdToValidate: 1, diff --git a/x/superfluid/simulation/genesis.go b/x/superfluid/simulation/genesis.go index c3f293c550b..bff60a17fd7 100644 --- a/x/superfluid/simulation/genesis.go +++ b/x/superfluid/simulation/genesis.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -14,7 +14,7 @@ import ( func RandomizedGenState(simState *module.SimulationState) { superfluidGenesis := &types.GenesisState{ Params: types.Params{ - MinimumRiskFactor: sdk.NewDecWithPrec(5, 2), // 5% + MinimumRiskFactor: osmomath.NewDecWithPrec(5, 2), // 5% }, SuperfluidAssets: []types.SuperfluidAsset{}, OsmoEquivalentMultipliers: []types.OsmoEquivalentMultiplierRecord{}, diff --git a/x/superfluid/types/errors.go b/x/superfluid/types/errors.go index 9cd35461083..632d4ad0f0d 100644 --- a/x/superfluid/types/errors.go +++ b/x/superfluid/types/errors.go @@ -6,8 +6,7 @@ import ( errorsmod "cosmossdk.io/errors" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" ) @@ -119,8 +118,8 @@ func (e UnexpectedDenomError) Error() string { } type TokenConvertedLessThenDesiredStakeError struct { - ActualTotalAmtToStake sdk.Int - ExpectedTotalAmtToStake sdk.Int + ActualTotalAmtToStake osmomath.Int + ExpectedTotalAmtToStake osmomath.Int } func (e TokenConvertedLessThenDesiredStakeError) Error() string { diff --git a/x/superfluid/types/expected_keepers.go b/x/superfluid/types/expected_keepers.go index 5456fedd319..711c3aab009 100644 --- a/x/superfluid/types/expected_keepers.go +++ b/x/superfluid/types/expected_keepers.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/model" cltypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -21,7 +22,7 @@ type LockupKeeper interface { GetLocksLongerThanDurationDenom(ctx sdk.Context, denom string, duration time.Duration) []lockuptypes.PeriodLock GetAccountLockedLongerDurationDenom(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []lockuptypes.PeriodLock GetAccountLockedLongerDurationDenomNotUnlockingOnly(ctx sdk.Context, addr sdk.AccAddress, denom string, duration time.Duration) []lockuptypes.PeriodLock - GetPeriodLocksAccumulation(ctx sdk.Context, query lockuptypes.QueryCondition) sdk.Int + GetPeriodLocksAccumulation(ctx sdk.Context, query lockuptypes.QueryCondition) osmomath.Int GetAccountPeriodLocks(ctx sdk.Context, addr sdk.AccAddress) []lockuptypes.PeriodLock GetPeriodLocks(ctx sdk.Context) ([]lockuptypes.PeriodLock, error) GetLockByID(ctx sdk.Context, lockID uint64) (*lockuptypes.PeriodLock, error) @@ -53,7 +54,7 @@ type LockupMsgServer interface { type GammKeeper interface { GetPoolAndPoke(ctx sdk.Context, poolId uint64) (gammtypes.CFMMPoolI, error) GetPoolsAndPoke(ctx sdk.Context) (res []gammtypes.CFMMPoolI, err error) - ExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, tokenOutMins sdk.Coins) (exitCoins sdk.Coins, err error) + ExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, tokenOutMins sdk.Coins) (exitCoins sdk.Coins, err error) GetAllMigrationInfo(ctx sdk.Context) (gammmigration.MigrationRecords, error) GetLinkedConcentratedPoolID(ctx sdk.Context, poolIdLeaving uint64) (poolIdEntering uint64, err error) MigrateUnlockedPositionFromBalancerToConcentrated(ctx sdk.Context, sender sdk.AccAddress, sharesToMigrate sdk.Coin, tokenOutMins sdk.Coins) (positionData cltypes.CreateFullRangePositionData, migratedPoolIDs MigrationPoolIDs, err error) @@ -63,7 +64,7 @@ type BankKeeper interface { GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin MintCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error - AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) + AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount osmomath.Int) SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error } @@ -73,15 +74,15 @@ type StakingKeeper interface { BondDenom(ctx sdk.Context) string GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) - ValidateUnbondAmount(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt sdk.Int) (shares sdk.Dec, err error) - Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) - InstantUndelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) (sdk.Coins, error) + ValidateUnbondAmount(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, amt osmomath.Int) (shares osmomath.Dec, err error) + Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt osmomath.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares osmomath.Dec, err error) + InstantUndelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount osmomath.Dec) (sdk.Coins, error) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) UnbondingTime(ctx sdk.Context) time.Duration GetParams(ctx sdk.Context) stakingtypes.Params IterateBondedValidatorsByPower(ctx sdk.Context, fn func(int64, stakingtypes.ValidatorI) bool) - TotalBondedTokens(ctx sdk.Context) sdk.Int + TotalBondedTokens(ctx sdk.Context) osmomath.Int IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(int64, stakingtypes.DelegationI) bool) } @@ -108,16 +109,16 @@ type EpochKeeper interface { type ConcentratedKeeper interface { GetPosition(ctx sdk.Context, positionId uint64) (model.Position, error) - SetPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, joinTime time.Time, liquidity sdk.Dec, positionId uint64, underlyingLockId uint64) error - UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta sdk.Dec, joinTime time.Time, positionId uint64) (cltypes.UpdatePositionData, error) + SetPosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, joinTime time.Time, liquidity osmomath.Dec, positionId uint64, underlyingLockId uint64) error + UpdatePosition(ctx sdk.Context, poolId uint64, owner sdk.AccAddress, lowerTick, upperTick int64, liquidityDelta osmomath.Dec, joinTime time.Time, positionId uint64) (cltypes.UpdatePositionData, error) GetConcentratedPoolById(ctx sdk.Context, poolId uint64) (cltypes.ConcentratedPoolExtension, error) CreateFullRangePositionLocked(ctx sdk.Context, clPoolId uint64, owner sdk.AccAddress, coins sdk.Coins, remainingLockDuration time.Duration) (positionData cltypes.CreateFullRangePositionData, concentratedLockID uint64, err error) CreateFullRangePositionUnlocking(ctx sdk.Context, clPoolId uint64, owner sdk.AccAddress, coins sdk.Coins, remainingLockDuration time.Duration) (positionData cltypes.CreateFullRangePositionData, concentratedLockID uint64, err error) GetPositionIdToLockId(ctx sdk.Context, underlyingLockId uint64) (uint64, error) - GetFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64) (sdk.Dec, error) + GetFullRangeLiquidityInPool(ctx sdk.Context, poolId uint64) (osmomath.Dec, error) PositionHasActiveUnderlyingLock(ctx sdk.Context, positionId uint64) (bool, uint64, error) HasAnyPositionForPool(ctx sdk.Context, poolId uint64) (bool, error) - WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, requestedLiquidityAmountToWithdraw sdk.Dec) (amtDenom0, amtDenom1 sdk.Int, err error) + WithdrawPosition(ctx sdk.Context, owner sdk.AccAddress, positionId uint64, requestedLiquidityAmountToWithdraw osmomath.Dec) (amtDenom0, amtDenom1 osmomath.Int, err error) GetUserPositions(ctx sdk.Context, addr sdk.AccAddress, poolId uint64) ([]model.Position, error) GetLockIdFromPositionId(ctx sdk.Context, positionId uint64) (uint64, error) } @@ -129,8 +130,8 @@ type PoolManagerKeeper interface { poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - ) (sdk.Int, error) + tokenOutMinAmount osmomath.Int, + ) (osmomath.Int, error) } type ValSetPreferenceKeeper interface { diff --git a/x/superfluid/types/msg_test.go b/x/superfluid/types/msg_test.go index 867b61ada40..c068f9dd21d 100644 --- a/x/superfluid/types/msg_test.go +++ b/x/superfluid/types/msg_test.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/superfluid/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/tendermint/tendermint/crypto/ed25519" ) @@ -17,7 +18,7 @@ import ( func TestAuthzMsg(t *testing.T) { pk1 := ed25519.GenPrivKey().PubKey() addr1 := sdk.AccAddress(pk1.Address()).String() - coin := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)) + coin := sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1)) testCases := []struct { name string @@ -94,7 +95,7 @@ func TestUnbondConvertAndStakeMsg(t *testing.T) { LockId: 2, Sender: addr1, ValAddr: valAddr, - MinAmtToStake: sdk.NewInt(10), + MinAmtToStake: osmomath.NewInt(10), SharesToConvert: sdk.NewInt64Coin("foo", 10), }, }, @@ -104,7 +105,7 @@ func TestUnbondConvertAndStakeMsg(t *testing.T) { LockId: 0, Sender: addr1, ValAddr: valAddr, - MinAmtToStake: sdk.NewInt(10), + MinAmtToStake: osmomath.NewInt(10), SharesToConvert: sdk.NewInt64Coin("foo", 10), }, }, @@ -113,7 +114,7 @@ func TestUnbondConvertAndStakeMsg(t *testing.T) { msg: &types.MsgUnbondConvertAndStake{ LockId: 0, Sender: addr1, - MinAmtToStake: sdk.NewInt(10), + MinAmtToStake: osmomath.NewInt(10), SharesToConvert: sdk.NewInt64Coin("foo", 10), }, }, @@ -123,7 +124,7 @@ func TestUnbondConvertAndStakeMsg(t *testing.T) { LockId: 0, Sender: "abcd", ValAddr: valAddr, - MinAmtToStake: sdk.NewInt(10), + MinAmtToStake: osmomath.NewInt(10), SharesToConvert: sdk.NewInt64Coin("foo", 10), }, expectedError: true, @@ -133,7 +134,7 @@ func TestUnbondConvertAndStakeMsg(t *testing.T) { msg: &types.MsgUnbondConvertAndStake{ LockId: 0, Sender: addr1, - MinAmtToStake: sdk.NewInt(10).Neg(), + MinAmtToStake: osmomath.NewInt(10).Neg(), SharesToConvert: sdk.NewInt64Coin("foo", 10), }, expectedError: true, diff --git a/x/superfluid/types/msgs.go b/x/superfluid/types/msgs.go index c6a85aa2195..3c693c4fee2 100644 --- a/x/superfluid/types/msgs.go +++ b/x/superfluid/types/msgs.go @@ -7,6 +7,8 @@ import ( errorsmod "cosmossdk.io/errors" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/osmosis-labs/osmosis/osmomath" ) // constants. @@ -396,7 +398,7 @@ func (msg MsgAddToConcentratedLiquiditySuperfluidPosition) GetSigners() []sdk.Ac var _ sdk.Msg = &MsgUnbondConvertAndStake{} -func NewMsgUnbondConvertAndStake(sender sdk.AccAddress, lockId uint64, valAddr string, minAmtToStake sdk.Int, sharesToConvert sdk.Coin) *MsgUnbondConvertAndStake { +func NewMsgUnbondConvertAndStake(sender sdk.AccAddress, lockId uint64, valAddr string, minAmtToStake osmomath.Int, sharesToConvert sdk.Coin) *MsgUnbondConvertAndStake { return &MsgUnbondConvertAndStake{ Sender: sender.String(), LockId: lockId, diff --git a/x/superfluid/types/params.go b/x/superfluid/types/params.go index a7969803de7..78ecb4428a1 100644 --- a/x/superfluid/types/params.go +++ b/x/superfluid/types/params.go @@ -4,14 +4,15 @@ import ( fmt "fmt" "time" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // Parameter store keys. var ( KeyMinimumRiskFactor = []byte("MinimumRiskFactor") - defaultMinimumRiskFactor = sdk.NewDecWithPrec(5, 1) // 50% + defaultMinimumRiskFactor = osmomath.NewDecWithPrec(5, 1) // 50% ) // ParamTable for minting module. @@ -19,7 +20,7 @@ func ParamKeyTable() paramtypes.KeyTable { return paramtypes.NewKeyTable().RegisterParamSet(&Params{}) } -func NewParams(minimumRiskFactor sdk.Dec) Params { +func NewParams(minimumRiskFactor osmomath.Dec) Params { return Params{ MinimumRiskFactor: minimumRiskFactor, } @@ -45,12 +46,12 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { } func ValidateMinimumRiskFactor(i interface{}) error { - v, ok := i.(sdk.Dec) + v, ok := i.(osmomath.Dec) if !ok { return fmt.Errorf("invalid parameter type: %T", i) } - if v.IsNegative() || v.GT(sdk.NewDec(100)) { + if v.IsNegative() || v.GT(osmomath.NewDec(100)) { return fmt.Errorf("minimum risk factor should be between 0 - 100: %s", v.String()) } diff --git a/x/superfluid/types/params.pb.go b/x/superfluid/types/params.pb.go index 0eebc7a1eeb..6a88e0b385d 100644 --- a/x/superfluid/types/params.pb.go +++ b/x/superfluid/types/params.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - 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,7 +31,7 @@ type Params struct { // superfluid staking, default: 5%. The minimum risk factor works // to counter-balance the staked amount on chain's exposure to various asset // volatilities, and have base staking be 'resistant' to volatility. - MinimumRiskFactor github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=minimum_risk_factor,json=minimumRiskFactor,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"minimum_risk_factor" yaml:"minimum_risk_factor"` + MinimumRiskFactor cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=minimum_risk_factor,json=minimumRiskFactor,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"minimum_risk_factor" yaml:"minimum_risk_factor"` } func (m *Params) Reset() { *m = Params{} } @@ -74,24 +74,24 @@ func init() { func init() { proto.RegisterFile("osmosis/superfluid/params.proto", fileDescriptor_0985261dfaf2a82e) } var fileDescriptor_0985261dfaf2a82e = []byte{ - // 260 bytes of a gzipped FileDescriptorProto + // 265 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0xcf, 0x2f, 0xce, 0xcd, 0x2f, 0xce, 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0x0c, 0x37, 0x1e, + 0xcb, 0x31, 0x44, 0x99, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x43, + 0xfd, 0xaa, 0x9b, 0x93, 0x98, 0x54, 0x0c, 0xe3, 0xe8, 0x97, 0x19, 0x5a, 0xea, 0x57, 0x20, 0x87, + 0x4f, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, 0x57, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, + 0xff, 0x85, 0x36, 0x64, 0x0b, 0x42, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/superfluid/types/query.pb.go b/x/superfluid/types/query.pb.go index 2c8ef01ec1d..e1572518ad8 100644 --- a/x/superfluid/types/query.pb.go +++ b/x/superfluid/types/query.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -721,9 +722,9 @@ func (m *QueryTotalDelegationByValidatorForDenomResponse) GetAssets() []Delegati } type Delegations struct { - ValAddr string `protobuf:"bytes,1,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` - AmountSfsd github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount_sfsd,json=amountSfsd,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount_sfsd" yaml:"amount_sfsd"` - OsmoEquivalent github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=osmo_equivalent,json=osmoEquivalent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"osmo_equivalent" yaml:"osmo_equivalent"` + ValAddr string `protobuf:"bytes,1,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` + AmountSfsd cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount_sfsd,json=amountSfsd,proto3,customtype=cosmossdk.io/math.Int" json:"amount_sfsd" yaml:"amount_sfsd"` + OsmoEquivalent cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=osmo_equivalent,json=osmoEquivalent,proto3,customtype=cosmossdk.io/math.Int" json:"osmo_equivalent" yaml:"osmo_equivalent"` } func (m *Delegations) Reset() { *m = Delegations{} } @@ -803,7 +804,7 @@ func (m *TotalSuperfluidDelegationsRequest) XXX_DiscardUnknown() { var xxx_messageInfo_TotalSuperfluidDelegationsRequest proto.InternalMessageInfo type TotalSuperfluidDelegationsResponse struct { - TotalDelegations github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_delegations,json=totalDelegations,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_delegations" yaml:"total_superfluid_delegations"` + TotalDelegations cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total_delegations,json=totalDelegations,proto3,customtype=cosmossdk.io/math.Int" json:"total_delegations" yaml:"total_superfluid_delegations"` } func (m *TotalSuperfluidDelegationsResponse) Reset() { *m = TotalSuperfluidDelegationsResponse{} } @@ -1809,135 +1810,135 @@ func init() { func init() { proto.RegisterFile("osmosis/superfluid/query.proto", fileDescriptor_e3d9448e4ed3943f) } var fileDescriptor_e3d9448e4ed3943f = []byte{ - // 2038 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x14, 0xc9, - 0x15, 0x76, 0x8f, 0xbd, 0x36, 0x3c, 0x24, 0x30, 0x05, 0x59, 0xec, 0x06, 0xc6, 0x6c, 0x9b, 0xb5, - 0x1d, 0x2f, 0x4c, 0x2f, 0x66, 0x31, 0x86, 0x0d, 0x68, 0x67, 0x30, 0x06, 0x27, 0xb0, 0x78, 0xc7, - 0xd8, 0x28, 0x7f, 0x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1, 0x40, 0x0d, 0xba, 0x1f, - 0x29, 0xad, 0xda, 0xde, 0x7f, 0x1e, 0x4f, 0xa1, 0x96, 0xde, 0xb0, 0x2e, 0x2b, 0x09, 0x53, 0x4a, - 0x15, 0xd8, 0xd3, 0xfa, 0x36, 0x31, 0xd0, 0x0e, 0x1c, 0xea, 0x68, 0x19, 0xb4, 0xe0, 0xf6, 0x57, - 0x6e, 0xf6, 0xed, 0xea, 0x55, 0xe6, 0xaa, 0xc3, 0x9c, 0x52, 0x3d, 0xd8, 0xde, 0x3d, 0x94, 0x69, - 0x78, 0x8d, 0x32, 0x1e, 0xef, 0x78, 0x82, 0x92, 0xb0, 0xdd, 0x7e, 0x2a, 0x81, 0x92, 0xa5, 0xc5, - 0xf7, 0xe3, 0x91, 0x04, 0x87, 0xbd, 0x40, 0x4d, 0x33, 0x62, 0x29, 0xa3, 0xb2, 0xb2, 0xd1, 0x37, - 0x82, 0x69, 0x86, 0x80, 0x19, 0x8c, 0x37, 0x34, 0x69, 0x5b, 0xa9, 0x8e, 0x7b, 0xed, 0xe9, 0x42, - 0x94, 0x8f, 0xdb, 0x9a, 0x60, 0x2c, 0x29, 0x37, 0x92, 0x75, 0xf4, 0x06, 0x1c, 0xe6, 0x76, 0x1c, - 0x57, 0x0b, 0x5b, 0x18, 0xdb, 0xf4, 0xf1, 0x48, 0x50, 0x66, 0xef, 0x03, 0xe5, 0xdd, 0x30, 0x09, - 0x23, 0x65, 0xd6, 0x24, 0xc7, 0x23, 0x41, 0xa8, 0x1c, 0x65, 0xf7, 0x70, 0x32, 0xbb, 0x3f, 0x92, - 0x40, 0xc9, 0x8a, 0x8a, 0x33, 0x58, 0x83, 0x51, 0x96, 0x0e, 0x3c, 0xa3, 0x27, 0xdb, 0x5a, 0x49, - 0xd8, 0x44, 0xae, 0x39, 0xa6, 0x5d, 0x79, 0x33, 0x20, 0xf4, 0xb3, 0x2f, 0xa7, 0xe6, 0x72, 0x10, - 0x1a, 0x2c, 0x20, 0x55,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9c, 0xe2, 0x3b, 0xa1, 0xfc, 0x66, 0xfe, 0x05, 0xfd, 0x9c, 0xda, 0x7c, - 0xba, 0x58, 0x7b, 0x3f, 0x0a, 0xec, 0x93, 0x02, 0x9c, 0xe9, 0xe7, 0x72, 0x87, 0x6e, 0x88, 0x02, - 0x1b, 0xe0, 0x0e, 0x2a, 0xdf, 0x7c, 0x76, 0x43, 0x1c, 0xf9, 0x26, 0x45, 0xbe, 0x86, 0xde, 0xcd, - 0xfc, 0x26, 0xb3, 0xa3, 0x50, 0x72, 0x2a, 0x61, 0x45, 0xd7, 0x2d, 0x71, 0xaf, 0xff, 0x65, 0x01, - 0xd4, 0x3e, 0x2f, 0x76, 0xe8, 0x9b, 0x03, 0xa2, 0x12, 0xdc, 0x42, 0xe5, 0x6f, 0xed, 0x89, 0x2d, - 0x4e, 0xd2, 0xb7, 0x29, 0x49, 0xeb, 0xe8, 0xbd, 0x3c, 0x24, 0xf9, 0x09, 0x0b, 0x3d, 0x79, 0xaa, - 0xac, 0x7d, 0xfe, 0xa4, 0x28, 0x7d, 0xf1, 0xa4, 0x28, 0xfd, 0xe3, 0x49, 0x51, 0xfa, 0xf9, 0xd3, - 0xe2, 0xd0, 0x17, 0x4f, 0x8b, 0x43, 0x7f, 0x7b, 0x5a, 0x1c, 0xfa, 0xce, 0x62, 0x62, 0x7c, 0xc2, - 0xdd, 0x9e, 0xb5, 0xf4, 0x2d, 0x12, 0xc5, 0xb0, 0x7b, 0xee, 0x92, 0xfa, 0x41, 0x32, 0x12, 0x3a, - 0x52, 0xd9, 0x1a, 0xa5, 0xff, 0x8b, 0xe4, 0xfc, 0xff, 0x03, 0x00, 0x00, 0xff, 0xff, 0xf4, 0xc7, - 0xc3, 0x8a, 0xc3, 0x23, 0x00, 0x00, + // 2042 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x14, 0xd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 0x57, 0xb4, + 0xf7, 0x92, 0x9e, 0xb0, 0x95, 0xca, 0xc6, 0x08, 0xfb, 0x1f, 0x21, 0x17, 0xff, 0x17, 0x00, 0x00, + 0xff, 0xff, 0xce, 0xa9, 0xbc, 0x78, 0x8f, 0x23, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/superfluid/types/superfluid.pb.go b/x/superfluid/types/superfluid.pb.go index 49dd05e34e3..2de91cc4561 100644 --- a/x/superfluid/types/superfluid.pb.go +++ b/x/superfluid/types/superfluid.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" @@ -173,8 +173,8 @@ func (m *SuperfluidIntermediaryAccount) GetGaugeId() uint64 { type OsmoEquivalentMultiplierRecord struct { EpochNumber int64 `protobuf:"varint,1,opt,name=epoch_number,json=epochNumber,proto3" json:"epoch_number,omitempty"` // superfluid asset denom, can be LP token or native token - Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` - Multiplier github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=multiplier,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"multiplier" yaml:"multiplier"` + Denom string `protobuf:"bytes,2,opt,name=denom,proto3" json:"denom,omitempty"` + Multiplier cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=multiplier,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"multiplier" yaml:"multiplier"` } func (m *OsmoEquivalentMultiplierRecord) Reset() { *m = OsmoEquivalentMultiplierRecord{} } @@ -493,59 +493,59 @@ func init() { } var fileDescriptor_79d3c29d82dbb734 = []byte{ - // 818 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcf, 0x8f, 0xdb, 0x44, - 0x14, 0x8e, 0x93, 0x74, 0xb7, 0x99, 0x85, 0x92, 0xba, 0xab, 0x92, 0x44, 0x5a, 0x7b, 0x71, 0x11, - 0x8d, 0x5a, 0xd5, 0x56, 0x8a, 0x84, 0x44, 0x6f, 0x49, 0x0a, 0x52, 0x50, 0x29, 0x91, 0x43, 0x85, - 0xc4, 0xc5, 0x9a, 0x78, 0xa6, 0xce, 0x28, 0x63, 0x8f, 0xeb, 0x19, 0x07, 0x72, 0xe3, 0xc0, 0xa1, - 0x47, 0xfe, 0x84, 0x4a, 0xdc, 0xf8, 0x23, 0x38, 0xef, 0x71, 0x25, 0x2e, 0x88, 0xc3, 0x82, 0x76, - 0x2f, 0x9c, 0xf7, 0x2f, 0x40, 0x33, 0xfe, 0x11, 0xef, 0x6e, 0x56, 0xc0, 0x05, 0x4e, 0x99, 0x79, - 0xdf, 0x9b, 0xf7, 0xbe, 0x6f, 0xde, 0x97, 0x31, 0xb8, 0xc7, 0x78, 0xc8, 0x38, 0xe1, 0x0e, 0x4f, - 0x63, 0x9c, 0xbc, 0xa4, 0x29, 0x41, 0x95, 0xa5, 0x1d, 0x27, 0x4c, 0x30, 0x5d, 0xcf, 0x93, 0xec, - 0x0d, 0xd2, 0xdb, 0x0f, 0x58, 0xc0, 0x14, 0xec, 0xc8, 0x55, 0x96, 0xd9, 0x33, 0x02, 0xc6, 0x02, - 0x8a, 0x1d, 0xb5, 0x9b, 0xa7, 0x2f, 0x1d, 0x94, 0x26, 0x50, 0x10, 0x16, 0xe5, 0xb8, 0x79, 0x19, - 0x17, 0x24, 0xc4, 0x5c, 0xc0, 0x30, 0x2e, 0x0a, 0xf8, 0xaa, 0x97, 0x33, 0x87, 0x1c, 0x3b, 0xab, - 0xc1, 0x1c, 0x0b, 0x38, 0x70, 0x7c, 0x46, 0x8a, 0x02, 0xdd, 0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80, 0x09, 0x6e, 0x6b, - 0x7a, 0x1f, 0xbc, 0xbf, 0x05, 0xaf, 0xda, 0x27, 0xcb, 0xac, 0xf7, 0x9a, 0xaf, 0x7f, 0x34, 0x6a, - 0xa3, 0xe9, 0xd1, 0xa9, 0xa1, 0x1d, 0x9f, 0x1a, 0xda, 0x1f, 0xa7, 0x86, 0xf6, 0xc3, 0x99, 0x51, - 0x3b, 0x3e, 0x33, 0x6a, 0xbf, 0x9e, 0x19, 0xb5, 0xaf, 0x3f, 0xaa, 0x28, 0xcc, 0x47, 0xfb, 0x88, - 0xc2, 0x39, 0x2f, 0x36, 0xce, 0x6a, 0xf0, 0xb1, 0xf3, 0x6d, 0xf5, 0xe3, 0xa8, 0x54, 0xcf, 0x77, - 0xd4, 0x27, 0xe7, 0xc3, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x89, 0xd4, 0x63, 0x39, 0x3f, 0x07, - 0x00, 0x00, + // 831 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcf, 0x6f, 0x1b, 0x45, + 0x14, 0xf6, 0xda, 0x6e, 0xd2, 0x4c, 0xa0, 0xb8, 0xdb, 0xa8, 0x24, 0x41, 0xd9, 0x0d, 0x5b, 0xa4, + 0x5a, 0xad, 0xba, 0xab, 0x14, 0x09, 0x41, 0x6f, 0x4e, 0x0a, 0x92, 0x51, 0x28, 0xd6, 0x9a, 0x0a, + 0xc4, 0x65, 0x35, 0xde, 0x79, 0x5d, 0x8f, 0x3c, 0xbb, 0xb3, 0xdd, 0x99, 0x35, 0xf8, 0xc6, 0x81, + 0x43, 0x8f, 0xfc, 0x09, 0x95, 0xb8, 0x71, 0xe5, 0x9f, 0xe8, 0xb1, 0x12, 0x17, 0xc4, 0x21, 0xa0, + 0xe4, 0xc2, 0xb9, 0x7f, 0x01, 0x9a, 0xd9, 0x1f, 0xde, 0x34, 0x8e, 0x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 0x18, 0x84, 0x21, 0xcf, 0x93, 0xcb, 0x88, 0xec, 0xa0, 0xab, 0x73, 0xcc, 0x02, 0x4c, 0x48, + 0xa6, 0x69, 0x6c, 0xf8, 0xeb, 0x73, 0xcc, 0x06, 0x84, 0x64, 0x0a, 0x8a, 0x70, 0x1e, 0x41, 0x40, + 0xc9, 0x76, 0x67, 0xdf, 0xe8, 0x77, 0xfd, 0x75, 0xbd, 0x1f, 0x12, 0xe7, 0x57, 0x03, 0x59, 0x5f, + 0x8a, 0x98, 0x7f, 0xfa, 0x34, 0xa7, 0x73, 0xcc, 0x20, 0x91, 0x5f, 0xe4, 0x4c, 0xd2, 0x94, 0x51, + 0xc8, 0x7c, 0x08, 0x79, 0x46, 0xcc, 0xf7, 0xd1, 0x5b, 0x90, 0xf2, 0x70, 0x1a, 0x24, 0x79, 0x3c, + 0x81, 0x4c, 0x77, 0xed, 0xf8, 0x9b, 0x3a, 0xf6, 0x48, 0x87, 0x96, 0x8c, 0xda, 0x4d, 0x46, 0xdf, + 0x20, 0x14, 0xd7, 0xc5, 0x74, 0xe3, 0x8d, 0xc3, 0x8f, 0x5f, 0x9c, 0xd8, 0xad, 0x3f, 0x4e, 0xec, + 0xf7, 0x8a, 0xd1, 0x08, 0x32, 0x73, 0x29, 0xf7, 0x62, 0x2c, 0xa7, 0xee, 0x31, 0x44, 0x38, 0x5c, + 0x3c, 0x84, 0xf0, 0xd5, 0x89, 0x7d, 0x7d, 0x81, 0x63, 0xf6, 0xc0, 0x59, 0x1e, 0x77, 0xfc, 0x46, + 0x2d, 0xe7, 0x55, 0x1b, 0xed, 0x2e, 0xef, 0xe8, 0x21, 0x30, 0x88, 0xb4, 0x31, 0x4a, 0xc6, 0x77, + 0xd1, 0x75, 0x52, 0xc4, 0x78, 0xa6, 0x2f, 0x04, 0x84, 0x28, 0x2f, 0xab, 0x57, 0x03, 0x83, 0x22, + 0xae, 0x92, 0xe7, 0x98, 0x51, 0x72, 0x2e, 0xb9, 0xd0, 0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, 0xff, 0xff, 0x37, 0xcf, 0x5c, 0x79, 0x34, 0x07, 0x00, 0x00, } func (this *SuperfluidAsset) Equal(that interface{}) bool { diff --git a/x/superfluid/types/tx.pb.go b/x/superfluid/types/tx.pb.go index a195571d6e0..d34baaf83ee 100644 --- a/x/superfluid/types/tx.pb.go +++ b/x/superfluid/types/tx.pb.go @@ -5,6 +5,7 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" @@ -836,10 +837,10 @@ func (m *MsgUnlockAndMigrateSharesToFullRangeConcentratedPosition) GetTokenOutMi } type MsgUnlockAndMigrateSharesToFullRangeConcentratedPositionResponse struct { - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` - LiquidityCreated github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=liquidity_created,json=liquidityCreated,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"liquidity_created" yaml:"liquidity_created"` - JoinTime time.Time `protobuf:"bytes,4,opt,name=join_time,json=joinTime,proto3,stdtime" json:"join_time" yaml:"join_time"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount0"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount1"` + LiquidityCreated cosmossdk_io_math.LegacyDec `protobuf:"bytes,3,opt,name=liquidity_created,json=liquidityCreated,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"liquidity_created" yaml:"liquidity_created"` + JoinTime time.Time `protobuf:"bytes,4,opt,name=join_time,json=joinTime,proto3,stdtime" json:"join_time" yaml:"join_time"` } func (m *MsgUnlockAndMigrateSharesToFullRangeConcentratedPositionResponse) Reset() { @@ -960,14 +961,14 @@ func (m *MsgAddToConcentratedLiquiditySuperfluidPosition) GetTokenDesired1() typ } type MsgAddToConcentratedLiquiditySuperfluidPositionResponse struct { - PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` - Amount0 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount0" yaml:"amount0"` - Amount1 github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount1" yaml:"amount1"` + PositionId uint64 `protobuf:"varint,1,opt,name=position_id,json=positionId,proto3" json:"position_id,omitempty" yaml:"position_id"` + Amount0 cosmossdk_io_math.Int `protobuf:"bytes,2,opt,name=amount0,proto3,customtype=cosmossdk.io/math.Int" json:"amount0" yaml:"amount0"` + Amount1 cosmossdk_io_math.Int `protobuf:"bytes,3,opt,name=amount1,proto3,customtype=cosmossdk.io/math.Int" json:"amount1" yaml:"amount1"` // new_liquidity is the final liquidity after the add. // It includes the liquidity that existed before in the position // and the new liquidity that was added to the position. - NewLiquidity github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,5,opt,name=new_liquidity,json=newLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"new_liquidity" yaml:"new_liquidity"` - LockId uint64 `protobuf:"varint,4,opt,name=lock_id,json=lockId,proto3" json:"lock_id,omitempty" yaml:"lock_id"` + NewLiquidity cosmossdk_io_math.LegacyDec `protobuf:"bytes,5,opt,name=new_liquidity,json=newLiquidity,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"new_liquidity" yaml:"new_liquidity"` + LockId uint64 `protobuf:"varint,4,opt,name=lock_id,json=lockId,proto3" json:"lock_id,omitempty" yaml:"lock_id"` } func (m *MsgAddToConcentratedLiquiditySuperfluidPositionResponse) Reset() { @@ -1032,7 +1033,7 @@ type MsgUnbondConvertAndStake struct { // valset-preference module. ValAddr string `protobuf:"bytes,3,opt,name=val_addr,json=valAddr,proto3" json:"val_addr,omitempty"` // min_amt_to_stake indicates the minimum amount to stake after conversion - MinAmtToStake github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=min_amt_to_stake,json=minAmtToStake,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_amt_to_stake" yaml:"min_amt_to_stake"` + MinAmtToStake cosmossdk_io_math.Int `protobuf:"bytes,4,opt,name=min_amt_to_stake,json=minAmtToStake,proto3,customtype=cosmossdk.io/math.Int" json:"min_amt_to_stake" yaml:"min_amt_to_stake"` // shares_to_convert indicates shares wanted to stake. // Note that this field is only used for liquid(unlocked) gamm shares. // For all other cases, this field would be disregarded. @@ -1101,7 +1102,7 @@ func (m *MsgUnbondConvertAndStake) GetSharesToConvert() types.Coin { } type MsgUnbondConvertAndStakeResponse struct { - TotalAmtStaked github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=total_amt_staked,json=totalAmtStaked,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"total_amt_staked" yaml:"total_amt_staked"` + TotalAmtStaked cosmossdk_io_math.Int `protobuf:"bytes,1,opt,name=total_amt_staked,json=totalAmtStaked,proto3,customtype=cosmossdk.io/math.Int" json:"total_amt_staked" yaml:"total_amt_staked"` } func (m *MsgUnbondConvertAndStakeResponse) Reset() { *m = MsgUnbondConvertAndStakeResponse{} } @@ -1163,102 +1164,102 @@ func init() { func init() { proto.RegisterFile("osmosis/superfluid/tx.proto", fileDescriptor_55b645f187d22814) } var fileDescriptor_55b645f187d22814 = []byte{ - // 1507 bytes of a gzipped FileDescriptorProto + // 1519 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x6f, 0x13, 0x47, - 0x14, 0xcf, 0xda, 0x21, 0x81, 0x09, 0x09, 0xc9, 0x96, 0x0f, 0xe3, 0x82, 0x6d, 0x86, 0xaf, 0xf0, - 0x61, 0x6f, 0x0c, 0x2d, 0xd0, 0x9c, 0x88, 0x63, 0x51, 0x05, 0x12, 0x15, 0x2d, 0x41, 0x95, 0xb8, - 0x58, 0x6b, 0xcf, 0x64, 0xd9, 0x66, 0x77, 0xc7, 0xec, 0x8c, 0x93, 0xa0, 0x9e, 0xda, 0x1e, 0x2a, - 0x71, 0x42, 0xbd, 0xb4, 0xb7, 0x9e, 0xdb, 0x43, 0xc5, 0x3f, 0x50, 0xa9, 0x87, 0x1e, 0x50, 0x4f, - 0x1c, 0xab, 0x56, 0x0a, 0x15, 0x1c, 0x7a, 0xcf, 0xa5, 0xd7, 0x6a, 0x76, 0x67, 0xc7, 0xeb, 0x64, - 0x37, 0xce, 0x9a, 0xf4, 0xd0, 0x0b, 0x78, 0x67, 0xde, 0xbc, 0xf7, 0x7b, 0x1f, 0xbf, 0xf7, 0x66, - 0x02, 0xde, 0x27, 0xd4, 0x21, 0xd4, 0xa2, 0x1a, 0xed, 0xb4, 0xb1, 0xb7, 0x62, 0x77, 0x2c, 0xa4, - 0xb1, 0x8d, 0x4a, 0xdb, 0x23, 0x8c, 0xa8, 0xaa, 0xd8, 0xac, 0x74, 0x37, 0xf3, 0x47, 0x4d, 0x62, - 0x12, 0x7f, 0x5b, 0xe3, 0xbf, 0x02, 0xc9, 0xfc, 0x94, 0xe1, 0x58, 0x2e, 0xd1, 0xfc, 0x7f, 0xc5, - 0x52, 0xc1, 0x24, 0xc4, 0xb4, 0xb1, 0xe6, 0x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0xd5, 0x37, 0x84, 0xb4, 0xec, 0xda, 0x61, 0x4a, 0xeb, 0xca, 0x8e, 0x44, 0xd7, + 0xc1, 0xb8, 0xec, 0x48, 0x22, 0x24, 0x36, 0x3b, 0x86, 0xba, 0x12, 0xb9, 0xd9, 0x11, 0x35, 0xb0, + 0xe3, 0xb3, 0x23, 0x82, 0xfa, 0x80, 0xec, 0x38, 0x60, 0xba, 0x94, 0xef, 0x3f, 0x7f, 0x95, 0x93, + 0x5e, 0xbc, 0xca, 0x49, 0x7f, 0xbd, 0xca, 0x49, 0x4f, 0x5f, 0xe7, 0x46, 0x5e, 0xbc, 0xce, 0x8d, + 0xfc, 0xfe, 0x3a, 0x37, 0xf2, 0xc9, 0xed, 0xd0, 0xf4, 0x13, 0x92, 0x8b, 0x96, 0x5e, 0xa7, 0xfe, + 0x42, 0xdd, 0x2a, 0xbd, 0xa3, 0x6e, 0x77, 0xfd, 0xe8, 0xcc, 0x27, 0x62, 0x7d, 0xcc, 0xbd, 0xdf, + 0xdf, 0xfa, 0x37, 0x00, 0x00, 0xff, 0xff, 0x01, 0x69, 0x0d, 0xa8, 0x97, 0x16, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/tokenfactory/keeper/createdenom_test.go b/x/tokenfactory/keeper/createdenom_test.go index fe79a34b732..fb48ed50417 100644 --- a/x/tokenfactory/keeper/createdenom_test.go +++ b/x/tokenfactory/keeper/createdenom_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/tokenfactory/types" ) @@ -14,7 +15,7 @@ func (s *KeeperTestSuite) TestMsgCreateDenom() { var ( tokenFactoryKeeper = s.App.TokenFactoryKeeper bankKeeper = s.App.BankKeeper - denomCreationFee = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(1000000))) + denomCreationFee = sdk.NewCoins(sdk.NewCoin("uosmo", osmomath.NewInt(1000000))) ) // Set the denom creation fee. It is currently turned off in favor @@ -77,10 +78,10 @@ func (s *KeeperTestSuite) TestCreateDenom() { var ( primaryDenom = "uosmo" secondaryDenom = apptesting.SecondaryDenom - defaultDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(50000000)))} - twoDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(50000000)), sdk.NewCoin(secondaryDenom, sdk.NewInt(50000000)))} + defaultDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, osmomath.NewInt(50000000)))} + twoDenomCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, osmomath.NewInt(50000000)), sdk.NewCoin(secondaryDenom, osmomath.NewInt(50000000)))} nilCreationFee = types.Params{DenomCreationFee: nil} - largeCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, sdk.NewInt(5000000000)))} + largeCreationFee = types.Params{DenomCreationFee: sdk.NewCoins(sdk.NewCoin(primaryDenom, osmomath.NewInt(5000000000)))} ) for _, tc := range []struct { diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 8772e6d34db..d2307783fb1 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -23,6 +23,7 @@ import ( "github.com/spf13/cobra" abci "github.com/tendermint/tendermint/abci/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" simulation "github.com/osmosis-labs/osmosis/v19/x/tokenfactory/simulation" @@ -186,7 +187,7 @@ func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.Valid // GenerateGenesisState creates a randomized GenState of the tokenfactory module. func (am AppModule) SimulatorGenesisState(simState *module.SimulationState, s *simtypes.SimCtx) { tfDefaultGen := types.DefaultGenesis() - tfDefaultGen.Params.DenomCreationFee = sdk.NewCoins(sdk.NewCoin("stake", sdk.NewInt(10000000))) + tfDefaultGen.Params.DenomCreationFee = sdk.NewCoins(sdk.NewCoin("stake", osmomath.NewInt(10000000))) tfDefaultGenJson := simState.Cdc.MustMarshalJSON(tfDefaultGen) simState.GenState[types.ModuleName] = tfDefaultGenJson } diff --git a/x/tokenfactory/simulation/sim_msgs.go b/x/tokenfactory/simulation/sim_msgs.go index 1c7ed64409c..ca2e85b3462 100644 --- a/x/tokenfactory/simulation/sim_msgs.go +++ b/x/tokenfactory/simulation/sim_msgs.go @@ -5,6 +5,7 @@ import ( legacysimulationtype "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" "github.com/osmosis-labs/osmosis/v19/x/tokenfactory/keeper" @@ -43,7 +44,7 @@ func RandomMsgMintDenom(k keeper.Keeper, sim *simtypes.SimCtx, ctx sdk.Context) } // TODO: Replace with an improved rand exponential coin - mintAmount := sim.RandPositiveInt(sdk.NewIntFromUint64(1000_000000)) + mintAmount := sim.RandPositiveInt(osmomath.NewIntFromUint64(1000_000000)) return &types.MsgMint{ Sender: addr.String(), Amount: sdk.NewCoin(denom, mintAmount), diff --git a/x/tokenfactory/types/msgs.go b/x/tokenfactory/types/msgs.go index 9ee67c9a5eb..d4cd5dd05ea 100644 --- a/x/tokenfactory/types/msgs.go +++ b/x/tokenfactory/types/msgs.go @@ -5,6 +5,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" + + "github.com/osmosis-labs/osmosis/osmomath" ) // constants @@ -79,7 +81,7 @@ func (m MsgMint) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } - if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { + if !m.Amount.IsValid() || m.Amount.Amount.Equal(osmomath.ZeroInt()) { return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) } @@ -122,7 +124,7 @@ func (m MsgBurn) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sender address (%s)", err) } - if !m.Amount.IsValid() || m.Amount.Amount.Equal(sdk.ZeroInt()) { + if !m.Amount.IsValid() || m.Amount.Amount.Equal(osmomath.ZeroInt()) { return errorsmod.Wrap(sdkerrors.ErrInvalidCoins, m.Amount.String()) } diff --git a/x/tokenfactory/types/msgs_test.go b/x/tokenfactory/types/msgs_test.go index 15fc07611d5..9f7ba81009f 100644 --- a/x/tokenfactory/types/msgs_test.go +++ b/x/tokenfactory/types/msgs_test.go @@ -9,6 +9,7 @@ import ( "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/tokenfactory/types" + "github.com/osmosis-labs/osmosis/osmomath" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/tendermint/tendermint/crypto/ed25519" @@ -18,7 +19,7 @@ import ( func TestAuthzMsg(t *testing.T) { pk1 := ed25519.GenPrivKey().PubKey() addr1 := sdk.AccAddress(pk1.Address()).String() - coin := sdk.NewCoin("denom", sdk.NewInt(1)) + coin := sdk.NewCoin("denom", osmomath.NewInt(1)) testCases := []struct { name string @@ -136,7 +137,7 @@ func TestMsgMint(t *testing.T) { createMsg := func(after func(msg types.MsgMint) types.MsgMint) types.MsgMint { properMsg := *types.NewMsgMint( addr1.String(), - sdk.NewCoin("bitcoin", sdk.NewInt(500000000)), + sdk.NewCoin("bitcoin", osmomath.NewInt(500000000)), ) return after(properMsg) @@ -175,7 +176,7 @@ func TestMsgMint(t *testing.T) { { name: "zero amount", msg: createMsg(func(msg types.MsgMint) types.MsgMint { - msg.Amount = sdk.NewCoin("bitcoin", sdk.ZeroInt()) + msg.Amount = sdk.NewCoin("bitcoin", osmomath.ZeroInt()) return msg }), expectPass: false, @@ -183,7 +184,7 @@ func TestMsgMint(t *testing.T) { { name: "negative amount", msg: createMsg(func(msg types.MsgMint) types.MsgMint { - msg.Amount.Amount = sdk.NewInt(-10000000) + msg.Amount.Amount = osmomath.NewInt(-10000000) return msg }), expectPass: false, @@ -208,7 +209,7 @@ func TestMsgBurn(t *testing.T) { // make a proper burn message baseMsg := types.NewMsgBurn( addr1.String(), - sdk.NewCoin("bitcoin", sdk.NewInt(500000000)), + sdk.NewCoin("bitcoin", osmomath.NewInt(500000000)), ) // validate burn message was created as intended @@ -244,7 +245,7 @@ func TestMsgBurn(t *testing.T) { name: "zero amount", msg: func() *types.MsgBurn { msg := baseMsg - msg.Amount.Amount = sdk.ZeroInt() + msg.Amount.Amount = osmomath.ZeroInt() return msg }, expectPass: false, @@ -253,7 +254,7 @@ func TestMsgBurn(t *testing.T) { name: "negative amount", msg: func() *types.MsgBurn { msg := baseMsg - msg.Amount.Amount = sdk.NewInt(-10000000) + msg.Amount.Amount = osmomath.NewInt(-10000000) return msg }, expectPass: false, diff --git a/x/twap/README.md b/x/twap/README.md index f7bb71a4f96..300af43fc77 100644 --- a/x/twap/README.md +++ b/x/twap/README.md @@ -86,7 +86,7 @@ and have a similar cosmwasm binding. func (k Keeper) GetArithmeticTwap(ctx sdk.Context, poolId uint64, baseAssetDenom string, quoteAssetDenom string, - startTime time.Time, endTime time.Time) (sdk.Dec, error) { ... } + startTime time.Time, endTime time.Time) (osmomath.Dec, error) { ... } ``` There are convenience methods for `GetArithmeticTwapToNow` which sets `endTime = ctx.BlockTime()`, and has minor gas reduction. diff --git a/x/twap/api.go b/x/twap/api.go index 085c57d919c..e5d789453de 100644 --- a/x/twap/api.go +++ b/x/twap/api.go @@ -5,6 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/twap/types" ) @@ -41,7 +42,7 @@ func (k Keeper) GetArithmeticTwap( quoteAssetDenom string, startTime time.Time, endTime time.Time, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { return k.getTwap(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, endTime, k.GetArithmeticStrategy()) } @@ -52,7 +53,7 @@ func (k Keeper) GetGeometricTwap( quoteAssetDenom string, startTime time.Time, endTime time.Time, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { return k.getTwap(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, endTime, k.GetGeometricStrategy()) } @@ -64,7 +65,7 @@ func (k Keeper) GetArithmeticTwapToNow( baseAssetDenom string, quoteAssetDenom string, startTime time.Time, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { return k.getTwapToNow(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, k.GetArithmeticStrategy()) } @@ -74,7 +75,7 @@ func (k Keeper) GetGeometricTwapToNow( baseAssetDenom string, quoteAssetDenom string, startTime time.Time, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { return k.getTwapToNow(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, k.GetGeometricStrategy()) } @@ -88,22 +89,22 @@ func (k Keeper) getTwap( startTime time.Time, endTime time.Time, strategy twapStrategy, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { if startTime.After(endTime) { - return sdk.Dec{}, types.StartTimeAfterEndTimeError{StartTime: startTime, EndTime: endTime} + return osmomath.Dec{}, types.StartTimeAfterEndTimeError{StartTime: startTime, EndTime: endTime} } if endTime.Equal(ctx.BlockTime()) { return k.getTwapToNow(ctx, poolId, baseAssetDenom, quoteAssetDenom, startTime, strategy) } else if endTime.After(ctx.BlockTime()) { - return sdk.Dec{}, types.EndTimeInFutureError{EndTime: endTime, BlockTime: ctx.BlockTime()} + return osmomath.Dec{}, types.EndTimeInFutureError{EndTime: endTime, BlockTime: ctx.BlockTime()} } startRecord, err := k.getInterpolatedRecord(ctx, poolId, startTime, baseAssetDenom, quoteAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } endRecord, err := k.getInterpolatedRecord(ctx, poolId, endTime, baseAssetDenom, quoteAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return computeTwap(startRecord, endRecord, quoteAssetDenom, strategy) @@ -118,18 +119,18 @@ func (k Keeper) getTwapToNow( quoteAssetDenom string, startTime time.Time, strategy twapStrategy, -) (sdk.Dec, error) { +) (osmomath.Dec, error) { if startTime.After(ctx.BlockTime()) { - return sdk.Dec{}, types.StartTimeAfterEndTimeError{StartTime: startTime, EndTime: ctx.BlockTime()} + return osmomath.Dec{}, types.StartTimeAfterEndTimeError{StartTime: startTime, EndTime: ctx.BlockTime()} } startRecord, err := k.getInterpolatedRecord(ctx, poolId, startTime, baseAssetDenom, quoteAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } endRecord, err := k.GetBeginBlockAccumulatorRecord(ctx, poolId, baseAssetDenom, quoteAssetDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return computeTwap(startRecord, endRecord, quoteAssetDenom, strategy) diff --git a/x/twap/api_test.go b/x/twap/api_test.go index d31faff9c8b..8c09bcb33c3 100644 --- a/x/twap/api_test.go +++ b/x/twap/api_test.go @@ -23,26 +23,26 @@ var ( baseQuoteAB, baseQuoteCA = true, true baseQuoteBA, baseQuoteAC, baseQuoteCB = false, false, false - ThreePlusOneThird sdk.Dec = sdk.MustNewDecFromStr("3.333333333333333333") + ThreePlusOneThird osmomath.Dec = osmomath.MustNewDecFromStr("3.333333333333333333") // base record is a record with t=baseTime, sp0=10(sp1=0.1) accumulators set to 0 - baseRecord types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + baseRecord types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(baseTime, osmomath.NewDec(10), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec()) threeAssetRecordAB, threeAssetRecordAC, threeAssetRecordBC types.TwapRecord = newThreeAssetPoolTwapRecordWithDefaults( baseTime, - sdk.NewDec(10), // spot price 0 - sdk.ZeroDec(), // accum A - sdk.ZeroDec(), // accum B - sdk.ZeroDec(), // accum C - sdk.ZeroDec(), // geomAccum AB - sdk.ZeroDec(), // geomAccum AC - sdk.ZeroDec(), // geomAccum BC + osmomath.NewDec(10), // spot price 0 + osmomath.ZeroDec(), // accum A + osmomath.ZeroDec(), // accum B + osmomath.ZeroDec(), // accum C + osmomath.ZeroDec(), // geomAccum AB + osmomath.ZeroDec(), // geomAccum AC + osmomath.ZeroDec(), // geomAccum BC ) // accumA = 10 seconds * (spot price = 10) = OneSec * 10 * 10 // accumB = 10 seconds * (spot price = 0.1) = OneSec // accumC = 10 seconds * (spot price = 20) = OneSec * 10 * 20 - accumA, accumB, accumC sdk.Dec = OneSec.MulInt64(10 * 10), OneSec, OneSec.MulInt64(10 * 20) + accumA, accumB, accumC osmomath.Dec = OneSec.MulInt64(10 * 10), OneSec, OneSec.MulInt64(10 * 20) // geomAccumAB = 10 seconds * (log_{1.0001}{spot price = 10}) geomAccumAB = geometricTenSecAccum.MulInt64(10) @@ -54,31 +54,31 @@ var ( // t = baseTime + 10 // spA = 5, spB = 0.2, spC = 10 tPlus10sp5Record = newTwoAssetPoolTwapRecordWithDefaults( - baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB, geomAccumAB) + baseTime.Add(10*time.Second), osmomath.NewDec(5), accumA, accumB, geomAccumAB) tPlus10sp5ThreeAssetRecordAB, tPlus10sp5ThreeAssetRecordAC, tPlus10sp5ThreeAssetRecordBC = newThreeAssetPoolTwapRecordWithDefaults( - baseTime.Add(10*time.Second), sdk.NewDec(5), accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC) + baseTime.Add(10*time.Second), osmomath.NewDec(5), accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC) // accumulators updated from tPlus10sp5Record with // t = baseTime + 20 // spA = 2, spB = 0.5, spC = 4 tPlus20sp2Record = newTwoAssetPoolTwapRecordWithDefaults( baseTime.Add(20*time.Second), - sdk.NewDec(2), // spot price 0 + osmomath.NewDec(2), // spot price 0 OneSec.MulInt64(10*10+5*10), // accum A OneSec.MulInt64(3), // accum B - sdk.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct ) tPlus20sp2ThreeAssetRecordAB, tPlus20sp2ThreeAssetRecordAC, tPlus20sp2ThreeAssetRecordBC = newThreeAssetPoolTwapRecordWithDefaults( baseTime.Add(20*time.Second), - sdk.NewDec(2), // spot price 0 + osmomath.NewDec(2), // spot price 0 OneSec.MulInt64(10*10+5*10), // accum A OneSec.MulInt64(3), // accum B OneSec.MulInt64(20*10+10*10), // accum C - sdk.ZeroDec(), // TODO: choose correct - sdk.ZeroDec(), // TODO: choose correct - sdk.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct ) errSpotPrice = errors.New("twap: error in pool spot price occurred between start and end time, twap result may be faulty") @@ -86,11 +86,11 @@ var ( func (s *TestSuite) TestGetBeginBlockAccumulatorRecord() { poolId, denomA, denomB := s.setupDefaultPool() - initStartRecord := newRecord(poolId, s.Ctx.BlockTime(), sdk.OneDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + initStartRecord := newRecord(poolId, s.Ctx.BlockTime(), osmomath.OneDec(), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec()) initStartRecord.PoolId, initStartRecord.Height = poolId, s.Ctx.BlockHeight() initStartRecord.Asset0Denom, initStartRecord.Asset1Denom = denomB, denomA - zeroAccumTenPoint1Record := recordWithUpdatedSpotPrice(initStartRecord, sdk.NewDec(10), sdk.NewDecWithPrec(1, 1)) + zeroAccumTenPoint1Record := recordWithUpdatedSpotPrice(initStartRecord, osmomath.NewDec(10), osmomath.NewDecWithPrec(1, 1)) tests := map[string]struct { // if start record is blank, don't do any sets @@ -107,9 +107,9 @@ func (s *TestSuite) TestGetBeginBlockAccumulatorRecord() { "default record": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomB, nil}, "default record but same denom": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomA, fmt.Errorf("both assets cannot be of the same denom: assetA: %s, assetB: %s", denomA, denomA)}, "default record wrong order (should get reordered)": {initStartRecord, initStartRecord, baseTime, 1, denomB, denomA, nil}, - "one second later record": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, sdk.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, + "one second later record": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, osmomath.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, "idempotent overwrite": {initStartRecord, initStartRecord, baseTime, 1, denomA, denomB, nil}, - "idempotent overwrite2": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, sdk.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, + "idempotent overwrite2": {initStartRecord, recordWithUpdatedAccum(initStartRecord, OneSec, OneSec, osmomath.ZeroDec()), tPlusOne, 1, denomA, denomB, nil}, "diff spot price": { zeroAccumTenPoint1Record, recordWithUpdatedAccum(zeroAccumTenPoint1Record, OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum), @@ -181,7 +181,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet []types.TwapRecord ctxTime time.Time input getTwapInput - expTwap sdk.Dec + expTwap osmomath.Dec expectError error expectSpErr time.Time }{ @@ -189,49 +189,49 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record) start and end point to same record, use sp1": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteAB), - expTwap: sdk.NewDecWithPrec(1, 1), + expTwap: osmomath.NewDecWithPrec(1, 1), }, "(1 record) start and end point to same record, end time = now": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOneMin, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record) spot price error before start time": { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, tMinOne)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(2 record) start and end point to same record": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(2 record) start and end exact, different records": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, baseTime.Add(10*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(2 record) start exact, end after second record": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, baseTime.Add(20*time.Second), baseQuoteBA), - expTwap: sdk.NewDecWithPrec(75, 1), // 10 for 10s, 5 for 10s + expTwap: osmomath.NewDecWithPrec(75, 1), // 10 for 10s, 5 for 10s }, "(2 record) start exact, end after second record, sp1": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, baseTime.Add(20*time.Second), baseQuoteAB), - expTwap: sdk.NewDecWithPrec(15, 2), // .1 for 10s, .2 for 10s + expTwap: osmomath.NewDecWithPrec(15, 2), // .1 for 10s, .2 for 10s }, // start at 5 second after first twap record, end at 5 second after second twap record "(2 record) start and end interpolated": { @@ -246,39 +246,39 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(10*time.Second), baseTime.Add(10*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(5), + expTwap: osmomath.NewDec(5), }, "(3 record) start and end exactly at record times, different records": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(10*time.Second), baseTime.Add(20*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(5), + expTwap: osmomath.NewDec(5), }, "(3 record) start at second record, end after third record": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(10*time.Second), baseTime.Add(30*time.Second), baseQuoteBA), - expTwap: sdk.NewDecWithPrec(35, 1), // 5 for 10s, 2 for 10s + expTwap: osmomath.NewDecWithPrec(35, 1), // 5 for 10s, 2 for 10s }, "(3 record) start at second record, end after third record, sp1": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(10*time.Second), baseTime.Add(30*time.Second), baseQuoteAB), - expTwap: sdk.NewDecWithPrec(35, 2), // 0.2 for 10s, 0.5 for 10s + expTwap: osmomath.NewDecWithPrec(35, 2), // 0.2 for 10s, 0.5 for 10s }, // start in middle of first and second record, end in middle of second and third record "(3 record) interpolate: in between second and third record": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(15*time.Second), baseTime.Add(25*time.Second), baseQuoteBA), - expTwap: sdk.NewDecWithPrec(35, 1), // 5 for 5s, 2 for 5 = 35 / 10 = 3.5 + expTwap: osmomath.NewDecWithPrec(35, 1), // 5 for 5s, 2 for 5 = 35 / 10 = 3.5 }, // interpolate in time closer to second record "(3 record) interpolate: get twap closer to second record": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record, tPlus20sp2Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime.Add(15*time.Second), baseTime.Add(30*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(3), // 5 for 5s, 2 for 10s = 45 / 15 = 3 + expTwap: osmomath.NewDec(3), // 5 for 5s, 2 for 10s = 45 / 15 = 3 }, // error catching @@ -310,7 +310,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOneMin, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -318,7 +318,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(tPlusOne, tPlusOneMin, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -326,7 +326,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, tPlusOne)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOneMin, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -335,7 +335,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -343,7 +343,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, tPlusOne)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -352,7 +352,7 @@ func (s *TestSuite) TestGetArithmeticTwap() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, tPlusOneMin)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(baseTime, tPlusOne, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectError: errSpotPrice, expectSpErr: baseTime, }, @@ -384,7 +384,7 @@ func (s *TestSuite) TestGetArithmeticTwap_ThreeAsset() { recordsToSet []types.TwapRecord ctxTime time.Time input []getTwapInput - expTwap []sdk.Dec + expTwap []osmomath.Dec expectError error }{ "(2 pairs of 3 records) start exact, end after second record": { @@ -397,7 +397,7 @@ func (s *TestSuite) TestGetArithmeticTwap_ThreeAsset() { // A 10 for 10s, 5 for 10s = 150/20 = 7.5 // C 20 for 10s, 10 for 10s = 300/20 = 15 // B .1 for 10s, .2 for 10s = 3/20 = 0.15 - expTwap: []sdk.Dec{sdk.NewDecWithPrec(75, 1), sdk.NewDec(15), sdk.NewDecWithPrec(15, 2)}, + expTwap: []osmomath.Dec{osmomath.NewDecWithPrec(75, 1), osmomath.NewDec(15), osmomath.NewDecWithPrec(15, 2)}, }, "(3 pairs of 3 record) start at second record, end after third record": { recordsToSet: []types.TwapRecord{ @@ -410,7 +410,7 @@ func (s *TestSuite) TestGetArithmeticTwap_ThreeAsset() { // A 5 for 10s, 2 for 10s = 70/20 = 3.5 // C 10 for 10s, 4 for 10s = 140/20 = 7 // B .2 for 10s, .5 for 10s = 7/20 = 0.35 - expTwap: []sdk.Dec{sdk.NewDecWithPrec(35, 1), sdk.NewDec(7), sdk.NewDecWithPrec(35, 2)}, + expTwap: []osmomath.Dec{osmomath.NewDecWithPrec(35, 1), osmomath.NewDec(7), osmomath.NewDecWithPrec(35, 2)}, }, // interpolate in time closer to second record "(3 record) interpolate: get twap closer to second record": { @@ -424,7 +424,7 @@ func (s *TestSuite) TestGetArithmeticTwap_ThreeAsset() { // A 5 for 5s, 2 for 10s = 45/15 = 3 // C 10 for 5s, 4 for 10s = 140/15 = 6 // B .2 for 5s, .5 for 10s = 7/15 = .4 - expTwap: []sdk.Dec{sdk.NewDec(3), sdk.NewDec(6), sdk.NewDecWithPrec(4, 1)}, + expTwap: []osmomath.Dec{osmomath.NewDec(3), osmomath.NewDec(6), osmomath.NewDecWithPrec(4, 1)}, }, } for name, test := range tests { @@ -471,10 +471,10 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod() { oneHourAfterKeepThreshold = baseTimePlusKeepPeriod.Add(time.Hour) periodBetweenBaseAndOneHourBeforeThreshold = (defaultRecordHistoryKeepPeriod.Milliseconds() - time.Hour.Milliseconds()) - accumBeforeKeepThreshold0, accumBeforeKeepThreshold1 = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10) - geomAccumBeforeKeepThreshold = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold).Mul(logTen) + accumBeforeKeepThreshold0, accumBeforeKeepThreshold1 = osmomath.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), osmomath.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10) + geomAccumBeforeKeepThreshold = osmomath.NewDec(periodBetweenBaseAndOneHourBeforeThreshold).Mul(logTen) // recordBeforeKeepThreshold is a record with t=baseTime+keepPeriod-1h, sp0=30(sp1=0.3) accumulators set relative to baseRecord - recordBeforeKeepThreshold types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(oneHourBeforeKeepThreshold, sdk.NewDec(30), accumBeforeKeepThreshold0, accumBeforeKeepThreshold1, geomAccumBeforeKeepThreshold) + recordBeforeKeepThreshold types.TwapRecord = newTwoAssetPoolTwapRecordWithDefaults(oneHourBeforeKeepThreshold, osmomath.NewDec(30), accumBeforeKeepThreshold0, accumBeforeKeepThreshold1, geomAccumBeforeKeepThreshold) ) // N.B.: when ctxTime = end time, we trigger the "TWAP to now path". @@ -484,56 +484,56 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod() { recordsToSet []types.TwapRecord ctxTime time.Time input getTwapInput - expTwap sdk.Dec + expTwap osmomath.Dec expectError error }{ "(1 record at keep threshold); to now; ctxTime = at keep threshold; start time = end time = base keep threshold": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: baseTimePlusKeepPeriod, input: makeSimpleTwapInput(baseTimePlusKeepPeriod, baseTimePlusKeepPeriod, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record at keep threshold); with end time; ctxTime = at keep threshold; start time = end time = base keep threshold - 1ms": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: baseTimePlusKeepPeriod, input: makeSimpleTwapInput(baseTimePlusKeepPeriod.Add(-time.Millisecond), baseTimePlusKeepPeriod.Add(-time.Millisecond), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record younger than keep threshold); to now; ctxTime = start time = end time = after keep threshold": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(oneHourAfterKeepThreshold, oneHourAfterKeepThreshold, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record younger than keep threshold); with end time; ctxTime = start time = end time = after keep threshold - 1ms": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(oneHourAfterKeepThreshold.Add(-time.Millisecond), oneHourAfterKeepThreshold.Add(-time.Millisecond), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record older than keep threshold); to now; ctxTime = baseTime, start time = end time = before keep threshold": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourBeforeKeepThreshold, input: makeSimpleTwapInput(oneHourBeforeKeepThreshold, oneHourBeforeKeepThreshold, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record older than keep threshold); with end time; ctxTime = baseTime, start time = end time = before keep threshold - 1ms": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourBeforeKeepThreshold, input: makeSimpleTwapInput(oneHourBeforeKeepThreshold.Add(-time.Millisecond), oneHourBeforeKeepThreshold.Add(-time.Millisecond), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record older than keep threshold); to now; ctxTime = after keep threshold, start time = before keep threshold; end time = after keep threshold": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(oneHourBeforeKeepThreshold, oneHourAfterKeepThreshold, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record older than keep threshold); with end time; ctxTime = after keep threshold, start time = before keep threshold; end time = after keep threshold - 1ms": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(oneHourBeforeKeepThreshold, oneHourAfterKeepThreshold.Add(-time.Millisecond), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record at keep threshold); to now; ctxTime = base keep threshold, start time = base time - 1ms (source of error); end time = base keep threshold; error": { recordsToSet: []types.TwapRecord{baseRecord}, @@ -552,28 +552,28 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod() { ctxTime: baseTimePlusKeepPeriod, input: makeSimpleTwapInput(baseTime, baseTimePlusKeepPeriod, baseQuoteBA), // expTwap: = (10 * (172800s - 3600s) + 30 * 3600s) / 172800s = 10.416666666666666666 - expTwap: sdk.MustNewDecFromStr("10.416666666666666666"), + expTwap: osmomath.MustNewDecFromStr("10.416666666666666666"), }, "(2 records); with end time; with one directly at threshold, interpolated": { recordsToSet: []types.TwapRecord{baseRecord, recordBeforeKeepThreshold}, ctxTime: baseTimePlusKeepPeriod.Add(time.Millisecond), input: makeSimpleTwapInput(baseTime, baseTimePlusKeepPeriod.Add(-time.Millisecond), baseQuoteBA), // expTwap: = (10 * (172800000ms - 3600000ms) + 30 * 3599999ms) / 172799999ms approx = 10.41666655333719 - expTwap: sdk.MustNewDecFromStr("10.416666553337190702"), + expTwap: osmomath.MustNewDecFromStr("10.416666553337190702"), }, "(2 records); to now; with one before keep threshold, interpolated": { recordsToSet: []types.TwapRecord{baseRecord, recordBeforeKeepThreshold}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(baseTime, oneHourAfterKeepThreshold, baseQuoteBA), // expTwap: = (10 * (172800s - 3600s) + 30 * 3600s * 2) / (172800s + 3600s) approx = 10.816326530612244 - expTwap: sdk.MustNewDecFromStr("10.816326530612244897"), + expTwap: osmomath.MustNewDecFromStr("10.816326530612244897"), }, "(2 records); with end time; with one before keep threshold, interpolated": { recordsToSet: []types.TwapRecord{baseRecord, recordBeforeKeepThreshold}, ctxTime: oneHourAfterKeepThreshold, input: makeSimpleTwapInput(baseTime, oneHourAfterKeepThreshold.Add(-time.Millisecond), baseQuoteBA), // expTwap: = (10 * (172800000ms - 3600000ms) + 30 * (3600000ms + 3599999ms)) / (172800000ms + 3599999ms) approx = 10.81632642186126 - expTwap: sdk.MustNewDecFromStr("10.816326421861260894"), + expTwap: osmomath.MustNewDecFromStr("10.816326421861260894"), }, } @@ -583,7 +583,7 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod() { s.preSetRecords(test.recordsToSet) s.Ctx = s.Ctx.WithBlockTime(test.ctxTime) - var twap sdk.Dec + var twap osmomath.Dec var err error twap, err = s.twapkeeper.GetArithmeticTwap(s.Ctx, test.input.poolId, @@ -609,17 +609,17 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod_ThreeAsset() { oneHourAfterKeepThreshold = baseTimePlusKeepPeriod.Add(time.Hour) periodBetweenBaseAndOneHourBeforeThreshold = (defaultRecordHistoryKeepPeriod.Milliseconds() - time.Hour.Milliseconds()) - accumBeforeKeepThresholdA, accumBeforeKeepThresholdB, accumBeforeKeepThresholdC = sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), sdk.NewDecWithPrec(1, 1).MulInt64(periodBetweenBaseAndOneHourBeforeThreshold), sdk.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 20) + accumBeforeKeepThresholdA, accumBeforeKeepThresholdB, accumBeforeKeepThresholdC = osmomath.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 10), osmomath.NewDecWithPrec(1, 1).MulInt64(periodBetweenBaseAndOneHourBeforeThreshold), osmomath.NewDec(periodBetweenBaseAndOneHourBeforeThreshold * 20) // recordBeforeKeepThreshold is a record with t=baseTime+keepPeriod-1h, spA=30(spB=0.3)(spC=60) accumulators set relative to baseRecord recordBeforeKeepThresholdAB, recordBeforeKeepThresholdAC, recordBeforeKeepThresholdBC = newThreeAssetPoolTwapRecordWithDefaults( oneHourBeforeKeepThreshold, - sdk.NewDec(30), + osmomath.NewDec(30), accumBeforeKeepThresholdA, accumBeforeKeepThresholdB, accumBeforeKeepThresholdC, - sdk.ZeroDec(), // TODO: choose correct - sdk.ZeroDec(), // TODO: choose correct - sdk.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct + osmomath.ZeroDec(), // TODO: choose correct ) ) @@ -627,7 +627,7 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod_ThreeAsset() { recordsToSet []types.TwapRecord ctxTime time.Time input []getTwapInput - expTwap []sdk.Dec + expTwap []osmomath.Dec expectError error }{ "(2 sets of 3 records); to now; with one directly at threshold, interpolated": { @@ -640,7 +640,7 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod_ThreeAsset() { // A 10 for 169200s, 30 for 3600s = 1800000/172800 = 10.416666 // C 20 for 169200s, 60 for 3600s = 100/172800 = 20.83333333 // B .1 for 169200s, .033 for 3600s = 17040/172800 = 0.0986111 - expTwap: []sdk.Dec{sdk.MustNewDecFromStr("10.416666666666666666"), sdk.MustNewDecFromStr("20.833333333333333333"), sdk.MustNewDecFromStr("0.098611111111111111")}, + expTwap: []osmomath.Dec{osmomath.MustNewDecFromStr("10.416666666666666666"), osmomath.MustNewDecFromStr("20.833333333333333333"), osmomath.MustNewDecFromStr("0.098611111111111111")}, }, "(2 sets of 3 records); with end time; with one before keep threshold, interpolated": { recordsToSet: []types.TwapRecord{ @@ -652,7 +652,7 @@ func (s *TestSuite) TestGetArithmeticTwap_PruningRecordKeepPeriod_ThreeAsset() { // A 10 for 169200000ms, 30 for 7199999ms = 1907999970/176399999 = 10.81632642 // C 20 for 169200000ms, 60 for 7199999ms = 3815999940/176399999 = 21.6326528 // B .1 for 169200000ms, .033 for 7199999ms = 17159999/176399999 = 0.09727891 - expTwap: []sdk.Dec{sdk.MustNewDecFromStr("10.816326421861260894"), sdk.MustNewDecFromStr("21.632652843722521789"), sdk.MustNewDecFromStr("0.097278911927129130")}, + expTwap: []osmomath.Dec{osmomath.MustNewDecFromStr("10.816326421861260894"), osmomath.MustNewDecFromStr("21.632652843722521789"), osmomath.MustNewDecFromStr("0.097278911927129130")}, }, } @@ -695,38 +695,38 @@ func (s *TestSuite) TestGetArithmeticTwapToNow() { recordsToSet []types.TwapRecord ctxTime time.Time input getTwapInput - expTwap sdk.Dec + expTwap osmomath.Dec expectedError error }{ "(1 record) start time = record time": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapToNowInput(baseTime, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(1 record) start time = record time, use sp1": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapToNowInput(baseTime, baseQuoteAB), - expTwap: sdk.NewDecWithPrec(1, 1), + expTwap: osmomath.NewDecWithPrec(1, 1), }, "(1 record) to_now: start time > record time": { recordsToSet: []types.TwapRecord{baseRecord}, ctxTime: tPlusOneMin, input: makeSimpleTwapToNowInput(baseTime.Add(10*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "(2 record) to now: start time = second record time": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapToNowInput(baseTime.Add(10*time.Second), baseQuoteBA), - expTwap: sdk.NewDec(5), // 10 for 0s, 5 for 10s + expTwap: osmomath.NewDec(5), // 10 for 0s, 5 for 10s }, "(2 record) to now: start time = second record time, use sp1": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, ctxTime: tPlusOneMin, input: makeSimpleTwapToNowInput(baseTime.Add(10*time.Second), baseQuoteAB), - expTwap: sdk.NewDecWithPrec(2, 1), + expTwap: osmomath.NewDecWithPrec(2, 1), }, "(2 record) first record time < start time < second record time": { recordsToSet: []types.TwapRecord{baseRecord, tPlus10sp5Record}, @@ -753,7 +753,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow() { recordsToSet: []types.TwapRecord{withLastErrTime(baseRecord, baseTime)}, ctxTime: tPlusOneMin, input: makeSimpleTwapInput(tPlusOne, tPlusOneMin, baseQuoteBA), - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), expectedError: errSpotPrice, }, } @@ -763,7 +763,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow() { s.preSetRecords(test.recordsToSet) s.Ctx = s.Ctx.WithBlockTime(test.ctxTime) - var twap sdk.Dec + var twap osmomath.Dec var err error // test the values of `GetArithmeticTwapToNow` if bool in test field is true @@ -791,7 +791,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow_ThreeAsset() { recordsToSet []types.TwapRecord ctxTime time.Time input []getTwapInput - expTwap []sdk.Dec + expTwap []osmomath.Dec expectedError error }{ "(2 pairs of 3 records) to now: start time = second record time": { @@ -804,7 +804,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow_ThreeAsset() { // A 10 for 0s, 5 for 10s = 50/10 = 5 // C 20 for 0s, 10 for 10s = 100/10 = 10 // B .1 for 0s, .2 for 10s = 2/10 = 0.2 - expTwap: []sdk.Dec{sdk.NewDec(5), sdk.NewDec(10), sdk.NewDecWithPrec(2, 1)}, + expTwap: []osmomath.Dec{osmomath.NewDec(5), osmomath.NewDec(10), osmomath.NewDecWithPrec(2, 1)}, }, "(2 pairs of 3 records) first record time < start time < second record time": { recordsToSet: []types.TwapRecord{ @@ -816,7 +816,7 @@ func (s *TestSuite) TestGetArithmeticTwapToNow_ThreeAsset() { // A 10 for 5s, 5 for 10s = 100/15 = 6 + 2/3 = 6.66666666 // C 20 for 5s, 10 for 10s = 200/15 = 13 + 1/3 = 13.333333 // B .1 for 5s, .2 for 10s = 2.5/15 = 0.1666666 - expTwap: []sdk.Dec{ThreePlusOneThird.MulInt64(2), sdk.MustNewDecFromStr("13.333333333333333333"), sdk.MustNewDecFromStr("0.166666666666666666")}, + expTwap: []osmomath.Dec{ThreePlusOneThird.MulInt64(2), osmomath.MustNewDecFromStr("13.333333333333333333"), osmomath.MustNewDecFromStr("0.166666666666666666")}, }, } for name, test := range tests { @@ -854,11 +854,11 @@ func (s *TestSuite) TestGeometricTwapToNow_BalancerPool_Randomized() { for i := 0; i < retries; i++ { elapsedTimeMs := sdkrand.RandIntBetween(r, 1, int(maxUint64>>1)) - weightA := sdk.NewInt(int64(sdkrand.RandIntBetween(r, 1, 1000))) - tokenASupply := sdk.NewInt(int64(sdkrand.RandIntBetween(r, 10_000, 1_000_000_000_000_000_000))) + weightA := osmomath.NewInt(int64(sdkrand.RandIntBetween(r, 1, 1000))) + tokenASupply := osmomath.NewInt(int64(sdkrand.RandIntBetween(r, 10_000, 1_000_000_000_000_000_000))) - tokenBSupply := sdk.NewInt(int64(sdkrand.RandIntBetween(r, 10_000, 1_000_000_000_000_000_000))) - weightB := sdk.NewInt(int64(sdkrand.RandIntBetween(r, 1, 1000))) + tokenBSupply := osmomath.NewInt(int64(sdkrand.RandIntBetween(r, 10_000, 1_000_000_000_000_000_000))) + weightB := osmomath.NewInt(int64(sdkrand.RandIntBetween(r, 1, 1000))) s.Run(fmt.Sprintf("elapsedTimeMs=%d, weightA=%d, tokenASupply=%d, weightB=%d, tokenBSupply=%d", elapsedTimeMs, weightA, tokenASupply, weightB, tokenBSupply), func() { s.SetupTest() @@ -878,8 +878,8 @@ func (s *TestSuite) TestGeometricTwapToNow_BalancerPool_Randomized() { } s.PrepareCustomBalancerPool(assets, balancer.PoolParams{ - SwapFee: sdk.ZeroDec(), - ExitFee: sdk.ZeroDec(), + SwapFee: osmomath.ZeroDec(), + ExitFee: osmomath.ZeroDec(), }) // We add 1ms to avoid always landing on the same block time @@ -897,10 +897,10 @@ func (s *TestSuite) TestGeometricTwapToNow_BalancerPool_Randomized() { s.Require().NoError(err) osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.SmallestDec(), + MultiplicativeTolerance: osmomath.SmallestDec(), }.CompareBigDec( - osmomath.BigDecFromSDKDec(spotPrice), - osmomath.BigDecFromSDKDec(twap), + osmomath.BigDecFromDec(spotPrice), + osmomath.BigDecFromDec(twap), ) }) } diff --git a/x/twap/client/query_proto_wrap_test.go b/x/twap/client/query_proto_wrap_test.go index 3fc97997cc9..7ec0aae7ca9 100644 --- a/x/twap/client/query_proto_wrap_test.go +++ b/x/twap/client/query_proto_wrap_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/twap/client" "github.com/osmosis-labs/osmosis/v19/x/twap/client/queryproto" @@ -87,7 +88,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenB", endTime: &newBlockTime, - result: sdk.NewDec(2).String(), + result: osmomath.NewDec(2).String(), }, { name: "tokenB in terms of tokenA", @@ -96,7 +97,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenA", endTime: &newBlockTime, - result: sdk.NewDecWithPrec(5, 1).String(), + result: osmomath.NewDecWithPrec(5, 1).String(), }, { name: "tokenC in terms of tokenD (rounded decimal of 4/3)", @@ -105,7 +106,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenD", endTime: &newBlockTime, - result: sdk.MustNewDecFromStr("1.333333330000000000").String(), + result: osmomath.MustNewDecFromStr("1.333333330000000000").String(), }, { name: "tokenB in terms of tokenC (rounded decimal of 2/3)", @@ -113,8 +114,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { baseAssetDenom: "tokenC", quoteAssetDenom: "tokenB", endTime: &newBlockTime, - - result: sdk.MustNewDecFromStr("0.666666670000000000").String(), + result: osmomath.MustNewDecFromStr("0.666666670000000000").String(), }, { name: "tokenD in terms of tokenE (1)", @@ -123,7 +123,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenE", endTime: &newBlockTime, - result: sdk.OneDec().String(), + result: osmomath.OneDec().String(), }, { name: "tokenA in terms of tokenB - no end time", @@ -132,7 +132,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenB", endTime: nil, - result: sdk.NewDec(2).String(), + result: osmomath.NewDec(2).String(), }, { name: "tokenA in terms of tokenB - end time is empty", @@ -141,7 +141,7 @@ func (suite *QueryTestSuite) TestQueryTwap() { quoteAssetDenom: "tokenB", endTime: &time.Time{}, - result: sdk.NewDec(2).String(), + result: osmomath.NewDec(2).String(), }, { name: "tokenA in terms of tokenB - start time too old", diff --git a/x/twap/client/queryproto/query.pb.go b/x/twap/client/queryproto/query.pb.go index 774577f2d88..2e0e02bcb49 100644 --- a/x/twap/client/queryproto/query.pb.go +++ b/x/twap/client/queryproto/query.pb.go @@ -5,11 +5,11 @@ package queryproto import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" @@ -116,7 +116,7 @@ func (m *ArithmeticTwapRequest) GetEndTime() *time.Time { } type ArithmeticTwapResponse struct { - ArithmeticTwap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=arithmetic_twap,json=arithmeticTwap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"arithmetic_twap" yaml:"arithmetic_twap"` + ArithmeticTwap cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=arithmetic_twap,json=arithmeticTwap,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"arithmetic_twap" yaml:"arithmetic_twap"` } func (m *ArithmeticTwapResponse) Reset() { *m = ArithmeticTwapResponse{} } @@ -221,7 +221,7 @@ func (m *ArithmeticTwapToNowRequest) GetStartTime() time.Time { } type ArithmeticTwapToNowResponse struct { - ArithmeticTwap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=arithmetic_twap,json=arithmeticTwap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"arithmetic_twap" yaml:"arithmetic_twap"` + ArithmeticTwap cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=arithmetic_twap,json=arithmeticTwap,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"arithmetic_twap" yaml:"arithmetic_twap"` } func (m *ArithmeticTwapToNowResponse) Reset() { *m = ArithmeticTwapToNowResponse{} } @@ -334,7 +334,7 @@ func (m *GeometricTwapRequest) GetEndTime() *time.Time { } type GeometricTwapResponse struct { - GeometricTwap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=geometric_twap,json=geometricTwap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"geometric_twap" yaml:"geometric_twap"` + GeometricTwap cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=geometric_twap,json=geometricTwap,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"geometric_twap" yaml:"geometric_twap"` } func (m *GeometricTwapResponse) Reset() { *m = GeometricTwapResponse{} } @@ -439,7 +439,7 @@ func (m *GeometricTwapToNowRequest) GetStartTime() time.Time { } type GeometricTwapToNowResponse struct { - GeometricTwap github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=geometric_twap,json=geometricTwap,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"geometric_twap" yaml:"geometric_twap"` + GeometricTwap cosmossdk_io_math.LegacyDec `protobuf:"bytes,1,opt,name=geometric_twap,json=geometricTwap,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"geometric_twap" yaml:"geometric_twap"` } func (m *GeometricTwapToNowResponse) Reset() { *m = GeometricTwapToNowResponse{} } @@ -571,57 +571,58 @@ func init() { func init() { proto.RegisterFile("osmosis/twap/v1beta1/query.proto", fileDescriptor_141a22dba58615af) } var fileDescriptor_141a22dba58615af = []byte{ - // 800 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x96, 0x41, 0x4f, 0x1b, 0x47, - 0x14, 0xc7, 0x3d, 0x2e, 0x98, 0x7a, 0x10, 0x46, 0x9d, 0x02, 0x85, 0x05, 0x76, 0xad, 0x85, 0x22, - 0x17, 0xc3, 0x2e, 0xa6, 0xa7, 0xa2, 0x5e, 0xb0, 0x2a, 0xd1, 0x4a, 0x55, 0xd5, 0xae, 0x50, 0x55, - 0xf5, 0x62, 0x8d, 0xed, 0xc9, 0xb2, 0x8a, 0x77, 0x67, 0xbd, 0x3b, 0x86, 0xf8, 0x9a, 0x4b, 0x0e, - 0xc9, 0x01, 0x25, 0xca, 0x21, 0x87, 0xe4, 0x9e, 0x43, 0xbe, 0x07, 0xa7, 0x04, 0x29, 0x97, 0x28, - 0x07, 0x27, 0x82, 0x7c, 0x02, 0x3e, 0x41, 0xb4, 0x33, 0xb3, 0x8e, 0xd7, 0x59, 0x11, 0x73, 0x42, - 0x48, 0x39, 0x99, 0x79, 0xef, 0xff, 0xde, 0xfb, 0xcd, 0x9b, 0x7d, 0x33, 0xc0, 0x22, 0x0d, 0x5d, - 0x1a, 0x3a, 0xa1, 0xc9, 0x8e, 0xb0, 0x6f, 0x1e, 0x56, 0xea, 0x84, 0xe1, 0x8a, 0xd9, 0xee, 0x90, - 0xa0, 0x6b, 0xf8, 0x01, 0x65, 0x14, 0xcd, 0x48, 0x85, 0x11, 0x29, 0x0c, 0xa9, 0x50, 0x66, 0x6c, - 0x6a, 0x53, 0x2e, 0x30, 0xa3, 0xbf, 0x84, 0x56, 0x59, 0x4b, 0xcd, 0x16, 0x2d, 0x6a, 0x01, 0x69, - 0xd0, 0x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 0x58, 0x21, 0x73, 0x84, 0x82, 0x89, 0x2e, 0x6e, 0x8d, 0x1e, 0x20, 0x31, - 0xb7, 0x38, 0xe6, 0x3a, 0x2a, 0x8d, 0x80, 0xc9, 0x23, 0xab, 0xff, 0x9e, 0x9c, 0xa9, 0xe0, 0xf4, - 0x4c, 0x05, 0xef, 0xcf, 0x54, 0x70, 0x7c, 0xae, 0x66, 0x4e, 0xcf, 0xd5, 0xcc, 0x9b, 0x73, 0x35, - 0xf3, 0xff, 0xaf, 0x03, 0xd3, 0x2d, 0xb3, 0x6d, 0xb6, 0x70, 0x3d, 0xec, 0xa7, 0x3e, 0xac, 0xfc, - 0x62, 0xde, 0x11, 0x05, 0x1a, 0x2d, 0x87, 0x78, 0x4c, 0xfc, 0xcb, 0x29, 0x6e, 0xa4, 0x1c, 0xff, - 0xf9, 0xf9, 0x63, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1e, 0xc0, 0xd5, 0xb1, 0x4d, 0x0b, 0x00, 0x00, + // 801 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x96, 0x41, 0x4f, 0xe3, 0x46, + 0x14, 0xc7, 0x33, 0x29, 0x84, 0x66, 0x10, 0x41, 0x9d, 0x02, 0x05, 0x03, 0x76, 0x64, 0x28, 0x4a, + 0x09, 0xb5, 0x09, 0x3d, 0x15, 0xd1, 0x03, 0x51, 0xa5, 0xaa, 0x12, 0xaa, 0x5a, 0x0b, 0x55, 0x55, + 0x2f, 0xd1, 0xc4, 0x19, 0x8c, 0xd5, 0xd8, 0x63, 0xec, 0x09, 0x34, 0x52, 0x0f, 0x6d, 0xa5, 0xde, + 0x51, 0xab, 0x1e, 0x7a, 0x68, 0xef, 0x3d, 0xec, 0xf7, 0xe0, 0xb4, 0x8b, 0xb4, 0x97, 0xd5, 0x1e, + 0xb2, 0x2b, 0xd8, 0x4f, 0xc0, 0x27, 0x58, 0x79, 0x66, 0x9c, 0x8d, 0xb3, 0x16, 0xeb, 0xbd, 0x20, + 0x21, 0xed, 0x09, 0x66, 0xde, 0xff, 0xbd, 0xff, 0x6f, 0xde, 0x8c, 0x67, 0x02, 0xab, 0x34, 0xf2, + 0x68, 0xe4, 0x46, 0x26, 0x3b, 0xc3, 0x81, 0x79, 0xda, 0x68, 0x13, 0x86, 0x1b, 0xe6, 0x49, 0x8f, + 0x84, 0x7d, 0x23, 0x08, 0x29, 0xa3, 0x68, 0x4e, 0x2a, 0x8c, 0x58, 0x61, 0x48, 0x85, 0x32, 0xe7, + 0x50, 0x87, 0x72, 0x81, 0x19, 0xff, 0x27, 0xb4, 0xca, 0x46, 0x66, 0xb5, 0x78, 0xd0, 0x0a, 0x89, + 0x4d, 0xc3, 0x8e, 0xd4, 0xe9, 0x99, 0x3a, 0x87, 0xf8, 0x24, 0x36, 0x12, 0x1a, 0xd5, 0xe6, 0x22, + 0xb3, 0x8d, 0x23, 0x32, 0x94, 0xd8, 0xd4, 0xf5, 0x65, 0x7c, 0x73, 0x34, 0xce, 0x81, 0x87, 0xaa, + 0x00, 0x3b, 0xae, 0x8f, 0x99, 0x4b, 0x13, 0xed, 0x8a, 0x43, 0xa9, 0xd3, 0x25, 0x26, 0x0e, 0x5c, + 0x13, 0xfb, 0x3e, 0x65, 0x3c, 0x98, 0x38, 0x2d, 0xc9, 0x28, 0x1f, 0xb5, 0x7b, 0x47, 0x26, 0xf6, + 0xfb, 0x49, 0x48, 0x98, 0xb4, 0xc4, 0x4a, 0xc5, 0x40, 0x86, 0xb4, 0xf1, 0x2c, 0xe6, 0x7a, 0x24, + 0x62, 0xd8, 0x0b, 0x84, 0x40, 0xff, 0xaf, 0x08, 0xe7, 0xf7, 0x43, 0x97, 0x1d, 0x7b, 0x84, 0xb9, + 0xf6, 0xe1, 0x19, 0x0e, 0x2c, 0x72, 0xd2, 0x23, 0x11, 0x43, 0x1f, 0xc1, 0xa9, 0x80, 0xd2, 0x6e, + 0xcb,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 0xb4, 0x81, + 0xd6, 0xb3, 0x99, 0xc6, 0x40, 0x1e, 0x00, 0xf8, 0x61, 0xc6, 0xd5, 0x87, 0xb6, 0xf3, 0x78, 0x8e, + 0x7e, 0x00, 0x4a, 0xe3, 0x2d, 0x32, 0x24, 0x6a, 0x83, 0xa3, 0xd6, 0xd1, 0x27, 0x79, 0x50, 0x05, + 0xd7, 0xdf, 0x00, 0xce, 0xa4, 0xce, 0x2c, 0xda, 0xcc, 0xf6, 0xcd, 0xba, 0x47, 0x95, 0x7a, 0x2e, + 0xad, 0xa4, 0xab, 0x73, 0xba, 0x8f, 0xd1, 0x5a, 0x36, 0x5d, 0x9a, 0xe2, 0x7f, 0x00, 0xd1, 0xeb, + 0xdf, 0x12, 0x32, 0x73, 0x18, 0xa6, 0xba, 0xb8, 0x9d, 0x3f, 0x41, 0x62, 0x6e, 0x73, 0xcc, 0x4d, + 0x54, 0xcb, 0x81, 0xc9, 0x33, 0x9b, 0xdf, 0x5f, 0x5c, 0xa9, 0xe0, 0xf2, 0x4a, 0x05, 0xcf, 0xaf, + 0x54, 0x70, 0x7e, 0xad, 0x16, 0x2e, 0xaf, 0xd5, 0xc2, 0x93, 0x6b, 0xb5, 0xf0, 0xe3, 0x9e, 0xe3, + 0xb2, 0xe3, 0x5e, 0xdb, 0xb0, 0xa9, 0x97, 0x54, 0xfb, 0xb4, 0x8b, 0xdb, 0xd1, 0xb0, 0xf4, 0x69, + 0xe3, 0x73, 0xf3, 0x67, 0x61, 0x60, 0x77, 0x5d, 0xe2, 0x33, 0xf1, 0x2b, 0x52, 0x5c, 0x43, 0x25, + 0xfe, 0xe7, 0xb3, 0x97, 0x01, 0x00, 0x00, 0xff, 0xff, 0xed, 0x44, 0x7a, 0xab, 0x20, 0x0b, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/twap/export_test.go b/x/twap/export_test.go index bd2a05f86e5..5e05bd21fa3 100644 --- a/x/twap/export_test.go +++ b/x/twap/export_test.go @@ -52,15 +52,15 @@ func (k Keeper) GetInterpolatedRecord(ctx sdk.Context, poolId uint64, asset0Deno return k.getInterpolatedRecord(ctx, poolId, t, asset0Denom, asset1Denom) } -func ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, strategy twapStrategy) (sdk.Dec, error) { +func ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, strategy twapStrategy) (osmomath.Dec, error) { return computeTwap(startRecord, endRecord, quoteAsset, strategy) } -func (as arithmetic) ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { +func (as arithmetic) ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) osmomath.Dec { return as.computeTwap(startRecord, endRecord, quoteAsset) } -func (gs geometric) ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { +func (gs geometric) ComputeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) osmomath.Dec { return gs.computeTwap(startRecord, endRecord, quoteAsset) } @@ -72,18 +72,18 @@ func NewTwapRecord(k types.PoolManagerInterface, ctx sdk.Context, poolId uint64, return newTwapRecord(k, ctx, poolId, denom0, denom1) } -func TwapLog(x sdk.Dec) sdk.Dec { +func TwapLog(x osmomath.Dec) osmomath.Dec { return twapLog(x) } // twapPow exponentiates 2 to the given exponent. // Used as a test-helper for the power function used in geometric twap. -func TwapPow(exponent sdk.Dec) sdk.Dec { - exp2 := osmomath.Exp2(osmomath.BigDecFromSDKDec(exponent.Abs())) +func TwapPow(exponent osmomath.Dec) osmomath.Dec { + exp2 := osmomath.Exp2(osmomath.BigDecFromDec(exponent.Abs())) if exponent.IsNegative() { - return osmomath.OneDec().Quo(exp2).SDKDec() + return osmomath.OneBigDec().Quo(exp2).Dec() } - return exp2.SDKDec() + return exp2.Dec() } func GetSpotPrices( @@ -92,7 +92,7 @@ func GetSpotPrices( poolId uint64, denom0, denom1 string, previousErrorTime time.Time, -) (sp0 sdk.Dec, sp1 sdk.Dec, latestErrTime time.Time) { +) (sp0 osmomath.Dec, sp1 osmomath.Dec, latestErrTime time.Time) { return getSpotPrices(ctx, k, poolId, denom0, denom1, previousErrorTime) } diff --git a/x/twap/keeper_test.go b/x/twap/keeper_test.go index f510aa6ef80..22e545f5ffb 100644 --- a/x/twap/keeper_test.go +++ b/x/twap/keeper_test.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" "github.com/osmosis-labs/osmosis/v19/app/apptesting" "github.com/osmosis-labs/osmosis/v19/x/twap" @@ -57,11 +58,11 @@ var ( Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), } basicCustomGenesis = types.NewGenesisState( @@ -79,11 +80,11 @@ var ( Asset1Denom: denom1, Height: 1, Time: baseTime, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, { PoolId: basePoolId, @@ -91,11 +92,11 @@ var ( Asset1Denom: denom1, Height: 2, Time: tPlusOne, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, mostRecentRecordPoolOne, }) @@ -106,11 +107,11 @@ var ( Asset1Denom: denom2, Height: 1, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), } decreasingOrderByTimeRecordsPoolTwo = types.NewGenesisState( @@ -123,11 +124,11 @@ var ( Asset1Denom: denom2, Height: 2, Time: tPlusOne, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, { PoolId: basePoolId, @@ -135,11 +136,11 @@ var ( Asset1Denom: denom2, Height: 3, Time: baseTime, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, }) @@ -159,12 +160,12 @@ func withLastErrTime(twap types.TwapRecord, lastErrorTime time.Time) types.TwapR return twap } -func withSp0(twap types.TwapRecord, sp sdk.Dec) types.TwapRecord { +func withSp0(twap types.TwapRecord, sp osmomath.Dec) types.TwapRecord { twap.P0LastSpotPrice = sp return twap } -func withSp1(twap types.TwapRecord, sp sdk.Dec) types.TwapRecord { +func withSp1(twap types.TwapRecord, sp osmomath.Dec) types.TwapRecord { twap.P1LastSpotPrice = sp return twap } @@ -221,11 +222,11 @@ func (suite *TestSuite) TestTwapInitGenesis() { Asset1Denom: "test2", Height: 1, Time: baseTime, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, }), @@ -410,8 +411,8 @@ func (s *TestSuite) CreateTestRecordsFromTimeInPool(t time.Time, poolId uint64) // newTwoAssetPoolTwapRecordWithDefaults creates a single twap records, mimicking what one would expect from a two asset pool. // given a spot price 0 (sp0), this spot price is assigned to denomA and sp0 is then created and assigned to denomB by -// calculating (1 / spA). -func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { +// calculating (1 / spA).osmomath.Dec +func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1, geomAccum osmomath.Dec) types.TwapRecord { return types.TwapRecord{ PoolId: 1, Time: t, @@ -419,7 +420,7 @@ func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1, geo Asset1Denom: denom1, P0LastSpotPrice: sp0, - P1LastSpotPrice: sdk.OneDec().Quo(sp0), + P1LastSpotPrice: osmomath.OneDec().Quo(sp0), P0ArithmeticTwapAccumulator: accum0, P1ArithmeticTwapAccumulator: accum1, GeometricTwapAccumulator: geomAccum, @@ -428,11 +429,11 @@ func newTwoAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accum0, accum1, geo // newThreeAssetPoolTwapRecordWithDefaults creates three twap records, mimicking what one would expect from a three asset pool. // given a spot price 0 (sp0), this spot price is assigned to denomA and referred to as spA. spB is then created and assigned by -// calculating (1 / spA). Finally spC is created and assigned by calculating (2 * spA). -func newThreeAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) (types.TwapRecord, types.TwapRecord, types.TwapRecord) { +// calculating (1 / spA). Finally spC is created and assigned by calculating (2 * spA).osmomath.Dec +func newThreeAssetPoolTwapRecordWithDefaults(t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC osmomath.Dec) (types.TwapRecord, types.TwapRecord, types.TwapRecord) { spA := sp0 - spB := sdk.OneDec().Quo(sp0) - spC := sp0.Mul(sdk.NewDec(2)) + spB := osmomath.OneDec().Quo(sp0) + spC := sp0.Mul(osmomath.NewDec(2)) twapAB := types.TwapRecord{ PoolId: 2, Time: t, @@ -466,20 +467,20 @@ func newEmptyPriceRecord(poolId uint64, t time.Time, asset0 string, asset1 strin Asset0Denom: asset0, Asset1Denom: asset1, - P0LastSpotPrice: sdk.ZeroDec(), - P1LastSpotPrice: sdk.ZeroDec(), - P0ArithmeticTwapAccumulator: sdk.ZeroDec(), - P1ArithmeticTwapAccumulator: sdk.ZeroDec(), - GeometricTwapAccumulator: sdk.ZeroDec(), + P0LastSpotPrice: osmomath.ZeroDec(), + P1LastSpotPrice: osmomath.ZeroDec(), + P0ArithmeticTwapAccumulator: osmomath.ZeroDec(), + P1ArithmeticTwapAccumulator: osmomath.ZeroDec(), + GeometricTwapAccumulator: osmomath.ZeroDec(), } } -func withPrice0Set(twapRecord types.TwapRecord, price0ToSet sdk.Dec) types.TwapRecord { +func withPrice0Set(twapRecord types.TwapRecord, price0ToSet osmomath.Dec) types.TwapRecord { twapRecord.P0LastSpotPrice = price0ToSet return twapRecord } -func withPrice1Set(twapRecord types.TwapRecord, price1ToSet sdk.Dec) types.TwapRecord { +func withPrice1Set(twapRecord types.TwapRecord, price1ToSet osmomath.Dec) types.TwapRecord { twapRecord.P1LastSpotPrice = price1ToSet return twapRecord } @@ -489,37 +490,37 @@ func withTime(twapRecord types.TwapRecord, time time.Time) types.TwapRecord { return twapRecord } -func newRecord(poolId uint64, t time.Time, sp0, accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { +func newRecord(poolId uint64, t time.Time, sp0, accum0, accum1, geomAccum osmomath.Dec) types.TwapRecord { return types.TwapRecord{ PoolId: poolId, Asset0Denom: defaultTwoAssetCoins[0].Denom, Asset1Denom: defaultTwoAssetCoins[1].Denom, Time: t, P0LastSpotPrice: sp0, - P1LastSpotPrice: sdk.OneDec().Quo(sp0), + P1LastSpotPrice: osmomath.OneDec().Quo(sp0), // make new copies - P0ArithmeticTwapAccumulator: accum0.Add(sdk.ZeroDec()), - P1ArithmeticTwapAccumulator: accum1.Add(sdk.ZeroDec()), - GeometricTwapAccumulator: geomAccum.Add(sdk.ZeroDec()), + P0ArithmeticTwapAccumulator: accum0.Add(osmomath.ZeroDec()), + P1ArithmeticTwapAccumulator: accum1.Add(osmomath.ZeroDec()), + GeometricTwapAccumulator: geomAccum.Add(osmomath.ZeroDec()), } } -// make an expected record for math tests, we adjust other values in the test runner. -func newExpRecord(accum0, accum1, geomAccum sdk.Dec) types.TwapRecord { +// make an expected record for math tests, wosmomath.Dect other values in the test runner. +func newExpRecord(accum0, accum1, geomAccum osmomath.Dec) types.TwapRecord { return types.TwapRecord{ Asset0Denom: defaultTwoAssetCoins[0].Denom, Asset1Denom: defaultTwoAssetCoins[1].Denom, // make new copies - P0ArithmeticTwapAccumulator: accum0.Add(sdk.ZeroDec()), - P1ArithmeticTwapAccumulator: accum1.Add(sdk.ZeroDec()), - GeometricTwapAccumulator: geomAccum.Add(sdk.ZeroDec()), + P0ArithmeticTwapAccumulator: accum0.Add(osmomath.ZeroDec()), + P1ArithmeticTwapAccumulator: accum1.Add(osmomath.ZeroDec()), + GeometricTwapAccumulator: geomAccum.Add(osmomath.ZeroDec()), } } -func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) []types.TwapRecord { +func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC osmomath.Dec) []types.TwapRecord { spA := sp0 - spB := sdk.OneDec().Quo(sp0) - spC := sp0.Mul(sdk.NewDec(2)) + spB := osmomath.OneDec().Quo(sp0) + spC := sp0.Mul(osmomath.NewDec(2)) twapAB := types.TwapRecord{ PoolId: poolId, Asset0Denom: defaultThreeAssetCoins[0].Denom, @@ -528,65 +529,65 @@ func newThreeAssetRecord(poolId uint64, t time.Time, sp0, accumA, accumB, accumC P0LastSpotPrice: spA, P1LastSpotPrice: spB, // make new copies - P0ArithmeticTwapAccumulator: accumA.Add(sdk.ZeroDec()), - P1ArithmeticTwapAccumulator: accumB.Add(sdk.ZeroDec()), - GeometricTwapAccumulator: geomAccumAB.Add(sdk.ZeroDec()), + P0ArithmeticTwapAccumulator: accumA.Add(osmomath.ZeroDec()), + P1ArithmeticTwapAccumulator: accumB.Add(osmomath.ZeroDec()), + GeometricTwapAccumulator: geomAccumAB.Add(osmomath.ZeroDec()), } twapAC := twapAB twapAC.Asset1Denom = denom2 twapAC.P1LastSpotPrice = spC twapAC.P1ArithmeticTwapAccumulator = accumC - twapAC.GeometricTwapAccumulator = geomAccumAC.Add(sdk.ZeroDec()) + twapAC.GeometricTwapAccumulator = geomAccumAC.Add(osmomath.ZeroDec()) twapBC := twapAC twapBC.Asset0Denom = denom1 twapBC.P0LastSpotPrice = spB twapBC.P0ArithmeticTwapAccumulator = accumB - twapBC.GeometricTwapAccumulator = geomAccumBC.Add(sdk.ZeroDec()) + twapBC.GeometricTwapAccumulator = geomAccumBC.Add(osmomath.ZeroDec()) return []types.TwapRecord{twapAB, twapAC, twapBC} } -// make an expected record for math tests, we adjust other values in the test runner. -func newThreeAssetExpRecord(poolId uint64, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC sdk.Dec) []types.TwapRecord { +// make an expected record for math tests, we adjust other values in the test runner.osmomath.Dec +func newThreeAssetExpRecord(poolId uint64, accumA, accumB, accumC, geomAccumAB, geomAccumAC, geomAccumBC osmomath.Dec) []types.TwapRecord { twapAB := types.TwapRecord{ PoolId: poolId, Asset0Denom: defaultThreeAssetCoins[0].Denom, Asset1Denom: defaultThreeAssetCoins[1].Denom, // make new copies - P0ArithmeticTwapAccumulator: accumA.Add(sdk.ZeroDec()), - P1ArithmeticTwapAccumulator: accumB.Add(sdk.ZeroDec()), - GeometricTwapAccumulator: geomAccumAB.Add(sdk.ZeroDec()), + P0ArithmeticTwapAccumulator: accumA.Add(osmomath.ZeroDec()), + P1ArithmeticTwapAccumulator: accumB.Add(osmomath.ZeroDec()), + GeometricTwapAccumulator: geomAccumAB.Add(osmomath.ZeroDec()), } twapAC := twapAB twapAC.Asset1Denom = denom2 twapAC.P1ArithmeticTwapAccumulator = accumC - twapAC.GeometricTwapAccumulator = geomAccumAC.Add(sdk.ZeroDec()) + twapAC.GeometricTwapAccumulator = geomAccumAC.Add(osmomath.ZeroDec()) twapBC := twapAC twapBC.Asset0Denom = denom1 twapBC.P0ArithmeticTwapAccumulator = accumB - twapBC.GeometricTwapAccumulator = geomAccumBC.Add(sdk.ZeroDec()) + twapBC.GeometricTwapAccumulator = geomAccumBC.Add(osmomath.ZeroDec()) return []types.TwapRecord{twapAB, twapAC, twapBC} } -func newOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) types.TwapRecord { +func newOneSidedRecord(time time.Time, accum osmomath.Dec, useP0 bool) types.TwapRecord { record := types.TwapRecord{Time: time, Asset0Denom: denom0, Asset1Denom: denom1} if useP0 { record.P0ArithmeticTwapAccumulator = accum } else { record.P1ArithmeticTwapAccumulator = accum } - record.P0LastSpotPrice = sdk.ZeroDec() - record.P1LastSpotPrice = sdk.OneDec() + record.P0LastSpotPrice = osmomath.ZeroDec() + record.P1LastSpotPrice = osmomath.OneDec() return record } -func newOneSidedGeometricRecord(time time.Time, accum sdk.Dec) types.TwapRecord { +func newOneSidedGeometricRecord(time time.Time, accum osmomath.Dec) types.TwapRecord { record := types.TwapRecord{Time: time, Asset0Denom: denom0, Asset1Denom: denom1} record.GeometricTwapAccumulator = accum - record.P0LastSpotPrice = sdk.NewDec(10) + record.P0LastSpotPrice = osmomath.NewDec(10) return record } -func newThreeAssetOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) []types.TwapRecord { +func newThreeAssetOneSidedRecord(time time.Time, accum osmomath.Dec, useP0 bool) []types.TwapRecord { record := types.TwapRecord{Time: time, Asset0Denom: denom0, Asset1Denom: denom1} if useP0 { record.P0ArithmeticTwapAccumulator = accum @@ -594,8 +595,8 @@ func newThreeAssetOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) []ty record.P1ArithmeticTwapAccumulator = accum } record.GeometricTwapAccumulator = accum - record.P0LastSpotPrice = sdk.ZeroDec() - record.P1LastSpotPrice = sdk.OneDec() + record.P0LastSpotPrice = osmomath.ZeroDec() + record.P1LastSpotPrice = osmomath.OneDec() records := []types.TwapRecord{record, record, record} records[1].Asset1Denom = denom2 records[2].Asset0Denom = denom1 @@ -603,14 +604,14 @@ func newThreeAssetOneSidedRecord(time time.Time, accum sdk.Dec, useP0 bool) []ty return records } -func recordWithUpdatedAccum(record types.TwapRecord, accum0 sdk.Dec, accum1, geomAccum sdk.Dec) types.TwapRecord { +func recordWithUpdatedAccum(record types.TwapRecord, accum0 osmomath.Dec, accum1, geomAccum osmomath.Dec) types.TwapRecord { record.P0ArithmeticTwapAccumulator = accum0 record.P1ArithmeticTwapAccumulator = accum1 record.GeometricTwapAccumulator = geomAccum return record } -func recordWithUpdatedSpotPrice(record types.TwapRecord, sp0 sdk.Dec, sp1 sdk.Dec) types.TwapRecord { +func recordWithUpdatedSpotPrice(record types.TwapRecord, sp0 osmomath.Dec, sp1 osmomath.Dec) types.TwapRecord { record.P0LastSpotPrice = sp0 record.P1LastSpotPrice = sp1 return record diff --git a/x/twap/listeners.go b/x/twap/listeners.go index 2326d79ed87..91af6c59d7b 100644 --- a/x/twap/listeners.go +++ b/x/twap/listeners.go @@ -3,6 +3,7 @@ package twap import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" concentratedliquiditytypes "github.com/osmosis-labs/osmosis/v19/x/concentrated-liquidity/types" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" epochtypes "github.com/osmosis-labs/osmosis/x/epochs/types" @@ -52,11 +53,11 @@ func (hook *gammhook) AfterCFMMSwap(ctx sdk.Context, sender sdk.AccAddress, pool hook.k.trackChangedPool(ctx, poolId) } -func (hook *gammhook) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount sdk.Int) { +func (hook *gammhook) AfterJoinPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, enterCoins sdk.Coins, shareOutAmount osmomath.Int) { hook.k.trackChangedPool(ctx, poolId) } -func (hook *gammhook) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount sdk.Int, exitCoins sdk.Coins) { +func (hook *gammhook) AfterExitPool(ctx sdk.Context, sender sdk.AccAddress, poolId uint64, shareInAmount osmomath.Int, exitCoins sdk.Coins) { hook.k.trackChangedPool(ctx, poolId) } diff --git a/x/twap/listeners_test.go b/x/twap/listeners_test.go index 316af775e69..31336fd9b26 100644 --- a/x/twap/listeners_test.go +++ b/x/twap/listeners_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" "github.com/osmosis-labs/osmosis/v19/x/twap" "github.com/osmosis-labs/osmosis/v19/x/twap/types" @@ -197,8 +198,8 @@ func (s *TestSuite) TestEndBlock() { s.Require().Equal(twapAfterPoolCreation.Time, baseTime) // accumulators should not have increased, as they are going through the first epoch - s.Require().Equal(sdk.ZeroDec(), twapAfterBlock1.P0ArithmeticTwapAccumulator) - s.Require().Equal(sdk.ZeroDec(), twapAfterBlock1.P1ArithmeticTwapAccumulator) + s.Require().Equal(osmomath.ZeroDec(), twapAfterBlock1.P0ArithmeticTwapAccumulator) + s.Require().Equal(osmomath.ZeroDec(), twapAfterBlock1.P1ArithmeticTwapAccumulator) } // check if spot price has been correctly updated in twap record diff --git a/x/twap/logic.go b/x/twap/logic.go index 8fa169db2e2..79f3eeaa83f 100644 --- a/x/twap/logic.go +++ b/x/twap/logic.go @@ -26,9 +26,9 @@ func newTwapRecord(k types.PoolManagerInterface, ctx sdk.Context, poolId uint64, Time: ctx.BlockTime(), P0LastSpotPrice: sp0, P1LastSpotPrice: sp1, - P0ArithmeticTwapAccumulator: sdk.ZeroDec(), - P1ArithmeticTwapAccumulator: sdk.ZeroDec(), - GeometricTwapAccumulator: sdk.ZeroDec(), + P0ArithmeticTwapAccumulator: osmomath.ZeroDec(), + P1ArithmeticTwapAccumulator: osmomath.ZeroDec(), + GeometricTwapAccumulator: osmomath.ZeroDec(), LastErrorTime: lastErrorTime, }, nil } @@ -44,7 +44,7 @@ func getSpotPrices( poolId uint64, denom0, denom1 string, previousErrorTime time.Time, -) (sp0 sdk.Dec, sp1 sdk.Dec, latestErrTime time.Time) { +) (sp0 osmomath.Dec, sp1 osmomath.Dec, latestErrTime time.Time) { latestErrTime = previousErrorTime // sp0 = denom0 quote, denom1 base. sp0, err0 := k.RouteCalculateSpotPrice(ctx, poolId, denom0, denom1) @@ -55,11 +55,11 @@ func getSpotPrices( // In the event of an error, we just sanity replace empty values with zero values // so that the numbers can be still be calculated within TWAPs over error values // TODO: Should we be using the last spot price? - if (sp0 == sdk.Dec{}) { - sp0 = sdk.ZeroDec() + if (sp0 == osmomath.Dec{}) { + sp0 = osmomath.ZeroDec() } - if (sp1 == sdk.Dec{}) { - sp1 = sdk.ZeroDec() + if (sp1 == osmomath.Dec{}) { + sp1 = osmomath.ZeroDec() } } if sp0.GT(types.MaxSpotPrice) { @@ -278,7 +278,7 @@ func (k Keeper) getMostRecentRecord(ctx sdk.Context, poolId uint64, assetA, asse // if (endRecord.Time == startRecord.Time) returns endRecord.LastSpotPrice // else returns // (endRecord.Accumulator - startRecord.Accumulator) / (endRecord.Time - startRecord.Time) -func computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, strategy twapStrategy) (sdk.Dec, error) { +func computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string, strategy twapStrategy) (osmomath.Dec, error) { // see if we need to return an error, due to spot price issues var err error = nil if endRecord.LastErrorTime.After(startRecord.Time) || @@ -300,10 +300,10 @@ func computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quote // twapLog returns the logarithm of the given spot price, base 2. // Panics if zero is given. -func twapLog(price sdk.Dec) sdk.Dec { +func twapLog(price osmomath.Dec) osmomath.Dec { if price.IsZero() { panic("twap: cannot take logarithm of zero") } - return osmomath.BigDecFromSDKDec(price).LogBase2().SDKDec() + return osmomath.BigDecFromDec(price).LogBase2().Dec() } diff --git a/x/twap/logic_test.go b/x/twap/logic_test.go index 6d17acd8fc0..fafc453cdfe 100644 --- a/x/twap/logic_test.go +++ b/x/twap/logic_test.go @@ -20,13 +20,13 @@ import ( ) var ( - zeroDec = sdk.ZeroDec() - oneDec = sdk.OneDec() + zeroDec = osmomath.ZeroDec() + oneDec = osmomath.OneDec() twoDec = oneDec.Add(oneDec) - pointFiveDec = sdk.OneDec().Quo(twoDec) - OneSec = sdk.MustNewDecFromStr("1000.000000000000000000") - logTen = twap.TwapLog(sdk.NewDec(10)) - logOneOverTen = twap.TwapLog(sdk.OneDec().QuoInt64(10)) + pointFiveDec = osmomath.OneDec().Quo(twoDec) + OneSec = osmomath.MustNewDecFromStr("1000.000000000000000000") + logTen = twap.TwapLog(osmomath.NewDec(10)) + logOneOverTen = twap.TwapLog(osmomath.OneDec().QuoInt64(10)) tenSecAccum = OneSec.MulInt64(10) geometricTenSecAccum = OneSec.Mul(logTen) ) @@ -42,29 +42,29 @@ func (s *TestSuite) TestGetSpotPrices() { testCases := map[string]struct { poolID uint64 prevErrTime time.Time - mockSp0 sdk.Dec - mockSp1 sdk.Dec + mockSp0 osmomath.Dec + mockSp1 osmomath.Dec mockSp0Err error mockSp1Err error - expectedSp0 sdk.Dec - expectedSp1 sdk.Dec + expectedSp0 osmomath.Dec + expectedSp1 osmomath.Dec expectedLatestErrTime time.Time }{ "zero sp": { poolID: poolID, prevErrTime: currTime, - mockSp0: sdk.ZeroDec(), - mockSp1: sdk.ZeroDec(), + mockSp0: osmomath.ZeroDec(), + mockSp1: osmomath.ZeroDec(), mockSp0Err: fmt.Errorf("foo"), - expectedSp0: sdk.ZeroDec(), - expectedSp1: sdk.ZeroDec(), + expectedSp0: osmomath.ZeroDec(), + expectedSp1: osmomath.ZeroDec(), expectedLatestErrTime: ctx.BlockTime(), }, "exceeds max spot price": { poolID: poolID, prevErrTime: currTime, - mockSp0: types.MaxSpotPrice.Add(sdk.OneDec()), - mockSp1: types.MaxSpotPrice.Add(sdk.OneDec()), + mockSp0: types.MaxSpotPrice.Add(osmomath.OneDec()), + mockSp1: types.MaxSpotPrice.Add(osmomath.OneDec()), expectedSp0: types.MaxSpotPrice, expectedSp1: types.MaxSpotPrice, expectedLatestErrTime: ctx.BlockTime(), @@ -72,10 +72,10 @@ func (s *TestSuite) TestGetSpotPrices() { "valid spot prices": { poolID: poolID, prevErrTime: currTime, - mockSp0: sdk.NewDecWithPrec(55, 2), - mockSp1: sdk.NewDecWithPrec(6, 1), - expectedSp0: sdk.NewDecWithPrec(55, 2), - expectedSp1: sdk.NewDecWithPrec(6, 1), + mockSp0: osmomath.NewDecWithPrec(55, 2), + mockSp1: osmomath.NewDecWithPrec(6, 1), + expectedSp0: osmomath.NewDecWithPrec(55, 2), + expectedSp1: osmomath.NewDecWithPrec(6, 1), expectedLatestErrTime: currTime, }, } @@ -156,9 +156,9 @@ func (s *TestSuite) TestNewTwapRecord() { s.Require().Equal(test.poolId, twapRecord.PoolId) s.Require().Equal(s.Ctx.BlockHeight(), twapRecord.Height) s.Require().Equal(s.Ctx.BlockTime(), twapRecord.Time) - s.Require().Equal(sdk.ZeroDec(), twapRecord.P0ArithmeticTwapAccumulator) - s.Require().Equal(sdk.ZeroDec(), twapRecord.P1ArithmeticTwapAccumulator) - s.Require().Equal(sdk.ZeroDec(), twapRecord.GeometricTwapAccumulator) + s.Require().Equal(osmomath.ZeroDec(), twapRecord.P0ArithmeticTwapAccumulator) + s.Require().Equal(osmomath.ZeroDec(), twapRecord.P1ArithmeticTwapAccumulator) + s.Require().Equal(osmomath.ZeroDec(), twapRecord.GeometricTwapAccumulator) } }) } @@ -170,14 +170,14 @@ func (s *TestSuite) TestUpdateRecord() { programmableAmmInterface := twapmock.NewProgrammedAmmInterface(s.App.TwapKeeper.GetAmmInterface()) s.App.TwapKeeper.SetAmmInterface(programmableAmmInterface) - spotPriceResOne := twapmock.SpotPriceResult{Sp: sdk.OneDec(), Err: nil} - spotPriceResOneErr := twapmock.SpotPriceResult{Sp: sdk.OneDec(), Err: errors.New("dummy err")} - spotPriceResOneErrNilDec := twapmock.SpotPriceResult{Sp: sdk.Dec{}, Err: errors.New("dummy err")} + spotPriceResOne := twapmock.SpotPriceResult{Sp: osmomath.OneDec(), Err: nil} + spotPriceResOneErr := twapmock.SpotPriceResult{Sp: osmomath.OneDec(), Err: errors.New("dummy err")} + spotPriceResOneErrNilDec := twapmock.SpotPriceResult{Sp: osmomath.Dec{}, Err: errors.New("dummy err")} baseTime := time.Unix(2, 0).UTC() updateTime := time.Unix(3, 0).UTC() baseTimeMinusOne := time.Unix(1, 0).UTC() - zeroAccumNoErrSp10Record := newRecord(poolId, baseTime, sdk.NewDec(10), zeroDec, zeroDec, zeroDec) + zeroAccumNoErrSp10Record := newRecord(poolId, baseTime, osmomath.NewDec(10), zeroDec, zeroDec, zeroDec) sp10OneTimeUnitAccumRecord := newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { @@ -202,13 +202,13 @@ func (s *TestSuite) TestUpdateRecord() { record: zeroAccumNoErrSp10Record, spotPriceResult0: spotPriceResOneErrNilDec, spotPriceResult1: spotPriceResOne, - expRecord: withSp0(withLastErrTime(sp10OneTimeUnitAccumRecord, updateTime), sdk.ZeroDec()), + expRecord: withSp0(withLastErrTime(sp10OneTimeUnitAccumRecord, updateTime), osmomath.ZeroDec()), }, "0 accum start, sp1 err at update with nil dec": { record: zeroAccumNoErrSp10Record, spotPriceResult0: spotPriceResOne, spotPriceResult1: spotPriceResOneErrNilDec, - expRecord: withSp1(withLastErrTime(sp10OneTimeUnitAccumRecord, updateTime), sdk.ZeroDec()), + expRecord: withSp1(withLastErrTime(sp10OneTimeUnitAccumRecord, updateTime), osmomath.ZeroDec()), }, "startRecord err time preserved": { record: withLastErrTime(zeroAccumNoErrSp10Record, baseTimeMinusOne), @@ -229,10 +229,10 @@ func (s *TestSuite) TestUpdateRecord() { s.Ctx = s.Ctx.WithBlockTime(updateTime.UTC()) test.record.PoolId = poolId test.expRecord.PoolId = poolId - if (test.expRecord.P0LastSpotPrice == sdk.Dec{}) { + if (test.expRecord.P0LastSpotPrice == osmomath.Dec{}) { test.expRecord.P0LastSpotPrice = test.spotPriceResult0.Sp } - if (test.expRecord.P1LastSpotPrice == sdk.Dec{}) { + if (test.expRecord.P1LastSpotPrice == osmomath.Dec{}) { test.expRecord.P1LastSpotPrice = test.spotPriceResult1.Sp } test.expRecord.Height = s.Ctx.BlockHeight() @@ -254,7 +254,7 @@ func (s *TestSuite) TestUpdateRecord() { func TestRecordWithUpdatedAccumulators(t *testing.T) { poolId := uint64(1) - defaultRecord := newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), oneDec, twoDec, pointFiveDec) + defaultRecord := newRecord(poolId, time.Unix(1, 0), osmomath.NewDec(10), oneDec, twoDec, pointFiveDec) tests := map[string]struct { record types.TwapRecord newTime time.Time @@ -262,7 +262,7 @@ func TestRecordWithUpdatedAccumulators(t *testing.T) { expectPanic bool }{ "accum with zero value": { - record: newRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec, zeroDec), + record: newRecord(poolId, time.Unix(1, 0), osmomath.NewDec(10), zeroDec, zeroDec, zeroDec), newTime: time.Unix(2, 0), expRecord: newExpRecord(OneSec.MulInt64(10), OneSec.QuoInt64(10), geometricTenSecAccum), }, @@ -272,7 +272,7 @@ func TestRecordWithUpdatedAccumulators(t *testing.T) { expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(10)), twoDec.Add(OneSec.QuoInt64(10)), pointFiveDec.Add(geometricTenSecAccum)), }, "larger time interval": { - record: newRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), oneDec, twoDec, pointFiveDec), + record: newRecord(poolId, time.Unix(11, 0), osmomath.NewDec(10), oneDec, twoDec, pointFiveDec), newTime: time.Unix(55, 0), expRecord: newExpRecord(oneDec.Add(OneSec.MulInt64(44*10)), twoDec.Add(OneSec.MulInt64(44).QuoInt64(10)), pointFiveDec.Add(OneSec.MulInt64(44).Mul(logTen))), }, @@ -282,22 +282,22 @@ func TestRecordWithUpdatedAccumulators(t *testing.T) { expRecord: newExpRecord(oneDec, twoDec, pointFiveDec), }, "sp0 - zero spot price - accum0 unchanged, accum1 updated, geom accum unchanged, last err time set": { - record: withPrice0Set(defaultRecord, sdk.ZeroDec()), + record: withPrice0Set(defaultRecord, osmomath.ZeroDec()), newTime: defaultRecord.Time.Add(time.Second), - expRecord: withLastErrTime(newExpRecord(oneDec, twoDec.Add(sdk.NewDecWithPrec(1, 1).Mul(OneSec)), pointFiveDec), defaultRecord.Time.Add(time.Second)), + expRecord: withLastErrTime(newExpRecord(oneDec, twoDec.Add(osmomath.NewDecWithPrec(1, 1).Mul(OneSec)), pointFiveDec), defaultRecord.Time.Add(time.Second)), }, "sp1 - zero spot price - accum0 updated, accum1 unchanged, geom accum updated correctly": { - record: withPrice1Set(defaultRecord, sdk.ZeroDec()), + record: withPrice1Set(defaultRecord, osmomath.ZeroDec()), newTime: defaultRecord.Time.Add(time.Second), expRecord: newExpRecord(tenSecAccum.Add(oneDec), twoDec, pointFiveDec.Add(geometricTenSecAccum)), }, "both sp - zero spot price - accum0 unchange, accum1 unchanged, geom accum unchanged": { - record: withPrice1Set(withPrice0Set(defaultRecord, sdk.ZeroDec()), sdk.ZeroDec()), + record: withPrice1Set(withPrice0Set(defaultRecord, osmomath.ZeroDec()), osmomath.ZeroDec()), newTime: defaultRecord.Time.Add(time.Second), expRecord: withLastErrTime(newExpRecord(oneDec, twoDec, pointFiveDec), defaultRecord.Time.Add(time.Second)), }, "spot price of one - geom accumulator 0": { - record: withPrice1Set(withPrice0Set(defaultRecord, sdk.OneDec()), sdk.OneDec()), + record: withPrice1Set(withPrice0Set(defaultRecord, osmomath.OneDec()), osmomath.OneDec()), newTime: defaultRecord.Time.Add(time.Second), expRecord: newExpRecord(oneDec.Add(OneSec), twoDec.Add(OneSec), pointFiveDec), }, @@ -333,17 +333,17 @@ func TestRecordWithUpdatedAccumulators_ThreeAsset(t *testing.T) { expRecord []types.TwapRecord }{ "accum with zero value": { - record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), zeroDec, zeroDec, zeroDec, zeroDec, zeroDec, zeroDec), + record: newThreeAssetRecord(poolId, time.Unix(1, 0), osmomath.NewDec(10), zeroDec, zeroDec, zeroDec, zeroDec, zeroDec, zeroDec), interpolateTime: time.Unix(2, 0), expRecord: newThreeAssetExpRecord(poolId, OneSec.MulInt64(10), OneSec.QuoInt64(10), OneSec.MulInt64(20), geometricTenSecAccum, geometricTenSecAccum, OneSec.Mul(logOneOverTen)), }, "small starting accumulators": { - record: newThreeAssetRecord(poolId, time.Unix(1, 0), sdk.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), + record: newThreeAssetRecord(poolId, time.Unix(1, 0), osmomath.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), interpolateTime: time.Unix(2, 0), expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(10)), oneDec.Add(OneSec.QuoInt64(10)), twoDec.Add(OneSec.MulInt64(20)), oneDec.Add(geometricTenSecAccum), twoDec.Add(geometricTenSecAccum), oneDec.Add(OneSec.Mul(logOneOverTen))), }, "larger time interval": { - record: newThreeAssetRecord(poolId, time.Unix(11, 0), sdk.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), + record: newThreeAssetRecord(poolId, time.Unix(11, 0), osmomath.NewDec(10), twoDec, oneDec, twoDec, oneDec, twoDec, oneDec), interpolateTime: time.Unix(55, 0), expRecord: newThreeAssetExpRecord(poolId, twoDec.Add(OneSec.MulInt64(44*10)), oneDec.Add(OneSec.MulInt64(44).QuoInt64(10)), twoDec.Add(OneSec.MulInt64(44*20)), oneDec.Add(OneSec.MulInt64(44).Mul(logTen)), twoDec.Add(OneSec.MulInt64(44).Mul(logTen)), oneDec.Add(OneSec.MulInt64(44).Mul(logOneOverTen))), }, @@ -365,7 +365,7 @@ func TestRecordWithUpdatedAccumulators_ThreeAsset(t *testing.T) { } func (s *TestSuite) TestGetInterpolatedRecord() { - baseRecord := newTwoAssetPoolTwapRecordWithDefaults(baseTime, sdk.OneDec(), sdk.OneDec(), sdk.OneDec(), sdk.OneDec().Quo(twoDec)) + baseRecord := newTwoAssetPoolTwapRecordWithDefaults(baseTime, osmomath.OneDec(), osmomath.OneDec(), osmomath.OneDec(), osmomath.OneDec().Quo(twoDec)) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { @@ -374,7 +374,7 @@ func (s *TestSuite) TestGetInterpolatedRecord() { testDenom0 string testDenom1 string testTime time.Time - expectedAccumulator sdk.Dec + expectedAccumulator osmomath.Dec expectedErr error expectedLastErrTime time.Time }{ @@ -392,7 +392,7 @@ func (s *TestSuite) TestGetInterpolatedRecord() { testDenom1: baseRecord.Asset1Denom, testTime: baseTime.Add(time.Second), // 1(spot price) * 1000(one sec in milli-seconds) - expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(sdk.NewDec(1000)), + expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(1000)), }, "call 1 second after existing record with error": { recordsToPreSet: withLastErrTime(baseRecord, baseTime), @@ -401,7 +401,7 @@ func (s *TestSuite) TestGetInterpolatedRecord() { testDenom1: baseRecord.Asset1Denom, testTime: baseTime.Add(time.Second), // 1(spot price) * 1000(one sec in milli-seconds) - expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(sdk.NewDec(1000)), + expectedAccumulator: baseRecord.P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(1000)), expectedLastErrTime: baseTime.Add(time.Second), }, "call 1 second before existing record": { @@ -463,13 +463,13 @@ func (s *TestSuite) TestGetInterpolatedRecord() { } func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { - baseRecord := newThreeAssetRecord(2, baseTime, sdk.NewDec(10), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()) + baseRecord := newThreeAssetRecord(2, baseTime, osmomath.NewDec(10), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec(), osmomath.ZeroDec()) // all tests occur with updateTime = base time + time.Unix(1, 0) tests := map[string]struct { recordsToPreSet []types.TwapRecord testTime time.Time - expectedP0Accumulator []sdk.Dec - expectedP1Accumulator []sdk.Dec + expectedP0Accumulator []osmomath.Dec + expectedP1Accumulator []osmomath.Dec expectedErr error }{ "call 1 second after existing record": { @@ -479,18 +479,18 @@ func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { // A 10 spot price * 1000ms = 10000 // A 10 spot price * 1000ms = 10000 // B .1 spot price * 1000ms = 100 - expectedP0Accumulator: []sdk.Dec{ - baseRecord[0].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), - baseRecord[1].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), - baseRecord[2].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), + expectedP0Accumulator: []osmomath.Dec{ + baseRecord[0].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(10000)), + baseRecord[1].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(10000)), + baseRecord[2].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(100)), }, // B .1 spot price * 1000ms = 100 // C 20 spot price * 1000ms = 20000 // C 20 spot price * 1000ms = 20000 - expectedP1Accumulator: []sdk.Dec{ - baseRecord[0].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), - baseRecord[1].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), - baseRecord[2].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), + expectedP1Accumulator: []osmomath.Dec{ + baseRecord[0].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(100)), + baseRecord[1].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(20000)), + baseRecord[2].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(20000)), }, }, "call 1 second after existing record with error": { @@ -504,18 +504,18 @@ func (s *TestSuite) TestGetInterpolatedRecord_ThreeAsset() { // A 10 spot price * 1000ms = 10000 // A 10 spot price * 1000ms = 10000 // B .1 spot price * 1000ms = 100 - expectedP0Accumulator: []sdk.Dec{ - baseRecord[0].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), - baseRecord[1].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(10000)), - baseRecord[2].P0ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), + expectedP0Accumulator: []osmomath.Dec{ + baseRecord[0].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(10000)), + baseRecord[1].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(10000)), + baseRecord[2].P0ArithmeticTwapAccumulator.Add(osmomath.NewDec(100)), }, // B .1 spot price * 1000ms = 100 // C 20 spot price * 1000ms = 20000 // C 20 spot price * 1000ms = 20000 - expectedP1Accumulator: []sdk.Dec{ - baseRecord[0].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(100)), - baseRecord[1].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), - baseRecord[2].P1ArithmeticTwapAccumulator.Add(sdk.NewDec(20000)), + expectedP1Accumulator: []osmomath.Dec{ + baseRecord[0].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(100)), + baseRecord[1].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(20000)), + baseRecord[2].P1ArithmeticTwapAccumulator.Add(osmomath.NewDec(20000)), }, }, "call 1 second before existing record": { @@ -569,7 +569,7 @@ type computeThreeAssetArithmeticTwapTestCase struct { startRecord []types.TwapRecord endRecord []types.TwapRecord quoteAsset []string - expTwap []sdk.Dec + expTwap []osmomath.Dec expErr bool } @@ -643,13 +643,13 @@ func (s *TestSuite) TestUpdateRecords() { type spOverride struct { baseDenom string quoteDenom string - overrideSp sdk.Dec + overrideSp osmomath.Dec overrideErr error } type expectedResults struct { - spotPriceA sdk.Dec - spotPriceB sdk.Dec + spotPriceA osmomath.Dec + spotPriceB osmomath.Dec lastErrorTime time.Time isMostRecent bool } @@ -701,17 +701,17 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.NewDec(2), + overrideSp: osmomath.NewDec(2), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.NewDecWithPrec(2, 1), + overrideSp: osmomath.NewDecWithPrec(2, 1), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: "extradenom", - overrideSp: sdk.NewDecWithPrec(3, 1), + overrideSp: osmomath.NewDecWithPrec(3, 1), }, }, @@ -726,12 +726,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.NewDec(2), + overrideSp: osmomath.NewDec(2), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.NewDecWithPrec(2, 1), + overrideSp: osmomath.NewDecWithPrec(2, 1), }, }, @@ -743,8 +743,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.NewDec(2), - spotPriceB: sdk.NewDecWithPrec(2, 1), + spotPriceA: osmomath.NewDec(2), + spotPriceB: osmomath.NewDecWithPrec(2, 1), isMostRecent: true, }, }, @@ -763,7 +763,7 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.NewDecWithPrec(2, 1), + overrideSp: osmomath.NewDecWithPrec(2, 1), overrideErr: spError, }, }, @@ -776,8 +776,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.ZeroDec(), - spotPriceB: sdk.NewDecWithPrec(2, 1), + spotPriceA: osmomath.ZeroDec(), + spotPriceB: osmomath.NewDecWithPrec(2, 1), lastErrorTime: baseRecord.Time.Add(time.Second), // equals to block time isMostRecent: true, }, @@ -792,12 +792,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: types.MaxSpotPrice.Add(sdk.OneDec()), + overrideSp: types.MaxSpotPrice.Add(osmomath.OneDec()), overrideErr: nil, // twap logic should identify the large spot price and mark it as error. }, }, @@ -810,7 +810,7 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.OneDec(), + spotPriceA: osmomath.OneDec(), spotPriceB: types.MaxSpotPrice, // Although the price returned from AMM was MaxSpotPrice + 1, it is reset to just MaxSpotPrice. lastErrorTime: baseRecord.Time.Add(time.Second), // equals to block time isMostRecent: true, @@ -826,12 +826,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, }, @@ -844,8 +844,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec(), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec(), lastErrorTime: baseRecord.Time, isMostRecent: true, }, @@ -860,7 +860,7 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, @@ -878,8 +878,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.ZeroDec(), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.ZeroDec(), lastErrorTime: baseRecord.Time.Add(time.Second), // equals to block time isMostRecent: true, }, @@ -895,12 +895,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, @@ -917,8 +917,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()), isMostRecent: true, }, }, @@ -934,12 +934,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, @@ -964,12 +964,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: mostRecentRecordPoolOne.Asset0Denom, quoteDenom: mostRecentRecordPoolOne.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: mostRecentRecordPoolOne.Asset1Denom, quoteDenom: mostRecentRecordPoolOne.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, @@ -992,19 +992,19 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: baseRecord.Asset0Denom, quoteDenom: baseRecord.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: baseRecord.Asset1Denom, quoteDenom: baseRecord.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, expectedHistoricalRecords: []expectedResults{ { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()), isMostRecent: true, }, }, @@ -1023,12 +1023,12 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: mostRecentRecordPoolOne.Asset0Denom, quoteDenom: mostRecentRecordPoolOne.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: mostRecentRecordPoolOne.Asset1Denom, quoteDenom: mostRecentRecordPoolOne.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, expectError: types.InvalidUpdateRecordError{}, @@ -1041,32 +1041,32 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: threeAssetRecordAB.Asset0Denom, quoteDenom: threeAssetRecordAB.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: threeAssetRecordAB.Asset1Denom, quoteDenom: threeAssetRecordAB.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, { baseDenom: threeAssetRecordAC.Asset0Denom, quoteDenom: threeAssetRecordAC.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: threeAssetRecordAC.Asset1Denom, quoteDenom: threeAssetRecordAC.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), }, { baseDenom: threeAssetRecordBC.Asset0Denom, quoteDenom: threeAssetRecordBC.Asset1Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, { baseDenom: threeAssetRecordBC.Asset1Denom, quoteDenom: threeAssetRecordBC.Asset0Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, }, @@ -1083,8 +1083,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record AB added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()), isMostRecent: true, }, // The original record AC at t. @@ -1099,8 +1099,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record AC added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()).Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()).Add(osmomath.OneDec()), isMostRecent: true, }, // The original record BC at t. @@ -1115,8 +1115,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record BC added. { - spotPriceA: sdk.OneDec().Add(sdk.OneDec()), - spotPriceB: sdk.OneDec(), + spotPriceA: osmomath.OneDec().Add(osmomath.OneDec()), + spotPriceB: osmomath.OneDec(), isMostRecent: true, }, }, @@ -1129,33 +1129,33 @@ func (s *TestSuite) TestUpdateRecords() { { baseDenom: threeAssetRecordAB.Asset0Denom, quoteDenom: threeAssetRecordAB.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: threeAssetRecordAB.Asset1Denom, quoteDenom: threeAssetRecordAB.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, { baseDenom: threeAssetRecordAC.Asset0Denom, quoteDenom: threeAssetRecordAC.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: threeAssetRecordAC.Asset1Denom, quoteDenom: threeAssetRecordAC.Asset0Denom, - overrideSp: types.MaxSpotPrice.Add(sdk.OneDec()), + overrideSp: types.MaxSpotPrice.Add(osmomath.OneDec()), overrideErr: nil, // twap logic should identify the large spot price and mark it as error. }, { baseDenom: threeAssetRecordBC.Asset0Denom, quoteDenom: threeAssetRecordBC.Asset1Denom, - overrideSp: sdk.OneDec(), + overrideSp: osmomath.OneDec(), }, { baseDenom: threeAssetRecordBC.Asset1Denom, quoteDenom: threeAssetRecordBC.Asset0Denom, - overrideSp: sdk.OneDec().Add(sdk.OneDec()), + overrideSp: osmomath.OneDec().Add(osmomath.OneDec()), }, }, @@ -1173,8 +1173,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record AB added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()), lastErrorTime: tPlus10sp5ThreeAssetRecordAB.Time, isMostRecent: true, }, @@ -1190,7 +1190,7 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record AC added. { - spotPriceA: sdk.OneDec(), + spotPriceA: osmomath.OneDec(), spotPriceB: types.MaxSpotPrice, // Although the price returned from AMM was MaxSpotPrice + 1, it is reset to just MaxSpotPrice. lastErrorTime: threeAssetRecordAC.Time.Add(time.Second * 11), // equals to block time isMostRecent: true, @@ -1207,8 +1207,8 @@ func (s *TestSuite) TestUpdateRecords() { }, // The new record BC added. { - spotPriceA: sdk.OneDec(), - spotPriceB: sdk.OneDec().Add(sdk.OneDec()), + spotPriceA: osmomath.OneDec(), + spotPriceB: osmomath.OneDec().Add(osmomath.OneDec()), isMostRecent: true, }, }, @@ -1361,7 +1361,7 @@ func (s *TestSuite) TestAfterCreatePool() { // This tests the behavior of computeArithmeticTwap, around error returning // when there has been an intermediate spot price error. func (s *TestSuite) TestComputeArithmeticTwapWithSpotPriceError() { - newOneSidedRecordWErrorTime := func(time time.Time, accum sdk.Dec, useP0 bool, errTime time.Time) types.TwapRecord { + newOneSidedRecordWErrorTime := func(time time.Time, accum osmomath.Dec, useP0 bool, errTime time.Time) types.TwapRecord { record := newOneSidedRecord(time, accum, useP0) record.LastErrorTime = errTime return record @@ -1374,41 +1374,41 @@ func (s *TestSuite) TestComputeArithmeticTwapWithSpotPriceError() { tests := map[string]computeTwapTestCase{ // should error, since end time may have been used to interpolate this value "errAtEndTime from end record": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec, true, tPlusOne), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), expErr: true, }, // should error, since start time may have been used to interpolate this value "err at StartTime exactly from end record": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec, true, baseTime), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), expErr: true, }, // should error, since start record is erroneous "err at StartTime exactly from start record": { - startRecord: newOneSidedRecordWErrorTime(baseTime, sdk.ZeroDec(), true, baseTime), + startRecord: newOneSidedRecordWErrorTime(baseTime, osmomath.ZeroDec(), true, baseTime), endRecord: newOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), expErr: true, }, "err before StartTime": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec, true, tMinOne), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), expErr: false, }, // Should not happen, but if it did would error "err after EndTime": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecordWErrorTime(tPlusOne, OneSec.MulInt64(2), true, baseTime.Add(20*time.Second)), quoteAsset: denom0, - expTwap: sdk.OneDec().MulInt64(2), + expTwap: osmomath.OneDec().MulInt64(2), expErr: true, }, } @@ -1424,8 +1424,8 @@ func (s *TestSuite) TestComputeArithmeticTwapWithSpotPriceError() { // TestTwapLog_CorrectBase tests that the base of 2 is used for the twap log function. // log_2{16} = 4 func (s *TestSuite) TestTwapLog_CorrectBase() { - logOf := sdk.NewDec(16) - expectedValue := sdk.NewDec(4) + logOf := osmomath.NewDec(16) + expectedValue := osmomath.NewDec(4) result := twap.TwapLog(logOf) @@ -1434,33 +1434,33 @@ func (s *TestSuite) TestTwapLog_CorrectBase() { func (s *TestSuite) TestTwapLog() { smallestAdditiveTolerance := osmomath.ErrTolerance{ - AdditiveTolerance: sdk.SmallestDec(), + AdditiveTolerance: osmomath.SmallestDec(), } testcases := []struct { name string - price sdk.Dec - expected sdk.Dec + price osmomath.Dec + expected osmomath.Dec expectPanic bool }{ { "max spot price", gammtypes.MaxSpotPrice, // log_2{2^128 - 1} = 128 - sdk.MustNewDecFromStr("127.999999999999999999"), + osmomath.MustNewDecFromStr("127.999999999999999999"), false, }, { "zero price - panic", - sdk.ZeroDec(), - sdk.Dec{}, + osmomath.ZeroDec(), + osmomath.Dec{}, true, }, { "smallest dec", - sdk.SmallestDec(), + osmomath.SmallestDec(), // https://www.wolframalpha.com/input?i=log+base+2+of+%2810%5E-18%29+with+20+digits - sdk.MustNewDecFromStr("59.794705707972522262").Neg(), + osmomath.MustNewDecFromStr("59.794705707972522262").Neg(), false, }, } @@ -1471,15 +1471,15 @@ func (s *TestSuite) TestTwapLog() { result := twap.TwapLog(tc.price) smallestAdditiveTolerance.CompareBigDec( - osmomath.BigDecFromSDKDec(tc.expected), - osmomath.BigDecFromSDKDec(result), + osmomath.BigDecFromDec(tc.expected), + osmomath.BigDecFromDec(result), ) }) }) } } -func testCaseFromDeltas(s *TestSuite, startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { +func testCaseFromDeltas(s *TestSuite, startAccum, accumDiff osmomath.Dec, timeDelta time.Duration, expectedTwap osmomath.Dec) computeTwapTestCase { return computeTwapTestCase{ newOneSidedRecord(baseTime, startAccum, true), newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), true), @@ -1495,7 +1495,7 @@ func testCaseFromDeltas(s *TestSuite, startAccum, accumDiff sdk.Dec, timeDelta t } } -func testCaseFromDeltasAsset1(s *TestSuite, startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { +func testCaseFromDeltasAsset1(s *TestSuite, startAccum, accumDiff osmomath.Dec, timeDelta time.Duration, expectedTwap osmomath.Dec) computeTwapTestCase { return computeTwapTestCase{ newOneSidedRecord(baseTime, startAccum, false), newOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), false), @@ -1511,7 +1511,7 @@ func testCaseFromDeltasAsset1(s *TestSuite, startAccum, accumDiff sdk.Dec, timeD } } -func geometricTestCaseFromDeltas0(s *TestSuite, startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { +func geometricTestCaseFromDeltas0(s *TestSuite, startAccum, accumDiff osmomath.Dec, timeDelta time.Duration, expectedTwap osmomath.Dec) computeTwapTestCase { return computeTwapTestCase{ newOneSidedGeometricRecord(baseTime, startAccum), newOneSidedGeometricRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff)), @@ -1527,16 +1527,16 @@ func geometricTestCaseFromDeltas0(s *TestSuite, startAccum, accumDiff sdk.Dec, t } } -func geometricTestCaseFromDeltas1(s *TestSuite, startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeTwapTestCase { - return geometricTestCaseFromDeltas0(s, startAccum, accumDiff, timeDelta, sdk.OneDec().Quo(expectedTwap)) +func geometricTestCaseFromDeltas1(s *TestSuite, startAccum, accumDiff osmomath.Dec, timeDelta time.Duration, expectedTwap osmomath.Dec) computeTwapTestCase { + return geometricTestCaseFromDeltas0(s, startAccum, accumDiff, timeDelta, osmomath.OneDec().Quo(expectedTwap)) } -func testThreeAssetCaseFromDeltas(startAccum, accumDiff sdk.Dec, timeDelta time.Duration, expectedTwap sdk.Dec) computeThreeAssetArithmeticTwapTestCase { +func testThreeAssetCaseFromDeltas(startAccum, accumDiff osmomath.Dec, timeDelta time.Duration, expectedTwap osmomath.Dec) computeThreeAssetArithmeticTwapTestCase { return computeThreeAssetArithmeticTwapTestCase{ newThreeAssetOneSidedRecord(baseTime, startAccum, true), newThreeAssetOneSidedRecord(baseTime.Add(timeDelta), startAccum.Add(accumDiff), true), []string{denom0, denom0, denom1}, - []sdk.Dec{expectedTwap, expectedTwap, expectedTwap}, + []osmomath.Dec{expectedTwap, expectedTwap, expectedTwap}, false, } } diff --git a/x/twap/migrate_test.go b/x/twap/migrate_test.go index d172a4715d5..230dd9002b4 100644 --- a/x/twap/migrate_test.go +++ b/x/twap/migrate_test.go @@ -3,9 +3,6 @@ package twap_test import ( "time" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/gogo/protobuf/proto" - "github.com/osmosis-labs/osmosis/v19/x/twap/types" ) @@ -68,29 +65,3 @@ func (s *TestSuite) TestMigrateExistingPoolsError() { err := s.twapkeeper.MigrateExistingPools(s.Ctx, latestPoolIdPlusOne) s.Require().Error(err) } - -// TestTwapRecord_GeometricTwap_MarshalUnmarshal this test proves that migrations -// to initialize geometric twap accumulators are not required. -// This is because proto marshalling will initialize the field to the zero value. -// Zero value is the expected initialization value for the geometric twap accumulator. -func (suite *TestSuite) TestTwapRecord_GeometricTwap_MarshalUnmarshal() { - originalRecord := types.TwapRecord{ - Asset0Denom: "uatom", - Asset1Denom: "uusd", - } - - suite.Require().True(originalRecord.GeometricTwapAccumulator.IsNil()) - - bz, err := proto.Marshal(&originalRecord) - suite.Require().NoError(err) - - var deserialized types.TwapRecord - err = proto.Unmarshal(bz, &deserialized) - suite.Require().NoError(err) - - suite.Require().Equal(originalRecord, deserialized) - suite.Require().Equal(originalRecord.String(), deserialized.String()) - - suite.Require().False(originalRecord.GeometricTwapAccumulator.IsNil()) - suite.Require().Equal(sdk.ZeroDec(), originalRecord.GeometricTwapAccumulator) -} diff --git a/x/twap/store_test.go b/x/twap/store_test.go index 088a6ab14e3..cbd79ea6c37 100644 --- a/x/twap/store_test.go +++ b/x/twap/store_test.go @@ -5,8 +5,7 @@ import ( "math" "time" - sdk "github.com/cosmos/cosmos-sdk/types" - + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/twap" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -162,11 +161,11 @@ func (s *TestSuite) TestGetRecordAtOrBeforeTime() { defaultInputAt := func(t time.Time) getRecordInput { return getRecordInput{1, t, denom0, denom1} } wrongPoolIdInputAt := func(t time.Time) getRecordInput { return getRecordInput{2, t, denom0, denom1} } defaultRevInputAt := func(t time.Time) getRecordInput { return getRecordInput{1, t, denom1, denom0} } - baseRecord := withPrice0Set(newEmptyPriceRecord(1, baseTime, denom0, denom1), sdk.OneDec()) + baseRecord := withPrice0Set(newEmptyPriceRecord(1, baseTime, denom0, denom1), osmomath.OneDec()) tMin1 := baseTime.Add(-time.Second) - tMin1Record := withPrice0Set(newEmptyPriceRecord(1, tMin1, denom0, denom1), sdk.OneDec()) + tMin1Record := withPrice0Set(newEmptyPriceRecord(1, tMin1, denom0, denom1), osmomath.OneDec()) tPlus1 := baseTime.Add(time.Second) - tPlus1Record := withPrice0Set(newEmptyPriceRecord(1, tPlus1, denom0, denom1), sdk.OneDec()) + tPlus1Record := withPrice0Set(newEmptyPriceRecord(1, tPlus1, denom0, denom1), osmomath.OneDec()) tests := map[string]struct { recordsToSet []types.TwapRecord @@ -534,18 +533,18 @@ func (s *TestSuite) TestAccumulatorOverflow() { maxSpotPrice := gammtypes.MaxSpotPrice tests := map[string]struct { // timeDelta is duration in nano seconds. - // we use sdk.Dec here because time.Duration would automatically cap to - // time.duration.maxDuration without erroring. - timeDelta sdk.Dec + // we use osmomath.Dec here because time.Duration would automatically cap to + // time.duosmomath.DecmaxDuration without erroring. + timeDelta osmomath.Dec panics bool }{ "no overflow": { // 2562047h47m16.854775807s in duration, this is over 292 years. - timeDelta: sdk.NewDec(2).Power(128), + timeDelta: osmomath.NewDec(2).Power(128), panics: false, }, "overflow": { - timeDelta: sdk.NewDec(2).Power(129), + timeDelta: osmomath.NewDec(2).Power(129), panics: true, }, } @@ -553,7 +552,7 @@ func (s *TestSuite) TestAccumulatorOverflow() { s.Run(name, func() { s.SetupTest() - var accumulatorVal sdk.Dec + var accumulatorVal osmomath.Dec fmt.Println(time.Duration(math.Pow(2, 128))) if test.panics { diff --git a/x/twap/strategy.go b/x/twap/strategy.go index f9910e58c7f..786c945b634 100644 --- a/x/twap/strategy.go +++ b/x/twap/strategy.go @@ -1,8 +1,6 @@ package twap import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/twap/types" @@ -14,7 +12,7 @@ import ( // We expose a common TWAP API to reduce duplication and avoid complexity. type twapStrategy interface { // computeTwap calculates the TWAP with specific startRecord and endRecord. - computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec + computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) osmomath.Dec } type arithmetic struct { @@ -27,8 +25,8 @@ type geometric struct { // computeTwap computes and returns an arithmetic TWAP between // two records given the quote asset. -func (s *arithmetic) computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { - var accumDiff sdk.Dec +func (s *arithmetic) computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) osmomath.Dec { + var accumDiff osmomath.Dec if quoteAsset == startRecord.Asset0Denom { accumDiff = endRecord.P0ArithmeticTwapAccumulator.Sub(startRecord.P0ArithmeticTwapAccumulator) } else { @@ -40,11 +38,11 @@ func (s *arithmetic) computeTwap(startRecord types.TwapRecord, endRecord types.T // computeTwap computes and returns a geometric TWAP between // two records given the quote asset. -func (s *geometric) computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) sdk.Dec { +func (s *geometric) computeTwap(startRecord types.TwapRecord, endRecord types.TwapRecord, quoteAsset string) osmomath.Dec { accumDiff := endRecord.GeometricTwapAccumulator.Sub(startRecord.GeometricTwapAccumulator) if accumDiff.IsZero() { - return sdk.ZeroDec() + return osmomath.ZeroDec() } timeDelta := types.CanonicalTimeMs(endRecord.Time) - types.CanonicalTimeMs(startRecord.Time) @@ -52,7 +50,7 @@ func (s *geometric) computeTwap(startRecord types.TwapRecord, endRecord types.Tw exponent := arithmeticMeanOfLogPrices // result = 2^exponent = 2^arithmeticMeanOfLogPrices - result := osmomath.Exp2(osmomath.BigDecFromSDKDec(exponent.Abs())) + result := osmomath.Exp2(osmomath.BigDecFromDec(exponent.Abs())) isExponentNegative := exponent.IsNegative() isQuoteAsset0 := quoteAsset == startRecord.Asset0Denom @@ -65,10 +63,10 @@ func (s *geometric) computeTwap(startRecord types.TwapRecord, endRecord types.Tw // https://proofwiki.org/wiki/Geometric_Mean_of_Reciprocals_is_Reciprocal_of_Geometric_Mean invertCase2 := !isExponentNegative && !isQuoteAsset0 if invertCase1 || invertCase2 { - result = osmomath.OneDec().Quo(result) + result = osmomath.OneBigDec().Quo(result) } // N.B. we round because this is the max number of significant figures supported // by the underlying spot price function. - return osmomath.SigFigRound(result.SDKDec(), gammtypes.SpotPriceSigFigs) + return osmomath.SigFigRound(result.Dec(), gammtypes.SpotPriceSigFigs) } diff --git a/x/twap/strategy_test.go b/x/twap/strategy_test.go index 9833aa1a70d..63beb622e70 100644 --- a/x/twap/strategy_test.go +++ b/x/twap/strategy_test.go @@ -3,8 +3,6 @@ package twap_test import ( "time" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils/osmoassert" gammtypes "github.com/osmosis-labs/osmosis/v19/x/gamm/types" @@ -17,7 +15,7 @@ type computeTwapTestCase struct { endRecord types.TwapRecord twapStrategies []twap.TwapStrategy quoteAsset string - expTwap sdk.Dec + expTwap osmomath.Dec expErr bool expPanic bool } @@ -37,56 +35,56 @@ func (s *TestSuite) TestComputeTwap() { tests := map[string]computeTwapTestCase{ "arithmetic only, basic: spot price = 1 for one second, 0 init accumulator": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: denom0, twapStrategies: []twap.TwapStrategy{ arithStrategy, }, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, // this test just shows what happens in case the records are reversed. // It should return the correct result, even though this is incorrect internal API usage "arithmetic only: invalid call: reversed records of above": { startRecord: newOneSidedRecord(tPlusOne, OneSec, true), - endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), quoteAsset: denom0, twapStrategies: []twap.TwapStrategy{ arithStrategy, }, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, "same record: denom0, end spot price = 0": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), - endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), quoteAsset: denom0, twapStrategies: []twap.TwapStrategy{ arithStrategy, geomStrategy, }, - expTwap: sdk.ZeroDec(), + expTwap: osmomath.ZeroDec(), }, "same record: denom1, end spot price = 1": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), - endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), quoteAsset: denom1, twapStrategies: []twap.TwapStrategy{ arithStrategy, geomStrategy, }, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, "arithmetic only: accumulator = 10*OneSec, t=5s. 0 base accum": testCaseFromDeltas( - s, sdk.ZeroDec(), tenSecAccum, 5*time.Second, sdk.NewDec(2)), - "arithmetic only: accumulator = 10*OneSec, t=100s. 0 base accum (asset 1)": testCaseFromDeltasAsset1(s, sdk.ZeroDec(), OneSec.MulInt64(10), 100*time.Second, sdk.NewDecWithPrec(1, 1)), + s, osmomath.ZeroDec(), tenSecAccum, 5*time.Second, osmomath.NewDec(2)), + "arithmetic only: accumulator = 10*OneSec, t=100s. 0 base accum (asset 1)": testCaseFromDeltasAsset1(s, osmomath.ZeroDec(), OneSec.MulInt64(10), 100*time.Second, osmomath.NewDecWithPrec(1, 1)), "geometric only: accumulator = log(10)*OneSec, t=5s. 0 base accum": geometricTestCaseFromDeltas0( - s, sdk.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), - "geometric only: accumulator = log(10)*OneSec, t=100s. 0 base accum (asset 1)": geometricTestCaseFromDeltas1(s, sdk.ZeroDec(), geometricTenSecAccum, 100*time.Second, sdk.OneDec().Quo(twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000)))), + s, osmomath.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), + "geometric only: accumulator = log(10)*OneSec, t=100s. 0 base accum (asset 1)": geometricTestCaseFromDeltas1(s, osmomath.ZeroDec(), geometricTenSecAccum, 100*time.Second, osmomath.OneDec().Quo(twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000)))), "three asset same record: asset1, end spot price = 1": { - startRecord: newThreeAssetOneSidedRecord(baseTime, sdk.ZeroDec(), true)[1], - endRecord: newThreeAssetOneSidedRecord(baseTime, sdk.ZeroDec(), true)[1], + startRecord: newThreeAssetOneSidedRecord(baseTime, osmomath.ZeroDec(), true)[1], + endRecord: newThreeAssetOneSidedRecord(baseTime, osmomath.ZeroDec(), true)[1], quoteAsset: denom2, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), twapStrategies: []twap.TwapStrategy{ arithStrategy, geomStrategy, @@ -111,47 +109,47 @@ func (s *TestSuite) TestComputeArithmeticStrategyTwap() { pointOneAccum := OneSec.QuoInt64(10) tests := map[string]computeTwapTestCase{ "basic: spot price = 1 for one second, 0 init accumulator": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, // this test just shows what happens in case the records are reversed. // It should return the correct result, even though this is incorrect internal API usage "invalid call: reversed records of above": { startRecord: newOneSidedRecord(tPlusOne, OneSec, true), - endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, "same record (zero time delta), division by 0 - panic": { - startRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), - endRecord: newOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), + endRecord: newOneSidedRecord(baseTime, osmomath.ZeroDec(), true), quoteAsset: denom0, expPanic: true, }, "accumulator = 10*OneSec, t=5s. 0 base accum": testCaseFromDeltas( - s, sdk.ZeroDec(), tenSecAccum, 5*time.Second, sdk.NewDec(2)), + s, osmomath.ZeroDec(), tenSecAccum, 5*time.Second, osmomath.NewDec(2)), "accumulator = 10*OneSec, t=3s. 0 base accum": testCaseFromDeltas( - s, sdk.ZeroDec(), tenSecAccum, 3*time.Second, ThreePlusOneThird), + s, osmomath.ZeroDec(), tenSecAccum, 3*time.Second, ThreePlusOneThird), "accumulator = 10*OneSec, t=100s. 0 base accum": testCaseFromDeltas( - s, sdk.ZeroDec(), tenSecAccum, 100*time.Second, sdk.NewDecWithPrec(1, 1)), + s, osmomath.ZeroDec(), tenSecAccum, 100*time.Second, osmomath.NewDecWithPrec(1, 1)), // test that base accum has no impact "accumulator = 10*OneSec, t=5s. 10 base accum": testCaseFromDeltas( - s, sdk.NewDec(10), tenSecAccum, 5*time.Second, sdk.NewDec(2)), + s, osmomath.NewDec(10), tenSecAccum, 5*time.Second, osmomath.NewDec(2)), "accumulator = 10*OneSec, t=3s. 10*second base accum": testCaseFromDeltas( s, tenSecAccum, tenSecAccum, 3*time.Second, ThreePlusOneThird), "accumulator = 10*OneSec, t=100s. .1*second base accum": testCaseFromDeltas( - s, pointOneAccum, tenSecAccum, 100*time.Second, sdk.NewDecWithPrec(1, 1)), + s, pointOneAccum, tenSecAccum, 100*time.Second, osmomath.NewDecWithPrec(1, 1)), - "accumulator = 10*OneSec, t=100s. 0 base accum (asset 1)": testCaseFromDeltasAsset1(s, sdk.ZeroDec(), OneSec.MulInt64(10), 100*time.Second, sdk.NewDecWithPrec(1, 1)), + "accumulator = 10*OneSec, t=100s. 0 base accum (asset 1)": testCaseFromDeltasAsset1(s, osmomath.ZeroDec(), OneSec.MulInt64(10), 100*time.Second, osmomath.NewDecWithPrec(1, 1)), "start record time with nanoseconds does not change result": { - startRecord: newOneSidedRecord(baseTime.Add(oneHundredNanoseconds), sdk.ZeroDec(), true), + startRecord: newOneSidedRecord(baseTime.Add(oneHundredNanoseconds), osmomath.ZeroDec(), true), endRecord: newOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: denom0, - expTwap: sdk.OneDec(), + expTwap: osmomath.OneDec(), }, } for name, test := range tests { @@ -171,7 +169,7 @@ func (s *TestSuite) TestComputeArithmeticStrategyTwap() { func (s *TestSuite) TestComputeGeometricStrategyTwap() { var ( errTolerance = osmomath.ErrTolerance{ - MultiplicativeTolerance: sdk.SmallestDec(), + MultiplicativeTolerance: osmomath.SmallestDec(), RoundingDir: osmomath.RoundDown, } @@ -200,39 +198,39 @@ func (s *TestSuite) TestComputeGeometricStrategyTwap() { tests := map[string]computeTwapTestCase{ // basic test for both denom with zero start accumulator "basic denom0: spot price = 1 for one second, 0 init accumulator": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), endRecord: newOneSidedGeometricRecord(tPlusOne, geometricTenSecAccum), quoteAsset: denom0, - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, "basic denom1: spot price = 1 for one second, 0 init accumulator": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), endRecord: newOneSidedGeometricRecord(tPlusOne, geometricTenSecAccum), quoteAsset: denom1, - expTwap: sdk.OneDec().Quo(sdk.NewDec(10)), + expTwap: osmomath.OneDec().Quo(osmomath.NewDec(10)), }, // basic test for both denom with non-zero start accumulator "denom0: start accumulator of 10 * 1s, end accumulator 10 * 1s + 20 * 2s = 20": { startRecord: newOneSidedGeometricRecord(baseTime, geometricTenSecAccum), - endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(sdk.NewDec(20))))), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(osmomath.NewDec(20))))), quoteAsset: denom0, - expTwap: sdk.NewDec(20), + expTwap: osmomath.NewDec(20), }, "denom1 start accumulator of 10 * 1s, end accumulator 10 * 1s + 20 * 2s = 20": { startRecord: newOneSidedGeometricRecord(baseTime, geometricTenSecAccum), - endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(sdk.NewDec(20))))), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Second*2), geometricTenSecAccum.Add(OneSec.MulInt64(2).Mul(twap.TwapLog(osmomath.NewDec(20))))), quoteAsset: denom1, - expTwap: sdk.OneDec().Quo(sdk.NewDec(20)), + expTwap: osmomath.OneDec().Quo(osmomath.NewDec(20)), }, // toggle time delta. "accumulator = log(10)*OneSec, t=5s. 0 base accum": geometricTestCaseFromDeltas0( - s, sdk.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), + s, osmomath.ZeroDec(), geometricTenSecAccum, 5*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(5*1000))), "accumulator = log(10)*OneSec, t=3s. 0 base accum": geometricTestCaseFromDeltas0( - s, sdk.ZeroDec(), geometricTenSecAccum, 3*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(3*1000))), + s, osmomath.ZeroDec(), geometricTenSecAccum, 3*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(3*1000))), "accumulator = log(10)*OneSec, t=100s. 0 base accum": geometricTestCaseFromDeltas0( - s, sdk.ZeroDec(), geometricTenSecAccum, 100*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000))), + s, osmomath.ZeroDec(), geometricTenSecAccum, 100*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000))), // test that base accum has no impact "accumulator = log(10)*OneSec, t=5s. 10 base accum": geometricTestCaseFromDeltas0( @@ -243,10 +241,10 @@ func (s *TestSuite) TestComputeGeometricStrategyTwap() { s, OneSec.MulInt64(10).Mul(logOneOverTen), geometricTenSecAccum, 100*time.Second, twap.TwapPow(geometricTenSecAccum.QuoInt64(100*1000))), "price of 1_000_000 for an hour": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), - endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Hour), OneSec.MulInt64(60*60).Mul(twap.TwapLog(sdk.NewDec(1_000_000)))), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), + endRecord: newOneSidedGeometricRecord(baseTime.Add(time.Hour), OneSec.MulInt64(60*60).Mul(twap.TwapLog(osmomath.NewDec(1_000_000)))), quoteAsset: denom0, - expTwap: sdk.NewDec(1_000_000), + expTwap: osmomath.NewDec(1_000_000), }, "no overflow test: at max spot price denom0 quote - get max spot price": { @@ -261,36 +259,36 @@ func (s *TestSuite) TestComputeGeometricStrategyTwap() { endRecord: newOneSidedGeometricRecord(baseRecord.Time.Add(oneHundredYearsMin1MsDuration), overflowTestCaseAccumDiff), quoteAsset: denom1, - expTwap: sdk.ZeroDec(), + expTwap: osmomath.ZeroDec(), }, "no underflow test: spot price is smallest possible denom0 quote": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), endRecord: newOneSidedGeometricRecord(baseRecord.Time.Add(oneHundredYearsMin1MsDuration), underflowTestCaseAccumDiff), quoteAsset: denom0, expTwap: gammtypes.MinSpotPrice, }, "no underflow test: spot price is smallest possible denom1 quote": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), endRecord: newOneSidedGeometricRecord(baseRecord.Time.Add(oneHundredYearsMin1MsDuration), underflowTestCaseAccumDiff), quoteAsset: denom1, - expTwap: sdk.OneDec().Quo(gammtypes.MinSpotPrice), + expTwap: osmomath.OneDec().Quo(gammtypes.MinSpotPrice), }, "zero accum difference - return zero": { - startRecord: newOneSidedGeometricRecord(baseTime, sdk.ZeroDec()), - endRecord: newOneSidedGeometricRecord(baseRecord.Time.Add(time.Millisecond), sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime, osmomath.ZeroDec()), + endRecord: newOneSidedGeometricRecord(baseRecord.Time.Add(time.Millisecond), osmomath.ZeroDec()), quoteAsset: denom1, - expTwap: sdk.ZeroDec(), + expTwap: osmomath.ZeroDec(), }, "start record time with nanoseconds does not change result": { - startRecord: newOneSidedGeometricRecord(baseTime.Add(oneHundredNanoseconds), sdk.ZeroDec()), + startRecord: newOneSidedGeometricRecord(baseTime.Add(oneHundredNanoseconds), osmomath.ZeroDec()), endRecord: newOneSidedGeometricRecord(tPlusOne, geometricTenSecAccum), quoteAsset: denom0, - expTwap: sdk.NewDec(10), + expTwap: osmomath.NewDec(10), }, } @@ -304,7 +302,7 @@ func (s *TestSuite) TestComputeGeometricStrategyTwap() { // Sig fig round the expected value. tc.expTwap = osmomath.SigFigRound(tc.expTwap, gammtypes.SpotPriceSigFigs) - s.Require().Equal(0, errTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(tc.expTwap), osmomath.BigDecFromSDKDec(actualTwap)), "expected %s, got %s", tc.expTwap, actualTwap) + s.Require().Equal(0, errTolerance.CompareBigDec(osmomath.BigDecFromDec(tc.expTwap), osmomath.BigDecFromDec(actualTwap)), "expected %s, got %s", tc.expTwap, actualTwap) }) }) } @@ -315,19 +313,19 @@ func (s *TestSuite) TestComputeArithmeticStrategyTwap_ThreeAsset() { pointOneAccum := OneSec.QuoInt64(10) tests := map[string]computeThreeAssetArithmeticTwapTestCase{ "three asset basic: spot price = 1 for one second, 0 init accumulator": { - startRecord: newThreeAssetOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newThreeAssetOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newThreeAssetOneSidedRecord(tPlusOne, OneSec, true), quoteAsset: []string{denom0, denom0, denom1}, - expTwap: []sdk.Dec{sdk.OneDec(), sdk.OneDec(), sdk.OneDec()}, + expTwap: []osmomath.Dec{osmomath.OneDec(), osmomath.OneDec(), osmomath.OneDec()}, }, "three asset. accumulator = 10*OneSec, t=5s. 0 base accum": testThreeAssetCaseFromDeltas( - sdk.ZeroDec(), tenSecAccum, 5*time.Second, sdk.NewDec(2)), + osmomath.ZeroDec(), tenSecAccum, 5*time.Second, osmomath.NewDec(2)), // test that base accum has no impact "three asset. accumulator = 10*OneSec, t=5s. 10 base accum": testThreeAssetCaseFromDeltas( - sdk.NewDec(10), tenSecAccum, 5*time.Second, sdk.NewDec(2)), + osmomath.NewDec(10), tenSecAccum, 5*time.Second, osmomath.NewDec(2)), "three asset. accumulator = 10*OneSec, t=100s. .1*second base accum": testThreeAssetCaseFromDeltas( - pointOneAccum, tenSecAccum, 100*time.Second, sdk.NewDecWithPrec(1, 1)), + pointOneAccum, tenSecAccum, 100*time.Second, osmomath.NewDecWithPrec(1, 1)), } for name, test := range tests { s.Run(name, func() { @@ -342,24 +340,24 @@ func (s *TestSuite) TestComputeArithmeticStrategyTwap_ThreeAsset() { func (s *TestSuite) TestComputeGeometricStrategyTwap_ThreeAsset() { var ( - five = sdk.NewDec(5) + five = osmomath.NewDec(5) fiveFor3Sec = OneSec.MulInt64(3).Mul(twap.TwapLog(five)) ten = five.MulInt64(2) tenFor100Sec = OneSec.MulInt64(100).Mul(twap.TwapLog(ten)) - errTolerance = sdk.MustNewDecFromStr("0.00000001") + errTolerance = osmomath.MustNewDecFromStr("0.00000001") ) tests := map[string]computeThreeAssetArithmeticTwapTestCase{ "three asset basic: spot price = 10 for one second, 0 init accumulator": { - startRecord: newThreeAssetOneSidedRecord(baseTime, sdk.ZeroDec(), true), + startRecord: newThreeAssetOneSidedRecord(baseTime, osmomath.ZeroDec(), true), endRecord: newThreeAssetOneSidedRecord(tPlusOne, geometricTenSecAccum, true), quoteAsset: []string{denom0, denom0, denom1}, - expTwap: []sdk.Dec{sdk.NewDec(10), sdk.NewDec(10), sdk.NewDec(10)}, + expTwap: []osmomath.Dec{osmomath.NewDec(10), osmomath.NewDec(10), osmomath.NewDec(10)}, }, "three asset. accumulator = 5*3Sec, t=3s, no start accum": testThreeAssetCaseFromDeltas( - sdk.ZeroDec(), fiveFor3Sec, 3*time.Second, five), + osmomath.ZeroDec(), fiveFor3Sec, 3*time.Second, five), // test that base accum has no impact "three asset. accumulator = 5*3Sec, t=3s. 10 base accum": testThreeAssetCaseFromDeltas( diff --git a/x/twap/types/expected_interfaces.go b/x/twap/types/expected_interfaces.go index 79e651468cc..fd02f632770 100644 --- a/x/twap/types/expected_interfaces.go +++ b/x/twap/types/expected_interfaces.go @@ -1,6 +1,10 @@ package types -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/osmomath" +) // AmmInterface is the functionality needed from a given pool ID, in order to maintain records and serve TWAPs. type PoolManagerInterface interface { @@ -14,5 +18,5 @@ type PoolManagerInterface interface { poolID uint64, quoteAssetDenom string, baseAssetDenom string, - ) (price sdk.Dec, err error) + ) (price osmomath.Dec, err error) } diff --git a/x/twap/types/genesis_test.go b/x/twap/types/genesis_test.go index 7dfc3ea69fa..f50f4b99281 100644 --- a/x/twap/types/genesis_test.go +++ b/x/twap/types/genesis_test.go @@ -4,8 +4,9 @@ import ( "testing" time "time" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/osmomath" ) const ( @@ -24,11 +25,11 @@ var ( Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), } ) @@ -52,11 +53,11 @@ func TestGenesisState_Validate(t *testing.T) { Asset1Denom: denom1, Height: 2, Time: tPlusOne, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, { PoolId: basePoolId, @@ -64,16 +65,16 @@ func TestGenesisState_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), - GeometricTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), + GeometricTwapAccumulator: osmomath.OneDec(), }, }) ) - withGeometricAcc := func(record TwapRecord, geometricAcc sdk.Dec) TwapRecord { + withGeometricAcc := func(record TwapRecord, geometricAcc osmomath.Dec) TwapRecord { record.GeometricTwapAccumulator = geometricAcc return record } @@ -96,10 +97,10 @@ func TestGenesisState_Validate(t *testing.T) { twapGenesis: NewGenesisState(basicParams, []TwapRecord{}), }, "valid geometric twap acc is negative": { - twapGenesis: NewGenesisState(basicParams, []TwapRecord{withGeometricAcc(baseRecord, sdk.NewDec(-1))}), + twapGenesis: NewGenesisState(basicParams, []TwapRecord{withGeometricAcc(baseRecord, osmomath.NewDec(-1))}), }, "invalid geometric twap acc is nil": { - twapGenesis: NewGenesisState(basicParams, []TwapRecord{withGeometricAcc(baseRecord, sdk.Dec{})}), + twapGenesis: NewGenesisState(basicParams, []TwapRecord{withGeometricAcc(baseRecord, osmomath.Dec{})}), expectedErr: true, }, "invalid genesis - pool ID doesn't exist": { @@ -112,10 +113,10 @@ func TestGenesisState_Validate(t *testing.T) { Asset1Denom: "test2", Height: 1, Time: baseTime, - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), }, }), @@ -207,7 +208,7 @@ func TestTWAPRecord_Validate(t *testing.T) { "invalid p0 last spot price: zero": { twapRecord: func() TwapRecord { r := baseRecord - r.P0LastSpotPrice = sdk.ZeroDec() + r.P0LastSpotPrice = osmomath.ZeroDec() return r }(), @@ -216,7 +217,7 @@ func TestTWAPRecord_Validate(t *testing.T) { "invalid p0 last spot price: negative": { twapRecord: func() TwapRecord { r := baseRecord - r.P0LastSpotPrice = sdk.OneDec().Neg() + r.P0LastSpotPrice = osmomath.OneDec().Neg() return r }(), @@ -226,8 +227,8 @@ func TestTWAPRecord_Validate(t *testing.T) { twapRecord: func() TwapRecord { r := baseRecord r.LastErrorTime = r.Time - r.P0LastSpotPrice = sdk.NewDec(5) - r.P1LastSpotPrice = sdk.ZeroDec() // note that this one is zero due to spot price error. + r.P0LastSpotPrice = osmomath.NewDec(5) + r.P1LastSpotPrice = osmomath.ZeroDec() // note that this one is zero due to spot price error. return r }(), @@ -237,8 +238,8 @@ func TestTWAPRecord_Validate(t *testing.T) { twapRecord: func() TwapRecord { r := baseRecord r.LastErrorTime = r.Time - r.P0LastSpotPrice = sdk.ZeroDec() // note that this one is zero due to spot price error. - r.P1LastSpotPrice = sdk.ZeroDec() // note that this one is zero due to spot price error. + r.P0LastSpotPrice = osmomath.ZeroDec() // note that this one is zero due to spot price error. + r.P1LastSpotPrice = osmomath.ZeroDec() // note that this one is zero due to spot price error. return r }(), @@ -248,8 +249,8 @@ func TestTWAPRecord_Validate(t *testing.T) { twapRecord: func() TwapRecord { r := baseRecord r.LastErrorTime = r.Time - r.P0LastSpotPrice = sdk.NewDec(5) - r.P1LastSpotPrice = sdk.NewDecWithPrec(2, 1) + r.P0LastSpotPrice = osmomath.NewDec(5) + r.P1LastSpotPrice = osmomath.NewDecWithPrec(2, 1) return r }(), @@ -263,9 +264,9 @@ func TestTWAPRecord_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), } return r }(), @@ -280,9 +281,9 @@ func TestTWAPRecord_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), } return r }(), @@ -292,7 +293,7 @@ func TestTWAPRecord_Validate(t *testing.T) { "invalid p0 arithmetic accum: negative": { twapRecord: func() TwapRecord { r := baseRecord - r.P0ArithmeticTwapAccumulator = sdk.OneDec().Neg() + r.P0ArithmeticTwapAccumulator = osmomath.OneDec().Neg() return r }(), @@ -306,9 +307,9 @@ func TestTWAPRecord_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), } return r }(), @@ -323,9 +324,9 @@ func TestTWAPRecord_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), } return r }(), @@ -339,10 +340,10 @@ func TestTWAPRecord_Validate(t *testing.T) { Asset1Denom: denom1, Height: 3, Time: tPlusOne.Add(time.Second), - P0LastSpotPrice: sdk.OneDec(), - P1LastSpotPrice: sdk.OneDec(), - P0ArithmeticTwapAccumulator: sdk.OneDec(), - P1ArithmeticTwapAccumulator: sdk.OneDec(), + P0LastSpotPrice: osmomath.OneDec(), + P1LastSpotPrice: osmomath.OneDec(), + P0ArithmeticTwapAccumulator: osmomath.OneDec(), + P1ArithmeticTwapAccumulator: osmomath.OneDec(), } return r }(), diff --git a/x/twap/types/keys.go b/x/twap/types/keys.go index a1a003f8064..25390b91496 100644 --- a/x/twap/types/keys.go +++ b/x/twap/types/keys.go @@ -8,6 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" ) @@ -92,7 +93,7 @@ func ParseTwapFromBz(bz []byte) (twap TwapRecord, err error) { } err = proto.Unmarshal(bz, &twap) if twap.GeometricTwapAccumulator.IsNil() { - twap.GeometricTwapAccumulator = sdk.ZeroDec() + twap.GeometricTwapAccumulator = osmomath.ZeroDec() } return twap, err } diff --git a/x/twap/types/keys_test.go b/x/twap/types/keys_test.go index 35393c4a6ec..f155694584e 100644 --- a/x/twap/types/keys_test.go +++ b/x/twap/types/keys_test.go @@ -5,9 +5,10 @@ import ( "testing" time "time" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" + + "github.com/osmosis-labs/osmosis/osmomath" ) func TestFormatMostRecentTWAPKey(t *testing.T) { @@ -67,13 +68,14 @@ func TestParseTwapFromBz(t *testing.T) { Asset1Denom: "A", Height: 1, Time: baseTime, - P0LastSpotPrice: sdk.NewDecWithPrec(1, 5), - P1LastSpotPrice: sdk.NewDecWithPrec(2, 5), // inconsistent value - P0ArithmeticTwapAccumulator: sdk.ZeroDec(), - P1ArithmeticTwapAccumulator: sdk.ZeroDec(), + P0LastSpotPrice: osmomath.NewDecWithPrec(1, 5), + P1LastSpotPrice: osmomath.NewDecWithPrec(2, 5), // inconsistent value + P0ArithmeticTwapAccumulator: osmomath.ZeroDec(), + P1ArithmeticTwapAccumulator: osmomath.ZeroDec(), + GeometricTwapAccumulator: osmomath.ZeroDec(), } - withGeomAcc := func(r TwapRecord, acc sdk.Dec) TwapRecord { + withGeomAcc := func(r TwapRecord, acc osmomath.Dec) TwapRecord { r.GeometricTwapAccumulator = acc return r } @@ -87,11 +89,11 @@ func TestParseTwapFromBz(t *testing.T) { false, }, "with nil geometric twap accumulator -> set to zero": { - withGeomAcc(baseParseRecord, sdk.Dec{}), + withGeomAcc(baseParseRecord, osmomath.Dec{}), true, }, "with non-nil geometric twap accumulator -> not overwritten": { - withGeomAcc(baseParseRecord, sdk.OneDec()), + withGeomAcc(baseParseRecord, osmomath.OneDec()), false, }, } @@ -104,7 +106,7 @@ func TestParseTwapFromBz(t *testing.T) { require.NoError(t, err) if tt.isGeometricAccumNil { - tt.record.GeometricTwapAccumulator = sdk.ZeroDec() + tt.record.GeometricTwapAccumulator = osmomath.ZeroDec() } require.Equal(t, tt.record, record) diff --git a/x/twap/types/twap_record.pb.go b/x/twap/types/twap_record.pb.go index 74b75fb452c..84fc0824f38 100644 --- a/x/twap/types/twap_record.pb.go +++ b/x/twap/types/twap_record.pb.go @@ -4,11 +4,11 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" _ "github.com/cosmos/cosmos-proto" _ "github.com/cosmos/cosmos-sdk/codec/types" _ "github.com/cosmos/cosmos-sdk/types" - 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" @@ -51,11 +51,11 @@ type TwapRecord struct { Time time.Time `protobuf:"bytes,5,opt,name=time,proto3,stdtime" json:"time" yaml:"record_time"` // We store the last spot prices in the struct, so that we can interpolate // accumulator values for times between when accumulator records are stored. - P0LastSpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,6,opt,name=p0_last_spot_price,json=p0LastSpotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p0_last_spot_price"` - P1LastSpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,7,opt,name=p1_last_spot_price,json=p1LastSpotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p1_last_spot_price"` - P0ArithmeticTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,8,opt,name=p0_arithmetic_twap_accumulator,json=p0ArithmeticTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p0_arithmetic_twap_accumulator"` - P1ArithmeticTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,9,opt,name=p1_arithmetic_twap_accumulator,json=p1ArithmeticTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"p1_arithmetic_twap_accumulator"` - GeometricTwapAccumulator github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,10,opt,name=geometric_twap_accumulator,json=geometricTwapAccumulator,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"geometric_twap_accumulator"` + P0LastSpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,6,opt,name=p0_last_spot_price,json=p0LastSpotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"p0_last_spot_price"` + P1LastSpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,7,opt,name=p1_last_spot_price,json=p1LastSpotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"p1_last_spot_price"` + P0ArithmeticTwapAccumulator cosmossdk_io_math.LegacyDec `protobuf:"bytes,8,opt,name=p0_arithmetic_twap_accumulator,json=p0ArithmeticTwapAccumulator,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"p0_arithmetic_twap_accumulator"` + P1ArithmeticTwapAccumulator cosmossdk_io_math.LegacyDec `protobuf:"bytes,9,opt,name=p1_arithmetic_twap_accumulator,json=p1ArithmeticTwapAccumulator,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"p1_arithmetic_twap_accumulator"` + GeometricTwapAccumulator cosmossdk_io_math.LegacyDec `protobuf:"bytes,10,opt,name=geometric_twap_accumulator,json=geometricTwapAccumulator,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"geometric_twap_accumulator"` // This field contains the time in which the last spot price error occured. // It is used to alert the caller if they are getting a potentially erroneous // TWAP, due to an unforeseen underlying error. @@ -146,41 +146,41 @@ func init() { } var fileDescriptor_dbf5c78678e601aa = []byte{ - // 540 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xbf, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0x63, 0x1a, 0x52, 0x7a, 0xa1, 0xaa, 0x64, 0x45, 0x60, 0x82, 0x64, 0x87, 0x0c, 0x55, - 0x18, 0xea, 0x1f, 0x30, 0xc1, 0x96, 0xa8, 0x0c, 0x20, 0x84, 0x90, 0xe9, 0x04, 0xc3, 0xe9, 0x6c, - 0x5f, 0x1d, 0x0b, 0x3b, 0x77, 0xba, 0xbb, 0xb4, 0xe4, 0xbf, 0xe8, 0x9f, 0xd5, 0xb1, 0x23, 0x62, - 0x30, 0x28, 0xd9, 0x18, 0x3b, 0x31, 0xa2, 0xfb, 0x91, 0xd0, 0x84, 0x5f, 0x52, 0xa6, 0xe4, 0xbd, - 0xf7, 0x7d, 0x9f, 0xef, 0x7b, 0xf6, 0x93, 0xc1, 0x21, 0xe1, 0x15, 0xe1, 0x05, 0x0f, 0xc4, 0x39, - 0xa2, 0xc1, 0x59, 0x94, 0x60, 0x81, 0x22, 0x15, 0x40, 0x86, 0x53, 0xc2, 0x32, 0x9f, 0x32, 0x22, - 0x88, 0xdd, 0x31, 0x3a, 0x5f, 0x96, 0x7c, 0xa3, 0xeb, 0x76, 0x72, 0x92, 0x13, 0x25, 0x08, 0xe4, - 0x3f, 0xad, 0xed, 0x3e, 0xc8, 0x09, 0xc9, 0x4b, 0x1c, 0xa8, 0x28, 0x99, 0x9e, 0x06, 0x68, 0x32, - 0x5b, 0x96, 0x52, 0xc5, 0x81, 0xba, 0x47, 0x07, 0xa6, 0xe4, 0xea, 0x28, 0x48, 0x10, 0xc7, 0xab, - 0x41, 0x52, 0x52, 0x4c, 0x4c, 0xdd, 0xdb, 0xa4, 0x8a, 0xa2, 0xc2, 0x5c, 0xa0, 0x8a, 0x6a, 0x41, - 0xff, 0x47, 0x0b, 0x80, 0x93, 0x73, 0x44, 0x63, 0x35, 0xb7, 0x7d, 0x1f, 0xec, 0x52, 0x42, 0x4a, - 0x58, 0x64, 0x8e, 0xd5, 0xb3, 0x06, 0xcd, 0xb8, 0x25, 0xc3, 0x97, 0x99, 0xfd, 0x08, 0xdc, 0x45, - 0x9c, 0x63, 0x11, 0xc2, 0x0c, 0x4f, 0x48, 0xe5, 0xdc, 0xea, 0x59, 0x83, 0xbd, 0xb8, 0xad, 0x73, - 0xc7, 0x32, 0xb5, 0x92, 0x44, 0x46, 0xb2, 0x73, 0x43, 0x12, 0x69, 0xc9, 0x10, 0xb4, 0xc6, 0xb8, - 0xc8, 0xc7, 0xc2, 0x69, 0xf6, 0xac, 0xc1, 0xce, 0xe8, 0xf1, 0xf7, 0xda, 0xdb, 0xd7, 0x8f, 0x0c, - 0xea, 0xc2, 0x75, 0xed, 0x75, 0x66, 0xa8, 0x2a, 0x9f, 0xf7, 0xd7, 0xd2, 0xfd, 0xd8, 0x34, 0xda, - 0x6f, 0x40, 0x53, 0xee, 0xe0, 0xdc, 0xee, 0x59, 0x83, 0xf6, 0x93, 0xae, 0xaf, 0x17, 0xf4, 0x97, - 0x0b, 0xfa, 0x27, 0xcb, 0x05, 0x47, 0xee, 0x65, 0xed, 0x35, 0xae, 0x6b, 0xcf, 0x5e, 0xe3, 0xc9, - 0xe6, 0xfe, 0xc5, 0x57, 0xcf, 0x8a, 0x15, 0xc7, 0xfe, 0x00, 0x6c, 0x1a, 0xc2, 0x12, 0x71, 0x01, - 0x39, 0x25, 0x02, 0x52, 0x56, 0xa4, 0xd8, 0x69, 0xc9, 0xd9, 0x47, 0xbe, 0x24, 0x7c, 0xa9, 0xbd, - 0xc3, 0xbc, 0x10, 0xe3, 0x69, 0xe2, 0xa7, 0xa4, 0x32, 0x8f, 0xdf, 0xfc, 0x1c, 0xf1, 0xec, 0x63, - 0x20, 0x66, 0x14, 0x73, 0xff, 0x18, 0xa7, 0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gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0xc7, 0x63, 0x1a, 0x52, 0xba, 0xa1, 0xaa, 0x64, 0x45, 0x60, 0x52, 0xc9, 0x0e, 0x41, 0x42, + 0xe1, 0x80, 0x3f, 0xe0, 0x04, 0xb7, 0x44, 0xe5, 0x00, 0xaa, 0x50, 0x65, 0x7a, 0xe2, 0x62, 0xad, + 0x9d, 0xad, 0x6d, 0x61, 0x67, 0x56, 0xbb, 0x9b, 0x96, 0xbc, 0x45, 0x5f, 0x89, 0x5b, 0x8f, 0x3d, + 0x22, 0x0e, 0x06, 0x25, 0x37, 0x8e, 0x7d, 0x02, 0xb4, 0xbb, 0x4e, 0x20, 0xe1, 0xab, 0xbd, 0x79, + 0x66, 0xfe, 0xf3, 0xfb, 0xef, 0x78, 0x47, 0x8b, 0x1e, 0x03, 0x2f, 0x81, 0xe7, 0xdc, 0x13, 0x67, + 0x98, 0x7a, 0xa7, 0x41, 0x4c, 0x04, 0x0e, 0x54, 0x10, 0x31, 0x92, 0x00, 0x1b, 0xbb, 0x94, 0x81, + 0x00, 0xb3, 0x53, 0xeb, 0x5c, 0x59, 0x72, 0x6b, 0x5d, 0xb7, 0x93, 0x42, 0x0a, 0x4a, 0xe0, 0xc9, + 0x2f, 0xad, 0xed, 0x3e, 0x48, 0x01, 0xd2, 0x82, 0x78, 0x2a, 0x8a, 0xa7, 0x27, 0x1e, 0x9e, 0xcc, + 0x96, 0xa5, 0x44, 0x71, 0x22, 0xdd, 0xa3, 0x83, 0xba, 0x64, 0xeb, 0xc8, 0x8b, 0x31, 0x27, 0xab, + 0x83, 0x24, 0x90, 0x4f, 0xea, 0xba, 0xb3, 0x49, 0x15, 0x79, 0x49, 0xb8, 0xc0, 0x25, 0xd5, 0x82, + 0xfe, 0xa7, 0x16, 0x42, 0xc7, 0x67, 0x98, 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41, 0x1c, 0xc9, 0x5e, + 0x45, 0x0c, 0x7e, 0x23, 0x6e, 0xdf, 0x84, 0x18, 0xac, 0x13, 0x33, 0x64, 0x53, 0x3f, 0xc2, 0x2c, + 0x17, 0x59, 0x49, 0x44, 0x9e, 0x44, 0x6a, 0xd5, 0x70, 0x92, 0x4c, 0xcb, 0x69, 0x81, 0x05, 0x30, + 0xeb, 0xce, 0xf5, 0xe9, 0xfb, 0xd4, 0x1f, 0xae, 0x48, 0xf2, 0xea, 0x87, 0x3f, 0x39, 0xca, 0x29, + 0xf8, 0xa7, 0xd3, 0xce, 0x4d, 0x9c, 0x82, 0xbf, 0x3b, 0x61, 0xd4, 0x4d, 0x09, 0x94, 0x44, 0xb0, + 0x3f, 0xb9, 0xa0, 0xeb, 0xbb, 0x58, 0x2b, 0xcc, 0xa6, 0xc5, 0x09, 0xda, 0x53, 0xb7, 0x40, 0x18, + 0x03, 0xa6, 0x2e, 0xde, 0x6a, 0xff, 0x77, 0x6b, 0xfa, 0xf5, 0xd6, 0xdc, 0xd3, 0x5b, 0xb3, 0x01, + 0xd0, 0x9b, 0xb3, 0x2b, 0xb3, 0xaf, 0x64, 0x52, 0xf6, 0x8d, 0xde, 0x5c, 0xcc, 0x6d, 0xe3, 0x72, + 0x6e, 0x1b, 0xdf, 0xe6, 0xb6, 0x71, 0xbe, 0xb0, 0x1b, 0x97, 0x0b, 0xbb, 0xf1, 0x79, 0x61, 0x37, + 0xde, 0xfb, 0x69, 0x2e, 0xb2, 0x69, 0xec, 0x26, 0x50, 0x7a, 0xf5, 0x5b, 0xf0, 0xb4, 0xc0, 0x31, + 0x5f, 0x06, 0xde, 0x69, 0xf0, 0xc2, 0xfb, 0xa8, 0x9f, 0x11, 0x31, 0xa3, 0x84, 0xc7, 0x2d, 0x75, + 0xa4, 0xe7, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xfe, 0xc4, 0xd7, 0x79, 0x63, 0x04, 0x00, 0x00, } func (m *TwapRecord) Marshal() (dAtA []byte, err error) { diff --git a/x/twap/types/twapmock/amminterface.go b/x/twap/types/twapmock/amminterface.go index e5611fed586..508db6204dd 100644 --- a/x/twap/types/twapmock/amminterface.go +++ b/x/twap/types/twapmock/amminterface.go @@ -3,6 +3,7 @@ package twapmock import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/twap/types" ) @@ -21,7 +22,7 @@ type SpotPriceInput struct { quoteDenom string } type SpotPriceResult struct { - Sp sdk.Dec + Sp osmomath.Dec Err error } @@ -52,7 +53,7 @@ func (p *ProgrammedPoolManagerInterface) ProgramPoolDenomsOverride(poolId uint64 } func (p *ProgrammedPoolManagerInterface) ProgramPoolSpotPriceOverride(poolId uint64, - quoteDenom, baseDenom string, overrideSp sdk.Dec, overrideErr error, + quoteDenom, baseDenom string, overrideSp osmomath.Dec, overrideErr error, ) { input := SpotPriceInput{poolId, baseDenom, quoteDenom} p.programmedSpotPrice[input] = SpotPriceResult{overrideSp, overrideErr} @@ -73,7 +74,7 @@ func (p *ProgrammedPoolManagerInterface) RouteCalculateSpotPrice(ctx sdk.Context poolId uint64, quoteDenom, baseDenom string, -) (price sdk.Dec, err error) { +) (price osmomath.Dec, err error) { input := SpotPriceInput{poolId, baseDenom, quoteDenom} if res, ok := p.programmedSpotPrice[input]; ok { return res.Sp, res.Err diff --git a/x/twap/types/utils.go b/x/twap/types/utils.go index 7ed86258681..cd112f2a8f9 100644 --- a/x/twap/types/utils.go +++ b/x/twap/types/utils.go @@ -5,10 +5,10 @@ import ( "sort" "time" - sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" ) -var MaxSpotPrice = sdk.NewDec(2).Power(128).Sub(sdk.OneDec()) +var MaxSpotPrice = osmomath.NewDec(2).Power(128).Sub(osmomath.OneDec()) // GetAllUniqueDenomPairs returns all unique pairs of denoms, where for every pair // (X, Y), X < Y. @@ -37,13 +37,13 @@ func GetAllUniqueDenomPairs(denoms []string) []DenomPair { // SpotPriceMulDuration returns the spot price multiplied by the time delta, // that is the spot price between the current and last TWAP record. // A single second accounts for 1_000_000_000 when converted to int64. -func SpotPriceMulDuration(sp sdk.Dec, timeDeltaMs int64) sdk.Dec { +func SpotPriceMulDuration(sp osmomath.Dec, timeDeltaMs int64) osmomath.Dec { return sp.MulInt64(timeDeltaMs) } -// AccumDiffDivDuration returns the accumulated difference divided by the the +// AccumDiffDivDuration returns the osmomath.Decated difference dividosmomath.Deche the // time delta, that is the spot price between the current and last TWAP record. -func AccumDiffDivDuration(accumDiff sdk.Dec, timeDeltaMs int64) sdk.Dec { +func AccumDiffDivDuration(accumDiff osmomath.Dec, timeDeltaMs int64) osmomath.Dec { return accumDiff.QuoInt64(timeDeltaMs) } diff --git a/x/txfees/keeper/feedecorator.go b/x/txfees/keeper/feedecorator.go index 45321068dbe..069dbcb7b4c 100644 --- a/x/txfees/keeper/feedecorator.go +++ b/x/txfees/keeper/feedecorator.go @@ -7,6 +7,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/txfees/keeper/txfee_filters" "github.com/osmosis-labs/osmosis/v19/x/txfees/types" @@ -95,7 +96,7 @@ func (mfd MempoolFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate b return next(ctx, tx, simulate) } -func (mfd MempoolFeeDecorator) getMinBaseGasPrice(ctx sdk.Context, baseDenom string, simulate bool, feeTx sdk.FeeTx) sdk.Dec { +func (mfd MempoolFeeDecorator) getMinBaseGasPrice(ctx sdk.Context, baseDenom string, simulate bool, feeTx sdk.FeeTx) osmomath.Dec { // In block execution (DeliverTx), its set to the governance decided upon consensus min fee. minBaseGasPrice := types.ConsensusMinFee // If we are in CheckTx, a separate function is ran locally to ensure sufficient fees for entering our mempool. @@ -105,14 +106,14 @@ func (mfd MempoolFeeDecorator) getMinBaseGasPrice(ctx sdk.Context, baseDenom str } // If we are in genesis or are simulating a tx, then we actually override all of the above, to set it to 0. if ctx.IsGenesis() || simulate { - minBaseGasPrice = sdk.ZeroDec() + minBaseGasPrice = osmomath.ZeroDec() } return minBaseGasPrice } // IsSufficientFee checks if the feeCoin provided (in any asset), is worth enough osmo at current spot prices // to pay the gas cost of this tx. -func (k Keeper) IsSufficientFee(ctx sdk.Context, minBaseGasPrice sdk.Dec, gasRequested uint64, feeCoin sdk.Coin) error { +func (k Keeper) IsSufficientFee(ctx sdk.Context, minBaseGasPrice osmomath.Dec, gasRequested uint64, feeCoin sdk.Coin) error { baseDenom, err := k.GetBaseDenom(ctx) if err != nil { return err @@ -120,7 +121,7 @@ func (k Keeper) IsSufficientFee(ctx sdk.Context, minBaseGasPrice sdk.Dec, gasReq // Determine the required fees by multiplying the required minimum gas // price by the gas limit, where fee = ceil(minGasPrice * gasLimit). - glDec := sdk.NewDec(int64(gasRequested)) + glDec := osmomath.NewDec(int64(gasRequested)) requiredBaseFee := sdk.NewCoin(baseDenom, minBaseGasPrice.Mul(glDec).Ceil().RoundInt()) convertedFee, err := k.ConvertToBaseToken(ctx, feeCoin) @@ -135,7 +136,7 @@ func (k Keeper) IsSufficientFee(ctx sdk.Context, minBaseGasPrice sdk.Dec, gasReq return nil } -func (mfd MempoolFeeDecorator) GetMinBaseGasPriceForTx(ctx sdk.Context, baseDenom string, tx sdk.FeeTx) sdk.Dec { +func (mfd MempoolFeeDecorator) GetMinBaseGasPriceForTx(ctx sdk.Context, baseDenom string, tx sdk.FeeTx) osmomath.Dec { cfgMinGasPrice := ctx.MinGasPrices().AmountOf(baseDenom) // the check below prevents tx gas from getting over HighGasTxThreshold which is default to 1_000_000 if tx.GetGas() >= mfd.Opts.HighGasTxThreshold { diff --git a/x/txfees/keeper/feedecorator_test.go b/x/txfees/keeper/feedecorator_test.go index 489cf6f67b0..2e8d8ca6c8b 100644 --- a/x/txfees/keeper/feedecorator_test.go +++ b/x/txfees/keeper/feedecorator_test.go @@ -11,6 +11,7 @@ import ( authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/txfees/keeper" "github.com/osmosis-labs/osmosis/v19/x/txfees/types" ) @@ -19,12 +20,12 @@ func (s *KeeperTestSuite) TestFeeDecorator() { s.SetupTest(false) mempoolFeeOpts := types.NewDefaultMempoolFeeOptions() - mempoolFeeOpts.MinGasPriceForHighGasTx = sdk.MustNewDecFromStr("0.0025") + mempoolFeeOpts.MinGasPriceForHighGasTx = osmomath.MustNewDecFromStr("0.0025") baseDenom, _ := s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) baseGas := uint64(10000) consensusMinFeeAmt := int64(25) point1BaseDenomMinGasPrices := sdk.NewDecCoins(sdk.NewDecCoinFromDec(baseDenom, - sdk.MustNewDecFromStr("0.1"))) + osmomath.MustNewDecFromStr("0.1"))) // uion is setup with a relative price of 1:1 uion := "uion" diff --git a/x/txfees/keeper/feetokens.go b/x/txfees/keeper/feetokens.go index 9f1fd50e238..f4eea8230fb 100644 --- a/x/txfees/keeper/feetokens.go +++ b/x/txfees/keeper/feetokens.go @@ -5,6 +5,7 @@ import ( errorsmod "cosmossdk.io/errors" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/txfees/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -38,20 +39,20 @@ func (k Keeper) ConvertToBaseToken(ctx sdk.Context, inputFee sdk.Coin) (sdk.Coin // Spot Price Calculation: spotPrice / (1 - spreadFactor), // where spotPrice is defined as: // (tokenBalanceIn / tokenWeightIn) / (tokenBalanceOut / tokenWeightOut) -func (k Keeper) CalcFeeSpotPrice(ctx sdk.Context, inputDenom string) (sdk.Dec, error) { +func (k Keeper) CalcFeeSpotPrice(ctx sdk.Context, inputDenom string) (osmomath.Dec, error) { baseDenom, err := k.GetBaseDenom(ctx) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } feeToken, err := k.GetFeeToken(ctx, inputDenom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } spotPrice, err := k.spotPriceCalculator.CalculateSpotPrice(ctx, feeToken.PoolID, baseDenom, feeToken.Denom) if err != nil { - return sdk.Dec{}, err + return osmomath.Dec{}, err } return spotPrice, nil } diff --git a/x/txfees/keeper/hooks.go b/x/txfees/keeper/hooks.go index 5979b67f89e..e2c835f6bad 100644 --- a/x/txfees/keeper/hooks.go +++ b/x/txfees/keeper/hooks.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/osmoutils" txfeestypes "github.com/osmosis-labs/osmosis/v19/x/txfees/types" epochstypes "github.com/osmosis-labs/osmosis/x/epochs/types" @@ -108,7 +109,7 @@ func (k Keeper) swapNonNativeFeeToDenom(ctx sdk.Context, denomToSwapTo string, f // 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() + minAmountOut := osmomath.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. diff --git a/x/txfees/keeper/hooks_test.go b/x/txfees/keeper/hooks_test.go index fcfbf76da9e..f3a02fde560 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/osmomath" "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" @@ -55,7 +56,7 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { baseDenom string denoms []string poolTypes []poolmanagertypes.PoolI - spreadFactor sdk.Dec + spreadFactor osmomath.Dec expectPass bool }{ { @@ -64,7 +65,7 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { baseDenom: baseDenom, denoms: []string{uion}, poolTypes: []poolmanagertypes.PoolI{uionPool}, - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), }, { name: "Multiple non-osmo fee token: TxFees AfterEpochEnd", @@ -72,11 +73,11 @@ func (s *KeeperTestSuite) TestTxFeesAfterEpochEnd() { baseDenom: baseDenom, denoms: []string{atom, ust}, poolTypes: []poolmanagertypes.PoolI{atomPool, ustPool}, - spreadFactor: sdk.MustNewDecFromStr("0"), + spreadFactor: osmomath.MustNewDecFromStr("0"), }, } - finalOutputAmount := sdk.NewInt(0) + finalOutputAmount := osmomath.NewInt(0) for _, tc := range tests { tc := tc @@ -132,8 +133,8 @@ func (s *KeeperTestSuite) TestSwapNonNativeFeeToDenom() { 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))) + defaultPoolCoins = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, osmomath.NewInt(100))) + defaultBalanceToSwap = sdk.NewCoins(sdk.NewCoin("foo", osmomath.NewInt(100))) ) tests := []struct { @@ -199,8 +200,8 @@ func (s *KeeperTestSuite) TestSwapNonNativeFeeToDenom_SimpleCases() { var ( defaultTxFeesDenom, _ = s.App.TxFeesKeeper.GetBaseDenom(s.Ctx) - defaultPoolCoins = sdk.NewCoins(sdk.NewCoin(preSwapDenom, sdk.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, sdk.NewInt(100))) - defaultBalanceToSwap = sdk.NewCoins(sdk.NewCoin(preSwapDenom, sdk.NewInt(100))) + defaultPoolCoins = sdk.NewCoins(sdk.NewCoin(preSwapDenom, osmomath.NewInt(100)), sdk.NewCoin(defaultTxFeesDenom, osmomath.NewInt(100))) + defaultBalanceToSwap = sdk.NewCoins(sdk.NewCoin(preSwapDenom, osmomath.NewInt(100))) defaultProtorevLinkDenoms = []string{preSwapDenom, defaultTxFeesDenom} reversedProtorevLinkDenoms = []string{defaultTxFeesDenom, preSwapDenom} ) @@ -461,8 +462,8 @@ func (s *KeeperTestSuite) preparePoolsForSwappingToDenom(nonNativeDenomA, nonNat poolIdTwo := s.PrepareConcentratedPoolWithCoins(nonNativeDenomB, denomToSwapTo).GetId() // Add liquidity to both pools - poolOneCoins := sdk.NewCoins(sdk.NewCoin(nonNativeDenomA, sdk.NewInt(100)), sdk.NewCoin(denomToSwapTo, sdk.NewInt(100))) - poolTwoCoins := sdk.NewCoins(sdk.NewCoin(nonNativeDenomB, sdk.NewInt(100)), sdk.NewCoin(denomToSwapTo, sdk.NewInt(100))) + poolOneCoins := sdk.NewCoins(sdk.NewCoin(nonNativeDenomA, osmomath.NewInt(100)), sdk.NewCoin(denomToSwapTo, osmomath.NewInt(100))) + poolTwoCoins := sdk.NewCoins(sdk.NewCoin(nonNativeDenomB, osmomath.NewInt(100)), sdk.NewCoin(denomToSwapTo, osmomath.NewInt(100))) s.FundAcc(s.TestAccs[0], poolOneCoins.Add(poolTwoCoins...)) _, err := s.App.ConcentratedLiquidityKeeper.CreateFullRangePosition(s.Ctx, poolIdOne, s.TestAccs[0], poolOneCoins) @@ -481,10 +482,10 @@ func (s *KeeperTestSuite) preparePoolsForSwappingToDenom(nonNativeDenomA, nonNat // returns a set of coins that covers all edge cases and success scenarios for swapping to denom. func prepareCoinsForSwapToDenomTest(swapToDenom string) sdk.Coins { return sdk.NewCoins( - sdk.NewCoin(preSwapDenom, sdk.NewInt(100)), // first pool with a link to denom pair in protorev (gets swapped) - sdk.NewCoin(swapToDenom, sdk.NewInt(300)), // swapToDenom (left as is in balance) - sdk.NewCoin(denomWithNoPool, sdk.NewInt(400)), // no pool exists, silently skipped - sdk.NewCoin(denomWithNoProtorevLink, sdk.NewInt(500)), // pool with no link to denom pair in protorev, silently skipped - sdk.NewCoin(otherPreSwapDenom, sdk.NewInt(600)), // second pool with a link to denom pair in protorev (gets swapped) + sdk.NewCoin(preSwapDenom, osmomath.NewInt(100)), // first pool with a link to denom pair in protorev (gets swapped) + sdk.NewCoin(swapToDenom, osmomath.NewInt(300)), // swapToDenom (left as is in balance) + sdk.NewCoin(denomWithNoPool, osmomath.NewInt(400)), // no pool exists, silently skipped + sdk.NewCoin(denomWithNoProtorevLink, osmomath.NewInt(500)), // pool with no link to denom pair in protorev, silently skipped + sdk.NewCoin(otherPreSwapDenom, osmomath.NewInt(600)), // second pool with a link to denom pair in protorev (gets swapped) ) } diff --git a/x/txfees/keeper/keeper_test.go b/x/txfees/keeper/keeper_test.go index 7eee526f7cf..87d61f561c3 100644 --- a/x/txfees/keeper/keeper_test.go +++ b/x/txfees/keeper/keeper_test.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" osmosisapp "github.com/osmosis-labs/osmosis/v19/app" "github.com/osmosis-labs/osmosis/v19/app/apptesting" @@ -46,7 +47,7 @@ func (s *KeeperTestSuite) SetupTest(isCheckTx bool) { baseDenomPriorities := []protorevtypes.BaseDenom{ { Denom: baseDenom, - StepSize: sdk.NewInt(1_000_000), + StepSize: osmomath.NewInt(1_000_000), }, } err = s.App.ProtoRevKeeper.SetBaseDenoms(s.Ctx, baseDenomPriorities) @@ -56,13 +57,13 @@ func (s *KeeperTestSuite) SetupTest(isCheckTx bool) { for _, acc := range s.TestAccs { s.FundAcc(acc, sdk.NewCoins( - sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10000000000)), - sdk.NewCoin("uosmo", sdk.NewInt(100000000000000000)), // Needed for pool creation fee - sdk.NewCoin("uion", sdk.NewInt(10000000)), - sdk.NewCoin("atom", sdk.NewInt(10000000)), - sdk.NewCoin("ust", sdk.NewInt(10000000)), - sdk.NewCoin("foo", sdk.NewInt(10000000)), - sdk.NewCoin("bar", sdk.NewInt(10000000)), + sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10000000000)), + sdk.NewCoin("uosmo", osmomath.NewInt(100000000000000000)), // Needed for pool creation fee + sdk.NewCoin("uion", osmomath.NewInt(10000000)), + sdk.NewCoin("atom", osmomath.NewInt(10000000)), + sdk.NewCoin("ust", osmomath.NewInt(10000000)), + sdk.NewCoin("foo", osmomath.NewInt(10000000)), + sdk.NewCoin("bar", osmomath.NewInt(10000000)), )) } } diff --git a/x/txfees/types/constants.go b/x/txfees/types/constants.go index 57d4352ad20..3f0fd199333 100644 --- a/x/txfees/types/constants.go +++ b/x/txfees/types/constants.go @@ -1,7 +1,9 @@ package types -import sdk "github.com/cosmos/cosmos-sdk/types" +import ( + "github.com/osmosis-labs/osmosis/osmomath" +) // ConsensusMinFee is a governance set parameter from prop 354 (https://www.mintscan.io/osmosis/proposals/354) // Its intended to be .0025 uosmo / gas -var ConsensusMinFee sdk.Dec = sdk.NewDecWithPrec(25, 4) +var ConsensusMinFee osmomath.Dec = osmomath.NewDecWithPrec(25, 4) diff --git a/x/txfees/types/expected_keepers.go b/x/txfees/types/expected_keepers.go index cd0de930a52..cf9858b0ca5 100644 --- a/x/txfees/types/expected_keepers.go +++ b/x/txfees/types/expected_keepers.go @@ -4,13 +4,14 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/osmosis-labs/osmosis/osmomath" poolmanagertypes "github.com/osmosis-labs/osmosis/v19/x/poolmanager/types" ) // SpotPriceCalculator defines the contract that must be fulfilled by a spot price calculator // The x/gamm keeper is expected to satisfy this interface. type SpotPriceCalculator interface { - CalculateSpotPrice(ctx sdk.Context, poolId uint64, quoteDenom, baseDenom string) (sdk.Dec, error) + CalculateSpotPrice(ctx sdk.Context, poolId uint64, quoteDenom, baseDenom string) (osmomath.Dec, error) } // PoolManager defines the contract needed for swap related APIs. @@ -20,7 +21,7 @@ type PoolManager interface { sender sdk.AccAddress, routes []poolmanagertypes.SwapAmountInRoute, tokenIn sdk.Coin, - tokenOutMinAmount sdk.Int) (tokenOutAmount sdk.Int, err error) + tokenOutMinAmount osmomath.Int) (tokenOutAmount osmomath.Int, err error) SwapExactAmountIn( ctx sdk.Context, @@ -28,8 +29,8 @@ type PoolManager interface { poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - ) (sdk.Int, error) + tokenOutMinAmount osmomath.Int, + ) (osmomath.Int, error) SwapExactAmountInNoTakerFee( ctx sdk.Context, @@ -37,8 +38,8 @@ type PoolManager interface { poolId uint64, tokenIn sdk.Coin, tokenOutDenom string, - tokenOutMinAmount sdk.Int, - ) (sdk.Int, error) + tokenOutMinAmount osmomath.Int, + ) (osmomath.Int, error) GetParams(ctx sdk.Context) (params poolmanagertypes.Params) } diff --git a/x/txfees/types/options.go b/x/txfees/types/options.go index 8527fb2cd1d..4191b5a253f 100644 --- a/x/txfees/types/options.go +++ b/x/txfees/types/options.go @@ -5,8 +5,9 @@ import ( "github.com/spf13/cast" + "github.com/osmosis-labs/osmosis/osmomath" + servertypes "github.com/cosmos/cosmos-sdk/server/types" - sdk "github.com/cosmos/cosmos-sdk/types" ) // If Options are not set in a config somewhere, @@ -14,19 +15,19 @@ import ( // DefaultMinGasPriceForArbitrageTx represents minimum gas price // for arbitrage transactions. -var DefaultMinGasPriceForArbitrageTx = sdk.ZeroDec() +var DefaultMinGasPriceForArbitrageTx = osmomath.ZeroDec() var ( - DefaultMinGasPriceForHighGasTx = sdk.ZeroDec() + DefaultMinGasPriceForHighGasTx = osmomath.ZeroDec() DefaultMaxGasWantedPerTx = uint64(25 * 1000 * 1000) DefaultHighGasTxThreshold = uint64(1 * 1000 * 1000) ) type MempoolFeeOptions struct { MaxGasWantedPerTx uint64 - MinGasPriceForArbitrageTx sdk.Dec + MinGasPriceForArbitrageTx osmomath.Dec HighGasTxThreshold uint64 - MinGasPriceForHighGasTx sdk.Dec + MinGasPriceForHighGasTx osmomath.Dec } func NewDefaultMempoolFeeOptions() MempoolFeeOptions { @@ -59,15 +60,15 @@ func parseMaxGasWantedPerTx(opts servertypes.AppOptions) uint64 { return value } -func parseMinGasPriceForArbitrageTx(opts servertypes.AppOptions) sdk.Dec { +func parseMinGasPriceForArbitrageTx(opts servertypes.AppOptions) osmomath.Dec { return parseDecFromConfig(opts, "arbitrage-min-gas-fee", DefaultMinGasPriceForArbitrageTx.Clone()) } -func parseMinGasPriceForHighGasTx(opts servertypes.AppOptions) sdk.Dec { +func parseMinGasPriceForHighGasTx(opts servertypes.AppOptions) osmomath.Dec { return parseDecFromConfig(opts, "min-gas-price-for-high-gas-tx", DefaultMinGasPriceForHighGasTx.Clone()) } -func parseDecFromConfig(opts servertypes.AppOptions, optName string, defaultValue sdk.Dec) sdk.Dec { +func parseDecFromConfig(opts servertypes.AppOptions, optName string, defaultValue osmomath.Dec) osmomath.Dec { valueInterface := opts.Get("osmosis-mempool." + optName) value := defaultValue if valueInterface != nil { @@ -77,7 +78,7 @@ func parseDecFromConfig(opts servertypes.AppOptions, optName string, defaultValu } var err error // pre-pend 0 to allow the config to start with a decimal, e.g. ".01" - value, err = sdk.NewDecFromStr("0" + valueStr) + value, err = osmomath.NewDecFromStr("0" + valueStr) if err != nil { panic(fmt.Errorf("invalidly configured osmosis-mempool.%v, err= %v", optName, err)) } diff --git a/x/txfees/types/query.pb.go b/x/txfees/types/query.pb.go index 13a48b43178..d6b9c11beb0 100644 --- a/x/txfees/types/query.pb.go +++ b/x/txfees/types/query.pb.go @@ -5,8 +5,8 @@ package types import ( context "context" + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -160,8 +160,8 @@ func (m *QueryDenomSpotPriceRequest) GetDenom() string { // QueryDenomSpotPriceRequest defines grpc response structure for querying spot // price for the specified tx fee denom type QueryDenomSpotPriceResponse struct { - PoolID uint64 `protobuf:"varint,1,opt,name=poolID,proto3" json:"poolID,omitempty" yaml:"pool_id"` - SpotPrice github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=spot_price,json=spotPrice,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"spot_price" yaml:"spot_price"` + PoolID uint64 `protobuf:"varint,1,opt,name=poolID,proto3" json:"poolID,omitempty" yaml:"pool_id"` + SpotPrice cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=spot_price,json=spotPrice,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"spot_price" yaml:"spot_price"` } func (m *QueryDenomSpotPriceResponse) Reset() { *m = QueryDenomSpotPriceResponse{} } @@ -388,46 +388,46 @@ func init() { } var fileDescriptor_6cbc1b48c44dfdd6 = []byte{ - // 612 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0x41, 0x6f, 0x12, 0x4f, - 0x18, 0xc6, 0x99, 0xfe, 0xff, 0x34, 0x61, 0x6a, 0x1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, 0xc8, 0x4c, 0x1d, 0x94, 0xa6, 0x2e, - 0xbb, 0xf6, 0x29, 0xb4, 0x5c, 0x4f, 0x4c, 0x4c, 0x8f, 0x8b, 0x8f, 0xd9, 0x49, 0x6c, 0xad, 0x2e, - 0xbf, 0xb7, 0xaa, 0x3e, 0xb2, 0xe5, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2a, 0x88, 0x5d, 0xa8, - 0x1d, 0x06, 0x00, 0x00, + // 614 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xc1, 0x6a, 0x13, 0x41, + 0x18, 0xc7, 0xb3, 0xd5, 0x14, 0x32, 0x95, 0xa2, 0x83, 0x6d, 0xe3, 0x56, 0x36, 0x61, 0x50, 0x29, + 0x95, 0xec, 0x98, 0x44, 0x41, 0xbd, 0x19, 0x42, 0x41, 0x28, 0x52, 0x57, 0x41, 0xe8, 0x65, 0xd9, + 0x4d, 0xbe, 0x6c, 0x97, 0x26, 0x99, 0x6d, 0x66, 0x52, 0x1a, 0xc4, 0x8b, 0x4f, 0x20, 0x28, 0x3e, + 0x80, 0x17, 0x6f, 0x3e, 0x47, 0x8f, 0x05, 0x2f, 0xe2, 0x21, 0x48, 0xe2, 0x13, 0xe4, 0x09, 0x64, + 0x67, 0x67, 0xb3, 0x69, 0x9b, 0x98, 0xe6, 0x96, 0x99, 0xef, 0xff, 0xfd, 0xbf, 0xff, 0x97, 0xf9, + 0x25, 0x88, 0x30, 0xde, 0x62, 0xdc, 0xe7, 0x54, 0x9c, 0x34, 0x00, 0x38, 0x3d, 0x2e, 0xba, 0x20, + 0x9c, 0x22, 0x3d, 0xea, 0x42, 0xa7, 0x67, 0x06, 0x1d, 0x26, 0x18, 0x5e, 0x57, 0x1a, 0x33, 0xd2, + 0x98, 0x4a, 0xa3, 0xdf, 0xf6, 0x98, 0xc7, 0xa4, 0x84, 0x86, 0x9f,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, 0xfe, 0xe8, 0xea, 0x0d, 0x2a, 0xe7, 0x13, 0x99, + 0x93, 0xe2, 0xc2, 0xac, 0x9c, 0x32, 0x99, 0xad, 0x38, 0xa3, 0xef, 0xe5, 0xf1, 0x83, 0x7c, 0xf3, + 0x31, 0x49, 0x73, 0xde, 0xfc, 0x22, 0x8a, 0x73, 0xde, 0xfc, 0x12, 0xa0, 0xf3, 0xdf, 0x3c, 0x41, + 0xb4, 0xb2, 0x7b, 0x3a, 0x30, 0xb4, 0xb3, 0x81, 0xa1, 0xfd, 0x19, 0x18, 0xda, 0xa7, 0xa1, 0x91, + 0x3a, 0x1b, 0x1a, 0xa9, 0x5f, 0x43, 0x23, 0xb5, 0x5f, 0xf2, 0x7c, 0x71, 0xd0, 0x75, 0xcd, 0x1a, + 0x6b, 0xc5, 0x3e, 0x85, 0xa6, 0xe3, 0xf2, 0xb1, 0xe9, 0x71, 0xf1, 0x19, 0x3d, 0x89, 0xad, 0x45, + 0x2f, 0x00, 0xee, 0x2e, 0xcb, 0x7f, 0xd6, 0xf2, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xa7, 0x74, + 0x5a, 0x70, 0x12, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/x/valset-pref/README.md b/x/valset-pref/README.md index b537b2b43fc..38cb9e35190 100644 --- a/x/valset-pref/README.md +++ b/x/valset-pref/README.md @@ -90,7 +90,7 @@ If the user does not have an existing validator set use delegators' current stak - Check if the user has a validator-set and if so, get the users validator-set from `KVStore`. - Safety Checks - check if the user has enough funds to delegate. - - check overflow/underflow since `Delegate` method takes `sdk.Int` as tokenAmount. + - check overflow/underflow since `Delegate` method takes `osmomath.Int` as tokenAmount. - use the [Delegate](https://github.com/cosmos/cosmos-sdk/blob/main/x/staking/keeper/delegation.go#L614) method from the cosmos-sdk to handle delegation. ### MsgUndelegateFromValidatorSet @@ -119,7 +119,7 @@ The given amount will be divided based on the weights distributed to the validat - The unbonding logic will be follow the `UnDelegate` logic from the cosmos-sdk. - Safety Checks - check that the amount of funds to undelegate is <= to the funds the user has in the address. - - `UnDelegate` method takes `sdk.Dec` as tokenAmount, so check if overflow/underflow case is relevant. + - `UnDelegate` method takes `osmomath.Dec` as tokenAmount, so check if overflow/underflow case is relevant. - use the [UnDelegate](https://github.com/cosmos/cosmos-sdk/blob/main/x/staking/keeper/delegation.go#L614) method from the cosmos-sdk to handle delegation. ### MsgWithdrawDelegationRewards diff --git a/x/valset-pref/client/cli/query_test.go b/x/valset-pref/client/cli/query_test.go index 0dc0c2ec2d5..61f305f4160 100644 --- a/x/valset-pref/client/cli/query_test.go +++ b/x/valset-pref/client/cli/query_test.go @@ -11,6 +11,7 @@ import ( valPref "github.com/osmosis-labs/osmosis/v19/x/valset-pref" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/client/queryproto" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" + "github.com/osmosis-labs/osmosis/osmomath" ) type QueryTestSuite struct { @@ -28,15 +29,15 @@ func (s *QueryTestSuite) SetupSuite() { preferences := []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, } diff --git a/x/valset-pref/export_test.go b/x/valset-pref/export_test.go index 30602ced58f..ba5b1679c84 100644 --- a/x/valset-pref/export_test.go +++ b/x/valset-pref/export_test.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -10,6 +11,6 @@ type ( ValSet = valSet ) -func (k Keeper) ValidateLockForForceUnlock(ctx sdk.Context, lockID uint64, delegatorAddr string) (*lockuptypes.PeriodLock, sdk.Int, error) { +func (k Keeper) ValidateLockForForceUnlock(ctx sdk.Context, lockID uint64, delegatorAddr string) (*lockuptypes.PeriodLock, osmomath.Int, error) { return k.validateLockForForceUnlock(ctx, lockID, delegatorAddr) } diff --git a/x/valset-pref/keeper.go b/x/valset-pref/keeper.go index 54876849f68..8a859da49ee 100644 --- a/x/valset-pref/keeper.go +++ b/x/valset-pref/keeper.go @@ -9,6 +9,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" ) @@ -71,7 +72,7 @@ func (k Keeper) GetExistingStakingDelegations(ctx sdk.Context, delAddr sdk.AccAd return nil, types.ErrNoDelegation } - existingTotalShares := sdk.NewDec(0) + existingTotalShares := osmomath.NewDec(0) // calculate total shares that currently exists for _, existingDelegation := range existingDelegations { existingTotalShares = existingTotalShares.Add(existingDelegation.Shares) diff --git a/x/valset-pref/keeper_test.go b/x/valset-pref/keeper_test.go index 0b49955220a..d670afe4677 100644 --- a/x/valset-pref/keeper_test.go +++ b/x/valset-pref/keeper_test.go @@ -10,6 +10,7 @@ import ( "github.com/stretchr/testify/suite" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" appParams "github.com/osmosis-labs/osmosis/v19/app/params" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" @@ -33,19 +34,19 @@ func (s *KeeperTestSuite) PrepareDelegateToValidatorSet() []types.ValidatorPrefe valPreferences := []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(2, 1), // 0.2 + Weight: osmomath.NewDecWithPrec(2, 1), // 0.2 }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(332, 3), // 0.33 + Weight: osmomath.NewDecWithPrec(332, 3), // 0.33 }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(12, 2), // 0.12 + Weight: osmomath.NewDecWithPrec(12, 2), // 0.12 }, { ValOperAddress: valAddrs[3], - Weight: sdk.NewDecWithPrec(348, 3), // 0.35 + Weight: osmomath.NewDecWithPrec(348, 3), // 0.35 }, } @@ -101,7 +102,7 @@ func (s *KeeperTestSuite) AllocateRewards(ctx sdk.Context, delegator sdk.AccAddr } // Pres *KeeperTestSuites sets up existing delegation by creating a certain number of validators and delegating tokenAmt to them. -func (s *KeeperTestSuite) PrepareExistingDelegations(ctx sdk.Context, valAddrs []string, delegator sdk.AccAddress, tokenAmt sdk.Int) error { +func (s *KeeperTestSuite) PrepareExistingDelegations(ctx sdk.Context, valAddrs []string, delegator sdk.AccAddress, tokenAmt osmomath.Int) error { for i := 0; i < len(valAddrs); i++ { valAddr, err := sdk.ValAddressFromBech32(valAddrs[i]) if err != nil { @@ -181,7 +182,7 @@ func (s *KeeperTestSuite) TestGetDelegationPreference() { } if test.setExistingDelegations { - err := s.PrepareExistingDelegations(s.Ctx, valAddrs, test.delegator, sdk.NewInt(10_000_000)) + err := s.PrepareExistingDelegations(s.Ctx, valAddrs, test.delegator, osmomath.NewInt(10_000_000)) s.Require().NoError(err) } diff --git a/x/valset-pref/msg_server_test.go b/x/valset-pref/msg_server_test.go index a13045722e0..945bb2bf22c 100644 --- a/x/valset-pref/msg_server_test.go +++ b/x/valset-pref/msg_server_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" appParams "github.com/osmosis-labs/osmosis/v19/app/params" valPref "github.com/osmosis-labs/osmosis/v19/x/valset-pref" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" @@ -28,15 +29,15 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, }, expectPass: true, @@ -47,15 +48,15 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(1, 1), + Weight: osmomath.NewDecWithPrec(1, 1), }, }, expectPass: true, @@ -66,15 +67,15 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(1, 1), + Weight: osmomath.NewDecWithPrec(1, 1), }, }, expectPass: false, @@ -85,15 +86,15 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(1, 1), + Weight: osmomath.NewDecWithPrec(1, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(7, 1), + Weight: osmomath.NewDecWithPrec(7, 1), }, }, expectPass: true, @@ -104,7 +105,7 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: "addr1---------------", - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, expectPass: false, @@ -115,11 +116,11 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[3], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[4], - Weight: sdk.NewDecWithPrec(7, 1), + Weight: osmomath.NewDecWithPrec(7, 1), }, }, expectPass: true, // SetValidatorSetPreference modifies the existing delegations @@ -130,18 +131,18 @@ func (s *KeeperTestSuite) TestSetValidatorSetPreference() { preferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[3], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[4], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[5], - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, }, - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), setExistingDelegations: true, expectPass: true, }, // SetValidatorSetPreference ignores the existing delegation and modifies the existing valset @@ -181,55 +182,55 @@ func (s *KeeperTestSuite) TestDelegateToValidatorSet() { tests := []struct { name string delegator sdk.AccAddress - amountToDelegate sdk.Coin // amount to delegate - expectedShares []sdk.Dec // expected shares after delegation - setExistingDelegations bool // if true, create new delegation (non-valset) with {delegator, valAddrs} - setValSet bool // if true, create a new valset {delegator, preferences} + amountToDelegate sdk.Coin // amount to delegate + expectedShares []osmomath.Dec // expected shares after delegation + setExistingDelegations bool // if true, create new delegation (non-valset) with {delegator, valAddrs} + setValSet bool // if true, create a new valset {delegator, preferences} expectPass bool }{ { name: "Delegate to valid validators", delegator: sdk.AccAddress([]byte("addr1---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), setValSet: true, - expectedShares: []sdk.Dec{sdk.NewDec(2_000_000), sdk.NewDec(3_300_000), sdk.NewDec(1_200_000), sdk.NewDec(3_500_000)}, + expectedShares: []osmomath.Dec{osmomath.NewDec(2_000_000), osmomath.NewDec(3_300_000), osmomath.NewDec(1_200_000), osmomath.NewDec(3_500_000)}, expectPass: true, }, { name: "Delegate more tokens to existing validator-set", delegator: sdk.AccAddress([]byte("addr1---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(4_000_000), sdk.NewDec(6_600_000), sdk.NewDec(2_400_000), sdk.NewDec(7_000_000)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(4_000_000), osmomath.NewDec(6_600_000), osmomath.NewDec(2_400_000), osmomath.NewDec(7_000_000)}, expectPass: true, }, { name: "User does not have enough tokens to stake", delegator: sdk.AccAddress([]byte("addr2---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(200_000_000)), + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(200_000_000)), setValSet: true, expectPass: false, }, { name: "Delegate to existing staking position (non valSet)", delegator: sdk.AccAddress([]byte("addr3---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(13_333_333), sdk.NewDec(13_333_333), sdk.NewDec(13_333_334)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(13_333_333), osmomath.NewDec(13_333_333), osmomath.NewDec(13_333_334)}, setExistingDelegations: true, expectPass: true, }, { name: "Delegate very small amount to existing valSet", delegator: sdk.AccAddress([]byte("addr4---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(0o10_013)), // small case - expectedShares: []sdk.Dec{sdk.NewDec(821), sdk.NewDec(1355), sdk.NewDec(492), sdk.NewDec(1439)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(0o10_013)), // small case + expectedShares: []osmomath.Dec{osmomath.NewDec(821), osmomath.NewDec(1355), osmomath.NewDec(492), osmomath.NewDec(1439)}, setValSet: true, expectPass: true, }, { name: "Delegate large amount to existing valSet", delegator: sdk.AccAddress([]byte("addr5---------------")), - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(96_386_414)), - expectedShares: []sdk.Dec{sdk.NewDec(19_277_282), sdk.NewDec(31_807_516), sdk.NewDec(11_566_369), sdk.NewDec(33_735_247)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(96_386_414)), + expectedShares: []osmomath.Dec{osmomath.NewDec(19_277_282), osmomath.NewDec(31_807_516), osmomath.NewDec(11_566_369), osmomath.NewDec(33_735_247)}, setValSet: true, expectPass: true, }, @@ -281,8 +282,8 @@ func (s *KeeperTestSuite) TestDelegateToValidatorSet() { } if test.setExistingDelegations { - delSharesAmt := sdk.NewDec(0) - expectedAmt := sdk.NewDec(0) + delSharesAmt := osmomath.NewDec(0) + expectedAmt := osmomath.NewDec(0) for i, val := range valAddrs { valAddr, err := sdk.ValAddressFromBech32(val) @@ -314,7 +315,7 @@ func (s *KeeperTestSuite) TestUnDelegateFromValidatorSet() { delegator sdk.AccAddress coinToStake sdk.Coin coinToUnStake sdk.Coin - expectedShares []sdk.Dec // expected shares after undelegation + expectedShares []osmomath.Dec // expected shares after undelegation setValSet bool setExistingDelegations bool expectPass bool @@ -322,61 +323,61 @@ func (s *KeeperTestSuite) TestUnDelegateFromValidatorSet() { { name: "Unstake half from the ValSet", delegator: sdk.AccAddress([]byte("addr1---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), // delegate 20osmo - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), // undelegate 10osmo - expectedShares: []sdk.Dec{sdk.NewDec(2_000_000), sdk.NewDec(3_300_000), sdk.NewDec(1_200_000), sdk.NewDec(3_500_000)}, + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), // delegate 20osmo + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), // undelegate 10osmo + expectedShares: []osmomath.Dec{osmomath.NewDec(2_000_000), osmomath.NewDec(3_300_000), osmomath.NewDec(1_200_000), osmomath.NewDec(3_500_000)}, setValSet: true, expectPass: true, }, { name: "Unstake x amount from ValSet", delegator: sdk.AccAddress([]byte("addr2---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), // delegate 20osmo - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(15_000_000)), // undelegate 15osmo - expectedShares: []sdk.Dec{sdk.NewDec(1_000_000), sdk.NewDec(1_650_000), sdk.NewDec(600_000), sdk.NewDec(1_750_000)}, // validatorDelegatedShares - (weight * coinToUnstake) + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), // delegate 20osmo + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(15_000_000)), // undelegate 15osmo + expectedShares: []osmomath.Dec{osmomath.NewDec(1_000_000), osmomath.NewDec(1_650_000), osmomath.NewDec(600_000), osmomath.NewDec(1_750_000)}, // validatorDelegatedShares - (weight * coinToUnstake) setValSet: true, expectPass: true, }, { name: "Unstake everything", delegator: sdk.AccAddress([]byte("addr3---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), setValSet: true, expectPass: true, }, { name: "Unstake more amount than the staked amount", delegator: sdk.AccAddress([]byte("addr4---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(40_000_000)), + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(40_000_000)), setValSet: true, expectPass: false, }, { name: "UnDelegate from existing staking position (non valSet) ", delegator: sdk.AccAddress([]byte("addr5---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(1_000_000), sdk.NewDec(1_660_000), sdk.NewDec(600_000), sdk.NewDec(1_740_000)}, // validatorDelegatedShares - (weight * coinToUnstake) + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(1_000_000), osmomath.NewDec(1_660_000), osmomath.NewDec(600_000), osmomath.NewDec(1_740_000)}, // validatorDelegatedShares - (weight * coinToUnstake) setExistingDelegations: true, expectPass: true, }, { name: "Undelegate extreme amounts to check truncation, large amount", delegator: sdk.AccAddress([]byte("addr6---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100_000_000)), - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(87_461_351)), - expectedShares: []sdk.Dec{sdk.NewDec(2_507_730), sdk.NewDec(4_137_755), sdk.NewDec(1_504_638), sdk.NewDec(4_388_526)}, // validatorDelegatedShares - (weight * coinToUnstake), for ex: 20_000_000 - (0.2 * 87_461_351) + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(100_000_000)), + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(87_461_351)), + expectedShares: []osmomath.Dec{osmomath.NewDec(2_507_730), osmomath.NewDec(4_137_755), osmomath.NewDec(1_504_638), osmomath.NewDec(4_388_526)}, // validatorDelegatedShares - (weight * coinToUnstake), for ex: 20_000_000 - (0.2 * 87_461_351) setValSet: true, expectPass: true, }, { name: "Undelegate extreme amounts to check truncation, small amount", delegator: sdk.AccAddress([]byte("addr7---------------")), - coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1234)), - expectedShares: []sdk.Dec{sdk.NewDec(1_999_754), sdk.NewDec(3_299_593), sdk.NewDec(1_199_852), sdk.NewDec(3_499_567)}, // validatorDelegatedShares - (weight * coinToUnstake), + coinToStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + coinToUnStake: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(1234)), + expectedShares: []osmomath.Dec{osmomath.NewDec(1_999_754), osmomath.NewDec(3_299_593), osmomath.NewDec(1_199_852), osmomath.NewDec(3_499_567)}, // validatorDelegatedShares - (weight * coinToUnstake), setValSet: true, expectPass: true, }, @@ -439,10 +440,10 @@ func (s *KeeperTestSuite) TestRedelegateToValidatorSet() { name string delegator sdk.AccAddress newPreferences []types.ValidatorPreference - amountToDelegate sdk.Coin // amount to delegate - expectedShares []sdk.Dec // expected shares after delegation - setExistingDelegation bool // ensures that there is existing delegations (non valset) - setExistingValSetDelegation bool // ensures that there is existing valset delegation + amountToDelegate sdk.Coin // amount to delegate + expectedShares []osmomath.Dec // expected shares after delegation + setExistingDelegation bool // ensures that there is existing delegations (non valset) + setExistingValSetDelegation bool // ensures that there is existing valset delegation expectPass bool }{ { @@ -451,19 +452,19 @@ func (s *KeeperTestSuite) TestRedelegateToValidatorSet() { newPreferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(6, 1), + Weight: osmomath.NewDecWithPrec(6, 1), }, }, - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(4_000_000), sdk.NewDec(4_000_000), sdk.NewDec(12_000_000)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(4_000_000), osmomath.NewDec(4_000_000), osmomath.NewDec(12_000_000)}, setExistingValSetDelegation: true, expectPass: true, // addr1 successfully redelegates to (valAddr0, valAddr1, valAddr2) }, @@ -473,18 +474,18 @@ func (s *KeeperTestSuite) TestRedelegateToValidatorSet() { newPreferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, }, - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), expectPass: false, // first redelegation already in progress so must end that first }, { @@ -493,19 +494,19 @@ func (s *KeeperTestSuite) TestRedelegateToValidatorSet() { newPreferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[4], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[3], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, }, - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(10_000_000), sdk.NewDec(6_000_000), sdk.NewDec(4_000_000)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(10_000_000), osmomath.NewDec(6_000_000), osmomath.NewDec(4_000_000)}, expectPass: false, // this fails because valAddrs[1] is being redelegated to in first test }, { @@ -514,19 +515,19 @@ func (s *KeeperTestSuite) TestRedelegateToValidatorSet() { newPreferences: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], // validator that has existing delegation - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, }, - amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(10_000_000)), - expectedShares: []sdk.Dec{sdk.NewDec(5_000_000), sdk.NewDec(3_000_000), sdk.NewDec(2_000_000)}, + amountToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(10_000_000)), + expectedShares: []osmomath.Dec{osmomath.NewDec(5_000_000), osmomath.NewDec(3_000_000), osmomath.NewDec(2_000_000)}, setExistingDelegation: true, expectPass: true, }, @@ -594,14 +595,14 @@ func (s *KeeperTestSuite) TestWithdrawDelegationRewards() { { name: "Withdraw all rewards from existing valset delegations", delegator: sdk.AccAddress([]byte("addr1---------------")), - coinsToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), // delegate 20osmo + coinsToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), // delegate 20osmo setValSetDelegation: true, expectPass: true, }, { name: "Withdraw all rewards from existing staking delegations (no val-set)", delegator: sdk.AccAddress([]byte("addr2---------------")), - coinsToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(20_000_000)), + coinsToDelegate: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(20_000_000)), setExistingDelegation: true, expectPass: true, }, @@ -670,7 +671,7 @@ func (s *KeeperTestSuite) TestDelegateBondedTokens() { delegator sdk.AccAddress lockId uint64 expectedUnlockedOsmo sdk.Coin - expectedDelegations []sdk.Dec + expectedDelegations []osmomath.Dec setValSet bool expectPass bool }{ @@ -678,8 +679,8 @@ func (s *KeeperTestSuite) TestDelegateBondedTokens() { name: "DelegateBondedTokens with existing osmo denom lockId, bonded and <= 2 weeks bond duration", delegator: sdk.AccAddress([]byte("addr1---------------")), lockId: testLock[0].ID, - expectedUnlockedOsmo: sdk.NewCoin(appParams.BaseCoinUnit, sdk.NewInt(60_000_000)), // delegator has 100osmo and creates 5 locks 10osmo each, forceUnlock only 1 lock - expectedDelegations: []sdk.Dec{sdk.NewDec(2_000_000), sdk.NewDec(3_300_000), sdk.NewDec(1_200_000), sdk.NewDec(3_500_000)}, + expectedUnlockedOsmo: sdk.NewCoin(appParams.BaseCoinUnit, osmomath.NewInt(60_000_000)), // delegator has 100osmo and creates 5 locks 10osmo each, forceUnlock only 1 lock + expectedDelegations: []osmomath.Dec{osmomath.NewDec(2_000_000), osmomath.NewDec(3_300_000), osmomath.NewDec(1_200_000), osmomath.NewDec(3_500_000)}, setValSet: true, expectPass: true, }, diff --git a/x/valset-pref/simulation/sim_msgs.go b/x/valset-pref/simulation/sim_msgs.go index 10eebef508e..a5cfa431241 100644 --- a/x/valset-pref/simulation/sim_msgs.go +++ b/x/valset-pref/simulation/sim_msgs.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" osmosimtypes "github.com/osmosis-labs/osmosis/v19/simulation/simtypes" valsetkeeper "github.com/osmosis-labs/osmosis/v19/x/valset-pref" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" @@ -13,7 +14,7 @@ import ( func RandomMsgSetValSetPreference(k valsetkeeper.Keeper, sim *osmosimtypes.SimCtx, ctx sdk.Context) (*types.MsgSetValidatorSetPreference, error) { // Start with a weight of 1 - remainingWeight := sdk.NewDec(1) + remainingWeight := osmomath.NewDec(1) preferences, err := GetRandomValAndWeights(ctx, k, sim, remainingWeight) if err != nil { @@ -45,7 +46,7 @@ func RandomMsgDelegateToValSet(k valsetkeeper.Keeper, sim *osmosimtypes.SimCtx, return &types.MsgDelegateToValidatorSet{ Delegator: delegator.Address.String(), - Coin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(delegationCoin))), + Coin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(int64(delegationCoin))), }, nil } @@ -88,7 +89,7 @@ func RandomMsgUnDelegateFromValSet(k valsetkeeper.Keeper, sim *osmosimtypes.SimC return &types.MsgUndelegateFromValidatorSet{ Delegator: delAddr.String(), - Coin: sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(int64(undelegationCoin))), + Coin: sdk.NewCoin(sdk.DefaultBondDenom, osmomath.NewInt(int64(undelegationCoin))), }, nil } @@ -125,7 +126,7 @@ func RandomMsgReDelegateToValSet(k valsetkeeper.Keeper, sim *osmosimtypes.SimCtx } // new delegations to redelegate to - remainingWeight := sdk.NewDec(1) + remainingWeight := osmomath.NewDec(1) preferences, err := GetRandomValAndWeights(ctx, k, sim, remainingWeight) if err != nil { return nil, err @@ -164,7 +165,7 @@ func RandomValidator(ctx sdk.Context, sim *osmosimtypes.SimCtx) *stakingtypes.Va return &validators[rand.Intn(len(validators))] } -func GetRandomValAndWeights(ctx sdk.Context, k valsetkeeper.Keeper, sim *osmosimtypes.SimCtx, remainingWeight sdk.Dec) ([]types.ValidatorPreference, error) { +func GetRandomValAndWeights(ctx sdk.Context, k valsetkeeper.Keeper, sim *osmosimtypes.SimCtx, remainingWeight osmomath.Dec) ([]types.ValidatorPreference, error) { var preferences []types.ValidatorPreference // Generate random validators with random weights that sums to 1 @@ -185,13 +186,13 @@ func GetRandomValAndWeights(ctx sdk.Context, k valsetkeeper.Keeper, sim *osmosim } } - totalWeight := sdk.ZeroDec() + totalWeight := osmomath.ZeroDec() // check if all the weights in preferences equal 1 for _, prefs := range preferences { totalWeight = totalWeight.Add(prefs.Weight) } - if !totalWeight.Equal(sdk.OneDec()) { + if !totalWeight.Equal(osmomath.OneDec()) { return nil, fmt.Errorf("generated weights donot equal 1 got: %d", totalWeight) } diff --git a/x/valset-pref/types/expected_interfaces.go b/x/valset-pref/types/expected_interfaces.go index dc9b0a6bbb7..7c49bd71521 100644 --- a/x/valset-pref/types/expected_interfaces.go +++ b/x/valset-pref/types/expected_interfaces.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" + "github.com/osmosis-labs/osmosis/osmomath" lockuptypes "github.com/osmosis-labs/osmosis/v19/x/lockup/types" ) @@ -13,10 +14,10 @@ import ( type StakingInterface interface { GetAllValidators(ctx sdk.Context) (validators []stakingtypes.Validator) GetValidator(ctx sdk.Context, addr sdk.ValAddress) (validator stakingtypes.Validator, found bool) - Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt sdk.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares sdk.Dec, err error) + Delegate(ctx sdk.Context, delAddr sdk.AccAddress, bondAmt osmomath.Int, tokenSrc stakingtypes.BondStatus, validator stakingtypes.Validator, subtractAccount bool) (newShares osmomath.Dec, err error) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation stakingtypes.Delegation, found bool) - Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount sdk.Dec) (time.Time, error) - BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount sdk.Dec) (completionTime time.Time, err error) + Undelegate(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, sharesAmount osmomath.Dec) (time.Time, error) + BeginRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, sharesAmount osmomath.Dec) (completionTime time.Time, err error) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (delegations []stakingtypes.Delegation) GetValidators(ctx sdk.Context, maxRetrieve uint32) (validators []stakingtypes.Validator) } diff --git a/x/valset-pref/types/msgs.go b/x/valset-pref/types/msgs.go index 22e6291de7a..93abfdcd7e6 100644 --- a/x/valset-pref/types/msgs.go +++ b/x/valset-pref/types/msgs.go @@ -34,7 +34,7 @@ func (m MsgSetValidatorSetPreference) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid delegator address (%s)", err) } - totalWeight := sdk.ZeroDec() + totalWeight := osmomath.ZeroDec() validatorAddrs := []string{} for _, validator := range m.Preferences { _, err := sdk.ValAddressFromBech32(validator.ValOperAddress) @@ -58,10 +58,10 @@ func (m MsgSetValidatorSetPreference) ValidateBasic() error { } // Round to 2 digit after the decimal. For ex: 0.999 = 1.0, 0.874 = 0.87, 0.5123 = 0.51 - roundedValue := osmomath.SigFigRound(totalWeight, sdk.NewDec(10).Power(2).TruncateInt()) + roundedValue := osmomath.SigFigRound(totalWeight, osmomath.NewDec(10).Power(2).TruncateInt()) // check if the total validator distribution weights equal 1 - if !roundedValue.Equal(sdk.OneDec()) { + if !roundedValue.Equal(osmomath.OneDec()) { return fmt.Errorf("The weights allocated to the validators do not add up to 1, Got: %f", roundedValue) } @@ -179,7 +179,7 @@ func (m MsgRedelegateValidatorSet) ValidateBasic() error { return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid delegator address (%s)", err) } - totalWeight := sdk.NewDec(0) + totalWeight := osmomath.NewDec(0) validatorAddrs := []string{} for _, validator := range m.Preferences { _, err := sdk.ValAddressFromBech32(validator.ValOperAddress) @@ -198,10 +198,10 @@ func (m MsgRedelegateValidatorSet) ValidateBasic() error { } // Round to 2 digit after the decimal. For ex: 0.999 = 1.0, 0.874 = 0.87, 0.5123 = 0.51 - roundedValue := osmomath.SigFigRound(totalWeight, sdk.NewDec(10).Power(2).TruncateInt()) + roundedValue := osmomath.SigFigRound(totalWeight, osmomath.NewDec(10).Power(2).TruncateInt()) // check if the total validator distribution weights equal 1 - if !roundedValue.Equal(sdk.OneDec()) { + if !roundedValue.Equal(osmomath.OneDec()) { return fmt.Errorf("The weights allocated to the validators do not add up to 1, Got: %f", roundedValue) } diff --git a/x/valset-pref/types/msgs_test.go b/x/valset-pref/types/msgs_test.go index 79cab9dd43b..0928381ee94 100644 --- a/x/valset-pref/types/msgs_test.go +++ b/x/valset-pref/types/msgs_test.go @@ -3,9 +3,9 @@ package types_test import ( "testing" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/app/apptesting" appParams "github.com/osmosis-labs/osmosis/v19/app/params" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" @@ -27,15 +27,15 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(322, 3), + Weight: osmomath.NewDecWithPrec(322, 3), }, { ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", - Weight: sdk.NewDecWithPrec(332, 3), + Weight: osmomath.NewDecWithPrec(332, 3), }, { ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", - Weight: sdk.NewDecWithPrec(348, 3), + Weight: osmomath.NewDecWithPrec(348, 3), }, }, }, @@ -48,15 +48,15 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(6, 1), + Weight: osmomath.NewDecWithPrec(6, 1), }, { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(4, 1), + Weight: osmomath.NewDecWithPrec(4, 1), }, { ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, }, }, @@ -69,7 +69,7 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDec(1), + Weight: osmomath.NewDec(1), }, }, }, @@ -82,15 +82,15 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxay", // invalid address - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(6, 1), + Weight: osmomath.NewDecWithPrec(6, 1), }, }, }, @@ -103,15 +103,15 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, { ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", - Weight: sdk.NewDecWithPrec(3, 1), + Weight: osmomath.NewDecWithPrec(3, 1), }, }, }, @@ -124,15 +124,15 @@ func TestMsgSetValidatorSetPreference(t *testing.T) { Preferences: []types.ValidatorPreference{ { ValOperAddress: "osmovaloper1x2cfenmflhj3dwm2ph6nkgqr3nppkg86fxaymg", - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: "osmovaloper1jcr68jghzm24zwe78zuhz7xahua8429erxk7vm", - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: "osmovaloper1gqsr38e4zteekwr6kq5se5jpadafqmcfyz8jds", - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, }, }, diff --git a/x/valset-pref/types/state.pb.go b/x/valset-pref/types/state.pb.go index 4051a934c86..0077ecb568f 100644 --- a/x/valset-pref/types/state.pb.go +++ b/x/valset-pref/types/state.pb.go @@ -4,8 +4,8 @@ package types import ( + cosmossdk_io_math "cosmossdk.io/math" fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" _ "google.golang.org/genproto/googleapis/api/annotations" @@ -35,7 +35,7 @@ type ValidatorPreference struct { // funds to. ValOperAddress string `protobuf:"bytes,1,opt,name=val_oper_address,json=valOperAddress,proto3" json:"val_oper_address,omitempty" yaml:"val_oper_address"` // weight is decimal between 0 and 1, and they all sum to 1. - Weight github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"weight"` + Weight cosmossdk_io_math.LegacyDec `protobuf:"bytes,2,opt,name=weight,proto3,customtype=cosmossdk.io/math.LegacyDec" json:"weight"` } func (m *ValidatorPreference) Reset() { *m = ValidatorPreference{} } @@ -123,30 +123,30 @@ func init() { } var fileDescriptor_d3010474a5b89fce = []byte{ - // 355 bytes of a gzipped FileDescriptorProto + // 361 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x4a, 0xeb, 0x40, - 0x18, 0xc5, 0x93, 0x5e, 0x28, 0xdc, 0x14, 0x44, 0xa2, 0xd0, 0x12, 0x25, 0x29, 0x59, 0x68, 0x37, - 0x9d, 0xa1, 0xba, 0x10, 0xdd, 0x59, 0xd4, 0xad, 0x52, 0xd1, 0x85, 0x9b, 0x32, 0x49, 0xbe, 0xa6, - 0xc1, 0x49, 0x66, 0x98, 0x19, 0xa3, 0x7d, 0x03, 0x97, 0x3e, 0x84, 0x0f, 0xd3, 0x65, 0x97, 0xe2, - 0x22, 0x68, 0xfb, 0x06, 0x7d, 0x02, 0x69, 0x12, 0xda, 0x2a, 0xba, 0x9a, 0x7f, 0xbf, 0xf3, 0x71, - 0xce, 0x1c, 0x63, 0x9f, 0xc9, 0x98, 0xc9, 0x48, 0xe2, 0x94, 0x50, 0x09, 0xaa, 0xcd, 0x05, 0x0c, - 0x70, 0xda, 0xf1, 0x40, 0x91, 0x0e, 0x96, 0x8a, 0x28, 0x40, 0x5c, 0x30, 0xc5, 0x4c, 0xab, 0x04, - 0x51, 0x01, 0x2e, 0x38, 0x54, 0x72, 0xd6, 0x76, 0xc8, 0x42, 0x96, 0x63, 0x78, 0xb1, 0x2b, 0x14, - 0xd6, 0x6e, 0xc8, 0x58, 0x48, 0x01, 0x13, 0x1e, 0x61, 0x92, 0x24, 0x4c, 0x11, 0x15, 0xb1, 0x44, - 0x16, 0xaf, 0xee, 0xab, 0x6e, 0x6c, 0xdd, 0x12, 0x1a, 0x05, 0x44, 0x31, 0x71, 0x25, 0x60, 0x00, - 0x02, 0x12, 0x1f, 0xcc, 0x73, 0x63, 0x33, 0x25, 0xb4, 0xcf, 0x38, 0x88, 0x3e, 0x09, 0x02, 0x01, - 0x52, 0x36, 0xf4, 0xa6, 0xde, 0xfa, 0xdf, 0xdd, 0x99, 0x67, 0x4e, 0x7d, 0x44, 0x62, 0x7a, 0xe2, - 0xfe, 0x24, 0xdc, 0xde, 0x46, 0x4a, 0xe8, 0x25, 0x07, 0x71, 0x5a, 0x5c, 0x98, 0x17, 0x46, 0xf5, - 0x11, 0xa2, 0x70, 0xa8, 0x1a, 0x95, 0x5c, 0x8c, 0xc6, 0x99, 0xa3, 0xbd, 0x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x1f, 0x55, 0xad, 0xbe, 0xf2, 0x76, 0x89, 0x72, 0x6d, 0x4f, + 0xe8, 0x91, 0x56, 0x4b, 0xd6, 0xd7, 0x46, 0xa5, 0xf5, 0xab, 0x5d, 0xdb, 0xa5, 0xe4, 0xe7, 0xed, + 0x90, 0x6f, 0x52, 0xf6, 0x8c, 0xa5, 0x9d, 0x45, 0x66, 0xe9, 0x45, 0x9e, 0x8d, 0x89, 0x76, 0x7f, + 0x73, 0x7e, 0xef, 0x6a, 0xf2, 0x6e, 0x2a, 0x93, 0x99, 0xa9, 0x4e, 0x67, 0xa6, 0xfa, 0x36, 0x33, + 0xd5, 0xa7, 0xb9, 0xa9, 0x4c, 0xe7, 0xa6, 0xf2, 0x32, 0x37, 0x95, 0x9b, 0x7d, 0x3f, 0x90, 0xa3, + 0x3b, 0x87, 0xb8, 0x2c, 0xa2, 0xa5, 0x83, 0x4e, 0x08, 0x8e, 0xa0, 0xab, 0x56, 0xbb, 0x07, 0xf4, + 0xe1, 0x53, 0xb7, 0x72, 0x9c, 0xa0, 0x70, 0xaa, 0x79, 0x09, 0x7b, 0x1f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x96, 0xde, 0x34, 0x00, 0xff, 0x01, 0x00, 0x00, } func (m *ValidatorPreference) Marshal() (dAtA []byte, err error) { diff --git a/x/valset-pref/validator_set.go b/x/valset-pref/validator_set.go index d0bfa9e85f8..7d5cde10d25 100644 --- a/x/valset-pref/validator_set.go +++ b/x/valset-pref/validator_set.go @@ -18,7 +18,7 @@ import ( type valSet struct { ValAddr string - Amount sdk.Dec + Amount osmomath.Dec } // SetValidatorSetPreferences sets a new valset position for a delegator in modules state. @@ -83,8 +83,8 @@ func (k Keeper) DelegateToValidatorSet(ctx sdk.Context, delegatorAddr string, co } // totalDelAmt is the amount that keeps running track of the amount of tokens delegated - totalDelAmt := sdk.NewInt(0) - tokenAmt := sdk.NewInt(0) + totalDelAmt := osmomath.NewInt(0) + tokenAmt := osmomath.NewInt(0) // loop through the validatorSetPreference and delegate the proportion of the tokens based on weights for i, val := range existingSet.Preferences { @@ -96,10 +96,10 @@ func (k Keeper) DelegateToValidatorSet(ctx sdk.Context, delegatorAddr string, co // in the last valset iteration we dont calculate it from shares using decimals and trucation, // we use whats remaining to get more accurate value if len(existingSet.Preferences)-1 == i { - tokenAmt = coin.Amount.Sub(totalDelAmt).ToDec().TruncateInt() + tokenAmt = coin.Amount.Sub(totalDelAmt).ToLegacyDec().TruncateInt() } else { // tokenAmt takes the amount to delegate, calculated by {val_distribution_weight * tokenAmt} - tokenAmt = val.Weight.Mul(coin.Amount.ToDec()).TruncateInt() + tokenAmt = val.Weight.Mul(coin.Amount.ToLegacyDec()).TruncateInt() totalDelAmt = totalDelAmt.Add(tokenAmt) } @@ -133,7 +133,7 @@ func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string } // the total amount the user wants to undelegate - tokenAmt := sdk.NewDec(coin.Amount.Int64()) + tokenAmt := osmomath.NewDec(coin.Amount.Int64()) err = k.CheckUndelegateTotalAmount(tokenAmt, existingSet.Preferences) if err != nil { @@ -141,8 +141,8 @@ func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string } // totalDelAmt is the amount that keeps running track of the amount of tokens undelegated - totalUnDelAmt := sdk.NewInt(0) - amountToUnDelegate := sdk.NewInt(0) + totalUnDelAmt := osmomath.NewInt(0) + amountToUnDelegate := osmomath.NewInt(0) for i, val := range existingSet.Preferences { valAddr, validator, err := k.getValAddrAndVal(ctx, val.ValOperAddress) @@ -153,7 +153,7 @@ func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string // in the last valset iteration we dont calculate it from shares using decimals and trucation, // we use whats remaining to get more accurate value if len(existingSet.Preferences)-1 == i { - amountToUnDelegate = coin.Amount.Sub(totalUnDelAmt).ToDec().TruncateInt() + amountToUnDelegate = coin.Amount.Sub(totalUnDelAmt).ToLegacyDec().TruncateInt() } else { // Calculate the amount to undelegate based on the existing weights amountToUnDelegate = val.Weight.Mul(tokenAmt).TruncateInt() @@ -174,14 +174,14 @@ func (k Keeper) UndelegateFromValidatorSet(ctx sdk.Context, delegatorAddr string } // CheckUndelegateTotalAmount checks if the tokenAmount equals the total amount calculated from valset weights. -func (k Keeper) CheckUndelegateTotalAmount(tokenAmt sdk.Dec, existingSet []types.ValidatorPreference) error { - totalAmountFromWeights := sdk.NewDec(0) +func (k Keeper) CheckUndelegateTotalAmount(tokenAmt osmomath.Dec, existingSet []types.ValidatorPreference) error { + totalAmountFromWeights := osmomath.NewDec(0) for _, val := range existingSet { totalAmountFromWeights = totalAmountFromWeights.Add(val.Weight.Mul(tokenAmt)) } - totalAmountFromWeights = totalAmountFromWeights.RoundInt().ToDec() - tokenAmt = tokenAmt.RoundInt().ToDec() + totalAmountFromWeights = totalAmountFromWeights.RoundInt().ToLegacyDec() + tokenAmt = tokenAmt.RoundInt().ToLegacyDec() if !totalAmountFromWeights.Equal(tokenAmt) { return fmt.Errorf("The undelegate total do not add up with the amount calculated from weights expected %s got %s", tokenAmt, totalAmountFromWeights) @@ -208,7 +208,7 @@ func (k Keeper) CheckUndelegateTotalAmount(tokenAmt sdk.Dec, existingSet []types func (k Keeper) PreformRedelegation(ctx sdk.Context, delegator sdk.AccAddress, existingSet []types.ValidatorPreference, newSet []types.ValidatorPreference) error { var existingValSet []valSet var newValSet []valSet - totalTokenAmount := sdk.NewDec(0) + totalTokenAmount := osmomath.NewDec(0) // Rearranging the exisingValSet and newValSet to to add extra validator padding for _, existingVals := range existingSet { @@ -260,7 +260,7 @@ func (k Keeper) PreformRedelegation(ctx sdk.Context, delegator sdk.AccAddress, e return err } - transferAmount := sdk.MinDec(diffVal.Amount, targetDiffVal.Amount.Abs()).TruncateDec() + transferAmount := osmomath.MinDec(diffVal.Amount, targetDiffVal.Amount.Abs()).TruncateDec() if transferAmount.IsZero() { break } @@ -394,7 +394,7 @@ func (k Keeper) IsPreferenceValid(ctx sdk.Context, preferences []types.Validator var weightsRoundedValPrefList []types.ValidatorPreference for _, val := range preferences { // round up weights - valWeightStr := osmomath.SigFigRound(val.Weight, sdk.NewDec(10).Power(2).TruncateInt()) + valWeightStr := osmomath.SigFigRound(val.Weight, osmomath.NewDec(10).Power(2).TruncateInt()) _, _, err := k.GetValidatorInfo(ctx, val.ValOperAddress) if err != nil { @@ -454,7 +454,7 @@ func (k Keeper) GetValidatorInfo(ctx sdk.Context, existingValAddr string) (sdk.V // GetValSetStruct initializes valSet struct with valAddr, weight and amount. // It also creates an extra struct with zero amount, that can be appended to newValSet that will be created. // We do this to make sure the struct array length is the same to calculate their difference. -func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares sdk.Dec) (valStruct valSet, valStructZeroAmt valSet) { +func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromShares osmomath.Dec) (valStruct valSet, valStructZeroAmt valSet) { val_struct := valSet{ ValAddr: validator.ValOperAddress, Amount: amountFromShares, @@ -462,29 +462,29 @@ func (k Keeper) GetValSetStruct(validator types.ValidatorPreference, amountFromS val_struct_zero_amount := valSet{ ValAddr: validator.ValOperAddress, - Amount: sdk.NewDec(0), + Amount: osmomath.NewDec(0), } return val_struct, val_struct_zero_amount } // check if lock owner matches the delegator, contains only uosmo and is bonded for <= 2weeks -func (k Keeper) validateLockForForceUnlock(ctx sdk.Context, lockID uint64, delegatorAddr string) (*lockuptypes.PeriodLock, sdk.Int, error) { +func (k Keeper) validateLockForForceUnlock(ctx sdk.Context, lockID uint64, delegatorAddr string) (*lockuptypes.PeriodLock, osmomath.Int, error) { // Checks if sender is lock ID owner lock, err := k.lockupKeeper.GetLockByID(ctx, lockID) if err != nil { - return nil, sdk.Int{}, err + return nil, osmomath.Int{}, err } if lock.GetOwner() != delegatorAddr { - return nil, sdk.Int{}, fmt.Errorf("delegator (%s) and lock owner (%s) does not match", delegatorAddr, lock.Owner) + return nil, osmomath.Int{}, fmt.Errorf("delegator (%s) and lock owner (%s) does not match", delegatorAddr, lock.Owner) } - lockedOsmoAmount := sdk.NewInt(0) + lockedOsmoAmount := osmomath.NewInt(0) // check that lock contains only 1 token coin, err := lock.SingleCoin() if err != nil { - return nil, sdk.Int{}, fmt.Errorf("lock fails to meet expected invariant, it contains multiple coins") + return nil, osmomath.Int{}, fmt.Errorf("lock fails to meet expected invariant, it contains multiple coins") } // check that the lock denom is uosmo @@ -493,13 +493,13 @@ func (k Keeper) validateLockForForceUnlock(ctx sdk.Context, lockID uint64, deleg } // check if there is enough uosmo token in the lock - if lockedOsmoAmount.LTE(sdk.NewInt(0)) { - return nil, sdk.Int{}, fmt.Errorf("lock does not contain osmo denom, or there isn't enough osmo to unbond") + if lockedOsmoAmount.LTE(osmomath.NewInt(0)) { + return nil, osmomath.Int{}, fmt.Errorf("lock does not contain osmo denom, or there isn't enough osmo to unbond") } // Checks if lock ID is bonded and ensure that the duration is <= 2 weeks if lock.IsUnlocking() || lock.Duration > time.Hour*24*7*2 { - return nil, sdk.Int{}, fmt.Errorf("the tokens have to bonded and the duration has to be <= 2weeks") + return nil, osmomath.Int{}, fmt.Errorf("the tokens have to bonded and the duration has to be <= 2weeks") } return lock, lockedOsmoAmount, nil diff --git a/x/valset-pref/validator_set_test.go b/x/valset-pref/validator_set_test.go index cfe51c72824..eae6a8f913f 100644 --- a/x/valset-pref/validator_set_test.go +++ b/x/valset-pref/validator_set_test.go @@ -3,6 +3,7 @@ package keeper_test import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/osmosis-labs/osmosis/osmomath" "github.com/osmosis-labs/osmosis/v19/x/valset-pref/types" ) @@ -69,56 +70,56 @@ func (s *KeeperTestSuite) TestCheckUndelegateTotalAmount() { valAddrs := s.SetupMultipleValidators(3) tests := []struct { name string - tokenAmt sdk.Dec + tokenAmt osmomath.Dec existingSet []types.ValidatorPreference expectPass bool }{ { name: "token amount matches with totalAmountFromWeights", - tokenAmt: sdk.NewDec(122_312_231), + tokenAmt: osmomath.NewDec(122_312_231), existingSet: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(17, 2), // 0.17 + Weight: osmomath.NewDecWithPrec(17, 2), // 0.17 }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(83, 2), // 0.83 + Weight: osmomath.NewDecWithPrec(83, 2), // 0.83 }, }, expectPass: true, }, { name: "token decimal amount matches with totalAmountFromWeights", - tokenAmt: sdk.MustNewDecFromStr("122312231.532"), + tokenAmt: osmomath.MustNewDecFromStr("122312231.532"), existingSet: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(17, 2), // 0.17 + Weight: osmomath.NewDecWithPrec(17, 2), // 0.17 }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(83, 2), // 0.83 + Weight: osmomath.NewDecWithPrec(83, 2), // 0.83 }, }, expectPass: true, }, { name: "tokenAmt doesnot match with totalAmountFromWeights", - tokenAmt: sdk.NewDec(122_312_231), + tokenAmt: osmomath.NewDec(122_312_231), existingSet: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(17, 2), // 0.17 + Weight: osmomath.NewDecWithPrec(17, 2), // 0.17 }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(83, 2), // 0.83 + Weight: osmomath.NewDecWithPrec(83, 2), // 0.83 }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(83, 2), // 0.83 + Weight: osmomath.NewDecWithPrec(83, 2), // 0.83 }, }, expectPass: false, @@ -142,33 +143,33 @@ func (s *KeeperTestSuite) TestIsValidatorSetEqual() { valSetOne := []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, } valSetTwo := []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, { ValOperAddress: valAddrs[2], - Weight: sdk.NewDecWithPrec(5, 1), + Weight: osmomath.NewDecWithPrec(5, 1), }, } valSetThree := []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.NewDecWithPrec(2, 1), + Weight: osmomath.NewDecWithPrec(2, 1), }, { ValOperAddress: valAddrs[1], - Weight: sdk.NewDecWithPrec(8, 1), + Weight: osmomath.NewDecWithPrec(8, 1), }, } @@ -218,7 +219,7 @@ func (s *KeeperTestSuite) TestIsPreferenceValid() { tests := []struct { name string valSetPreference []types.ValidatorPreference - expectedWeights []sdk.Dec + expectedWeights []osmomath.Dec expectPass bool }{ { @@ -226,22 +227,22 @@ func (s *KeeperTestSuite) TestIsPreferenceValid() { valSetPreference: []types.ValidatorPreference{ { ValOperAddress: valAddrs[0], - Weight: sdk.MustNewDecFromStr("0.3315"), // rounds to = 0.33 + Weight: osmomath.MustNewDecFromStr("0.3315"), // rounds to = 0.33 }, { ValOperAddress: valAddrs[1], - Weight: sdk.MustNewDecFromStr("0.000"), // rounds to = 0 + Weight: osmomath.MustNewDecFromStr("0.000"), // rounds to = 0 }, { ValOperAddress: valAddrs[2], - Weight: sdk.MustNewDecFromStr("0.536"), // rounds to = 0.54 + Weight: osmomath.MustNewDecFromStr("0.536"), // rounds to = 0.54 }, { ValOperAddress: valAddrs[3], - Weight: sdk.MustNewDecFromStr("0.119"), // rounds to = 0.12 + Weight: osmomath.MustNewDecFromStr("0.119"), // rounds to = 0.12 }, }, - expectedWeights: []sdk.Dec{sdk.NewDecWithPrec(33, 2), sdk.ZeroDec(), sdk.NewDecWithPrec(54, 2), sdk.NewDecWithPrec(12, 2)}, + expectedWeights: []osmomath.Dec{osmomath.NewDecWithPrec(33, 2), osmomath.ZeroDec(), osmomath.NewDecWithPrec(54, 2), osmomath.NewDecWithPrec(12, 2)}, expectPass: true, }, { @@ -249,11 +250,11 @@ func (s *KeeperTestSuite) TestIsPreferenceValid() { valSetPreference: []types.ValidatorPreference{ { ValOperAddress: "addr1---------------", - Weight: sdk.MustNewDecFromStr("0.3415"), + Weight: osmomath.MustNewDecFromStr("0.3415"), }, { ValOperAddress: valAddrs[0], - Weight: sdk.MustNewDecFromStr("0.000"), + Weight: osmomath.MustNewDecFromStr("0.000"), }, }, expectPass: false, From 0fa139797d4f01ed0e287f145b8b31f03c9d4231 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 19 Sep 2023 01:56:17 +0000 Subject: [PATCH 2/2] Generated protofile changes --- .../client/queryproto/query.pb.go | 280 +++++++++--------- 1 file changed, 144 insertions(+), 136 deletions(-) diff --git a/x/concentrated-liquidity/client/queryproto/query.pb.go b/x/concentrated-liquidity/client/queryproto/query.pb.go index 5dc55440d00..10ebdb19e4d 100644 --- a/x/concentrated-liquidity/client/queryproto/query.pb.go +++ b/x/concentrated-liquidity/client/queryproto/query.pb.go @@ -1660,142 +1660,150 @@ func init() { } var fileDescriptor_5c83e18b11fd607d = []byte{ - // 2145 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x5a, 0x4d, 0x6c, 0x1c, 0x49, - 0x15, 0x4e, 0x4d, 0x12, 0x27, 0xf3, 0xe2, 0xc4, 0x4e, 0xd9, 0xb1, 0x27, 0x93, 0x64, 0x26, 0x14, - 0x2c, 0x6b, 0x6d, 0xe2, 0x19, 0xf2, 0x63, 0x82, 0xe3, 0x64, 0xb3, 0x1e, 0x7b, 0x6d, 0x8d, 0xd6, - 0xc9, 0x3a, 0xbd, 0x31, 0x20, 0x0e, 0xf4, 0xf6, 0x74, 0x97, 0xc7, 0xad, 0xe9, 0xe9, 0x9a, 0x74, - 0x57, 0xdb, 0x6b, 0x2d, 0x91, 0x56, 0xec, 0x11, 0x09, 0x16, 0x71, 0x45, 0x5c, 0xb8, 0x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0x2b, 0x54, 0x58, 0x71, 0xa8, - 0xd6, 0x30, 0xd8, 0x96, 0x5d, 0x39, 0xf1, 0x7c, 0xa7, 0x78, 0x4c, 0x69, 0x2b, 0xc5, 0xcb, 0x1d, - 0x18, 0x32, 0x02, 0xc3, 0xab, 0x07, 0x62, 0x08, 0xdc, 0xeb, 0x00, 0xf1, 0x08, 0xc6, 0x22, 0x73, - 0xdb, 0x55, 0x23, 0x0c, 0xff, 0x1d, 0x38, 0x13, 0x1a, 0xf3, 0x83, 0x8a, 0x44, 0x50, 0x27, 0x76, - 0x77, 0x8a, 0x38, 0x0c, 0x6a, 0x44, 0x24, 0x0a, 0x84, 0xab, 0xaa, 0x41, 0x36, 0x61, 0xbc, 0x53, - 0x9f, 0x0c, 0xc9, 0x77, 0xe1, 0x74, 0xc8, 0x25, 0xb4, 0x1d, 0x4d, 0x44, 0x22, 0x9d, 0xe4, 0x9b, - 0x30, 0xbc, 0xca, 0x98, 0x15, 0xd5, 0xcf, 0x52, 0x42, 0x80, 0x06, 0x49, 0xf2, 0x8f, 0x10, 0x9c, - 0x95, 0x8a, 0x25, 0x92, 0x19, 0x38, 0xe9, 0x17, 0x52, 0x98, 0xd8, 0xf1, 0x52, 0xb0, 0x91, 0x4a, - 0xe1, 0x46, 0x2a, 0xcd, 0xdb, 0xdb, 0x95, 0xec, 0x1f, 0x7e, 0x35, 0x7d, 0xd2, 0x97, 0xab, 0x2a, - 0x01, 0xf7, 0xd1, 0x65, 0x6c, 0x04, 0xce, 0xae, 0x8a, 0xc6, 0x25, 0xdd, 0x25, 0x6b, 0x70, 0x2e, - 0xfc, 0x20, 0x5d, 0x5c, 0x80, 0xa1, 0xa0, 0xb7, 0xc9, 0x50, 0xbf, 0x72, 0x40, 0xa8, 0x03, 0x71, - 0x19, 0x53, 0x29, 0x4a, 0x3e, 0x46, 0x30, 0xfa, 0xc4, 0xd4, 0x1b, 0x2b, 0x21, 0xdb, 0x23, 0xca, - 0xf1, 0xbb, 0x70, 0x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ec, 0xd3, 0x97, 0x85, 0x63, 0x7f, 0x7e, 0x59, 0x38, 0xf6, 0x9d, - 0x47, 0xb1, 0x89, 0x46, 0xea, 0x9f, 0xb6, 0xb4, 0x9a, 0x1b, 0x19, 0xdb, 0xbc, 0x31, 0x5b, 0x7e, - 0xaf, 0xd7, 0xdf, 0xd2, 0x75, 0xcb, 0xa4, 0x36, 0x0f, 0xfe, 0x57, 0x41, 0xf0, 0x57, 0xc7, 0x21, - 0xf1, 0xcf, 0xad, 0xff, 0x05, 0x00, 0x00, 0xff, 0xff, 0x7f, 0xaa, 0x47, 0x4c, 0x5b, 0x21, 0x00, - 0x00, + // 2283 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x5a, 0x4d, 0x6c, 0x1c, 0x49, + 0x15, 0x4e, 0x4f, 0x7e, 0x36, 0xf3, 0xe2, 0xfc, 0x95, 0x1d, 0xdb, 0x99, 0x24, 0x33, 0xd9, 0x82, + 0xec, 0x5a, 0x9b, 0x78, 0x86, 0xfc, 0x11, 0x12, 0x27, 0x9b, 0xf5, 0xd8, 0x6b, 0x6b, 0x58, 0xc7, + 0xeb, 0xf4, 0xc6, 0x80, 0x38, 0xd0, 0xdb, 0xd3, 0x5d, 0x1e, 0x97, 0xa6, 0xa7, 0x6b, 0xd2, 0x5d, + 0x6d, 0xc7, 0x2c, 0x91, 0x56, 0xec, 0x11, 0x09, 0x16, 0x71, 0x45, 0x5c, 0x38, 0x80, 0x56, 0x1c, + 0xb9, 0xc0, 0x0d, 0x0e, 0x28, 0xe2, 0xb0, 0x5a, 0x09, 0x21, 0xa1, 0x3d, 0xcc, 0x42, 0xc2, 0x01, + 0x69, 0x01, 0x89, 0xe1, 0xc2, 0x11, 0x75, 0x75, 0x75, 0x4f, 0xcf, 0xb8, 0xc7, 0xee, 0x19, 0x1b, + 0x89, 0x53, 0xa6, 0xba, 0xde, 0xdf, 0xf7, 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23, 0xc1, 0xc0, 0x06, 0xa5, 0x56, 0x1b, 0x9f, 0x17, 0xe5, 0x6e, 0x0e, 0xc8, 0x25, 0xad, 0xbd, + 0x29, 0xac, 0x2d, 0xa1, 0xe9, 0xb4, 0xd6, 0x06, 0x36, 0x7e, 0xac, 0xc0, 0xf1, 0xae, 0x29, 0x29, + 0x9a, 0x49, 0x7b, 0xdf, 0x27, 0xcc, 0x85, 0x73, 0x77, 0x87, 0x63, 0x96, 0x18, 0xca, 0x02, 0xc3, + 0x5d, 0x74, 0x27, 0xb5, 0xc7, 0xa5, 0x84, 0xd2, 0x7b, 0xb2, 0x50, 0x3f, 0x45, 0x9f, 0x2b, 0x70, + 0x26, 0xb1, 0x59, 0x45, 0x73, 0x83, 0x76, 0xa4, 0x09, 0x8d, 0x73, 0x6e, 0x7e, 0x6f, 0x42, 0x24, + 0xd0, 0x45, 0x01, 0x74, 0x16, 0xdd, 0x4f, 0x09, 0xb4, 0x53, 0x0c, 0xc2, 0x71, 0x93, 0xe6, 0x08, + 0x4c, 0xff, 0x8e, 0x0f, 0xd6, 0xba, 0xc7, 0x20, 0xe8, 0xcd, 0x41, 0x4d, 0x4d, 0x1c, 0x54, 0xe5, + 0x16, 0xf6, 0x2a, 0x46, 0x62, 0xae, 0x08, 0xcc, 0x73, 0x68, 0x76, 0x60, 0xcc, 0x36, 0xe1, 0xa2, + 0x62, 0x47, 0xc8, 0xfe, 0xa9, 0xc0, 0x78, 0x72, 0xc3, 0x8e, 0xd2, 0xc6, 0x67, 0xc7, 0x51, 0x42, + 0xee, 0xcd, 0x3d, 0x4a, 0x19, 0x32, 0xcc, 0xfd, 0x26, 0x03, 0xe8, 0x2f, 0x0a, 0x8c, 0x26, 0x74, + 0xea, 0x68, 0x76, 0x50, 0x3b, 0xb7, 0x4d, 0x0f, 0x72, 0xe5, 0xbd, 0x88, 0x90, 0x38, 0xe7, 0x04, + 0xce, 0x7b, 0x68, 0x66, 0x60, 0x9c, 0x9d, 0xee, 0x1c, 0xfd, 0x4e, 0x81, 0x91, 0xf8, 0xdf, 0x26, + 0xd0, 0x9d, 0x01, 0xdf, 0x4a, 0xb1, 0x3f, 0x90, 0xe4, 0x66, 0x86, 0xe2, 0x95, 0x70, 0xee, 0x09, + 0x38, 0xb7, 0xd0, 0xcd, 0x01, 0xcb, 0x90, 0x56, 0xdd, 0xd2, 0xa8, 0x89, 0xfe, 0xa6, 0xc0, 0x78, + 0xf2, 0x08, 0x20, 0x75, 0x76, 0xee, 0x38, 0x90, 0x48, 0x9d, 0x9d, 0x3b, 0xcf, 0x21, 0xf0, 0xac, + 0x80, 0x39, 0x83, 0x6e, 0x0f, 0x70, 0xbf, 0x69, 0xba, 0x2f, 0x2f, 0xca, 0xcb, 0x3f, 0x2a, 0x70, + 0xaa, 0xb7, 0x49, 0x42, 0xaf, 0x0f, 0xd7, 0x01, 0x45, 0xf0, 0xee, 0x0f, 0xcd, 0x2f, 0x81, 0xbd, + 0x21, 0x80, 0xdd, 0x41, 0x5f, 0x49, 0x09, 0x6c, 0x5b, 0x2b, 0x87, 0xfe, 0xae, 0xc0, 0x44, 0x9f, + 0xde, 0x3f, 0x75, 0x59, 0xdd, 0x79, 0x82, 0x91, 0xba, 0xac, 0xee, 0x32, 0x82, 0x18, 0xf8, 0xce, + 0x14, 0x97, 0x47, 0x10, 0xc5, 0xb0, 0x1b, 0x47, 0xbf, 0xce, 0xc0, 0x17, 0xd3, 0x34, 0x66, 0x48, + 0x4d, 0x5b, 0x2c, 0xd2, 0xf7, 0x99, 0xb9, 0x77, 0xf6, 0x55, 0xa6, 0xf4, 0x0a, 0x15, 0x5e, 0x31, + 0x90, 0x9e, 0xb6, 0x22, 0xc5, 0x1a, 0x49, 0xcd, 0xa2, 0x76, 0x5d, 0x5b, 0x73, 0x58, 0x43, 0x8b, + 0x33, 0x95, 0xde, 0x4b, 0x6a, 0x74, 0x9f, 0xa2, 0xff, 0x28, 0x30, 0x9e, 0xdc, 0x1a, 0xa6, 0x3e, + 0xee, 0x3b, 0x76, 0xaa, 0xa9, 0x8f, 0xfb, 0xce, 0xfd, 0x29, 0x7e, 0x28, 0x5c, 0xf2, 0x16, 0xaa, + 0xa4, 0x74, 0x89, 0xe7, 0x12, 0x47, 0xf3, 0x42, 0x79, 0x5a, 0xd2, 0x5b, 0xeb, 0x53, 0x05, 0x4e, + 0x6f, 0xeb, 0x29, 0x51, 0xda, 0xf3, 0xdb, 0xaf, 0x55, 0xcd, 0xbd, 0x31, 0xbc, 0x80, 0x21, 0x0f, + 0x45, 0x8d, 0x70, 0xad, 0xa7, 0xff, 0x15, 0x4f, 0xab, 0x3e, 0x7d, 0x5a, 0xea, 0x1a, 0xb0, 0x73, + 0x73, 0x9b, 0xba, 0x06, 0xec, 0xd2, 0x2e, 0x0e, 0xfc, 0xb4, 0xea, 0xdf, 0xb7, 0x96, 0xd7, 0x9f, + 0x3d, 0xcf, 0x2b, 0x9f, 0x3c, 0xcf, 0x2b, 0x7f, 0x7e, 0x9e, 0x57, 0x3e, 0x7c, 0x91, 0x3f, 0xf0, + 0xc9, 0x8b, 0xfc, 0x81, 0x3f, 0xbd, 0xc8, 0x1f, 0xf8, 0xe6, 0x72, 0xac, 0xc7, 0x93, 0x6a, 0xa6, + 0x2d, 0xbd, 0xea, 0x46, 0x3a, 0x37, 0xae, 0xde, 0x2e, 0x3d, 0xe9, 0xf7, 0x1f, 0x4c, 0x0c, 0x8b, + 0x12, 0x9b, 0x07, 0xff, 0xd5, 0x26, 0xf8, 0x53, 0xfc, 0x11, 0xf1, 0xcf, 0xf5, 0xff, 0x06, 0x00, + 0x00, 0xff, 0xff, 0xc3, 0x6b, 0xd8, 0x3f, 0x70, 0x24, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used.