Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Create the exchange module #1661

Merged
merged 317 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
317 commits
Select commit Hold shift + click to select a range
421df54
[1658]: get/set store stuff for the settlement flat fees.
SpicyLemon Sep 1, 2023
876ffa3
[1658]: Rename the key prefix makers to start with Get to set them ap…
SpicyLemon Sep 1, 2023
9b3bf96
[1658]: Create a generic iterator and use that for the GetParams func.
SpicyLemon Sep 1, 2023
443e296
[1658]; Switch to a record separator byte to separate the price and f…
SpicyLemon Sep 1, 2023
0ab7493
[1658]: Most of the settlement ratio stuff.
SpicyLemon Sep 2, 2023
c66113c
[1658]: Refactor IsAcceptableBuyerSettlementFee into ValidateBuyerSet…
SpicyLemon Sep 4, 2023
cbe4130
[1658]: Create keeper.getStore and use that everywhere. Write flat an…
SpicyLemon Sep 4, 2023
8ea7281
[1658]: The rest of the market store stuff: inactive bool, user-settl…
SpicyLemon Sep 5, 2023
b74bdd1
[1658]: Add a last market id store entry and write CreateMarket(...).
SpicyLemon Sep 5, 2023
e2d848d
[1658]: Normalize the required attributes when storing them.
SpicyLemon Sep 5, 2023
9f2a4a5
[1658]: Fill out GovCreateMarket.
SpicyLemon Sep 5, 2023
b9c364c
[1658]: Add the endpoint comments to the msg server funcs.
SpicyLemon Sep 5, 2023
1d274e0
[1658]: Add a market id field to the update fees message and a last m…
SpicyLemon Sep 5, 2023
09c0309
[1658]: Get rid of NewGenesisState since it doesn't do anything helpf…
SpicyLemon Sep 5, 2023
f259eb6
[1658]: Implement GovManageFees.
SpicyLemon Sep 5, 2023
62fab32
[1658]: Create a GetMarket function.
SpicyLemon Sep 5, 2023
e1a22b7
[1658]: Create a known market id set of entries in the store.
SpicyLemon Sep 5, 2023
f0c2457
[1658]: Break out a lot of the keeper funcs into versions that can ta…
SpicyLemon Sep 5, 2023
5842062
[1658]: Add some empty suffix/value tests to ParseKeySuffixSettlement…
SpicyLemon Sep 5, 2023
43adb83
[1659]: Refactor ParseFeeRatioStoreValue due to nakedret linter error.
SpicyLemon Sep 5, 2023
18684c5
[1658]: Take care of the keys unit test TODOs I recently added.
SpicyLemon Sep 5, 2023
c4960e7
[1658]: Create IsBidOrder and IsAskOrder functions.
SpicyLemon Sep 6, 2023
a994bd0
[1658]: Refactor order state store plans; move the type byte into the…
SpicyLemon Sep 6, 2023
6c0b0f8
[1658]: get/set/delete orders. Tweak some keys stuff related to order…
SpicyLemon Sep 6, 2023
b807913
[1658]: Create index key parsers.
SpicyLemon Sep 6, 2023
7e913a4
[1658]: Create the index iterators.
SpicyLemon Sep 6, 2023
20a1903
[1658]: Add the name keeper to the keeper and create CanCreateAsk and…
SpicyLemon Sep 6, 2023
834f122
[1658]: Add some extra explanation to the req attrs fields.
SpicyLemon Sep 6, 2023
aec6e34
[1658]: Populate the create ask, create bid and cancel order messages.
SpicyLemon Sep 9, 2023
b1409f5
[1658]: Impliment Msg funcs for create ask, create bid, and cancel or…
SpicyLemon Sep 9, 2023
4afea0e
[1658]: Create a ratio.ApplyToLoosely that doesn't require even divis…
SpicyLemon Sep 10, 2023
a20d101
[1658]: Create GetHoldAmount methods on the Order, AskOrder, and BidO…
SpicyLemon Sep 10, 2023
c0a09bd
[1658]: Add a way to collect fees for a market and the exchange.
SpicyLemon Sep 10, 2023
2f757e6
[1658]: Implement CreateAsk, CreateBid, and CancelOrder.
SpicyLemon Sep 10, 2023
231bcba
[1658]: Fill in the MsgMarketWithdrawRequest message.
SpicyLemon Sep 15, 2023
ebcf560
[1658]: Msg methods for MsgMarketWithdrawRequest.
SpicyLemon Sep 15, 2023
ab2c925
[1658]: Implement MarketWithdraw.
SpicyLemon Sep 15, 2023
8a946e9
[1658]: Put an authority check short-circuit into hasPermission. Crea…
SpicyLemon Sep 15, 2023
48fb67f
[1658]: Get rid of hasPermission(store, ...) and just use HasPermissi…
SpicyLemon Sep 15, 2023
5e06f46
[1658]: Make some of the order keeper stuff public again. Change Crea…
SpicyLemon Sep 15, 2023
bef968a
[1658]: Change QueryIsValidMarket into QueryValidateCreateMarket and …
SpicyLemon Sep 15, 2023
1a1dc79
[1658]: Fix 'an bid' in a couple places.
SpicyLemon Sep 15, 2023
5203189
[1658]: Fill in content of MsgMarketManageReqAttrsRequest.
SpicyLemon Sep 15, 2023
a7b1d0a
[1658]: Refactor ValidateReqAttrs to only take in a single list.
SpicyLemon Sep 15, 2023
04fca37
[1658]: Implement the Msg methods for MsgMarketManageReqAttrsRequest.
SpicyLemon Sep 15, 2023
7ca7d09
[1658]: Create a generic intersection function and use that for strin…
SpicyLemon Sep 15, 2023
44349c7
[1658]: Repurpose contains to work on any with a provided equals func…
SpicyLemon Sep 15, 2023
dbdf85c
[1658]: Unit tests on MsgMarketManageReqAttrsRequest.ValidateBasic().
SpicyLemon Sep 15, 2023
5d83522
[1658]: Add the missing market_id field to MsgMarketManageReqAttrsReq…
SpicyLemon Sep 15, 2023
a6d0805
[1658]: Update MsgMarketManageReqAttrsRequest validation to make sure…
SpicyLemon Sep 15, 2023
4112486
[1658]: Make containsString public.
SpicyLemon Sep 18, 2023
c85e52d
[1658]: Implement MarketManageReqAttrs.
SpicyLemon Sep 18, 2023
e906de1
[1658]: Add the admin and market_id fields to the market management p…
SpicyLemon Sep 18, 2023
db03bf3
[1658]: Implement GetSigners and the admin and market id validation p…
SpicyLemon Sep 18, 2023
c780238
[1658]: Fill in the fields of MsgMarketManagePermissionsRequest.
SpicyLemon Sep 18, 2023
8e45670
[1658]: Implement MarketManagePermissions.
SpicyLemon Sep 18, 2023
4cb6d7d
[1658]: Create the rest of the Can... funcs for checking permissions.
SpicyLemon Sep 18, 2023
bbf853a
[1658]: Finish MsgMarketManagePermissionsRequest.ValidateBasic().
SpicyLemon Sep 18, 2023
2c94ac5
[1658]: Fill in the MsgMarketUpdateDetailsRequest MsgMarketUpdateEnab…
SpicyLemon Sep 18, 2023
75ba1c1
[1658]: Implement ValidateBasic() for MsgMarketUpdateDetailsRequest M…
SpicyLemon Sep 18, 2023
373380d
[1658]: Add the gogoproto equal function to MarketDetails.
SpicyLemon Sep 18, 2023
2111d7a
[1658]: Implement MarketUpdateDetails MarketUpdateEnabled and MarketU…
SpicyLemon Sep 18, 2023
5ac806f
[1658]: Tweak some line spacing in tx.proto.
SpicyLemon Sep 18, 2023
145e74a
[1658]: Rename the owner field in MsgCancelOrderRequest to signer.
SpicyLemon Sep 18, 2023
066974e
[1658]: add fields to MsgFillBidsRequest.
SpicyLemon Sep 18, 2023
8bd7769
[1658]: Implment Msg methods for MsgFillBidsRequest.
SpicyLemon Sep 18, 2023
5f94a69
[1658]: Implement FillBids.
SpicyLemon Sep 19, 2023
af18063
[1658]: Fill in the MsgFillAsksRequest fields.
SpicyLemon Sep 19, 2023
fb10d1a
[1658]: Implement ValidateBasic and GetSigners for MsgFillAsksRequest.
SpicyLemon Sep 19, 2023
91349b6
[1658]: Change total_price to a single Coin entry since validating se…
SpicyLemon Sep 19, 2023
52063e3
[1658]: Implement FillAsks.
SpicyLemon Sep 19, 2023
425b67d
[1658]: Add missing comment on AccessGrant.Contains.
SpicyLemon Sep 19, 2023
e4723ff
[1658]: Fix the GetPrice unit test to look for the correct panic mess…
SpicyLemon Sep 19, 2023
65983b1
[1658]: Add fields to the MsgMarketSettleRequest message.
SpicyLemon Sep 19, 2023
dadbf6c
[1658]: MsgMarketSettleRequest.ValidateBasic().
SpicyLemon Sep 19, 2023
8d1097a
[1658]: Fix a TODO comment.
SpicyLemon Sep 19, 2023
a64e63e
[1658]: Remove the EventCreateMarketSubmitted since I got rid of the …
SpicyLemon Sep 19, 2023
8352e6e
[1658]: Split the EventMarketUserSettleUpdated into an Enabled and Di…
SpicyLemon Sep 19, 2023
cb7a1bd
[1658]: Constructors and test updates for recent event changes.
SpicyLemon Sep 19, 2023
ca9abe6
[1658]: Rename the EventMarketWithdraw.AmountWithdrawn to just Amount.
SpicyLemon Sep 19, 2023
05a2ffa
[1658]: Correct a test that wasn't testing the right thing.
SpicyLemon Sep 19, 2023
a841230
[1658]: Wrap errors returned by the msg service endpoints. Emit events.
SpicyLemon Sep 19, 2023
e9c4827
[1658]: Fix some event field comments.
SpicyLemon Sep 19, 2023
1a879b5
[1658]: extract getAskOrders and getBidOrders out of FillAsks and Fil…
SpicyLemon Sep 19, 2023
86c2425
[1658]: Fill in the MarketSettle endpoint. Still need to do the actua…
SpicyLemon Sep 19, 2023
47ad792
[1658]: Some pre-settlement validation.
SpicyLemon Sep 19, 2023
9c823c1
[1658]: Start work on a Fulfillment struct.
SpicyLemon Sep 19, 2023
218875b
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Sep 20, 2023
2c67451
[1658]: Use a generic IndexedAddrAmts instead of two separate types f…
SpicyLemon Sep 20, 2023
faf4b2f
[1659]: Normalize the attributes when updating them.
SpicyLemon Sep 20, 2023
76c8c8c
[1658]: Create ValidateName and ValidateNameSegment for better error …
SpicyLemon Sep 20, 2023
477b7b9
[1658]: Remove the name keeper, and don't worry about attribute lengt…
SpicyLemon Sep 20, 2023
faa0186
[1658]: Create a helpers.go with some of the generic helpr funcs (tha…
SpicyLemon Sep 20, 2023
c53bda1
[1658]: Move the fulfillment stuff to its own file and create the bid…
SpicyLemon Sep 20, 2023
538423b
[1658]: Don't generate getters for Order, AskOrder, and BidOrder mess…
SpicyLemon Sep 21, 2023
d994dd3
[1658]: Create SubOrderI and OrderI interfaces and implement all the …
SpicyLemon Sep 21, 2023
078151d
[1658]: Make it so GetOrderType doesn't panic, but instead always ret…
SpicyLemon Sep 21, 2023
4c9e364
[1658]: Lots of work on fulfillment transfer identification and valid…
SpicyLemon Sep 22, 2023
50b8a96
[1658]: Make BidOrder.Assets a Coin (instead of Coins).
SpicyLemon Sep 22, 2023
a053329
[1658]: Split out some of the create order validation for easier use …
SpicyLemon Sep 22, 2023
90469f7
[1658]: Tweak partial expected error messages.
SpicyLemon Sep 22, 2023
0b6c804
[1658]: Make AskOrder assets a single Coin too.
SpicyLemon Sep 22, 2023
60d31da
[1658]: Get most of the fulfillment stuff finally coded. Still need t…
SpicyLemon Sep 23, 2023
a9f219d
[1659]: Set the partial order and emit events during settlement.
SpicyLemon Sep 23, 2023
65f71dd
[1658]: Have BuildSettlementTransfers take in a Fulfillments instead …
SpicyLemon Sep 25, 2023
17055d4
[1658]: Add unit test for DefaultGenesisState.
SpicyLemon Sep 25, 2023
7000e3a
[1658]: Add todos for funcs to unit test.
SpicyLemon Sep 25, 2023
9d7b499
[1658]: Unit tests on the HasUpdates funcs.
SpicyLemon Sep 25, 2023
b9c21bf
[1658]: In fulfillment.go: Make some things public that were private.…
SpicyLemon Sep 25, 2023
b43a385
[1658]: Refine the fulfillment stuff to simplify Finalize and put mos…
SpicyLemon Sep 25, 2023
088d28b
[1658]: Unit tests on the rest of the helper funcs.
SpicyLemon Sep 26, 2023
91af37a
[1658]: Unit tests on the indexedAddrAmts stuff.
SpicyLemon Sep 26, 2023
47b591b
[1658]: Unit tests on the OrderI funcs of OrderFulfillment.
SpicyLemon Sep 26, 2023
debff29
[1658]: Unit tests on GetAsset/PriceTransfer.
SpicyLemon Sep 26, 2023
0b586ca
[1658]: Unit tests on BuildSettlementTransfers.
SpicyLemon Sep 26, 2023
bbb45a9
[1658]: Unit tests on the OrderFulfillment Apply and ApplyLeftoverPri…
SpicyLemon Sep 27, 2023
c3ec406
[1658]: Don't use intermediate variables in GetFulfillmentAssetsAmt, …
SpicyLemon Sep 27, 2023
805ce18
[1658]: Add the order id to the error message for non SubOrderI types.
SpicyLemon Sep 27, 2023
d921806
[1658]: Unit tests on GetFulfillmentAssetsAmt and NewPartialFulfillment.
SpicyLemon Sep 27, 2023
d904dcd
[1658]: Fix a calc in Finalize.
SpicyLemon Sep 27, 2023
1ef4084
[1658]: Most of the unit tests on Finalize.
SpicyLemon Sep 27, 2023
3c75dfe
[1658]: The last of the Finalize unit tests.
SpicyLemon Sep 28, 2023
51e0e03
[1658]: Create newUnknownOrder and use that instead of doing it the h…
SpicyLemon Sep 28, 2023
08c48d4
[1658]: Tweak OrderFulfillment.Validate: Check the sub-order first. R…
SpicyLemon Sep 28, 2023
4796a4d
[1658]: Further refinements to OrderFulfillment.Validate as I work th…
SpicyLemon Sep 28, 2023
9fbe69a
[1658]: Unit tests on OrderFulfillment.Validate.
SpicyLemon Sep 28, 2023
44f5a76
[1658]: Update Fulfill: add context to the order type mismatch error.…
SpicyLemon Sep 28, 2023
3af84c9
[1658]: Unit tests on Fulfill.
SpicyLemon Sep 28, 2023
6b937a5
[1658]: Tweak some error messages in BuildFulfillments. Also make sur…
SpicyLemon Sep 29, 2023
4899347
[1658]: Unit tests on BuildFulfillments.
SpicyLemon Sep 29, 2023
f32f506
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Sep 29, 2023
29b498c
[1658]: Create a unit test for 2 asks 1 bid with amounts just off tha…
SpicyLemon Sep 29, 2023
19cd79a
[1658]: Create shells of InitGenesis and ExportGenesis.
SpicyLemon Sep 29, 2023
d2ef8df
[1658]: Lint fix and some TODOs for uint parsers.
SpicyLemon Sep 29, 2023
b10c1e7
[1658]: Implement InitGenesis and ExportGenesis. Move NormalizeReqAtt…
SpicyLemon Sep 29, 2023
a299620
[1658]: Check sizes of orders for when we're reading them.
SpicyLemon Sep 29, 2023
dc7b97d
[1658]: Create the query server with stubs and wire it into the module.
SpicyLemon Sep 29, 2023
c5a7203
[1658]: Have uint16FromBz, uint32FromBz, and uint64FromBz return a bo…
SpicyLemon Sep 29, 2023
69ab8fe
[1658]: Fix some query server todos.
SpicyLemon Sep 29, 2023
bb847ca
[1658]: Populate the QueryOrderFeeCalc messages.
SpicyLemon Sep 29, 2023
971917e
[1658]: Make the QueryOrderFeeCalcResponse []Coin insted of Coins sin…
SpicyLemon Sep 29, 2023
7a25a32
[1658]: Implement QueryOrderFeeCalc.
SpicyLemon Sep 29, 2023
24ca9d2
[1658]: Remove the QuerySettlementFeeCalc since I took out the fee am…
SpicyLemon Sep 29, 2023
d62324f
[1658]: Change QueryGetAddressOrders to QueryGetOwnerOrders. Add a Qu…
SpicyLemon Sep 29, 2023
b2ed53b
[1658]: Implement QueryGetOrder.
SpicyLemon Sep 29, 2023
6ef00a3
[1658]: Implement QueryGetMarketOrders.
SpicyLemon Sep 29, 2023
7a859a0
[1658]: Implement QueryGetOwnerOrders.
SpicyLemon Sep 29, 2023
c6ef636
[1658]: Add an order_type field to the QueryGetAssetOrdersRequest and…
SpicyLemon Sep 29, 2023
2741766
[1658]: Implement QueryGetAssetOrders and QueryGetAllOrders.
SpicyLemon Sep 29, 2023
1cb40db
[1658]: Refactor the Market to order and address to order indexes to …
SpicyLemon Oct 1, 2023
073c5ce
Revert "[1658]: Refactor the Market to order and address to order ind…
SpicyLemon Oct 2, 2023
99d37a5
[1658]: Change the asset-to-order index to match the others with the …
SpicyLemon Oct 2, 2023
8924f21
[1658]: Extract the pagination stuff to a new GetPageOfOrdersFromInde…
SpicyLemon Oct 2, 2023
3568831
[1658]: Add the order type field to QueryGetMarketOrders and QueryGet…
SpicyLemon Oct 2, 2023
0a44838
[1658]: Allow the MarketOrders, AddressOrders, and AssetOrders querie…
SpicyLemon Oct 2, 2023
696c7e5
[1658]: Rename QueryMarketInfo to QueryGetMarket. Add QueryGetAllMark…
SpicyLemon Oct 2, 2023
9f6cb3e
[1658]: Implement QueryGetMarket and QueryGetAllMarkets.
SpicyLemon Oct 2, 2023
4af84bc
[1658]: Fill in and implement QueryParams.
SpicyLemon Oct 2, 2023
22f7129
[1658]: Fill in the fields of the ValidateCreateMarket and ValidateMa…
SpicyLemon Oct 2, 2023
70c7539
[1658]: Implement QueryValidateCreateMarket and QueryValidateMarket.
SpicyLemon Oct 2, 2023
cfc581f
[1658]: Implement QueryValidateManageFees.
SpicyLemon Oct 3, 2023
1a0ef9a
[1658]: Pull ratio price denoms check out into its own function. In Q…
SpicyLemon Oct 3, 2023
c922a1b
[1658]: Reorganize keeper/market.go and tweak a few of the function n…
SpicyLemon Oct 3, 2023
edb0d1a
[1658]: Make the marketID the 2nd arg for consistency in CollectFee a…
SpicyLemon Oct 3, 2023
bc422e3
[1658]: Reorganize keeper/orders.go. In SettleOrders, release the hol…
SpicyLemon Oct 3, 2023
5f885b8
[1658]: Store the last order id and use it for getting the next order…
SpicyLemon Oct 3, 2023
d10eeec
[1658]: Create emitEvent and emitEvents that just logs any errors ins…
SpicyLemon Oct 3, 2023
b1cd73c
[1658]: Begin the overhaul of fulfillment. Create a Distribution stru…
SpicyLemon Oct 3, 2023
871108a
[1658]: Major work on the fulfillment overhaul. Allocation done, just…
SpicyLemon Oct 4, 2023
4da6be3
[1658]: Move GetAssetTransfer and GetPriceTransfer out of the way and…
SpicyLemon Oct 4, 2023
14ee6bf
[1658]: Finish BuildSettlement (at least until I find problems as I w…
SpicyLemon Oct 5, 2023
cea1599
[1658]: Wire the keeper's SettleOrders method to use the new BuildSet…
SpicyLemon Oct 5, 2023
df1a9f1
[1658]: Stub out all the new test funcs needed.
SpicyLemon Oct 5, 2023
abbf186
[1658]: Unit tests on NewOrderFulfillments, assetCoin, and priceCoin.
SpicyLemon Oct 5, 2023
40a4c0a
[1658]: Unit tests on GetFulfillmentPriceAmt.
SpicyLemon Oct 5, 2023
127145b
[1658]: Unit tests on sumAssetsAndPrice and sumPriceLeft.
SpicyLemon Oct 5, 2023
12bf03d
[1658]: Unit tests on the DistributeAssets and DistributePrice stuff.
SpicyLemon Oct 5, 2023
5ade7ee
[1658]: Unit tests on the CopyChange funcs and Order.Split. Also fixe…
SpicyLemon Oct 5, 2023
453c417
[1658]: Unit tests on OrderFulfillment.SplitOrder
SpicyLemon Oct 5, 2023
69efe08
[1658]: Unit tests and fixes for OrderFulfillment.Validate, getAssetT…
SpicyLemon Oct 5, 2023
4693cef
[1658]: Unit tests on validateCanSettle.
SpicyLemon Oct 6, 2023
84822ce
[1658]: Fix allocateAssets giving the wrong thing to DistributeAssets.
SpicyLemon Oct 6, 2023
a60a450
[1658]: Unit tests on allocateAssets and splitPartial.
SpicyLemon Oct 6, 2023
c87f99f
[1658]: Fix buildTransfers to not double up the transfers.
SpicyLemon Oct 6, 2023
8d6fd55
[1658]: Add some fields to EventOrderFilled and EventOrderPartiallyFi…
SpicyLemon Oct 6, 2023
622979c
[1658]: Create a FilledOrder struct to represent what's been filled i…
SpicyLemon Oct 6, 2023
65197e1
[1658]: Unit tests on splitOrderFulfillments.
SpicyLemon Oct 6, 2023
c06b680
[1658]: Unit tests on populateFilled.
SpicyLemon Oct 6, 2023
8663434
[1658]: Unit tests on setFeesToPay.
SpicyLemon Oct 6, 2023
e857942
[1658]: Unit tests on validateFulfillments.
SpicyLemon Oct 6, 2023
3b0340b
[1658]: Unit tests on buildTransfers.
SpicyLemon Oct 7, 2023
ffe6329
[1658]: Unit tests on allocatePrice.
SpicyLemon Oct 8, 2023
73fdfcc
[1658]: Remove duplicate total price check.
SpicyLemon Oct 8, 2023
7599be3
[1658]: Unit tests on BuildSettlement.
SpicyLemon Oct 8, 2023
1b06d49
[1658]: Clean up the now-unneeded order fulfillment stuff. Make the O…
SpicyLemon Oct 8, 2023
39401cf
[1658]: Unit tests on ParseIndexKeySuffixOrderID.
SpicyLemon Oct 9, 2023
a127d0e
[1658]: Stub out the remaining module pieces.
SpicyLemon Oct 9, 2023
16ed92c
[1658]: Bypass the quarantine module when doing transfers.
SpicyLemon Oct 9, 2023
6fd187a
[1658]: During InitGenesis, make sure that there's holds on all the o…
SpicyLemon Oct 9, 2023
d4d40fa
[1658]: Use DoTransfer in FillBids (instead of InputOutputCoins direc…
SpicyLemon Oct 9, 2023
d949f9b
[1658]: Add the exchange module to the app.
SpicyLemon Oct 9, 2023
f0e1230
[1658]: Create ValidateAuthority and use that instead of IsAuthority …
SpicyLemon Oct 9, 2023
56f89c2
[1658]: Tweak IsAuthority to be case insensitive, and ValidateAuthori…
SpicyLemon Oct 9, 2023
9fe33ba
[1658]: Create the mock keepers and create the beginnings of the keep…
SpicyLemon Oct 9, 2023
5c46ff7
[1658]: Change DoTransfer to return an error instead of panic when an…
SpicyLemon Oct 9, 2023
4180e8e
[1658]: Unit tests on DoTransfer, CalculateExchangeSplit, CollectFee,…
SpicyLemon Oct 9, 2023
fc656c9
[1658]: Lint fixes.
SpicyLemon Oct 9, 2023
2429efa
[1658]: Fully generate the proto stuff.
SpicyLemon Oct 9, 2023
c30a6cc
[1658]: Add the bare beginnings of the spec doc.
SpicyLemon Oct 9, 2023
7b48bbc
[1658]: Create TODOs for all the keeper unit tests.
SpicyLemon Oct 9, 2023
fd535bc
Some small tweaks from initial code review.
SpicyLemon Oct 9, 2023
1863bef
[1658]: Move some of the generic unit test helper functions into help…
SpicyLemon Oct 10, 2023
d22f41a
[1658]: Prevent an admin from revoking their own ability to manage pe…
SpicyLemon Oct 10, 2023
a4a9d24
[1658]: Reorg the module.go file a bit.
SpicyLemon Oct 10, 2023
89f2733
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Oct 10, 2023
9cd1987
[1658]: Add a changelog entry.
SpicyLemon Oct 10, 2023
444982e
[1658]: Don't allow a single star wildcard in required attributes sin…
SpicyLemon Oct 11, 2023
1a453fd
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Oct 11, 2023
5b5e61e
[1658]: Fix a few comments.
SpicyLemon Oct 11, 2023
d45ba46
[1658]: Add a last_order_id field to the genesis state.
SpicyLemon Oct 11, 2023
56aceff
[1658]: Create stringerJoin to clean up some of the unit test helper …
SpicyLemon Oct 11, 2023
03d779b
[1658]: Tweak to assertEqualOrderFulfillmentSlices to the string comp…
SpicyLemon Oct 11, 2023
86d4d7b
[1658]: Fix a call to feeCoins in TestBuildSettlement that was missin…
SpicyLemon Oct 11, 2023
7fa39e2
[1658]: Create stringerLines and use it to clean up some more unit te…
SpicyLemon Oct 11, 2023
9a19d4d
[1658]: Delete some unwanted empty lines.
SpicyLemon Oct 11, 2023
49c3bc5
[1658]: Provide suggested sizes when making maps.
SpicyLemon Oct 11, 2023
e0ca215
[1658]: Flatten a for loop in UpdatePermissions a little bit.
SpicyLemon Oct 12, 2023
c443a4a
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Oct 12, 2023
911c023
[1658]: Fix the field comments in MsgMarketManageReqAttrsRequest.
SpicyLemon Oct 12, 2023
09e346a
[1658]: Double check that the market details are valid in CreateMarke…
SpicyLemon Oct 12, 2023
79641ca
[1658]: Allow an admin to revoke their permission to manage permissions.
SpicyLemon Oct 12, 2023
6a5d479
[1658]: Add an external id field to the orders and create a tx for se…
SpicyLemon Oct 12, 2023
d1373c0
[1658]: Add the market id to severl order-related events.
SpicyLemon Oct 13, 2023
714139d
[1658]: Move the sumAssetsAndPrice calls and validation to before the…
SpicyLemon Oct 13, 2023
6014f4f
Merge branch 'main' into dwedul/1658-exchange-module
SpicyLemon Oct 13, 2023
043954c
[1658]: Make IndexedAddrAmts public.
SpicyLemon Oct 13, 2023
2dcbd45
[1658]: Extract a closeSettlement method from the end of SettleOrders…
SpicyLemon Oct 13, 2023
994815e
[1658]: In IndexedAddrAmts.Add, if the coins to add is zero, don't do…
SpicyLemon Oct 13, 2023
d03a9b2
[1658]: Increase the maximmum external id length to allow for 32 byte…
SpicyLemon Oct 13, 2023
2e00120
[1658]: Remove the 'Query' from the name of all the query endpoints.
SpicyLemon Oct 17, 2023
0e00405
[1658]: Add the hold queries to the stargate whitelist.
SpicyLemon Oct 17, 2023
0c9b27e
[1658]: Add all the exchange queries to the stargate whitelist.
SpicyLemon Oct 17, 2023
44acefe
[1658]: Fix the market keeper to set an empty byte slice instead of n…
SpicyLemon Oct 15, 2023
b8728ab
[1658]: Fix getBuyerSettlementFeeRatiosForPriceDenom to return an err…
SpicyLemon Oct 16, 2023
145d2c1
[1658]: Add the fee to an error in validateFlatFee. Fix validateSelle…
SpicyLemon Oct 16, 2023
a726b01
[1658]: Refactor validateAskPrice to clean it up a bit.
SpicyLemon Oct 16, 2023
a2ae3bd
[1658]: In validateBuyerSettlementFee, when a fee is required but one…
SpicyLemon Oct 17, 2023
13820fb
[1658]: in validateBuyerSettlementFee, only include errors for a type…
SpicyLemon Oct 17, 2023
30e1ceb
[1658]: Create ParseFeeRatio.
SpicyLemon Oct 16, 2023
f48c014
[1658]: Set the exchange params to the defaults in the upgrade.
SpicyLemon Oct 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

* Create the `x/exchange` module which facilitates the buying and selling of assets [#1658](https://github.com/provenance-io/provenance/issues/1658).
Assets and funds remain in their owner's account (with a hold on them) until the order is settled (or cancelled).
Market's are created to manage order matching and define fees.
The chain will receive a portion of the fees a market collects.
* Allow marker's transfer authority to prevent transfer of restricted coin with deny list on send [#1518](https://github.com/provenance-io/provenance/issues/1518).
* Add net asset value to markers [#1328](https://github.com/provenance-io/provenance/issues/1328).
* Add ICQHost and Oracle module to allow cross chain oracle queries [#1497](https://github.com/provenance-io/provenance/issues/1497).
Expand Down
19 changes: 18 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,13 @@ import (
attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper"
attributetypes "github.com/provenance-io/provenance/x/attribute/types"
attributewasm "github.com/provenance-io/provenance/x/attribute/wasm"
"github.com/provenance-io/provenance/x/exchange"
exchangekeeper "github.com/provenance-io/provenance/x/exchange/keeper"
exchangemodule "github.com/provenance-io/provenance/x/exchange/module"
"github.com/provenance-io/provenance/x/hold"
holdkeeper "github.com/provenance-io/provenance/x/hold/keeper"
holdmodule "github.com/provenance-io/provenance/x/hold/module"
ibchooks "github.com/provenance-io/provenance/x/ibchooks"
"github.com/provenance-io/provenance/x/ibchooks"
ibchookskeeper "github.com/provenance-io/provenance/x/ibchooks/keeper"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
"github.com/provenance-io/provenance/x/marker"
Expand Down Expand Up @@ -226,6 +229,7 @@ var (
triggermodule.AppModuleBasic{},
oraclemodule.AppModuleBasic{},
holdmodule.AppModuleBasic{},
exchangemodule.AppModuleBasic{},
)

// module account permissions
Expand Down Expand Up @@ -317,6 +321,7 @@ type App struct {
AttributeKeeper attributekeeper.Keeper
NameKeeper namekeeper.Keeper
HoldKeeper holdkeeper.Keeper
ExchangeKeeper exchangekeeper.Keeper
WasmKeeper *wasm.Keeper
ContractKeeper *wasmkeeper.PermissionedKeeper

Expand Down Expand Up @@ -400,6 +405,7 @@ func New(
triggertypes.StoreKey,
oracletypes.StoreKey,
hold.StoreKey,
exchange.StoreKey,
)
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
Expand Down Expand Up @@ -569,6 +575,11 @@ func New(
appCodec, keys[hold.StoreKey], app.BankKeeper,
)

app.ExchangeKeeper = exchangekeeper.NewKeeper(
appCodec, keys[exchange.StoreKey], authtypes.FeeCollectorName,
app.AccountKeeper, app.AttributeKeeper, app.BankKeeper, app.HoldKeeper,
)

pioMessageRouter := MessageRouterFunc(func(msg sdk.Msg) baseapp.MsgServiceHandler {
return pioMsgFeesRouter.Handler(msg)
})
Expand Down Expand Up @@ -751,6 +762,7 @@ func New(
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
oracleModule,
holdmodule.NewAppModule(appCodec, app.HoldKeeper),
exchangemodule.NewAppModule(appCodec, app.ExchangeKeeper),

// IBC
ibc.NewAppModule(app.IBCKeeper),
Expand Down Expand Up @@ -801,6 +813,7 @@ func New(
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,
exchange.ModuleName,
)

app.mm.SetOrderEndBlockers(
Expand Down Expand Up @@ -840,6 +853,7 @@ func New(
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,
exchange.ModuleName,
)

// NOTE: The genutils module must occur after staking so that pools are
Expand Down Expand Up @@ -871,6 +885,7 @@ func New(
metadatatypes.ModuleName,
msgfeestypes.ModuleName,
hold.ModuleName,
exchange.ModuleName, // must be after the hold module.

ibchost.ModuleName,
ibctransfertypes.ModuleName,
Expand Down Expand Up @@ -911,6 +926,7 @@ func New(
quarantine.ModuleName,
sanction.ModuleName,
hold.ModuleName,
exchange.ModuleName,

ibchookstypes.ModuleName,
icatypes.ModuleName,
Expand Down Expand Up @@ -961,6 +977,7 @@ func New(
triggermodule.NewAppModule(appCodec, app.TriggerKeeper, app.AccountKeeper, app.BankKeeper),
oraclemodule.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper, app.IBCKeeper.ChannelKeeper),
holdmodule.NewAppModule(appCodec, app.HoldKeeper),
exchangemodule.NewAppModule(appCodec, app.ExchangeKeeper),
provwasm.NewWrapper(appCodec, app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.NameKeeper),

// IBC
Expand Down
28 changes: 24 additions & 4 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

attributekeeper "github.com/provenance-io/provenance/x/attribute/keeper"
attributetypes "github.com/provenance-io/provenance/x/attribute/types"
"github.com/provenance-io/provenance/x/exchange"
"github.com/provenance-io/provenance/x/hold"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types"
Expand Down Expand Up @@ -113,10 +114,11 @@ var upgrades = map[string]appUpgrade{
removeInactiveValidatorDelegations(ctx, app)
setupICQ(ctx, app)
updateMaxSupply(ctx, app)
setExchangeParams(ctx, app)

return vm, nil
},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.ModuleName, hold.ModuleName},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.ModuleName, hold.ModuleName, exchange.ModuleName},
},
"saffron": { // upgrade for v1.17.0,
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
Expand All @@ -132,10 +134,11 @@ var upgrades = map[string]appUpgrade{
removeInactiveValidatorDelegations(ctx, app)
setupICQ(ctx, app)
updateMaxSupply(ctx, app)
setExchangeParams(ctx, app)

return vm, nil
},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.ModuleName, hold.ModuleName},
Added: []string{icqtypes.ModuleName, oracletypes.ModuleName, ibchookstypes.ModuleName, hold.ModuleName, exchange.ModuleName},
},
// TODO - Add new upgrade definitions here.
}
Expand Down Expand Up @@ -324,14 +327,16 @@ func setAccountDataNameRecord(ctx sdk.Context, accountK attributetypes.AccountKe
return attributekeeper.EnsureModuleAccountAndAccountDataNameRecord(ctx, accountK, nameK)
}

// setupICQ sets the correct default values for ICQKeeper
// setupICQ sets the correct default values for ICQKeeper.
// TODO: Remove with the saffron handlers.
func setupICQ(ctx sdk.Context, app *App) {
ctx.Logger().Info("Updating ICQ params")
app.ICQKeeper.SetParams(ctx, icqtypes.NewParams(true, []string{"/provenance.oracle.v1.Query/Oracle"}))
ctx.Logger().Info("Done updating ICQ params")
}

// updateMaxSupply sets the value of max supply to the current value of MaxTotalSupply
// updateMaxSupply sets the value of max supply to the current value of MaxTotalSupply.
// TODO: Remove with the saffron handlers.
func updateMaxSupply(ctx sdk.Context, app *App) {
ctx.Logger().Info("Updating MaxSupply marker param")
params := app.MarkerKeeper.GetParams(ctx)
Expand All @@ -340,3 +345,18 @@ func updateMaxSupply(ctx sdk.Context, app *App) {
app.MarkerKeeper.SetParams(ctx, params)
ctx.Logger().Info("Done updating MaxSupply marker param")
}

// setExchangeParams sets exchange module's params to the defaults.
// TODO: Remove with the saffron handlers.
func setExchangeParams(ctx sdk.Context, app *App) {
ctx.Logger().Info("Ensuring exchange module params are set.")
params := app.ExchangeKeeper.GetParams(ctx)
if params != nil {
ctx.Logger().Info("Exchange module params are already defined.")
} else {
params = exchange.DefaultParams()
ctx.Logger().Info("Setting exchange module params to defaults.")
app.ExchangeKeeper.SetParams(ctx, params)
}
ctx.Logger().Info("Done ensuring exchange module params are set.")
}
78 changes: 78 additions & 0 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/staking/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

"github.com/provenance-io/provenance/x/exchange"
msgfeetypes "github.com/provenance-io/provenance/x/msgfees/types"
)

Expand Down Expand Up @@ -426,6 +427,7 @@ func (s *UpgradeTestSuite) TestSaffronRC1() {
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
"INF Ensuring exchange module params are set.",
}

s.AssertUpgradeHandlerLogs("saffron-rc1", expInLog, nil)
Expand All @@ -442,6 +444,7 @@ func (s *UpgradeTestSuite) TestSaffron() {
"INF Done updating ICQ params",
"INF Updating MaxSupply marker param",
"INF Done updating MaxSupply marker param",
"INF Ensuring exchange module params are set.",
}

s.AssertUpgradeHandlerLogs("saffron", expInLog, nil)
Expand Down Expand Up @@ -841,3 +844,78 @@ func (s *UpgradeTestSuite) TestSetAccountDataNameRecord() {
s.Require().NoError(err, "setAccountDataNameRecord")
s.AssertLogContents(logOutput, expInLog, nil, true, "setAccountDataNameRecord")
}

func (s *UpgradeTestSuite) TestSetExchangeParams() {
startMsg := "INF Ensuring exchange module params are set."
noopMsg := "INF Exchange module params are already defined."
updateMsg := "INF Setting exchange module params to defaults."
doneMsg := "INF Done ensuring exchange module params are set."

tests := []struct {
name string
existingParams *exchange.Params
expectedParams *exchange.Params
expInLog []string
}{
{
name: "no params set yet",
existingParams: nil,
expectedParams: exchange.DefaultParams(),
expInLog: []string{startMsg, updateMsg, doneMsg},
},
{
name: "params set with no splits and default zero",
existingParams: &exchange.Params{DefaultSplit: 0},
expectedParams: &exchange.Params{DefaultSplit: 0},
expInLog: []string{startMsg, noopMsg, doneMsg},
},
{
name: "params set with no splits and different default",
existingParams: &exchange.Params{DefaultSplit: exchange.DefaultDefaultSplit + 100},
expectedParams: &exchange.Params{DefaultSplit: exchange.DefaultDefaultSplit + 100},
expInLog: []string{startMsg, noopMsg, doneMsg},
},
{
name: "params set with some splits",
existingParams: &exchange.Params{
DefaultSplit: exchange.DefaultDefaultSplit + 100,
DenomSplits: []exchange.DenomSplit{
{Denom: "peach", Split: 3000},
{Denom: "plum", Split: 100},
},
},
expectedParams: &exchange.Params{
DefaultSplit: exchange.DefaultDefaultSplit + 100,
DenomSplits: []exchange.DenomSplit{
{Denom: "peach", Split: 3000},
{Denom: "plum", Split: 100},
},
},
expInLog: []string{startMsg, noopMsg, doneMsg},
},
}

for _, tc := range tests {
s.Run(tc.name, func() {
s.app.ExchangeKeeper.SetParams(s.ctx, tc.existingParams)

// Reset the log buffer and call the fun. Relog the output if it panics.
s.logBuffer.Reset()
testFunc := func() {
setExchangeParams(s.ctx, s.app)
}
didNotPanic := s.Assert().NotPanics(testFunc, "setExchangeParams")
logOutput := s.GetLogOutput("setExchangeParams")
if !didNotPanic {
return
}

// Make sure the log has the expected lines.
s.AssertLogContents(logOutput, tc.expInLog, nil, true, "setExchangeParams")

// Make sure the params are as expected now.
params := s.app.ExchangeKeeper.GetParams(s.ctx)
s.Assert().Equal(tc.expectedParams, params, "params after setExchangeParams")
})
}
}
2 changes: 1 addition & 1 deletion client/docs/statik/statik.go

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36409,8 +36409,8 @@ paths:
type: string
format: uint64
title: >-
maximum amount of supply to allow a marker to be created
with
Deprecated: Prefer to use `max_supply` instead. Maximum
amount of supply to allow a marker to be created with
enable_governance:
type: boolean
format: boolean
Expand All @@ -36425,6 +36425,11 @@ paths:

requests are only subject to platform coin validation
denom expression)
max_supply:
type: string
title: >-
maximum amount of supply to allow a marker to be created
with
description: >-
QueryParamsResponse is the response type for the Query/Params RPC
method.
Expand Down Expand Up @@ -83319,7 +83324,9 @@ definitions:
max_total_supply:
type: string
format: uint64
title: maximum amount of supply to allow a marker to be created with
title: >-
Deprecated: Prefer to use `max_supply` instead. Maximum amount of
supply to allow a marker to be created with
enable_governance:
type: boolean
format: boolean
Expand All @@ -83332,6 +83339,9 @@ definitions:

requests are only subject to platform coin validation denom
expression)
max_supply:
type: string
title: maximum amount of supply to allow a marker to be created with
description: Params defines the set of params for the account module.
provenance.marker.v1.QueryAccessResponse:
type: object
Expand Down Expand Up @@ -83950,7 +83960,9 @@ definitions:
max_total_supply:
type: string
format: uint64
title: maximum amount of supply to allow a marker to be created with
title: >-
Deprecated: Prefer to use `max_supply` instead. Maximum amount of
supply to allow a marker to be created with
enable_governance:
type: boolean
format: boolean
Expand All @@ -83963,6 +83975,9 @@ definitions:

requests are only subject to platform coin validation denom
expression)
max_supply:
type: string
title: maximum amount of supply to allow a marker to be created with
description: QueryParamsResponse is the response type for the Query/Params RPC method.
provenance.marker.v1.QuerySupplyResponse:
type: object
Expand Down
Loading
Loading