Skip to content

Commit

Permalink
Shprd (DefiLlama#9011)
Browse files Browse the repository at this point in the history
* Add shprd vaults TVL

* code refactor

* Update pull request template

---------

Co-authored-by: Francis Berger <[email protected]>
  • Loading branch information
g1nt0ki and Francis Berger authored Feb 20, 2024
1 parent 0e991eb commit cd8d00e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 6 deletions.
34 changes: 34 additions & 0 deletions projects/shprd/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const protocolConfig = {
factories: {
ethereum: { address: '0xf14c4b935054b8d1017ad96c9a265eb7f8ecf13c' },
arbitrum: { address: '0xf0ee0b31aae29f0bea8ff806c101377fc92e4ffa' },
}
}

async function tvl(ts, block, _, { api }) {
// 1. get all vaults deployed on chain
const factoryAddress = protocolConfig.factories[api.chain].address
const factoryState = await api.call({
abi: "function getFactoryState() view returns (address[], address, address, address, address, address)",
target: factoryAddress,
});
const vaultAddresses = factoryState[0]

// 2. get all tradable erc20s for these same vaults
const tokens = await api.call({ abi: "address[]:getWhitelistedTokens", target: factoryAddress, });
return api.sumTokens({ owners: vaultAddresses, tokens, })
}


module.exports = {
start: 1688162400,
hallmarks: [
[1695396647, "Fees distribution #1"],
[1705582439, "Fees distribution #2"],
],
methodology: `TVL is the total value of erc20s managed by SHPRD vaults`
};

Object.keys(protocolConfig.factories).forEach(chain => {
module.exports[chain] = { tvl }
})
15 changes: 9 additions & 6 deletions pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
**NOTE**

#### Please enable "Allow edits by maintainers" while putting up the PR.

---

> - If you would like to add a `volume` adapter please submit the PR [here](https://github.com/DefiLlama/adapters).
> - If you would like to add a `liquidations` adapter, please refer to [this readme document](https://github.com/DefiLlama/DefiLlama-Adapters/tree/main/liquidations) for details.
1. Once your adapter has been merged, it takes time to show on the UI. If more than 24 hours have passed, please let us know in Discord.
2. Please enable "Allow edits by maintainers" while putting up the PR.
3. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
4. Please fill the form below **only if the PR is for listing a new protocol** else it can be ignored/replaced with reason/details about the PR
5. **For updating listing info** It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
6. Do not edit/push `package-lock.json` file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
7. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap
2. Sorry, We no longer accept fetch adapter for new projects, we prefer the tvl to computed from blockchain data, if you have trouble with creating a the adapter, please hop onto our discord, we are happy to assist you.
3. Please fill the form below **only if the PR is for listing a new protocol** else it can be ignored/replaced with reason/details about the PR
4. **For updating listing info** It is a different repo, you can find your listing in this file: https://github.com/DefiLlama/defillama-server/blob/master/defi/src/protocols/data2.ts, you can edit it there and put up a PR
5. Do not edit/push `package-lock.json` file as part of your changes, we use lockfileVersion 2, and most use v1 and using that messes up our CI
6. No need to go to our discord and announce that you've created a PR, we monitor all PRs and will review it asap

---
##### Name (to be shown on DefiLlama):
Expand Down

0 comments on commit cd8d00e

Please sign in to comment.