Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

feat(rigoblock): add uni v3 positions #2902

Merged
merged 38 commits into from Aug 26, 2023

Conversation

gabririgo
Copy link
Contributor

@gabririgo gabririgo commented Aug 18, 2023

Description

Added Rigoblock contract position fetcher for Uniswap V3 liquidity positions owned by Rigoblock pools. The contract positions are with the same group id as the token fetcher. This PR also adds base currency balances (i.e. ETH for Ethereum and so on).

Checklist

  • I have followed the Contributing Guidelines
  • (optional) As a contributor, my Ethereum address/ENS is:
  • (optional) As a contributor, my Twitter handle is:

How to test?

run locally and check the returned values from http://localhost:5001/apps/rigoblock/positions?groupIds[]=pool&network=ethereum

- append null address to tracked assets
- return base currency if positive balance as underlying token
- return base currency balance reserve
- added abstract implementation of custom contract position fetcher
- added supported chain files
- correct token definitions
- renamed imported type to allow removing of overwritten methods
- silenced undefined network warning for debugging
- since cannot override methods with different return types, injected uniswap position builder instead of inheriting uniswap position fetcher methods
- implemented missing methods in rigoblock contract fetcher
-removed commented code
- added tokens from liquidity positions in data props
- implemented getTokenBalancesPerPosition method
- use contract position template instead of custom
- implement getTokenBalancesPerPosition
- rename getBalance method to getUnderlyingBalances
- added liquidity definition as sum of USD value of liquidity positions to add to tvl
];
});
}).flat(2);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest you implement the logic fetching the underlying tokens in the getDefinitions since it's freee.

You can get the underlying token addresses by appTokens.map(x => x.tokens.map(y => y.address))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This has been done. I do not later retrieve from appToken.tokens as would require an extra RPC call. I am storing the tokens and the balances by making the onchain calls in the definitions, then saving some data that is needed in the application in dataProps and reading them from there.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why you're fetching everything in the definition, propagating it all the way down to method which retrieve balances ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The getBalances method only accepts address: string as input (please correct me if I am wrong as I would be more than happy to pass contractPosition as input in getBalances using a custom contract position fetcher to save the rpc calls), so regardless of it being a contract position template or overwriting it with a custom contract position template the onchain call is required at that level. However, in order to define the liquidity positions owned by each rigoblock pool, I have to make the same onchain call, as with the same call both underlying liquidity position tokens and balances are returned.

Copy link
Contributor

Choose a reason for hiding this comment

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

When doing a bunch of read with Multicall, there's almost no need to optimize the number of RPC calls. In getTokenDefinitions, you don't need to have the actual balances of a pool, all you need are token addresses. GetBalance has to return the balance for a specific wallet and not for a pool (I might be confused as I'm not familiar with rigoblock)

- use getUnderlyingBalances method in getDefinitions only
- pass underlying token balances to data props
- retrieve token balances per position from data props
];
});
}).flat(2);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand why you're fetching everything in the definition, propagating it all the way down to method which retrieve balances ?

@wpoulin wpoulin merged commit 4dd9051 into Zapper-fi:main Aug 26, 2023
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants