-
Notifications
You must be signed in to change notification settings - Fork 0
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 carbon defi in apps #1
base: main
Are you sure you want to change the base?
Conversation
src/apps/carbon-defi/ethereum/carbon-defi.strategy.contract-position-fetcher.ts
Outdated
Show resolved
Hide resolved
src/apps/carbon-defi/ethereum/carbon-defi.strategy.contract-position-fetcher.ts
Outdated
Show resolved
Hide resolved
src/apps/carbon-defi/ethereum/carbon-defi.strategy.contract-position-fetcher.ts
Outdated
Show resolved
Hide resolved
I'm opening a new comment since both other are outdated. I managed to used async getRawBalances(address: string): Promise<RawContractPositionBalance[]> {
if (address === ZERO_ADDRESS) return [];
const controller = this.getContract();
const voucher = this.factory.voucher({ address: '', network: Network.ETHEREUM_MAINNET });
// Get all strategies ids from the user
const strategyIds = await voucher.read.tokensByOwner([address, BigInt(0), BigInt(0)]);
const getAllBalances = strategyIds.map(async strategyId => {
const strategy = await controller.read.strategy([strategyId]);
return {
key: '', // Can I use strategyId ?
tokens: [
{
key: '', // What should be here ?
balance: strategy.orders[0].y.toString(),
},
{
key: '', // What should be here ?
balance: strategy.orders[1].y.toString(),
},
],
};
});
return Promise.all(getAllBalances);
} |
const pairs = await contract.read.pairs(); | ||
const getStrategies = pairs.map(pair => contract.read.strategiesByPair([...pair, BigInt(0), BigInt(0)])); | ||
const strategies = await Promise.all(getStrategies).then(matrix => matrix.flat()); | ||
return strategies.filter(isActiveStrategy).map(strategy => ({ address, strategy: strategy })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Essentially, the balances are stil propagated from the definition all the way to dataProps and then balances. The definition should not contain balances
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting the definitions (strategies in Carbon) from the contract always returns the balance.
I can remove this information from the dataProps, but I'll have to redo the call to the contract in getBalances
Is that ok ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okok get it
Thanks for your contribution. As you saw/know, studio has been archived 😢 so I'll have to grab your code and add it to our private repo for the app integration to show up. I hope you don't mind |
Sure no problem, thanks for the reviews and explanations. Since I couldn't test with the UI, could you send me a screenshot of the preview when possible? |
e6d56af
to
649fc14
Compare
Description
Add Carbon Defi as an app.
It should look like that in the UI
@wpoulin could you add this to zapper ? 🙏
Also is it possible to add this description in the app page ? I didn't find where is should be set in the code.
"The Ultimate DEX for Onchain Trading & Liquidity"
Checklist
How to test?
Run
Then check :
http://localhost:5001/apps/carbon-defi/positions?groupIds[]=strategy&network=ethereum
Should display 429 positions, each of them with exactly 2 tokens
http://localhost:5001/apps/carbon-defi/balances?addresses[]=0xb58796c7e02852D46bE2d82c7aCCd4524a43b9dE&networks[]=ethereum
Should have two positions with two tokens inside each