Skip to content

Commit

Permalink
feat(sushiswap-kashi): Extract to Studio, fix Polygon (Zapper-fi#942)
Browse files Browse the repository at this point in the history
  • Loading branch information
immasandwich committed Jul 24, 2022
1 parent 52a4384 commit 85dce04
Show file tree
Hide file tree
Showing 20 changed files with 3,673 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/apps/polygon/ethereum/polygon.balance-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { POLYGON_DEFINITION } from '../polygon.definition';

import { PolygonStakingContractPositionDataProps } from './polygon.staking.contract-position-fetcher';

type Eth2DepositsResponse = {
type DelegatedMaticResponse = {
delegators: {
validatorId: string;
delegatedAmount: string;
Expand All @@ -39,7 +39,7 @@ export class EthereumPolygonBalanceFetcher implements BalanceFetcher {
constructor(@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit) {}

async getDelegatedBalances(address: string) {
const data = await this.appToolkit.helpers.theGraphHelper.gqlFetchAll<Eth2DepositsResponse>({
const data = await this.appToolkit.helpers.theGraphHelper.gqlFetchAll<DelegatedMaticResponse>({
endpoint: GQL_ENDPOINT,
query: DELEGATED_MATIC_QUERY,
dataToSearch: 'delegators',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Inject } from '@nestjs/common';

import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper';
import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition';

const appId = SUSHISWAP_KASHI_DEFINITION.id;
const network = Network.ARBITRUM_MAINNET;

@Register.BalanceFetcher(appId, network)
export class ArbitrumSushiswapKashiBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(SushiSwapKashiLendingBalanceHelper)
private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper,
) {}

async getBalances(address: string) {
const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({
network,
address,
});

return presentBalanceFetcherResponse([
{
label: 'Lending',
assets: balances,
},
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Inject } from '@nestjs/common';

import { Register } from '~app-toolkit/decorators';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper';
import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition';

const appId = SUSHISWAP_KASHI_DEFINITION.id;
const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id;
const network = Network.ARBITRUM_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class ArbitrumSushiswapKashiLendingTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper,
) {}

getPositions() {
return this.lendingTokenHelper.getTokens({
network,
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/arbitrum-bentobox',
subgraphVersion: 1,
first: 1000,
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Inject } from '@nestjs/common';

import { Register } from '~app-toolkit/decorators';
import { presentBalanceFetcherResponse } from '~app-toolkit/helpers/presentation/balance-fetcher-response.present';
import { BalanceFetcher } from '~balance/balance-fetcher.interface';
import { Network } from '~types/network.interface';

import { SushiSwapKashiLendingBalanceHelper } from '../helpers/sushiswap-kashi.lending.balance-helper';
import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition';

const appId = SUSHISWAP_KASHI_DEFINITION.id;
const network = Network.BINANCE_SMART_CHAIN_MAINNET;

@Register.BalanceFetcher(appId, network)
export class BinanceSmartChainSushiswapKashiBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(SushiSwapKashiLendingBalanceHelper)
private readonly sushiSwapKashiLendingBalanceHelper: SushiSwapKashiLendingBalanceHelper,
) {}

async getBalances(address: string) {
const balances = await this.sushiSwapKashiLendingBalanceHelper.getBalances({
network,
address,
});

return presentBalanceFetcherResponse([
{
label: 'Lending',
assets: balances,
},
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Inject } from '@nestjs/common';

import { Register } from '~app-toolkit/decorators';
import { PositionFetcher } from '~position/position-fetcher.interface';
import { AppTokenPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { SushiswapKashiLendingTokenHelper } from '../helpers/sushiswap-kashi.lending.token-helper';
import { SUSHISWAP_KASHI_DEFINITION } from '../sushiswap-kashi.definition';

const appId = SUSHISWAP_KASHI_DEFINITION.id;
const groupId = SUSHISWAP_KASHI_DEFINITION.groups.lending.id;
const network = Network.BINANCE_SMART_CHAIN_MAINNET;

@Register.TokenPositionFetcher({ appId, groupId, network })
export class BinanceSmartChainSushiswapKashiLendingTokenFetcher implements PositionFetcher<AppTokenPosition> {
constructor(
@Inject(SushiswapKashiLendingTokenHelper) private readonly lendingTokenHelper: SushiswapKashiLendingTokenHelper,
) {}

getPositions() {
return this.lendingTokenHelper.getTokens({
network,
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/bsc-bentobox',
subgraphVersion: 1,
first: 1000,
});
}
}

0 comments on commit 85dce04

Please sign in to comment.