blockful-io / swaplace-contracts

Swaplace is an open-source, ownerless and feeless token swap protocol
https://app.swaplace.xyz/
MIT License
32 stars 33 forks source link

feat: create DefiLlama adapter to measure TVL #190

Open 0xneves opened 5 months ago

0xneves commented 5 months ago

Feature Request

Describe the Feature Request

We want to have our project listed on DefiLlama. They provide an extensive tutorial on how to create adapters for such features on this link.

1- Fork the Adapters repo (button towards the top right of the repo page). 2- Add a new folder with the same name as the project to projects/. 3- Write an SDK adapter in the new folder. 4- Make a Pull Request with the changes on your fork, to the main DefiLlama Adapters repo, with a brief explanation of what you changed. 5- Wait for someone to either comment on or merge your Pull Request. There is no need to ask for someone to check your PR as there a monitored regularly. 6- Once your PR has been merged, please give 24 hours for the front-end team to load your listing onto the UI. 7- If protocol is already listed and you want to add a new product/version, just make a new adapter and submit a PR. DefiLlama team will make the necessary changes afterwards (adding all protocols under a parent listing).

Describe Preferred Solution

Following the above tutorial will fulfill this task. The differential that we are looking for in Swaplace is not TVL, but rather: Offers - funds that are approved for spending on a non-custodial platform, but not deposited into the platform contracts

Since Swaplace operates on approvals, we can only measure the total value of tokens that the contract has in approvals. So let's say Jhon approved $1000 to Swaplace contract. We must build our adapter to measure such approved funds and sum them as a total approved value to become the TVL of Swaplace.

Additional Context

The question I raise is: Most people will approve type(uint256).max, and this will be considered an infinite money glitch. So my question is... Can we detect approvals to the contract, then call balanceOf on that user to see how much he really does have that is negotiable? Can we push the adapters of DefiLlama to such feat?

Another question I'm raising is about the NFTs floor prices, can we measure them? Using approvals just like mentioned above?

0xjoaovpsantos commented 5 months ago

Working on it @0xneves :)

0xneves commented 5 months ago

Working on it @0xneves :)

Wow, descending from the heavens