forked from Zapper-fi/studio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:0xrmvdao/studio
- Loading branch information
Showing
173 changed files
with
20,182 additions
and
3,172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { applyDecorators, SetMetadata } from '@nestjs/common'; | ||
|
||
export const BALANCE_PRESENTER_GROUP_LABEL = 'BALANCE_PRESENTER_GROUP_LABEL'; | ||
|
||
export const GroupMeta = (groupLabel: string) => { | ||
return applyDecorators(SetMetadata(BALANCE_PRESENTER_GROUP_LABEL, groupLabel)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/apps/badger/arbitrum/badger.claimable.contract-position-balance-fetcher.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,33 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import Axios from 'axios'; | ||
import { values } from 'lodash'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { CURVE_DEFINITION } from '~apps/curve/curve.definition'; | ||
import { CacheOnInterval } from '~cache/cache-on-interval.decorator'; | ||
import { PositionFetcher } from '~position/position-fetcher.interface'; | ||
import { AppTokenPosition } from '~position/position.interface'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { BADGER_DEFINITION } from '../badger.definition'; | ||
import { BadgerContractFactory, BadgerSett } from '../contracts'; | ||
import { BadgerVaultTokenDefinitionsResolver } from '../helpers/badger.vault.token-definition-resolver'; | ||
import { BadgerVaultTokenHelper } from '../helpers/badger.vault.token-helper'; | ||
|
||
const appId = BADGER_DEFINITION.id; | ||
const groupId = BADGER_DEFINITION.groups.vault.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
export type BadgerApiTokensResponseEntry = { | ||
address: string; | ||
decimals: number; | ||
name: string; | ||
symbol: string; | ||
type: string; | ||
vaultToken: { | ||
address: string; | ||
network: string; | ||
}; | ||
}; | ||
|
||
export type BadgerApiTokensResponse = Record<string, BadgerApiTokensResponseEntry>; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumBadgerVaultTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor(@Inject(BadgerVaultTokenHelper) private readonly badgerVaultTokenHelper: BadgerVaultTokenHelper) {} | ||
|
||
@CacheOnInterval({ | ||
key: `studio:${appId}:${groupId}:${network}:definitions`, | ||
timeout: 15 * 60 * 1000, | ||
}) | ||
async getVaultDefinitions() { | ||
const { data } = await Axios.get<BadgerApiTokensResponse>('https://api.badger.com/v2/tokens?chain=arbitrum'); | ||
const vaultDefinitions = values(data) | ||
.filter(t => t.type === 'Vault') | ||
.map(t => ({ address: t.address.toLowerCase(), underlyingAddress: t.vaultToken.address.toLowerCase() })); | ||
return vaultDefinitions; | ||
export class ArbitrumBadgerVaultTokenFetcher extends BadgerVaultTokenHelper<BadgerSett> { | ||
appId = appId; | ||
groupId = groupId; | ||
network = network; | ||
|
||
constructor( | ||
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, | ||
@Inject(BadgerContractFactory) protected readonly contractFactory: BadgerContractFactory, | ||
@Inject(BadgerVaultTokenDefinitionsResolver) tokenDefinitionsResolver: BadgerVaultTokenDefinitionsResolver, | ||
) { | ||
super(appToolkit, tokenDefinitionsResolver, contractFactory); | ||
} | ||
|
||
async getPositions() { | ||
const vaultDefinitions = await this.getVaultDefinitions(); | ||
|
||
return this.badgerVaultTokenHelper.getTokens({ | ||
network, | ||
definitions: vaultDefinitions, | ||
dependencies: [ | ||
{ appId: CURVE_DEFINITION.id, groupIds: [CURVE_DEFINITION.groups.pool.id], network }, | ||
{ appId: 'sushiswap', groupIds: ['pool'], network }, | ||
{ appId: 'swapr', groupIds: ['pool'], network }, | ||
], | ||
}); | ||
getContract(address: string): BadgerSett { | ||
return this.contractFactory.badgerSett({ network: this.network, address }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 0 additions & 27 deletions
27
src/apps/badger/ethereum/badger.claimable.contract-position-balance-fetcher.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.