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

Add Blacksail Finance TVL adapter for Sonic Mainnet #12932

Merged
merged 14 commits into from
Jan 7, 2025

Conversation

xblackbeard
Copy link
Contributor

@xblackbeard xblackbeard commented Jan 1, 2025

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.
  • If you would like to add a liquidations adapter, please refer to this readme document 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. 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):

Blacksail Finance

Twitter Link:

https://x.com/blacksail_fi

List of audit links if any:

https://app.solidproof.io/projects/blacksail
https://docs.blacksail.finance/about-blacksail-finance/audits/in-house-audit

Website Link:

https://app.blacksail.finance/

Logo (High resolution, will be shown with rounded borders):

https://docs.blacksail.finance/~gitbook/image?url=https%3A%2F%2F198229502-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fi9vbjZSWtXcZaBayytwv%252Fuploads%252FgwVIhnoQzfk2f6q8kT3r%252Fbsf-black.png%3Falt%3Dmedia%26token%3D28513eb7-5067-481f-ae50-59ac4980ea90&width=768&dpr=1&quality=100&sign=d7fee2e9&sv=2

https://docs.blacksail.finance/~gitbook/image?url=https%3A%2F%2F198229502-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252Fi9vbjZSWtXcZaBayytwv%252Fuploads%252F6JWmH8geJBq9IWRhp7om%252Fbsf.png%3Falt%3Dmedia%26token%3D06b917ea-2024-4a2e-8327-7ee37c018fbe&width=768&dpr=1&quality=100&sign=9131b2cf&sv=2

Current TVL:

22,536.77

Treasury Addresses (if the protocol has treasury)

0x0c16Da76872131bC6095f73b894B4757873dAce1

Chain:

Sonic: 146

