Skip to content

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

Open
wants to merge 108 commits into
base: vault-integration
Choose a base branch
from
Open

feat: protocol fee #228

wants to merge 108 commits into from

Conversation

AuHau
Copy link
Member

@AuHau AuHau commented Mar 24, 2025

Closes #186

Based on the Vault integration worked.

- 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
markspanbroek and others added 16 commits March 4, 2025 09:36
- 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
Copy link
Collaborator

@emizzle emizzle left a 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 👍

Comment on lines +17 to +21
function maxPriceWithProtocolFee(request, config) {
return maxPrice(request) + protocolFee(request, config)
}

function maxPriceWithProtocolFee(request, config) {
Copy link
Collaborator

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);
Copy link
Collaborator

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 () {
Copy link
Collaborator

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(
Copy link
Contributor

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 ?

@emizzle
Copy link
Collaborator

emizzle commented Apr 17, 2025

@AuHau let's get this updated so we can merge it please?

@AuHau
Copy link
Member Author

AuHau commented Apr 17, 2025

It is based on Vault integration, which is not merged in yet so pretty pointless to update... 😉

@emizzle
Copy link
Collaborator

emizzle commented Apr 17, 2025

But the Vault work was merged, no?

@AuHau
Copy link
Member Author

AuHau commented Apr 17, 2025

Well yes and no ;-)
Vault itself yes, but not its integration: #223 (and that is actually what is this PR based on)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants