-
Notifications
You must be signed in to change notification settings - Fork 105
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
feat(x/ecocredit/marketplace): implement buyer and seller fees #2154
Conversation
…onc/marketplace-fees
…onc/marketplace-fees-impl
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2154 +/- ##
==========================================
+ Coverage 72.90% 72.92% +0.01%
==========================================
Files 240 243 +3
Lines 13860 14022 +162
==========================================
+ Hits 10105 10225 +120
- Misses 3016 3042 +26
- Partials 739 755 +16
|
x/ecocredit/server/server.go
Outdated
@@ -67,7 +67,7 @@ func NewServer(storeKey storetypes.StoreKey, | |||
s.marketplaceStore = marketStore | |||
s.BaseKeeper = basekeeper.NewKeeper(baseStore, bankKeeper, baseAddr, basketStore, marketStore, authority) | |||
s.BasketKeeper = basketkeeper.NewKeeper(basketStore, baseStore, bankKeeper, basketAddr, authority) | |||
s.MarketplaceKeeper = marketkeeper.NewKeeper(marketStore, baseStore, bankKeeper, authority) | |||
s.MarketplaceKeeper = marketkeeper.NewKeeper(marketStore, baseStore, bankKeeper, authority, ecocredit.ModuleName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question for reviewers: Should the fee pool be the main ecocredit module account or should it be separated into a separate module account? How do we give governance the ability to govern over this fee pool (likely in a separate PR)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe it should be its own account, it will also make it easier if it evolves into its own module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeancarloBarrios see 3376e76 and caa606c where:
- a marketplace fee pool module account is set up,
- and I added a new
MsgGovSendFromFeePool
message so that governance can actually manage the fee pool funds
Let me know if this all looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah It looks good to me
* expect bob bank balance "0foo" | ||
* expect fee pool balance "15foo" | ||
|
||
Scenario: fees get burned |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is an event emitted when fees are burned? I see above there are scenarios to test that specific events are emitted. Maybe that isn't needed here since it would not be an event type provided by marketplace submodule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can emit the burn event here. Don't have a strong preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like a burn event should be emitted but it just isn't clear to me if that is already happening. Does the bank keeper do that for us? If so, then maybe we don't need to include in tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bank keeper does include burn events, but since MsgBuyDirect
now also includes the fees paid and we can assume that if the denom is uregen
that it was a burn, is it okay if we just leave it at that and not add another event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the pros and cons of adding a specific event here? seems like for users, it is useful to have a specific event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there's really a pro to adding it. The con is that it just adds duplicitous events which takes up extra storage. The bank keeper and marketplace module already emit events containing the relevant data, so I think we should leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I might have created some confusion here. I just wanted to make sure that a burn event does exist. I agree we do not need a duplicate event. This would all be very clear if the test scenario included checking that the burn event is emitted but no worries if this is non-trivial to add.
return err | ||
} | ||
|
||
// if total fee > 0, then transfer total fee from buyer account to fee pool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, just a question on how the fees/costs are moving around.
As implemented here a successful MsgBuyDirect
in a TX with quantity 10, cost 10uregen and both a buyer fee 0.1 and seller fee 0.05, will result in two separate transfer
events in the message :
transfer
for all total fees (15uregen) from the buyer to the fee pooltransfer
for seller payment (95uregen) from the buyer to the seller
This makes sense and the math adds up. But I wonder if it could lead to some confusion because from the resulting tx it looks like the buyer is paying all of the fees. I'm not sure how important it is too keep this detailed of a record on the TX or if it is much less efficient, but it seems like it could be useful for helpting to calculate total fees spent by buyer or seller (maybe for tax purposes?)
An example:
transfer
for only buyer fees (10uregen) from the buyer to the fee pooltransfer
for seller payment subtotal cost (100uregen) from the buyer to the sellertransfer
for only seller fees (5uregen) from the seller to the fee pool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally, I would stick to the side of efficiency here and not introduce unnecessary state changes because of downstream accounting. If accounting is the consideration, I would rather deal with that by adding attributes to events, maybe enhancing EventBuyDirect
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it might make sense to add that in EventBuyDirect
then. I'm just assuming this would be useful for accounting, maybe we can validate that from a business use-case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, to keep track of accounting the event makes more sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paul121 @JeancarloBarrios added seller and buyer fees paid to EventBuyDirect
, see b1a7ad2. Does that address this sufficiently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks great
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ryan and I reviewed this PR today during the regen ledger office hours he is hosting and came out with an important question regarding this feature: Why is the seller paying the fee at time of purchase?
An alternative could be paying the seller fee when creating the sell order. There are few reasons this could be desirable:
- There will be a scenario when the seller fee % changes after sell orders have been created. Paying the seller fee at the time of purchase means the seller can never guarantee what fee they might be charged in the future. All sell orders could automatically be closed when changing the seller fee % but this would create a bad UX.
- Paying the seller fee when creating a sell order means the seller would be explicitly consenting to the current seller fee when signing their transaction.
- It would be easier to track the exact seller fee amount (see my above comment)
- This would help to prevent spamming the network of unreasonable sell orders. If a seller cancels the sell order, the fee has already been paid/burned, and benefits the network.
I have to say that I strongly disagree with this. Sellers can change their pricing or close orders at any point in time. Making it so that they pay upfront would mean that the fees need to be escrowed. Also, they are paying for the fees in the sell denom which means they need to gather that capital in advance without having already gotten payment. If fees are low this might not be a problem, but if fees are non-trivial this capital requirement could be a barrier to entry. If we want an anti-spam fee, that should be something different IMHO. |
Yes, agree that needing the capital in advance could be a barrier to entry, and there could be other solutions for anti-spam fee. But we wondered if these things might be beneficial for the network. It would be a more significant change though. The fact that fees could change after the sell order is created was our main concern. Perhaps it isn't a huge issue, but just wanted to make sure to flag that. It should at least be clear to the seller that the sell order may incur a fee when it is later closed. |
There will always be plenty of advanced notice around governance changes if sellers are concerned about fee changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it looks good I dont have any major comment LGTM
"I like to compare it to the fees you see on the Apple App Store or similar platforms. Essentially, the ecosystem determines what fees are reasonable; under that mindset, what @aaronc suggests makes sense to me. However, I understand the concern of sellers having to adjust prices based on the fee. For quick implementation, it's acceptable because, as @aaronc mentioned, it requires a governance proposal, so it's unlikely to change significantly anytime soon. Later on, we can introduce a custom fee module that allows for more nuanced adjustments. |
…onc/marketplace-fees-impl
@paul121 @JeancarloBarrios I believe I have addressed all concerns. I have also added a new message |
Note that the cosmos module docs have moved here: https://docs.cosmos.network/main/build/building-modules/intro |
@aaronc you'd asked me to review this, mentioning that non technical folks like myself could engage in this productively. So far the only productive comment I have made is finding a broken link to cosmos module docs. After reviewing the changes and discussions about adding a fee pool and governance / management of fees, it sounds like the team has made some solid decisions. While I'm not the tech expert to dive into the nitty-gritty, it seems like the next step would be for those who have the know-how to double-check the work. They'd ensure everything is up to snuff security-wise, works smoothly, and fits what the project aims to do. It's like making sure the foundation is strong before moving on! |
Thanks @glandua. I think the key high-level points to keep in mind here is that:
|
I reviewed these changes and they make sense to me. My only question is if we have a way for the marketplace account to grant access (likely authz authorization) for another account to manage these accrued fees more efficiently than via governance proposals. Can that authorization itself be created via a separate governance proposal? I assume this is already possible or could be added in a followup PR but just want to make sure there is a path for this. |
Authz should make this possible with no additional ledger dev needed. |
I believe we can do that already. with authz itself |
I reviewed it again and it LGTM!!! |
Thanks for the reviews @JeancarloBarrios and @paul121. Going to go ahead and merge this now. |
Description
Implementation for #2151
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change