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

Commit

Permalink
feat: migrated sushiswap-bentobox to studio (#685)
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoulin authored Jun 20, 2022
1 parent ddb9818 commit b3f2d3a
Show file tree
Hide file tree
Showing 19 changed files with 3,441 additions and 0 deletions.
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 { SushiSwapBentoBoxContractPositionBalanceHelper } from '../helpers/sushiswap-bentobox.vault.contract-position-balance-helper';
import { SUSHISWAP_BENTOBOX_DEFINITION } from '../sushiswap-bentobox.definition';

const network = Network.ARBITRUM_MAINNET;

@Register.BalanceFetcher(SUSHISWAP_BENTOBOX_DEFINITION.id, network)
export class ArbitrumSushiSwapBentoBoxBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(SushiSwapBentoBoxContractPositionBalanceHelper)
private readonly balanceHelper: SushiSwapBentoBoxContractPositionBalanceHelper,
) {}

async getBalances(address: string) {
const balances = await this.balanceHelper.getBalances({
address,
network,
bentoBoxAddress: '0x74c764d41b77dbbb4fe771dab1939b00b146894a',
});

return presentBalanceFetcherResponse([
{
label: 'SushiSwap BentoBox',
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 { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { SushiSwapBentoBoxContractPositionHelper } from '../helpers/sushiswap-bentobox.vault.contract-position-helper';
import { SUSHISWAP_BENTOBOX_DEFINITION } from '../sushiswap-bentobox.definition';

const appId = SUSHISWAP_BENTOBOX_DEFINITION.id;
const groupId = SUSHISWAP_BENTOBOX_DEFINITION.groups.vault.id;
const network = Network.ARBITRUM_MAINNET;

@Register.ContractPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class ArbitrumSushiSwapBentoBoxContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SushiSwapBentoBoxContractPositionHelper)
private readonly positionHelper: SushiSwapBentoBoxContractPositionHelper,
) {}

async getPositions() {
return this.positionHelper.getPositions({
bentoBoxAddress: '0x74c764d41b77dbbb4fe771dab1939b00b146894a',
network,
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/arbitrum-bentobox',
});
}
}
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 { SushiSwapBentoBoxContractPositionBalanceHelper } from '../helpers/sushiswap-bentobox.vault.contract-position-balance-helper';
import { SUSHISWAP_BENTOBOX_DEFINITION } from '../sushiswap-bentobox.definition';

const network = Network.BINANCE_SMART_CHAIN_MAINNET;

@Register.BalanceFetcher(SUSHISWAP_BENTOBOX_DEFINITION.id, network)
export class BscSushiSwapBentoBoxBalanceFetcher implements BalanceFetcher {
constructor(
@Inject(SushiSwapBentoBoxContractPositionBalanceHelper)
private readonly balanceHelper: SushiSwapBentoBoxContractPositionBalanceHelper,
) {}

async getBalances(address: string) {
const balances = await this.balanceHelper.getBalances({
address,
network,
bentoBoxAddress: '0xf5bce5077908a1b7370b9ae04adc565ebd643966',
});

return presentBalanceFetcherResponse([
{
label: 'SushiSwap BentoBox',
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 { ContractPosition } from '~position/position.interface';
import { Network } from '~types/network.interface';

import { SushiSwapBentoBoxContractPositionHelper } from '../helpers/sushiswap-bentobox.vault.contract-position-helper';
import { SUSHISWAP_BENTOBOX_DEFINITION } from '../sushiswap-bentobox.definition';

const appId = SUSHISWAP_BENTOBOX_DEFINITION.id;
const groupId = SUSHISWAP_BENTOBOX_DEFINITION.groups.vault.id;
const network = Network.BINANCE_SMART_CHAIN_MAINNET;

@Register.ContractPositionFetcher({ appId, groupId, network, options: { includeInTvl: true } })
export class BscSushiSwapBentoBoxContractPositionFetcher implements PositionFetcher<ContractPosition> {
constructor(
@Inject(SushiSwapBentoBoxContractPositionHelper)
private readonly positionHelper: SushiSwapBentoBoxContractPositionHelper,
) {}

async getPositions() {
return this.positionHelper.getPositions({
bentoBoxAddress: '0xf5bce5077908a1b7370b9ae04adc565ebd643966',
network,
subgraphUrl: 'https://api.thegraph.com/subgraphs/name/sushiswap/bsc-bentobox',
});
}
}
Loading

0 comments on commit b3f2d3a

Please sign in to comment.