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

feat(sushiswap-kashi): Extract to Studio, fix Polygon #942

Merged
merged 3 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
});
}
}
Loading