This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stargate): Add wrapped ETH and Voting Escrow positions (#947)
- Loading branch information
Showing
30 changed files
with
4,403 additions
and
19 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,38 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; | ||
import { ZERO_ADDRESS } from '~app-toolkit/constants/address'; | ||
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 { StargateContractFactory, StargateEth } from '../contracts'; | ||
import { STARGATE_DEFINITION } from '../stargate.definition'; | ||
|
||
const appId = STARGATE_DEFINITION.id; | ||
const groupId = STARGATE_DEFINITION.groups.eth.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
const address = '0x915a55e36a01285a14f05de6e81ed9ce89772f8e'.toLowerCase(); | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumStargateEthTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(StargateContractFactory) private readonly contractFactory: StargateContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return await this.appToolkit.helpers.vaultTokenHelper.getTokens<StargateEth>({ | ||
appId, | ||
groupId, | ||
network, | ||
resolveVaultAddresses: () => [address], | ||
resolveContract: ({ address, network }) => this.contractFactory.stargateEth({ address, network }), | ||
resolveUnderlyingTokenAddress: () => ZERO_ADDRESS, | ||
resolveReserve: ({ multicall, contract }) => multicall.wrap(contract).totalSupply().then(Number), | ||
resolvePricePerShare: ({ underlyingToken }) => underlyingToken.price, | ||
}); | ||
} | ||
} |
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,37 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; | ||
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 { StargateContractFactory, StargateVe } from '../contracts'; | ||
import { STARGATE_DEFINITION } from '../stargate.definition'; | ||
|
||
const appId = STARGATE_DEFINITION.id; | ||
const groupId = STARGATE_DEFINITION.groups.ve.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
const address = '0xfbd849e6007f9bc3cc2d6eb159c045b8dc660268'.toLowerCase(); | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumStargateVeTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(StargateContractFactory) private readonly contractFactory: StargateContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return await this.appToolkit.helpers.vaultTokenHelper.getTokens<StargateVe>({ | ||
appId, | ||
groupId, | ||
network, | ||
resolveVaultAddresses: () => [address], | ||
resolveContract: ({ address, network }) => this.contractFactory.stargateVe({ address, network }), | ||
resolveUnderlyingTokenAddress: ({ multicall, contract }) => multicall.wrap(contract).token(), | ||
resolveReserve: ({ multicall, contract }) => multicall.wrap(contract).totalSupply().then(Number), | ||
resolvePricePerShare: ({ underlyingToken }) => underlyingToken.price, | ||
}); | ||
} | ||
} |
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,37 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; | ||
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 { StargateContractFactory, StargateVe } from '../contracts'; | ||
import { STARGATE_DEFINITION } from '../stargate.definition'; | ||
|
||
const appId = STARGATE_DEFINITION.id; | ||
const groupId = STARGATE_DEFINITION.groups.ve.id; | ||
const network = Network.AVALANCHE_MAINNET; | ||
|
||
const address = '0xca0f57d295bbce554da2c07b005b7d6565a58fce'.toLowerCase(); | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class AvalancheStargateVeTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(StargateContractFactory) private readonly contractFactory: StargateContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return await this.appToolkit.helpers.vaultTokenHelper.getTokens<StargateVe>({ | ||
appId, | ||
groupId, | ||
network, | ||
resolveVaultAddresses: () => [address], | ||
resolveContract: ({ address, network }) => this.contractFactory.stargateVe({ address, network }), | ||
resolveUnderlyingTokenAddress: ({ multicall, contract }) => multicall.wrap(contract).token(), | ||
resolveReserve: ({ multicall, contract }) => multicall.wrap(contract).totalSupply().then(Number), | ||
resolvePricePerShare: ({ underlyingToken }) => underlyingToken.price, | ||
}); | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
src/apps/stargate/binance-smart-chain/stargate.ve.token-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,37 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; | ||
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 { StargateContractFactory, StargateVe } from '../contracts'; | ||
import { STARGATE_DEFINITION } from '../stargate.definition'; | ||
|
||
const appId = STARGATE_DEFINITION.id; | ||
const groupId = STARGATE_DEFINITION.groups.ve.id; | ||
const network = Network.BINANCE_SMART_CHAIN_MAINNET; | ||
|
||
const address = '0xd4888870c8686c748232719051b677791dbda26d'.toLowerCase(); | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class BinanceSmartChainStargateVeTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(StargateContractFactory) private readonly contractFactory: StargateContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
return await this.appToolkit.helpers.vaultTokenHelper.getTokens<StargateVe>({ | ||
appId, | ||
groupId, | ||
network, | ||
resolveVaultAddresses: () => [address], | ||
resolveContract: ({ address, network }) => this.contractFactory.stargateVe({ address, network }), | ||
resolveUnderlyingTokenAddress: ({ multicall, contract }) => multicall.wrap(contract).token(), | ||
resolveReserve: ({ multicall, contract }) => multicall.wrap(contract).totalSupply().then(Number), | ||
resolvePricePerShare: ({ underlyingToken }) => underlyingToken.price, | ||
}); | ||
} | ||
} |
Oops, something went wrong.