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

Feat: Added wise-lending-v2 fees #1968

Merged
merged 3 commits into from
Oct 14, 2024
Merged

Conversation

jenelyn0214
Copy link
Contributor

No description provided.

@llamatester
Copy link

The wise-lending-v2 adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees wise-lending-v2

🦙 Running WISE-LENDING-V2 adapter 🦙
---------------------------------------------------
Start Date:	Sun, 06 Oct 2024 03:10:55 GMT
End Date:	Mon, 07 Oct 2024 03:10:55 GMT
---------------------------------------------------

ARBITRUM 👇
Backfill start time: 1/10/2024
NO METHODOLOGY SPECIFIED
Daily fees: 352
End timestamp: 1728270654 (2024-10-07T03:10:54.000Z)

@g1nt0ki g1nt0ki self-assigned this Oct 7, 2024
@g1nt0ki g1nt0ki self-requested a review October 7, 2024 12:13
Copy link
Member

@g1nt0ki g1nt0ki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @jenelyn0214 thanks for the PR, but we prefer computing fees on chain (where possible) this way we/the users can understand what is included as fees and the adapter would continue to work even if the endpoint becomes unreachable.

Easiest way to do this is, relying on event logs, are there are any logs emitted when users pay the fees.

If you share sample transaction of this, I can work on refactoring it to compute fees using onchain data

@vm06007
Copy link

vm06007 commented Oct 9, 2024

@jenelyn0214 could you take the on-chain code we use for https://data.wisetoken.net/WISE/globals/fees.json and implement here same calls to contract data that gives us same result as in the feed.

@llamatester
Copy link

The wise-lending-v2 adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees wise-lending-v2

🦙 Running WISE-LENDING-V2 adapter 🦙
---------------------------------------------------
Start Date:	Wed, 09 Oct 2024 11:05:44 GMT
End Date:	Thu, 10 Oct 2024 11:05:44 GMT
---------------------------------------------------

ARBITRUM 👇
Backfill start time: 1/10/2024
NO METHODOLOGY SPECIFIED
Daily fees: 346
End timestamp: 1728558343 (2024-10-10T11:05:43.000Z)

@vm06007
Copy link

vm06007 commented Oct 11, 2024

@g1nt0ki can you check again we've changed the implementation to be on-chain

calls: arbitrumPools,
});

api.add(arbitrumPools, feeAmounts);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seem it total value not daily

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you query this endpoint daily then you get the values on daily basis

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this adapter shows our current fees generated by the protocol that are not withdrawn, as soon as protocol withdraws the fees this global value of fees accumulated is reduced accordingly. @dtmkeng feel free to open our contract and see how the fees are handled.

  • query feeTokens() to see accumulated fees for the pool that are not withdrawn, query feeTokens() at any time to get the amount of fees protocol holds at each point in time.

  • elaborate about daily? contract provides fees for each pool at every given moment every time you make a snapshot of this data (daily, monthly or each hour is up to you) we give you data on chain about fees we've collected at each point available from the protocol.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seem it total value not daily

can you elaborate how it should be? did you check contract code? the fees reported are correct per pool, if they are withdrawn on daily basis call to this function would reflect that in value updated every time queried.

Copy link
Contributor

@dtmkeng dtmkeng Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value you get from function it total value not daily

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

daily value from contract function should like this https://github.com/DefiLlama/dimension-adapters/blob/master/fees/crv-usd.ts

@vm06007
Copy link

vm06007 commented Oct 14, 2024

@g1nt0ki could you take a look and progress this PR? We've changed the solution to be on-chain.

@g1nt0ki g1nt0ki merged commit 2715061 into DefiLlama:master Oct 14, 2024
2 checks passed
@llamatester
Copy link

The wise-lending-v2 adapter exports:

> [email protected] test
> ts-node --transpile-only cli/testAdapter.ts fees wise-lending-v2

🦙 Running WISE-LENDING-V2 adapter 🦙
---------------------------------------------------
Start Date:	Sun, 13 Oct 2024 21:03:02 GMT
End Date:	Mon, 14 Oct 2024 21:03:02 GMT
---------------------------------------------------

ARBITRUM 👇
Backfill start time: 1/10/2024
NO METHODOLOGY SPECIFIED
Daily fees: 0
Total fees: 360
End timestamp: 1728939781 (2024-10-14T21:03:01.000Z)

@g1nt0ki
Copy link
Member

g1nt0ki commented Oct 14, 2024

@jenelyn0214 hmm, on second thought, this might show lower fees because if the protocol withdraws fees in the 24 hour period, it is subtracted right? is there some event log when the withdrawal happens so we can include it?

@vm06007
Copy link

vm06007 commented Oct 15, 2024

@jenelyn0214 hmm, on second thought, this might show lower fees because if the protocol withdraws fees in the 24 hour period, it is subtracted right? is there some event log when the withdrawal happens so we can include it?

yes let's include it if possible, we have event ClaimedFeesWise()

        emit ClaimedFeesWise(
            underlyingTokenAddress,
            tokenAmount,
            block.timestamp
        );

emitted during claimWiseFees call.

@g1nt0ki
Copy link
Member

g1nt0ki commented Oct 17, 2024

okay, updated code the use that event: a2a5c6a

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.

5 participants