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.
feat(plutus): Add new locks, split plsJONES and plsDPX groups, add cl…
…aimables (Zapper-fi#939)
- Loading branch information
1 parent
615691e
commit 7c137e2
Showing
16 changed files
with
1,385 additions
and
93 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
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,73 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present'; | ||
import { getImagesFromToken } from '~app-toolkit/helpers/presentation/image.present'; | ||
import { ContractType } from '~position/contract.interface'; | ||
import { PositionFetcher } from '~position/position-fetcher.interface'; | ||
import { AppTokenPosition } from '~position/position.interface'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { PlutusContractFactory } from '../contracts'; | ||
import PLUTUS_DEFINITION from '../plutus.definition'; | ||
|
||
const appId = PLUTUS_DEFINITION.id; | ||
const groupId = PLUTUS_DEFINITION.groups.plsDpx.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumPlutusPlsDpxTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(PlutusContractFactory) private readonly plutusContractFactory: PlutusContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
const multicall = this.appToolkit.getMulticall(network); | ||
const baseTokens = await this.appToolkit.getBaseTokenPrices(network); | ||
const dpxToken = baseTokens.find(v => v.address === '0x6c2c06790b3e3e3c38e12ee22f8183b37a13ee55'); | ||
if (!dpxToken) return []; | ||
|
||
const plsDpxAddress = '0xf236ea74b515ef96a9898f5a4ed4aa591f253ce1'; | ||
const contract = this.plutusContractFactory.erc20({ address: plsDpxAddress, network }); | ||
const [symbol, decimals, supplyRaw] = await Promise.all([ | ||
multicall.wrap(contract).symbol(), | ||
multicall.wrap(contract).decimals(), | ||
multicall.wrap(contract).totalSupply(), | ||
]); | ||
|
||
const supply = Number(supplyRaw) / 10 ** decimals; | ||
const price = dpxToken.price; // @TODO Use pool price when peg pools are live | ||
const pricePerShare = 1; | ||
const liquidity = price * supply; | ||
const tokens = [dpxToken]; | ||
|
||
const token: AppTokenPosition = { | ||
type: ContractType.APP_TOKEN, | ||
address: plsDpxAddress, | ||
network, | ||
appId, | ||
groupId, | ||
symbol, | ||
decimals, | ||
supply, | ||
price, | ||
pricePerShare, | ||
tokens, | ||
dataProps: {}, | ||
displayProps: { | ||
label: symbol, | ||
images: getImagesFromToken(dpxToken), | ||
statsItems: [ | ||
{ | ||
label: 'Liquidity', | ||
value: buildDollarDisplayItem(liquidity), | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
return [token]; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/apps/plutus/arbitrum/plutus.pls-jones.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,73 @@ | ||
import { Inject } from '@nestjs/common'; | ||
|
||
import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; | ||
import { Register } from '~app-toolkit/decorators'; | ||
import { buildDollarDisplayItem } from '~app-toolkit/helpers/presentation/display-item.present'; | ||
import { getImagesFromToken } from '~app-toolkit/helpers/presentation/image.present'; | ||
import { ContractType } from '~position/contract.interface'; | ||
import { PositionFetcher } from '~position/position-fetcher.interface'; | ||
import { AppTokenPosition } from '~position/position.interface'; | ||
import { Network } from '~types/network.interface'; | ||
|
||
import { PlutusContractFactory } from '../contracts'; | ||
import PLUTUS_DEFINITION from '../plutus.definition'; | ||
|
||
const appId = PLUTUS_DEFINITION.id; | ||
const groupId = PLUTUS_DEFINITION.groups.plsJones.id; | ||
const network = Network.ARBITRUM_MAINNET; | ||
|
||
@Register.TokenPositionFetcher({ appId, groupId, network }) | ||
export class ArbitrumPlutusPlsJonesTokenFetcher implements PositionFetcher<AppTokenPosition> { | ||
constructor( | ||
@Inject(APP_TOOLKIT) private readonly appToolkit: IAppToolkit, | ||
@Inject(PlutusContractFactory) private readonly plutusContractFactory: PlutusContractFactory, | ||
) {} | ||
|
||
async getPositions() { | ||
const multicall = this.appToolkit.getMulticall(network); | ||
const appTokens = await this.appToolkit.getAppTokenPositions({ appId: 'sushiswap', groupIds: ['pool'], network }); | ||
const jonesEthToken = appTokens.find(v => v.address === '0xe8ee01ae5959d3231506fcdef2d5f3e85987a39c'); | ||
if (!jonesEthToken) return []; | ||
|
||
const plsJonesAddress = '0xe7f6c3c1f0018e4c08acc52965e5cbff99e34a44'; | ||
const contract = this.plutusContractFactory.erc20({ address: plsJonesAddress, network }); | ||
const [symbol, decimals, supplyRaw] = await Promise.all([ | ||
multicall.wrap(contract).symbol(), | ||
multicall.wrap(contract).decimals(), | ||
multicall.wrap(contract).totalSupply(), | ||
]); | ||
|
||
const supply = Number(supplyRaw) / 10 ** decimals; | ||
const price = jonesEthToken.price; // @TODO Use pool price when peg pools are live | ||
const pricePerShare = 1; | ||
const liquidity = price * supply; | ||
const tokens = [jonesEthToken]; | ||
|
||
const token: AppTokenPosition = { | ||
type: ContractType.APP_TOKEN, | ||
address: plsJonesAddress, | ||
network, | ||
appId, | ||
groupId, | ||
symbol, | ||
decimals, | ||
supply, | ||
price, | ||
pricePerShare, | ||
tokens, | ||
dataProps: {}, | ||
displayProps: { | ||
label: symbol, | ||
images: getImagesFromToken(jonesEthToken), | ||
statsItems: [ | ||
{ | ||
label: 'Liquidity', | ||
value: buildDollarDisplayItem(liquidity), | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
return [token]; | ||
} | ||
} |
Oops, something went wrong.