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

feat: DFX integration #347

Merged
merged 12 commits into from
May 4, 2022
Merged

Conversation

kafitz
Copy link
Contributor

@kafitz kafitz commented May 3, 2022

@immasandwich
Copy link
Contributor

@kafitz Nice PR! I'll add those base tokens in the next hour.

// Denormalize big integer values
const supply = Number(supplyRaw) / 10 ** decimals;
const totalLiquidity = Number(totalLiquidityRaw) / 1e18;
const pricePerShare = 1;
Copy link
Contributor

@immasandwich immasandwich May 3, 2022

Choose a reason for hiding this comment

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

pricePerShare is a bit tricky. It's the ratio between the supply of the token and the underlying reserves. You can use something like:

const reserves = reservesRaw.map((reserveRaw, i) => Number(reserveRaw) / 10 ** tokens[i].decimals);
const pricePerShare = reserves.map(r => r / supply);

You can deconstruct the reservesRaw from the response from multicall.wrap(contract).liquidity()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix e2764f5


// Prepare display props
const [, baseToken, quoteToken] = name.split('-');
const label = `${baseToken.toUpperCase()}/${quoteToken.toUpperCase()} LP`;
Copy link
Contributor

Choose a reason for hiding this comment

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

For Uniswap V2, we set the label as UNI-V2 WETH / WBTC. Perhaps you should label DFX as:

const label = `DFX LP ${baseToken.toUpperCase()} / ${quoteToken.toUpperCase()};`

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix 024456b


return presentBalanceFetcherResponse([
{
label: 'DfxCurves',
Copy link
Contributor

Choose a reason for hiding this comment

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

DFX Curves is probably cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix 024456b

@@ -0,0 +1,38 @@
// Test address: http://localhost:5001/apps/dfx/balances?addresses[]=0x1867608e55a862e96e468b51dc6983bca8688f3d&network=ethereum
//
Copy link
Contributor

Choose a reason for hiding this comment

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

Comments not needed, you can add this to the PR description if you'd like for future reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix e2764f5

Added Polygon test addresses to original template post

@@ -0,0 +1,103 @@
// Test address: http://localhost:5001/apps/dfx/tokens?groupIds[]=dfx-curve&network=ethereum
//
import { Inject } from '@nestjs/common';
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of this file should include the groupId, so you can instead make it dfx.curve.token-fetcher.ts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix e25acbf

description: 'DFX.Finance is a decentralized foreign exchange protocol optimized for stablecoins',
url: 'https://app.dfx.finance/',
groups: {
curve: { id: 'dfx-curve', type: GroupType.TOKEN },
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to keep the key curve as the camelcase of the ID dfx-curve, i.e:

dfxCurve: { id: 'dfx-curve', type: GroupType.TOKEN },

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix 9a0983e

// Denormalize big integer values
const supply = Number(supplyRaw) / 10 ** decimals;
const totalLiquidity = Number(totalLiquidityRaw) / 1e18;
const pricePerShare = 1;
Copy link
Contributor

@immasandwich immasandwich May 3, 2022

Choose a reason for hiding this comment

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

Same comments as in the Ethereum dfx.amm.token-fetcher.ts re: pricePerShare here and label below

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PricePerShare fix e2764f5
Label fix 024456b


return presentBalanceFetcherResponse([
{
label: 'DfxCurves',
Copy link
Contributor

Choose a reason for hiding this comment

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

DFX Curves

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix 024456b

Copy link
Contributor

@immasandwich immasandwich left a comment

Choose a reason for hiding this comment

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

assets/dfx.png should be moved to assets/logo.png

}

async getBalances(address: string) {
const [curveTokenBalances] = await Promise.all([this.getCurveTokenBalances(address)]);
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably also want to add getStakingBalances here, and use the ContractPositionBalanceHelper (on this.appToolkit.helpers.contractPositionBalanceHelper) to build the staked 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.

Fix 3471340

@kafitz kafitz requested a review from immasandwich May 3, 2022 21:04
import { PolygonDfxCurveTokenFetcher } from './polygon/dfx.curve.token-fetcher';
import { PolygonDfxStakingContractPositionFetcher } from './polygon/dfx.staking.contract-position-fetcher';

@Module({
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use Register.AppModule as in the other app modules (this was a recent change on our side)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix 4ce53b4

@immasandwich immasandwich merged commit 029e3b2 into Zapper-fi:main May 4, 2022
@SamIam-0x
Copy link
Contributor

Hello @kafitz !

Looks like you did not provide an address when submitting your PR. I recognize it may have seemed kind of random that we were asking for a wallet address with a PR submission, but we are actually looking for ways to reward Studio contributors in the future.

Is there an address you’d want to provide? Could even be an empty address, if you do not have an doxxed address

Let me know! Also, if you’d like to privately provide it, feel free to shoot me a TG https://t.me/SamIAm_0x or DM on the Zapper Discord.

Thanks!
Sam

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.

3 participants