Coingecko ID (so your TVL can appear on Coingecko, leave empty if not listed): (https://api.coingecko.com/api/v3/coins/list)
Coinmarketcap ID (so your TVL can appear on Coinmarketcap, leave empty if not listed): (https://api.coinmarketcap.com/data-api/v3/map/all?listing_status=active,inactive,untracked&start=1&limit=10000)
Short Description (to be shown on DefiLlama):

Blacksail Finance is an advanced smart contract yield compounding suite built on the Sonic Blockchain network. Blacksail helps users earn more cryptocurrency by automatically compounding their DeFi rewards for their crypto tokens into their original assets, allowing users to easily earn more of their favorite holdings.

Token address and ticker if any:
Category (full list at https://defillama.com/categories) *Please choose only one:

Yield Aggregator

Oracle Provider(s): Specify the oracle(s) used (e.g., Chainlink, Band, API3, TWAP, etc.):
Implementation Details: Briefly describe how the oracle is integrated into your project:
Documentation/Proof: Provide links to documentation or any other resources that verify the oracle's usage:
forkedFrom (Does your project originate from another project):
methodology (what is being counted as tvl, how is tvl being calculated):

TVL is the usd value of all LP tokens deposited in each vault strategy contract on Blacksail Finance.

Github org/user (Optional, if your code is open source, we can track activity):

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

AxiosError: Request failed with status code 403
Axios:  Origin not allowed
Truncated error stack:
    at settle (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/axios/dist/node/axios.cjs:2015:12)
    at IncomingMessage.emit (node:events:529:35)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:8:26
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

AxiosError: Request failed with status code 403
Axios:  Origin not allowed
Truncated error stack:
    at settle (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/axios/dist/node/axios.cjs:2015:12)
    at IncomingMessage.emit (node:events:529:35)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:8:26
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

AxiosError: Request failed with status code 403
Axios:  Origin not allowed
Truncated error stack:
    at settle (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/axios/dist/node/axios.cjs:2015:12)
    at IncomingMessage.emit (node:events:529:35)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:8:26
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

AxiosError: Request failed with status code 403
Axios:  Origin not allowed
Truncated error stack:
    at settle (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/axios/dist/node/axios.cjs:2015:12)
    at IncomingMessage.emit (node:events:529:35)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:8:26
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

AxiosError: Request failed with status code 403
Axios:  Origin not allowed
Truncated error stack:
    at settle (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/axios/dist/node/axios.cjs:2015:12)
    at IncomingMessage.emit (node:events:529:35)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:8:26
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@xblackbeard
Copy link
Contributor Author

What origin do I need to whitelist in the API?

@waynebruce0x
Copy link
Collaborator

please read token balances using on chain methods instead of a proprietary api. In its current form this adapter is impossible to debug or audit

@waynebruce0x waynebruce0x self-assigned this Jan 2, 2025
@xblackbeard
Copy link
Contributor Author

xblackbeard commented Jan 2, 2025

please read token balances using on chain methods instead of a proprietary api. In its current form this adapter is impossible to debug or audit

@waynebruce0x We can call the balances of the strategies directly on chain if you prefer, but the issue remains in the fact that we need to multiply the balances by the USD value of the LPs held by the strategy which requires a custom API since each LP price is calculated differently per DEX. Do you have some suggestions here? Do we have a public LP pricing API we can use, or can we use our API for the pricing portion only? This is the same reason why beefy.finance uses a custom API endpoint.

@waynebruce0x
Copy link
Collaborator

Our price API supports a range of LPs and we should be able to support any missing assets that are a significant portion of your TVL

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Cannot find module 'web3'
Require stack:
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js
Truncated error stack:

    at Object.<anonymous> (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:2:14)
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Cannot find module 'web3'
Require stack:
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js
Truncated error stack:

    at Object.<anonymous> (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:2:14)
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Cannot find module 'web3'
Require stack:
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js
- /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js
Truncated error stack:

    at Object.<anonymous> (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:2:16)
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Protocol doesn't have total tvl, make sure to export a tvl key either on the main object or in one of the chains
Truncated error stack:

    at /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:228:11
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@xblackbeard
Copy link
Contributor Author

xblackbeard commented Jan 4, 2025

@waynebruce0x do you mind taking a look at this error? I implemented on chain methods to grab the strategy balances and calculate the total tvl for the chain. May still need to whitelist a domain in CORS to allow us to pull the strategy addresses from the blacksail API

@waynebruce0x
Copy link
Collaborator

Our server infra does not have a static IP - can you give us a key or make the API public?

@xblackbeard
Copy link
Contributor Author

@waynebruce0x Thanks for taking a look, I have created an API key for you to use, what's the most secure way for me to send it over to you to store in the env?

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Protocol doesn't have total tvl, make sure to export a tvl key either on the main object or in one of the chains
Truncated error stack:

    at /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:228:11
Error saving cache: Error: ENOENT: no such file or directory, open '/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/node_modules/@defillama/sdk/build/util/local_cache/zlib-1.0/BlockCache.json'

@llamabutler
Copy link

Error while running adapter at projects/blacksail:

Error: Failed to fetch Blacksail API: 403 - Forbidden
Truncated error stack:

    at fetchChain (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:91:19)
    at async tvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/projects/blacksail/index.js:118:20)
    at async getTvl (/home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:52:23)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:173:9
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async /home/runner/work/DefiLlama-Adapters/DefiLlama-Adapters/test.js:216:3

@waynebruce0x
Copy link
Collaborator

have you got discord? can you join our server and tag me in a message? Failing that, telegram?

const response = await fetch('https://api.blacksail.finance/stats', {
method: 'GET',
headers: {
'x-api-key': process.env.BLACKSAIL_API_KEY,
Copy link
Member

Choose a reason for hiding this comment

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

hi, can you share this api key, unsure why this is a protected route.

Copy link
Contributor Author

@xblackbeard xblackbeard Jan 8, 2025

Choose a reason for hiding this comment

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

Hi, I have shared the API key with @waynebruce0x via discord DMs previously to add to the .env. What's your discord tag I can DM it to you as well?

@llamabutler
Copy link

The adapter at projects/blacksail exports TVL:

sonic                     11.25 k

total                    11.25 k 

@g1nt0ki
Copy link
Member

g1nt0ki commented Jan 7, 2025

added a hack for now, will fix it once we get the api

@g1nt0ki g1nt0ki merged commit 59e557d into DefiLlama:main Jan 7, 2025
1 check passed
@xblackbeard
Copy link
Contributor Author

xblackbeard commented Jan 8, 2025

@g1nt0ki Hi thanks for working on PR 12932 for Blacksail, reading the comments I have shared the API key with @waynebruce0x via discord DM previously to add to the env, would you like a copy as well? I see the PR was closed without calling the API at all, whats up with that?

Also it seems like we aren't properly calculating the price of our largest pool which is a beets (WeightedPool) LP from this strategy with roughly 5K tvl: 0xAc57B713C630f188bc2d95c2ae3C27A1DE1DebA1

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