This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gmx): Migrate to templates (#1801)
- Loading branch information
1 parent
3fe9058
commit 74df378
Showing
23 changed files
with
444 additions
and
869 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; | ||
|
||
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 { GmxEsGmxTokenFetcher } from '../common/gmx.es-gmx.token-fetcher'; | ||
|
||
import { GMX_DEFINITION } from '../gmx.definition'; | ||
import { GmxEsGmxTokenHelper } from '../helpers/gmx.es-gmx.token-helper'; | ||
@PositionTemplate() | ||
export class ArbitrumGmxEsGmxTokenFetcher extends GmxEsGmxTokenFetcher { | ||
groupLabel = 'esGMX'; | ||
isExcludedFromTvl = true; | ||
|
||
const appId = GMX_DEFINITION.id; | ||
const groupId = GMX_DEFINITION.groups.esGmx.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network, options: { excludeFromTvl: true } }) | ||
export class ArbitrumGmxEsGmxTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor(@Inject(GmxEsGmxTokenHelper) private readonly gmxEsGmxTokenHelper: GmxEsGmxTokenHelper) {} | ||
|
||
async getPositions() { | ||
return this.gmxEsGmxTokenHelper.getTokens({ | ||
esGmxTokenAddress: '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', | ||
network, | ||
}); | ||
} | ||
esGmxAddress = '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca'; | ||
gmxAddress = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a'; | ||
} |
102 changes: 42 additions & 60 deletions
102
src/apps/gmx/arbitrum/gmx.farm.contract-position-fetcher.ts
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,44 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { SingleStakingFarmContractPositionHelper } from '~app-toolkit'; | ||
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 { GmxContractFactory, GmxRewardTracker } from '../contracts'; | ||
import GMX_DEFINITION from '../gmx.definition'; | ||
|
||
export const GMX_FARM = { | ||
address: '0x908c4d94d34924765f1edc22a1dd098397c59dd4', | ||
stakedTokenAddress: '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a', | ||
rewardTokenAddresses: ['0x82af49447d8a07e3bd95bd0d56f35241523fbab1', '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca'], | ||
rewardTrackerAddresses: ['0xd2d1162512f927a7e282ef43a362659e4f2a728f', '0x908c4d94d34924765f1edc22a1dd098397c59dd4'], | ||
}; | ||
|
||
export const ES_GMX_FARM = { | ||
address: '0x908c4d94d34924765f1edc22a1dd098397c59dd4', | ||
stakedTokenAddress: '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', | ||
rewardTokenAddresses: ['0x82af49447d8a07e3bd95bd0d56f35241523fbab1', '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca'], | ||
rewardTrackerAddresses: [], | ||
}; | ||
|
||
export const GLP_FARM = { | ||
address: '0x4e971a87900b931ff39d1aad67697f49835400b6', | ||
stakedTokenAddress: '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258', | ||
rewardTokenAddresses: ['0x82af49447d8a07e3bd95bd0d56f35241523fbab1', '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca'], | ||
rewardTrackerAddresses: ['0x4e971a87900b931ff39d1aad67697f49835400b6', '0x1addd80e6039594ee970e5872d247bf0414c8903'], | ||
}; | ||
|
||
export const FARMS = [GMX_FARM, ES_GMX_FARM, GLP_FARM]; | ||
|
||
const appId = GMX_DEFINITION.id; | ||
const groupId = GMX_DEFINITION.groups.farm.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.ContractPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumGmxFarmContractPositionFetcher implements PositionFetcher<ContractPosition> { | ||
constructor( | ||
@Inject(SingleStakingFarmContractPositionHelper) | ||
private readonly singleStakingFarmContractPositionHelper: SingleStakingFarmContractPositionHelper, | ||
@Inject(GmxContractFactory) | ||
private readonly gmxContractFactory: GmxContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return this.singleStakingFarmContractPositionHelper.getContractPositions<GmxRewardTracker>({ | ||
appId, | ||
groupId, | ||
network, | ||
dependencies: [ | ||
{ appId: GMX_DEFINITION.id, groupIds: [GMX_DEFINITION.groups.esGmx.id, GMX_DEFINITION.groups.glp.id], network }, | ||
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; | ||
|
||
import { GmxFarmContractPositionFetcher } from '../common/gmx.farm.contract-position-fetcher'; | ||
|
||
@PositionTemplate() | ||
export class ArbitrumGmxFarmContractPositionFetcher extends GmxFarmContractPositionFetcher { | ||
groupLabel = 'Farms'; | ||
readerAddress = '0xe725ad0ce3ecf68a7b93d8d8091e83043ff12e9a'; | ||
farms = [ | ||
{ | ||
address: '0x908c4d94d34924765f1edc22a1dd098397c59dd4', | ||
stakedTokenAddress: '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a', // GMX | ||
rewardTokenAddresses: [ | ||
'0x82af49447d8a07e3bd95bd0d56f35241523fbab1', | ||
'0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', | ||
], | ||
rewardTrackerAddresses: [ | ||
'0xd2d1162512f927a7e282ef43a362659e4f2a728f', | ||
'0x908c4d94d34924765f1edc22a1dd098397c59dd4', | ||
], | ||
}, | ||
{ | ||
address: '0x908c4d94d34924765f1edc22a1dd098397c59dd4', | ||
stakedTokenAddress: '0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', // esGMX | ||
rewardTokenAddresses: [ | ||
'0x82af49447d8a07e3bd95bd0d56f35241523fbab1', | ||
'0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', | ||
], | ||
rewardTrackerAddresses: [], | ||
}, | ||
{ | ||
address: '0x4e971a87900b931ff39d1aad67697f49835400b6', | ||
stakedTokenAddress: '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258', // GLP | ||
rewardTokenAddresses: [ | ||
'0x82af49447d8a07e3bd95bd0d56f35241523fbab1', | ||
'0xf42ae1d54fd613c9bb14810b0588faaa09a426ca', | ||
], | ||
rewardTrackerAddresses: [ | ||
'0x4e971a87900b931ff39d1aad67697f49835400b6', | ||
'0x1addd80e6039594ee970e5872d247bf0414c8903', | ||
], | ||
resolveFarmDefinitions: async () => FARMS, | ||
resolveFarmContract: ({ network, address }) => this.gmxContractFactory.gmxRewardTracker({ network, address }), | ||
resolveIsActive: () => true, | ||
resolveRois: () => ({ dailyROI: 0, weeklyROI: 0, yearlyROI: 0 }), | ||
}); | ||
} | ||
}, | ||
]; | ||
} |
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,27 +1,11 @@ | ||
import { Inject } from '@nestjs/common'; | ||
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; | ||
|
||
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 { GmxGlpTokenFetcher } from '../common/gmx.glp.token-fetcher'; | ||
@PositionTemplate() | ||
export class ArbitrumGmxGlpTokenFetcher extends GmxGlpTokenFetcher { | ||
groupLabel = 'GLP'; | ||
|
||
import GMX_DEFINITION from '../gmx.definition'; | ||
import { GmxGlpTokenHelper } from '../helpers/gmx.glp.token-helper'; | ||
|
||
const appId = GMX_DEFINITION.id; | ||
const groupId = GMX_DEFINITION.groups.glp.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumGmxGlpTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor(@Inject(GmxGlpTokenHelper) private readonly gmxGlpTokenHelper: GmxGlpTokenHelper) {} | ||
|
||
async getPositions() { | ||
return this.gmxGlpTokenHelper.getTokens({ | ||
glmManagerAddress: '0x321f653eed006ad1c29d174e17d96351bde22649', | ||
glpTokenAddress: '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258', | ||
network, | ||
blockedTokenAddresses: ['0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a'], | ||
}); | ||
} | ||
glmManagerAddress = '0x321f653eed006ad1c29d174e17d96351bde22649'; | ||
glpTokenAddress = '0x4277f8f2c384827b5273592ff7cebd9f2c1ac258'; | ||
blockedTokenAddresses = ['0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a']; | ||
} |
26 changes: 0 additions & 26 deletions
26
src/apps/gmx/arbitrum/gmx.option.contract-position-fetcher.ts
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/apps/gmx/arbitrum/gmx.perp.contract-position-fetcher.ts
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,10 @@ | ||
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; | ||
|
||
import { GmxPerpContractPositionFetcher } from '../common/gmx.perp.contract-position-fetcher'; | ||
|
||
@PositionTemplate() | ||
export class ArbitrumGmxPerpContractPositionFetcher extends GmxPerpContractPositionFetcher { | ||
groupLabel = 'Perpetuals'; | ||
vaultAddress = '0x489ee077994b6658eafa855c308275ead8097c4a'; | ||
usdcAddress = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8'; | ||
} |
Oops, something went wrong.