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

Commit

Permalink
feat(studio): Move Synthetix to a private module (#3137)
Browse files Browse the repository at this point in the history
* feat(studio): Move Synthetix to a private module

* Done
  • Loading branch information
immasandwich committed Dec 12, 2023
1 parent ca81bbe commit d5fe616
Show file tree
Hide file tree
Showing 101 changed files with 22 additions and 13,003 deletions.
4 changes: 4 additions & 0 deletions src/apps/inverse/contracts/viem.contract-factory.ts
Expand Up @@ -8,6 +8,7 @@ import {
InverseDcaVaultToken__factory,
InverseLendingPool__factory,
InverseLens__factory,
InverseStaking__factory,
} from './viem';

type ContractOpts = { address: string; network: Network };
Expand All @@ -28,4 +29,7 @@ export class InverseViemContractFactory {
inverseLens({ address, network }: ContractOpts) {
return InverseLens__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
inverseStaking({ address, network }: ContractOpts) {
return InverseStaking__factory.connect(address, this.appToolkit.getViemNetworkProvider(network));
}
}
Expand Up @@ -3,7 +3,7 @@
/* eslint-disable */
import { getContract, GetContractReturnType, PublicClient } from 'viem';

export const synthetixRewardsAbi = [
export const inverseStakingAbi = [
{
constant: true,
inputs: [
Expand Down Expand Up @@ -427,11 +427,11 @@ export const synthetixRewardsAbi = [
},
] as const;

export type SynthetixRewards = typeof synthetixRewardsAbi;
export type SynthetixRewardsContract = GetContractReturnType<SynthetixRewards, PublicClient>;
export type InverseStaking = typeof inverseStakingAbi;
export type InverseStakingContract = GetContractReturnType<InverseStaking, PublicClient>;

export class SynthetixRewards__factory {
export class InverseStaking__factory {
static connect(address: string, client: PublicClient) {
return getContract({ address, abi: synthetixRewardsAbi, publicClient: client });
return getContract({ address, abi: inverseStakingAbi, publicClient: client });
}
}
2 changes: 2 additions & 0 deletions src/apps/inverse/contracts/viem/index.ts
Expand Up @@ -6,8 +6,10 @@ export type { InverseController } from './InverseController';
export type { InverseDcaVaultToken } from './InverseDcaVaultToken';
export type { InverseLendingPool } from './InverseLendingPool';
export type { InverseLens } from './InverseLens';
export type { InverseStaking } from './InverseStaking';

export { InverseController__factory } from './InverseController';
export { InverseDcaVaultToken__factory } from './InverseDcaVaultToken';
export { InverseLendingPool__factory } from './InverseLendingPool';
export { InverseLens__factory } from './InverseLens';
export { InverseStaking__factory } from './InverseStaking';
Expand Up @@ -2,14 +2,15 @@ import { Inject } from '@nestjs/common';

import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface';
import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator';
import { SynthetixViemContractFactory } from '~apps/synthetix/contracts';
import { SynthetixRewards } from '~apps/synthetix/contracts/viem';
import { GetDataPropsParams, GetTokenBalancesParams } from '~position/template/contract-position.template.types';
import {
SingleStakingFarmDefinition,
SingleStakingFarmTemplateContractPositionFetcher,
} from '~position/template/single-staking.template.contract-position-fetcher';

import { InverseViemContractFactory } from '../contracts';
import { InverseStaking } from '../contracts/viem';

const FARMS = [
// DOLA 3CRV Curve
{
Expand All @@ -20,37 +21,37 @@ const FARMS = [
];

@PositionTemplate()
export class EthereumInverseFarmContractPositionFetcher extends SingleStakingFarmTemplateContractPositionFetcher<SynthetixRewards> {
export class EthereumInverseFarmContractPositionFetcher extends SingleStakingFarmTemplateContractPositionFetcher<InverseStaking> {
groupLabel = 'Farms';

constructor(
@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit,
@Inject(SynthetixViemContractFactory) protected readonly contractFactory: SynthetixViemContractFactory,
@Inject(InverseViemContractFactory) protected readonly contractFactory: InverseViemContractFactory,
) {
super(appToolkit);
}

getContract(address: string) {
return this.contractFactory.synthetixRewards({ address, network: this.network });
return this.contractFactory.inverseStaking({ address, network: this.network });
}

async getFarmDefinitions(): Promise<SingleStakingFarmDefinition[]> {
return FARMS;
}

async getRewardRates({ contract }: GetDataPropsParams<SynthetixRewards>) {
async getRewardRates({ contract }: GetDataPropsParams<InverseStaking>) {
return contract.read.rewardRate();
}

async getIsActive({ contract }: GetDataPropsParams<SynthetixRewards>): Promise<boolean> {
async getIsActive({ contract }: GetDataPropsParams<InverseStaking>): Promise<boolean> {
return (await contract.read.rewardRate()) > 0;
}

async getStakedTokenBalance({ address, contract }: GetTokenBalancesParams<SynthetixRewards>) {
async getStakedTokenBalance({ address, contract }: GetTokenBalancesParams<InverseStaking>) {
return contract.read.balanceOf([address]);
}

async getRewardTokenBalances({ address, contract }: GetTokenBalancesParams<SynthetixRewards>) {
async getRewardTokenBalances({ address, contract }: GetTokenBalancesParams<InverseStaking>) {
return contract.read.earned([address]);
}
}
2 changes: 0 additions & 2 deletions src/apps/inverse/inverse.module.ts
@@ -1,7 +1,6 @@
import { Module } from '@nestjs/common';

import { AbstractApp } from '~app/app.dynamic-module';
import { SynthetixViemContractFactory } from '~apps/synthetix/contracts';

import { InverseViemContractFactory } from './contracts';
import { EthereumInverseBorrowContractPositionFetcher } from './ethereum/inverse.borrow.contract-position-fetcher';
Expand All @@ -14,7 +13,6 @@ import { EthereumInverseSupplyTokenFetcher } from './ethereum/inverse.supply.tok
@Module({
providers: [
InverseViemContractFactory,
SynthetixViemContractFactory,
EthereumInverseBorrowContractPositionFetcher,
EthereumInverseClaimableContractPositionFetcher,
EthereumInverseDcaVaultTokenFetcher,
Expand Down
3 changes: 0 additions & 3 deletions src/apps/kwenta/kwenta.module.ts
Expand Up @@ -2,8 +2,6 @@ import { Module } from '@nestjs/common';

import { AbstractApp } from '~app/app.dynamic-module';

import { SynthetixViemContractFactory } from '../synthetix/contracts';

import { KwentaViemContractFactory } from './contracts';
import { OptimismKwentaEscrowV2ContractPositionFetcher } from './optimism/kwenta.escrow-v2.contract-position-fetcher';
import { OptimismKwentaEscrowContractPositionFetcher } from './optimism/kwenta.escrow.contract-position-fetcher';
Expand All @@ -15,7 +13,6 @@ import { OptimismKwentaStakingContractPositionFetcher } from './optimism/kwenta.
@Module({
providers: [
KwentaViemContractFactory,
SynthetixViemContractFactory,
OptimismKwentaPerpV1CrossMarginContractPositionFetcher,
OptimismKwentaPerpV2SmartMarginContractPositionFetcher,
OptimismKwentaStakingContractPositionFetcher,
Expand Down
Expand Up @@ -8,7 +8,6 @@ import { PositionTemplate } from '~app-toolkit/decorators/position-template.deco
import { drillBalance } from '~app-toolkit/helpers/drill-balance.helper';
import { getAppAssetImage } from '~app-toolkit/helpers/presentation/image.present';
import { gqlFetch } from '~app-toolkit/helpers/the-graph.helper';
import { SynthetixPerp } from '~apps/synthetix/contracts/viem';
import { ContractType } from '~position/contract.interface';
import { ContractPositionBalance } from '~position/position-balance.interface';
import { MetaType } from '~position/position.interface';
Expand Down Expand Up @@ -64,7 +63,7 @@ export class OptimismKwentaPerpV1CrossMarginContractPositionFetcher extends Cust
throw new Error('Method not implemented.');
}

async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<SynthetixPerp>) {
async getTokenBalancesPerPosition({ address, contract }: GetTokenBalancesParams<KwentaPerp>) {
const remainingMargin = await contract.read.remainingMargin([address]);
return [remainingMargin[0]];
}
Expand Down
3 changes: 0 additions & 3 deletions src/apps/polynomial/polynomial.module.ts
Expand Up @@ -2,8 +2,6 @@ import { Module } from '@nestjs/common';

import { AbstractApp } from '~app/app.dynamic-module';

import { SynthetixViemContractFactory } from '../synthetix/contracts';

import { PolynomialAccountResolver } from './common/polynomial.account-resolver';
import { PolynomialApiHelper } from './common/polynomial.api';
import { PolynomialViemContractFactory } from './contracts';
Expand All @@ -19,7 +17,6 @@ import { OptimismPolynomialSmartWalletContractPositionFetcher } from './optimism
PolynomialApiHelper,
PolynomialAccountResolver,
PolynomialViemContractFactory,
SynthetixViemContractFactory,
OptimismPolynomialCallSellingVaultTokenFetcher,
OptimismPolynomialCallSellingVaultQueueContractPositionFetcher,
OptimismPolynomialPutSellingVaultTokenFetcher,
Expand Down
Binary file removed src/apps/synthetix/assets/logo.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAAVE.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sADA.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAPE.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAPT.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sARB.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sATOM.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAUD.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAVAX.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sAXS.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sBCH.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sBLUR.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sBNB.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sBTC.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sCHF.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sCRV.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sDOGE.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sDOT.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sDYDX.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sDebtRatio.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sETH.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sETHBTC.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sEUR.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sFIL.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sFLOKI.png
Binary file not shown.
Binary file removed src/apps/synthetix/assets/sFLOW.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sFTM.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sGBP.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sGMX.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sINJ.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sINR.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sJPY.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sKRW.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sLDO.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sLINK.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sLTC.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sMATIC.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sNEAR.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sOIL.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sOP.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sPEPE.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sSHIB.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sSOL.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sSUI.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sTRX.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sUNI.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sUSD.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sXAG.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sXAU.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sXMR.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sXRP.png
Diff not rendered.
Binary file removed src/apps/synthetix/assets/sstETH.png
Diff not rendered.
121 changes: 0 additions & 121 deletions src/apps/synthetix/common/synthetix.loan.contract-position-fetcher.ts

This file was deleted.

0 comments on commit d5fe616

Please sign in to comment.