-
Notifications
You must be signed in to change notification settings - Fork 10
feat: protocol fee #228
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
base: vault-integration
Are you sure you want to change the base?
feat: protocol fee #228
Conversation
- changes balance from uint256 -> uint128 so that entire Balance can be read or written with a single operation - moves Lock to library - simplifies lock checks
- removes RequestCancelled event, which was not great anyway because it is not emitted at the moment that the request is cancelled
- move all collateral calculatons to separate library
so that they can no longer be transfered within the vault
This state is no longer necessary, vault ensures that payouts happen only once. Hosts could bypass this state anyway by withdrawing from the vault directly.
- changes to marketplace constructor - we no longer have _marketplaceTotals - timestamps have their own type now - freeSlot no longer takes payout addresses - slot state 'Paid' no longer exists - freeSlot can be invoked more than once now - a failed request no longer ends immediately
No need to test the token itself
It is no longer a discount on the collateral, to simplify reasoning about collateral in the sales module of the codex node
b865da4
to
53679b4
Compare
53679b4
to
cfd30bf
Compare
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.
Nice job! One request for an additional test, but nothing blocking, so will approve now 👍
function maxPriceWithProtocolFee(request, config) { | ||
return maxPrice(request) + protocolFee(request, config) | ||
} | ||
|
||
function maxPriceWithProtocolFee(request, config) { |
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.
Do these functions not have the exact same signature?
@@ -149,6 +156,8 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian { | |||
TokensPerSecond pricePerSecond = request.ask.pricePerSecond(); | |||
uint128 price = pricePerSecond.accumulate(request.ask.duration); | |||
|
|||
_collectProtocolFee(request.client, request.ask); |
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'm assuming this function and _transferToVault(request.client, fund, account, price);
would revert with "insufficient funds" if the user does not have enough funds to cover both the fee and the price?
) | ||
}) | ||
|
||
it("is not returned when request is cancelled", async function () { |
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.
Maybe we should add a similar test for failed? Since now I believe with the Vault the client gets refunded if the request fails...
const startBalance = await token.balanceOf(client.address) | ||
await marketplace.withdrawFunds(slot.request) | ||
const endBalance = await token.balanceOf(client.address) | ||
expect(endBalance - startBalance).to.equal( |
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.
Why we do not check the dead balance here ?
cfd30bf
to
8a11e87
Compare
@AuHau let's get this updated so we can merge it please? |
It is based on Vault integration, which is not merged in yet so pretty pointless to update... 😉 |
But the Vault work was merged, no? |
Well yes and no ;-) |
55fb29f
to
0bdefa7
Compare
Closes #186
Based on the Vault integration worked.