Skip to content

Add figure markets #15501

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

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

jarrydallison
Copy link

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): Figure Markets
Twitter Link: https://twitter.com/figuremarkets
List of audit links if any: N/A
Website Link: https://www.figuremarkets.com/
Logo (High resolution, will be shown with rounded borders):

Figure Markets_id_661929bb-b50a-4524-ad7f-5c6261b40203_size900

Current TVL:

Figure Markets: 48.96 M
Figure Markets Democratized Prime: 837.08 k

Treasury Addresses (if the protocol has treasury)

N/A

Chain: Provenance
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):

Figure Markets: A crypto exchange designed for traders who demand more. Benefit from the security and asset control of decentralized custody with the ease and liquidity of a centralized exchange.
FM Democratized Prime: Democratized Prime connects your cash or crypto with borrowers seeking liquidity on their collateral.

Token address and ticker if any:

N/A

Category (full list at https://defillama.com/categories) *Please choose only one:

Figure Markets: OTC Marketplace
Figure Markets Democratized Prime: RWA Lending

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):

N/A

methodology (what is being counted as tvl, how is tvl being calculated):

Figure Markets: All commitments to the Figure Markets exchange are pulled, and those commitments are then converted to their CoinGecko denoms and values
Figure Markets Democratized Prime:
To determine the TVL and borrowed amounts in the Figure Markets Democratized Prime protocol, we query each pool, determining the total collateral and total loaned, and subtract the two to calculate the total TVL in the protocol.

  1. Get all available pools at https://www.figuremarkets.com/service-lending/api/v1/leverage-pools?location=CAYMAN

  2. For each asset pool that isn't YLDS, pull the existing offers at https://www.figuremarkets.com/service-lending/api/v1/offers?asset=${asset}&location=CAYMAN

  3. YLDS is backed by lending facilities. To get all lending lending facilities, pull all assets and filter to only those whose type is LENDING_FACILITY at https://www.figuremarkets.com/service-hft-exchange/api/v1/assets?page=1&size=100&include_lending_facility_assets=true

  4. Add all lending facility unpaid balances to get the existing total lending collateral available on the protocol. To get the total borrowed, query the existing offer for YLDS.

  5. Calculate the TVL using these values. We also report this as doublecounted since it is likely represented in the Figure Markets protocol, and also represent the borrowed amount as borrowed in the response.

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

https://github.com/provenance-io/provenance

@llamabutler
Copy link

The adapter at projects/figure-markets-democratized-prime exports TVL:

provenance                837.42 k
provenance-borrowed       3.62 k
borrowed                  3.62 k

total                    837.42 k 

@llamabutler
Copy link

The adapter at projects/figure-markets exports TVL:

provenance                48.97 M

total                    48.97 M 

await Promise.all(
Object.keys(tokenObject).map(async (t) => {
// Get the denom exponent information
const response = await fetch(
Copy link
Member

Choose a reason for hiding this comment

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

no, this is really bad, this will fetch denom metadata each time, use this structure instead: https://github.com/DefiLlama/DefiLlama-Adapters/blob/main/projects/helper/tokenMapping.js#L41

then you can do api.add(token, bal) in the adapter code and add

return sumTokens2({ api }), it will take care of transforming to cg tokens

Copy link
Author

Choose a reason for hiding this comment

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

Updated locally, pushing after we answer the below question.

Copy link
Member

Choose a reason for hiding this comment

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

this file can be removed

Copy link
Author

Choose a reason for hiding this comment

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

Removed locally, will push once the below question is answered.

nextTokens.commitments.map((c) =>
c.amount.map((a) => {
const denom = a.denom;
if (acc[denom]) {
Copy link
Member

Choose a reason for hiding this comment

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

can be replaced with api.add(a.denom, a.amount)

Copy link
Author

Choose a reason for hiding this comment

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

Updated, will push as soon as we answer the below question.

}

// Returns all leveraged pools in Figure Markets Democratized Prime
// https://www.figuremarkets.com/c/democratized-prime/lending-pools
Copy link
Member

Choose a reason for hiding this comment

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

leverage pools is derivatives trading? I wouldnt mix it with lending, also, how to get info of both on chain?

Copy link
Author

Choose a reason for hiding this comment

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

Working on this. I mislabeled that, it should have read lending pools.

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.

3 participants